77c0f8586829348619b1c4081391254665ab3d32
5 #include "client_options.h"
7 static int opt_verbose
;
8 static int opt_displayflag
;
9 static char *opt_servers
;
11 int main(int argc
, char *argv
[])
20 static struct option long_options
[] =
22 {"version", no_argument
, NULL
, OPT_VERSION
},
23 {"help", no_argument
, NULL
, OPT_HELP
},
24 {"verbose", no_argument
, &opt_verbose
, OPT_VERBOSE
},
25 {"debug", no_argument
, &opt_verbose
, OPT_DEBUG
},
26 {"servers", required_argument
, NULL
, OPT_SERVERS
},
27 {"flag", no_argument
, &opt_displayflag
, OPT_FLAG
},
35 option_rv
= getopt_long(argc
, argv
, "", long_options
, &option_index
);
36 if (option_rv
== -1) break;
40 case OPT_VERSION
: /* --version */
41 printf("memcache tools, memcat, v1.0\n");
44 case OPT_HELP
: /* --help */
45 printf("useful help messages go here\n");
48 case OPT_SERVERS
: /* --servers */
49 opt_servers
= strdup(optarg
);
52 /* getopt_long already printed an error message. */
59 /* todo, turn opt_servers into something to pass to memcached_init */
60 memc
= memcached_init(NULL
);
62 for (x
= 1; x
< argc
; x
++)
64 string
= memcached_get(memc
, argv
[x
], strlen(argv
[x
]),
65 &string_length
, &flags
, &rc
);
68 printf("%.*s\n", string_length
, string
);
73 memcached_deinit(memc
);