1 #ifndef MEMCACHED_TYPES_H 2 #define MEMCACHED_TYPES_H 1 3 4 #include <sys/types.h> 5 #include <stdint.h> 6 7 #ifdef __WIN32__ 8 struct iovec { 9 size_t iov_len; 10 void* iov_base; 11 }; 12 #else 13 #include <sys/uio.h> 14 #endif 15 16 #ifndef bool 17 #define bool char 18 #define false 0 19 #define true 1 20 #endif 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * Time relative to server start. Smaller than time_t on 64-bit systems. 28 */ 29 typedef uint32_t rel_time_t; 30 31 /** 32 * Response codes for engine operations. 33 */ 34 typedef enum { 35 ENGINE_SUCCESS = 0x00, /**< The command executed successfully */ 36 ENGINE_KEY_ENOENT = 0x01, /**< The key does not exists */ 37 ENGINE_KEY_EEXISTS = 0x02, /**< The key already exists */ 38 ENGINE_ENOMEM = 0x03, /**< Could not allocate memory */ 39 ENGINE_NOT_STORED = 0x04, /**< The item was not stored */ 40 ENGINE_EINVAL = 0x05, /**< Invalid arguments */ 41 ENGINE_ENOTSUP = 0x06, /**< The engine does not support this */ 42 ENGINE_EWOULDBLOCK = 0x07, /**< This would cause the engine to block */ 43 ENGINE_E2BIG = 0x08, /**< The data is too big for the engine */ 44 ENGINE_WANT_MORE = 0x09, /**< The engine want more data if the frontend 45 * have more data available. */ 46 ENGINE_DISCONNECT = 0x0a, /**< Tell the server to disconnect this client */ 47 ENGINE_EACCESS = 0x0b, /**< Access control violations */ 48 ENGINE_NOT_MY_VBUCKET = 0x0c, /** < This vbucket doesn't belong to me */ 49 ENGINE_TMPFAIL = 0x0d, /**< Temporary failure, please try again later */ 50 ENGINE_FAILED = 0xff /**< Generic failue. */ 51 } ENGINE_ERROR_CODE; 52 53 /** 54 * Engine storage operations. 55 */ 56 typedef enum { 57 OPERATION_ADD = 1, /**< Store with add semantics */ 58 OPERATION_SET, /**< Store with set semantics */ 59 OPERATION_REPLACE, /**< Store with replace semantics */ 60 OPERATION_APPEND, /**< Store with append semantics */ 61 OPERATION_PREPEND, /**< Store with prepend semantics */ 62 OPERATION_CAS /**< Store with set semantics. */ 63 } ENGINE_STORE_OPERATION; 64 65 /** 66 * Data common to any item stored in memcached. 67 */ 68 typedef void item; 69 70 typedef struct { 71 uint64_t cas; 72 rel_time_t exptime; /**< When the item will expire (relative to process 73 * startup) */ 74 uint32_t nbytes; /**< The total size of the data (in bytes) */ 75 uint32_t flags; /**< Flags associated with the item (in network byte order)*/ 76 uint8_t clsid; /** class id for the object */ 77 uint16_t nkey; /**< The total length of the key (in bytes) */ 78 uint16_t nvalue; /** < IN: The number of elements available in value 79 * OUT: the number of elements used in value */ 80 const void *key; 81 struct iovec value[1]; 82 } item_info; 83 84 typedef struct { 85 const char *username; 86 const char *config; 87 } auth_data_t; 88 89 /* Forward declaration of the server handle -- to be filled in later */ 90 typedef struct server_handle_v1_t SERVER_HANDLE_V1; 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif /* MEMCACHED_TYPES_H */ 97