d6e315078749285fd56bda874cce033c8629d84b
11 #include "client_options.h"
12 #include "utilities.h"
15 void options_parse(int argc
, char *argv
[]);
17 static int opt_verbose
= 0;
18 static int opt_displayflag
= 0;
19 static char *opt_servers
= NULL
;
21 int main(int argc
, char *argv
[])
25 memc
= memcached_init(NULL
);
26 options_parse(argc
, argv
);
32 memcached_stat_st
*stat
;
33 memcached_server_st
*server_list
;
35 parse_opt_servers(memc
, opt_servers
);
36 stat
= memcached_stat(memc
, NULL
, &rc
);
38 server_list
= memcached_server_list(memc
);
40 printf("Listing %u Server\n\n", memcached_server_count(memc
));
41 for (x
= 0; x
< memcached_server_count(memc
); x
++)
46 list
= memcached_stat_get_keys(memc
, &stat
[x
], &rc
);
47 assert(rc
== MEMCACHED_SUCCESS
);
49 printf("Server: %s (%u)\n", memcached_server_name(memc
, server_list
[x
]),
50 memcached_server_port(memc
, server_list
[x
]));
51 for (ptr
= list
; *ptr
; ptr
++)
54 char *value
= memcached_stat_get_value(memc
, &stat
[x
], *ptr
, &rc
);
56 printf("\t %s: %s\n", *ptr
, value
);
68 memcached_deinit(memc
);
73 void options_parse(int argc
, char *argv
[])
75 static struct option long_options
[]=
77 {"version", no_argument
, NULL
, OPT_VERSION
},
78 {"help", no_argument
, NULL
, OPT_HELP
},
79 {"verbose", no_argument
, &opt_verbose
, OPT_VERBOSE
},
80 {"debug", no_argument
, &opt_verbose
, OPT_DEBUG
},
81 {"servers", required_argument
, NULL
, OPT_SERVERS
},
82 {"flag", no_argument
, &opt_displayflag
, OPT_FLAG
},
91 option_rv
= getopt_long(argc
, argv
, "Vhvds:", long_options
, &option_index
);
92 if (option_rv
== -1) break;
97 case OPT_VERBOSE
: /* --verbose or -v */
98 opt_verbose
= OPT_VERBOSE
;
100 case OPT_DEBUG
: /* --debug or -d */
101 opt_verbose
= OPT_DEBUG
;
103 case OPT_VERSION
: /* --version or -V */
104 printf("memcache tools, memcat, v1.0\n");
107 case OPT_HELP
: /* --help or -h */
108 printf("useful help messages go here\n");
111 case OPT_SERVERS
: /* --servers or -s */
112 opt_servers
= strdup(optarg
);
115 /* getopt_long already printed an error message. */