Merging trunkg
[m6w6/libmemcached] / libmemcached-1.0 / types.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38
39 #pragma once
40
41 #ifdef __cplusplus
42 struct memcached_st;
43 struct memcached_stat_st;
44 struct memcached_analysis_st;
45 struct memcached_result_st;
46 struct memcached_array_st;
47 struct memcached_error_t;
48
49 // All of the flavors of memcache_server_st
50 struct memcached_server_st;
51 typedef const struct memcached_server_st *memcached_server_instance_st;
52 typedef struct memcached_server_st *memcached_server_list_st;
53
54 struct memcached_callback_st;
55
56 // The following two structures are internal, and never exposed to users.
57 struct memcached_string_st;
58 struct memcached_string_t;
59 struct memcached_continuum_item_st;
60
61 #else
62
63 typedef struct memcached_st memcached_st;
64 typedef struct memcached_stat_st memcached_stat_st;
65 typedef struct memcached_analysis_st memcached_analysis_st;
66 typedef struct memcached_result_st memcached_result_st;
67 typedef struct memcached_array_st memcached_array_st;
68 typedef struct memcached_error_t memcached_error_t;
69
70 // All of the flavors of memcache_server_st
71 typedef struct memcached_server_st memcached_server_st;
72 typedef const struct memcached_server_st *memcached_server_instance_st;
73 typedef struct memcached_server_st *memcached_server_list_st;
74
75 typedef struct memcached_callback_st memcached_callback_st;
76
77 // The following two structures are internal, and never exposed to users.
78 typedef struct memcached_string_st memcached_string_st;
79 typedef struct memcached_string_t memcached_string_t;
80 typedef struct memcached_continuum_item_st memcached_continuum_item_st;
81
82 #endif
83
84
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88
89 typedef memcached_return_t (*memcached_clone_fn)(memcached_st *destination, const memcached_st *source);
90 typedef memcached_return_t (*memcached_cleanup_fn)(const memcached_st *ptr);
91
92 /**
93 Memory allocation functions.
94 */
95 typedef void (*memcached_free_fn)(const memcached_st *ptr, void *mem, void *context);
96 typedef void *(*memcached_malloc_fn)(const memcached_st *ptr, const size_t size, void *context);
97 typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context);
98 typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context);
99
100
101 typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);
102 typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);
103 typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server,
104 const char *key, size_t key_length,
105 const char *value, size_t value_length,
106 void *context);
107
108 /**
109 Trigger functions.
110 */
111 typedef memcached_return_t (*memcached_trigger_key_fn)(const memcached_st *ptr,
112 const char *key, size_t key_length,
113 memcached_result_st *result);
114 typedef memcached_return_t (*memcached_trigger_delete_key_fn)(const memcached_st *ptr,
115 const char *key, size_t key_length);
116
117 typedef memcached_return_t (*memcached_dump_fn)(const memcached_st *ptr,
118 const char *key,
119 size_t key_length,
120 void *context);
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 /**
127 @note The following definitions are just here for backwards compatibility.
128 */
129 typedef memcached_return_t memcached_return;
130 typedef memcached_server_distribution_t memcached_server_distribution;
131 typedef memcached_behavior_t memcached_behavior;
132 typedef memcached_callback_t memcached_callback;
133 typedef memcached_hash_t memcached_hash;
134 typedef memcached_connection_t memcached_connection;
135 typedef memcached_clone_fn memcached_clone_func;
136 typedef memcached_cleanup_fn memcached_cleanup_func;
137 typedef memcached_execute_fn memcached_execute_function;
138 typedef memcached_server_fn memcached_server_function;
139 typedef memcached_trigger_key_fn memcached_trigger_key;
140 typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key;
141 typedef memcached_dump_fn memcached_dump_func;