2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
12 #include "libmemcached/common.h"
19 #include <libmemcached/memcached.h>
21 #include "utilities.h"
23 #define PROGRAM_NAME "memerror"
24 #define PROGRAM_DESCRIPTION "Translate a memcached errror code into a string."
28 void options_parse(int argc
, char *argv
[]);
30 static int opt_verbose
= 0;
32 int main(int argc
, char *argv
[])
34 options_parse(argc
, argv
);
39 printf("%s\n", memcached_strerror(NULL
, atoi(argv
[1])));
45 void options_parse(int argc
, char *argv
[])
50 memcached_programs_help_st help_options
[]=
55 static struct option long_options
[]=
57 {(OPTIONSTRING
)"version", no_argument
, NULL
, OPT_VERSION
},
58 {(OPTIONSTRING
)"help", no_argument
, NULL
, OPT_HELP
},
59 {(OPTIONSTRING
)"verbose", no_argument
, &opt_verbose
, OPT_VERBOSE
},
60 {(OPTIONSTRING
)"debug", no_argument
, &opt_verbose
, OPT_DEBUG
},
66 option_rv
= getopt_long(argc
, argv
, "Vhvds:", long_options
, &option_index
);
67 if (option_rv
== -1) break;
72 case OPT_VERBOSE
: /* --verbose or -v */
73 opt_verbose
= OPT_VERBOSE
;
75 case OPT_DEBUG
: /* --debug or -d */
76 opt_verbose
= OPT_DEBUG
;
78 case OPT_VERSION
: /* --version or -V */
79 version_command(PROGRAM_NAME
);
81 case OPT_HELP
: /* --help or -h */
82 help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
, long_options
, help_options
);
85 /* getopt_long already printed an error message. */