Backed out changeset 74a1c5ce90d4
[awesomized/libmemcached] / clients / memcp.c
index 5b80fd645597142dca09466721f1ac55c9c00188..0a7809f8ff1ccc4659f80082734b130548d4fadd 100644 (file)
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <sys/types.h>
@@ -22,6 +22,7 @@
 /* Prototypes */
 void options_parse(int argc, char *argv[]);
 
+static int opt_binary=0;
 static int opt_verbose= 0;
 static char *opt_servers= NULL;
 static char *opt_hash= NULL;
@@ -60,6 +61,7 @@ int main(int argc, char *argv[])
 
   memcached_server_push(memc, servers);
   memcached_server_list_free(servers);
+  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
 
   while (optind < argc) 
   {
@@ -106,7 +108,7 @@ int main(int argc, char *argv[])
       exit(1);
     }
 
-    if (read_length != sbuf.st_size);
+    if (read_length != sbuf.st_size)
     {
       fprintf(stderr, "Failure reading from file\n");
       exit(1);
@@ -172,6 +174,7 @@ void options_parse(int argc, char *argv[])
       {"add",  no_argument, NULL, OPT_ADD},
       {"replace",  no_argument, NULL, OPT_REPLACE},
       {"hash", required_argument, NULL, OPT_HASH},
+      {"binary", no_argument, NULL, OPT_BINARY},
       {0, 0, 0, 0},
     };
 
@@ -185,6 +188,9 @@ void options_parse(int argc, char *argv[])
     {
     case 0:
       break;
+    case OPT_BINARY:
+      opt_binary = 1;
+      break;
     case OPT_VERBOSE: /* --verbose or -v */
       opt_verbose = OPT_VERBOSE;
       break;