Cleanup from memaslap
[awesomized/libmemcached] / clients / memstat.c
index 652421bc1dd553bb46e14e6cd17a60aa2a793ee5..765e7ab7e4b0047dc80ebea010d9d728d8e17107 100644 (file)
@@ -17,7 +17,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/mman.h>
 #include <fcntl.h>
 #include <string.h>
 #include <getopt.h>
@@ -41,10 +40,12 @@ static int opt_verbose= 0;
 static int opt_displayflag= 0;
 static int opt_analyze= 0;
 static char *opt_servers= NULL;
+static char *stat_args= NULL;
 static char *analyze_mode= NULL;
 
 static struct option long_options[]=
 {
+  {(OPTIONSTRING)"args", required_argument, NULL, OPT_STAT_ARGS},
   {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
   {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
   {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
@@ -83,6 +84,7 @@ int main(int argc, char *argv[])
   memcached_server_st *servers;
 
   options_parse(argc, argv);
+  initialize_sockets();
 
   if (! opt_servers)
   {
@@ -126,7 +128,7 @@ int main(int argc, char *argv[])
   }
   else
   {
-    rc= memcached_stat_execute(memc, NULL, stat_printer, NULL);
+    rc= memcached_stat_execute(memc, stat_args, stat_printer, NULL);
   }
 
   free(opt_servers);
@@ -332,6 +334,9 @@ static void options_parse(int argc, char *argv[])
     case OPT_SERVERS: /* --servers or -s */
       opt_servers= strdup(optarg);
       break;
+    case OPT_STAT_ARGS:
+      stat_args= strdup(optarg);
+      break;
     case OPT_ANALYZE: /* --analyze or -a */
       opt_analyze= OPT_ANALYZE;
       analyze_mode= (optarg) ? strdup(optarg) : NULL;