~brianaker/libmemcached/pushtest

« back to all changes in this revision

Viewing changes to libmemcached-1.2/return.h

  • Committer: Brian Aker
  • Date: 2012-10-13 11:28:52 UTC
  • mto: This revision was merged to the branch mainline in revision 1080.
  • Revision ID: brian@tangent.org-20121013112852-ebfvxrvqbyj2g2ri
Fix all include location, and drop versions of the library that were never shipped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2
 
 * 
3
 
 *  Libmemcached library
4
 
 *
5
 
 *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
6
 
 *
7
 
 *  Redistribution and use in source and binary forms, with or without
8
 
 *  modification, are permitted provided that the following conditions are
9
 
 *  met:
10
 
 *
11
 
 *      * Redistributions of source code must retain the above copyright
12
 
 *  notice, this list of conditions and the following disclaimer.
13
 
 *
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
17
 
 *  distribution.
18
 
 *
19
 
 *      * The names of its contributors may not be used to endorse or
20
 
 *  promote products derived from this software without specific prior
21
 
 *  written permission.
22
 
 *
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.
34
 
 *
35
 
 */
36
 
 
37
 
#pragma once
38
 
 
39
 
enum memcached_return_t {
40
 
  MEMCACHED_SUCCESS,
41
 
  MEMCACHED_FAILURE,
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,
54
 
  MEMCACHED_NOTSTORED,
55
 
  MEMCACHED_STORED,
56
 
  MEMCACHED_NOTFOUND,
57
 
  MEMCACHED_MEMORY_ALLOCATION_FAILURE,
58
 
  MEMCACHED_PARTIAL_READ,
59
 
  MEMCACHED_SOME_ERRORS,
60
 
  MEMCACHED_NO_SERVERS,
61
 
  MEMCACHED_END,
62
 
  MEMCACHED_DELETED,
63
 
  MEMCACHED_VALUE,
64
 
  MEMCACHED_STAT,
65
 
  MEMCACHED_ITEM,
66
 
  MEMCACHED_ERRNO,
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,
71
 
  MEMCACHED_TIMEOUT,
72
 
  MEMCACHED_BUFFERED,
73
 
  MEMCACHED_BAD_KEY_PROVIDED,
74
 
  MEMCACHED_INVALID_HOST_PROTOCOL,
75
 
  MEMCACHED_SERVER_MARKED_DEAD,
76
 
  MEMCACHED_UNKNOWN_STAT_KEY,
77
 
  MEMCACHED_E2BIG,
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,
85
 
  MEMCACHED_DEPRECATED,
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 */
90
 
};
91
 
 
92
 
#ifndef __cplusplus
93
 
typedef enum memcached_return_t memcached_return_t;
94
 
#endif
95
 
 
96
 
static inline bool memcached_success(memcached_return_t rc)
97
 
{
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);
106
 
}
107
 
 
108
 
static inline bool memcached_failed(memcached_return_t rc)
109
 
{
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);
117
 
}
118
 
 
119
 
static inline bool memcached_fatal(memcached_return_t rc)
120
 
{
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);
128
 
}
129
 
 
130
 
#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)