Add ability to have version "just requested" when you initially connect.
[m6w6/libmemcached] / libmemcached / common.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * LibMemcached
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * * The names of its contributors may not be used to endorse or
22 * promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39 /*
40 Common include file for libmemached
41 */
42
43 #pragma once
44
45 #include <config.h>
46
47 #ifdef __cplusplus
48 #include <cstdio>
49 #include <cstdlib>
50 #include <cstring>
51 #include <ctime>
52 #include <cctype>
53 #include <cerrno>
54 #include <climits>
55 #else
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <time.h>
60 #include <errno.h>
61 #include <limits.h>
62 #endif
63
64 #include <fcntl.h>
65 #include <sys/types.h>
66 #include <unistd.h>
67
68 #ifdef HAVE_STRINGS_H
69 #include <strings.h>
70 #endif
71
72 #include <libmemcached-1.0/memcached.h>
73 #include <libmemcached/watchpoint.h>
74 #include <libmemcached/is.h>
75
76 #include <libmemcached/instance.h>
77 #include <libmemcached/server_instance.h>
78
79 #ifdef HAVE_POLL_H
80 #include <poll.h>
81 #else
82 #include "poll/poll.h"
83 #endif
84
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88
89 typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
90
91 #ifdef __cplusplus
92 } // extern "C"
93 #endif
94
95
96 #ifdef __cplusplus
97 org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_t server_key);
98 #endif
99
100 memcached_return_t memcached_server_execute(memcached_st *ptr,
101 memcached_server_execute_fn callback,
102 void *context);
103 /* These are private not to be installed headers */
104 #include <libmemcached/error.hpp>
105 #include <libmemcached/memory.h>
106 #include <libmemcached/io.h>
107 #ifdef __cplusplus
108 #include <libmemcached/string.hpp>
109 #include <libmemcached/memcached/protocol_binary.h>
110 #include <libmemcached/io.hpp>
111 #include <libmemcached/udp.hpp>
112 #include <libmemcached/do.hpp>
113 #include <libmemcached/socket.hpp>
114 #include <libmemcached/connect.hpp>
115 #include <libmemcached/allocators.hpp>
116 #include <libmemcached/hash.hpp>
117 #include <libmemcached/quit.hpp>
118 #include <libmemcached/instance.hpp>
119 #include <libmemcached/server.hpp>
120 #include <libmemcached/flag.hpp>
121 #include <libmemcached/behavior.hpp>
122 #include <libmemcached/sasl.hpp>
123 #include <libmemcached/server_list.hpp>
124 #endif
125 #include <libmemcached/internal.h>
126 #include <libmemcached/array.h>
127 #include <libmemcached/libmemcached_probes.h>
128 #include <libmemcached/byteorder.h>
129 #include <libmemcached/initialize_query.h>
130 #ifdef __cplusplus
131 #include <libmemcached/response.h>
132 #endif
133 #include <libmemcached/namespace.h>
134 #include <libmemcached/virtual_bucket.h>
135
136 #ifdef __cplusplus
137 #include <libmemcached/backtrace.hpp>
138 #include <libmemcached/assert.hpp>
139 #include <libmemcached/server.hpp>
140 #include <libmemcached/key.hpp>
141 #include <libmemcached/encoding_key.h>
142 #include <libmemcached/result.h>
143 #include <libmemcached/version.hpp>
144 #endif
145
146 #include <libmemcached/continuum.hpp>
147
148 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
149
150 #define likely(x) if((x))
151 #define unlikely(x) if((x))
152
153 #else
154
155 #define likely(x) if(__builtin_expect((x) != 0, 1))
156 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
157 #endif
158
159 #define MEMCACHED_BLOCK_SIZE 1024
160 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
161 #define SMALL_STRING_LEN 1024
162 #define HUGE_STRING_LEN 8196
163
164 #ifdef __cplusplus
165 extern "C" {
166 #endif
167
168 memcached_return_t run_distribution(memcached_st *ptr);
169
170 #define memcached_server_response_increment(A) (A)->cursor_active_++
171 #define memcached_server_response_decrement(A) (A)->cursor_active_--
172 #define memcached_server_response_reset(A) (A)->cursor_active_=0
173
174 #define memcached_instance_response_increment(A) (A)->cursor_active_++
175 #define memcached_instance_response_decrement(A) (A)->cursor_active_--
176 #define memcached_instance_response_reset(A) (A)->cursor_active_=0
177
178 #ifdef __cplusplus
179 }
180 #endif
181
182 #ifdef __cplusplus
183 bool memcached_purge(org::libmemcached::Instance*);
184 org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key);
185 #endif