1 #include "libmemcached/common.h"
8 #include <libmemcached/memcached.h>
10 #include "utilities.h"
12 #define PROGRAM_NAME "memerror"
13 #define PROGRAM_DESCRIPTION "Translate a memcached errror code into a string."
17 void options_parse(int argc
, char *argv
[]);
19 static int opt_verbose
= 0;
21 int main(int argc
, char *argv
[])
23 options_parse(argc
, argv
);
28 printf("%s\n", memcached_strerror(NULL
, atoi(argv
[1])));
34 void options_parse(int argc
, char *argv
[])
39 memcached_programs_help_st help_options
[]=
44 static struct option long_options
[]=
46 {(OPTIONSTRING
)"version", no_argument
, NULL
, OPT_VERSION
},
47 {(OPTIONSTRING
)"help", no_argument
, NULL
, OPT_HELP
},
48 {(OPTIONSTRING
)"verbose", no_argument
, &opt_verbose
, OPT_VERBOSE
},
49 {(OPTIONSTRING
)"debug", no_argument
, &opt_verbose
, OPT_DEBUG
},
55 option_rv
= getopt_long(argc
, argv
, "Vhvds:", long_options
, &option_index
);
56 if (option_rv
== -1) break;
61 case OPT_VERBOSE
: /* --verbose or -v */
62 opt_verbose
= OPT_VERBOSE
;
64 case OPT_DEBUG
: /* --debug or -d */
65 opt_verbose
= OPT_DEBUG
;
67 case OPT_VERSION
: /* --version or -V */
68 version_command(PROGRAM_NAME
);
70 case OPT_HELP
: /* --help or -h */
71 help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
, long_options
, help_options
);
74 /* getopt_long already printed an error message. */