7
#include <libmemcached/memcached.h>
11
#define PROGRAM_NAME "memerror"
12
#define PROGRAM_DESCRIPTION "Translate a memcached errror code into a string."
16
void options_parse(int argc, char *argv[]);
18
static int opt_verbose= 0;
20
int main(int argc, char *argv[])
22
options_parse(argc, argv);
27
printf("%s\n", memcached_strerror(NULL, atoi(argv[1])));
33
void options_parse(int argc, char *argv[])
38
memcached_programs_help_st help_options[]=
43
static struct option long_options[]=
45
{"version", no_argument, NULL, OPT_VERSION},
46
{"help", no_argument, NULL, OPT_HELP},
47
{"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
48
{"debug", no_argument, &opt_verbose, OPT_DEBUG},
54
option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
55
if (option_rv == -1) break;
60
case OPT_VERBOSE: /* --verbose or -v */
61
opt_verbose = OPT_VERBOSE;
63
case OPT_DEBUG: /* --debug or -d */
64
opt_verbose = OPT_DEBUG;
66
case OPT_VERSION: /* --version or -V */
67
version_command(PROGRAM_NAME);
69
case OPT_HELP: /* --help or -h */
70
help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
73
/* getopt_long already printed an error message. */