3 #include <sys/socket.h>
4 #include <netinet/tcp.h>
7 These functions provide data and function callback support
10 memcached_return
memcached_callback_set(memcached_st
*ptr
,
11 memcached_callback flag
,
16 case MEMCACHED_CALLBACK_USER_DATA
:
21 case MEMCACHED_CALLBACK_CLEANUP_FUNCTION
:
23 memcached_cleanup_func func
= (memcached_cleanup_func
)data
;
24 ptr
->on_cleanup
= func
;
27 case MEMCACHED_CALLBACK_CLONE_FUNCTION
:
29 memcached_clone_func func
= (memcached_clone_func
)data
;
33 case MEMCACHED_CALLBACK_MALLOC_FUNCTION
:
35 memcached_malloc_function func
= (memcached_malloc_function
)data
;
36 ptr
->call_malloc
= func
;
39 case MEMCACHED_CALLBACK_REALLOC_FUNCTION
:
41 memcached_realloc_function func
= (memcached_realloc_function
)data
;
42 ptr
->call_realloc
= func
;
45 case MEMCACHED_CALLBACK_FREE_FUNCTION
:
47 memcached_free_function func
= (memcached_free_function
)data
;
51 case MEMCACHED_CALLBACK_GET_FAILURE
:
53 memcached_trigger_key func
= (memcached_trigger_key
)data
;
54 ptr
->get_key_failure
= func
;
58 return MEMCACHED_FAILURE
;
61 return MEMCACHED_SUCCESS
;
64 void *memcached_callback_get(memcached_st
*ptr
,
65 memcached_callback flag
,
66 memcached_return
*error
)
68 memcached_return local_error
;
74 case MEMCACHED_CALLBACK_USER_DATA
:
76 *error
= ptr
->user_data
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
77 return (void *)ptr
->user_data
;
79 case MEMCACHED_CALLBACK_CLEANUP_FUNCTION
:
81 *error
= ptr
->on_cleanup
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
82 return (void *)ptr
->on_cleanup
;
84 case MEMCACHED_CALLBACK_CLONE_FUNCTION
:
86 *error
= ptr
->on_clone
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
87 return (void *)ptr
->on_clone
;
89 case MEMCACHED_CALLBACK_MALLOC_FUNCTION
:
91 *error
= ptr
->call_malloc
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
92 return (void *)ptr
->call_malloc
;
94 case MEMCACHED_CALLBACK_REALLOC_FUNCTION
:
96 *error
= ptr
->call_realloc
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
97 return (void *)ptr
->call_realloc
;
99 case MEMCACHED_CALLBACK_FREE_FUNCTION
:
101 *error
= ptr
->call_free
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
102 return (void *)ptr
->call_free
;
104 case MEMCACHED_CALLBACK_GET_FAILURE
:
106 *error
= ptr
->get_key_failure
? MEMCACHED_SUCCESS
: MEMCACHED_FAILURE
;
107 return (void *)ptr
->get_key_failure
;
110 WATCHPOINT_ASSERT(0);
111 *error
= MEMCACHED_FAILURE
;