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;
39 case OPT_VERSION
: /* --version or -V */
40 printf("memcache tools, memrm, v1.0\n");
43 case OPT_HELP
: /* --help or -h */
44 printf("useful help messages go here\n");
47 case OPT_SERVERS
: /* --servers or -s */
50 case OPT_EXPIRE
: /* --expire */
51 expires
= (time_t)strtol(optarg
, (char **)NULL
, 10);
54 /* getopt_long already printed an error message. */
61 memc
= memcached_init(NULL
);
62 parse_opt_servers(memc
, opt_servers
);
64 while (optind
<= argc
)
67 printf("key: %s\nexpires: %ld\n", argv
[optind
], expires
);
69 rc
= memcached_delete(memc
, argv
[optind
], strlen(argv
[optind
]), expires
);
71 if (rc
!= MEMCACHED_SUCCESS
)
72 fprintf(stderr
, "memrm: %s: memcache error %s\n",
73 argv
[optind
], memcached_strerror(memc
, rc
));
78 memcached_deinit(memc
);