1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
* Copyright (C) 2011 Data Differential, http://datadifferential.com/
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following disclaimer
16
* in the documentation and/or other materials provided with the
19
* * The names of its contributors may not be used to endorse or
20
* promote products derived from this software without specific prior
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
enum memcached_return_t {
42
MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only
43
MEMCACHED_CONNECTION_FAILURE,
44
MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE
45
MEMCACHED_WRITE_FAILURE,
46
MEMCACHED_READ_FAILURE,
47
MEMCACHED_UNKNOWN_READ_FAILURE,
48
MEMCACHED_PROTOCOL_ERROR,
49
MEMCACHED_CLIENT_ERROR,
50
MEMCACHED_SERVER_ERROR,
51
MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE, // DEPRECATED
52
MEMCACHED_DATA_EXISTS,
53
MEMCACHED_DATA_DOES_NOT_EXIST,
57
MEMCACHED_MEMORY_ALLOCATION_FAILURE,
58
MEMCACHED_PARTIAL_READ,
59
MEMCACHED_SOME_ERRORS,
67
MEMCACHED_FAIL_UNIX_SOCKET, // DEPRECATED
68
MEMCACHED_NOT_SUPPORTED,
69
MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */
70
MEMCACHED_FETCH_NOTFINISHED,
73
MEMCACHED_BAD_KEY_PROVIDED,
74
MEMCACHED_INVALID_HOST_PROTOCOL,
75
MEMCACHED_SERVER_MARKED_DEAD,
76
MEMCACHED_UNKNOWN_STAT_KEY,
78
MEMCACHED_INVALID_ARGUMENTS,
79
MEMCACHED_KEY_TOO_BIG,
80
MEMCACHED_AUTH_PROBLEM,
81
MEMCACHED_AUTH_FAILURE,
82
MEMCACHED_AUTH_CONTINUE,
83
MEMCACHED_PARSE_ERROR,
84
MEMCACHED_PARSE_USER_ERROR,
86
MEMCACHED_IN_PROGRESS,
87
MEMCACHED_SERVER_TEMPORARILY_DISABLED,
88
MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE,
89
MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
93
typedef enum memcached_return_t memcached_return_t;
96
static inline bool memcached_success(memcached_return_t rc)
98
return (rc == MEMCACHED_BUFFERED ||
99
rc == MEMCACHED_DELETED ||
100
rc == MEMCACHED_END ||
101
rc == MEMCACHED_ITEM ||
102
rc == MEMCACHED_STAT ||
103
rc == MEMCACHED_STORED ||
104
rc == MEMCACHED_SUCCESS ||
105
rc == MEMCACHED_VALUE);
108
static inline bool memcached_failed(memcached_return_t rc)
110
return (rc != MEMCACHED_SUCCESS &&
111
rc != MEMCACHED_END &&
112
rc != MEMCACHED_STORED &&
113
rc != MEMCACHED_STAT &&
114
rc != MEMCACHED_DELETED &&
115
rc != MEMCACHED_BUFFERED &&
116
rc != MEMCACHED_VALUE);
119
static inline bool memcached_fatal(memcached_return_t rc)
121
return (rc != MEMCACHED_SUCCESS &&
122
rc != MEMCACHED_END &&
123
rc != MEMCACHED_STORED &&
124
rc != MEMCACHED_STAT &&
125
rc != MEMCACHED_DELETED &&
126
rc != MEMCACHED_BUFFERED &&
127
rc != MEMCACHED_VALUE);
130
#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)