Merge in all scanner tree + virtual buckets.
[awesomized/libmemcached] / clients / memcp.c
index df3ca77e315e46fa205955fcd880c11eee697af3..bf3828ae544ba64476a36887c101c9f8fa41873d 100644 (file)
 #include <errno.h>
 #include <strings.h>
 #include <string.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <limits.h>
+
 
 #include <libmemcached/memcached.h>
 
@@ -55,17 +59,17 @@ static long strtol_wrapper(const char *nptr, int base, bool *error)
 
   /* Check for various possible errors */
 
-  if ((errno == ERANGE && (val == INTMAX_MAX || val == INTMAX_MIN))
+  if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
       || (errno != 0 && val == 0))
   {
     *error= true;
-    return 0;
+    return EXIT_SUCCESS;
   }
 
   if (endptr == nptr)
   {
     *error= true;
-    return 0;
+    return EXIT_SUCCESS;
   }
 
   *error= false;
@@ -81,6 +85,7 @@ int main(int argc, char *argv[])
   int return_code= 0;
 
   options_parse(argc, argv);
+  initialize_sockets();
 
   memc= memcached_create(NULL);
   process_hash_option(memc, opt_hash);
@@ -112,7 +117,7 @@ int main(int argc, char *argv[])
   if (!initialize_sasl(memc, opt_username, opt_passwd))
   {
     memcached_free(memc);
-    return 1;
+    return EXIT_FAILURE;
   }
 
   while (optind < argc)
@@ -183,8 +188,8 @@ int main(int argc, char *argv[])
     {
       fprintf(stderr, "memcp: %s: memcache error %s",
              ptr, memcached_strerror(memc, rc));
-      if (memc->cached_errno)
-       fprintf(stderr, " system error %s", strerror(memc->cached_errno));
+      if (memcached_last_error_errno(memc))
+       fprintf(stderr, " system error %s", strerror(memcached_last_error_errno(memc)));
       fprintf(stderr, "\n");
 
       return_code= -1;