X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcallback.c;h=dcb3ddeb17d0f87a3235f6b7042e8d26fa65c1bd;hb=b048aacba5d279f3271163cfaa0704684beca1e2;hp=252b4334e66166b2985def805da973457a5b9ed3;hpb=c67da677fe0944d3d2d3ff46e65fc3bc775404ae;p=awesomized%2Flibmemcached diff --git a/libmemcached/callback.c b/libmemcached/callback.c index 252b4334..dcb3ddeb 100644 --- a/libmemcached/callback.c +++ b/libmemcached/callback.c @@ -9,10 +9,8 @@ * */ -#include "common.h" +#include "libmemcached/common.h" #include -#include -#include /* These functions provide data and function callback support @@ -26,35 +24,7 @@ memcached_return_t memcached_callback_set(memcached_st *ptr, { case MEMCACHED_CALLBACK_PREFIX_KEY: { - char *key= (char *)data; - - if (key) - { - size_t key_length= strlen(key); - - if (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED) - { - return MEMCACHED_BAD_KEY_PROVIDED; - } - - if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1) - || (strcpy(ptr->prefix_key, key) == NULL)) - { - ptr->prefix_key_length= 0; - return MEMCACHED_BAD_KEY_PROVIDED; - } - else - { - ptr->prefix_key_length= key_length; - } - } - else - { - memset(ptr->prefix_key, 0, MEMCACHED_PREFIX_KEY_MAX_SIZE); - ptr->prefix_key_length= 0; - } - - break; + return memcached_set_prefix_key(ptr, (char*)data, data ? strlen((char*)data) : 0); } case MEMCACHED_CALLBACK_USER_DATA: { @@ -126,15 +96,15 @@ void *memcached_callback_get(memcached_st *ptr, { case MEMCACHED_CALLBACK_PREFIX_KEY: { - if (ptr->prefix_key[0] == 0) + if (ptr->prefix_key) { - *error= MEMCACHED_FAILURE; - return NULL; + *error= MEMCACHED_SUCCESS; + return (void *)memcached_array_string(ptr->prefix_key); } else { - *error= MEMCACHED_SUCCESS; - return (void *)ptr->prefix_key; + *error= MEMCACHED_FAILURE; + return NULL; } } case MEMCACHED_CALLBACK_USER_DATA: