6 static int opt_verbose
;
7 static int opt_displayflag
;
8 static char *opt_servers
;
10 int main(int argc
, char *argv
[])
18 static struct option long_options
[] =
20 {"version", no_argument
, NULL
, 257},
21 {"help", no_argument
, NULL
, 258},
22 {"verbose", no_argument
, &opt_verbose
, 1},
23 {"debug", no_argument
, &opt_verbose
, 2},
24 {"servers", required_argument
, NULL
, 259},
25 {"flag", no_argument
, &opt_displayflag
, 1},
32 option_rv
= getopt_long(argc
, argv
, "", long_options
, &option_index
);
33 if (option_rv
== -1) break;
37 case 257: /* --version */
38 printf("memcache tools, memcat, v1.0\n");
41 case 258: /* --help */
42 printf("useful help messages go here\n");
45 case 259: /* --servers */
46 opt_servers
= strdup(optarg
);
49 /* getopt_long already printed an error message. */
56 /* todo, turn opt_servers into something to pass to memcached_init */
57 memc
= memcached_init(NULL
);
59 while (optind
< argc
) {
60 string
= memcached_get(memc
, argv
[optind
], strlen(argv
[optind
]),
61 &string_length
, &flags
, &rc
);
63 printf("%.*s\n", string_length
, string
);
69 memcached_deinit(memc
);