#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
+#include <inttypes.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <errno.h>
#include <strings.h>
#include <string.h>
-#include <assert.h>
#include <libmemcached/memcached.h>
/* 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;
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
while (optind < argc)
{
fprintf(stderr, "read: %s\n", strerror(errno));
exit(1);
}
- assert(read_length == sbuf.st_size);
+
+ if (read_length != sbuf.st_size)
+ {
+ fprintf(stderr, "Failure reading from file\n");
+ exit(1);
+ }
if (opt_method == OPT_ADD)
rc= memcached_add(memc, ptr, strlen(ptr),
{"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},
};
{
case 0:
break;
+ case OPT_BINARY:
+ opt_binary = 1;
+ break;
case OPT_VERBOSE: /* --verbose or -v */
opt_verbose = OPT_VERBOSE;
break;