Blame libmemcached-1.0/return.h

Packit 83fed9
/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
Packit 83fed9
 * 
Packit 83fed9
 *  Libmemcached library
Packit 83fed9
 *
Packit 83fed9
 *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
Packit 83fed9
 *
Packit 83fed9
 *  Redistribution and use in source and binary forms, with or without
Packit 83fed9
 *  modification, are permitted provided that the following conditions are
Packit 83fed9
 *  met:
Packit 83fed9
 *
Packit 83fed9
 *      * Redistributions of source code must retain the above copyright
Packit 83fed9
 *  notice, this list of conditions and the following disclaimer.
Packit 83fed9
 *
Packit 83fed9
 *      * Redistributions in binary form must reproduce the above
Packit 83fed9
 *  copyright notice, this list of conditions and the following disclaimer
Packit 83fed9
 *  in the documentation and/or other materials provided with the
Packit 83fed9
 *  distribution.
Packit 83fed9
 *
Packit 83fed9
 *      * The names of its contributors may not be used to endorse or
Packit 83fed9
 *  promote products derived from this software without specific prior
Packit 83fed9
 *  written permission.
Packit 83fed9
 *
Packit 83fed9
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 83fed9
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 83fed9
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 83fed9
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 83fed9
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 83fed9
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 83fed9
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 83fed9
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 83fed9
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 83fed9
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 83fed9
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 83fed9
 *
Packit 83fed9
 */
Packit 83fed9
Packit 83fed9
#pragma once
Packit 83fed9
Packit 83fed9
static inline bool memcached_success(memcached_return_t rc)
Packit 83fed9
{
Packit 83fed9
  return (rc == MEMCACHED_BUFFERED ||
Packit 83fed9
          rc == MEMCACHED_DELETED ||
Packit 83fed9
          rc == MEMCACHED_END || 
Packit 83fed9
          rc == MEMCACHED_ITEM || 
Packit 83fed9
          rc == MEMCACHED_STAT || 
Packit 83fed9
          rc == MEMCACHED_STORED || 
Packit 83fed9
          rc == MEMCACHED_SUCCESS || 
Packit 83fed9
          rc == MEMCACHED_VALUE);
Packit 83fed9
}
Packit 83fed9
Packit 83fed9
static inline bool memcached_failed(memcached_return_t rc)
Packit 83fed9
{
Packit 83fed9
  return (rc != MEMCACHED_SUCCESS && 
Packit 83fed9
          rc != MEMCACHED_END && 
Packit 83fed9
          rc != MEMCACHED_STORED && 
Packit 83fed9
          rc != MEMCACHED_STAT && 
Packit 83fed9
          rc != MEMCACHED_DELETED &&
Packit 83fed9
          rc != MEMCACHED_BUFFERED &&
Packit 83fed9
          rc != MEMCACHED_VALUE);
Packit 83fed9
}
Packit 83fed9
Packit 83fed9
static inline bool memcached_fatal(memcached_return_t rc)
Packit 83fed9
{
Packit 83fed9
  return (
Packit 83fed9
          rc != MEMCACHED_BUFFERED &&
Packit 83fed9
          rc != MEMCACHED_CLIENT_ERROR &&
Packit 83fed9
          rc != MEMCACHED_DATA_EXISTS &&
Packit 83fed9
          rc != MEMCACHED_DELETED &&
Packit 83fed9
          rc != MEMCACHED_E2BIG && 
Packit 83fed9
          rc != MEMCACHED_END && 
Packit 83fed9
          rc != MEMCACHED_ITEM &&
Packit 83fed9
          rc != MEMCACHED_ERROR &&
Packit 83fed9
          rc != MEMCACHED_NOTFOUND && 
Packit 83fed9
          rc != MEMCACHED_NOTSTORED && 
Packit 83fed9
          rc != MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE && 
Packit 83fed9
          rc != MEMCACHED_STAT && 
Packit 83fed9
          rc != MEMCACHED_STORED && 
Packit 83fed9
          rc != MEMCACHED_SUCCESS && 
Packit 83fed9
          rc != MEMCACHED_VALUE);
Packit 83fed9
}
Packit 83fed9
Packit 83fed9
#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)