X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fmemrm.c;h=81c5f852bd21a992e718b86acb44e7c6203694c6;hb=d5a64e45227450892b00a97ed611d40fd8287239;hp=203146efae04ca2df288901ec19473429c9c6a9d;hpb=4801b6fa83529ab4327b1757e2d3a7ab4670ed5b;p=m6w6%2Flibmemcached diff --git a/clients/memrm.c b/clients/memrm.c index 203146ef..81c5f852 100644 --- a/clients/memrm.c +++ b/clients/memrm.c @@ -1,3 +1,14 @@ +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: + * + */ + #include "libmemcached/common.h" #include #include @@ -17,14 +28,16 @@ static char *opt_hash= NULL; #define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster." /* Prototypes */ -void options_parse(int argc, char *argv[]); +static void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; + int return_code= 0; + options_parse(argc, argv); if (!opt_servers) @@ -48,20 +61,22 @@ int main(int argc, char *argv[]) memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) opt_binary); - - while (optind < argc) + + while (optind < argc) { - if (opt_verbose) + if (opt_verbose) printf("key: %s\nexpires: %llu\n", argv[optind], (unsigned long long)opt_expire); rc = memcached_delete(memc, argv[optind], strlen(argv[optind]), opt_expire); - if (rc != MEMCACHED_SUCCESS) + if (rc != MEMCACHED_SUCCESS) { - fprintf(stderr, "memrm: %s: memcache error %s", + fprintf(stderr, "memrm: %s: memcache error %s", argv[optind], memcached_strerror(memc, rc)); if (memc->cached_errno) fprintf(stderr, " system error %s", strerror(memc->cached_errno)); fprintf(stderr, "\n"); + + return_code= -1; } optind++; @@ -74,11 +89,11 @@ int main(int argc, char *argv[]) if (opt_hash) free(opt_hash); - return 0; + return return_code; } -void options_parse(int argc, char *argv[]) +static void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { @@ -100,7 +115,7 @@ void options_parse(int argc, char *argv[]) int option_index= 0; int option_rv; - while (1) + while (1) { option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break;