emit messages to stderr when write fails
[awesomized/libmemcached] / src / memstat.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <sys/types.h>
5 #include <sys/mman.h>
6 #include <fcntl.h>
7 #include <getopt.h>
8
9 #include <memcached.h>
10
11 #include "client_options.h"
12 #include "utilities.h"
13
14 /* Prototypes */
15 void options_parse(int argc, char *argv[]);
16
17 static int opt_verbose;
18 static int opt_displayflag;
19 static char *opt_servers;
20
21 int main(int argc, char *argv[])
22 {
23 memcached_st *memc;
24
25 memc= memcached_init(NULL);
26 options_parse(argc, argv);
27
28 parse_opt_servers(memc, opt_servers);
29
30 memcached_deinit(memc);
31
32 return 0;
33 }
34
35 void options_parse(int argc, char *argv[])
36 {
37 static struct option long_options[]=
38 {
39 {"version", no_argument, NULL, OPT_VERSION},
40 {"help", no_argument, NULL, OPT_HELP},
41 {"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
42 {"debug", no_argument, &opt_verbose, OPT_DEBUG},
43 {"servers", required_argument, NULL, OPT_SERVERS},
44 {"flag", no_argument, &opt_displayflag, OPT_FLAG},
45 {0, 0, 0, 0},
46 };
47
48 int option_index= 0;
49 int option_rv;
50
51 while (1)
52 {
53 option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
54 if (option_rv == -1) break;
55 switch (option_rv)
56 {
57 case 0:
58 break;
59 case OPT_VERBOSE: /* --verbose or -v */
60 opt_verbose = OPT_VERBOSE;
61 break;
62 case OPT_DEBUG: /* --debug or -d */
63 opt_verbose = OPT_DEBUG;
64 break;
65 case OPT_VERSION: /* --version or -V */
66 printf("memcache tools, memcat, v1.0\n");
67 exit(0);
68 break;
69 case OPT_HELP: /* --help or -h */
70 printf("useful help messages go here\n");
71 exit(0);
72 break;
73 case OPT_SERVERS: /* --servers or -s */
74 opt_servers= optarg;
75 break;
76 case '?':
77 /* getopt_long already printed an error message. */
78 exit(1);
79 default:
80 abort();
81 }
82 }
83 }