6deca09bb0731ed2c3125f8229c436479d895d4a
5 #include "client_options.h"
7 static int opt_verbose
;
8 static char *opt_servers
;
10 int main(int argc
, char *argv
[])
18 static struct option long_options
[] =
20 {"version", no_argument
, NULL
, OPT_VERSION
},
21 {"help", no_argument
, NULL
, OPT_HELP
},
22 {"verbose", no_argument
, &opt_verbose
, 1},
23 {"debug", no_argument
, &opt_verbose
, 2},
24 {"servers", required_argument
, NULL
, OPT_SERVERS
},
25 {"expire", required_argument
, NULL
, OPT_EXPIRE
},
33 option_rv
= getopt_long(argc
, argv
, "Vhvds:", long_options
, &option_index
);
34 if (option_rv
== -1) break;
38 case OPT_VERSION
: /* --version or -V */
39 printf("memcache tools, memrm, v1.0\n");
42 case OPT_HELP
: /* --help or -h */
43 printf("useful help messages go here\n");
46 case OPT_SERVERS
: /* --servers or -s */
49 case OPT_EXPIRE
: /* --expire */
50 expires
= (time_t)strtol(optarg
, (char **)NULL
, 10);
53 /* getopt_long already printed an error message. */
60 memc
= memcached_init(NULL
);
61 parse_opt_servers(memc
, opt_servers
);
63 while (optind
<= argc
)
66 printf("key: %s\nexpires: %ld\n", argv
[optind
], expires
);
68 rc
= memcached_delete(memc
, argv
[optind
], strlen(argv
[optind
]), expires
);
72 memcached_deinit(memc
);