libmemcached/callback.cc
/*
  These functions provide data and function callback support
*/
These functions provide data and function callback support
These functions provide data and function callback support
memcached_return_t memcached_callback_set(memcached_st *ptr,
                                          const memcached_callback_t flag,
                                          const void *data)
{
  switch (flag)
  {
  case MEMCACHED_CALLBACK_PREFIX_KEY:
    {
      return memcached_set_namespace(ptr, (char*)data, data ? strlen((char*)data) : 0);
    }
  case MEMCACHED_CALLBACK_USER_DATA:
    {
      ptr->user_data= const_cast<void *>(data);
      break;
    }
  case MEMCACHED_CALLBACK_CLEANUP_FUNCTION:
    {
      memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data;
      ptr->on_cleanup= func;
      break;
    }
  case MEMCACHED_CALLBACK_CLONE_FUNCTION:
    {
      memcached_clone_fn func= *(memcached_clone_fn *)&data;
      ptr->on_clone= func;
      break;
    }
#ifdef MEMCACHED_ENABLE_DEPRECATED
  case MEMCACHED_CALLBACK_MALLOC_FUNCTION:
    {
      memcached_malloc_function func= *(memcached_malloc_fn *)&data;
      ptr->call_malloc= func;
      break;
    }
  case MEMCACHED_CALLBACK_REALLOC_FUNCTION:
    {
      memcached_realloc_function func= *(memcached_realloc_fn *)&data;
      ptr->call_realloc= func;
      break;
    }
  case MEMCACHED_CALLBACK_FREE_FUNCTION:
    {
      memcached_free_function func= *(memcached_free_fn *)&data;
      ptr->call_free= func;
      break;
    }
#endif
  case MEMCACHED_CALLBACK_GET_FAILURE:
    {
      memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data;
      ptr->get_key_failure= func;
      break;
    }
  case MEMCACHED_CALLBACK_DELETE_TRIGGER:
    {
      memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data;
      ptr->delete_trigger= func;
      break;
    }
  case MEMCACHED_CALLBACK_MAX:
    return MEMCACHED_FAILURE;
  }
  return MEMCACHED_SUCCESS;
}
memcached_return_t memcached_callback_set ( memcached_st * ptr , const memcached_callback_t flag , const void * data ) { switch ( flag ) { case MEMCACHED_CALLBACK_PREFIX_KEY : { return memcached_set_namespace ( ptr , ( char * ) data , data ? strlen ( ( char * ) data ) : 0 ) ; } case MEMCACHED_CALLBACK_USER_DATA : { ptr -> user_data = const_cast < void * > ( data ) ; break ; } case MEMCACHED_CALLBACK_CLEANUP_FUNCTION : { memcached_cleanup_fn func = * ( memcached_cleanup_fn * ) & data ; ptr -> on_cleanup = func ; break ; } case MEMCACHED_CALLBACK_CLONE_FUNCTION : { memcached_clone_fn func = * ( memcached_clone_fn * ) & data ; ptr -> on_clone = func ; break ; } #ifdef MEMCACHED_ENABLE_DEPRECATED case MEMCACHED_CALLBACK_MALLOC_FUNCTION : { memcached_malloc_function func = * ( memcached_malloc_fn * ) & data ; ptr -> call_malloc = func ; break ; } case MEMCACHED_CALLBACK_REALLOC_FUNCTION : { memcached_realloc_function func = * ( memcached_realloc_fn * ) & data ; ptr -> call_realloc = func ; break ; } case MEMCACHED_CALLBACK_FREE_FUNCTION : { memcached_free_function func = * ( memcached_free_fn * ) & data ; ptr -> call_free = func ; break ; } #endif case MEMCACHED_CALLBACK_GET_FAILURE : { memcached_trigger_key_fn func = * ( memcached_trigger_key_fn * ) & data ; ptr -> get_key_failure = func ; break ; } case MEMCACHED_CALLBACK_DELETE_TRIGGER : { memcached_trigger_delete_key_fn func = * ( memcached_trigger_delete_key_fn * ) & data ; ptr -> delete_trigger = func ; break ; } case MEMCACHED_CALLBACK_MAX : return MEMCACHED_FAILURE ; } return MEMCACHED_SUCCESS ; }
These functions provide data and function callback support
These functions provide data and function callback support