Cleanup.
[awesomized/libmemcached] / src / memstat.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <sys/types.h>
5 #include <sys/mman.h>
6 #include <fcntl.h>
7 #include <getopt.h>
8
9 #include <memcached.h>
10
11 #include "client_options.h"
12 #include "utilities.h"
13
14 /* Prototypes */
15 void options_parse(int argc, char *argv[]);
16
17 static int opt_verbose;
18 static int opt_displayflag;
19 static char *opt_servers;
20
21 int main(int argc, char *argv[])
22 {
23 memcached_st *memc;
24
25 memc= memcached_init(NULL);
26 options_parse(argc, argv);
27
28 parse_opt_servers(memc, opt_servers);
29
30 memcached_deinit(memc);
31
32 return 0;
33 }
34
35 void options_parse(int argc, char *argv[])
36 {
37 static struct option long_options[] =
38 {
39 {"version", no_argument, NULL, OPT_VERSION},
40 {"help", no_argument, NULL, OPT_HELP},
41 {"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
42 {"debug", no_argument, &opt_verbose, OPT_DEBUG},
43 {"servers", required_argument, NULL, OPT_SERVERS},
44 {"flag", no_argument, &opt_displayflag, OPT_FLAG},
45 {0, 0, 0, 0},
46 };
47
48 int option_index = 0;
49 int option_rv;
50
51 while (1)
52 {
53 option_rv = getopt_long(argc, argv, "", long_options, &option_index);
54 if (option_rv == -1) break;
55 switch (option_rv) {
56 case 0:
57 break;
58 case OPT_VERSION: /* --version */
59 printf("memcache tools, memcat, v1.0\n");
60 exit(0);
61 break;
62 case OPT_HELP: /* --help */
63 printf("useful help messages go here\n");
64 exit(0);
65 break;
66 case OPT_SERVERS: /* --servers */
67 opt_servers = optarg;
68 break;
69 case '?':
70 /* getopt_long already printed an error message. */
71 exit(1);
72 default:
73 abort();
74 }
75 }
76 }