dedcb94595e5bc79f9417c0cefaffe17aeaa68f6
6 #include "client_options.h"
11 void options_parse(int argc
, char *argv
[]);
13 static int opt_verbose
;
14 static int opt_displayflag
;
15 static char *opt_servers
;
17 int main(int argc
, char *argv
[])
26 memc
= memcached_init(NULL
);
28 options_parse(argc
, argv
);
30 parse_opt_servers(memc
, opt_servers
);
32 for (x
= 1; x
< argc
; x
++)
34 string
= memcached_get(memc
, argv
[x
], strlen(argv
[x
]),
35 &string_length
, &flags
, &rc
);
36 if (rc
== MEMCACHED_SUCCESS
) {
37 if (opt_displayflag
) {
38 printf("%d\n", flags
);
42 printf("%.*s\n", string_length
, string
);
49 memcached_deinit(memc
);
55 void options_parse(int argc
, char *argv
[])
60 static struct option long_options
[] =
62 {"version", no_argument
, NULL
, OPT_VERSION
},
63 {"help", no_argument
, NULL
, OPT_HELP
},
64 {"verbose", no_argument
, &opt_verbose
, OPT_VERBOSE
},
65 {"debug", no_argument
, &opt_verbose
, OPT_DEBUG
},
66 {"servers", required_argument
, NULL
, OPT_SERVERS
},
67 {"flag", no_argument
, &opt_displayflag
, OPT_FLAG
},
73 option_rv
= getopt_long(argc
, argv
, "", long_options
, &option_index
);
74 if (option_rv
== -1) break;
78 case OPT_VERSION
: /* --version */
79 printf("memcache tools, memcat, v1.0\n");
82 case OPT_HELP
: /* --help */
83 printf("useful help messages go here\n");
86 case OPT_SERVERS
: /* --servers */
87 opt_servers
= strdup(optarg
);
90 /* getopt_long already printed an error message. */