X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fmemtouch.cc;h=09e0c92a2074fb87479960f81d44d1d25f4b48ac;hb=585b2385384b32af964b5f2f999e70173b33a460;hp=8bb3c78c3904ec73d31b59ba3e5e1d6f4c349893;hpb=2569efffe16042f47dc5d2c34528a9ec22fc18b0;p=awesomized%2Flibmemcached diff --git a/clients/memtouch.cc b/clients/memtouch.cc index 8bb3c78c..09e0c92a 100644 --- a/clients/memtouch.cc +++ b/clients/memtouch.cc @@ -10,19 +10,21 @@ * */ -#include +#include +#include #include #include #include #include #include + #include #include "utilities.h" #define PROGRAM_NAME "memtouch" -#define PROGRAM_DESCRIPTION "Update the expiration value of an alreasy existing value in the sever" +#define PROGRAM_DESCRIPTION "Update the expiration value of an already existing value in the server" /* Prototypes */ @@ -52,18 +54,24 @@ int main(int argc, char *argv[]) { opt_servers= strdup(temp); } - else + + if (opt_servers == NULL) { std::cerr << "No Servers provided" << std::endl; - return EXIT_FAILURE; + exit(EXIT_FAILURE); } } + memcached_server_st* servers= memcached_servers_parse(opt_servers); + if (servers == NULL or memcached_server_list_count(servers) == 0) + { + std::cerr << "Invalid server list provided:" << opt_servers << std::endl; + return EXIT_FAILURE; + } + memcached_st *memc= memcached_create(NULL); process_hash_option(memc, opt_hash); - memcached_server_st *servers= memcached_servers_parse(opt_servers); - memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, @@ -212,7 +220,13 @@ void options_parse(int argc, char *argv[]) break; case OPT_EXPIRE: + errno= 0; expiration= time_t(strtoul(optarg, (char **)NULL, 10)); + if (errno != 0) + { + fprintf(stderr, "Invalid value for --expire: %s\n", optarg); + exit(EXIT_FAILURE); + } break; case OPT_QUIET: