From: Date: Mon, 10 Mar 2008 16:23:02 +0000 (-0400) Subject: Cleanup of include system. Broke up major memcached.h file into many files X-Git-Tag: _20~1^2~62 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ef2fc5e3fc97fa92db986ac4d36fbf51c3befe80;p=m6w6%2Flibmemcached Cleanup of include system. Broke up major memcached.h file into many files (still only need one include in application) --- diff --git a/.hgignore b/.hgignore index a7097160..5c068824 100644 --- a/.hgignore +++ b/.hgignore @@ -6,7 +6,7 @@ ^config.(log|status)$ ^libtool$ ^autom4te.cache$ -^include/(libmemcached_config.h(.in)?|stamp-h1)$ +^libmemcached/(libmemcached_config.h(.in)?|stamp-h1)$ ^libmemcached/libmemcached_config.h.in$ ^stamp-h1$ ^lib/libmemcachedPlus.la$ @@ -14,8 +14,8 @@ # Build artifacts -^lib/libmemcached.la$ -^src/mem(cat|cp|flush|rm|slap|stat|error)$ +^libmemcached/libmemcached.la$ +^clients/mem(cat|cp|flush|rm|slap|stat|error)$ ^tests/testapp$ .(deps|libs)/*$ .cmp$ @@ -25,7 +25,7 @@ support/libmemcached.pc$ support/libmemcached.spec$ docs/pod2htmd.tmp docs/pod2htmi.tmp -lib/memcachedplus.loT +libmemcached/memcachedplus.loT tests/atomsmasher tests/startservers tests/stopservers diff --git a/configure.ac b/configure.ac index 90072831..a4d12058 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ MEMCACHED_LIBRARY_NAME=libmemcached #release versioning MEMCACHED_MAJOR_VERSION=0 -MEMCACHED_MINOR_VERSION=17 +MEMCACHED_MINOR_VERSION=18 MEMCACHED_MICRO_VERSION=0 #API version diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index bd35e18a..01adbefa 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -24,7 +24,14 @@ noinst_HEADERS = libmemcached_probes.h \ memcached_io.h \ common.h -pkginclude_HEADERS= memcached.h memcached.hh +pkginclude_HEADERS= memcached.h \ + memcached.hh \ + libmemcached_config.h \ + memcached_constants.h \ + memcached_result.h \ + memcached_server.h \ + memcached_string.h \ + memcached_types.h lib_LTLIBRARIES = libmemcached.la diff --git a/libmemcached/common.h b/libmemcached/common.h index a70e65f3..14a17076 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -100,23 +100,9 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death); #define memcached_server_response_reset(A) (A)->cursor_active=0 /* String Struct */ -#define memcached_string_length(A) (size_t)((A)->end - (A)->string) -#define memcached_string_set_length(A, B) (A)->end= (A)->string + B -#define memcached_string_size(A) (A)->current_size -#define memcached_string_value(A) (A)->string - memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string_st *string, size_t initial_size); -memcached_return memcached_string_check(memcached_string_st *string, size_t need); -char *memcached_string_c_copy(memcached_string_st *string); -memcached_return memcached_string_append_character(memcached_string_st *string, - char character); -memcached_return memcached_string_append(memcached_string_st *string, - char *value, size_t length); -size_t memcached_string_backspace(memcached_string_st *string, size_t remove); -memcached_return memcached_string_reset(memcached_string_st *string); -void memcached_string_free(memcached_string_st *string); memcached_return memcached_do(memcached_server_st *ptr, char *commmand, size_t command_length, uint8_t with_flush); memcached_return memcached_version(memcached_st *ptr); diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index d3ec176e..4db72e94 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -15,6 +15,12 @@ #include #include +#include +#include +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -34,138 +40,6 @@ extern "C" { /* string value */ #define LIBMEMCACHED_VERSION_STRING "0.17" -typedef enum { - MEMCACHED_SUCCESS, - MEMCACHED_FAILURE, - MEMCACHED_HOST_LOOKUP_FAILURE, - MEMCACHED_CONNECTION_FAILURE, - MEMCACHED_CONNECTION_BIND_FAILURE, - MEMCACHED_WRITE_FAILURE, - MEMCACHED_READ_FAILURE, - MEMCACHED_UNKNOWN_READ_FAILURE, - MEMCACHED_PROTOCOL_ERROR, - MEMCACHED_CLIENT_ERROR, - MEMCACHED_SERVER_ERROR, - MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE, - MEMCACHED_DATA_EXISTS, - MEMCACHED_DATA_DOES_NOT_EXIST, - MEMCACHED_NOTSTORED, - MEMCACHED_STORED, - MEMCACHED_NOTFOUND, - MEMCACHED_MEMORY_ALLOCATION_FAILURE, - MEMCACHED_PARTIAL_READ, - MEMCACHED_SOME_ERRORS, - MEMCACHED_NO_SERVERS, - MEMCACHED_END, - MEMCACHED_DELETED, - MEMCACHED_VALUE, - MEMCACHED_STAT, - MEMCACHED_ERRNO, - MEMCACHED_FAIL_UNIX_SOCKET, - MEMCACHED_NOT_SUPPORTED, - MEMCACHED_NO_KEY_PROVIDED, - MEMCACHED_FETCH_NOTFINISHED, - MEMCACHED_TIMEOUT, - MEMCACHED_BUFFERED, - MEMCACHED_BAD_KEY_PROVIDED, - MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ -} memcached_return; - -typedef struct memcached_st memcached_st; -typedef struct memcached_stat_st memcached_stat_st; -typedef struct memcached_result_st memcached_result_st; -typedef struct memcached_string_st memcached_string_st; -typedef struct memcached_server_st memcached_server_st; -typedef memcached_return (*memcached_clone_func)(memcached_st *parent, memcached_st *clone); -typedef memcached_return (*memcached_cleanup_func)(memcached_st *ptr); -typedef void (*memcached_free_function)(memcached_st *ptr, void *mem); -typedef void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size); -typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, const size_t size); -typedef memcached_return (*memcached_execute_function)(memcached_st *ptr, memcached_result_st *result, void *context); -typedef memcached_return (*memcached_server_function)(memcached_st *ptr, memcached_server_st *server, void *context); - -typedef enum { - MEMCACHED_DISTRIBUTION_MODULA, - MEMCACHED_DISTRIBUTION_CONSISTENT, -} memcached_server_distribution; - -typedef enum { - MEMCACHED_BEHAVIOR_NO_BLOCK, - MEMCACHED_BEHAVIOR_TCP_NODELAY, - MEMCACHED_BEHAVIOR_HASH, - MEMCACHED_BEHAVIOR_KETAMA, - MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, - MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, - MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, - MEMCACHED_BEHAVIOR_SUPPORT_CAS, - MEMCACHED_BEHAVIOR_POLL_TIMEOUT, - MEMCACHED_BEHAVIOR_DISTRIBUTION, - MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, - MEMCACHED_BEHAVIOR_USER_DATA, - MEMCACHED_BEHAVIOR_SORT_HOSTS, - MEMCACHED_BEHAVIOR_VERIFY_KEY, - MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, - MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, -} memcached_behavior; - -typedef enum { - MEMCACHED_CALLBACK_USER_DATA, - MEMCACHED_CALLBACK_CLEANUP_FUNCTION, - MEMCACHED_CALLBACK_CLONE_FUNCTION, - MEMCACHED_CALLBACK_MALLOC_FUNCTION, - MEMCACHED_CALLBACK_REALLOC_FUNCTION, - MEMCACHED_CALLBACK_FREE_FUNCTION, -} memcached_callback; - -typedef enum { - MEMCACHED_HASH_DEFAULT= 0, - MEMCACHED_HASH_MD5, - MEMCACHED_HASH_CRC, - MEMCACHED_HASH_FNV1_64, - MEMCACHED_HASH_FNV1A_64, - MEMCACHED_HASH_FNV1_32, - MEMCACHED_HASH_FNV1A_32, - MEMCACHED_HASH_KETAMA, - MEMCACHED_HASH_HSIEH, - MEMCACHED_HASH_MURMUR, -} memcached_hash; - -typedef enum { - MEMCACHED_CONNECTION_UNKNOWN, - MEMCACHED_CONNECTION_TCP, - MEMCACHED_CONNECTION_UDP, - MEMCACHED_CONNECTION_UNIX_SOCKET, -} memcached_connection; - -typedef enum { - MEMCACHED_NOT_ALLOCATED, - MEMCACHED_ALLOCATED, - MEMCACHED_USED, -} memcached_allocated; - -struct memcached_server_st { - char hostname[MEMCACHED_MAX_HOST_LENGTH]; - unsigned int port; - int fd; - int cached_errno; - unsigned int cursor_active; - char write_buffer[MEMCACHED_MAX_BUFFER]; - size_t write_buffer_offset; - char read_buffer[MEMCACHED_MAX_BUFFER]; - size_t read_data_length; - size_t read_buffer_length; - char *read_ptr; - memcached_allocated sockaddr_inited; - struct addrinfo *address_info; - memcached_connection type; - uint8_t major_version; - uint8_t minor_version; - uint8_t micro_version; - uint16_t count; - time_t next_retry; - memcached_st *root; -}; - struct memcached_stat_st { uint32_t pid; uint32_t uptime; @@ -193,26 +67,6 @@ struct memcached_stat_st { char version[MEMCACHED_VERSION_STRING_LENGTH]; }; -struct memcached_string_st { - memcached_st *root; - memcached_allocated is_allocated; - char *string; - char *end; - size_t current_size; - size_t block_size; -}; - -struct memcached_result_st { - memcached_allocated is_allocated; - memcached_st *root; - char key[MEMCACHED_MAX_KEY]; - size_t key_length; - memcached_string_st value; - uint32_t flags; - uint64_t cas; - /* Add result callback function */ -}; - struct memcached_st { memcached_allocated is_allocated; memcached_server_st *hosts; @@ -315,12 +169,6 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_return *error); /* Server Public functions */ -#define memcached_server_count(A) (A)->number_of_hosts -#define memcached_server_name(A,B) (B).hostname -#define memcached_server_port(A,B) (B).port -#define memcached_server_list(A) (A)->hosts -#define memcached_server_response_count(A) (A)->cursor_active - memcached_return memcached_server_add_udp(memcached_st *ptr, char *hostname, @@ -420,23 +268,6 @@ memcached_return memcached_server_cursor(memcached_st *ptr, void *context, unsigned int number_of_callbacks); -/* Result Struct */ -void memcached_result_free(memcached_result_st *result); -memcached_result_st *memcached_result_create(memcached_st *ptr, - memcached_result_st *result); -#define memcached_result_key_value(A) (A)->key -#define memcached_result_key_length(A) (A)->key_length -#ifdef FIX -#define memcached_result_value(A) memcached_string_value((A)->value) -#define memcached_result_length(A) memcached_string_length((A)->value) -#else -char *memcached_result_value(memcached_result_st *ptr); -size_t memcached_result_length(memcached_result_st *ptr); -#endif -#define memcached_result_flags(A) (A)->flags -#define memcached_result_cas(A) (A)->cas - - #ifndef __WATCHPOINT_H__ #define __WATCHPOINT_H__ /* Some personal debugging functions */ diff --git a/libmemcached/memcached_constants.h b/libmemcached/memcached_constants.h new file mode 100644 index 00000000..65192bfb --- /dev/null +++ b/libmemcached/memcached_constants.h @@ -0,0 +1,126 @@ +/* + * Summary: Constants for libmemcached + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_CONSTANTS_H__ +#define __MEMCACHED_CONSTANTS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public defines */ +#define MEMCACHED_DEFAULT_PORT 11211 +#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ +#define MEMCACHED_MAX_BUFFER 8196 +#define MEMCACHED_MAX_HOST_LENGTH 64 +#define MEMCACHED_WHEEL_SIZE 1024 +#define MEMCACHED_STRIDE 4 +#define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX + +typedef enum { + MEMCACHED_SUCCESS, + MEMCACHED_FAILURE, + MEMCACHED_HOST_LOOKUP_FAILURE, + MEMCACHED_CONNECTION_FAILURE, + MEMCACHED_CONNECTION_BIND_FAILURE, + MEMCACHED_WRITE_FAILURE, + MEMCACHED_READ_FAILURE, + MEMCACHED_UNKNOWN_READ_FAILURE, + MEMCACHED_PROTOCOL_ERROR, + MEMCACHED_CLIENT_ERROR, + MEMCACHED_SERVER_ERROR, + MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE, + MEMCACHED_DATA_EXISTS, + MEMCACHED_DATA_DOES_NOT_EXIST, + MEMCACHED_NOTSTORED, + MEMCACHED_STORED, + MEMCACHED_NOTFOUND, + MEMCACHED_MEMORY_ALLOCATION_FAILURE, + MEMCACHED_PARTIAL_READ, + MEMCACHED_SOME_ERRORS, + MEMCACHED_NO_SERVERS, + MEMCACHED_END, + MEMCACHED_DELETED, + MEMCACHED_VALUE, + MEMCACHED_STAT, + MEMCACHED_ERRNO, + MEMCACHED_FAIL_UNIX_SOCKET, + MEMCACHED_NOT_SUPPORTED, + MEMCACHED_NO_KEY_PROVIDED, + MEMCACHED_FETCH_NOTFINISHED, + MEMCACHED_TIMEOUT, + MEMCACHED_BUFFERED, + MEMCACHED_BAD_KEY_PROVIDED, + MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ +} memcached_return; + +typedef enum { + MEMCACHED_DISTRIBUTION_MODULA, + MEMCACHED_DISTRIBUTION_CONSISTENT, +} memcached_server_distribution; + +typedef enum { + MEMCACHED_BEHAVIOR_NO_BLOCK, + MEMCACHED_BEHAVIOR_TCP_NODELAY, + MEMCACHED_BEHAVIOR_HASH, + MEMCACHED_BEHAVIOR_KETAMA, + MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, + MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, + MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, + MEMCACHED_BEHAVIOR_SUPPORT_CAS, + MEMCACHED_BEHAVIOR_POLL_TIMEOUT, + MEMCACHED_BEHAVIOR_DISTRIBUTION, + MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, + MEMCACHED_BEHAVIOR_USER_DATA, + MEMCACHED_BEHAVIOR_SORT_HOSTS, + MEMCACHED_BEHAVIOR_VERIFY_KEY, + MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, + MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, +} memcached_behavior; + +typedef enum { + MEMCACHED_CALLBACK_USER_DATA, + MEMCACHED_CALLBACK_CLEANUP_FUNCTION, + MEMCACHED_CALLBACK_CLONE_FUNCTION, + MEMCACHED_CALLBACK_MALLOC_FUNCTION, + MEMCACHED_CALLBACK_REALLOC_FUNCTION, + MEMCACHED_CALLBACK_FREE_FUNCTION, +} memcached_callback; + +typedef enum { + MEMCACHED_HASH_DEFAULT= 0, + MEMCACHED_HASH_MD5, + MEMCACHED_HASH_CRC, + MEMCACHED_HASH_FNV1_64, + MEMCACHED_HASH_FNV1A_64, + MEMCACHED_HASH_FNV1_32, + MEMCACHED_HASH_FNV1A_32, + MEMCACHED_HASH_KETAMA, + MEMCACHED_HASH_HSIEH, + MEMCACHED_HASH_MURMUR, +} memcached_hash; + +typedef enum { + MEMCACHED_CONNECTION_UNKNOWN, + MEMCACHED_CONNECTION_TCP, + MEMCACHED_CONNECTION_UDP, + MEMCACHED_CONNECTION_UNIX_SOCKET, +} memcached_connection; + +typedef enum { + MEMCACHED_NOT_ALLOCATED, + MEMCACHED_ALLOCATED, + MEMCACHED_USED, +} memcached_allocated; + + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_CONSTANTS_H__ */ diff --git a/libmemcached/memcached_result.h b/libmemcached/memcached_result.h new file mode 100644 index 00000000..1c229ecb --- /dev/null +++ b/libmemcached/memcached_result.h @@ -0,0 +1,47 @@ +/* + * Summary: Result structure used for libmemcached. + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_RESULT_H__ +#define __MEMCACHED_RESULT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct memcached_result_st { + memcached_allocated is_allocated; + memcached_st *root; + char key[MEMCACHED_MAX_KEY]; + size_t key_length; + memcached_string_st value; + uint32_t flags; + uint64_t cas; + /* Add result callback function */ +}; + +/* Result Struct */ +void memcached_result_free(memcached_result_st *result); +memcached_result_st *memcached_result_create(memcached_st *ptr, + memcached_result_st *result); +#define memcached_result_key_value(A) (A)->key +#define memcached_result_key_length(A) (A)->key_length +#ifdef FIX +#define memcached_result_value(A) memcached_string_value((A)->value) +#define memcached_result_length(A) memcached_string_length((A)->value) +#else +char *memcached_result_value(memcached_result_st *ptr); +size_t memcached_result_length(memcached_result_st *ptr); +#endif +#define memcached_result_flags(A) (A)->flags +#define memcached_result_cas(A) (A)->cas + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_RESULT_H__ */ diff --git a/libmemcached/memcached_server.h b/libmemcached/memcached_server.h new file mode 100644 index 00000000..f0eff961 --- /dev/null +++ b/libmemcached/memcached_server.h @@ -0,0 +1,50 @@ +/* + * Summary: String structure used for libmemcached. + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_SERVER_H__ +#define __MEMCACHED_SERVER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct memcached_server_st { + char hostname[MEMCACHED_MAX_HOST_LENGTH]; + unsigned int port; + int fd; + int cached_errno; + unsigned int cursor_active; + char write_buffer[MEMCACHED_MAX_BUFFER]; + size_t write_buffer_offset; + char read_buffer[MEMCACHED_MAX_BUFFER]; + size_t read_data_length; + size_t read_buffer_length; + char *read_ptr; + memcached_allocated sockaddr_inited; + struct addrinfo *address_info; + memcached_connection type; + uint8_t major_version; + uint8_t minor_version; + uint8_t micro_version; + uint16_t count; + time_t next_retry; + memcached_st *root; +}; + +#define memcached_server_count(A) (A)->number_of_hosts +#define memcached_server_name(A,B) (B).hostname +#define memcached_server_port(A,B) (B).port +#define memcached_server_list(A) (A)->hosts +#define memcached_server_response_count(A) (A)->cursor_active + + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_SERVER_H__ */ diff --git a/libmemcached/memcached_string.h b/libmemcached/memcached_string.h new file mode 100644 index 00000000..990c76ee --- /dev/null +++ b/libmemcached/memcached_string.h @@ -0,0 +1,44 @@ +/* + * Summary: String structure used for libmemcached. + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_STRING_H__ +#define __MEMCACHED_STRING_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct memcached_string_st { + memcached_st *root; + memcached_allocated is_allocated; + char *string; + char *end; + size_t current_size; + size_t block_size; +}; + +#define memcached_string_length(A) (size_t)((A)->end - (A)->string) +#define memcached_string_set_length(A, B) (A)->end= (A)->string + B +#define memcached_string_size(A) (A)->current_size +#define memcached_string_value(A) (A)->string + +memcached_return memcached_string_check(memcached_string_st *string, size_t need); +char *memcached_string_c_copy(memcached_string_st *string); +memcached_return memcached_string_append_character(memcached_string_st *string, + char character); +memcached_return memcached_string_append(memcached_string_st *string, + char *value, size_t length); +size_t memcached_string_backspace(memcached_string_st *string, size_t remove); +memcached_return memcached_string_reset(memcached_string_st *string); +void memcached_string_free(memcached_string_st *string); + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_STRING_H__ */ diff --git a/libmemcached/memcached_types.h b/libmemcached/memcached_types.h new file mode 100644 index 00000000..76f5171d --- /dev/null +++ b/libmemcached/memcached_types.h @@ -0,0 +1,33 @@ +/* + * Summary: Typpes for libmemcached + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_TYPES_H__ +#define __MEMCACHED_TYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct memcached_st memcached_st; +typedef struct memcached_stat_st memcached_stat_st; +typedef struct memcached_result_st memcached_result_st; +typedef struct memcached_string_st memcached_string_st; +typedef struct memcached_server_st memcached_server_st; +typedef memcached_return (*memcached_clone_func)(memcached_st *parent, memcached_st *clone); +typedef memcached_return (*memcached_cleanup_func)(memcached_st *ptr); +typedef void (*memcached_free_function)(memcached_st *ptr, void *mem); +typedef void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size); +typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, const size_t size); +typedef memcached_return (*memcached_execute_function)(memcached_st *ptr, memcached_result_st *result, void *context); +typedef memcached_return (*memcached_server_function)(memcached_st *ptr, memcached_server_st *server, void *context); + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_TYPES_H__ */