Merge in check (i.e. we are going to put a lock in it to make sure any concurrent...
[m6w6/libmemcached] / libmemcached / return.h
index 3b7875c529bf13752cc0fd6d5dab6ab9ecd6d804..d45d2e853e570d0ca24a8c6559fec5fba92f558b 100644 (file)
@@ -39,9 +39,9 @@
 enum memcached_return_t {
   MEMCACHED_SUCCESS,
   MEMCACHED_FAILURE,
-  MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() only
-  MEMCACHED_CONNECTION_FAILURE,  // DEPRECATED
-  MEMCACHED_CONNECTION_BIND_FAILURE,  // DEPRECATED
+  MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only
+  MEMCACHED_CONNECTION_FAILURE,
+  MEMCACHED_CONNECTION_BIND_FAILURE,  // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE
   MEMCACHED_WRITE_FAILURE,
   MEMCACHED_READ_FAILURE,
   MEMCACHED_UNKNOWN_READ_FAILURE,
@@ -83,6 +83,7 @@ enum memcached_return_t {
   MEMCACHED_PARSE_ERROR,
   MEMCACHED_PARSE_USER_ERROR,
   MEMCACHED_DEPRECATED,
+  MEMCACHED_IN_PROGRESS,
   MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
 };
 
@@ -90,7 +91,27 @@ enum memcached_return_t {
 typedef enum memcached_return_t memcached_return_t;
 #endif
 
+static inline bool memcached_success(memcached_return_t rc)
+{
+  return (rc == MEMCACHED_BUFFERED ||
+          rc == MEMCACHED_DELETED ||
+          rc == MEMCACHED_END || 
+          rc == MEMCACHED_ITEM || 
+          rc == MEMCACHED_STAT || 
+          rc == MEMCACHED_STORED || 
+          rc == MEMCACHED_SUCCESS || 
+          rc == MEMCACHED_VALUE);
+}
 
-#define memcached_success(X) (X) == MEMCACHED_SUCCESS ? true : false
-#define memcached_failed(A) (A) != MEMCACHED_SUCCESS ? true : false
+static inline bool memcached_failed(memcached_return_t rc)
+{
+  return (rc != MEMCACHED_SUCCESS && 
+          rc != MEMCACHED_END && 
+          rc != MEMCACHED_STORED && 
+          rc != MEMCACHED_STAT && 
+          rc != MEMCACHED_DELETED &&
+          rc != MEMCACHED_BUFFERED &&
+          rc != MEMCACHED_VALUE);
+}
 
+#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)