From 3a41c6c5dedb9638e678402c5e867f2de6e923ee Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 13 Oct 2012 19:12:16 -0400 Subject: Update for version 1.2 --- Makefile.am | 7 +- clients/execute.h | 2 +- clients/memcapable.cc | 2 +- clients/memcat.cc | 2 +- clients/memcp.cc | 2 +- clients/memdump.cc | 2 +- clients/memerror.cc | 2 +- clients/memexist.cc | 2 +- clients/memflush.cc | 3 +- clients/memparse.cc | 2 +- clients/memping.cc | 4 +- clients/memrm.cc | 3 +- clients/memslap.cc | 2 +- clients/memstat.cc | 2 +- clients/memtouch.cc | 2 +- clients/utilities.h | 2 +- configure.ac | 2 +- example/byteorder.cc | 89 -- example/byteorder.h | 49 - example/include.am | 28 - example/interface_v0.cc | 561 ---------- example/interface_v1.cc | 417 ------- example/memcached_light.cc | 646 ----------- example/memcached_light.h | 44 - example/storage.cc | 168 --- example/storage.h | 24 - example/t/include.am | 40 - example/t/memcached_light.cc | 248 ----- libmemcached-1.0/alloc.h | 54 - libmemcached-1.0/allocators.h | 64 -- libmemcached-1.0/analyze.h | 56 - libmemcached-1.0/auto.h | 111 -- libmemcached-1.0/basic_string.h | 55 - libmemcached-1.0/behavior.h | 83 -- libmemcached-1.0/callback.h | 55 - libmemcached-1.0/callbacks.h | 53 - libmemcached-1.0/configure.h.in | 52 - libmemcached-1.0/defaults.h | 55 - libmemcached-1.0/delete.h | 57 - libmemcached-1.0/deprecated_types.h | 60 -- libmemcached-1.0/dump.h | 51 - libmemcached-1.0/encoding_key.h | 49 - libmemcached-1.0/error.h | 67 -- libmemcached-1.0/exception.hpp | 60 -- libmemcached-1.0/exist.h | 52 - libmemcached-1.0/fetch.h | 53 - libmemcached-1.0/flush.h | 49 - libmemcached-1.0/flush_buffers.h | 49 - libmemcached-1.0/get.h | 110 -- libmemcached-1.0/hash.h | 65 -- libmemcached-1.0/include.am | 56 - libmemcached-1.0/limits.h | 46 - libmemcached-1.0/memcached.h | 169 --- libmemcached-1.0/memcached.hpp | 878 --------------- libmemcached-1.0/options.h | 49 - libmemcached-1.0/parse.h | 23 - libmemcached-1.0/platform.h | 56 - libmemcached-1.0/quit.h | 49 - libmemcached-1.0/result.h | 89 -- libmemcached-1.0/return.h | 81 -- libmemcached-1.0/sasl.h | 70 -- libmemcached-1.0/server.h | 123 --- libmemcached-1.0/server_list.h | 68 -- libmemcached-1.0/stats.h | 69 -- libmemcached-1.0/storage.h | 131 --- libmemcached-1.0/strerror.h | 50 - libmemcached-1.0/struct/allocator.h | 46 - libmemcached-1.0/struct/analysis.h | 51 - libmemcached-1.0/struct/callback.h | 44 - libmemcached-1.0/struct/include.am | 13 - libmemcached-1.0/struct/memcached.h | 132 --- libmemcached-1.0/struct/result.h | 56 - libmemcached-1.0/struct/sasl.h | 54 - libmemcached-1.0/struct/server.h | 98 -- libmemcached-1.0/struct/stat.h | 68 -- libmemcached-1.0/struct/string.h | 59 - libmemcached-1.0/t/c_sasl_test.c | 61 -- libmemcached-1.0/t/c_test.c | 61 -- libmemcached-1.0/t/cc_test.cc | 62 -- libmemcached-1.0/t/include.am | 32 - libmemcached-1.0/touch.h | 59 - libmemcached-1.0/triggers.h | 64 -- libmemcached-1.0/types.h | 85 -- libmemcached-1.0/types/behavior.h | 84 -- libmemcached-1.0/types/callback.h | 54 - libmemcached-1.0/types/connection.h | 49 - libmemcached-1.0/types/hash.h | 58 - libmemcached-1.0/types/include.am | 8 - libmemcached-1.0/types/return.h | 95 -- libmemcached-1.0/types/server_distribution.h | 54 - libmemcached-1.0/verbosity.h | 50 - libmemcached-1.0/version.h | 52 - libmemcached-1.0/visibility.h | 67 -- libmemcached-1.2/alloc.h | 54 + libmemcached-1.2/allocators.h | 64 ++ libmemcached-1.2/analyze.h | 56 + libmemcached-1.2/auto.h | 111 ++ libmemcached-1.2/basic_string.h | 55 + libmemcached-1.2/behavior.h | 83 ++ libmemcached-1.2/callback.h | 55 + libmemcached-1.2/callbacks.h | 53 + libmemcached-1.2/configure.h.in | 52 + libmemcached-1.2/defaults.h | 55 + libmemcached-1.2/delete.h | 57 + libmemcached-1.2/deprecated_types.h | 60 ++ libmemcached-1.2/dump.h | 51 + libmemcached-1.2/encoding_key.h | 49 + libmemcached-1.2/error.h | 67 ++ libmemcached-1.2/exception.hpp | 60 ++ libmemcached-1.2/exist.h | 52 + libmemcached-1.2/fetch.h | 53 + libmemcached-1.2/flush.h | 49 + libmemcached-1.2/flush_buffers.h | 49 + libmemcached-1.2/get.h | 110 ++ libmemcached-1.2/hash.h | 65 ++ libmemcached-1.2/include.am | 56 + libmemcached-1.2/limits.h | 46 + libmemcached-1.2/memcached.h | 167 +++ libmemcached-1.2/memcached.hpp | 878 +++++++++++++++ libmemcached-1.2/memcached/vbucket.h | 59 + libmemcached-1.2/options.h | 49 + libmemcached-1.2/parse.h | 23 + libmemcached-1.2/platform.h | 56 + libmemcached-1.2/quit.h | 49 + libmemcached-1.2/result.h | 89 ++ libmemcached-1.2/return.h | 81 ++ libmemcached-1.2/sasl.h | 70 ++ libmemcached-1.2/server.h | 123 +++ libmemcached-1.2/server_list.h | 68 ++ libmemcached-1.2/stats.h | 69 ++ libmemcached-1.2/storage.h | 131 +++ libmemcached-1.2/strerror.h | 50 + libmemcached-1.2/struct/allocator.h | 46 + libmemcached-1.2/struct/analysis.h | 51 + libmemcached-1.2/struct/callback.h | 44 + libmemcached-1.2/struct/include.am | 13 + libmemcached-1.2/struct/memcached.h | 132 +++ libmemcached-1.2/struct/result.h | 56 + libmemcached-1.2/struct/sasl.h | 54 + libmemcached-1.2/struct/server.h | 98 ++ libmemcached-1.2/struct/stat.h | 68 ++ libmemcached-1.2/struct/string.h | 59 + libmemcached-1.2/t/c_sasl_test.c | 61 ++ libmemcached-1.2/t/c_test.c | 61 ++ libmemcached-1.2/t/cc_test.cc | 62 ++ libmemcached-1.2/t/include.am | 30 + libmemcached-1.2/touch.h | 59 + libmemcached-1.2/triggers.h | 64 ++ libmemcached-1.2/types.h | 85 ++ libmemcached-1.2/types/behavior.h | 84 ++ libmemcached-1.2/types/callback.h | 54 + libmemcached-1.2/types/connection.h | 49 + libmemcached-1.2/types/hash.h | 58 + libmemcached-1.2/types/include.am | 8 + libmemcached-1.2/types/return.h | 95 ++ libmemcached-1.2/types/server_distribution.h | 54 + libmemcached-1.2/verbosity.h | 50 + libmemcached-1.2/version.h | 52 + libmemcached-1.2/visibility.h | 67 ++ libmemcached/common.h | 2 +- libmemcached/include.am | 4 - libmemcached/memcached.h | 39 - libmemcached/memcached.hpp | 40 - libmemcached/memcached/protocol_binary.h | 2 +- libmemcached/memory.h | 2 +- libmemcached/util.h | 40 - libmemcachedprotocol-0.0/binary.h | 728 ------------- libmemcachedprotocol-0.0/callback.h | 416 ------- libmemcachedprotocol-0.0/handler.h | 218 ---- libmemcachedprotocol-0.0/include.am | 9 - libmemcachedprotocol-0.0/vbucket.h | 59 - libmemcachedprotocol/ascii_handler.c | 1123 ------------------- libmemcachedprotocol/ascii_handler.h | 40 - libmemcachedprotocol/binary_handler.c | 1198 --------------------- libmemcachedprotocol/binary_handler.h | 47 - libmemcachedprotocol/cache.c | 189 ---- libmemcachedprotocol/cache.h | 148 --- libmemcachedprotocol/common.h | 162 --- libmemcachedprotocol/handler.c | 437 -------- libmemcachedprotocol/include.am | 34 - libmemcachedprotocol/pedantic.c | 237 ---- libmemcachedutil-1.0/flush.h | 50 - libmemcachedutil-1.0/include.am | 13 - libmemcachedutil-1.0/ostream.hpp | 50 - libmemcachedutil-1.0/pid.h | 58 - libmemcachedutil-1.0/ping.h | 52 - libmemcachedutil-1.0/pool.h | 83 -- libmemcachedutil-1.0/util.h | 46 - libmemcachedutil-1.0/version.h | 53 - libmemcachedutil-1.2/flush.h | 50 + libmemcachedutil-1.2/include.am | 11 + libmemcachedutil-1.2/ostream.hpp | 50 + libmemcachedutil-1.2/pid.h | 58 + libmemcachedutil-1.2/ping.h | 52 + libmemcachedutil-1.2/pool.h | 80 ++ libmemcachedutil-1.2/util.h | 46 + libmemcachedutil-1.2/version.h | 53 + libmemcachedutil/common.h | 5 +- libtest/comparison.hpp | 4 +- libtest/memcached.cc | 4 +- tests/cycle.cc | 2 +- tests/failure.cc | 2 +- tests/libmemcached-1.0/atomsmasher.cc | 2 +- tests/libmemcached-1.0/basic.cc | 2 +- tests/libmemcached-1.0/debug.cc | 2 +- tests/libmemcached-1.0/deprecated.cc | 2 +- tests/libmemcached-1.0/dump.cc | 4 +- tests/libmemcached-1.0/encoding_key.cc | 4 +- tests/libmemcached-1.0/error_conditions.cc | 2 +- tests/libmemcached-1.0/generate.cc | 2 +- tests/libmemcached-1.0/ketama.cc | 2 +- tests/libmemcached-1.0/mem_functions.cc | 24 +- tests/libmemcached-1.0/memcached_fetch_execute.cc | 2 +- tests/libmemcached-1.0/memcached_get.cc | 2 +- tests/libmemcached-1.0/namespace.cc | 2 +- tests/libmemcached-1.0/parser.cc | 4 +- tests/libmemcached-1.0/plus.cpp | 2 +- tests/libmemcached-1.0/pool.cc | 4 +- tests/libmemcached-1.0/print.cc | 2 +- tests/libmemcached-1.0/replication.cc | 2 +- tests/libmemcached-1.0/sasl.cc | 2 +- tests/libmemcached-1.0/server_add.cc | 2 +- tests/libmemcached-1.0/setup_and_teardowns.cc | 2 +- tests/libmemcached-1.0/stat.cc | 4 +- tests/libmemcached-1.0/string.cc | 2 +- tests/libmemcached-1.0/touch.cc | 8 +- tests/libmemcached-1.0/virtual_buckets.cc | 2 +- tests/mem_udp.cc | 4 +- tests/memcapable.cc | 2 +- tests/memcat.cc | 2 +- tests/memcp.cc | 2 +- tests/memdump.cc | 2 +- tests/memerror.cc | 2 +- tests/memexist.cc | 4 +- tests/memflush.cc | 2 +- tests/memrm.cc | 2 +- tests/memslap.cc | 2 +- tests/memstat.cc | 2 +- tests/memtouch.cc | 4 +- tests/parser.cc | 2 +- win32/include.am | 1 - 241 files changed, 5531 insertions(+), 12964 deletions(-) delete mode 100644 example/byteorder.cc delete mode 100644 example/byteorder.h delete mode 100644 example/include.am delete mode 100644 example/interface_v0.cc delete mode 100644 example/interface_v1.cc delete mode 100644 example/memcached_light.cc delete mode 100644 example/memcached_light.h delete mode 100644 example/storage.cc delete mode 100644 example/storage.h delete mode 100644 example/t/include.am delete mode 100644 example/t/memcached_light.cc delete mode 100644 libmemcached-1.0/alloc.h delete mode 100644 libmemcached-1.0/allocators.h delete mode 100644 libmemcached-1.0/analyze.h delete mode 100644 libmemcached-1.0/auto.h delete mode 100644 libmemcached-1.0/basic_string.h delete mode 100644 libmemcached-1.0/behavior.h delete mode 100644 libmemcached-1.0/callback.h delete mode 100644 libmemcached-1.0/callbacks.h delete mode 100644 libmemcached-1.0/configure.h.in delete mode 100644 libmemcached-1.0/defaults.h delete mode 100644 libmemcached-1.0/delete.h delete mode 100644 libmemcached-1.0/deprecated_types.h delete mode 100644 libmemcached-1.0/dump.h delete mode 100644 libmemcached-1.0/encoding_key.h delete mode 100644 libmemcached-1.0/error.h delete mode 100644 libmemcached-1.0/exception.hpp delete mode 100644 libmemcached-1.0/exist.h delete mode 100644 libmemcached-1.0/fetch.h delete mode 100644 libmemcached-1.0/flush.h delete mode 100644 libmemcached-1.0/flush_buffers.h delete mode 100644 libmemcached-1.0/get.h delete mode 100644 libmemcached-1.0/hash.h delete mode 100644 libmemcached-1.0/include.am delete mode 100644 libmemcached-1.0/limits.h delete mode 100644 libmemcached-1.0/memcached.h delete mode 100644 libmemcached-1.0/memcached.hpp delete mode 100644 libmemcached-1.0/options.h delete mode 100644 libmemcached-1.0/parse.h delete mode 100644 libmemcached-1.0/platform.h delete mode 100644 libmemcached-1.0/quit.h delete mode 100644 libmemcached-1.0/result.h delete mode 100644 libmemcached-1.0/return.h delete mode 100644 libmemcached-1.0/sasl.h delete mode 100644 libmemcached-1.0/server.h delete mode 100644 libmemcached-1.0/server_list.h delete mode 100644 libmemcached-1.0/stats.h delete mode 100644 libmemcached-1.0/storage.h delete mode 100644 libmemcached-1.0/strerror.h delete mode 100644 libmemcached-1.0/struct/allocator.h delete mode 100644 libmemcached-1.0/struct/analysis.h delete mode 100644 libmemcached-1.0/struct/callback.h delete mode 100644 libmemcached-1.0/struct/include.am delete mode 100644 libmemcached-1.0/struct/memcached.h delete mode 100644 libmemcached-1.0/struct/result.h delete mode 100644 libmemcached-1.0/struct/sasl.h delete mode 100644 libmemcached-1.0/struct/server.h delete mode 100644 libmemcached-1.0/struct/stat.h delete mode 100644 libmemcached-1.0/struct/string.h delete mode 100644 libmemcached-1.0/t/c_sasl_test.c delete mode 100644 libmemcached-1.0/t/c_test.c delete mode 100644 libmemcached-1.0/t/cc_test.cc delete mode 100644 libmemcached-1.0/t/include.am delete mode 100644 libmemcached-1.0/touch.h delete mode 100644 libmemcached-1.0/triggers.h delete mode 100644 libmemcached-1.0/types.h delete mode 100644 libmemcached-1.0/types/behavior.h delete mode 100644 libmemcached-1.0/types/callback.h delete mode 100644 libmemcached-1.0/types/connection.h delete mode 100644 libmemcached-1.0/types/hash.h delete mode 100644 libmemcached-1.0/types/include.am delete mode 100644 libmemcached-1.0/types/return.h delete mode 100644 libmemcached-1.0/types/server_distribution.h delete mode 100644 libmemcached-1.0/verbosity.h delete mode 100644 libmemcached-1.0/version.h delete mode 100644 libmemcached-1.0/visibility.h create mode 100644 libmemcached-1.2/alloc.h create mode 100644 libmemcached-1.2/allocators.h create mode 100644 libmemcached-1.2/analyze.h create mode 100644 libmemcached-1.2/auto.h create mode 100644 libmemcached-1.2/basic_string.h create mode 100644 libmemcached-1.2/behavior.h create mode 100644 libmemcached-1.2/callback.h create mode 100644 libmemcached-1.2/callbacks.h create mode 100644 libmemcached-1.2/configure.h.in create mode 100644 libmemcached-1.2/defaults.h create mode 100644 libmemcached-1.2/delete.h create mode 100644 libmemcached-1.2/deprecated_types.h create mode 100644 libmemcached-1.2/dump.h create mode 100644 libmemcached-1.2/encoding_key.h create mode 100644 libmemcached-1.2/error.h create mode 100644 libmemcached-1.2/exception.hpp create mode 100644 libmemcached-1.2/exist.h create mode 100644 libmemcached-1.2/fetch.h create mode 100644 libmemcached-1.2/flush.h create mode 100644 libmemcached-1.2/flush_buffers.h create mode 100644 libmemcached-1.2/get.h create mode 100644 libmemcached-1.2/hash.h create mode 100644 libmemcached-1.2/include.am create mode 100644 libmemcached-1.2/limits.h create mode 100644 libmemcached-1.2/memcached.h create mode 100644 libmemcached-1.2/memcached.hpp create mode 100644 libmemcached-1.2/memcached/vbucket.h create mode 100644 libmemcached-1.2/options.h create mode 100644 libmemcached-1.2/parse.h create mode 100644 libmemcached-1.2/platform.h create mode 100644 libmemcached-1.2/quit.h create mode 100644 libmemcached-1.2/result.h create mode 100644 libmemcached-1.2/return.h create mode 100644 libmemcached-1.2/sasl.h create mode 100644 libmemcached-1.2/server.h create mode 100644 libmemcached-1.2/server_list.h create mode 100644 libmemcached-1.2/stats.h create mode 100644 libmemcached-1.2/storage.h create mode 100644 libmemcached-1.2/strerror.h create mode 100644 libmemcached-1.2/struct/allocator.h create mode 100644 libmemcached-1.2/struct/analysis.h create mode 100644 libmemcached-1.2/struct/callback.h create mode 100644 libmemcached-1.2/struct/include.am create mode 100644 libmemcached-1.2/struct/memcached.h create mode 100644 libmemcached-1.2/struct/result.h create mode 100644 libmemcached-1.2/struct/sasl.h create mode 100644 libmemcached-1.2/struct/server.h create mode 100644 libmemcached-1.2/struct/stat.h create mode 100644 libmemcached-1.2/struct/string.h create mode 100644 libmemcached-1.2/t/c_sasl_test.c create mode 100644 libmemcached-1.2/t/c_test.c create mode 100644 libmemcached-1.2/t/cc_test.cc create mode 100644 libmemcached-1.2/t/include.am create mode 100644 libmemcached-1.2/touch.h create mode 100644 libmemcached-1.2/triggers.h create mode 100644 libmemcached-1.2/types.h create mode 100644 libmemcached-1.2/types/behavior.h create mode 100644 libmemcached-1.2/types/callback.h create mode 100644 libmemcached-1.2/types/connection.h create mode 100644 libmemcached-1.2/types/hash.h create mode 100644 libmemcached-1.2/types/include.am create mode 100644 libmemcached-1.2/types/return.h create mode 100644 libmemcached-1.2/types/server_distribution.h create mode 100644 libmemcached-1.2/verbosity.h create mode 100644 libmemcached-1.2/version.h create mode 100644 libmemcached-1.2/visibility.h delete mode 100644 libmemcached/memcached.h delete mode 100644 libmemcached/memcached.hpp delete mode 100644 libmemcached/util.h delete mode 100644 libmemcachedprotocol-0.0/binary.h delete mode 100644 libmemcachedprotocol-0.0/callback.h delete mode 100644 libmemcachedprotocol-0.0/handler.h delete mode 100644 libmemcachedprotocol-0.0/include.am delete mode 100644 libmemcachedprotocol-0.0/vbucket.h delete mode 100644 libmemcachedprotocol/ascii_handler.c delete mode 100644 libmemcachedprotocol/ascii_handler.h delete mode 100644 libmemcachedprotocol/binary_handler.c delete mode 100644 libmemcachedprotocol/binary_handler.h delete mode 100644 libmemcachedprotocol/cache.c delete mode 100644 libmemcachedprotocol/cache.h delete mode 100644 libmemcachedprotocol/common.h delete mode 100644 libmemcachedprotocol/handler.c delete mode 100644 libmemcachedprotocol/include.am delete mode 100644 libmemcachedprotocol/pedantic.c delete mode 100644 libmemcachedutil-1.0/flush.h delete mode 100644 libmemcachedutil-1.0/include.am delete mode 100644 libmemcachedutil-1.0/ostream.hpp delete mode 100644 libmemcachedutil-1.0/pid.h delete mode 100644 libmemcachedutil-1.0/ping.h delete mode 100644 libmemcachedutil-1.0/pool.h delete mode 100644 libmemcachedutil-1.0/util.h delete mode 100644 libmemcachedutil-1.0/version.h create mode 100644 libmemcachedutil-1.2/flush.h create mode 100644 libmemcachedutil-1.2/include.am create mode 100644 libmemcachedutil-1.2/ostream.hpp create mode 100644 libmemcachedutil-1.2/pid.h create mode 100644 libmemcachedutil-1.2/ping.h create mode 100644 libmemcachedutil-1.2/pool.h create mode 100644 libmemcachedutil-1.2/util.h create mode 100644 libmemcachedutil-1.2/version.h diff --git a/Makefile.am b/Makefile.am index cc6bc018..0ad054e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,18 +37,15 @@ dist_aclocal_DATA= include libtest/include.am include libhashkit-1.0/include.am -include libmemcached-1.0/include.am -include libmemcachedprotocol-0.0/include.am -include libmemcachedutil-1.0/include.am +include libmemcached-1.2/include.am +include libmemcachedutil-1.2/include.am include clients/include.am include docs/include.am include man/include.am -include example/include.am include libhashkit/include.am include libmemcached/include.am include libmemcachedutil/include.am -include libmemcachedprotocol/include.am include libmemcachedinternal/include.am include libmemcachedinternal/util/include.am include poll/include.am diff --git a/clients/execute.h b/clients/execute.h index ebf92f62..57831360 100644 --- a/clients/execute.h +++ b/clients/execute.h @@ -13,7 +13,7 @@ #include -#include +#include #include "clients/generator.h" #ifdef __cplusplus diff --git a/clients/memcapable.cc b/clients/memcapable.cc index 2026acee..980e3392 100644 --- a/clients/memcapable.cc +++ b/clients/memcapable.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include "libmemcached/socket.hpp" #include "libmemcached/memcached/protocol_binary.h" diff --git a/clients/memcat.cc b/clients/memcat.cc index ef287781..bc66edf3 100644 --- a/clients/memcat.cc +++ b/clients/memcat.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "utilities.h" diff --git a/clients/memcp.cc b/clients/memcp.cc index 4ad0919d..11a5a3d0 100644 --- a/clients/memcp.cc +++ b/clients/memcp.cc @@ -31,7 +31,7 @@ #include -#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memdump.cc b/clients/memdump.cc index 5b333728..26cf02ae 100644 --- a/clients/memdump.cc +++ b/clients/memdump.cc @@ -25,7 +25,7 @@ #include #include -#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memerror.cc b/clients/memerror.cc index 910b2a6d..a8d4a007 100644 --- a/clients/memerror.cc +++ b/clients/memerror.cc @@ -21,7 +21,7 @@ #include #include -#include +#include #include "utilities.h" diff --git a/clients/memexist.cc b/clients/memexist.cc index af9a72c9..36d2066d 100644 --- a/clients/memexist.cc +++ b/clients/memexist.cc @@ -17,7 +17,7 @@ #include #include -#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memflush.cc b/clients/memflush.cc index 5342d757..02179fe5 100644 --- a/clients/memflush.cc +++ b/clients/memflush.cc @@ -17,7 +17,8 @@ #include #include -#include +#include + #include "client_options.h" #include "utilities.h" diff --git a/clients/memparse.cc b/clients/memparse.cc index ab4cee9e..351f785c 100644 --- a/clients/memparse.cc +++ b/clients/memparse.cc @@ -41,7 +41,7 @@ #include #include -#include +#include int main(int argc, char *argv[]) { diff --git a/clients/memping.cc b/clients/memping.cc index f4fcec86..f316212d 100644 --- a/clients/memping.cc +++ b/clients/memping.cc @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memrm.cc b/clients/memrm.cc index 3b7f8a4b..3bf4141a 100644 --- a/clients/memrm.cc +++ b/clients/memrm.cc @@ -17,7 +17,8 @@ #include #include -#include +#include + #include "client_options.h" #include "utilities.h" diff --git a/clients/memslap.cc b/clients/memslap.cc index 777820a0..419a25b4 100644 --- a/clients/memslap.cc +++ b/clients/memslap.cc @@ -55,7 +55,7 @@ #include -#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memstat.cc b/clients/memstat.cc index 6fd42d6c..3eb3c0c0 100644 --- a/clients/memstat.cc +++ b/clients/memstat.cc @@ -26,7 +26,7 @@ #include #include -#include +#include #include "client_options.h" #include "utilities.h" diff --git a/clients/memtouch.cc b/clients/memtouch.cc index 8bb3c78c..8f9d7b28 100644 --- a/clients/memtouch.cc +++ b/clients/memtouch.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "utilities.h" diff --git a/clients/utilities.h b/clients/utilities.h index da973b5f..2aed219a 100644 --- a/clients/utilities.h +++ b/clients/utilities.h @@ -12,7 +12,7 @@ #pragma once #include -#include +#include #include "clients/client_options.h" #if TIME_WITH_SYS_TIME diff --git a/configure.ac b/configure.ac index 60d399d2..afeb970d 100644 --- a/configure.ac +++ b/configure.ac @@ -272,7 +272,7 @@ AX_AM_JOBSERVER([yes]) AC_CONFIG_FILES([ Makefile docs/conf.py - libmemcached-1.0/configure.h + libmemcached-1.2/configure.h support/libmemcached.pc support/libmemcached.spec ]) diff --git a/example/byteorder.cc b/example/byteorder.cc deleted file mode 100644 index 5b25624a..00000000 --- a/example/byteorder.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include - -#include - -/* Byte swap a 64-bit number. */ -#ifndef swap64 -static inline uint64_t swap64(uint64_t in) -{ -#ifndef WORDS_BIGENDIAN - /* Little endian, flip the bytes around until someone makes a faster/better - * way to do this. */ - uint64_t rv= 0; - for (uint8_t x= 0; x < 8; x++) - { - rv= (rv << 8) | (in & 0xff); - in >>= 8; - } - return rv; -#else - /* big-endian machines don't need byte swapping */ - return in; -#endif // WORDS_BIGENDIAN -} -#endif - -#ifdef HAVE_HTONLL - -uint64_t example_ntohll(uint64_t value) -{ - return ntohll(value); -} - -uint64_t example_htonll(uint64_t value) -{ - return htonll(value); -} - -#else // HAVE_HTONLL - -uint64_t example_ntohll(uint64_t value) -{ - return swap64(value); -} - -uint64_t example_htonll(uint64_t value) -{ - return swap64(value); -} - -#endif // HAVE_HTONLL diff --git a/example/byteorder.h b/example/byteorder.h deleted file mode 100644 index 1e319a3e..00000000 --- a/example/byteorder.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Byteorder for example - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -uint64_t example_ntohll(uint64_t); - -uint64_t example_htonll(uint64_t); - -#ifdef __cplusplus -} -#endif diff --git a/example/include.am b/example/include.am deleted file mode 100644 index 8dfa5f4a..00000000 --- a/example/include.am +++ /dev/null @@ -1,28 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -if HAVE_LIBEVENT -noinst_PROGRAMS+= example/memcached_light -endif - -noinst_HEADERS+= example/byteorder.h -noinst_HEADERS+= example/memcached_light.h -noinst_HEADERS+= example/storage.h - -example_memcached_light_SOURCES= -example_memcached_light_LDADD= -example_memcached_light_LDFLAGS= - -example_memcached_light_SOURCES+= example/byteorder.cc -example_memcached_light_SOURCES+= example/interface_v0.cc -example_memcached_light_SOURCES+= example/interface_v1.cc -example_memcached_light_SOURCES+= example/memcached_light.cc -example_memcached_light_SOURCES+= example/storage.cc -example_memcached_light_SOURCES+= util/daemon.cc -example_memcached_light_SOURCES+= util/pidfile.cc - -example_memcached_light_LDADD+= libmemcached/libmemcachedprotocol.la -example_memcached_light_LDFLAGS+= @LIBEVENT_LDFLAGS@ - -include example/t/include.am diff --git a/example/interface_v0.cc b/example/interface_v0.cc deleted file mode 100644 index 1cba4eb1..00000000 --- a/example/interface_v0.cc +++ /dev/null @@ -1,561 +0,0 @@ -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -/** - * This file contains an implementation of the callback interface for level 0 - * in the protocol library. You might want to have your copy of the protocol - * specification next to your coffee ;-) - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "example/memcached_light.h" -#include "example/storage.h" -#include "util/log.hpp" - - -using namespace datadifferential; - -static util::log_info_st *log_file= NULL; - -static protocol_binary_response_status noop_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= PROTOCOL_BINARY_CMD_NOOP; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status quit_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= PROTOCOL_BINARY_CMD_QUIT; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - if (header->request.opcode == PROTOCOL_BINARY_CMD_QUIT) - { - response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - - /* I need a better way to signal to close the connection */ - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; -} - -static protocol_binary_response_status get_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - uint8_t opcode= header->request.opcode; - union protocol_binary_response_get_un { - protocol_binary_response_get response; - char buffer[4096]; - }; - - protocol_binary_response_get_un msg; - memset(&msg, 0, sizeof(protocol_binary_response_get_un)); - - msg.response.message.header.response.magic= PROTOCOL_BINARY_RES; - msg.response.message.header.response.opcode= opcode; - msg.response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - msg.response.message.header.response.opaque= header->request.opaque; - - struct item *item= get_item(header + 1, ntohs(header->request.keylen)); - if (item) - { - msg.response.message.body.flags= htonl(item->flags); - char *ptr= (char*)(msg.response.bytes + sizeof(*header) + 4); - uint32_t bodysize= 4; - msg.response.message.header.response.cas= example_htonll(item->cas); - if (opcode == PROTOCOL_BINARY_CMD_GETK || opcode == PROTOCOL_BINARY_CMD_GETKQ) - { - memcpy(ptr, item->key, item->nkey); - msg.response.message.header.response.keylen= htons((uint16_t)item->nkey); - ptr += item->nkey; - bodysize += (uint32_t)item->nkey; - } - memcpy(ptr, item->data, item->size); - bodysize += (uint32_t)item->size; - msg.response.message.header.response.bodylen= htonl(bodysize); - msg.response.message.header.response.extlen= 4; - - release_item(item); - return response_handler(cookie, header, (protocol_binary_response_header*)&msg); - } - else if (opcode == PROTOCOL_BINARY_CMD_GET || opcode == PROTOCOL_BINARY_CMD_GETK) - { - msg.response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); - return response_handler(cookie, header, (protocol_binary_response_header*)&msg); - } - - /* Q shouldn't report a miss ;-) */ - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status delete_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - size_t keylen= ntohs(header->request.keylen); - - char *key= ((char*)header) + sizeof(*header); - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.opaque= header->request.opaque; - - if (delete_item(key, keylen) == false) - { - log_file->write(util::VERBOSE_NOTICE, "%s not found: %.*s", __func__, keylen, key); - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - else if (header->request.opcode == PROTOCOL_BINARY_CMD_DELETE) - { - log_file->write(util::VERBOSE_NOTICE, "%s not found: %.*s", __func__, keylen, key); - /* DELETEQ doesn't want success response */ - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - - log_file->write(util::VERBOSE_NOTICE, "%s deleted: %.*s", __func__, keylen, key); - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status flush_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - uint8_t opcode= header->request.opcode; - - /* @fixme sett inn when! */ - flush(0); - - if (opcode == PROTOCOL_BINARY_CMD_FLUSH) - { - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= opcode; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status arithmetic_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_request_incr *req= (protocol_binary_request_incr*)header; - protocol_binary_response_incr response; - memset(&response, 0, sizeof(protocol_binary_response_incr)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.opaque= header->request.opaque; - - uint16_t keylen= ntohs(header->request.keylen); - uint64_t initial= example_ntohll(req->message.body.initial); - uint64_t delta= example_ntohll(req->message.body.delta); - uint32_t expiration= ntohl(req->message.body.expiration); - uint32_t flags= 0; - void *key= req->bytes + sizeof(req->bytes); - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - - uint64_t value= initial; - - struct item *item= get_item(key, keylen); - if (item != NULL) - { - if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENT || - header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ) - { - value= (*(uint64_t*)item->data) + delta; - } - else - { - if (delta > *(uint64_t*)item->data) - { - value= 0; - } - else - { - value= *(uint64_t*)item->data - delta; - } - } - expiration= (uint32_t)item->exp; - flags= item->flags; - - release_item(item); - delete_item(key, keylen); - } - - item= create_item(key, keylen, NULL, sizeof(value), flags, (time_t)expiration); - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - memcpy(item->data, &value, sizeof(value)); - put_item(item); - } - - response.message.header.response.status= htons(rval); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) - { - response.message.header.response.bodylen= ntohl(8); - response.message.body.value= example_ntohll((*(uint64_t*)item->data)); - response.message.header.response.cas= example_ntohll(item->cas); - - release_item(item); - if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ || - header->request.opcode == PROTOCOL_BINARY_CMD_DECREMENTQ) - { - return PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - } - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status version_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - const char *versionstring= "1.0.0"; - union protocol_binary_response_header_un - { - protocol_binary_response_header packet; - char buffer[256]; - }; - - protocol_binary_response_header_un response; - memset(&response, 0, sizeof(protocol_binary_response_header_un)); - - response.packet.response.magic= PROTOCOL_BINARY_RES; - response.packet.response.opcode= PROTOCOL_BINARY_CMD_VERSION; - response.packet.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.packet.response.opaque= header->request.opaque; - response.packet.response.cas= 0; - response.packet.response.bodylen= htonl((uint32_t)strlen(versionstring)); - - assert(sizeof(protocol_binary_response_header) +strlen(versionstring) <= 256); - memcpy(response.buffer + sizeof(protocol_binary_response_header), versionstring, strlen(versionstring)); - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status concat_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - uint16_t keylen= ntohs(header->request.keylen); - uint64_t cas= example_ntohll(header->request.cas); - void *key= header + 1; - uint32_t vallen= ntohl(header->request.bodylen) - keylen; - void *val= (char*)key + keylen; - - struct item *item= get_item(key, keylen); - struct item *nitem= NULL; - - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - else if (cas != 0 && cas != item->cas) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, - item->flags, item->exp)) == NULL) - { - release_item(item); - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - if (header->request.opcode == PROTOCOL_BINARY_CMD_APPEND || - header->request.opcode == PROTOCOL_BINARY_CMD_APPENDQ) - { - memcpy(nitem->data, item->data, item->size); - memcpy(((char*)(nitem->data)) + item->size, val, vallen); - } - else - { - memcpy(nitem->data, val, vallen); - memcpy(((char*)(nitem->data)) + vallen, item->data, item->size); - } - release_item(item); - delete_item(key, keylen); - put_item(nitem); - cas= nitem->cas; - release_item(nitem); - - if (header->request.opcode == PROTOCOL_BINARY_CMD_APPEND || - header->request.opcode == PROTOCOL_BINARY_CMD_PREPEND) - { - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.status= htons(rval); - response.message.header.response.opaque= header->request.opaque; - response.message.header.response.cas= example_htonll(cas); - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - } - - return rval; -} - -static protocol_binary_response_status set_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - size_t keylen= ntohs(header->request.keylen); - size_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_replace *request= (protocol_binary_request_replace*)header; - uint32_t flags= ntohl(request->message.body.flags); - time_t timeout= (time_t)ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - if (header->request.cas != 0) - { - /* validate cas */ - struct item* item= get_item(key, keylen); - if (item != NULL) - { - if (item->cas != example_ntohll(header->request.cas)) - { - release_item(item); - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - release_item(item); - } - } - - delete_item(key, keylen); - struct item* item= create_item(key, keylen, data, datalen, flags, timeout); - if (item == NULL) - { - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); - } - else - { - put_item(item); - /* SETQ shouldn't return a message */ - if (header->request.opcode == PROTOCOL_BINARY_CMD_SET) - { - response.message.header.response.cas= example_htonll(item->cas); - release_item(item); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - release_item(item); - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status add_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - size_t keylen= ntohs(header->request.keylen); - size_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_add *request= (protocol_binary_request_add*)header; - uint32_t flags= ntohl(request->message.body.flags); - time_t timeout= (time_t)ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - struct item* item= get_item(key, keylen); - if (item == NULL) - { - item= create_item(key, keylen, data, datalen, flags, timeout); - if (item == NULL) - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); - else - { - put_item(item); - /* ADDQ shouldn't return a message */ - if (header->request.opcode == PROTOCOL_BINARY_CMD_ADD) - { - response.message.header.response.cas= example_htonll(item->cas); - release_item(item); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - release_item(item); - return PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - } - else - { - release_item(item); - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); - } - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status replace_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - size_t keylen= ntohs(header->request.keylen); - size_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_replace *request= (protocol_binary_request_replace*)header; - uint32_t flags= ntohl(request->message.body.flags); - time_t timeout= (time_t)ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - struct item* item= get_item(key, keylen); - if (item == NULL) - { - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); - } - else if (header->request.cas == 0 || example_ntohll(header->request.cas) == item->cas) - { - release_item(item); - delete_item(key, keylen); - item= create_item(key, keylen, data, datalen, flags, timeout); - - if (item == NULL) - { - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); - } - else - { - put_item(item); - /* REPLACEQ shouldn't return a message */ - if (header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE) - { - response.message.header.response.cas= example_htonll(item->cas); - release_item(item); - return response_handler(cookie, header, (protocol_binary_response_header*)&response); - } - release_item(item); - return PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - } - else - { - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); - release_item(item); - } - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -static protocol_binary_response_status stat_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - /* Just send the terminating packet*/ - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= PROTOCOL_BINARY_CMD_STAT; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); - response.message.header.response.opaque= header->request.opaque; - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -memcached_binary_protocol_callback_st interface_v0_impl; - -void initialize_interface_v0_handler(util::log_info_st& arg) -{ - log_file= &arg; - - interface_v0_impl.interface_version= MEMCACHED_PROTOCOL_HANDLER_V0; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GET]= get_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_SET]= set_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_ADD]= add_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_REPLACE]= replace_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DELETE]= delete_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_INCREMENT]= arithmetic_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DECREMENT]= arithmetic_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_QUIT]= quit_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_FLUSH]= flush_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETQ]= get_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_NOOP]= noop_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_VERSION]= version_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETK]= get_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETKQ]= get_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_APPEND]= concat_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_PREPEND]= concat_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_STAT]= stat_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_SETQ]= set_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_ADDQ]= add_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_REPLACEQ]= replace_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DELETEQ]= delete_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_INCREMENTQ]= arithmetic_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DECREMENTQ]= arithmetic_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_QUITQ]= quit_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_FLUSHQ]= flush_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_APPENDQ]= concat_command_handler; - interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_PREPENDQ]= concat_command_handler; -} diff --git a/example/interface_v1.cc b/example/interface_v1.cc deleted file mode 100644 index 8afe12a3..00000000 --- a/example/interface_v1.cc +++ /dev/null @@ -1,417 +0,0 @@ -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -/** - * This file contains an implementation of the callback interface for level 1 - * in the protocol library. If you compare the implementation with the one - * in interface_v0.cc you will see that this implementation is much easier and - * hides all of the protocol logic and let you focus on the application - * logic. One "problem" with this layer is that it is synchronous, so that - * you will not receive the next command before a answer to the previous - * command is being sent. - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "example/memcached_light.h" -#include "example/storage.h" -#include "util/log.hpp" - -static datadifferential::util::log_info_st *log_file= NULL; - -static protocol_binary_response_status add_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void *data, - uint32_t datalen, - uint32_t flags, - uint32_t exptime, - uint64_t *cas) -{ - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - struct item* item= get_item(key, keylen); - if (item == NULL) - { - item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); - if (item == 0) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - put_item(item); - *cas= item->cas; - release_item(item); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - - return rval; -} - -static protocol_binary_response_status append_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint64_t cas, - uint64_t *result_cas) -{ - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - - struct item *item= get_item(key, keylen); - struct item *nitem; - - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - else if (cas != 0 && cas != item->cas) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, - item->flags, item->exp)) == NULL) - { - release_item(item); - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - memcpy(nitem->data, item->data, item->size); - memcpy(((char*)(nitem->data)) + item->size, val, vallen); - release_item(item); - delete_item(key, keylen); - put_item(nitem); - *result_cas= nitem->cas; - release_item(nitem); - } - - return rval; -} - -static protocol_binary_response_status decrement_handler(const void *cookie, - const void *key, - uint16_t keylen, - uint64_t delta, - uint64_t initial, - uint32_t expiration, - uint64_t *result, - uint64_t *result_cas) { - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - uint64_t val= initial; - struct item *item= get_item(key, keylen); - - if (item != NULL) - { - if (delta > *(uint64_t*)item->data) - val= 0; - else - val= *(uint64_t*)item->data - delta; - - expiration= (uint32_t)item->exp; - release_item(item); - delete_item(key, keylen); - } - - item= create_item(key, keylen, NULL, sizeof(initial), 0, (time_t)expiration); - if (item == 0) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - memcpy(item->data, &val, sizeof(val)); - put_item(item); - *result= val; - *result_cas= item->cas; - release_item(item); - } - - return rval; -} - -static protocol_binary_response_status delete_handler(const void *, // cookie - const void *key, - uint16_t keylen, - uint64_t cas) -{ - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - - if (cas != 0) - { - struct item *item= get_item(key, keylen); - if (item != NULL) - { - if (item->cas != cas) - { - release_item(item); - return PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - release_item(item); - } - } - - if (!delete_item(key, keylen)) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - - return rval; -} - - -static protocol_binary_response_status flush_handler(const void * /* cookie */, uint32_t /* when */) -{ - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status get_handler(const void *cookie, - const void *key, - uint16_t keylen, - memcached_binary_protocol_get_response_handler response_handler) { - struct item *item= get_item(key, keylen); - - if (item == NULL) - { - return PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - - protocol_binary_response_status rc; - rc= response_handler(cookie, key, (uint16_t)keylen, - item->data, (uint32_t)item->size, item->flags, - item->cas); - release_item(item); - return rc; -} - -static protocol_binary_response_status increment_handler(const void *cookie, - const void *key, - uint16_t keylen, - uint64_t delta, - uint64_t initial, - uint32_t expiration, - uint64_t *result, - uint64_t *result_cas) { - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - uint64_t val= initial; - struct item *item= get_item(key, keylen); - - if (item != NULL) - { - val= (*(uint64_t*)item->data) + delta; - expiration= (uint32_t)item->exp; - release_item(item); - delete_item(key, keylen); - } - - item= create_item(key, keylen, NULL, sizeof(initial), 0, (time_t)expiration); - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - char buffer[1024] = {0}; - memcpy(buffer, key, keylen); - memcpy(item->data, &val, sizeof(val)); - put_item(item); - *result= val; - *result_cas= item->cas; - release_item(item); - } - - return rval; -} - -static protocol_binary_response_status noop_handler(const void *cookie) { - (void)cookie; - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status prepend_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint64_t cas, - uint64_t *result_cas) { - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - - struct item *item= get_item(key, keylen); - struct item *nitem= NULL; - - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - else if (cas != 0 && cas != item->cas) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, - item->flags, item->exp)) == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - memcpy(nitem->data, val, vallen); - memcpy(((char*)(nitem->data)) + vallen, item->data, item->size); - release_item(item); - item= NULL; - delete_item(key, keylen); - put_item(nitem); - *result_cas= nitem->cas; - } - - if (item) - release_item(item); - - if (nitem) - release_item(nitem); - - return rval; -} - -static protocol_binary_response_status quit_handler(const void *) //cookie -{ - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -static protocol_binary_response_status replace_handler(const void *, // cookie - const void *key, - uint16_t keylen, - const void* data, - uint32_t datalen, - uint32_t flags, - uint32_t exptime, - uint64_t cas, - uint64_t *result_cas) -{ - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - struct item* item= get_item(key, keylen); - - if (item == NULL) - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; - } - else if (cas == 0 || cas == item->cas) - { - release_item(item); - delete_item(key, keylen); - item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); - if (item == 0) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - put_item(item); - *result_cas= item->cas; - release_item(item); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - release_item(item); - } - - return rval; -} - -static protocol_binary_response_status set_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void* data, - uint32_t datalen, - uint32_t flags, - uint32_t exptime, - uint64_t cas, - uint64_t *result_cas) { - (void)cookie; - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - - if (cas != 0) - { - struct item* item= get_item(key, keylen); - if (item != NULL && cas != item->cas) - { - /* Invalid CAS value */ - release_item(item); - return PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; - } - } - - delete_item(key, keylen); - struct item* item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); - if (item == 0) - { - rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - else - { - put_item(item); - *result_cas= item->cas; - release_item(item); - } - - return rval; -} - -static protocol_binary_response_status stat_handler(const void *cookie, - const void *, // key - uint16_t, // keylen, - memcached_binary_protocol_stat_response_handler response_handler) -{ - /* Just return an empty packet */ - return response_handler(cookie, NULL, 0, NULL, 0); -} - -static protocol_binary_response_status version_handler(const void *cookie, - memcached_binary_protocol_version_response_handler response_handler) -{ - const char *version= "0.1.1"; - return response_handler(cookie, version, (uint32_t)strlen(version)); -} - -memcached_binary_protocol_callback_st interface_v1_impl; - -void initialize_interface_v1_handler(datadifferential::util::log_info_st& arg) -{ - log_file= &arg; - memset(&interface_v1_impl, 0, sizeof(memcached_binary_protocol_callback_st)); - - interface_v1_impl.interface_version= MEMCACHED_PROTOCOL_HANDLER_V1; - interface_v1_impl.interface.v1.add= add_handler; - interface_v1_impl.interface.v1.append= append_handler; - interface_v1_impl.interface.v1.decrement= decrement_handler; - interface_v1_impl.interface.v1.delete_object= delete_handler; - interface_v1_impl.interface.v1.flush_object= flush_handler; - interface_v1_impl.interface.v1.get= get_handler; - interface_v1_impl.interface.v1.increment= increment_handler; - interface_v1_impl.interface.v1.noop= noop_handler; - interface_v1_impl.interface.v1.prepend= prepend_handler; - interface_v1_impl.interface.v1.quit= quit_handler; - interface_v1_impl.interface.v1.replace= replace_handler; - interface_v1_impl.interface.v1.set= set_handler; - interface_v1_impl.interface.v1.stat= stat_handler; - interface_v1_impl.interface.v1.version= version_handler; -} diff --git a/example/memcached_light.cc b/example/memcached_light.cc deleted file mode 100644 index 3f14c8ee..00000000 --- a/example/memcached_light.cc +++ /dev/null @@ -1,646 +0,0 @@ -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -/** - * What is a library without an example to show you how to use the library? - * This example use both interfaces to implement a small memcached server. - * Please note that this is an exemple on how to use the library, not - * an implementation of a scalable memcached server. If you look closely - * at the example it isn't even multithreaded ;-) - * - * With that in mind, let me give you some pointers into the source: - * storage.c/h - Implements the item store for this server and not really - * interesting for this example. - * interface_v0.cc - Shows an implementation of the memcached server by using - * the "raw" access to the packets as they arrive - * interface_v1.cc - Shows an implementation of the memcached server by using - * the more "logical" interface. - * memcached_light.cc- This file sets up all of the sockets and run the main - * message loop. - * - * - * config.h is included so that I can use the ntohll/htonll on platforms that - * doesn't have that (this is a private function inside libmemcached, so you - * cannot use it directly from libmemcached without special modifications to - * the library) - */ - -#include - -#include -#include -#include -#include "example/storage.h" -#include "example/memcached_light.h" - -#include "util/daemon.hpp" -#include "util/log.hpp" -#include "util/pidfile.hpp" - -using namespace datadifferential; - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern memcached_binary_protocol_callback_st interface_v0_impl; -extern memcached_binary_protocol_callback_st interface_v1_impl; - -static memcached_socket_t server_sockets[1024]; -static int num_server_sockets= 0; - -struct connection -{ - void *userdata; - struct event event; -}; - -/* The default maximum number of connections... (change with -c) */ -static int maxconns= 1024; - -static struct connection *socket_userdata_map; -static struct event_base *event_base= NULL; - -struct options_st { - std::string pid_file; - std::string service; - std::string log_file; - bool is_verbose; - bool opt_daemon; - - options_st() : - service("9999"), - is_verbose(false), - opt_daemon(false) - { - } -}; - -static options_st global_options; - -/** - * Callback for driving a client connection - * @param fd the socket for the client socket - * @param which identifying the event that occurred (not used) - * @param arg the connection structure for the client - */ -static void drive_client(memcached_socket_t fd, short, void *arg) -{ - struct connection *client= (struct connection*)arg; - struct memcached_protocol_client_st* c= (struct memcached_protocol_client_st*)client->userdata; - assert(c != NULL); - - memcached_protocol_event_t events= memcached_protocol_client_work(c); - if (events & MEMCACHED_PROTOCOL_ERROR_EVENT) - { - if (global_options.is_verbose) - { - struct sockaddr_in sin; - socklen_t addrlen= sizeof(sin); - - if (getsockname(fd, (struct sockaddr *)&sin, &addrlen) != -1) - { - std::cout << __FILE__ << ":" << __LINE__ - << " close(MEMCACHED_PROTOCOL_ERROR_EVENT)" - << " " << inet_ntoa(sin.sin_addr) << ":" << sin.sin_port - << " fd:" << fd - << std::endl; - } - else - { - std::cout << __FILE__ << ":" << __LINE__ << "close() MEMCACHED_PROTOCOL_ERROR_EVENT" << std::endl; - } - } - - memcached_protocol_client_destroy(c); - closesocket(fd); - } - else - { - short flags = 0; - if (events & MEMCACHED_PROTOCOL_WRITE_EVENT) - { - flags= EV_WRITE; - } - - if (events & MEMCACHED_PROTOCOL_READ_EVENT) - { - flags|= EV_READ; - } - - event_set(&client->event, int(fd), flags, drive_client, client); - event_base_set(event_base, &client->event); - - if (event_add(&client->event, 0) == -1) - { - memcached_protocol_client_destroy(c); - closesocket(fd); - } - } -} - -/** - * Callback for accepting new connections - * @param fd the socket for the server socket - * @param which identifying the event that occurred (not used) - * @param arg the connection structure for the server - */ -static void accept_handler(memcached_socket_t fd, short, void *arg) -{ - struct connection *server= (struct connection *)arg; - /* accept new client */ - struct sockaddr_storage addr; - socklen_t addrlen= sizeof(addr); - memcached_socket_t sock= accept(fd, (struct sockaddr *)&addr, &addrlen); - - if (sock == INVALID_SOCKET) - { - perror("Failed to accept client"); - } - -#ifndef WIN32 - if (sock >= maxconns) - { - closesocket(sock); - return ; - } -#endif - - struct memcached_protocol_client_st* c= memcached_protocol_create_client((memcached_protocol_st*)server->userdata, sock); - if (c == NULL) - { - closesocket(sock); - } - else - { - memcached_protocol_client_set_verbose(c, global_options.is_verbose); - struct connection *client = &socket_userdata_map[sock]; - client->userdata= c; - - event_set(&client->event, int(sock), EV_READ, drive_client, client); - event_base_set(event_base, &client->event); - if (event_add(&client->event, 0) == -1) - { - std::cerr << "Failed to add event for " << sock << std::endl; - memcached_protocol_client_destroy(c); - closesocket(sock); - } - } -} - -static bool server_socket(util::log_info_st& log_file, const std::string& service) -{ - struct addrinfo *ai; - struct addrinfo hints; - memset(&hints, 0, sizeof(struct addrinfo)); - - hints.ai_flags= AI_PASSIVE; - hints.ai_family= AF_UNSPEC; - hints.ai_socktype= SOCK_STREAM; - - int error= getaddrinfo("127.0.0.1", service.c_str(), &hints, &ai); - if (error != 0) - { - if (error != EAI_SYSTEM) - { - std::string buffer("getaddrinfo: "); - buffer+= gai_strerror(error); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - } - else - { - std::string buffer("getaddrinfo: "); - buffer+= strerror(errno); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - } - - return false; - } - - struct linger ling= {0, 0}; - - for (struct addrinfo *next= ai; next; next= next->ai_next) - { - memcached_socket_t sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (sock == INVALID_SOCKET) - { - std::string buffer("Failed to create socket: "); - buffer+= strerror(errno); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - continue; - } - - int flags; -#ifdef WIN32 - u_long arg = 1; - if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR) - { - std::cerr << "Failed to set nonblocking io: " << strerror(errno) << std::endl; - closesocket(sock); - continue; - } -#else - flags= fcntl(sock, F_GETFL, 0); - if (flags == -1) - { - std::string buffer("Failed to get socket flags: "); - buffer+= strerror(errno); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - closesocket(sock); - continue; - } - - if ((flags & O_NONBLOCK) != O_NONBLOCK) - { - if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) - { - std::string buffer("Failed to set socket to nonblocking mode: "); - buffer+= strerror(errno); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - closesocket(sock); - continue; - } - } -#endif - - flags= 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)) != 0) - { - std::cerr << "Failed to set SO_REUSEADDR: " << strerror(errno) << std::endl; - } - - if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)) != 0) - { - std::cerr << "Failed to set SO_KEEPALIVE: " << strerror(errno) << std::endl; - } - - if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)) != 0) - { - std::cerr << "Failed to set SO_LINGER: " << strerror(errno) << std::endl; - } - - if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)) != 0) - { - std::cerr << "Failed to set TCP_NODELAY: " << strerror(errno) << std::endl; - } - - if (bind(sock, next->ai_addr, next->ai_addrlen) == SOCKET_ERROR) - { - if (get_socket_errno() != EADDRINUSE) - { - std::cerr << "bind(): " << strerror(errno) << std::endl; - freeaddrinfo(ai); - } - closesocket(sock); - continue; - } - - if (listen(sock, 1024) == SOCKET_ERROR) - { - std::string buffer("listen(): "); - buffer+= strerror(errno); - log_file.write(util::VERBOSE_ERROR, buffer.c_str()); - closesocket(sock); - continue; - } - - if (global_options.is_verbose) - { - std::string buffer("Listening to: "); - buffer+= global_options.service; - log_file.write(util::VERBOSE_NOTICE, buffer.c_str()); - } - - server_sockets[num_server_sockets++]= sock; - } - - freeaddrinfo(ai); - - return (num_server_sockets > 0) ? true : false; -} - -/** - * Convert a command code to a textual string - * @param cmd the comcode to convert - * @return a textual string with the command or NULL for unknown commands - */ -static const char* comcode2str(uint8_t cmd) -{ - static const char * const text[] = { - "GET", "SET", "ADD", "REPLACE", "DELETE", - "INCREMENT", "DECREMENT", "QUIT", "FLUSH", - "GETQ", "NOOP", "VERSION", "GETK", "GETKQ", - "APPEND", "PREPEND", "STAT", "SETQ", "ADDQ", - "REPLACEQ", "DELETEQ", "INCREMENTQ", "DECREMENTQ", - "QUITQ", "FLUSHQ", "APPENDQ", "PREPENDQ" - }; - - if (cmd <= PROTOCOL_BINARY_CMD_PREPENDQ) - { - return text[cmd]; - } - - return NULL; -} - -/** - * Print out the command we are about to execute - */ -static void pre_execute(const void *cookie, - protocol_binary_request_header *header) -{ - if (global_options.is_verbose) - { - if (header) - { - const char *cmd= comcode2str(header->request.opcode); - if (cmd != NULL) - { - std::cout << "pre_execute from " << cookie << ": " << cmd << std::endl; - } - else - { - std::cout << "pre_execute from " << cookie << ": " << header->request.opcode << std::endl; - } - } - else - { - std::cout << "pre_execute from " << cookie << std::endl; - } - } -} - -/** - * Print out the command we just executed - */ -static void post_execute(const void *cookie, - protocol_binary_request_header *header) -{ - if (global_options.is_verbose) - { - if (header) - { - const char *cmd= comcode2str(header->request.opcode); - if (cmd != NULL) - { - std::cout << "post_execute from " << cookie << ": " << cmd << std::endl; - } - else - { - std::cout << "post_execute from " << cookie << ": " << header->request.opcode << std::endl; - } - } - else - { - std::cout << "post_execute from " << cookie << std::endl; - } - } -} - -/** - * Callback handler for all unknown commands. - * Send an unknown command back to the client - */ -static protocol_binary_response_status unknown(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_response_no_extras response; - memset(&response, 0, sizeof(protocol_binary_response_no_extras)); - - response.message.header.response.magic= PROTOCOL_BINARY_RES; - response.message.header.response.opcode= header->request.opcode; - response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND); - response.message.header.response.opaque= header->request.opaque; - - return response_handler(cookie, header, (protocol_binary_response_header*)&response); -} - -/** - * Program entry point. Bind to the specified port(s) and serve clients - * - * @param argc number of items in the argument vector - * @param argv argument vector - * @return EXIT_SUCCESS on success, 1 otherwise - */ -int main(int argc, char **argv) -{ - memcached_binary_protocol_callback_st *interface= &interface_v0_impl; - - { - enum long_option_t { - OPT_HELP, - OPT_VERBOSE, - OPT_DAEMON, - OPT_PROTOCOL_VERSION, - OPT_VERSION, - OPT_PORT, - OPT_MAX_CONNECTIONS, - OPT_LOGFILE, - OPT_PIDFILE - }; - - static struct option long_options[]= - { - { "help", no_argument, NULL, OPT_HELP }, - { "port", required_argument, NULL, OPT_PORT }, - { "verbose", no_argument, NULL, OPT_VERBOSE }, - { "daemon", no_argument, NULL, OPT_DAEMON }, - { "protocol", no_argument, NULL, OPT_PROTOCOL_VERSION }, - { "version", no_argument, NULL, OPT_VERSION }, - { "max-connections", required_argument, NULL, OPT_MAX_CONNECTIONS }, - { "pid-file", required_argument, NULL, OPT_PIDFILE }, - { "log-file", required_argument, NULL, OPT_LOGFILE }, - {0, 0, 0, 0} - }; - - bool opt_help= false; - int option_index; - bool done= false; - while (done == false) - { - switch (getopt_long(argc, argv, "", long_options, &option_index)) - { - case -1: - done= true; - break; - - case OPT_PROTOCOL_VERSION: - interface= &interface_v1_impl; - break; - - case OPT_PIDFILE: - global_options.pid_file= optarg; - break; - - case OPT_LOGFILE: - global_options.log_file= optarg; - break; - - case OPT_VERBOSE: - global_options.is_verbose= true; - break; - - case OPT_VERSION: - break; - - case OPT_DAEMON: - global_options.opt_daemon= true; - break; - - case OPT_PORT: - global_options.service= optarg; - break; - - case OPT_MAX_CONNECTIONS: - maxconns= atoi(optarg); - break; - - case OPT_HELP: /* FALLTHROUGH */ - opt_help= true; - break; - - default: - { - std::cerr << "Unknown option: " << optarg << std::endl; - return EXIT_FAILURE; - } - } - } - - if (opt_help) - { - std::cout << "Usage: " << argv[0] << std::endl; - for (struct option *ptr_option= long_options; ptr_option->name; ptr_option++) - { - std::cout << "\t" << ptr_option->name << std::endl; - } - return EXIT_SUCCESS; - } - } - - if (global_options.opt_daemon) - { - util::daemonize(false, true); - } - - if (initialize_storage() == false) - { - /* Error message already printed */ - return EXIT_FAILURE; - } - - util::Pidfile _pid_file(global_options.pid_file); - - if (_pid_file.create() == false) - { - std::cerr << "Failed to create pid-file" << _pid_file.error_message() << std::endl; - return EXIT_FAILURE; - } - - util::log_info_st log_file(argv[0], global_options.log_file, false); - log_file.write(util::VERBOSE_NOTICE, "starting log"); - - /* - * We need to initialize the handlers manually due to a bug in the - * warnings generated by struct initialization in gcc (all the way up to 4.4) - */ - initialize_interface_v0_handler(log_file); - initialize_interface_v1_handler(log_file); - - - if (server_socket(log_file, global_options.service) == false) - { - return EXIT_FAILURE; - } - - if (num_server_sockets == 0) - { - log_file.write(util::VERBOSE_ERROR, "No server sockets are available."); - return EXIT_FAILURE; - } - - /* - * Create and initialize the handles to the protocol handlers. I want - * to be able to trace the traffic throught the pre/post handlers, and - * set up a common handler for unknown messages - */ - interface->pre_execute= pre_execute; - interface->post_execute= post_execute; - interface->unknown= unknown; - - struct memcached_protocol_st *protocol_handle; - if ((protocol_handle= memcached_protocol_create_instance()) == NULL) - { - log_file.write(util::VERBOSE_ERROR, "No server sockets are available."); - return EXIT_FAILURE; - } - - socket_userdata_map= (struct connection*)calloc((size_t)(maxconns), sizeof(struct connection)); - if (socket_userdata_map == NULL) - { - log_file.write(util::VERBOSE_ERROR, "Failed to allocate room for connections"); - return EXIT_FAILURE; - } - - memcached_binary_protocol_set_callbacks(protocol_handle, interface); - memcached_binary_protocol_set_pedantic(protocol_handle, true); - - event_base= event_init(); - if (event_base == NULL) - { - std::cerr << "Failed to create an instance of libevent" << std::endl; - return EXIT_FAILURE; - } - - for (int xx= 0; xx < num_server_sockets; ++xx) - { - struct connection *conn= &socket_userdata_map[server_sockets[xx]]; - conn->userdata= protocol_handle; - - event_set(&conn->event, int(server_sockets[xx]), EV_READ | EV_PERSIST, accept_handler, conn); - - event_base_set(event_base, &conn->event); - if (event_add(&conn->event, 0) == -1) - { - log_file.write(util::VERBOSE_ERROR, "Failed to add event"); - closesocket(server_sockets[xx]); - } - } - - if (global_options.opt_daemon) - { - if (util::daemon_is_ready(true) == false) - { - log_file.write(util::VERBOSE_ERROR, "Failed for util::daemon_is_ready()"); - return EXIT_FAILURE; - } - } - - - /* Serve all of the clients */ - switch (event_base_loop(event_base, 0)) - { - case -1: - log_file.write(util::VERBOSE_ERROR, "event_base_loop() failed"); - break; - - case 1: - log_file.write(util::VERBOSE_ERROR, "event_base_loop(), no events were registered"); - break; - - default: - break; - } - log_file.write(util::VERBOSE_NOTICE, "exiting"); - - /* NOTREACHED */ - return EXIT_SUCCESS; -} diff --git a/example/memcached_light.h b/example/memcached_light.h deleted file mode 100644 index 6abb8744..00000000 --- a/example/memcached_light.h +++ /dev/null @@ -1,44 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Memcached Light interface definitions - * - * Copyright (C) 2012 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -#pragma once - -#include "util/log.hpp" - -void initialize_interface_v0_handler(datadifferential::util::log_info_st&); -void initialize_interface_v1_handler(datadifferential::util::log_info_st&); diff --git a/example/storage.cc b/example/storage.cc deleted file mode 100644 index 2e63a3e3..00000000 --- a/example/storage.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -#include "config.h" -#include -#include -#include -#include -#include -#include "storage.h" - -struct list_entry { - struct item item; - struct list_entry *next; - struct list_entry *prev; -}; - -static struct list_entry *root; -static uint64_t cas; - -bool initialize_storage(void) -{ - return true; -} - -void shutdown_storage(void) -{ - /* Do nothing */ -} - -void put_item(struct item* item) -{ - struct list_entry* entry= (struct list_entry*)item; - - update_cas(item); - - if (root == NULL) - { - entry->next= entry->prev= entry; - } - else - { - entry->prev= root->prev; - entry->next= root; - entry->prev->next= entry; - entry->next->prev= entry; - } - - root= entry; -} - -struct item* get_item(const void* key, size_t nkey) -{ - struct list_entry *walker= root; - - if (root == NULL) - { - return NULL; - } - - do - { - if (((struct item*)walker)->nkey == nkey && - memcmp(((struct item*)walker)->key, key, nkey) == 0) - { - return (struct item*)walker; - } - walker= walker->next; - } while (walker != root); - - return NULL; -} - -struct item* create_item(const void* key, size_t nkey, const void* data, - size_t size, uint32_t flags, time_t exp) -{ - struct item* ret= (struct item*)calloc(1, sizeof(struct list_entry)); - - if (ret != NULL) - { - ret->key= malloc(nkey); - if (size > 0) - { - ret->data= malloc(size); - } - - if (ret->key == NULL || (size > 0 && ret->data == NULL)) - { - free(ret->key); - free(ret->data); - free(ret); - return NULL; - } - - memcpy(ret->key, key, nkey); - if (data != NULL) - { - memcpy(ret->data, data, size); - } - - ret->nkey= nkey; - ret->size= size; - ret->flags= flags; - ret->exp= exp; - } - - return ret; -} - -bool delete_item(const void* key, size_t nkey) -{ - struct item* item= get_item(key, nkey); - bool ret= false; - - if (item) - { - /* remove from linked list */ - struct list_entry *entry= (struct list_entry*)item; - - if (entry->next == entry) - { - /* Only one object in the list */ - root= NULL; - } - else - { - /* ensure that we don't loose track of the root, and this will - * change the start position for the next search ;-) */ - root= entry->next; - entry->prev->next= entry->next; - entry->next->prev= entry->prev; - } - - free(item->key); - free(item->data); - free(item); - ret= true; - } - - return ret; -} - -void flush(uint32_t /* when */) -{ - /* remove the complete linked list */ - if (root == NULL) - { - return; - } - - root->prev->next= NULL; - while (root != NULL) - { - struct item* tmp= (struct item*)root; - root= root->next; - - free(tmp->key); - free(tmp->data); - free(tmp); - } -} - -void update_cas(struct item* item) -{ - item->cas= ++cas; -} - -void release_item(struct item* /* item */) -{ -} diff --git a/example/storage.h b/example/storage.h deleted file mode 100644 index bd1b8780..00000000 --- a/example/storage.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -#pragma once - -struct item { - uint64_t cas; - void* key; - size_t nkey; - void* data; - size_t size; - uint32_t flags; - time_t exp; -}; - -bool initialize_storage(void); -void shutdown_storage(void); - -void update_cas(struct item* item); -void put_item(struct item* item); -struct item* get_item(const void* key, size_t nkey); -struct item* create_item(const void* key, size_t nkey, const void *data, - size_t size, uint32_t flags, time_t exp); -bool delete_item(const void* key, size_t nkey); -void flush(uint32_t when); -void release_item(struct item* item); diff --git a/example/t/include.am b/example/t/include.am deleted file mode 100644 index 394e4c6c..00000000 --- a/example/t/include.am +++ /dev/null @@ -1,40 +0,0 @@ -# vim:ft=automake -# Copyright (C) 2012 Data Differential -# All rights reserved. -# -# Use and distribution licensed under the BSD license. See -# the COPYING file in the parent directory for full text. -# -# included from Top Level Makefile.am -# All paths should be given relative to the root - -MEMCACHED_LIGHT_TESTS_LDADDS= \ - libmemcached/libmemcached.la \ - libmemcached/libmemcachedutil.la \ - libtest/libtest.la - -example_t_memcached_light_CXXFLAGS= -example_t_memcached_light_DEPENDENCIES= -example_t_memcached_light_LDADD= -example_t_memcached_light_SOURCES= - -example_t_memcached_light_SOURCES+= example/t/memcached_light.cc -example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc -example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc -example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc -example_t_memcached_light_CXXFLAGS+= $(AM_CXXFLAGS) -example_t_memcached_light_DEPENDENCIES+= $(MEMCACHED_LIGHT_TESTS_LDADDS) -example_t_memcached_light_DEPENDENCIES+= example/memcached_light -example_t_memcached_light_LDADD+= $(MEMCACHED_LIGHT_TESTS_LDADDS) -example_t_memcached_light_LDADD+= $(LIBUUID_LDFLAGS) -check_PROGRAMS+= example/t/memcached_light -noinst_PROGRAMS+= example/t/memcached_light - -test-memcached_light: example/t/memcached_light example/memcached_light - @example/t/memcached_light - -gdb-memcached_light: example/t/memcached_light example/memcached_light - @$(DEBUG_COMMAND) example/t/memcached_light - -valgrind-memcached_light: example/t/memcached_light example/memcached_light - $(VALGRIND_COMMAND) example/t/memcached_light diff --git a/example/t/memcached_light.cc b/example/t/memcached_light.cc deleted file mode 100644 index c5956b24..00000000 --- a/example/t/memcached_light.cc +++ /dev/null @@ -1,248 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Test memcat - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/* - Test that we are cycling the servers we are creating during testing. -*/ - -#include - -#include -#include - -#include "tests/libmemcached-1.0/memcached_get.h" - -using namespace libtest; - -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif - -static std::string executable("example/memcached_light"); - -static test_return_t help_TEST(void *) -{ - const char *args[]= { "--help", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t verbose_TEST(void *) -{ - const char *args[]= { "--help", "--verbose", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t daemon_TEST(void *) -{ - const char *args[]= { "--help", "--daemon", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t protocol_TEST(void *) -{ - const char *args[]= { "--help", "--protocol", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t version_TEST(void *) -{ - const char *args[]= { "--help", "--version", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t port_TEST(void *) -{ - const char *args[]= { "--help", "--port=9090", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t pid_file_TEST(void *) -{ - const char *args[]= { "--help", "--pid-file=/tmp/foo.pid", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t log_file_TEST(void *) -{ - const char *args[]= { "--help", "--log-file=/tmp/foo.log", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -static test_return_t max_connections_file_TEST(void *) -{ - const char *args[]= { "--help", "--max-connections=/tmp/foo.max_connections", 0 }; - - test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); - - return TEST_SUCCESS; -} - -typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *); - -static test_return_t _runner_default(libmemcached_test_callback_fn func, void *object) -{ - if (func) - { - test_true(object); - test_return_t ret; - try { - ret= func((memcached_st*)object); - } - catch (std::exception& e) - { - libtest::Error << e.what(); - return TEST_FAILURE; - } - - return ret; - } - - return TEST_SUCCESS; -} - -class MemcachedLightRunner : public libtest::Runner { -public: - test_return_t run(test_callback_fn* func, void *object) - { - return _runner_default(libmemcached_test_callback_fn(func), object); - } -}; - -test_st cmdline_option_TESTS[] ={ - {"--help", true, help_TEST }, - {"--verbose", true, verbose_TEST }, - {"--daemon", true, daemon_TEST }, - {"--protocol", true, protocol_TEST }, - {"--version", true, version_TEST }, - {"--port", true, port_TEST }, - {"--pid-file", true, pid_file_TEST }, - {"--log-file", true, log_file_TEST }, - {"--max-connections", true, max_connections_file_TEST }, - {0, 0, 0} -}; - -/* Clean the server before beginning testing */ -test_st basic_TESTS[] ={ -#if 0 - {"memcached_get()", true, (test_callback_fn*)get_test }, - {"memcached_get() test 2", false, (test_callback_fn*)get_test2 }, - {"memcached_get() test 3", false, (test_callback_fn*)get_test3 }, - {"memcached_get() test 4", false, (test_callback_fn*)get_test4 }, - {"memcached_get() test 5", false, (test_callback_fn*)get_test5 }, -#endif - {0, 0, 0} -}; - -collection_st collection[] ={ - {"command line options", 0, 0, cmdline_option_TESTS }, - {"basic", 0, 0, basic_TESTS }, - {0, 0, 0, 0} -}; - -static void *world_create(server_startup_st& servers, test_return_t& error) -{ - if (access(executable.c_str(), X_OK) != 0) - { - error= TEST_SKIPPED; - return NULL; - } - - if (HAVE_MEMCACHED_LIGHT_BINARY == 0) - { - error= TEST_SKIPPED; - return NULL; - } - - if (server_startup(servers, "memcached-light", libtest::default_port(), 0, NULL) == 0) - { - error= TEST_FAILURE; - return NULL; - } - - - char buffer[1024]; - int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(libtest::default_port())); - fatal_assert(length > 0); - - memcached_st *memc= memcached(buffer, length); - - fatal_assert(memc); - - return (void*)memc; -} - -static bool world_destroy(void *object) -{ - memcached_st *memc= (memcached_st*)object; - memcached_free(memc); - - return TEST_SUCCESS; -} - - -void get_world(libtest::Framework* world) -{ - world->create(world_create); - world->destroy(world_destroy); - world->collections(collection); - world->set_runner(new MemcachedLightRunner); -} - diff --git a/libmemcached-1.0/alloc.h b/libmemcached-1.0/alloc.h deleted file mode 100644 index bc65b951..00000000 --- a/libmemcached-1.0/alloc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/** - Memory allocation functions. -*/ -typedef void (*memcached_free_fn)(const memcached_st *ptr, void *mem, void *context); -typedef void *(*memcached_malloc_fn)(const memcached_st *ptr, const size_t size, void *context); -typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context); -typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/allocators.h b/libmemcached-1.0/allocators.h deleted file mode 100644 index 86f05a06..00000000 --- a/libmemcached-1.0/allocators.h +++ /dev/null @@ -1,64 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, - memcached_malloc_fn mem_malloc, - memcached_free_fn mem_free, - memcached_realloc_fn mem_realloc, - memcached_calloc_fn mem_calloc, - void *context); - -LIBMEMCACHED_API -void memcached_get_memory_allocators(const memcached_st *ptr, - memcached_malloc_fn *mem_malloc, - memcached_free_fn *mem_free, - memcached_realloc_fn *mem_realloc, - memcached_calloc_fn *mem_calloc); - -LIBMEMCACHED_API -void *memcached_get_memory_allocators_context(const memcached_st *ptr); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/analyze.h b/libmemcached-1.0/analyze.h deleted file mode 100644 index 0da38143..00000000 --- a/libmemcached-1.0/analyze.h +++ /dev/null @@ -1,56 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_analysis_st *memcached_analyze(memcached_st *memc, - memcached_stat_st *memc_stat, - memcached_return_t *error); - -LIBMEMCACHED_API -void memcached_analyze_free(memcached_analysis_st *); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/auto.h b/libmemcached-1.0/auto.h deleted file mode 100644 index f37d50fc..00000000 --- a/libmemcached-1.0/auto.h +++ /dev/null @@ -1,111 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API - memcached_return_t memcached_increment(memcached_st *ptr, - const char *key, size_t key_length, - uint32_t offset, - uint64_t *value); -LIBMEMCACHED_API - memcached_return_t memcached_decrement(memcached_st *ptr, - const char *key, size_t key_length, - uint32_t offset, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_increment_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - uint64_t offset, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_decrement_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - uint64_t offset, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_increment_with_initial(memcached_st *ptr, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, - const char *group_key, - size_t group_key_length, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value); - -LIBMEMCACHED_API - memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, - const char *group_key, - size_t group_key_length, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/basic_string.h b/libmemcached-1.0/basic_string.h deleted file mode 100644 index de8d3d51..00000000 --- a/libmemcached-1.0/basic_string.h +++ /dev/null @@ -1,55 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -// No assumptions of NULL should be made - -struct memcached_string_t { - const char *c_str; - size_t size; -}; - -#define memcached_size(X) (X).size; -#define memcached_c_str(X) (X).c_str; -#define memcached_string_param(X) (X).c_str, (X).size - -#ifdef __cplusplus -#define memcached_string_printf(X) int((X).size), (X).c_str -#else -#define memcached_string_printf(X) (int)((X).size), (X).c_str -#endif - diff --git a/libmemcached-1.0/behavior.h b/libmemcached-1.0/behavior.h deleted file mode 100644 index c6633532..00000000 --- a/libmemcached-1.0/behavior.h +++ /dev/null @@ -1,83 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data); - -LIBMEMCACHED_API -uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag); - -LIBMEMCACHED_API -memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type); - -LIBMEMCACHED_API -memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type); - -LIBMEMCACHED_API -memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type); - -LIBMEMCACHED_API -memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr); - -LIBMEMCACHED_API - const char *libmemcached_string_behavior(const memcached_behavior_t flag); - -LIBMEMCACHED_API - const char *libmemcached_string_distribution(const memcached_server_distribution_t flag); - -LIBMEMCACHED_API - memcached_return_t memcached_bucket_set(memcached_st *self, - const uint32_t *host_map, - const uint32_t *forward_map, - const uint32_t buckets, - const uint32_t replicas); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/callback.h b/libmemcached-1.0/callback.h deleted file mode 100644 index a62e9aa6..00000000 --- a/libmemcached-1.0/callback.h +++ /dev/null @@ -1,55 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_callback_set(memcached_st *ptr, - const memcached_callback_t flag, - const void *data); -LIBMEMCACHED_API -void *memcached_callback_get(memcached_st *ptr, - const memcached_callback_t flag, - memcached_return_t *error); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/callbacks.h b/libmemcached-1.0/callbacks.h deleted file mode 100644 index e321ceb4..00000000 --- a/libmemcached-1.0/callbacks.h +++ /dev/null @@ -1,53 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); -typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); -typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server, - const char *key, size_t key_length, - const char *value, size_t value_length, - void *context); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/configure.h.in b/libmemcached-1.0/configure.h.in deleted file mode 100644 index 3f0465a0..00000000 --- a/libmemcached-1.0/configure.h.in +++ /dev/null @@ -1,52 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker, Trond Norbye All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -@DEPRECATED@ -@LIBMEMCACHED_WITH_SASL_SUPPORT@ - -#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION_STRING@" -#define LIBMEMCACHED_VERSION_HEX @LIBMEMCACHED_VERSION_HEX@ - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/defaults.h b/libmemcached-1.0/defaults.h deleted file mode 100644 index 38c29ba3..00000000 --- a/libmemcached-1.0/defaults.h +++ /dev/null @@ -1,55 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -/* Public defines */ -#define MEMCACHED_DEFAULT_PORT 11211 -#define MEMCACHED_POINTS_PER_SERVER 100 -#define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 -#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */ -#define MEMCACHED_STRIDE 4 -#define MEMCACHED_DEFAULT_TIMEOUT 5000 -#define MEMCACHED_DEFAULT_CONNECT_TIMEOUT 4000 -#define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should build for in the continuum */ -#define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU -#define MEMCACHED_SERVER_FAILURE_LIMIT 5 -#define MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT 2 -#define MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT 0 - - diff --git a/libmemcached-1.0/delete.h b/libmemcached-1.0/delete.h deleted file mode 100644 index 617d5857..00000000 --- a/libmemcached-1.0/delete.h +++ /dev/null @@ -1,57 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length, - time_t expiration); - -LIBMEMCACHED_API -memcached_return_t memcached_delete_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - time_t expiration); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/deprecated_types.h b/libmemcached-1.0/deprecated_types.h deleted file mode 100644 index 716d3e44..00000000 --- a/libmemcached-1.0/deprecated_types.h +++ /dev/null @@ -1,60 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * Warning, none of these should ever be used. - */ - -#pragma once - -/** - @note The following definitions are just here for backwards compatibility. -*/ -typedef memcached_return_t memcached_return; -typedef memcached_server_distribution_t memcached_server_distribution; -typedef memcached_behavior_t memcached_behavior; -typedef memcached_callback_t memcached_callback; -typedef memcached_hash_t memcached_hash; -typedef memcached_connection_t memcached_connection; -typedef memcached_clone_fn memcached_clone_func; -typedef memcached_cleanup_fn memcached_cleanup_func; -typedef memcached_execute_fn memcached_execute_function; -typedef memcached_server_fn memcached_server_function; -typedef memcached_trigger_key_fn memcached_trigger_key; -typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key; -typedef memcached_dump_fn memcached_dump_func; - diff --git a/libmemcached-1.0/dump.h b/libmemcached-1.0/dump.h deleted file mode 100644 index b6e639e8..00000000 --- a/libmemcached-1.0/dump.h +++ /dev/null @@ -1,51 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); - - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/encoding_key.h b/libmemcached-1.0/encoding_key.h deleted file mode 100644 index 3adbcb62..00000000 --- a/libmemcached-1.0/encoding_key.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2012 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API - memcached_return_t memcached_set_encoding_key(memcached_st*, const char *str, size_t length); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/error.h b/libmemcached-1.0/error.h deleted file mode 100644 index 7fdc18b8..00000000 --- a/libmemcached-1.0/error.h +++ /dev/null @@ -1,67 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * LibMemcached - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API - const char *memcached_error(const memcached_st *); - -LIBMEMCACHED_API - const char *memcached_last_error_message(const memcached_st *); - -LIBMEMCACHED_API - void memcached_error_print(const memcached_st *); - -LIBMEMCACHED_API - memcached_return_t memcached_last_error(const memcached_st *); - -LIBMEMCACHED_API - int memcached_last_error_errno(const memcached_st *); - -LIBMEMCACHED_API - const char *memcached_server_error(const memcached_server_instance_st ptr); - -LIBMEMCACHED_API - memcached_return_t memcached_server_error_return(const memcached_server_instance_st ptr); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/exception.hpp b/libmemcached-1.0/exception.hpp deleted file mode 100644 index 4759072a..00000000 --- a/libmemcached-1.0/exception.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Summary: Exceptions for the C++ interface - * - * Copy: See Copyright for the status of this software. - * - */ - -/** - * @file - * @brief Exception declarations - */ - -#pragma once - -#include -#include - -namespace memcache -{ - class Exception : public std::runtime_error - { - public: - Exception(const std::string& msg, int in_errno) - : - std::runtime_error(msg), - _errno(in_errno) - {} - - Exception(const char *msg, int in_errno) - : - std::runtime_error(std::string(msg)), - _errno(in_errno) {} - - virtual ~Exception() throw() {} - - int getErrno() const - { - return _errno; - } - - private: - int _errno; - }; - - class Warning : public Exception - { - public: - Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} - Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {} - }; - - class Error : public Exception - { - public: - Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} - Error(const char *msg, int in_errno) : Exception(msg, in_errno) {} - virtual ~Error() throw() {} - }; - -} /* namespace libmemcached */ diff --git a/libmemcached-1.0/exist.h b/libmemcached-1.0/exist.h deleted file mode 100644 index ef60a81a..00000000 --- a/libmemcached-1.0/exist.h +++ /dev/null @@ -1,52 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_exist(memcached_st *memc, const char *key, size_t key_length); - -LIBMEMCACHED_API -memcached_return_t memcached_exist_by_key(memcached_st *memc, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length); -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/fetch.h b/libmemcached-1.0/fetch.h deleted file mode 100644 index bff186ac..00000000 --- a/libmemcached-1.0/fetch.h +++ /dev/null @@ -1,53 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_fetch_execute(memcached_st *ptr, - memcached_execute_fn *callback, - void *context, - uint32_t number_of_callbacks); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/flush.h b/libmemcached-1.0/flush.h deleted file mode 100644 index 820a98e7..00000000 --- a/libmemcached-1.0/flush.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/flush_buffers.h b/libmemcached-1.0/flush_buffers.h deleted file mode 100644 index 31b58687..00000000 --- a/libmemcached-1.0/flush_buffers.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_flush_buffers(memcached_st *mem); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/get.h b/libmemcached-1.0/get.h deleted file mode 100644 index 32e4c5f3..00000000 --- a/libmemcached-1.0/get.h +++ /dev/null @@ -1,110 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Public defines */ -LIBMEMCACHED_API -char *memcached_get(memcached_st *ptr, - const char *key, size_t key_length, - size_t *value_length, - uint32_t *flags, - memcached_return_t *error); - -LIBMEMCACHED_API -memcached_return_t memcached_mget(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys); - -LIBMEMCACHED_API -char *memcached_get_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - size_t *value_length, - uint32_t *flags, - memcached_return_t *error); - -LIBMEMCACHED_API -memcached_return_t memcached_mget_by_key(memcached_st *ptr, - const char *group_key, - size_t group_key_length, - const char * const *keys, - const size_t *key_length, - const size_t number_of_keys); - -LIBMEMCACHED_API -char *memcached_fetch(memcached_st *ptr, - char *key, - size_t *key_length, - size_t *value_length, - uint32_t *flags, - memcached_return_t *error); - -LIBMEMCACHED_API -memcached_result_st *memcached_fetch_result(memcached_st *ptr, - memcached_result_st *result, - memcached_return_t *error); - -LIBMEMCACHED_API -memcached_return_t memcached_mget_execute(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - const size_t number_of_keys, - memcached_execute_fn *callback, - void *context, - const uint32_t number_of_callbacks); - -LIBMEMCACHED_API -memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, - const char *group_key, - size_t group_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_fn *callback, - void *context, - const uint32_t number_of_callbacks); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/hash.h b/libmemcached-1.0/hash.h deleted file mode 100644 index 9fdb7d6f..00000000 --- a/libmemcached-1.0/hash.h +++ /dev/null @@ -1,65 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* The two public hash bits */ -LIBMEMCACHED_API -uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm); - -LIBMEMCACHED_API -const hashkit_st *memcached_get_hashkit(const memcached_st *ptr); - -LIBMEMCACHED_API -memcached_return_t memcached_set_hashkit(memcached_st *ptr, hashkit_st *hashk); - -LIBMEMCACHED_API -uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length); - -LIBMEMCACHED_API -void memcached_autoeject(memcached_st *ptr); - -LIBMEMCACHED_API - const char * libmemcached_string_hash(memcached_hash_t type); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/include.am b/libmemcached-1.0/include.am deleted file mode 100644 index 19e48289..00000000 --- a/libmemcached-1.0/include.am +++ /dev/null @@ -1,56 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -EXTRA_DIST+= libmemcached-1.0/configure.h.in -BUILT_SOURCES+= libmemcached-1.0/configure.h - -include libmemcached-1.0/struct/include.am -include libmemcached-1.0/types/include.am - -# Tests for this version of the interface -include libmemcached-1.0/t/include.am - -nobase_include_HEADERS+= libmemcached-1.0/alloc.h -nobase_include_HEADERS+= libmemcached-1.0/allocators.h -nobase_include_HEADERS+= libmemcached-1.0/analyze.h -nobase_include_HEADERS+= libmemcached-1.0/auto.h -nobase_include_HEADERS+= libmemcached-1.0/basic_string.h -nobase_include_HEADERS+= libmemcached-1.0/behavior.h -nobase_include_HEADERS+= libmemcached-1.0/callback.h -nobase_include_HEADERS+= libmemcached-1.0/callbacks.h -nobase_include_HEADERS+= libmemcached-1.0/configure.h -nobase_include_HEADERS+= libmemcached-1.0/defaults.h -nobase_include_HEADERS+= libmemcached-1.0/delete.h -nobase_include_HEADERS+= libmemcached-1.0/deprecated_types.h -nobase_include_HEADERS+= libmemcached-1.0/dump.h -nobase_include_HEADERS+= libmemcached-1.0/encoding_key.h -nobase_include_HEADERS+= libmemcached-1.0/error.h -nobase_include_HEADERS+= libmemcached-1.0/exception.hpp -nobase_include_HEADERS+= libmemcached-1.0/exist.h -nobase_include_HEADERS+= libmemcached-1.0/fetch.h -nobase_include_HEADERS+= libmemcached-1.0/flush.h -nobase_include_HEADERS+= libmemcached-1.0/flush_buffers.h -nobase_include_HEADERS+= libmemcached-1.0/get.h -nobase_include_HEADERS+= libmemcached-1.0/hash.h -nobase_include_HEADERS+= libmemcached-1.0/limits.h -nobase_include_HEADERS+= libmemcached-1.0/memcached.h -nobase_include_HEADERS+= libmemcached-1.0/memcached.hpp -nobase_include_HEADERS+= libmemcached-1.0/options.h -nobase_include_HEADERS+= libmemcached-1.0/parse.h -nobase_include_HEADERS+= libmemcached-1.0/platform.h -nobase_include_HEADERS+= libmemcached-1.0/quit.h -nobase_include_HEADERS+= libmemcached-1.0/result.h -nobase_include_HEADERS+= libmemcached-1.0/return.h -nobase_include_HEADERS+= libmemcached-1.0/sasl.h -nobase_include_HEADERS+= libmemcached-1.0/server.h -nobase_include_HEADERS+= libmemcached-1.0/server_list.h -nobase_include_HEADERS+= libmemcached-1.0/stats.h -nobase_include_HEADERS+= libmemcached-1.0/storage.h -nobase_include_HEADERS+= libmemcached-1.0/strerror.h -nobase_include_HEADERS+= libmemcached-1.0/touch.h -nobase_include_HEADERS+= libmemcached-1.0/triggers.h -nobase_include_HEADERS+= libmemcached-1.0/types.h -nobase_include_HEADERS+= libmemcached-1.0/verbosity.h -nobase_include_HEADERS+= libmemcached-1.0/version.h -nobase_include_HEADERS+= libmemcached-1.0/visibility.h diff --git a/libmemcached-1.0/limits.h b/libmemcached-1.0/limits.h deleted file mode 100644 index 076df407..00000000 --- a/libmemcached-1.0/limits.h +++ /dev/null @@ -1,46 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH 20 -#define MEMCACHED_MAX_BUFFER 8196 -#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ -#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ -#define MEMCACHED_PREFIX_KEY_MAX_SIZE 128 -#define MEMCACHED_VERSION_STRING_LENGTH 24 diff --git a/libmemcached-1.0/memcached.h b/libmemcached-1.0/memcached.h deleted file mode 100644 index 23462a76..00000000 --- a/libmemcached-1.0/memcached.h +++ /dev/null @@ -1,169 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/* This seems to be required for older compilers @note http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t */ -#ifndef __STDC_FORMAT_MACROS -# define __STDC_FORMAT_MACROS -#endif - -#ifdef __cplusplus -# include -# include -# include -#else -# include -# include -# include -# include -#endif - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// Everything above this line must be in the order specified. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -void memcached_servers_reset(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_st *memcached_create(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_st *memcached(const char *string, size_t string_length); - -LIBMEMCACHED_API -void memcached_free(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_return_t memcached_reset(memcached_st *ptr); - -LIBMEMCACHED_API -void memcached_reset_last_disconnected_server(memcached_st *ptr); - -LIBMEMCACHED_API -memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr); - -LIBMEMCACHED_API -void *memcached_get_user_data(const memcached_st *ptr); - -LIBMEMCACHED_API -void *memcached_set_user_data(memcached_st *ptr, void *data); - -LIBMEMCACHED_API -memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source); - -LIBMEMCACHED_API -memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key); - -LIBMEMCACHED_API -uint32_t memcached_server_count(const memcached_st *); - -LIBMEMCACHED_API -uint64_t memcached_query_id(const memcached_st *); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/memcached.hpp b/libmemcached-1.0/memcached.hpp deleted file mode 100644 index 4f12e2ec..00000000 --- a/libmemcached-1.0/memcached.hpp +++ /dev/null @@ -1,878 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * Summary: C++ interface for memcached server - * - * Copy: See Copyright for the status of this software. - * - * Authors: Padraig O'Sullivan - * Patrick Galbraith - */ - -/** - * @file memcached.hpp - * @brief Libmemcached C++ interface - */ - -#pragma once - -#include -#if 0 -#include -#endif - -#include - -#include -#include -#include -#include - -namespace memcache -{ - -/** - * This is the core memcached library (if later, other objects - * are needed, they will be created from this class). - */ -class Memcache -{ -public: - - Memcache() - { - memc_= memcached(NULL, 0); - } - - Memcache(const std::string &config) - { - memc_= memcached(config.c_str(), config.size()); - } - - Memcache(const std::string &hostname, in_port_t port) - { - memc_= memcached(NULL, 0); - if (memc_) - { - memcached_server_add(memc_, hostname.c_str(), port); - } - } - - Memcache(memcached_st *clone) - { - memc_= memcached_clone(NULL, clone); - } - - Memcache(const Memcache &rhs) - { - memc_= memcached_clone(NULL, rhs.getImpl()); - } - - Memcache &operator=(const Memcache &rhs) - { - if (this != &rhs) - { - memcached_free(memc_); - memc_= memcached_clone(NULL, rhs.getImpl()); - } - - return *this; - } - - ~Memcache() - { - memcached_free(memc_); - } - - /** - * Get the internal memcached_st * - */ - const memcached_st *getImpl() const - { - return memc_; - } - - /** - * Return an error string for the given return structure. - * - * @param[in] rc a memcached_return_t structure - * @return error string corresponding to given return code in the library. - */ - const std::string getError(memcached_return_t rc) const - { - /* first parameter to strerror is unused */ - return memcached_strerror(NULL, rc); - } - - bool error(std::string& error_message) const - { - if (memcached_failed(memcached_last_error(memc_))) - { - error_message+= memcached_last_error_message(memc_); - return true; - } - - return false; - } - - bool error() const - { - if (memcached_failed(memcached_last_error(memc_))) - { - return true; - } - - return false; - } - - bool error(memcached_return_t& arg) const - { - arg= memcached_last_error(memc_); - return memcached_failed(arg); - } - - bool setBehavior(memcached_behavior_t flag, uint64_t data) - { - return (memcached_success(memcached_behavior_set(memc_, flag, data))); - } - - uint64_t getBehavior(memcached_behavior_t flag) - { - return memcached_behavior_get(memc_, flag); - } - - /** - * Configure the memcache object - * - * @param[in] in_config configuration - * @return true on success; false otherwise - */ - bool configure(const std::string &configuration) - { - memcached_st *new_memc= memcached(configuration.c_str(), configuration.size()); - - if (new_memc) - { - memcached_free(memc_); - memc_= new_memc; - - return true; - } - - return false; - } - - /** - * Add a server to the list of memcached servers to use. - * - * @param[in] server_name name of the server to add - * @param[in] port port number of server to add - * @return true on success; false otherwise - */ - bool addServer(const std::string &server_name, in_port_t port) - { - return memcached_success(memcached_server_add(memc_, server_name.c_str(), port)); - } - - /** - * Remove a server from the list of memcached servers to use. - * - * @param[in] server_name name of the server to remove - * @param[in] port port number of server to remove - * @return true on success; false otherwise - */ - bool removeServer(const std::string &server_name, in_port_t port) - { - std::string tmp_str; - std::ostringstream strstm; - tmp_str.append(","); - tmp_str.append(server_name); - tmp_str.append(":"); - strstm << port; - tmp_str.append(strstm.str()); - - //memcached_return_t rc= memcached_server_remove(server); - - return false; - } - - /** - * Fetches an individual value from the server. mget() must always - * be called before using this method. - * - * @param[in] key key of object to fetch - * @param[out] ret_val store returned object in this vector - * @return a memcached return structure - */ - memcached_return_t fetch(std::string &key, - std::vector &ret_val, - uint32_t &flags, - uint64_t &cas_value) - { - memcached_return_t rc; - - memcached_result_st *result; - if ((result= memcached_fetch_result(memc_, NULL, &rc))) - { - // Key - key.assign(memcached_result_key_value(result), memcached_result_key_length(result)); - - // Actual value, null terminated - ret_val.reserve(memcached_result_length(result) +1); - ret_val.assign(memcached_result_value(result), - memcached_result_value(result) +memcached_result_length(result) +1); - ret_val.resize(memcached_result_length(result)); - - // Misc - flags= memcached_result_flags(result); - cas_value= memcached_result_cas(result); - } - memcached_result_free(result); - - return rc; - } - - memcached_return_t fetch(std::string &key, - std::vector &ret_val) - { - uint32_t flags= 0; - uint64_t cas_value= 0; - - return fetch(key, ret_val, flags, cas_value); - } - - /** - * Fetches an individual value from the server. - * - * @param[in] key key of object whose value to get - * @param[out] ret_val object that is retrieved is stored in - * this vector - * @return true on success; false otherwise - */ - bool get(const std::string &key, std::vector &ret_val) - { - uint32_t flags= 0; - memcached_return_t rc; - size_t value_length= 0; - - char *value= memcached_get(memc_, key.c_str(), key.length(), - &value_length, &flags, &rc); - if (value != NULL && ret_val.empty()) - { - ret_val.reserve(value_length +1); // Always provide null - ret_val.assign(value, value +value_length +1); - ret_val.resize(value_length); - free(value); - - return true; - } - - return false; - } - - /** - * Fetches an individual from a server which is specified by - * the master_key parameter that is used for determining which - * server an object was stored in if key partitioning was - * used for storage. - * - * @param[in] master_key key that specifies server object is stored on - * @param[in] key key of object whose value to get - * @param[out] ret_val object that is retrieved is stored in - * this vector - * @return true on success; false otherwise - */ - bool getByKey(const std::string &master_key, - const std::string &key, - std::vector &ret_val) - { - uint32_t flags= 0; - memcached_return_t rc; - size_t value_length= 0; - - char *value= memcached_get_by_key(memc_, - master_key.c_str(), master_key.length(), - key.c_str(), key.length(), - &value_length, &flags, &rc); - if (value) - { - ret_val.reserve(value_length +1); // Always provide null - ret_val.assign(value, value +value_length +1); - ret_val.resize(value_length); - free(value); - - return true; - } - return false; - } - - /** - * Selects multiple keys at once. This method always - * works asynchronously. - * - * @param[in] keys vector of keys to select - * @return true if all keys are found - */ - bool mget(const std::vector& keys) - { - std::vector real_keys; - std::vector key_len; - /* - * Construct an array which will contain the length - * of each of the strings in the input vector. Also, to - * interface with the memcached C API, we need to convert - * the vector of std::string's to a vector of char *. - */ - real_keys.reserve(keys.size()); - key_len.reserve(keys.size()); - - std::vector::const_iterator it= keys.begin(); - - while (it != keys.end()) - { - real_keys.push_back(const_cast((*it).c_str())); - key_len.push_back((*it).length()); - ++it; - } - - /* - * If the std::vector of keys is empty then we cannot - * call memcached_mget as we will get undefined behavior. - */ - if (not real_keys.empty()) - { - return memcached_success(memcached_mget(memc_, &real_keys[0], &key_len[0], real_keys.size())); - } - - return false; - } - - /** - * Writes an object to the server. If the object already exists, it will - * overwrite the existing object. This method always returns true - * when using non-blocking mode unless a network error occurs. - * - * @param[in] key key of object to write to server - * @param[in] value value of object to write to server - * @param[in] expiration time to keep the object stored in the server for - * @param[in] flags flags to store with the object - * @return true on succcess; false otherwise - */ - bool set(const std::string &key, - const std::vector &value, - time_t expiration, - uint32_t flags) - { - memcached_return_t rc= memcached_set(memc_, - key.c_str(), key.length(), - &value[0], value.size(), - expiration, flags); - return memcached_success(rc); - } - - bool set(const std::string &key, - const char* value, const size_t value_length, - time_t expiration, - uint32_t flags) - { - memcached_return_t rc= memcached_set(memc_, - key.c_str(), key.length(), - value, value_length, - expiration, flags); - return memcached_success(rc); - } - - /** - * Writes an object to a server specified by the master_key parameter. - * If the object already exists, it will overwrite the existing object. - * - * @param[in] master_key key that specifies server to write to - * @param[in] key key of object to write to server - * @param[in] value value of object to write to server - * @param[in] expiration time to keep the object stored in the server for - * @param[in] flags flags to store with the object - * @return true on succcess; false otherwise - */ - bool setByKey(const std::string& master_key, - const std::string& key, - const std::vector &value, - time_t expiration, - uint32_t flags) - { - return memcached_success(memcached_set_by_key(memc_, master_key.c_str(), - master_key.length(), - key.c_str(), key.length(), - &value[0], value.size(), - expiration, - flags)); - } - - /** - * Writes a list of objects to the server. Objects are specified by - * 2 vectors - 1 vector of keys and 1 vector of values. - * - * @param[in] keys vector of keys of objects to write to server - * @param[in] values vector of values of objects to write to server - * @param[in] expiration time to keep the objects stored in server for - * @param[in] flags flags to store with the objects - * @return true on success; false otherwise - */ - bool setAll(const std::vector& keys, - const std::vector< std::vector *>& values, - time_t expiration, - uint32_t flags) - { - bool retval= true; - std::vector::const_iterator key_it= keys.begin(); - std::vector< std::vector *>::const_iterator val_it= values.begin(); - while (key_it != keys.end()) - { - retval= set((*key_it), *(*val_it), expiration, flags); - if (retval == false) - { - return retval; - } - ++key_it; - ++val_it; - } - return retval; - } - - /** - * Writes a list of objects to the server. Objects are specified by - * a map of keys to values. - * - * @param[in] key_value_map map of keys and values to store in server - * @param[in] expiration time to keep the objects stored in server for - * @param[in] flags flags to store with the objects - * @return true on success; false otherwise - */ - bool setAll(const std::map >& key_value_map, - time_t expiration, - uint32_t flags) - { - bool retval= true; - std::map >::const_iterator it= key_value_map.begin(); - - while (it != key_value_map.end()) - { - retval= set(it->first, it->second, expiration, flags); - if (retval == false) - { - // We should tell the user what the key that failed was - return false; - } - ++it; - } - - return true; - } - - /** - * Increment the value of the object associated with the specified - * key by the offset given. The resulting value is saved in the value - * parameter. - * - * @param[in] key key of object in server whose value to increment - * @param[in] offset amount to increment object's value by - * @param[out] value store the result of the increment here - * @return true on success; false otherwise - */ - bool increment(const std::string& key, uint32_t offset, uint64_t *value) - { - return memcached_success(memcached_increment(memc_, key.c_str(), key.length(), offset, value)); - } - - /** - * Decrement the value of the object associated with the specified - * key by the offset given. The resulting value is saved in the value - * parameter. - * - * @param[in] key key of object in server whose value to decrement - * @param[in] offset amount to increment object's value by - * @param[out] value store the result of the decrement here - * @return true on success; false otherwise - */ - bool decrement(const std::string& key, uint32_t offset, uint64_t *value) - { - return memcached_success(memcached_decrement(memc_, key.c_str(), - key.length(), - offset, value)); - } - - - /** - * Add an object with the specified key and value to the server. This - * function returns false if the object already exists on the server. - * - * @param[in] key key of object to add - * @param[in] value of object to add - * @return true on success; false otherwise - */ - bool add(const std::string& key, const std::vector& value) - { - return memcached_success(memcached_add(memc_, key.c_str(), key.length(), - &value[0], value.size(), 0, 0)); - } - - /** - * Add an object with the specified key and value to the server. This - * function returns false if the object already exists on the server. The - * server to add the object to is specified by the master_key parameter. - * - * @param[in[ master_key key of server to add object to - * @param[in] key key of object to add - * @param[in] value of object to add - * @return true on success; false otherwise - */ - bool addByKey(const std::string& master_key, - const std::string& key, - const std::vector& value) - { - return memcached_success(memcached_add_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, 0)); - } - - /** - * Replaces an object on the server. This method only succeeds - * if the object is already present on the server. - * - * @param[in] key key of object to replace - * @param[in[ value value to replace object with - * @return true on success; false otherwise - */ - bool replace(const std::string& key, const std::vector& value) - { - return memcached_success(memcached_replace(memc_, key.c_str(), key.length(), - &value[0], value.size(), - 0, 0)); - } - - /** - * Replaces an object on the server. This method only succeeds - * if the object is already present on the server. The server - * to replace the object on is specified by the master_key param. - * - * @param[in] master_key key of server to replace object on - * @param[in] key key of object to replace - * @param[in[ value value to replace object with - * @return true on success; false otherwise - */ - bool replaceByKey(const std::string& master_key, - const std::string& key, - const std::vector& value) - { - return memcached_success(memcached_replace_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, 0)); - } - - /** - * Places a segment of data before the last piece of data stored. - * - * @param[in] key key of object whose value we will prepend data to - * @param[in] value data to prepend to object's value - * @return true on success; false otherwise - */ - bool prepend(const std::string& key, const std::vector& value) - { - return memcached_success(memcached_prepend(memc_, key.c_str(), key.length(), - &value[0], value.size(), 0, 0)); - } - - /** - * Places a segment of data before the last piece of data stored. The - * server on which the object where we will be prepending data is stored - * on is specified by the master_key parameter. - * - * @param[in] master_key key of server where object is stored - * @param[in] key key of object whose value we will prepend data to - * @param[in] value data to prepend to object's value - * @return true on success; false otherwise - */ - bool prependByKey(const std::string& master_key, - const std::string& key, - const std::vector& value) - { - return memcached_success(memcached_prepend_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, - 0)); - } - - /** - * Places a segment of data at the end of the last piece of data stored. - * - * @param[in] key key of object whose value we will append data to - * @param[in] value data to append to object's value - * @return true on success; false otherwise - */ - bool append(const std::string& key, const std::vector& value) - { - return memcached_success(memcached_append(memc_, - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, 0)); - } - - /** - * Places a segment of data at the end of the last piece of data stored. The - * server on which the object where we will be appending data is stored - * on is specified by the master_key parameter. - * - * @param[in] master_key key of server where object is stored - * @param[in] key key of object whose value we will append data to - * @param[in] value data to append to object's value - * @return true on success; false otherwise - */ - bool appendByKey(const std::string& master_key, - const std::string& key, - const std::vector &value) - { - return memcached_success(memcached_append_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, 0)); - } - - /** - * Overwrite data in the server as long as the cas_arg value - * is still the same in the server. - * - * @param[in] key key of object in server - * @param[in] value value to store for object in server - * @param[in] cas_arg "cas" value - */ - bool cas(const std::string& key, - const std::vector& value, - uint64_t cas_arg) - { - return memcached_success(memcached_cas(memc_, key.c_str(), key.length(), - &value[0], value.size(), - 0, 0, cas_arg)); - } - - /** - * Overwrite data in the server as long as the cas_arg value - * is still the same in the server. The server to use is - * specified by the master_key parameter. - * - * @param[in] master_key specifies server to operate on - * @param[in] key key of object in server - * @param[in] value value to store for object in server - * @param[in] cas_arg "cas" value - */ - bool casByKey(const std::string& master_key, - const std::string& key, - const std::vector &value, - uint64_t cas_arg) - { - return memcached_success(memcached_cas_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - &value[0], - value.size(), - 0, 0, cas_arg)); - } - - /** - * Delete an object from the server specified by the key given. - * - * @param[in] key key of object to delete - * @return true on success; false otherwise - */ - bool remove(const std::string& key) - { - return memcached_success(memcached_delete(memc_, key.c_str(), key.length(), 0)); - } - - /** - * Delete an object from the server specified by the key given. - * - * @param[in] key key of object to delete - * @param[in] expiration time to delete the object after - * @return true on success; false otherwise - */ - bool remove(const std::string& key, time_t expiration) - { - return memcached_success(memcached_delete(memc_, - key.c_str(), - key.length(), - expiration)); - } - - /** - * Delete an object from the server specified by the key given. - * - * @param[in] master_key specifies server to remove object from - * @param[in] key key of object to delete - * @return true on success; false otherwise - */ - bool removeByKey(const std::string& master_key, - const std::string& key) - { - return memcached_success(memcached_delete_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - 0)); - } - - /** - * Delete an object from the server specified by the key given. - * - * @param[in] master_key specifies server to remove object from - * @param[in] key key of object to delete - * @param[in] expiration time to delete the object after - * @return true on success; false otherwise - */ - bool removeByKey(const std::string& master_key, - const std::string& key, - time_t expiration) - { - return memcached_success(memcached_delete_by_key(memc_, - master_key.c_str(), - master_key.length(), - key.c_str(), - key.length(), - expiration)); - } - - /** - * Wipe the contents of memcached servers. - * - * @param[in] expiration time to wait until wiping contents of - * memcached servers - * @return true on success; false otherwise - */ - bool flush(time_t expiration= 0) - { - return memcached_success(memcached_flush(memc_, expiration)); - } - - /** - * Get the library version string. - * @return std::string containing a copy of the library version string. - */ - const std::string libVersion() const - { - const char *ver= memcached_lib_version(); - const std::string version(ver); - return version; - } - - /** - * Retrieve memcached statistics. Populate a std::map with the retrieved - * stats. Each server will map to another std::map of the key:value stats. - * - * @param[out] stats_map a std::map to be populated with the memcached - * stats - * @return true on success; false otherwise - */ - bool getStats(std::map< std::string, std::map >& stats_map) - { - memcached_return_t rc; - memcached_stat_st *stats= memcached_stat(memc_, NULL, &rc); - - if (rc != MEMCACHED_SUCCESS && - rc != MEMCACHED_SOME_ERRORS) - { - return false; - } - - uint32_t server_count= memcached_server_count(memc_); - - /* - * For each memcached server, construct a std::map for its stats and add - * it to the std::map of overall stats. - */ - for (uint32_t x= 0; x < server_count; x++) - { - memcached_server_instance_st instance= memcached_server_instance_by_position(memc_, x); - std::ostringstream strstm; - std::string server_name(memcached_server_name(instance)); - server_name.append(":"); - strstm << memcached_server_port(instance); - server_name.append(strstm.str()); - - std::map server_stats; - char **list= memcached_stat_get_keys(memc_, &stats[x], &rc); - for (char** ptr= list; *ptr; ptr++) - { - char *value= memcached_stat_get_value(memc_, &stats[x], *ptr, &rc); - server_stats[*ptr]= value; - free(value); - } - - stats_map[server_name]= server_stats; - free(list); - } - - memcached_stat_free(memc_, stats); - return true; - } - -private: - memcached_st *memc_; -}; - -} diff --git a/libmemcached-1.0/options.h b/libmemcached-1.0/options.h deleted file mode 100644 index f5a6e06d..00000000 --- a/libmemcached-1.0/options.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API - memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/parse.h b/libmemcached-1.0/parse.h deleted file mode 100644 index a91f769d..00000000 --- a/libmemcached-1.0/parse.h +++ /dev/null @@ -1,23 +0,0 @@ -/* LibMemcached - * Copyright (C) 2010 Brian Aker - * All rights reserved. - * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. - * - * Summary: Work with fetching results - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_server_list_st memcached_servers_parse(const char *server_strings); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/platform.h b/libmemcached-1.0/platform.h deleted file mode 100644 index 763febaa..00000000 --- a/libmemcached-1.0/platform.h +++ /dev/null @@ -1,56 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef WIN32 - -#include -#include -typedef short in_port_t; -typedef SOCKET memcached_socket_t; -#else -typedef int memcached_socket_t; -#include -#include -#include -#include -#include -#include - -#endif /* WIN32 */ diff --git a/libmemcached-1.0/quit.h b/libmemcached-1.0/quit.h deleted file mode 100644 index 90ff3ff0..00000000 --- a/libmemcached-1.0/quit.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -void memcached_quit(memcached_st *ptr); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/result.h b/libmemcached-1.0/result.h deleted file mode 100644 index 615957f3..00000000 --- a/libmemcached-1.0/result.h +++ /dev/null @@ -1,89 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* Result Struct */ -LIBMEMCACHED_API -void memcached_result_free(memcached_result_st *result); - -LIBMEMCACHED_API -void memcached_result_reset(memcached_result_st *ptr); - -LIBMEMCACHED_API -memcached_result_st *memcached_result_create(const memcached_st *ptr, - memcached_result_st *result); - -LIBMEMCACHED_API -const char *memcached_result_key_value(const memcached_result_st *self); - -LIBMEMCACHED_API -size_t memcached_result_key_length(const memcached_result_st *self); - -LIBMEMCACHED_API -const char *memcached_result_value(const memcached_result_st *self); - -LIBMEMCACHED_API -char *memcached_result_take_value(memcached_result_st *self); - -LIBMEMCACHED_API -size_t memcached_result_length(const memcached_result_st *self); - -LIBMEMCACHED_API -uint32_t memcached_result_flags(const memcached_result_st *self); - -LIBMEMCACHED_API -uint64_t memcached_result_cas(const memcached_result_st *self); - -LIBMEMCACHED_API -memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length); - -LIBMEMCACHED_API -void memcached_result_set_flags(memcached_result_st *self, uint32_t flags); - -LIBMEMCACHED_API -void memcached_result_set_expiration(memcached_result_st *self, time_t expiration); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/return.h b/libmemcached-1.0/return.h deleted file mode 100644 index 65dc63af..00000000 --- a/libmemcached-1.0/return.h +++ /dev/null @@ -1,81 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -static inline bool memcached_success(memcached_return_t rc) -{ - return (rc == MEMCACHED_BUFFERED || - rc == MEMCACHED_DELETED || - rc == MEMCACHED_END || - rc == MEMCACHED_ITEM || - rc == MEMCACHED_STAT || - rc == MEMCACHED_STORED || - rc == MEMCACHED_SUCCESS || - rc == MEMCACHED_VALUE); -} - -static inline bool memcached_failed(memcached_return_t rc) -{ - return (rc != MEMCACHED_SUCCESS && - rc != MEMCACHED_END && - rc != MEMCACHED_STORED && - rc != MEMCACHED_STAT && - rc != MEMCACHED_DELETED && - rc != MEMCACHED_BUFFERED && - rc != MEMCACHED_VALUE); -} - -static inline bool memcached_fatal(memcached_return_t rc) -{ - return ( - rc != MEMCACHED_BUFFERED && - rc != MEMCACHED_DATA_EXISTS && - rc != MEMCACHED_DELETED && - rc != MEMCACHED_E2BIG && - rc != MEMCACHED_END && - rc != MEMCACHED_ITEM && - rc != MEMCACHED_ERROR && - rc != MEMCACHED_NOTFOUND && - rc != MEMCACHED_NOTSTORED && - rc != MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE && - rc != MEMCACHED_STAT && - rc != MEMCACHED_STORED && - rc != MEMCACHED_SUCCESS && - rc != MEMCACHED_VALUE); -} - -#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS) diff --git a/libmemcached-1.0/sasl.h b/libmemcached-1.0/sasl.h deleted file mode 100644 index c3084217..00000000 --- a/libmemcached-1.0/sasl.h +++ /dev/null @@ -1,70 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT -#include -#else -#define sasl_callback_t void -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -void memcached_set_sasl_callbacks(memcached_st *ptr, - const sasl_callback_t *callbacks); - -LIBMEMCACHED_API -memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, - const char *username, - const char *password); - -LIBMEMCACHED_API -memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr); - - -LIBMEMCACHED_API -sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr); - -#ifdef __cplusplus -} -#endif - -#include diff --git a/libmemcached-1.0/server.h b/libmemcached-1.0/server.h deleted file mode 100644 index dc650d2a..00000000 --- a/libmemcached-1.0/server.h +++ /dev/null @@ -1,123 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_server_cursor(const memcached_st *ptr, - const memcached_server_fn *callback, - void *context, - uint32_t number_of_callbacks); - -LIBMEMCACHED_API - memcached_server_instance_st memcached_server_by_key(memcached_st *ptr, - const char *key, - size_t key_length, - memcached_return_t *error); - -LIBMEMCACHED_API -void memcached_server_error_reset(memcached_server_st *ptr); - -LIBMEMCACHED_API -void memcached_server_free(memcached_server_st *ptr); - -LIBMEMCACHED_API -memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr); - - -LIBMEMCACHED_API -memcached_return_t memcached_server_add_udp(memcached_st *ptr, - const char *hostname, - in_port_t port); -LIBMEMCACHED_API -memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, - const char *filename); -LIBMEMCACHED_API -memcached_return_t memcached_server_add(memcached_st *ptr, - const char *hostname, in_port_t port); - -LIBMEMCACHED_API -memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, - const char *hostname, - in_port_t port, - uint32_t weight); -LIBMEMCACHED_API -memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, - const char *filename, - uint32_t weight); -LIBMEMCACHED_API -memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, - in_port_t port, - uint32_t weight); - -/** - Operations on Single Servers. -*/ -LIBMEMCACHED_API -uint32_t memcached_server_response_count(const memcached_server_instance_st self); - -LIBMEMCACHED_API -const char *memcached_server_name(const memcached_server_instance_st self); - -LIBMEMCACHED_API -in_port_t memcached_server_port(const memcached_server_instance_st self); - -LIBMEMCACHED_API -void memcached_instance_next_retry(memcached_server_instance_st self, const time_t absolute_time); - -LIBMEMCACHED_API -const char *memcached_server_type(const memcached_server_instance_st ptr); - -LIBMEMCACHED_API -uint8_t memcached_server_major_version(const memcached_server_instance_st ptr); - -LIBMEMCACHED_API -uint8_t memcached_server_minor_version(const memcached_server_instance_st ptr); - -LIBMEMCACHED_API -uint8_t memcached_server_micro_version(const memcached_server_instance_st ptr); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/server_list.h b/libmemcached-1.0/server_list.h deleted file mode 100644 index 04bebab4..00000000 --- a/libmemcached-1.0/server_list.h +++ /dev/null @@ -1,68 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Server List Public functions */ -LIBMEMCACHED_API - void memcached_server_list_free(memcached_server_list_st ptr); - -LIBMEMCACHED_API - memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list); - -LIBMEMCACHED_API - memcached_server_list_st memcached_server_list_append(memcached_server_list_st ptr, - const char *hostname, - in_port_t port, - memcached_return_t *error); -LIBMEMCACHED_API - memcached_server_list_st memcached_server_list_append_with_weight(memcached_server_list_st ptr, - const char *hostname, - in_port_t port, - uint32_t weight, - memcached_return_t *error); -LIBMEMCACHED_API - uint32_t memcached_server_list_count(const memcached_server_list_st ptr); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/stats.h b/libmemcached-1.0/stats.h deleted file mode 100644 index 708064f1..00000000 --- a/libmemcached-1.0/stats.h +++ /dev/null @@ -1,69 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -void memcached_stat_free(const memcached_st *, memcached_stat_st *); - -LIBMEMCACHED_API -memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error); - -LIBMEMCACHED_API -memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, - const char *hostname, in_port_t port); - -LIBMEMCACHED_API -char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_stat, - const char *key, memcached_return_t *error); - -LIBMEMCACHED_API -char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat, - memcached_return_t *error); - -LIBMEMCACHED_API -memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcached-1.0/storage.h b/libmemcached-1.0/storage.h deleted file mode 100644 index e634235a..00000000 --- a/libmemcached-1.0/storage.h +++ /dev/null @@ -1,131 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* All of the functions for adding data to the server */ -LIBMEMCACHED_API -memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); -LIBMEMCACHED_API -memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); -LIBMEMCACHED_API -memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); -LIBMEMCACHED_API -memcached_return_t memcached_append(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); -LIBMEMCACHED_API -memcached_return_t memcached_prepend(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); -LIBMEMCACHED_API -memcached_return_t memcached_cas(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas); - -LIBMEMCACHED_API -memcached_return_t memcached_set_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); - -LIBMEMCACHED_API -memcached_return_t memcached_add_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); - -LIBMEMCACHED_API -memcached_return_t memcached_replace_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); - -LIBMEMCACHED_API -memcached_return_t memcached_prepend_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); - -LIBMEMCACHED_API -memcached_return_t memcached_append_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); - -LIBMEMCACHED_API -memcached_return_t memcached_cas_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/strerror.h b/libmemcached-1.0/strerror.h deleted file mode 100644 index 16bf424a..00000000 --- a/libmemcached-1.0/strerror.h +++ /dev/null @@ -1,50 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -const char *memcached_strerror(const memcached_st *ptr, memcached_return_t rc); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/struct/allocator.h b/libmemcached-1.0/struct/allocator.h deleted file mode 100644 index 3ff6ade8..00000000 --- a/libmemcached-1.0/struct/allocator.h +++ /dev/null @@ -1,46 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_allocator_t { - memcached_calloc_fn calloc; - memcached_free_fn free; - memcached_malloc_fn malloc; - memcached_realloc_fn realloc; - void *context; -}; diff --git a/libmemcached-1.0/struct/analysis.h b/libmemcached-1.0/struct/analysis.h deleted file mode 100644 index 09cccedc..00000000 --- a/libmemcached-1.0/struct/analysis.h +++ /dev/null @@ -1,51 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_analysis_st { - memcached_st *root; - uint32_t average_item_size; - uint32_t longest_uptime; - uint32_t least_free_server; - uint32_t most_consumed_server; - uint32_t oldest_server; - double pool_hit_ratio; - uint64_t most_used_bytes; - uint64_t least_remaining_bytes; -}; - diff --git a/libmemcached-1.0/struct/callback.h b/libmemcached-1.0/struct/callback.h deleted file mode 100644 index 21b96765..00000000 --- a/libmemcached-1.0/struct/callback.h +++ /dev/null @@ -1,44 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_callback_st { - memcached_execute_fn *callback; - void *context; - uint32_t number_of_callback; -}; diff --git a/libmemcached-1.0/struct/include.am b/libmemcached-1.0/struct/include.am deleted file mode 100644 index fc2d9223..00000000 --- a/libmemcached-1.0/struct/include.am +++ /dev/null @@ -1,13 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -nobase_include_HEADERS+= libmemcached-1.0/struct/allocator.h -nobase_include_HEADERS+= libmemcached-1.0/struct/analysis.h -nobase_include_HEADERS+= libmemcached-1.0/struct/callback.h -nobase_include_HEADERS+= libmemcached-1.0/struct/memcached.h -nobase_include_HEADERS+= libmemcached-1.0/struct/result.h -nobase_include_HEADERS+= libmemcached-1.0/struct/sasl.h -nobase_include_HEADERS+= libmemcached-1.0/struct/server.h -nobase_include_HEADERS+= libmemcached-1.0/struct/stat.h -nobase_include_HEADERS+= libmemcached-1.0/struct/string.h diff --git a/libmemcached-1.0/struct/memcached.h b/libmemcached-1.0/struct/memcached.h deleted file mode 100644 index 624887b7..00000000 --- a/libmemcached-1.0/struct/memcached.h +++ /dev/null @@ -1,132 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_st { - /** - @note these are static and should not change without a call to behavior. - */ - struct { - bool is_purging:1; - bool is_processing_input:1; - bool is_time_for_rebuild:1; - bool is_parsing:1; - } state; - - struct { - // Everything below here is pretty static. - bool auto_eject_hosts:1; - bool binary_protocol:1; - bool buffer_requests:1; - bool hash_with_namespace:1; - bool no_block:1; // Don't block - bool reply:1; - bool randomize_replica_read:1; - bool support_cas:1; - bool tcp_nodelay:1; - bool use_sort_hosts:1; - bool use_udp:1; - bool verify_key:1; - bool tcp_keepalive:1; - bool is_aes:1; - bool is_fetching_version:1; - bool not_used:1; - } flags; - - memcached_server_distribution_t distribution; - hashkit_st hashkit; - struct { - unsigned int version; - } server_info; - uint32_t number_of_hosts; -#ifdef __cplusplus - org::libmemcached::Instance* servers; - org::libmemcached::Instance* last_disconnected_server; -#else - void *servers; - void *last_disconnected_server; -#endif - int32_t snd_timeout; - int32_t rcv_timeout; - uint32_t server_failure_limit; - uint32_t io_msg_watermark; - uint32_t io_bytes_watermark; - uint32_t io_key_prefetch; - uint32_t tcp_keepidle; - int32_t poll_timeout; - int32_t connect_timeout; // How long we will wait on connect() before we will timeout - int32_t retry_timeout; - int32_t dead_timeout; - int send_size; - int recv_size; - void *user_data; - uint64_t query_id; - uint32_t number_of_replicas; - memcached_result_st result; - - struct { - bool weighted_; - uint32_t continuum_count; // Ketama - uint32_t continuum_points_counter; // Ketama - time_t next_distribution_rebuild; // Ketama - struct memcached_continuum_item_st *continuum; // Ketama - } ketama; - - struct memcached_virtual_bucket_t *virtual_bucket; - - struct memcached_allocator_t allocators; - - memcached_clone_fn on_clone; - memcached_cleanup_fn on_cleanup; - memcached_trigger_key_fn get_key_failure; - memcached_trigger_delete_key_fn delete_trigger; - memcached_callback_st *callbacks; - struct memcached_sasl_st sasl; - struct memcached_error_t *error_messages; - struct memcached_array_st *_namespace; - struct { - uint32_t initial_pool_size; - uint32_t max_pool_size; - int32_t version; // This is used by pool and others to determine if the memcached_st is out of date. - struct memcached_array_st *filename; - } configure; - struct { - bool is_allocated:1; - } options; - -}; diff --git a/libmemcached-1.0/struct/result.h b/libmemcached-1.0/struct/result.h deleted file mode 100644 index c3bfddb5..00000000 --- a/libmemcached-1.0/struct/result.h +++ /dev/null @@ -1,56 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_result_st { - uint32_t item_flags; - time_t item_expiration; - size_t key_length; - uint64_t item_cas; - struct memcached_st *root; - memcached_string_st value; - uint64_t numeric_value; - uint64_t count; - char item_key[MEMCACHED_MAX_KEY]; - struct { - bool is_allocated:1; - bool is_initialized:1; - } options; - /* Add result callback function */ -}; - diff --git a/libmemcached-1.0/struct/sasl.h b/libmemcached-1.0/struct/sasl.h deleted file mode 100644 index da9eed38..00000000 --- a/libmemcached-1.0/struct/sasl.h +++ /dev/null @@ -1,54 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT -#include -#else -#define sasl_callback_t void -#endif - -#pragma once - -struct memcached_sasl_st { - sasl_callback_t *callbacks; - /* - ** Did we allocate data inside the callbacks, or did the user - ** supply that. - */ - bool is_allocated; -}; - diff --git a/libmemcached-1.0/struct/server.h b/libmemcached-1.0/struct/server.h deleted file mode 100644 index a8a30565..00000000 --- a/libmemcached-1.0/struct/server.h +++ /dev/null @@ -1,98 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifndef WIN32 -#include -#endif - -#ifdef NI_MAXHOST -#define MEMCACHED_NI_MAXHOST NI_MAXHOST -#else -#define MEMCACHED_NI_MAXHOST 1025 -#endif - -#ifdef NI_MAXSERV -#define MEMCACHED_NI_MAXSERV NI_MAXSERV -#else -#define MEMCACHED_NI_MAXSERV 32 -#endif - -enum memcached_server_state_t { - MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done - MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered - MEMCACHED_SERVER_STATE_IN_PROGRESS, - MEMCACHED_SERVER_STATE_CONNECTED, - MEMCACHED_SERVER_STATE_IN_TIMEOUT, - MEMCACHED_SERVER_STATE_DISABLED -}; - -struct memcached_server_st { - struct { - bool is_allocated:1; - bool is_initialized:1; - bool is_shutting_down:1; - bool is_dead:1; - } options; - uint32_t number_of_hosts; - uint32_t cursor_active; - in_port_t port; - uint32_t io_bytes_sent; /* # bytes sent since last read */ - uint32_t request_id; - uint32_t server_failure_counter; - uint64_t server_failure_counter_query_id; - uint32_t weight; - uint32_t version; - enum memcached_server_state_t state; - struct { - uint32_t read; - uint32_t write; - uint32_t timeouts; - size_t _bytes_read; - } io_wait_count; - uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set. - uint8_t micro_version; // ditto, and note that this is the third, not second version bit - uint8_t minor_version; // ditto - memcached_connection_t type; - time_t next_retry; - struct memcached_st *root; - uint64_t limit_maxbytes; - struct memcached_error_t *error_messages; - char hostname[MEMCACHED_NI_MAXHOST]; -}; diff --git a/libmemcached-1.0/struct/stat.h b/libmemcached-1.0/struct/stat.h deleted file mode 100644 index acd4e21f..00000000 --- a/libmemcached-1.0/struct/stat.h +++ /dev/null @@ -1,68 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -struct memcached_stat_st { - unsigned long connection_structures; - unsigned long curr_connections; - unsigned long curr_items; - pid_t pid; - unsigned long pointer_size; - unsigned long rusage_system_microseconds; - unsigned long rusage_system_seconds; - unsigned long rusage_user_microseconds; - unsigned long rusage_user_seconds; - unsigned long threads; - unsigned long time; - unsigned long total_connections; - unsigned long total_items; - unsigned long uptime; - unsigned long long bytes; - unsigned long long bytes_read; - unsigned long long bytes_written; - unsigned long long cmd_get; - unsigned long long cmd_set; - unsigned long long evictions; - unsigned long long get_hits; - unsigned long long get_misses; - unsigned long long limit_maxbytes; - char version[MEMCACHED_VERSION_STRING_LENGTH]; - void *__future; // @todo create a new structure to place here for future usage - memcached_st *root; -}; - diff --git a/libmemcached-1.0/struct/string.h b/libmemcached-1.0/struct/string.h deleted file mode 100644 index 9edb637a..00000000 --- a/libmemcached-1.0/struct/string.h +++ /dev/null @@ -1,59 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - Strings are always under our control so we make some assumptions - about them. - - 1) is_initialized is always valid. - 2) A string once intialized will always be, until free where we - unset this flag. - 3) A string always has a root. -*/ - -struct memcached_string_st { - char *end; - char *string; - size_t current_size; - struct memcached_st *root; - struct { - bool is_allocated:1; - bool is_initialized:1; - } options; -}; diff --git a/libmemcached-1.0/t/c_sasl_test.c b/libmemcached-1.0/t/c_sasl_test.c deleted file mode 100644 index 93f729d1..00000000 --- a/libmemcached-1.0/t/c_sasl_test.c +++ /dev/null @@ -1,61 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached C sasl test app - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * @file @brief C dummy test, aka testing C linking, etc - */ - -#include - -#ifdef HAVE_SASL_SASL_H -#include -#endif - -#include - -int main(void) -{ - memcached_st *memc= memcached_create(NULL); - - if (memc == NULL) - { - return EXIT_FAILURE; - } - memcached_free(memc); - - return EXIT_SUCCESS; -} - diff --git a/libmemcached-1.0/t/c_test.c b/libmemcached-1.0/t/c_test.c deleted file mode 100644 index 40935fac..00000000 --- a/libmemcached-1.0/t/c_test.c +++ /dev/null @@ -1,61 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached C test app - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * @file @brief C dummy test, aka testing C linking, etc - */ - -#include - -#include - -int main(void) -{ - (void)memcached_success(MEMCACHED_SUCCESS); - (void)memcached_failed(MEMCACHED_SUCCESS); - (void)memcached_continue(MEMCACHED_SUCCESS); - - memcached_st *memc= memcached_create(NULL); - - if (memc == NULL) - { - return EXIT_FAILURE; - } - memcached_free(memc); - - return EXIT_SUCCESS; -} - diff --git a/libmemcached-1.0/t/cc_test.cc b/libmemcached-1.0/t/cc_test.cc deleted file mode 100644 index 71ee8c30..00000000 --- a/libmemcached-1.0/t/cc_test.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached C++ test app - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * @file @brief C dummy test, aka testing C linking, etc - */ - -#include - -#include - -int main(void) -{ - (void)memcached_success(MEMCACHED_SUCCESS); - (void)memcached_failed(MEMCACHED_SUCCESS); - (void)memcached_continue(MEMCACHED_SUCCESS); - - memcached_st *memc= memcached_create(NULL); - - if (memc == NULL) - { - return EXIT_FAILURE; - } - - memcached_free(memc); - - return EXIT_SUCCESS; -} - diff --git a/libmemcached-1.0/t/include.am b/libmemcached-1.0/t/include.am deleted file mode 100644 index 96705114..00000000 --- a/libmemcached-1.0/t/include.am +++ /dev/null @@ -1,32 +0,0 @@ -# vim:ft=automake -# Copyright (C) 2011 Data Differential -# All rights reserved. -# -# Use and distribution licensed under the BSD license. See -# the COPYING file in the parent directory for full text. -# -# included from Top Level Makefile.am -# All paths should be given relative to the root - -LIBMEMCACHED_1_0_TEST_PATH= libmemcached-1.0/t - -# Test linking with C application -libmemcached_1_0_t_c_test_SOURCES= libmemcached-1.0/t/c_test.c -libmemcached_1_0_t_c_test_LDADD= libmemcached/libmemcached.la -libmemcached_1_0_t_c_test_DEPENDENCIES= libmemcached/libmemcached.la -check_PROGRAMS+= libmemcached-1.0/t/c_test -noinst_PROGRAMS+= libmemcached-1.0/t/c_test - -# Test linking with C++ application -libmemcached_1_0_t_cc_test_SOURCES= libmemcached-1.0/t/cc_test.cc -libmemcached_1_0_t_cc_test_LDADD= libmemcached/libmemcached.la -libmemcached_1_0_t_cc_test_DEPENDENCIES= libmemcached/libmemcached.la -check_PROGRAMS+= libmemcached-1.0/t/cc_test -noinst_PROGRAMS+= libmemcached-1.0/t/cc_test - -# Test linking with C application/SASL include -libmemcached_1_0_t_c_sasl_test_SOURCES= libmemcached-1.0/t/c_sasl_test.c -libmemcached_1_0_t_c_sasl_test_LDADD= libmemcached/libmemcached.la -libmemcached_1_0_t_c_sasl_test_DEPENDENCIES= libmemcached/libmemcached.la -check_PROGRAMS+= libmemcached-1.0/t/c_sasl_test -noinst_PROGRAMS+= libmemcached-1.0/t/c_sasl_test diff --git a/libmemcached-1.0/touch.h b/libmemcached-1.0/touch.h deleted file mode 100644 index e143c037..00000000 --- a/libmemcached-1.0/touch.h +++ /dev/null @@ -1,59 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - - -LIBMEMCACHED_API -memcached_return_t memcached_touch(memcached_st *ptr, - const char *key, size_t key_length, - time_t expiration); - -LIBMEMCACHED_API -memcached_return_t memcached_touch_by_key(memcached_st *ptr, - const char *group_key, size_t group_key_length, - const char *key, size_t key_length, - time_t expiration); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/triggers.h b/libmemcached-1.0/triggers.h deleted file mode 100644 index b331429e..00000000 --- a/libmemcached-1.0/triggers.h +++ /dev/null @@ -1,64 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef memcached_return_t (*memcached_clone_fn)(memcached_st *destination, const memcached_st *source); -typedef memcached_return_t (*memcached_cleanup_fn)(const memcached_st *ptr); - -/** - Trigger functions. -*/ -typedef memcached_return_t (*memcached_trigger_key_fn)(const memcached_st *ptr, - const char *key, size_t key_length, - memcached_result_st *result); -typedef memcached_return_t (*memcached_trigger_delete_key_fn)(const memcached_st *ptr, - const char *key, size_t key_length); - -typedef memcached_return_t (*memcached_dump_fn)(const memcached_st *ptr, - const char *key, - size_t key_length, - void *context); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/types.h b/libmemcached-1.0/types.h deleted file mode 100644 index 53992d3a..00000000 --- a/libmemcached-1.0/types.h +++ /dev/null @@ -1,85 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -#ifdef __cplusplus - -namespace org { namespace libmemcached { struct Instance; } } - -struct memcached_st; -struct memcached_stat_st; -struct memcached_analysis_st; -struct memcached_result_st; -struct memcached_array_st; -struct memcached_error_t; - -// All of the flavors of memcache_server_st -struct memcached_server_st; -struct memcached_instance_st; -typedef const org::libmemcached::Instance* memcached_server_instance_st; -typedef struct memcached_server_st *memcached_server_list_st; - -struct memcached_callback_st; - -// The following two structures are internal, and never exposed to users. -struct memcached_string_st; -struct memcached_string_t; -struct memcached_continuum_item_st; - -#else - -typedef struct memcached_st memcached_st; -typedef struct memcached_stat_st memcached_stat_st; -typedef struct memcached_analysis_st memcached_analysis_st; -typedef struct memcached_result_st memcached_result_st; -typedef struct memcached_array_st memcached_array_st; -typedef struct memcached_error_t memcached_error_t; - -// All of the flavors of memcache_server_st -typedef struct memcached_server_st memcached_server_st; -typedef const void *memcached_server_instance_st; -typedef struct memcached_server_st *memcached_server_list_st; - -typedef struct memcached_callback_st memcached_callback_st; - -// The following two structures are internal, and never exposed to users. -typedef struct memcached_string_st memcached_string_st; -typedef struct memcached_string_t memcached_string_t; - -#endif diff --git a/libmemcached-1.0/types/behavior.h b/libmemcached-1.0/types/behavior.h deleted file mode 100644 index d0af189a..00000000 --- a/libmemcached-1.0/types/behavior.h +++ /dev/null @@ -1,84 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -enum memcached_behavior_t { - 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_KETAMA_WEIGHTED, - MEMCACHED_BEHAVIOR_KETAMA_HASH, - MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, - MEMCACHED_BEHAVIOR_SND_TIMEOUT, - MEMCACHED_BEHAVIOR_RCV_TIMEOUT, - MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, - MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, - MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, - MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, - MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, - MEMCACHED_BEHAVIOR_NOREPLY, - MEMCACHED_BEHAVIOR_USE_UDP, - MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, - MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, - MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, - MEMCACHED_BEHAVIOR_CORK, - MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, - MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, - MEMCACHED_BEHAVIOR_LOAD_FROM_FILE, - MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, - MEMCACHED_BEHAVIOR_DEAD_TIMEOUT, - MEMCACHED_BEHAVIOR_MAX -}; - -#ifndef __cplusplus -typedef enum memcached_behavior_t memcached_behavior_t; -#endif diff --git a/libmemcached-1.0/types/callback.h b/libmemcached-1.0/types/callback.h deleted file mode 100644 index d5481f50..00000000 --- a/libmemcached-1.0/types/callback.h +++ /dev/null @@ -1,54 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -enum memcached_callback_t { - MEMCACHED_CALLBACK_PREFIX_KEY = 0, - MEMCACHED_CALLBACK_USER_DATA = 1, - MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, - MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, - MEMCACHED_CALLBACK_GET_FAILURE = 7, - MEMCACHED_CALLBACK_DELETE_TRIGGER = 8, - MEMCACHED_CALLBACK_MAX, - MEMCACHED_CALLBACK_NAMESPACE= MEMCACHED_CALLBACK_PREFIX_KEY -}; - -#ifndef __cplusplus -typedef enum memcached_callback_t memcached_callback_t; -#endif diff --git a/libmemcached-1.0/types/connection.h b/libmemcached-1.0/types/connection.h deleted file mode 100644 index d2a072b7..00000000 --- a/libmemcached-1.0/types/connection.h +++ /dev/null @@ -1,49 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -enum memcached_connection_t { - MEMCACHED_CONNECTION_TCP, - MEMCACHED_CONNECTION_UDP, - MEMCACHED_CONNECTION_UNIX_SOCKET -}; - -#ifndef __cplusplus -typedef enum memcached_connection_t memcached_connection_t; -#endif diff --git a/libmemcached-1.0/types/hash.h b/libmemcached-1.0/types/hash.h deleted file mode 100644 index 7651eb1a..00000000 --- a/libmemcached-1.0/types/hash.h +++ /dev/null @@ -1,58 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -enum memcached_hash_t { - 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_HSIEH, - MEMCACHED_HASH_MURMUR, - MEMCACHED_HASH_JENKINS, - MEMCACHED_HASH_CUSTOM, - MEMCACHED_HASH_MAX -}; - -#ifndef __cplusplus -typedef enum memcached_hash_t memcached_hash_t; -#endif diff --git a/libmemcached-1.0/types/include.am b/libmemcached-1.0/types/include.am deleted file mode 100644 index fa330469..00000000 --- a/libmemcached-1.0/types/include.am +++ /dev/null @@ -1,8 +0,0 @@ -# vim:ft=automake - -nobase_include_HEADERS+= libmemcached-1.0/types/behavior.h -nobase_include_HEADERS+= libmemcached-1.0/types/callback.h -nobase_include_HEADERS+= libmemcached-1.0/types/connection.h -nobase_include_HEADERS+= libmemcached-1.0/types/hash.h -nobase_include_HEADERS+= libmemcached-1.0/types/return.h -nobase_include_HEADERS+= libmemcached-1.0/types/server_distribution.h diff --git a/libmemcached-1.0/types/return.h b/libmemcached-1.0/types/return.h deleted file mode 100644 index f4ec9b08..00000000 --- a/libmemcached-1.0/types/return.h +++ /dev/null @@ -1,95 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -enum memcached_return_t { - MEMCACHED_SUCCESS, - MEMCACHED_FAILURE, - MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only - MEMCACHED_CONNECTION_FAILURE, - MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE - MEMCACHED_WRITE_FAILURE, - MEMCACHED_READ_FAILURE, - MEMCACHED_UNKNOWN_READ_FAILURE, - MEMCACHED_PROTOCOL_ERROR, - MEMCACHED_CLIENT_ERROR, - MEMCACHED_SERVER_ERROR, // Server returns "SERVER_ERROR" - MEMCACHED_ERROR, // Server returns "ERROR" - 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_ITEM, - MEMCACHED_ERRNO, - MEMCACHED_FAIL_UNIX_SOCKET, // DEPRECATED - MEMCACHED_NOT_SUPPORTED, - MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */ - MEMCACHED_FETCH_NOTFINISHED, - MEMCACHED_TIMEOUT, - MEMCACHED_BUFFERED, - MEMCACHED_BAD_KEY_PROVIDED, - MEMCACHED_INVALID_HOST_PROTOCOL, - MEMCACHED_SERVER_MARKED_DEAD, - MEMCACHED_UNKNOWN_STAT_KEY, - MEMCACHED_E2BIG, - MEMCACHED_INVALID_ARGUMENTS, - MEMCACHED_KEY_TOO_BIG, - MEMCACHED_AUTH_PROBLEM, - MEMCACHED_AUTH_FAILURE, - MEMCACHED_AUTH_CONTINUE, - MEMCACHED_PARSE_ERROR, - MEMCACHED_PARSE_USER_ERROR, - MEMCACHED_DEPRECATED, - MEMCACHED_IN_PROGRESS, - MEMCACHED_SERVER_TEMPORARILY_DISABLED, - MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE, - MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ - MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE= MEMCACHED_ERROR -}; - -#ifndef __cplusplus -typedef enum memcached_return_t memcached_return_t; -#endif diff --git a/libmemcached-1.0/types/server_distribution.h b/libmemcached-1.0/types/server_distribution.h deleted file mode 100644 index 95e129f6..00000000 --- a/libmemcached-1.0/types/server_distribution.h +++ /dev/null @@ -1,54 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#pragma once - -enum memcached_server_distribution_t { - MEMCACHED_DISTRIBUTION_MODULA, - MEMCACHED_DISTRIBUTION_CONSISTENT, - MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, - MEMCACHED_DISTRIBUTION_RANDOM, - MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, - MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED, - MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET, - MEMCACHED_DISTRIBUTION_CONSISTENT_MAX -}; - -#ifndef __cplusplus -typedef enum memcached_server_distribution_t memcached_server_distribution_t; -#endif diff --git a/libmemcached-1.0/verbosity.h b/libmemcached-1.0/verbosity.h deleted file mode 100644 index 29946486..00000000 --- a/libmemcached-1.0/verbosity.h +++ /dev/null @@ -1,50 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity); - - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/version.h b/libmemcached-1.0/version.h deleted file mode 100644 index c443accb..00000000 --- a/libmemcached-1.0/version.h +++ /dev/null @@ -1,52 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -memcached_return_t memcached_version(memcached_st *ptr); - -LIBMEMCACHED_API -const char * memcached_lib_version(void); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcached-1.0/visibility.h b/libmemcached-1.0/visibility.h deleted file mode 100644 index d4e4eea0..00000000 --- a/libmemcached-1.0/visibility.h +++ /dev/null @@ -1,67 +0,0 @@ -/* LibMemcached - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. - * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. - * - * Summary: Interface for memcached server. - * - * Author: Trond Norbye - * - */ - -/** - * @file - * @brief Visibility control macros - */ - -#pragma once - -/** - * - * LIBMEMCACHED_API is used for the public API symbols. It either DLL imports or - * DLL exports (or does nothing for static build). - * - * LIBMEMCACHED_LOCAL is used for non-api symbols. - */ - -#if defined(BUILDING_LIBMEMCACHEDINTERNAL) -# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY -# define LIBMEMCACHED_API __attribute__ ((visibility("default"))) -# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("default"))) -# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) -# define LIBMEMCACHED_API __global -# define LIBMEMCACHED_LOCAL __global -# elif defined(_MSC_VER) -# define LIBMEMCACHED_API extern __declspec(dllexport) -# define LIBMEMCACHED_LOCAL extern __declspec(dllexport) -# else -# define LIBMEMCACHED_API -# define LIBMEMCACHED_LOCAL -# endif -#else -# if defined(BUILDING_LIBMEMCACHED) -# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY -# define LIBMEMCACHED_API __attribute__ ((visibility("default"))) -# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden"))) -# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) -# define LIBMEMCACHED_API __global -# define LIBMEMCACHED_LOCAL __hidden -# elif defined(_MSC_VER) -# define LIBMEMCACHED_API extern __declspec(dllexport) -# define LIBMEMCACHED_LOCAL -# else -# define LIBMEMCACHED_API -# define LIBMEMCACHED_LOCAL -# endif /* defined(HAVE_VISIBILITY) */ -# else /* defined(BUILDING_LIBMEMCACHED) */ -# if defined(_MSC_VER) -# define LIBMEMCACHED_API extern __declspec(dllimport) -# define LIBMEMCACHED_LOCAL -# else -# define LIBMEMCACHED_API -# define LIBMEMCACHED_LOCAL -# endif /* defined(_MSC_VER) */ -# endif /* defined(BUILDING_LIBMEMCACHED) */ -#endif /* defined(BUILDING_LIBMEMCACHEDINTERNAL) */ diff --git a/libmemcached-1.2/alloc.h b/libmemcached-1.2/alloc.h new file mode 100644 index 00000000..bc65b951 --- /dev/null +++ b/libmemcached-1.2/alloc.h @@ -0,0 +1,54 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Memory allocation functions. +*/ +typedef void (*memcached_free_fn)(const memcached_st *ptr, void *mem, void *context); +typedef void *(*memcached_malloc_fn)(const memcached_st *ptr, const size_t size, void *context); +typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context); +typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/allocators.h b/libmemcached-1.2/allocators.h new file mode 100644 index 00000000..86f05a06 --- /dev/null +++ b/libmemcached-1.2/allocators.h @@ -0,0 +1,64 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, + memcached_malloc_fn mem_malloc, + memcached_free_fn mem_free, + memcached_realloc_fn mem_realloc, + memcached_calloc_fn mem_calloc, + void *context); + +LIBMEMCACHED_API +void memcached_get_memory_allocators(const memcached_st *ptr, + memcached_malloc_fn *mem_malloc, + memcached_free_fn *mem_free, + memcached_realloc_fn *mem_realloc, + memcached_calloc_fn *mem_calloc); + +LIBMEMCACHED_API +void *memcached_get_memory_allocators_context(const memcached_st *ptr); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/analyze.h b/libmemcached-1.2/analyze.h new file mode 100644 index 00000000..50a7f063 --- /dev/null +++ b/libmemcached-1.2/analyze.h @@ -0,0 +1,56 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_analysis_st *memcached_analyze(memcached_st *memc, + memcached_stat_st *memc_stat, + memcached_return_t *error); + +LIBMEMCACHED_API +void memcached_analyze_free(memcached_analysis_st *); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/auto.h b/libmemcached-1.2/auto.h new file mode 100644 index 00000000..f37d50fc --- /dev/null +++ b/libmemcached-1.2/auto.h @@ -0,0 +1,111 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + memcached_return_t memcached_increment(memcached_st *ptr, + const char *key, size_t key_length, + uint32_t offset, + uint64_t *value); +LIBMEMCACHED_API + memcached_return_t memcached_decrement(memcached_st *ptr, + const char *key, size_t key_length, + uint32_t offset, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_increment_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + uint64_t offset, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_decrement_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + uint64_t offset, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_increment_with_initial(memcached_st *ptr, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, + const char *group_key, + size_t group_key_length, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value); + +LIBMEMCACHED_API + memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, + const char *group_key, + size_t group_key_length, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/basic_string.h b/libmemcached-1.2/basic_string.h new file mode 100644 index 00000000..de8d3d51 --- /dev/null +++ b/libmemcached-1.2/basic_string.h @@ -0,0 +1,55 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +// No assumptions of NULL should be made + +struct memcached_string_t { + const char *c_str; + size_t size; +}; + +#define memcached_size(X) (X).size; +#define memcached_c_str(X) (X).c_str; +#define memcached_string_param(X) (X).c_str, (X).size + +#ifdef __cplusplus +#define memcached_string_printf(X) int((X).size), (X).c_str +#else +#define memcached_string_printf(X) (int)((X).size), (X).c_str +#endif + diff --git a/libmemcached-1.2/behavior.h b/libmemcached-1.2/behavior.h new file mode 100644 index 00000000..c6633532 --- /dev/null +++ b/libmemcached-1.2/behavior.h @@ -0,0 +1,83 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data); + +LIBMEMCACHED_API +uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag); + +LIBMEMCACHED_API +memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type); + +LIBMEMCACHED_API +memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type); + +LIBMEMCACHED_API +memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type); + +LIBMEMCACHED_API +memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr); + +LIBMEMCACHED_API + const char *libmemcached_string_behavior(const memcached_behavior_t flag); + +LIBMEMCACHED_API + const char *libmemcached_string_distribution(const memcached_server_distribution_t flag); + +LIBMEMCACHED_API + memcached_return_t memcached_bucket_set(memcached_st *self, + const uint32_t *host_map, + const uint32_t *forward_map, + const uint32_t buckets, + const uint32_t replicas); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/callback.h b/libmemcached-1.2/callback.h new file mode 100644 index 00000000..a62e9aa6 --- /dev/null +++ b/libmemcached-1.2/callback.h @@ -0,0 +1,55 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_callback_set(memcached_st *ptr, + const memcached_callback_t flag, + const void *data); +LIBMEMCACHED_API +void *memcached_callback_get(memcached_st *ptr, + const memcached_callback_t flag, + memcached_return_t *error); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/callbacks.h b/libmemcached-1.2/callbacks.h new file mode 100644 index 00000000..e321ceb4 --- /dev/null +++ b/libmemcached-1.2/callbacks.h @@ -0,0 +1,53 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); +typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); +typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server, + const char *key, size_t key_length, + const char *value, size_t value_length, + void *context); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/configure.h.in b/libmemcached-1.2/configure.h.in new file mode 100644 index 00000000..3f0465a0 --- /dev/null +++ b/libmemcached-1.2/configure.h.in @@ -0,0 +1,52 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker, Trond Norbye All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +@DEPRECATED@ +@LIBMEMCACHED_WITH_SASL_SUPPORT@ + +#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION_STRING@" +#define LIBMEMCACHED_VERSION_HEX @LIBMEMCACHED_VERSION_HEX@ + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/defaults.h b/libmemcached-1.2/defaults.h new file mode 100644 index 00000000..38c29ba3 --- /dev/null +++ b/libmemcached-1.2/defaults.h @@ -0,0 +1,55 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +/* Public defines */ +#define MEMCACHED_DEFAULT_PORT 11211 +#define MEMCACHED_POINTS_PER_SERVER 100 +#define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 +#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */ +#define MEMCACHED_STRIDE 4 +#define MEMCACHED_DEFAULT_TIMEOUT 5000 +#define MEMCACHED_DEFAULT_CONNECT_TIMEOUT 4000 +#define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should build for in the continuum */ +#define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU +#define MEMCACHED_SERVER_FAILURE_LIMIT 5 +#define MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT 2 +#define MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT 0 + + diff --git a/libmemcached-1.2/delete.h b/libmemcached-1.2/delete.h new file mode 100644 index 00000000..617d5857 --- /dev/null +++ b/libmemcached-1.2/delete.h @@ -0,0 +1,57 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length, + time_t expiration); + +LIBMEMCACHED_API +memcached_return_t memcached_delete_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + time_t expiration); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/deprecated_types.h b/libmemcached-1.2/deprecated_types.h new file mode 100644 index 00000000..716d3e44 --- /dev/null +++ b/libmemcached-1.2/deprecated_types.h @@ -0,0 +1,60 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Warning, none of these should ever be used. + */ + +#pragma once + +/** + @note The following definitions are just here for backwards compatibility. +*/ +typedef memcached_return_t memcached_return; +typedef memcached_server_distribution_t memcached_server_distribution; +typedef memcached_behavior_t memcached_behavior; +typedef memcached_callback_t memcached_callback; +typedef memcached_hash_t memcached_hash; +typedef memcached_connection_t memcached_connection; +typedef memcached_clone_fn memcached_clone_func; +typedef memcached_cleanup_fn memcached_cleanup_func; +typedef memcached_execute_fn memcached_execute_function; +typedef memcached_server_fn memcached_server_function; +typedef memcached_trigger_key_fn memcached_trigger_key; +typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key; +typedef memcached_dump_fn memcached_dump_func; + diff --git a/libmemcached-1.2/dump.h b/libmemcached-1.2/dump.h new file mode 100644 index 00000000..b6e639e8 --- /dev/null +++ b/libmemcached-1.2/dump.h @@ -0,0 +1,51 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); + + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/encoding_key.h b/libmemcached-1.2/encoding_key.h new file mode 100644 index 00000000..3adbcb62 --- /dev/null +++ b/libmemcached-1.2/encoding_key.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + memcached_return_t memcached_set_encoding_key(memcached_st*, const char *str, size_t length); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/error.h b/libmemcached-1.2/error.h new file mode 100644 index 00000000..7fdc18b8 --- /dev/null +++ b/libmemcached-1.2/error.h @@ -0,0 +1,67 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * LibMemcached + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + const char *memcached_error(const memcached_st *); + +LIBMEMCACHED_API + const char *memcached_last_error_message(const memcached_st *); + +LIBMEMCACHED_API + void memcached_error_print(const memcached_st *); + +LIBMEMCACHED_API + memcached_return_t memcached_last_error(const memcached_st *); + +LIBMEMCACHED_API + int memcached_last_error_errno(const memcached_st *); + +LIBMEMCACHED_API + const char *memcached_server_error(const memcached_server_instance_st ptr); + +LIBMEMCACHED_API + memcached_return_t memcached_server_error_return(const memcached_server_instance_st ptr); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/exception.hpp b/libmemcached-1.2/exception.hpp new file mode 100644 index 00000000..4759072a --- /dev/null +++ b/libmemcached-1.2/exception.hpp @@ -0,0 +1,60 @@ +/* + * Summary: Exceptions for the C++ interface + * + * Copy: See Copyright for the status of this software. + * + */ + +/** + * @file + * @brief Exception declarations + */ + +#pragma once + +#include +#include + +namespace memcache +{ + class Exception : public std::runtime_error + { + public: + Exception(const std::string& msg, int in_errno) + : + std::runtime_error(msg), + _errno(in_errno) + {} + + Exception(const char *msg, int in_errno) + : + std::runtime_error(std::string(msg)), + _errno(in_errno) {} + + virtual ~Exception() throw() {} + + int getErrno() const + { + return _errno; + } + + private: + int _errno; + }; + + class Warning : public Exception + { + public: + Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} + Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {} + }; + + class Error : public Exception + { + public: + Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} + Error(const char *msg, int in_errno) : Exception(msg, in_errno) {} + virtual ~Error() throw() {} + }; + +} /* namespace libmemcached */ diff --git a/libmemcached-1.2/exist.h b/libmemcached-1.2/exist.h new file mode 100644 index 00000000..ef60a81a --- /dev/null +++ b/libmemcached-1.2/exist.h @@ -0,0 +1,52 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_exist(memcached_st *memc, const char *key, size_t key_length); + +LIBMEMCACHED_API +memcached_return_t memcached_exist_by_key(memcached_st *memc, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length); +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/fetch.h b/libmemcached-1.2/fetch.h new file mode 100644 index 00000000..bff186ac --- /dev/null +++ b/libmemcached-1.2/fetch.h @@ -0,0 +1,53 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_fetch_execute(memcached_st *ptr, + memcached_execute_fn *callback, + void *context, + uint32_t number_of_callbacks); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/flush.h b/libmemcached-1.2/flush.h new file mode 100644 index 00000000..820a98e7 --- /dev/null +++ b/libmemcached-1.2/flush.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/flush_buffers.h b/libmemcached-1.2/flush_buffers.h new file mode 100644 index 00000000..31b58687 --- /dev/null +++ b/libmemcached-1.2/flush_buffers.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_flush_buffers(memcached_st *mem); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/get.h b/libmemcached-1.2/get.h new file mode 100644 index 00000000..32e4c5f3 --- /dev/null +++ b/libmemcached-1.2/get.h @@ -0,0 +1,110 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public defines */ +LIBMEMCACHED_API +char *memcached_get(memcached_st *ptr, + const char *key, size_t key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + +LIBMEMCACHED_API +memcached_return_t memcached_mget(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys); + +LIBMEMCACHED_API +char *memcached_get_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + +LIBMEMCACHED_API +memcached_return_t memcached_mget_by_key(memcached_st *ptr, + const char *group_key, + size_t group_key_length, + const char * const *keys, + const size_t *key_length, + const size_t number_of_keys); + +LIBMEMCACHED_API +char *memcached_fetch(memcached_st *ptr, + char *key, + size_t *key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + +LIBMEMCACHED_API +memcached_result_st *memcached_fetch_result(memcached_st *ptr, + memcached_result_st *result, + memcached_return_t *error); + +LIBMEMCACHED_API +memcached_return_t memcached_mget_execute(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + const size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + const uint32_t number_of_callbacks); + +LIBMEMCACHED_API +memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, + const char *group_key, + size_t group_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + const uint32_t number_of_callbacks); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/hash.h b/libmemcached-1.2/hash.h new file mode 100644 index 00000000..9fdb7d6f --- /dev/null +++ b/libmemcached-1.2/hash.h @@ -0,0 +1,65 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/* The two public hash bits */ +LIBMEMCACHED_API +uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm); + +LIBMEMCACHED_API +const hashkit_st *memcached_get_hashkit(const memcached_st *ptr); + +LIBMEMCACHED_API +memcached_return_t memcached_set_hashkit(memcached_st *ptr, hashkit_st *hashk); + +LIBMEMCACHED_API +uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length); + +LIBMEMCACHED_API +void memcached_autoeject(memcached_st *ptr); + +LIBMEMCACHED_API + const char * libmemcached_string_hash(memcached_hash_t type); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/include.am b/libmemcached-1.2/include.am new file mode 100644 index 00000000..9e597d0a --- /dev/null +++ b/libmemcached-1.2/include.am @@ -0,0 +1,56 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +EXTRA_DIST+= libmemcached-1.2/configure.h.in +BUILT_SOURCES+= libmemcached-1.2/configure.h + +include libmemcached-1.2/struct/include.am +include libmemcached-1.2/types/include.am + +# Tests for this version of the interface +include libmemcached-1.2/t/include.am + +nobase_include_HEADERS+= libmemcached-1.2/alloc.h +nobase_include_HEADERS+= libmemcached-1.2/allocators.h +nobase_include_HEADERS+= libmemcached-1.2/analyze.h +nobase_include_HEADERS+= libmemcached-1.2/auto.h +nobase_include_HEADERS+= libmemcached-1.2/basic_string.h +nobase_include_HEADERS+= libmemcached-1.2/behavior.h +nobase_include_HEADERS+= libmemcached-1.2/callback.h +nobase_include_HEADERS+= libmemcached-1.2/callbacks.h +nobase_include_HEADERS+= libmemcached-1.2/configure.h +nobase_include_HEADERS+= libmemcached-1.2/defaults.h +nobase_include_HEADERS+= libmemcached-1.2/delete.h +nobase_include_HEADERS+= libmemcached-1.2/dump.h +nobase_include_HEADERS+= libmemcached-1.2/encoding_key.h +nobase_include_HEADERS+= libmemcached-1.2/error.h +nobase_include_HEADERS+= libmemcached-1.2/exception.hpp +nobase_include_HEADERS+= libmemcached-1.2/exist.h +nobase_include_HEADERS+= libmemcached-1.2/fetch.h +nobase_include_HEADERS+= libmemcached-1.2/flush.h +nobase_include_HEADERS+= libmemcached-1.2/flush_buffers.h +nobase_include_HEADERS+= libmemcached-1.2/get.h +nobase_include_HEADERS+= libmemcached-1.2/hash.h +nobase_include_HEADERS+= libmemcached-1.2/limits.h +nobase_include_HEADERS+= libmemcached-1.2/memcached.h +nobase_include_HEADERS+= libmemcached-1.2/memcached.hpp +nobase_include_HEADERS+= libmemcached-1.2/memcached/vbucket.h +nobase_include_HEADERS+= libmemcached-1.2/options.h +nobase_include_HEADERS+= libmemcached-1.2/parse.h +nobase_include_HEADERS+= libmemcached-1.2/platform.h +nobase_include_HEADERS+= libmemcached-1.2/quit.h +nobase_include_HEADERS+= libmemcached-1.2/result.h +nobase_include_HEADERS+= libmemcached-1.2/return.h +nobase_include_HEADERS+= libmemcached-1.2/sasl.h +nobase_include_HEADERS+= libmemcached-1.2/server.h +nobase_include_HEADERS+= libmemcached-1.2/server_list.h +nobase_include_HEADERS+= libmemcached-1.2/stats.h +nobase_include_HEADERS+= libmemcached-1.2/storage.h +nobase_include_HEADERS+= libmemcached-1.2/strerror.h +nobase_include_HEADERS+= libmemcached-1.2/touch.h +nobase_include_HEADERS+= libmemcached-1.2/triggers.h +nobase_include_HEADERS+= libmemcached-1.2/types.h +nobase_include_HEADERS+= libmemcached-1.2/verbosity.h +nobase_include_HEADERS+= libmemcached-1.2/version.h +nobase_include_HEADERS+= libmemcached-1.2/visibility.h diff --git a/libmemcached-1.2/limits.h b/libmemcached-1.2/limits.h new file mode 100644 index 00000000..076df407 --- /dev/null +++ b/libmemcached-1.2/limits.h @@ -0,0 +1,46 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH 20 +#define MEMCACHED_MAX_BUFFER 8196 +#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ +#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ +#define MEMCACHED_PREFIX_KEY_MAX_SIZE 128 +#define MEMCACHED_VERSION_STRING_LENGTH 24 diff --git a/libmemcached-1.2/memcached.h b/libmemcached-1.2/memcached.h new file mode 100644 index 00000000..7d932471 --- /dev/null +++ b/libmemcached-1.2/memcached.h @@ -0,0 +1,167 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +/* This seems to be required for older compilers @note http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t */ +#ifndef __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +#endif + +#ifdef __cplusplus +# include +# include +# include +#else +# include +# include +# include +# include +#endif + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// Everything above this line must be in the order specified. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +void memcached_servers_reset(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_st *memcached_create(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_st *memcached(const char *string, size_t string_length); + +LIBMEMCACHED_API +void memcached_free(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_return_t memcached_reset(memcached_st *ptr); + +LIBMEMCACHED_API +void memcached_reset_last_disconnected_server(memcached_st *ptr); + +LIBMEMCACHED_API +memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr); + +LIBMEMCACHED_API +void *memcached_get_user_data(const memcached_st *ptr); + +LIBMEMCACHED_API +void *memcached_set_user_data(memcached_st *ptr, void *data); + +LIBMEMCACHED_API +memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source); + +LIBMEMCACHED_API +memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key); + +LIBMEMCACHED_API +uint32_t memcached_server_count(const memcached_st *); + +LIBMEMCACHED_API +uint64_t memcached_query_id(const memcached_st *); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/memcached.hpp b/libmemcached-1.2/memcached.hpp new file mode 100644 index 00000000..0bcb200e --- /dev/null +++ b/libmemcached-1.2/memcached.hpp @@ -0,0 +1,878 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Summary: C++ interface for memcached server + * + * Copy: See Copyright for the status of this software. + * + * Authors: Padraig O'Sullivan + * Patrick Galbraith + */ + +/** + * @file memcached.hpp + * @brief Libmemcached C++ interface + */ + +#pragma once + +#include +#if 0 +#include +#endif + +#include + +#include +#include +#include +#include + +namespace memcache +{ + +/** + * This is the core memcached library (if later, other objects + * are needed, they will be created from this class). + */ +class Memcache +{ +public: + + Memcache() + { + memc_= memcached(NULL, 0); + } + + Memcache(const std::string &config) + { + memc_= memcached(config.c_str(), config.size()); + } + + Memcache(const std::string &hostname, in_port_t port) + { + memc_= memcached(NULL, 0); + if (memc_) + { + memcached_server_add(memc_, hostname.c_str(), port); + } + } + + Memcache(memcached_st *clone) + { + memc_= memcached_clone(NULL, clone); + } + + Memcache(const Memcache &rhs) + { + memc_= memcached_clone(NULL, rhs.getImpl()); + } + + Memcache &operator=(const Memcache &rhs) + { + if (this != &rhs) + { + memcached_free(memc_); + memc_= memcached_clone(NULL, rhs.getImpl()); + } + + return *this; + } + + ~Memcache() + { + memcached_free(memc_); + } + + /** + * Get the internal memcached_st * + */ + const memcached_st *getImpl() const + { + return memc_; + } + + /** + * Return an error string for the given return structure. + * + * @param[in] rc a memcached_return_t structure + * @return error string corresponding to given return code in the library. + */ + const std::string getError(memcached_return_t rc) const + { + /* first parameter to strerror is unused */ + return memcached_strerror(NULL, rc); + } + + bool error(std::string& error_message) const + { + if (memcached_failed(memcached_last_error(memc_))) + { + error_message+= memcached_last_error_message(memc_); + return true; + } + + return false; + } + + bool error() const + { + if (memcached_failed(memcached_last_error(memc_))) + { + return true; + } + + return false; + } + + bool error(memcached_return_t& arg) const + { + arg= memcached_last_error(memc_); + return memcached_failed(arg); + } + + bool setBehavior(memcached_behavior_t flag, uint64_t data) + { + return (memcached_success(memcached_behavior_set(memc_, flag, data))); + } + + uint64_t getBehavior(memcached_behavior_t flag) + { + return memcached_behavior_get(memc_, flag); + } + + /** + * Configure the memcache object + * + * @param[in] in_config configuration + * @return true on success; false otherwise + */ + bool configure(const std::string &configuration) + { + memcached_st *new_memc= memcached(configuration.c_str(), configuration.size()); + + if (new_memc) + { + memcached_free(memc_); + memc_= new_memc; + + return true; + } + + return false; + } + + /** + * Add a server to the list of memcached servers to use. + * + * @param[in] server_name name of the server to add + * @param[in] port port number of server to add + * @return true on success; false otherwise + */ + bool addServer(const std::string &server_name, in_port_t port) + { + return memcached_success(memcached_server_add(memc_, server_name.c_str(), port)); + } + + /** + * Remove a server from the list of memcached servers to use. + * + * @param[in] server_name name of the server to remove + * @param[in] port port number of server to remove + * @return true on success; false otherwise + */ + bool removeServer(const std::string &server_name, in_port_t port) + { + std::string tmp_str; + std::ostringstream strstm; + tmp_str.append(","); + tmp_str.append(server_name); + tmp_str.append(":"); + strstm << port; + tmp_str.append(strstm.str()); + + //memcached_return_t rc= memcached_server_remove(server); + + return false; + } + + /** + * Fetches an individual value from the server. mget() must always + * be called before using this method. + * + * @param[in] key key of object to fetch + * @param[out] ret_val store returned object in this vector + * @return a memcached return structure + */ + memcached_return_t fetch(std::string &key, + std::vector &ret_val, + uint32_t &flags, + uint64_t &cas_value) + { + memcached_return_t rc; + + memcached_result_st *result; + if ((result= memcached_fetch_result(memc_, NULL, &rc))) + { + // Key + key.assign(memcached_result_key_value(result), memcached_result_key_length(result)); + + // Actual value, null terminated + ret_val.reserve(memcached_result_length(result) +1); + ret_val.assign(memcached_result_value(result), + memcached_result_value(result) +memcached_result_length(result) +1); + ret_val.resize(memcached_result_length(result)); + + // Misc + flags= memcached_result_flags(result); + cas_value= memcached_result_cas(result); + } + memcached_result_free(result); + + return rc; + } + + memcached_return_t fetch(std::string &key, + std::vector &ret_val) + { + uint32_t flags= 0; + uint64_t cas_value= 0; + + return fetch(key, ret_val, flags, cas_value); + } + + /** + * Fetches an individual value from the server. + * + * @param[in] key key of object whose value to get + * @param[out] ret_val object that is retrieved is stored in + * this vector + * @return true on success; false otherwise + */ + bool get(const std::string &key, std::vector &ret_val) + { + uint32_t flags= 0; + memcached_return_t rc; + size_t value_length= 0; + + char *value= memcached_get(memc_, key.c_str(), key.length(), + &value_length, &flags, &rc); + if (value != NULL && ret_val.empty()) + { + ret_val.reserve(value_length +1); // Always provide null + ret_val.assign(value, value +value_length +1); + ret_val.resize(value_length); + free(value); + + return true; + } + + return false; + } + + /** + * Fetches an individual from a server which is specified by + * the master_key parameter that is used for determining which + * server an object was stored in if key partitioning was + * used for storage. + * + * @param[in] master_key key that specifies server object is stored on + * @param[in] key key of object whose value to get + * @param[out] ret_val object that is retrieved is stored in + * this vector + * @return true on success; false otherwise + */ + bool getByKey(const std::string &master_key, + const std::string &key, + std::vector &ret_val) + { + uint32_t flags= 0; + memcached_return_t rc; + size_t value_length= 0; + + char *value= memcached_get_by_key(memc_, + master_key.c_str(), master_key.length(), + key.c_str(), key.length(), + &value_length, &flags, &rc); + if (value) + { + ret_val.reserve(value_length +1); // Always provide null + ret_val.assign(value, value +value_length +1); + ret_val.resize(value_length); + free(value); + + return true; + } + return false; + } + + /** + * Selects multiple keys at once. This method always + * works asynchronously. + * + * @param[in] keys vector of keys to select + * @return true if all keys are found + */ + bool mget(const std::vector& keys) + { + std::vector real_keys; + std::vector key_len; + /* + * Construct an array which will contain the length + * of each of the strings in the input vector. Also, to + * interface with the memcached C API, we need to convert + * the vector of std::string's to a vector of char *. + */ + real_keys.reserve(keys.size()); + key_len.reserve(keys.size()); + + std::vector::const_iterator it= keys.begin(); + + while (it != keys.end()) + { + real_keys.push_back(const_cast((*it).c_str())); + key_len.push_back((*it).length()); + ++it; + } + + /* + * If the std::vector of keys is empty then we cannot + * call memcached_mget as we will get undefined behavior. + */ + if (not real_keys.empty()) + { + return memcached_success(memcached_mget(memc_, &real_keys[0], &key_len[0], real_keys.size())); + } + + return false; + } + + /** + * Writes an object to the server. If the object already exists, it will + * overwrite the existing object. This method always returns true + * when using non-blocking mode unless a network error occurs. + * + * @param[in] key key of object to write to server + * @param[in] value value of object to write to server + * @param[in] expiration time to keep the object stored in the server for + * @param[in] flags flags to store with the object + * @return true on succcess; false otherwise + */ + bool set(const std::string &key, + const std::vector &value, + time_t expiration, + uint32_t flags) + { + memcached_return_t rc= memcached_set(memc_, + key.c_str(), key.length(), + &value[0], value.size(), + expiration, flags); + return memcached_success(rc); + } + + bool set(const std::string &key, + const char* value, const size_t value_length, + time_t expiration, + uint32_t flags) + { + memcached_return_t rc= memcached_set(memc_, + key.c_str(), key.length(), + value, value_length, + expiration, flags); + return memcached_success(rc); + } + + /** + * Writes an object to a server specified by the master_key parameter. + * If the object already exists, it will overwrite the existing object. + * + * @param[in] master_key key that specifies server to write to + * @param[in] key key of object to write to server + * @param[in] value value of object to write to server + * @param[in] expiration time to keep the object stored in the server for + * @param[in] flags flags to store with the object + * @return true on succcess; false otherwise + */ + bool setByKey(const std::string& master_key, + const std::string& key, + const std::vector &value, + time_t expiration, + uint32_t flags) + { + return memcached_success(memcached_set_by_key(memc_, master_key.c_str(), + master_key.length(), + key.c_str(), key.length(), + &value[0], value.size(), + expiration, + flags)); + } + + /** + * Writes a list of objects to the server. Objects are specified by + * 2 vectors - 1 vector of keys and 1 vector of values. + * + * @param[in] keys vector of keys of objects to write to server + * @param[in] values vector of values of objects to write to server + * @param[in] expiration time to keep the objects stored in server for + * @param[in] flags flags to store with the objects + * @return true on success; false otherwise + */ + bool setAll(const std::vector& keys, + const std::vector< std::vector *>& values, + time_t expiration, + uint32_t flags) + { + bool retval= true; + std::vector::const_iterator key_it= keys.begin(); + std::vector< std::vector *>::const_iterator val_it= values.begin(); + while (key_it != keys.end()) + { + retval= set((*key_it), *(*val_it), expiration, flags); + if (retval == false) + { + return retval; + } + ++key_it; + ++val_it; + } + return retval; + } + + /** + * Writes a list of objects to the server. Objects are specified by + * a map of keys to values. + * + * @param[in] key_value_map map of keys and values to store in server + * @param[in] expiration time to keep the objects stored in server for + * @param[in] flags flags to store with the objects + * @return true on success; false otherwise + */ + bool setAll(const std::map >& key_value_map, + time_t expiration, + uint32_t flags) + { + bool retval= true; + std::map >::const_iterator it= key_value_map.begin(); + + while (it != key_value_map.end()) + { + retval= set(it->first, it->second, expiration, flags); + if (retval == false) + { + // We should tell the user what the key that failed was + return false; + } + ++it; + } + + return true; + } + + /** + * Increment the value of the object associated with the specified + * key by the offset given. The resulting value is saved in the value + * parameter. + * + * @param[in] key key of object in server whose value to increment + * @param[in] offset amount to increment object's value by + * @param[out] value store the result of the increment here + * @return true on success; false otherwise + */ + bool increment(const std::string& key, uint32_t offset, uint64_t *value) + { + return memcached_success(memcached_increment(memc_, key.c_str(), key.length(), offset, value)); + } + + /** + * Decrement the value of the object associated with the specified + * key by the offset given. The resulting value is saved in the value + * parameter. + * + * @param[in] key key of object in server whose value to decrement + * @param[in] offset amount to increment object's value by + * @param[out] value store the result of the decrement here + * @return true on success; false otherwise + */ + bool decrement(const std::string& key, uint32_t offset, uint64_t *value) + { + return memcached_success(memcached_decrement(memc_, key.c_str(), + key.length(), + offset, value)); + } + + + /** + * Add an object with the specified key and value to the server. This + * function returns false if the object already exists on the server. + * + * @param[in] key key of object to add + * @param[in] value of object to add + * @return true on success; false otherwise + */ + bool add(const std::string& key, const std::vector& value) + { + return memcached_success(memcached_add(memc_, key.c_str(), key.length(), + &value[0], value.size(), 0, 0)); + } + + /** + * Add an object with the specified key and value to the server. This + * function returns false if the object already exists on the server. The + * server to add the object to is specified by the master_key parameter. + * + * @param[in[ master_key key of server to add object to + * @param[in] key key of object to add + * @param[in] value of object to add + * @return true on success; false otherwise + */ + bool addByKey(const std::string& master_key, + const std::string& key, + const std::vector& value) + { + return memcached_success(memcached_add_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, 0)); + } + + /** + * Replaces an object on the server. This method only succeeds + * if the object is already present on the server. + * + * @param[in] key key of object to replace + * @param[in[ value value to replace object with + * @return true on success; false otherwise + */ + bool replace(const std::string& key, const std::vector& value) + { + return memcached_success(memcached_replace(memc_, key.c_str(), key.length(), + &value[0], value.size(), + 0, 0)); + } + + /** + * Replaces an object on the server. This method only succeeds + * if the object is already present on the server. The server + * to replace the object on is specified by the master_key param. + * + * @param[in] master_key key of server to replace object on + * @param[in] key key of object to replace + * @param[in[ value value to replace object with + * @return true on success; false otherwise + */ + bool replaceByKey(const std::string& master_key, + const std::string& key, + const std::vector& value) + { + return memcached_success(memcached_replace_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, 0)); + } + + /** + * Places a segment of data before the last piece of data stored. + * + * @param[in] key key of object whose value we will prepend data to + * @param[in] value data to prepend to object's value + * @return true on success; false otherwise + */ + bool prepend(const std::string& key, const std::vector& value) + { + return memcached_success(memcached_prepend(memc_, key.c_str(), key.length(), + &value[0], value.size(), 0, 0)); + } + + /** + * Places a segment of data before the last piece of data stored. The + * server on which the object where we will be prepending data is stored + * on is specified by the master_key parameter. + * + * @param[in] master_key key of server where object is stored + * @param[in] key key of object whose value we will prepend data to + * @param[in] value data to prepend to object's value + * @return true on success; false otherwise + */ + bool prependByKey(const std::string& master_key, + const std::string& key, + const std::vector& value) + { + return memcached_success(memcached_prepend_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, + 0)); + } + + /** + * Places a segment of data at the end of the last piece of data stored. + * + * @param[in] key key of object whose value we will append data to + * @param[in] value data to append to object's value + * @return true on success; false otherwise + */ + bool append(const std::string& key, const std::vector& value) + { + return memcached_success(memcached_append(memc_, + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, 0)); + } + + /** + * Places a segment of data at the end of the last piece of data stored. The + * server on which the object where we will be appending data is stored + * on is specified by the master_key parameter. + * + * @param[in] master_key key of server where object is stored + * @param[in] key key of object whose value we will append data to + * @param[in] value data to append to object's value + * @return true on success; false otherwise + */ + bool appendByKey(const std::string& master_key, + const std::string& key, + const std::vector &value) + { + return memcached_success(memcached_append_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, 0)); + } + + /** + * Overwrite data in the server as long as the cas_arg value + * is still the same in the server. + * + * @param[in] key key of object in server + * @param[in] value value to store for object in server + * @param[in] cas_arg "cas" value + */ + bool cas(const std::string& key, + const std::vector& value, + uint64_t cas_arg) + { + return memcached_success(memcached_cas(memc_, key.c_str(), key.length(), + &value[0], value.size(), + 0, 0, cas_arg)); + } + + /** + * Overwrite data in the server as long as the cas_arg value + * is still the same in the server. The server to use is + * specified by the master_key parameter. + * + * @param[in] master_key specifies server to operate on + * @param[in] key key of object in server + * @param[in] value value to store for object in server + * @param[in] cas_arg "cas" value + */ + bool casByKey(const std::string& master_key, + const std::string& key, + const std::vector &value, + uint64_t cas_arg) + { + return memcached_success(memcached_cas_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + &value[0], + value.size(), + 0, 0, cas_arg)); + } + + /** + * Delete an object from the server specified by the key given. + * + * @param[in] key key of object to delete + * @return true on success; false otherwise + */ + bool remove(const std::string& key) + { + return memcached_success(memcached_delete(memc_, key.c_str(), key.length(), 0)); + } + + /** + * Delete an object from the server specified by the key given. + * + * @param[in] key key of object to delete + * @param[in] expiration time to delete the object after + * @return true on success; false otherwise + */ + bool remove(const std::string& key, time_t expiration) + { + return memcached_success(memcached_delete(memc_, + key.c_str(), + key.length(), + expiration)); + } + + /** + * Delete an object from the server specified by the key given. + * + * @param[in] master_key specifies server to remove object from + * @param[in] key key of object to delete + * @return true on success; false otherwise + */ + bool removeByKey(const std::string& master_key, + const std::string& key) + { + return memcached_success(memcached_delete_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + 0)); + } + + /** + * Delete an object from the server specified by the key given. + * + * @param[in] master_key specifies server to remove object from + * @param[in] key key of object to delete + * @param[in] expiration time to delete the object after + * @return true on success; false otherwise + */ + bool removeByKey(const std::string& master_key, + const std::string& key, + time_t expiration) + { + return memcached_success(memcached_delete_by_key(memc_, + master_key.c_str(), + master_key.length(), + key.c_str(), + key.length(), + expiration)); + } + + /** + * Wipe the contents of memcached servers. + * + * @param[in] expiration time to wait until wiping contents of + * memcached servers + * @return true on success; false otherwise + */ + bool flush(time_t expiration= 0) + { + return memcached_success(memcached_flush(memc_, expiration)); + } + + /** + * Get the library version string. + * @return std::string containing a copy of the library version string. + */ + const std::string libVersion() const + { + const char *ver= memcached_lib_version(); + const std::string version(ver); + return version; + } + + /** + * Retrieve memcached statistics. Populate a std::map with the retrieved + * stats. Each server will map to another std::map of the key:value stats. + * + * @param[out] stats_map a std::map to be populated with the memcached + * stats + * @return true on success; false otherwise + */ + bool getStats(std::map< std::string, std::map >& stats_map) + { + memcached_return_t rc; + memcached_stat_st *stats= memcached_stat(memc_, NULL, &rc); + + if (rc != MEMCACHED_SUCCESS && + rc != MEMCACHED_SOME_ERRORS) + { + return false; + } + + uint32_t server_count= memcached_server_count(memc_); + + /* + * For each memcached server, construct a std::map for its stats and add + * it to the std::map of overall stats. + */ + for (uint32_t x= 0; x < server_count; x++) + { + memcached_server_instance_st instance= memcached_server_instance_by_position(memc_, x); + std::ostringstream strstm; + std::string server_name(memcached_server_name(instance)); + server_name.append(":"); + strstm << memcached_server_port(instance); + server_name.append(strstm.str()); + + std::map server_stats; + char **list= memcached_stat_get_keys(memc_, &stats[x], &rc); + for (char** ptr= list; *ptr; ptr++) + { + char *value= memcached_stat_get_value(memc_, &stats[x], *ptr, &rc); + server_stats[*ptr]= value; + free(value); + } + + stats_map[server_name]= server_stats; + free(list); + } + + memcached_stat_free(memc_, stats); + return true; + } + +private: + memcached_st *memc_; +}; + +} diff --git a/libmemcached-1.2/memcached/vbucket.h b/libmemcached-1.2/memcached/vbucket.h new file mode 100644 index 00000000..e2cc563e --- /dev/null +++ b/libmemcached-1.2/memcached/vbucket.h @@ -0,0 +1,59 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef enum { + vbucket_state_active = 1, /**< Actively servicing a vbucket. */ + vbucket_state_replica, /**< Servicing a vbucket as a replica only. */ + vbucket_state_pending, /**< Pending active. */ + vbucket_state_dead /**< Not in use, pending deletion. */ +} vbucket_state_t; + +#define is_valid_vbucket_state_t(state) \ + (state == vbucket_state_active || \ + state == vbucket_state_replica || \ + state == vbucket_state_pending || \ + state == vbucket_state_dead) + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/options.h b/libmemcached-1.2/options.h new file mode 100644 index 00000000..f5a6e06d --- /dev/null +++ b/libmemcached-1.2/options.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/parse.h b/libmemcached-1.2/parse.h new file mode 100644 index 00000000..a91f769d --- /dev/null +++ b/libmemcached-1.2/parse.h @@ -0,0 +1,23 @@ +/* LibMemcached + * Copyright (C) 2010 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: Work with fetching results + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_server_list_st memcached_servers_parse(const char *server_strings); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/platform.h b/libmemcached-1.2/platform.h new file mode 100644 index 00000000..763febaa --- /dev/null +++ b/libmemcached-1.2/platform.h @@ -0,0 +1,56 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef WIN32 + +#include +#include +typedef short in_port_t; +typedef SOCKET memcached_socket_t; +#else +typedef int memcached_socket_t; +#include +#include +#include +#include +#include +#include + +#endif /* WIN32 */ diff --git a/libmemcached-1.2/quit.h b/libmemcached-1.2/quit.h new file mode 100644 index 00000000..90ff3ff0 --- /dev/null +++ b/libmemcached-1.2/quit.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +void memcached_quit(memcached_st *ptr); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/result.h b/libmemcached-1.2/result.h new file mode 100644 index 00000000..a1943507 --- /dev/null +++ b/libmemcached-1.2/result.h @@ -0,0 +1,89 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/* Result Struct */ +LIBMEMCACHED_API +void memcached_result_free(memcached_result_st *result); + +LIBMEMCACHED_API +void memcached_result_reset(memcached_result_st *ptr); + +LIBMEMCACHED_API +memcached_result_st *memcached_result_create(const memcached_st *ptr, + memcached_result_st *result); + +LIBMEMCACHED_API +const char *memcached_result_key_value(const memcached_result_st *self); + +LIBMEMCACHED_API +size_t memcached_result_key_length(const memcached_result_st *self); + +LIBMEMCACHED_API +const char *memcached_result_value(const memcached_result_st *self); + +LIBMEMCACHED_API +char *memcached_result_take_value(memcached_result_st *self); + +LIBMEMCACHED_API +size_t memcached_result_length(const memcached_result_st *self); + +LIBMEMCACHED_API +uint32_t memcached_result_flags(const memcached_result_st *self); + +LIBMEMCACHED_API +uint64_t memcached_result_cas(const memcached_result_st *self); + +LIBMEMCACHED_API +memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length); + +LIBMEMCACHED_API +void memcached_result_set_flags(memcached_result_st *self, uint32_t flags); + +LIBMEMCACHED_API +void memcached_result_set_expiration(memcached_result_st *self, time_t expiration); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/return.h b/libmemcached-1.2/return.h new file mode 100644 index 00000000..65dc63af --- /dev/null +++ b/libmemcached-1.2/return.h @@ -0,0 +1,81 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +static inline bool memcached_success(memcached_return_t rc) +{ + return (rc == MEMCACHED_BUFFERED || + rc == MEMCACHED_DELETED || + rc == MEMCACHED_END || + rc == MEMCACHED_ITEM || + rc == MEMCACHED_STAT || + rc == MEMCACHED_STORED || + rc == MEMCACHED_SUCCESS || + rc == MEMCACHED_VALUE); +} + +static inline bool memcached_failed(memcached_return_t rc) +{ + return (rc != MEMCACHED_SUCCESS && + rc != MEMCACHED_END && + rc != MEMCACHED_STORED && + rc != MEMCACHED_STAT && + rc != MEMCACHED_DELETED && + rc != MEMCACHED_BUFFERED && + rc != MEMCACHED_VALUE); +} + +static inline bool memcached_fatal(memcached_return_t rc) +{ + return ( + rc != MEMCACHED_BUFFERED && + rc != MEMCACHED_DATA_EXISTS && + rc != MEMCACHED_DELETED && + rc != MEMCACHED_E2BIG && + rc != MEMCACHED_END && + rc != MEMCACHED_ITEM && + rc != MEMCACHED_ERROR && + rc != MEMCACHED_NOTFOUND && + rc != MEMCACHED_NOTSTORED && + rc != MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE && + rc != MEMCACHED_STAT && + rc != MEMCACHED_STORED && + rc != MEMCACHED_SUCCESS && + rc != MEMCACHED_VALUE); +} + +#define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS) diff --git a/libmemcached-1.2/sasl.h b/libmemcached-1.2/sasl.h new file mode 100644 index 00000000..c85c9f64 --- /dev/null +++ b/libmemcached-1.2/sasl.h @@ -0,0 +1,70 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT +#include +#else +#define sasl_callback_t void +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +void memcached_set_sasl_callbacks(memcached_st *ptr, + const sasl_callback_t *callbacks); + +LIBMEMCACHED_API +memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, + const char *username, + const char *password); + +LIBMEMCACHED_API +memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr); + + +LIBMEMCACHED_API +sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr); + +#ifdef __cplusplus +} +#endif + +#include diff --git a/libmemcached-1.2/server.h b/libmemcached-1.2/server.h new file mode 100644 index 00000000..aad0c3ee --- /dev/null +++ b/libmemcached-1.2/server.h @@ -0,0 +1,123 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_server_cursor(const memcached_st *ptr, + const memcached_server_fn *callback, + void *context, + uint32_t number_of_callbacks); + +LIBMEMCACHED_API + memcached_server_instance_st memcached_server_by_key(memcached_st *ptr, + const char *key, + size_t key_length, + memcached_return_t *error); + +LIBMEMCACHED_API +void memcached_server_error_reset(memcached_server_st *ptr); + +LIBMEMCACHED_API +void memcached_server_free(memcached_server_st *ptr); + +LIBMEMCACHED_API +memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr); + + +LIBMEMCACHED_API +memcached_return_t memcached_server_add_udp(memcached_st *ptr, + const char *hostname, + in_port_t port); +LIBMEMCACHED_API +memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, + const char *filename); +LIBMEMCACHED_API +memcached_return_t memcached_server_add(memcached_st *ptr, + const char *hostname, in_port_t port); + +LIBMEMCACHED_API +memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, + const char *hostname, + in_port_t port, + uint32_t weight); +LIBMEMCACHED_API +memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, + const char *filename, + uint32_t weight); +LIBMEMCACHED_API +memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, + in_port_t port, + uint32_t weight); + +/** + Operations on Single Servers. +*/ +LIBMEMCACHED_API +uint32_t memcached_server_response_count(const memcached_server_instance_st self); + +LIBMEMCACHED_API +const char *memcached_server_name(const memcached_server_instance_st self); + +LIBMEMCACHED_API +in_port_t memcached_server_port(const memcached_server_instance_st self); + +LIBMEMCACHED_API +void memcached_instance_next_retry(memcached_server_instance_st self, const time_t absolute_time); + +LIBMEMCACHED_API +const char *memcached_server_type(const memcached_server_instance_st ptr); + +LIBMEMCACHED_API +uint8_t memcached_server_major_version(const memcached_server_instance_st ptr); + +LIBMEMCACHED_API +uint8_t memcached_server_minor_version(const memcached_server_instance_st ptr); + +LIBMEMCACHED_API +uint8_t memcached_server_micro_version(const memcached_server_instance_st ptr); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/server_list.h b/libmemcached-1.2/server_list.h new file mode 100644 index 00000000..04bebab4 --- /dev/null +++ b/libmemcached-1.2/server_list.h @@ -0,0 +1,68 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Server List Public functions */ +LIBMEMCACHED_API + void memcached_server_list_free(memcached_server_list_st ptr); + +LIBMEMCACHED_API + memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list); + +LIBMEMCACHED_API + memcached_server_list_st memcached_server_list_append(memcached_server_list_st ptr, + const char *hostname, + in_port_t port, + memcached_return_t *error); +LIBMEMCACHED_API + memcached_server_list_st memcached_server_list_append_with_weight(memcached_server_list_st ptr, + const char *hostname, + in_port_t port, + uint32_t weight, + memcached_return_t *error); +LIBMEMCACHED_API + uint32_t memcached_server_list_count(const memcached_server_list_st ptr); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/stats.h b/libmemcached-1.2/stats.h new file mode 100644 index 00000000..37d34814 --- /dev/null +++ b/libmemcached-1.2/stats.h @@ -0,0 +1,69 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +void memcached_stat_free(const memcached_st *, memcached_stat_st *); + +LIBMEMCACHED_API +memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error); + +LIBMEMCACHED_API +memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, + const char *hostname, in_port_t port); + +LIBMEMCACHED_API +char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_stat, + const char *key, memcached_return_t *error); + +LIBMEMCACHED_API +char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat, + memcached_return_t *error); + +LIBMEMCACHED_API +memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcached-1.2/storage.h b/libmemcached-1.2/storage.h new file mode 100644 index 00000000..e634235a --- /dev/null +++ b/libmemcached-1.2/storage.h @@ -0,0 +1,131 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/* All of the functions for adding data to the server */ +LIBMEMCACHED_API +memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); +LIBMEMCACHED_API +memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); +LIBMEMCACHED_API +memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); +LIBMEMCACHED_API +memcached_return_t memcached_append(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); +LIBMEMCACHED_API +memcached_return_t memcached_prepend(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); +LIBMEMCACHED_API +memcached_return_t memcached_cas(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas); + +LIBMEMCACHED_API +memcached_return_t memcached_set_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); + +LIBMEMCACHED_API +memcached_return_t memcached_add_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); + +LIBMEMCACHED_API +memcached_return_t memcached_replace_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); + +LIBMEMCACHED_API +memcached_return_t memcached_prepend_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); + +LIBMEMCACHED_API +memcached_return_t memcached_append_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); + +LIBMEMCACHED_API +memcached_return_t memcached_cas_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/strerror.h b/libmemcached-1.2/strerror.h new file mode 100644 index 00000000..16bf424a --- /dev/null +++ b/libmemcached-1.2/strerror.h @@ -0,0 +1,50 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +const char *memcached_strerror(const memcached_st *ptr, memcached_return_t rc); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/struct/allocator.h b/libmemcached-1.2/struct/allocator.h new file mode 100644 index 00000000..3ff6ade8 --- /dev/null +++ b/libmemcached-1.2/struct/allocator.h @@ -0,0 +1,46 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_allocator_t { + memcached_calloc_fn calloc; + memcached_free_fn free; + memcached_malloc_fn malloc; + memcached_realloc_fn realloc; + void *context; +}; diff --git a/libmemcached-1.2/struct/analysis.h b/libmemcached-1.2/struct/analysis.h new file mode 100644 index 00000000..09cccedc --- /dev/null +++ b/libmemcached-1.2/struct/analysis.h @@ -0,0 +1,51 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_analysis_st { + memcached_st *root; + uint32_t average_item_size; + uint32_t longest_uptime; + uint32_t least_free_server; + uint32_t most_consumed_server; + uint32_t oldest_server; + double pool_hit_ratio; + uint64_t most_used_bytes; + uint64_t least_remaining_bytes; +}; + diff --git a/libmemcached-1.2/struct/callback.h b/libmemcached-1.2/struct/callback.h new file mode 100644 index 00000000..21b96765 --- /dev/null +++ b/libmemcached-1.2/struct/callback.h @@ -0,0 +1,44 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_callback_st { + memcached_execute_fn *callback; + void *context; + uint32_t number_of_callback; +}; diff --git a/libmemcached-1.2/struct/include.am b/libmemcached-1.2/struct/include.am new file mode 100644 index 00000000..4a468b6f --- /dev/null +++ b/libmemcached-1.2/struct/include.am @@ -0,0 +1,13 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +nobase_include_HEADERS+= libmemcached-1.2/struct/allocator.h +nobase_include_HEADERS+= libmemcached-1.2/struct/analysis.h +nobase_include_HEADERS+= libmemcached-1.2/struct/callback.h +nobase_include_HEADERS+= libmemcached-1.2/struct/memcached.h +nobase_include_HEADERS+= libmemcached-1.2/struct/result.h +nobase_include_HEADERS+= libmemcached-1.2/struct/sasl.h +nobase_include_HEADERS+= libmemcached-1.2/struct/server.h +nobase_include_HEADERS+= libmemcached-1.2/struct/stat.h +nobase_include_HEADERS+= libmemcached-1.2/struct/string.h diff --git a/libmemcached-1.2/struct/memcached.h b/libmemcached-1.2/struct/memcached.h new file mode 100644 index 00000000..624887b7 --- /dev/null +++ b/libmemcached-1.2/struct/memcached.h @@ -0,0 +1,132 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_st { + /** + @note these are static and should not change without a call to behavior. + */ + struct { + bool is_purging:1; + bool is_processing_input:1; + bool is_time_for_rebuild:1; + bool is_parsing:1; + } state; + + struct { + // Everything below here is pretty static. + bool auto_eject_hosts:1; + bool binary_protocol:1; + bool buffer_requests:1; + bool hash_with_namespace:1; + bool no_block:1; // Don't block + bool reply:1; + bool randomize_replica_read:1; + bool support_cas:1; + bool tcp_nodelay:1; + bool use_sort_hosts:1; + bool use_udp:1; + bool verify_key:1; + bool tcp_keepalive:1; + bool is_aes:1; + bool is_fetching_version:1; + bool not_used:1; + } flags; + + memcached_server_distribution_t distribution; + hashkit_st hashkit; + struct { + unsigned int version; + } server_info; + uint32_t number_of_hosts; +#ifdef __cplusplus + org::libmemcached::Instance* servers; + org::libmemcached::Instance* last_disconnected_server; +#else + void *servers; + void *last_disconnected_server; +#endif + int32_t snd_timeout; + int32_t rcv_timeout; + uint32_t server_failure_limit; + uint32_t io_msg_watermark; + uint32_t io_bytes_watermark; + uint32_t io_key_prefetch; + uint32_t tcp_keepidle; + int32_t poll_timeout; + int32_t connect_timeout; // How long we will wait on connect() before we will timeout + int32_t retry_timeout; + int32_t dead_timeout; + int send_size; + int recv_size; + void *user_data; + uint64_t query_id; + uint32_t number_of_replicas; + memcached_result_st result; + + struct { + bool weighted_; + uint32_t continuum_count; // Ketama + uint32_t continuum_points_counter; // Ketama + time_t next_distribution_rebuild; // Ketama + struct memcached_continuum_item_st *continuum; // Ketama + } ketama; + + struct memcached_virtual_bucket_t *virtual_bucket; + + struct memcached_allocator_t allocators; + + memcached_clone_fn on_clone; + memcached_cleanup_fn on_cleanup; + memcached_trigger_key_fn get_key_failure; + memcached_trigger_delete_key_fn delete_trigger; + memcached_callback_st *callbacks; + struct memcached_sasl_st sasl; + struct memcached_error_t *error_messages; + struct memcached_array_st *_namespace; + struct { + uint32_t initial_pool_size; + uint32_t max_pool_size; + int32_t version; // This is used by pool and others to determine if the memcached_st is out of date. + struct memcached_array_st *filename; + } configure; + struct { + bool is_allocated:1; + } options; + +}; diff --git a/libmemcached-1.2/struct/result.h b/libmemcached-1.2/struct/result.h new file mode 100644 index 00000000..c3bfddb5 --- /dev/null +++ b/libmemcached-1.2/struct/result.h @@ -0,0 +1,56 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_result_st { + uint32_t item_flags; + time_t item_expiration; + size_t key_length; + uint64_t item_cas; + struct memcached_st *root; + memcached_string_st value; + uint64_t numeric_value; + uint64_t count; + char item_key[MEMCACHED_MAX_KEY]; + struct { + bool is_allocated:1; + bool is_initialized:1; + } options; + /* Add result callback function */ +}; + diff --git a/libmemcached-1.2/struct/sasl.h b/libmemcached-1.2/struct/sasl.h new file mode 100644 index 00000000..da9eed38 --- /dev/null +++ b/libmemcached-1.2/struct/sasl.h @@ -0,0 +1,54 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT +#include +#else +#define sasl_callback_t void +#endif + +#pragma once + +struct memcached_sasl_st { + sasl_callback_t *callbacks; + /* + ** Did we allocate data inside the callbacks, or did the user + ** supply that. + */ + bool is_allocated; +}; + diff --git a/libmemcached-1.2/struct/server.h b/libmemcached-1.2/struct/server.h new file mode 100644 index 00000000..a8a30565 --- /dev/null +++ b/libmemcached-1.2/struct/server.h @@ -0,0 +1,98 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifndef WIN32 +#include +#endif + +#ifdef NI_MAXHOST +#define MEMCACHED_NI_MAXHOST NI_MAXHOST +#else +#define MEMCACHED_NI_MAXHOST 1025 +#endif + +#ifdef NI_MAXSERV +#define MEMCACHED_NI_MAXSERV NI_MAXSERV +#else +#define MEMCACHED_NI_MAXSERV 32 +#endif + +enum memcached_server_state_t { + MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done + MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered + MEMCACHED_SERVER_STATE_IN_PROGRESS, + MEMCACHED_SERVER_STATE_CONNECTED, + MEMCACHED_SERVER_STATE_IN_TIMEOUT, + MEMCACHED_SERVER_STATE_DISABLED +}; + +struct memcached_server_st { + struct { + bool is_allocated:1; + bool is_initialized:1; + bool is_shutting_down:1; + bool is_dead:1; + } options; + uint32_t number_of_hosts; + uint32_t cursor_active; + in_port_t port; + uint32_t io_bytes_sent; /* # bytes sent since last read */ + uint32_t request_id; + uint32_t server_failure_counter; + uint64_t server_failure_counter_query_id; + uint32_t weight; + uint32_t version; + enum memcached_server_state_t state; + struct { + uint32_t read; + uint32_t write; + uint32_t timeouts; + size_t _bytes_read; + } io_wait_count; + uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set. + uint8_t micro_version; // ditto, and note that this is the third, not second version bit + uint8_t minor_version; // ditto + memcached_connection_t type; + time_t next_retry; + struct memcached_st *root; + uint64_t limit_maxbytes; + struct memcached_error_t *error_messages; + char hostname[MEMCACHED_NI_MAXHOST]; +}; diff --git a/libmemcached-1.2/struct/stat.h b/libmemcached-1.2/struct/stat.h new file mode 100644 index 00000000..acd4e21f --- /dev/null +++ b/libmemcached-1.2/struct/stat.h @@ -0,0 +1,68 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +struct memcached_stat_st { + unsigned long connection_structures; + unsigned long curr_connections; + unsigned long curr_items; + pid_t pid; + unsigned long pointer_size; + unsigned long rusage_system_microseconds; + unsigned long rusage_system_seconds; + unsigned long rusage_user_microseconds; + unsigned long rusage_user_seconds; + unsigned long threads; + unsigned long time; + unsigned long total_connections; + unsigned long total_items; + unsigned long uptime; + unsigned long long bytes; + unsigned long long bytes_read; + unsigned long long bytes_written; + unsigned long long cmd_get; + unsigned long long cmd_set; + unsigned long long evictions; + unsigned long long get_hits; + unsigned long long get_misses; + unsigned long long limit_maxbytes; + char version[MEMCACHED_VERSION_STRING_LENGTH]; + void *__future; // @todo create a new structure to place here for future usage + memcached_st *root; +}; + diff --git a/libmemcached-1.2/struct/string.h b/libmemcached-1.2/struct/string.h new file mode 100644 index 00000000..9edb637a --- /dev/null +++ b/libmemcached-1.2/struct/string.h @@ -0,0 +1,59 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +/** + Strings are always under our control so we make some assumptions + about them. + + 1) is_initialized is always valid. + 2) A string once intialized will always be, until free where we + unset this flag. + 3) A string always has a root. +*/ + +struct memcached_string_st { + char *end; + char *string; + size_t current_size; + struct memcached_st *root; + struct { + bool is_allocated:1; + bool is_initialized:1; + } options; +}; diff --git a/libmemcached-1.2/t/c_sasl_test.c b/libmemcached-1.2/t/c_sasl_test.c new file mode 100644 index 00000000..413c3cd3 --- /dev/null +++ b/libmemcached-1.2/t/c_sasl_test.c @@ -0,0 +1,61 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached C sasl test app + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * @file @brief C dummy test, aka testing C linking, etc + */ + +#include + +#ifdef HAVE_SASL_SASL_H +#include +#endif + +#include + +int main(void) +{ + memcached_st *memc= memcached_create(NULL); + + if (memc == NULL) + { + return EXIT_FAILURE; + } + memcached_free(memc); + + return EXIT_SUCCESS; +} + diff --git a/libmemcached-1.2/t/c_test.c b/libmemcached-1.2/t/c_test.c new file mode 100644 index 00000000..ac40cac0 --- /dev/null +++ b/libmemcached-1.2/t/c_test.c @@ -0,0 +1,61 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached C test app + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * @file @brief C dummy test, aka testing C linking, etc + */ + +#include + +#include + +int main(void) +{ + (void)memcached_success(MEMCACHED_SUCCESS); + (void)memcached_failed(MEMCACHED_SUCCESS); + (void)memcached_continue(MEMCACHED_SUCCESS); + + memcached_st *memc= memcached_create(NULL); + + if (memc == NULL) + { + return EXIT_FAILURE; + } + memcached_free(memc); + + return EXIT_SUCCESS; +} + diff --git a/libmemcached-1.2/t/cc_test.cc b/libmemcached-1.2/t/cc_test.cc new file mode 100644 index 00000000..87210d27 --- /dev/null +++ b/libmemcached-1.2/t/cc_test.cc @@ -0,0 +1,62 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached C++ test app + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * @file @brief C dummy test, aka testing C linking, etc + */ + +#include + +#include + +int main(void) +{ + (void)memcached_success(MEMCACHED_SUCCESS); + (void)memcached_failed(MEMCACHED_SUCCESS); + (void)memcached_continue(MEMCACHED_SUCCESS); + + memcached_st *memc= memcached_create(NULL); + + if (memc == NULL) + { + return EXIT_FAILURE; + } + + memcached_free(memc); + + return EXIT_SUCCESS; +} + diff --git a/libmemcached-1.2/t/include.am b/libmemcached-1.2/t/include.am new file mode 100644 index 00000000..544d9a46 --- /dev/null +++ b/libmemcached-1.2/t/include.am @@ -0,0 +1,30 @@ +# vim:ft=automake +# Copyright (C) 2011 Data Differential +# All rights reserved. +# +# Use and distribution licensed under the BSD license. See +# the COPYING file in the parent directory for full text. +# +# included from Top Level Makefile.am +# All paths should be given relative to the root + +# Test linking with C application +libmemcached_1_2_t_c_test_SOURCES= libmemcached-1.2/t/c_test.c +libmemcached_1_2_t_c_test_LDADD= libmemcached/libmemcached.la +libmemcached_1_2_t_c_test_DEPENDENCIES= libmemcached/libmemcached.la +check_PROGRAMS+= libmemcached-1.2/t/c_test +noinst_PROGRAMS+= libmemcached-1.2/t/c_test + +# Test linking with C++ application +libmemcached_1_2_t_cc_test_SOURCES= libmemcached-1.2/t/cc_test.cc +libmemcached_1_2_t_cc_test_LDADD= libmemcached/libmemcached.la +libmemcached_1_2_t_cc_test_DEPENDENCIES= libmemcached/libmemcached.la +check_PROGRAMS+= libmemcached-1.2/t/cc_test +noinst_PROGRAMS+= libmemcached-1.2/t/cc_test + +# Test linking with C application/SASL include +libmemcached_1_2_t_c_sasl_test_SOURCES= libmemcached-1.2/t/c_sasl_test.c +libmemcached_1_2_t_c_sasl_test_LDADD= libmemcached/libmemcached.la +libmemcached_1_2_t_c_sasl_test_DEPENDENCIES= libmemcached/libmemcached.la +check_PROGRAMS+= libmemcached-1.2/t/c_sasl_test +noinst_PROGRAMS+= libmemcached-1.2/t/c_sasl_test diff --git a/libmemcached-1.2/touch.h b/libmemcached-1.2/touch.h new file mode 100644 index 00000000..e143c037 --- /dev/null +++ b/libmemcached-1.2/touch.h @@ -0,0 +1,59 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + + +LIBMEMCACHED_API +memcached_return_t memcached_touch(memcached_st *ptr, + const char *key, size_t key_length, + time_t expiration); + +LIBMEMCACHED_API +memcached_return_t memcached_touch_by_key(memcached_st *ptr, + const char *group_key, size_t group_key_length, + const char *key, size_t key_length, + time_t expiration); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/triggers.h b/libmemcached-1.2/triggers.h new file mode 100644 index 00000000..b331429e --- /dev/null +++ b/libmemcached-1.2/triggers.h @@ -0,0 +1,64 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef memcached_return_t (*memcached_clone_fn)(memcached_st *destination, const memcached_st *source); +typedef memcached_return_t (*memcached_cleanup_fn)(const memcached_st *ptr); + +/** + Trigger functions. +*/ +typedef memcached_return_t (*memcached_trigger_key_fn)(const memcached_st *ptr, + const char *key, size_t key_length, + memcached_result_st *result); +typedef memcached_return_t (*memcached_trigger_delete_key_fn)(const memcached_st *ptr, + const char *key, size_t key_length); + +typedef memcached_return_t (*memcached_dump_fn)(const memcached_st *ptr, + const char *key, + size_t key_length, + void *context); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/types.h b/libmemcached-1.2/types.h new file mode 100644 index 00000000..53992d3a --- /dev/null +++ b/libmemcached-1.2/types.h @@ -0,0 +1,85 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +#ifdef __cplusplus + +namespace org { namespace libmemcached { struct Instance; } } + +struct memcached_st; +struct memcached_stat_st; +struct memcached_analysis_st; +struct memcached_result_st; +struct memcached_array_st; +struct memcached_error_t; + +// All of the flavors of memcache_server_st +struct memcached_server_st; +struct memcached_instance_st; +typedef const org::libmemcached::Instance* memcached_server_instance_st; +typedef struct memcached_server_st *memcached_server_list_st; + +struct memcached_callback_st; + +// The following two structures are internal, and never exposed to users. +struct memcached_string_st; +struct memcached_string_t; +struct memcached_continuum_item_st; + +#else + +typedef struct memcached_st memcached_st; +typedef struct memcached_stat_st memcached_stat_st; +typedef struct memcached_analysis_st memcached_analysis_st; +typedef struct memcached_result_st memcached_result_st; +typedef struct memcached_array_st memcached_array_st; +typedef struct memcached_error_t memcached_error_t; + +// All of the flavors of memcache_server_st +typedef struct memcached_server_st memcached_server_st; +typedef const void *memcached_server_instance_st; +typedef struct memcached_server_st *memcached_server_list_st; + +typedef struct memcached_callback_st memcached_callback_st; + +// The following two structures are internal, and never exposed to users. +typedef struct memcached_string_st memcached_string_st; +typedef struct memcached_string_t memcached_string_t; + +#endif diff --git a/libmemcached-1.2/types/behavior.h b/libmemcached-1.2/types/behavior.h new file mode 100644 index 00000000..d0af189a --- /dev/null +++ b/libmemcached-1.2/types/behavior.h @@ -0,0 +1,84 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +enum memcached_behavior_t { + 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_KETAMA_WEIGHTED, + MEMCACHED_BEHAVIOR_KETAMA_HASH, + MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, + MEMCACHED_BEHAVIOR_SND_TIMEOUT, + MEMCACHED_BEHAVIOR_RCV_TIMEOUT, + MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, + MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, + MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, + MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, + MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, + MEMCACHED_BEHAVIOR_NOREPLY, + MEMCACHED_BEHAVIOR_USE_UDP, + MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, + MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, + MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, + MEMCACHED_BEHAVIOR_CORK, + MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, + MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, + MEMCACHED_BEHAVIOR_LOAD_FROM_FILE, + MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, + MEMCACHED_BEHAVIOR_DEAD_TIMEOUT, + MEMCACHED_BEHAVIOR_MAX +}; + +#ifndef __cplusplus +typedef enum memcached_behavior_t memcached_behavior_t; +#endif diff --git a/libmemcached-1.2/types/callback.h b/libmemcached-1.2/types/callback.h new file mode 100644 index 00000000..d5481f50 --- /dev/null +++ b/libmemcached-1.2/types/callback.h @@ -0,0 +1,54 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +enum memcached_callback_t { + MEMCACHED_CALLBACK_PREFIX_KEY = 0, + MEMCACHED_CALLBACK_USER_DATA = 1, + MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, + MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, + MEMCACHED_CALLBACK_GET_FAILURE = 7, + MEMCACHED_CALLBACK_DELETE_TRIGGER = 8, + MEMCACHED_CALLBACK_MAX, + MEMCACHED_CALLBACK_NAMESPACE= MEMCACHED_CALLBACK_PREFIX_KEY +}; + +#ifndef __cplusplus +typedef enum memcached_callback_t memcached_callback_t; +#endif diff --git a/libmemcached-1.2/types/connection.h b/libmemcached-1.2/types/connection.h new file mode 100644 index 00000000..d2a072b7 --- /dev/null +++ b/libmemcached-1.2/types/connection.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +enum memcached_connection_t { + MEMCACHED_CONNECTION_TCP, + MEMCACHED_CONNECTION_UDP, + MEMCACHED_CONNECTION_UNIX_SOCKET +}; + +#ifndef __cplusplus +typedef enum memcached_connection_t memcached_connection_t; +#endif diff --git a/libmemcached-1.2/types/hash.h b/libmemcached-1.2/types/hash.h new file mode 100644 index 00000000..7651eb1a --- /dev/null +++ b/libmemcached-1.2/types/hash.h @@ -0,0 +1,58 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +enum memcached_hash_t { + 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_HSIEH, + MEMCACHED_HASH_MURMUR, + MEMCACHED_HASH_JENKINS, + MEMCACHED_HASH_CUSTOM, + MEMCACHED_HASH_MAX +}; + +#ifndef __cplusplus +typedef enum memcached_hash_t memcached_hash_t; +#endif diff --git a/libmemcached-1.2/types/include.am b/libmemcached-1.2/types/include.am new file mode 100644 index 00000000..a968c05f --- /dev/null +++ b/libmemcached-1.2/types/include.am @@ -0,0 +1,8 @@ +# vim:ft=automake + +nobase_include_HEADERS+= libmemcached-1.2/types/behavior.h +nobase_include_HEADERS+= libmemcached-1.2/types/callback.h +nobase_include_HEADERS+= libmemcached-1.2/types/connection.h +nobase_include_HEADERS+= libmemcached-1.2/types/hash.h +nobase_include_HEADERS+= libmemcached-1.2/types/return.h +nobase_include_HEADERS+= libmemcached-1.2/types/server_distribution.h diff --git a/libmemcached-1.2/types/return.h b/libmemcached-1.2/types/return.h new file mode 100644 index 00000000..f4ec9b08 --- /dev/null +++ b/libmemcached-1.2/types/return.h @@ -0,0 +1,95 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +enum memcached_return_t { + MEMCACHED_SUCCESS, + MEMCACHED_FAILURE, + MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only + MEMCACHED_CONNECTION_FAILURE, + MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE + MEMCACHED_WRITE_FAILURE, + MEMCACHED_READ_FAILURE, + MEMCACHED_UNKNOWN_READ_FAILURE, + MEMCACHED_PROTOCOL_ERROR, + MEMCACHED_CLIENT_ERROR, + MEMCACHED_SERVER_ERROR, // Server returns "SERVER_ERROR" + MEMCACHED_ERROR, // Server returns "ERROR" + 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_ITEM, + MEMCACHED_ERRNO, + MEMCACHED_FAIL_UNIX_SOCKET, // DEPRECATED + MEMCACHED_NOT_SUPPORTED, + MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */ + MEMCACHED_FETCH_NOTFINISHED, + MEMCACHED_TIMEOUT, + MEMCACHED_BUFFERED, + MEMCACHED_BAD_KEY_PROVIDED, + MEMCACHED_INVALID_HOST_PROTOCOL, + MEMCACHED_SERVER_MARKED_DEAD, + MEMCACHED_UNKNOWN_STAT_KEY, + MEMCACHED_E2BIG, + MEMCACHED_INVALID_ARGUMENTS, + MEMCACHED_KEY_TOO_BIG, + MEMCACHED_AUTH_PROBLEM, + MEMCACHED_AUTH_FAILURE, + MEMCACHED_AUTH_CONTINUE, + MEMCACHED_PARSE_ERROR, + MEMCACHED_PARSE_USER_ERROR, + MEMCACHED_DEPRECATED, + MEMCACHED_IN_PROGRESS, + MEMCACHED_SERVER_TEMPORARILY_DISABLED, + MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE, + MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ + MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE= MEMCACHED_ERROR +}; + +#ifndef __cplusplus +typedef enum memcached_return_t memcached_return_t; +#endif diff --git a/libmemcached-1.2/types/server_distribution.h b/libmemcached-1.2/types/server_distribution.h new file mode 100644 index 00000000..95e129f6 --- /dev/null +++ b/libmemcached-1.2/types/server_distribution.h @@ -0,0 +1,54 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#pragma once + +enum memcached_server_distribution_t { + MEMCACHED_DISTRIBUTION_MODULA, + MEMCACHED_DISTRIBUTION_CONSISTENT, + MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, + MEMCACHED_DISTRIBUTION_RANDOM, + MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, + MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED, + MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET, + MEMCACHED_DISTRIBUTION_CONSISTENT_MAX +}; + +#ifndef __cplusplus +typedef enum memcached_server_distribution_t memcached_server_distribution_t; +#endif diff --git a/libmemcached-1.2/verbosity.h b/libmemcached-1.2/verbosity.h new file mode 100644 index 00000000..29946486 --- /dev/null +++ b/libmemcached-1.2/verbosity.h @@ -0,0 +1,50 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity); + + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/version.h b/libmemcached-1.2/version.h new file mode 100644 index 00000000..c443accb --- /dev/null +++ b/libmemcached-1.2/version.h @@ -0,0 +1,52 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +memcached_return_t memcached_version(memcached_st *ptr); + +LIBMEMCACHED_API +const char * memcached_lib_version(void); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached-1.2/visibility.h b/libmemcached-1.2/visibility.h new file mode 100644 index 00000000..d4e4eea0 --- /dev/null +++ b/libmemcached-1.2/visibility.h @@ -0,0 +1,67 @@ +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: Interface for memcached server. + * + * Author: Trond Norbye + * + */ + +/** + * @file + * @brief Visibility control macros + */ + +#pragma once + +/** + * + * LIBMEMCACHED_API is used for the public API symbols. It either DLL imports or + * DLL exports (or does nothing for static build). + * + * LIBMEMCACHED_LOCAL is used for non-api symbols. + */ + +#if defined(BUILDING_LIBMEMCACHEDINTERNAL) +# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY +# define LIBMEMCACHED_API __attribute__ ((visibility("default"))) +# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("default"))) +# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) +# define LIBMEMCACHED_API __global +# define LIBMEMCACHED_LOCAL __global +# elif defined(_MSC_VER) +# define LIBMEMCACHED_API extern __declspec(dllexport) +# define LIBMEMCACHED_LOCAL extern __declspec(dllexport) +# else +# define LIBMEMCACHED_API +# define LIBMEMCACHED_LOCAL +# endif +#else +# if defined(BUILDING_LIBMEMCACHED) +# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY +# define LIBMEMCACHED_API __attribute__ ((visibility("default"))) +# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden"))) +# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) +# define LIBMEMCACHED_API __global +# define LIBMEMCACHED_LOCAL __hidden +# elif defined(_MSC_VER) +# define LIBMEMCACHED_API extern __declspec(dllexport) +# define LIBMEMCACHED_LOCAL +# else +# define LIBMEMCACHED_API +# define LIBMEMCACHED_LOCAL +# endif /* defined(HAVE_VISIBILITY) */ +# else /* defined(BUILDING_LIBMEMCACHED) */ +# if defined(_MSC_VER) +# define LIBMEMCACHED_API extern __declspec(dllimport) +# define LIBMEMCACHED_LOCAL +# else +# define LIBMEMCACHED_API +# define LIBMEMCACHED_LOCAL +# endif /* defined(_MSC_VER) */ +# endif /* defined(BUILDING_LIBMEMCACHED) */ +#endif /* defined(BUILDING_LIBMEMCACHEDINTERNAL) */ diff --git a/libmemcached/common.h b/libmemcached/common.h index 5c86eb16..935bd12c 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -89,7 +89,7 @@ # include #endif -#include +#include #include #include diff --git a/libmemcached/include.am b/libmemcached/include.am index 13304e62..9534799a 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -9,10 +9,6 @@ include libmemcached/csl/include.am EXTRA_DIST+= libmemcached/libmemcached_probes.d EXTRA_DIST+= libmemcached/memcached/README.txt -nobase_include_HEADERS+= libmemcached/memcached.h -nobase_include_HEADERS+= libmemcached/memcached.hpp -nobase_include_HEADERS+= libmemcached/util.h - noinst_HEADERS+= libmemcached/array.h noinst_HEADERS+= libmemcached/assert.hpp noinst_HEADERS+= libmemcached/backtrace.hpp diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h deleted file mode 100644 index a45077ee..00000000 --- a/libmemcached/memcached.h +++ /dev/null @@ -1,39 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp deleted file mode 100644 index d38e6d24..00000000 --- a/libmemcached/memcached.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include - diff --git a/libmemcached/memcached/protocol_binary.h b/libmemcached/memcached/protocol_binary.h index 51e2c422..ff9d6373 100644 --- a/libmemcached/memcached/protocol_binary.h +++ b/libmemcached/memcached/protocol_binary.h @@ -36,7 +36,7 @@ #ifndef PROTOCOL_BINARY_H #define PROTOCOL_BINARY_H -#include +#include /** * \addtogroup Protocol diff --git a/libmemcached/memory.h b/libmemcached/memory.h index 06cc9985..804bde30 100644 --- a/libmemcached/memory.h +++ b/libmemcached/memory.h @@ -38,7 +38,7 @@ #include -#include +#include #ifdef __cplusplus #include diff --git a/libmemcached/util.h b/libmemcached/util.h deleted file mode 100644 index 03ed6da5..00000000 --- a/libmemcached/util.h +++ /dev/null @@ -1,40 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include - diff --git a/libmemcachedprotocol-0.0/binary.h b/libmemcachedprotocol-0.0/binary.h deleted file mode 100644 index 51e2c422..00000000 --- a/libmemcachedprotocol-0.0/binary.h +++ /dev/null @@ -1,728 +0,0 @@ -/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - * Copyright (c) <2008>, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Summary: Constants used by to implement the binary protocol. - * - * Copy: See Copyright for the status of this software. - * - * Author: Trond Norbye - */ - -#ifndef PROTOCOL_BINARY_H -#define PROTOCOL_BINARY_H - -#include - -/** - * \addtogroup Protocol - * @{ - */ - -/** - * This file contains definitions of the constants and packet formats - * defined in the binary specification. Please note that you _MUST_ remember - * to convert each multibyte field to / from network byte order to / from - * host order. - */ -#ifdef __cplusplus -extern "C" -{ -#endif - - /** - * Definition of the legal "magic" values used in a packet. - * See section 3.1 Magic byte - */ - typedef enum { - PROTOCOL_BINARY_REQ = 0x80, - PROTOCOL_BINARY_RES = 0x81 - } protocol_binary_magic; - - /** - * Definition of the valid response status numbers. - * See section 3.2 Response Status - */ - typedef enum { - PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, - PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, - PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, - PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, - PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, - PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, - PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, - PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET = 0x07, - PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, - PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, - PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, - PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82, - PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED = 0x83, - PROTOCOL_BINARY_RESPONSE_EINTERNAL = 0x84, - PROTOCOL_BINARY_RESPONSE_EBUSY = 0x85, - PROTOCOL_BINARY_RESPONSE_ETMPFAIL = 0x86 - } protocol_binary_response_status; - - /** - * Defintion of the different command opcodes. - * See section 3.3 Command Opcodes - */ - typedef enum { - PROTOCOL_BINARY_CMD_GET = 0x00, - PROTOCOL_BINARY_CMD_SET = 0x01, - PROTOCOL_BINARY_CMD_ADD = 0x02, - PROTOCOL_BINARY_CMD_REPLACE = 0x03, - PROTOCOL_BINARY_CMD_DELETE = 0x04, - PROTOCOL_BINARY_CMD_INCREMENT = 0x05, - PROTOCOL_BINARY_CMD_DECREMENT = 0x06, - PROTOCOL_BINARY_CMD_QUIT = 0x07, - PROTOCOL_BINARY_CMD_FLUSH = 0x08, - PROTOCOL_BINARY_CMD_GETQ = 0x09, - PROTOCOL_BINARY_CMD_NOOP = 0x0a, - PROTOCOL_BINARY_CMD_VERSION = 0x0b, - PROTOCOL_BINARY_CMD_GETK = 0x0c, - PROTOCOL_BINARY_CMD_GETKQ = 0x0d, - PROTOCOL_BINARY_CMD_APPEND = 0x0e, - PROTOCOL_BINARY_CMD_PREPEND = 0x0f, - PROTOCOL_BINARY_CMD_STAT = 0x10, - PROTOCOL_BINARY_CMD_SETQ = 0x11, - PROTOCOL_BINARY_CMD_ADDQ = 0x12, - PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, - PROTOCOL_BINARY_CMD_DELETEQ = 0x14, - PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, - PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, - PROTOCOL_BINARY_CMD_QUITQ = 0x17, - PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, - PROTOCOL_BINARY_CMD_APPENDQ = 0x19, - PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, - PROTOCOL_BINARY_CMD_VERBOSITY = 0x1b, - PROTOCOL_BINARY_CMD_TOUCH = 0x1c, - PROTOCOL_BINARY_CMD_GAT = 0x1d, - PROTOCOL_BINARY_CMD_GATQ = 0x1e, - PROTOCOL_BINARY_CMD_GATK = 0x23, - PROTOCOL_BINARY_CMD_GATKQ = 0x24, - - PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, - PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, - PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, - - /* These commands are used for range operations and exist within - * this header for use in other projects. Range operations are - * not expected to be implemented in the memcached server itself. - */ - PROTOCOL_BINARY_CMD_RGET = 0x30, - PROTOCOL_BINARY_CMD_RSET = 0x31, - PROTOCOL_BINARY_CMD_RSETQ = 0x32, - PROTOCOL_BINARY_CMD_RAPPEND = 0x33, - PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, - PROTOCOL_BINARY_CMD_RPREPEND = 0x35, - PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, - PROTOCOL_BINARY_CMD_RDELETE = 0x37, - PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, - PROTOCOL_BINARY_CMD_RINCR = 0x39, - PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, - PROTOCOL_BINARY_CMD_RDECR = 0x3b, - PROTOCOL_BINARY_CMD_RDECRQ = 0x3c, - /* End Range operations */ - - /* VBucket commands */ - PROTOCOL_BINARY_CMD_SET_VBUCKET = 0x3d, - PROTOCOL_BINARY_CMD_GET_VBUCKET = 0x3e, - PROTOCOL_BINARY_CMD_DEL_VBUCKET = 0x3f, - /* End VBucket commands */ - - /* TAP commands */ - PROTOCOL_BINARY_CMD_TAP_CONNECT = 0x40, - PROTOCOL_BINARY_CMD_TAP_MUTATION = 0x41, - PROTOCOL_BINARY_CMD_TAP_DELETE = 0x42, - PROTOCOL_BINARY_CMD_TAP_FLUSH = 0x43, - PROTOCOL_BINARY_CMD_TAP_OPAQUE = 0x44, - PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET = 0x45, - PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START = 0x46, - PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END = 0x47, - /* End TAP */ - - PROTOCOL_BINARY_CMD_LAST_RESERVED = 0xef, - - /* Scrub the data */ - PROTOCOL_BINARY_CMD_SCRUB = 0xf0 - } protocol_binary_command; - - /** - * Definition of the data types in the packet - * See section 3.4 Data Types - */ - typedef enum { - PROTOCOL_BINARY_RAW_BYTES = 0x00 - } protocol_binary_datatypes; - - /** - * Definition of the header structure for a request packet. - * See section 2 - */ - typedef union { - struct { - uint8_t magic; - uint8_t opcode; - uint16_t keylen; - uint8_t extlen; - uint8_t datatype; - uint16_t vbucket; - uint32_t bodylen; - uint32_t opaque; - uint64_t cas; - } request; - uint8_t bytes[24]; - } protocol_binary_request_header; - - /** - * Definition of the header structure for a response packet. - * See section 2 - */ - typedef union { - struct { - uint8_t magic; - uint8_t opcode; - uint16_t keylen; - uint8_t extlen; - uint8_t datatype; - uint16_t status; - uint32_t bodylen; - uint32_t opaque; - uint64_t cas; - } response; - uint8_t bytes[24]; - } protocol_binary_response_header; - - /** - * Definition of a request-packet containing no extras - */ - union protocol_binary_request_no_extras { - struct { - protocol_binary_request_header header; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header)]; - }; - typedef union protocol_binary_request_no_extras protocol_binary_request_no_extras; - - /** - * Definition of a response-packet containing no extras - */ - typedef union { - struct { - protocol_binary_response_header header; - } message; - uint8_t bytes[sizeof(protocol_binary_response_header)]; - } protocol_binary_response_no_extras; - - /** - * Definition of the packet used by the get, getq, getk and getkq command. - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_get; - typedef protocol_binary_request_no_extras protocol_binary_request_getq; - typedef protocol_binary_request_no_extras protocol_binary_request_getk; - typedef protocol_binary_request_no_extras protocol_binary_request_getkq; - - /** - * Definition of the packet returned from a successful get, getq, getk and - * getkq. - * See section 4 - */ - typedef union { - struct { - protocol_binary_response_header header; - struct { - uint32_t flags; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; - } protocol_binary_response_get; - - typedef protocol_binary_response_get protocol_binary_response_getq; - typedef protocol_binary_response_get protocol_binary_response_getk; - typedef protocol_binary_response_get protocol_binary_response_getkq; - - /** - * Definition of the packet used by the delete command - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_delete; - - /** - * Definition of the packet returned by the delete command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_delete; - - /** - * Definition of the packet used by the flush command - * See section 4 - * Please note that the expiration field is optional, so remember to see - * check the header.bodysize to see if it is present. - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint32_t expiration; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_flush; - - /** - * Definition of the packet returned by the flush command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_flush; - - /** - * Definition of the packet used by set, add and replace - * See section 4 - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint32_t flags; - uint32_t expiration; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; - } protocol_binary_request_set; - typedef protocol_binary_request_set protocol_binary_request_add; - typedef protocol_binary_request_set protocol_binary_request_replace; - - /** - * Definition of the packet returned by set, add and replace - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_set; - typedef protocol_binary_response_no_extras protocol_binary_response_add; - typedef protocol_binary_response_no_extras protocol_binary_response_replace; - - /** - * Definition of the noop packet - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_noop; - - /** - * Definition of the packet returned by the noop command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_noop; - - /** - * Definition of the structure used by the increment and decrement - * command. - * See section 4 - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint64_t delta; - uint64_t initial; - uint32_t expiration; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; - } protocol_binary_request_incr; - typedef protocol_binary_request_incr protocol_binary_request_decr; - - /** - * Definition of the response from an incr or decr command - * command. - * See section 4 - */ - typedef union { - struct { - protocol_binary_response_header header; - struct { - uint64_t value; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; - } protocol_binary_response_incr; - typedef protocol_binary_response_incr protocol_binary_response_decr; - - /** - * Definition of the quit - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_quit; - - /** - * Definition of the packet returned by the quit command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_quit; - - /** - * Definition of the packet used by append and prepend command - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_append; - typedef protocol_binary_request_no_extras protocol_binary_request_prepend; - - /** - * Definition of the packet returned from a successful append or prepend - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_append; - typedef protocol_binary_response_no_extras protocol_binary_response_prepend; - - /** - * Definition of the packet used by the version command - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_version; - - /** - * Definition of the packet returned from a successful version command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_version; - - - /** - * Definition of the packet used by the stats command. - * See section 4 - */ - typedef protocol_binary_request_no_extras protocol_binary_request_stats; - - /** - * Definition of the packet returned from a successful stats command - * See section 4 - */ - typedef protocol_binary_response_no_extras protocol_binary_response_stats; - - /** - * Definition of the packet used by the verbosity command - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint32_t level; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_verbosity; - - /** - * Definition of the packet returned from the verbosity command - */ - typedef protocol_binary_response_no_extras protocol_binary_response_verbosity; - - /** - * Definition of the packet used by the touch command. - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint32_t expiration; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_touch; - - /** - * Definition of the packet returned from the touch command - */ - typedef protocol_binary_response_no_extras protocol_binary_response_touch; - - /** - * Definition of the packet used by the GAT(Q) command. - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - uint32_t expiration; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_gat; - - typedef protocol_binary_request_gat protocol_binary_request_gatq; - - /** - * Definition of the packet returned from the GAT(Q) - */ - typedef protocol_binary_response_get protocol_binary_response_gat; - typedef protocol_binary_response_get protocol_binary_response_gatq; - - - /** - * Definition of a request for a range operation. - * See http://code.google.com/p/memcached/wiki/RangeOps - * - * These types are used for range operations and exist within - * this header for use in other projects. Range operations are - * not expected to be implemented in the memcached server itself. - */ - typedef union { - struct { - protocol_binary_response_header header; - struct { - uint16_t size; - uint8_t reserved; - uint8_t flags; - uint32_t max_results; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_rangeop; - - typedef protocol_binary_request_rangeop protocol_binary_request_rget; - typedef protocol_binary_request_rangeop protocol_binary_request_rset; - typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; - typedef protocol_binary_request_rangeop protocol_binary_request_rappend; - typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; - typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; - typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; - typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; - typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; - typedef protocol_binary_request_rangeop protocol_binary_request_rincr; - typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; - typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; - typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; - - - /** - * Definition of tap commands - * See To be written - * - */ - - typedef union { - struct { - protocol_binary_request_header header; - struct { - /** - * flags is a bitmask used to set properties for the - * the connection. Please In order to be forward compatible - * you should set all undefined bits to 0. - * - * If the bit require extra userdata, it will be stored - * in the user-data field of the body (passed to the engine - * as enginespeciffic). That means that when you parse the - * flags and the engine-specific data, you have to work your - * way from bit 0 and upwards to find the correct offset for - * the data. - * - */ - uint32_t flags; - - /** - * Backfill age - * - * By using this flag you can limit the amount of data being - * transmitted. If you don't specify a backfill age, the - * server will transmit everything it contains. - * - * The first 8 bytes in the engine specific data contains - * the oldest entry (from epoc) you're interested in. - * Specifying a time in the future (for the server you are - * connecting to), will cause it to start streaming current - * changes. - */ -#define TAP_CONNECT_FLAG_BACKFILL 0x01 - /** - * Dump will cause the server to send the data stored on the - * server, but disconnect when the keys stored in the server - * are transmitted. - */ -#define TAP_CONNECT_FLAG_DUMP 0x02 - /** - * The body contains a list of 16 bits words in network byte - * order specifying the vbucket ids to monitor. The first 16 - * bit word contains the number of buckets. The number of 0 - * means "all buckets" - */ -#define TAP_CONNECT_FLAG_LIST_VBUCKETS 0x04 - /** - * The responsibility of the vbuckets is to be transferred - * over to the caller when all items are transferred. - */ -#define TAP_CONNECT_FLAG_TAKEOVER_VBUCKETS 0x08 - /** - * The tap consumer supports ack'ing of tap messages - */ -#define TAP_CONNECT_SUPPORT_ACK 0x10 - /** - * The tap consumer would prefer to just get the keys - * back. If the engine supports this it will set - * the TAP_FLAG_NO_VALUE flag in each of the - * tap packets returned. - */ -#define TAP_CONNECT_REQUEST_KEYS_ONLY 0x20 - /** - * The body contains a list of (vbucket_id, last_checkpoint_id) - * pairs. This provides the checkpoint support in TAP streams. - * The last checkpoint id represents the last checkpoint that - * was successfully persisted. - */ -#define TAP_CONNECT_CHECKPOINT 0x40 - /** - * The tap consumer is a registered tap client, which means that - * the tap server will maintain its checkpoint cursor permanently. - */ -#define TAP_CONNECT_REGISTERED_CLIENT 0x80 - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; - } protocol_binary_request_tap_connect; - - typedef union { - struct { - protocol_binary_request_header header; - struct { - struct { - uint16_t enginespecific_length; - /* - * The flag section support the following flags - */ - /** - * Request that the consumer send a response packet - * for this packet. The opaque field must be preserved - * in the response. - */ -#define TAP_FLAG_ACK 0x01 - /** - * The value for the key is not included in the packet - */ -#define TAP_FLAG_NO_VALUE 0x02 - uint16_t flags; - uint8_t ttl; - uint8_t res1; - uint8_t res2; - uint8_t res3; - } tap; - struct { - uint32_t flags; - uint32_t expiration; - } item; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 16]; - } protocol_binary_request_tap_mutation; - - typedef union { - struct { - protocol_binary_request_header header; - struct { - struct { - uint16_t enginespecific_length; - /** - * See the definition of the flags for - * protocol_binary_request_tap_mutation for a description - * of the available flags. - */ - uint16_t flags; - uint8_t ttl; - uint8_t res1; - uint8_t res2; - uint8_t res3; - } tap; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; - } protocol_binary_request_tap_no_extras; - - typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_delete; - typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_flush; - typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_opaque; - typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_vbucket_set; - - - /** - * Definition of the packet used by the scrub. - */ - typedef protocol_binary_request_no_extras protocol_binary_request_scrub; - - /** - * Definition of the packet returned from scrub. - */ - typedef protocol_binary_response_no_extras protocol_binary_response_scrub; - - - /** - * Definition of the packet used by set vbucket - */ - typedef union { - struct { - protocol_binary_request_header header; - struct { - vbucket_state_t state; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_request_header) + sizeof(vbucket_state_t)]; - } protocol_binary_request_set_vbucket; - /** - * Definition of the packet returned from set vbucket - */ - typedef protocol_binary_response_no_extras protocol_binary_response_set_vbucket; - /** - * Definition of the packet used by del vbucket - */ - typedef protocol_binary_request_no_extras protocol_binary_request_del_vbucket; - /** - * Definition of the packet returned from del vbucket - */ - typedef protocol_binary_response_no_extras protocol_binary_response_del_vbucket; - - /** - * Definition of the packet used by get vbucket - */ - typedef protocol_binary_request_no_extras protocol_binary_request_get_vbucket; - - /** - * Definition of the packet returned from get vbucket - */ - typedef union { - struct { - protocol_binary_response_header header; - struct { - vbucket_state_t state; - } body; - } message; - uint8_t bytes[sizeof(protocol_binary_response_header) + sizeof(vbucket_state_t)]; - } protocol_binary_response_get_vbucket; - - - /** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* PROTOCOL_BINARY_H */ diff --git a/libmemcachedprotocol-0.0/callback.h b/libmemcachedprotocol-0.0/callback.h deleted file mode 100644 index 638536c8..00000000 --- a/libmemcachedprotocol-0.0/callback.h +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Summary: Definition of the callback interface - * - * Copy: See Copyright for the status of this software. - * - * Author: Trond Norbye - */ - -#pragma once - -/** - * Callback to send data back from a successful GET/GETQ/GETK/GETKQ command - * - * @param cookie Just pass along the cookie supplied in the callback - * @param key What to insert as key in the reply - * @param keylen The length of the key - * @param body What to store in the body of the package - * @param bodylen The number of bytes of the body - * @param flags The flags stored with the item - * @param cas The CAS value to insert into the response (should be 0 - * if you don't care) - */ -typedef protocol_binary_response_status -(*memcached_binary_protocol_get_response_handler)(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen, - uint32_t flags, - uint64_t cas); -/** - * Callback to send data back from a STAT command - * - * @param cookie Just pass along the cookie supplied in the callback - * @param key What to insert as key in the reply - * @param keylen The length of the key - * @param body What to store in the body of the package - * @param bodylen The number of bytes of the body - */ -typedef protocol_binary_response_status -(*memcached_binary_protocol_stat_response_handler)(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen); -/** - * Callback to send data back from a VERSION command - * - * @param cookie Just pass along the cookie supplied in the callback - * @param text The version string - * @param length The number of bytes in the version string - */ -typedef protocol_binary_response_status -(*memcached_binary_protocol_version_response_handler)(const void *cookie, - const void *text, - uint32_t length); - - -/** - * In the low level interface you need to format the response - * packet yourself (giving you complete freedom :-) - * - * @param cookie Just pass along the cookie supplied in the callback - * @param request Pointer to the request packet you are sending a reply to - * @param response Pointer to the response packet to send - * - */ -typedef protocol_binary_response_status (*memcached_binary_protocol_raw_response_handler)(const void *cookie, - protocol_binary_request_header *request, - protocol_binary_response_header *response); - -/** - * In the low lever interface you have to do most of the work by - * yourself, but it also gives you a lot of freedom :-) - * @param cookie identification for this connection, just pass it along to - * the response handler - * @param header the command received over the wire. Never try to access - * anything outside the command. - * @param resonse_handler call this function to send data back to the client - */ -typedef protocol_binary_response_status (*memcached_binary_protocol_command_handler)(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler); - -/** - * The raw interface to the packets is implemented in version 0. It contains - * just an array with command handlers. The inxed in the array is the - * com code. - */ -typedef struct { - memcached_binary_protocol_command_handler comcode[256]; -} memcached_binary_protocol_callback_v0_st; - - -/** - * The first version of the callback struct containing all of the - * documented commands in the initial release of the binary protocol - * (aka. memcached 1.4.0). - * - * You might miss the Q commands (addq etc) but the response function - * knows how to deal with them so you don't need to worry about that :-) - */ -typedef struct { - /** - * Add an item to the cache - * @param cookie id of the client receiving the command - * @param key the key to add - * @param len the length of the key - * @param val the value to store for the key (may be NIL) - * @param vallen the length of the data - * @param flags the flags to store with the key - * @param exptime the expiry time for the key-value pair - * @param cas the resulting cas for the add operation (if success) - */ - protocol_binary_response_status (*add)(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint32_t flags, - uint32_t exptime, - uint64_t *cas); - - /** - * Append data to an existing key-value pair. - * - * @param cookie id of the client receiving the command - * @param key the key to add data to - * @param len the length of the key - * @param val the value to append to the value - * @param vallen the length of the data - * @param cas the CAS in the request - * @param result_cas the resulting cas for the append operation - * - */ - protocol_binary_response_status (*append)(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint64_t cas, - uint64_t *result_cas); - - /** - * Decrement the value for a key - * - * @param cookie id of the client receiving the command - * @param key the key to decrement the value for - * @param len the length of the key - * @param delta the amount to decrement - * @param initial initial value to store (if the key doesn't exist) - * @param expiration expiration time for the object (if the key doesn't exist) - * @param cas the CAS in the request - * @param result the result from the decrement - * @param result_cas the cas of the item - * - */ - protocol_binary_response_status (*decrement)(const void *cookie, - const void *key, - uint16_t keylen, - uint64_t delta, - uint64_t initial, - uint32_t expiration, - uint64_t *result, - uint64_t *result_cas); - - /** - * Delete an existing key - * - * @param cookie id of the client receiving the command - * @param key the key to delete_object - * @param len the length of the key - * @param cas the CAS in the request - */ - protocol_binary_response_status (*delete_object)(const void *cookie, - const void *key, - uint16_t keylen, - uint64_t cas); - - - /** - * Flush the cache - * - * @param cookie id of the client receiving the command - * @param when when the cache should be flushed (0 == immediately) - */ - protocol_binary_response_status (*flush_object)(const void *cookie, - uint32_t when); - - - - /** - * Get a key-value pair - * - * @param cookie id of the client receiving the command - * @param key the key to get - * @param len the length of the key - * @param response_handler to send the result back to the client - */ - protocol_binary_response_status (*get)(const void *cookie, - const void *key, - uint16_t keylen, - memcached_binary_protocol_get_response_handler response_handler); - - /** - * Increment the value for a key - * - * @param cookie id of the client receiving the command - * @param key the key to increment the value on - * @param len the length of the key - * @param delta the amount to increment - * @param initial initial value to store (if the key doesn't exist) - * @param expiration expiration time for the object (if the key doesn't exist) - * @param cas the CAS in the request - * @param result the result from the decrement - * @param result_cas the cas of the item - * - */ - protocol_binary_response_status (*increment)(const void *cookie, - const void *key, - uint16_t keylen, - uint64_t delta, - uint64_t initial, - uint32_t expiration, - uint64_t *result, - uint64_t *result_cas); - - /** - * The noop command was received. This is just a notification callback (the - * response is automatically created). - * - * @param cookie id of the client receiving the command - */ - protocol_binary_response_status (*noop)(const void *cookie); - - /** - * Prepend data to an existing key-value pair. - * - * @param cookie id of the client receiving the command - * @param key the key to prepend data to - * @param len the length of the key - * @param val the value to prepend to the value - * @param vallen the length of the data - * @param cas the CAS in the request - * @param result-cas the cas id of the item - * - */ - protocol_binary_response_status (*prepend)(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint64_t cas, - uint64_t *result_cas); - - /** - * The quit command was received. This is just a notification callback (the - * response is automatically created). - * - * @param cookie id of the client receiving the command - */ - protocol_binary_response_status (*quit)(const void *cookie); - - - /** - * Replace an existing item to the cache - * - * @param cookie id of the client receiving the command - * @param key the key to replace the content for - * @param len the length of the key - * @param val the value to store for the key (may be NIL) - * @param vallen the length of the data - * @param flags the flags to store with the key - * @param exptime the expiry time for the key-value pair - * @param cas the cas id in the request - * @param result_cas the cas id of the item - */ - protocol_binary_response_status (*replace)(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint32_t flags, - uint32_t exptime, - uint64_t cas, - uint64_t *result_cas); - - - /** - * Set a key-value pair in the cache - * - * @param cookie id of the client receiving the command - * @param key the key to insert - * @param len the length of the key - * @param val the value to store for the key (may be NIL) - * @param vallen the length of the data - * @param flags the flags to store with the key - * @param exptime the expiry time for the key-value pair - * @param cas the cas id in the request - * @param result_cas the cas id of the new item - */ - protocol_binary_response_status (*set)(const void *cookie, - const void *key, - uint16_t keylen, - const void* val, - uint32_t vallen, - uint32_t flags, - uint32_t exptime, - uint64_t cas, - uint64_t *result_cas); - - /** - * Get status information - * - * @param cookie id of the client receiving the command - * @param key the key to get status for (or NIL to request all status). - * Remember to insert the terminating packet if multiple - * packets should be returned. - * @param keylen the length of the key - * @param response_handler to send the result back to the client, but - * don't send reply on success! - * - */ - protocol_binary_response_status (*stat)(const void *cookie, - const void *key, - uint16_t keylen, - memcached_binary_protocol_stat_response_handler response_handler); - - /** - * Get the version information - * - * @param cookie id of the client receiving the command - * @param response_handler to send the result back to the client, but - * don't send reply on success! - * - */ - protocol_binary_response_status (*version)(const void *cookie, - memcached_binary_protocol_version_response_handler response_handler); -} memcached_binary_protocol_callback_v1_st; - - -/** - * The version numbers for the different callback structures. - */ -typedef enum { - /** Version 0 is a lowlevel interface that tries to maximize your freedom */ - MEMCACHED_PROTOCOL_HANDLER_V0= 0, - /** - * Version 1 abstracts more of the protocol details, and let you work at - * a logical level - */ - MEMCACHED_PROTOCOL_HANDLER_V1= 1 -} memcached_protocol_interface_version_t; - -/** - * Definition of the protocol callback structure. - */ -typedef struct { - /** - * The interface version you provide callbacks for. - */ - memcached_protocol_interface_version_t interface_version; - - /** - * Callback fired just before the command will be executed. - * - * @param cookie id of the client receiving the command - * @param header the command header as received on the wire. If you look - * at the content you must ensure that you don't - * try to access beyond the end of the message. - */ - void (*pre_execute)(const void *cookie, - protocol_binary_request_header *header); - /** - * Callback fired just after the command was exected (please note - * that the data transfer back to the client is not finished at this - * time). - * - * @param cookie id of the client receiving the command - * @param header the command header as received on the wire. If you look - * at the content you must ensure that you don't - * try to access beyond the end of the message. - */ - void (*post_execute)(const void *cookie, - protocol_binary_request_header *header); - - /** - * Callback fired if no specialized callback is registered for this - * specific command code. - * - * @param cookie id of the client receiving the command - * @param header the command header as received on the wire. You must - * ensure that you don't try to access beyond the end of the - * message. - * @param response_handler The response handler to send data back. - */ - protocol_binary_response_status (*unknown)(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler); - - /** - * The different interface levels we support. A pointer is used so the - * size of the structure is fixed. You must ensure that the memory area - * passed as the pointer is valid as long as you use the protocol handler. - */ - union { - memcached_binary_protocol_callback_v0_st v0; - - /** - * The first version of the callback struct containing all of the - * documented commands in the initial release of the binary protocol - * (aka. memcached 1.4.0). - */ - memcached_binary_protocol_callback_v1_st v1; - } interface; -} memcached_binary_protocol_callback_st; diff --git a/libmemcachedprotocol-0.0/handler.h b/libmemcachedprotocol-0.0/handler.h deleted file mode 100644 index 113338df..00000000 --- a/libmemcachedprotocol-0.0/handler.h +++ /dev/null @@ -1,218 +0,0 @@ -/* LibMemcached - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. - * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. - * - * Summary: Definition of the callback interface to the protocol handler - * - * Author: Trond Norbye - * - */ - -#pragma once - -#include -#if !defined(__cplusplus) -# include -#endif - -#include -#include -#include -#include - -/* Forward declarations */ -/* - * You should only access memcached_protocol_st from one thread!, - * and never assume anything about the internal layout / sizes of the - * structures. - */ -typedef struct memcached_protocol_st memcached_protocol_st; -typedef struct memcached_protocol_client_st memcached_protocol_client_st; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Function the protocol handler should call to receive data. - * This function should behave exactly like read(2) - * - * @param cookie a cookie used to represent a given client - * @param fd the filedescriptor associated with the client - * @param buf destination buffer - * @param nbuf number of bytes to receive - * @return the number of bytes copied into buf - * or -1 upon error (errno should contain more information) - */ -typedef ssize_t (*memcached_protocol_recv_func)(const void *cookie, - memcached_socket_t fd, - void *buf, - size_t nbuf); - -/** - * Function the protocol handler should call to send data. - * This function should behave exactly like write(2) - * - * @param cookie a cookie used to represent a given client - * @param fd the filedescriptor associated with the client - * @param buf the source buffer - * @param nbuf number of bytes to send - * @return the number of bytes sent - * or -1 upon error (errno should contain more information) - */ -typedef ssize_t (*memcached_protocol_send_func)(const void *cookie, - memcached_socket_t fd, - const void *buf, - size_t nbuf); - -/** - * Create an instance of the protocol handler - * - * @return NULL if allocation of an instance fails - */ -LIBMEMCACHED_API -memcached_protocol_st *memcached_protocol_create_instance(void); - -/** - * Get the callbacks associated with a protocol handler instance - * @return the callbacks currently used - */ -LIBMEMCACHED_API -memcached_binary_protocol_callback_st *memcached_binary_protocol_get_callbacks(memcached_protocol_st *instance); - -/** - * Set the callbacks to be used by the given protocol handler instance - * @param instance the instance to update - * @param callback the callbacks to use - */ -LIBMEMCACHED_API -void memcached_binary_protocol_set_callbacks(memcached_protocol_st *instance, memcached_binary_protocol_callback_st *callback); - -/** - * Should the library inspect the packages being sent and received and verify - * that they are according to the specification? If it encounters an invalid - * packet, it will return an EINVAL packet. - * - * @param instance the instance to update - * @param enable true if you want the library to check packages, false otherwise - */ -LIBMEMCACHED_API -void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable); - -/** - * Is the library inpecting each package? - * @param instance the instance to check - * @return true it the library is inspecting each package, false otherwise - */ -LIBMEMCACHED_API -bool memcached_binary_protocol_get_pedantic(memcached_protocol_st *instance); - -/** - * Destroy an instance of the protocol handler - * - * @param instance The instance to destroy - */ -LIBMEMCACHED_API -void memcached_protocol_destroy_instance(memcached_protocol_st *instance); - -/** - * Set the IO functions used by the instance to send and receive data. The - * functions should behave like recv(3socket) and send(3socket). - * - * @param instance the instance to specify the IO functions for - * @param recv the function to call for reciving data - * @param send the function to call for sending data - */ -LIBMEMCACHED_API -void memached_protocol_set_io_functions(memcached_protocol_st *instance, - memcached_protocol_recv_func recv, - memcached_protocol_send_func send); - - -/** - * Create a new client instance and associate it with a socket - * @param instance the protocol instance to bind the client to - * @param sock the client socket - * @return NULL if allocation fails, otherwise an instance - */ -LIBMEMCACHED_API -memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, memcached_socket_t sock); - -/** - * Destroy a client handle. - * The caller needs to close the socket accociated with the client - * before calling this function. This function invalidates the - * client memory area. - * - * @param client the client to destroy - */ -LIBMEMCACHED_API -void memcached_protocol_client_destroy(memcached_protocol_client_st *client); - -LIBMEMCACHED_API -void memcached_protocol_client_set_verbose(struct memcached_protocol_client_st *client, bool arg); - -/** - * Error event means that the client encountered an error with the - * connection so you should shut it down - */ -#define MEMCACHED_PROTOCOL_ERROR_EVENT 1 -/** - * Please notify when there is more data available to read - */ -#define MEMCACHED_PROTOCOL_READ_EVENT 2 -/** - * Please notify when it is possible to send more data - */ -#define MEMCACHED_PROTOCOL_WRITE_EVENT 4 -/** - * Backed paused the execution for this client - */ -#define MEMCACHED_PROTOCOL_PAUSE_EVENT 8 - -/** - * The different events the client is interested in. This is a bitmask of - * the constants defined above. - */ -typedef uint32_t memcached_protocol_event_t; - -/** - * Let the client do some work. This might involve reading / sending data - * to/from the client, or perform callbacks to execute a command. - * @param client the client structure to work on - * @return The next event the protocol handler will be notified for - */ -LIBMEMCACHED_API -memcached_protocol_event_t memcached_protocol_client_work(memcached_protocol_client_st *client); - -/** - * Get the socket attached to a client handle - * @param client the client to query - * @return the socket handle - */ -LIBMEMCACHED_API -memcached_socket_t memcached_protocol_client_get_socket(memcached_protocol_client_st *client); - -/** - * Get the error id socket attached to a client handle - * @param client the client to query for an error code - * @return the OS error code from the client - */ -LIBMEMCACHED_API -int memcached_protocol_client_get_errno(memcached_protocol_client_st *client); - -/** - * Get a raw response handler for the given cookie - * @param cookie the cookie passed along into the callback - * @return the raw reponse handler you may use if you find - * the generic callback too limiting - */ -LIBMEMCACHED_API -memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcachedprotocol-0.0/include.am b/libmemcachedprotocol-0.0/include.am deleted file mode 100644 index 3683c0f1..00000000 --- a/libmemcachedprotocol-0.0/include.am +++ /dev/null @@ -1,9 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - -nobase_include_HEADERS+= \ - libmemcachedprotocol-0.0/binary.h \ - libmemcachedprotocol-0.0/callback.h \ - libmemcachedprotocol-0.0/handler.h \ - libmemcachedprotocol-0.0/vbucket.h diff --git a/libmemcachedprotocol-0.0/vbucket.h b/libmemcachedprotocol-0.0/vbucket.h deleted file mode 100644 index e2cc563e..00000000 --- a/libmemcachedprotocol-0.0/vbucket.h +++ /dev/null @@ -1,59 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef enum { - vbucket_state_active = 1, /**< Actively servicing a vbucket. */ - vbucket_state_replica, /**< Servicing a vbucket as a replica only. */ - vbucket_state_pending, /**< Pending active. */ - vbucket_state_dead /**< Not in use, pending deletion. */ -} vbucket_state_t; - -#define is_valid_vbucket_state_t(state) \ - (state == vbucket_state_active || \ - state == vbucket_state_replica || \ - state == vbucket_state_pending || \ - state == vbucket_state_dead) - -#ifdef __cplusplus -} -#endif diff --git a/libmemcachedprotocol/ascii_handler.c b/libmemcachedprotocol/ascii_handler.c deleted file mode 100644 index 8cd29720..00000000 --- a/libmemcachedprotocol/ascii_handler.c +++ /dev/null @@ -1,1123 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include -#include -#include -#include -#include - - -static void print_ascii_command(memcached_protocol_client_st *client) -{ - if (client->is_verbose) - { - switch (client->ascii_command) - { - case SET_CMD: - fprintf(stderr, "%s:%d SET_CMD\n", __FILE__, __LINE__); - break; - - case ADD_CMD: - fprintf(stderr, "%s:%d ADD_CMD\n", __FILE__, __LINE__); - break; - - case REPLACE_CMD: - fprintf(stderr, "%s:%d REPLACE_CMD\n", __FILE__, __LINE__); - break; - - case CAS_CMD: - fprintf(stderr, "%s:%d CAS_CMD\n", __FILE__, __LINE__); - break; - - case APPEND_CMD: - fprintf(stderr, "%s:%d APPEND_CMD\n", __FILE__, __LINE__); - break; - - case PREPEND_CMD: - fprintf(stderr, "%s:%d PREPEND_CMD\n", __FILE__, __LINE__); - break; - - case DELETE_CMD: - fprintf(stderr, "%s:%d DELETE_CMD\n", __FILE__, __LINE__); - break; - - case INCR_CMD: /* FALLTHROUGH */ - fprintf(stderr, "%s:%d INCR_CMD\n", __FILE__, __LINE__); - break; - - case DECR_CMD: - fprintf(stderr, "%s:%d DECR_CMD\n", __FILE__, __LINE__); - break; - - case STATS_CMD: - fprintf(stderr, "%s:%d STATS_CMD\n", __FILE__, __LINE__); - break; - - case FLUSH_ALL_CMD: - fprintf(stderr, "%s:%d FLUSH_ALL_CMD\n", __FILE__, __LINE__); - break; - - case VERSION_CMD: - fprintf(stderr, "%s:%d VERSION_CMD\n", __FILE__, __LINE__); - break; - - case QUIT_CMD: - fprintf(stderr, "%s:%d QUIT_CMD\n", __FILE__, __LINE__); - break; - - case VERBOSITY_CMD: - fprintf(stderr, "%s:%d VERBOSITY_CMD\n", __FILE__, __LINE__); - break; - - case GET_CMD: - fprintf(stderr, "%s:%d GET_CMD\n", __FILE__, __LINE__); - break; - - case GETS_CMD: - fprintf(stderr, "%s:%d GETS_CMD\n", __FILE__, __LINE__); - break; - - default: - case UNKNOWN_CMD: - fprintf(stderr, "%s:%d UNKNOWN_CMD\n", __FILE__, __LINE__); - break; - - } - } -} - -/** - * Try to parse a key from the string. - * @pointer start pointer to a pointer to the string (IN and OUT) - * @return length of the string of -1 if this was an illegal key (invalid - * characters or invalid length) - * @todo add length! - */ -static uint16_t parse_ascii_key(char **start) -{ - uint16_t len= 0; - char *c= *start; - /* Strip leading whitespaces */ - while (isspace(*c)) - { - ++c; - } - - *start= c; - - while (*c != '\0' && !isspace(*c) && !iscntrl(*c)) - { - ++c; - ++len; - } - - - if (len == 0 || len > 240 || (*c != '\0' && *c != '\r' && iscntrl(*c))) - { - return 0; - } - - return len; -} - -/** - * Spool a zero-terminated string - * @param client destination - * @param text the text to spool - * @return status of the spool operation - */ -static protocol_binary_response_status raw_response_handler(memcached_protocol_client_st *client, const char *text) -{ - if (client->is_verbose) - { - fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, text); - } - - if (client->root->drain(client) == false) - { - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; - } - - assert(client->output != NULL); -#if 0 - if (client->output == NULL) - { - /* I can write directly to the socket.... */ - do - { - size_t num_bytes= len -offset; - ssize_t nw= client->root->send(client, - client->sock, - ptr + offset, - num_bytes); - if (nw == -1) - { - if (get_socket_errno() == EWOULDBLOCK) - { - break; - } - else if (get_socket_errno() != EINTR) - { - client->error= errno; - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; - } - } - else - { - offset += (size_t)nw; - } - } while (offset < len); - } -#endif - - return client->root->spool(client, text, strlen(text)); -} - -/** - * Send a "CLIENT_ERROR" message back to the client with the correct - * format of the command being sent - * @param client the client to send the message to - */ -static void send_command_usage(memcached_protocol_client_st *client) -{ - const char *errmsg[]= { - [GET_CMD]= "CLIENT_ERROR: Syntax error: get *\r\n", - [GETS_CMD]= "CLIENT_ERROR: Syntax error: gets *\r\n", - [SET_CMD]= "CLIENT_ERROR: Syntax error: set [noreply]\r\n", - [ADD_CMD]= "CLIENT_ERROR: Syntax error: add [noreply]\r\n", - [REPLACE_CMD]= "CLIENT_ERROR: Syntax error: replace [noreply]\r\n", - [CAS_CMD]= "CLIENT_ERROR: Syntax error: cas [noreply]\r\n", - [APPEND_CMD]= "CLIENT_ERROR: Syntax error: append [noreply]\r\n", - [PREPEND_CMD]= "CLIENT_ERROR: Syntax error: prepend [noreply]\r\n", - [DELETE_CMD]= "CLIENT_ERROR: Syntax error: delete_object [noreply]\r\n", - [INCR_CMD]= "CLIENT_ERROR: Syntax error: incr [noreply]\r\n", - [DECR_CMD]= "CLIENT_ERROR: Syntax error: decr [noreply]\r\n", - [STATS_CMD]= "CLIENT_ERROR: Syntax error: stats [key]\r\n", - [FLUSH_ALL_CMD]= "CLIENT_ERROR: Syntax error: flush_all [timeout] [noreply]\r\n", - [VERSION_CMD]= "CLIENT_ERROR: Syntax error: version\r\n", - [QUIT_CMD]="CLIENT_ERROR: Syntax error: quit\r\n", - - [VERBOSITY_CMD]= "CLIENT_ERROR: Syntax error: verbosity \r\n", - [UNKNOWN_CMD]= "CLIENT_ERROR: Unknown command\r\n", - }; - - client->mute = false; - raw_response_handler(client, errmsg[client->ascii_command]); -} - -/** - * Callback for the VERSION responses - * @param cookie client identifier - * @param text the length of the body - * @param textlen the length of the body - */ -static protocol_binary_response_status ascii_version_response_handler(const void *cookie, - const void *text, - uint32_t textlen) -{ - memcached_protocol_client_st *client= (memcached_protocol_client_st*)cookie; - raw_response_handler(client, "VERSION "); - client->root->spool(client, text, textlen); - raw_response_handler(client, "\r\n"); - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Callback for the GET/GETQ/GETK and GETKQ responses - * @param cookie client identifier - * @param key the key for the item - * @param keylen the length of the key - * @param body the length of the body - * @param bodylen the length of the body - * @param flags the flags for the item - * @param cas the CAS id for the item - */ -static protocol_binary_response_status -ascii_get_response_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen, - uint32_t flags, - uint64_t cas) -{ - memcached_protocol_client_st *client= (void*)cookie; - char buffer[300]; - strcpy(buffer, "VALUE "); - const char *source= key; - char *dest= buffer + 6; - - for (int x= 0; x < keylen; ++x) - { - if (*source != '\0' && !isspace(*source) && !iscntrl(*source)) - { - *dest= *source; - } - else - { - return PROTOCOL_BINARY_RESPONSE_EINVAL; /* key constraints in ascii */ - } - - ++dest; - ++source; - } - - size_t used= (size_t)(dest - buffer); - - if (client->ascii_command == GETS_CMD) - { - snprintf(dest, sizeof(buffer) - used, " %u %u %" PRIu64 "\r\n", flags, - bodylen, cas); - } - else - { - snprintf(dest, sizeof(buffer) - used, " %u %u\r\n", flags, bodylen); - } - - client->root->spool(client, buffer, strlen(buffer)); - client->root->spool(client, body, bodylen); - client->root->spool(client, "\r\n", 2); - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Callback for the STAT responses - * @param cookie client identifier - * @param key the key for the item - * @param keylen the length of the key - * @param body the length of the body - * @param bodylen the length of the body - */ -static protocol_binary_response_status ascii_stat_response_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen) -{ - - memcached_protocol_client_st *client= (void*)cookie; - - if (key != NULL) - { - raw_response_handler(client, "STAT "); - client->root->spool(client, key, keylen); - raw_response_handler(client, " "); - client->root->spool(client, body, bodylen); - raw_response_handler(client, "\r\n"); - } - else - { - raw_response_handler(client, "END\r\n"); - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Process a get or a gets request. - * @param client the client handle - * @param buffer the complete get(s) command - * @param end the last character in the command - */ -static void ascii_process_gets(memcached_protocol_client_st *client, - char *buffer, char *end) -{ - char *key= buffer; - - /* Skip command */ - key += (client->ascii_command == GETS_CMD) ? 5 : 4; - - int num_keys= 0; - while (key < end) - { - uint16_t nkey= parse_ascii_key(&key); - if (nkey == 0) /* Invalid key... stop processing this line */ - { - break; - } - - (void)client->root->callback->interface.v1.get(client, key, nkey, - ascii_get_response_handler); - key += nkey; - ++num_keys; - } - - if (num_keys == 0) - { - send_command_usage(client); - } - else - { - client->root->spool(client, "END\r\n", 5); - } -} - -/** - * Try to split up the command line "asdf asdf asdf asdf\n" into an - * argument vector for easier parsing. - * @param start the first character in the command line - * @param end the last character in the command line ("\n") - * @param vec the vector to insert the pointers into - * @size the number of elements in the vector - * @return the number of tokens in the vector - */ -static int ascii_tokenize_command(char *str, char *end, char **vec, int size) -{ - int elem= 0; - - while (str < end) - { - /* Skip leading blanks */ - while (str < end && isspace(*str)) - { - ++str; - } - - if (str == end) - { - return elem; - } - - vec[elem++]= str; - /* find the next non-blank field */ - while (str < end && !isspace(*str)) - { - ++str; - } - - /* zero-terminate it for easier parsing later on */ - *str= '\0'; - ++str; - - /* Is the vector full? */ - if (elem == size) - { - break; - } - } - - return elem; -} - -/** - * If we for some reasons needs to push the line back to read more - * data we have to reverse the tokenization. Just do the brain-dead replace - * of all '\0' to ' ' and set the last character to '\n'. We could have used - * the vector we created, but then we would have to search for all of the - * spaces we ignored... - * @param start pointer to the first character in the buffer to recover - * @param end pointer to the last character in the buffer to recover - */ -static void recover_tokenize_command(char *start, char *end) -{ - while (start < end) - { - if (*start == '\0') - *start= ' '; - ++start; - } - - *end= '\n'; -} - -/** - * Convert the textual command into a comcode - */ -static enum ascii_cmd ascii_to_cmd(char *start, size_t length) -{ - struct { - const char *cmd; - size_t len; - enum ascii_cmd cc; - } commands[]= { - { .cmd= "get", .len= 3, .cc= GET_CMD }, - { .cmd= "gets", .len= 4, .cc= GETS_CMD }, - { .cmd= "set", .len= 3, .cc= SET_CMD }, - { .cmd= "add", .len= 3, .cc= ADD_CMD }, - { .cmd= "replace", .len= 7, .cc= REPLACE_CMD }, - { .cmd= "cas", .len= 3, .cc= CAS_CMD }, - { .cmd= "append", .len= 6, .cc= APPEND_CMD }, - { .cmd= "prepend", .len= 7, .cc= PREPEND_CMD }, - { .cmd= "delete_object", .len= 6, .cc= DELETE_CMD }, - { .cmd= "incr", .len= 4, .cc= INCR_CMD }, - { .cmd= "decr", .len= 4, .cc= DECR_CMD }, - { .cmd= "stats", .len= 5, .cc= STATS_CMD }, - { .cmd= "flush_all", .len= 9, .cc= FLUSH_ALL_CMD }, - { .cmd= "version", .len= 7, .cc= VERSION_CMD }, - { .cmd= "quit", .len= 4, .cc= QUIT_CMD }, - { .cmd= "verbosity", .len= 9, .cc= VERBOSITY_CMD }, - { .cmd= NULL, .len= 0, .cc= UNKNOWN_CMD }}; - - int x= 0; - while (commands[x].len > 0) { - if (length >= commands[x].len) - { - if (strncmp(start, commands[x].cmd, commands[x].len) == 0) - { - /* Potential hit */ - if (length == commands[x].len || isspace(*(start + commands[x].len))) - { - return commands[x].cc; - } - } - } - ++x; - } - - return UNKNOWN_CMD; -} - -/** - * Perform a delete_object operation. - * - * @param client client requesting the deletion - * @param tokens the command as a vector - * @param ntokens the number of items in the vector - */ -static void process_delete(memcached_protocol_client_st *client, - char **tokens, int ntokens) -{ - char *key= tokens[1]; - uint16_t nkey; - - if (ntokens != 2 || (nkey= parse_ascii_key(&key)) == 0) - { - send_command_usage(client); - return; - } - - if (client->root->callback->interface.v1.delete_object == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - - protocol_binary_response_status rval= client->root->callback->interface.v1.delete_object(client, key, nkey, 0); - - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) - { - raw_response_handler(client, "DELETED\r\n"); - } - else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT) - { - raw_response_handler(client, "NOT_FOUND\r\n"); - } - else - { - char msg[80]; - snprintf(msg, sizeof(msg), "SERVER_ERROR: delete_object failed %u\r\n",(uint32_t)rval); - raw_response_handler(client, msg); - } -} - -static void process_arithmetic(memcached_protocol_client_st *client, - char **tokens, int ntokens) -{ - char *key= tokens[1]; - uint16_t nkey; - - if (ntokens != 3 || (nkey= parse_ascii_key(&key)) == 0) - { - send_command_usage(client); - return; - } - - uint64_t cas; - uint64_t result; - uint64_t delta= strtoull(tokens[2], NULL, 10); - - protocol_binary_response_status rval; - if (client->ascii_command == INCR_CMD) - { - if (client->root->callback->interface.v1.increment == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - rval= client->root->callback->interface.v1.increment(client, - key, nkey, - delta, 0, - 0, - &result, - &cas); - } - else - { - if (client->root->callback->interface.v1.decrement == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - rval= client->root->callback->interface.v1.decrement(client, - key, nkey, - delta, 0, - 0, - &result, - &cas); - } - - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) - { - char buffer[80]; - snprintf(buffer, sizeof(buffer), "%"PRIu64"\r\n", result); - raw_response_handler(client, buffer); - } - else - { - raw_response_handler(client, "NOT_FOUND\r\n"); - } -} - -/** - * Process the stats command (with or without a key specified) - * @param key pointer to the first character after "stats" - * @param end pointer to the "\n" - */ -static void process_stats(memcached_protocol_client_st *client, - char *key, char *end) -{ - if (client->root->callback->interface.v1.stat == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - - while (isspace(*key)) - { - key++; - } - - uint16_t nkey= (uint16_t)(end - key); - (void)client->root->callback->interface.v1.stat(client, key, nkey, - ascii_stat_response_handler); -} - -static void process_version(memcached_protocol_client_st *client, - char **tokens, int ntokens) -{ - (void)tokens; - if (ntokens != 1) - { - send_command_usage(client); - return; - } - - if (client->root->callback->interface.v1.version == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - - client->root->callback->interface.v1.version(client, - ascii_version_response_handler); -} - -static void process_flush(memcached_protocol_client_st *client, - char **tokens, int ntokens) -{ - if (ntokens > 2) - { - send_command_usage(client); - return; - } - - if (client->root->callback->interface.v1.flush_object == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return; - } - - uint32_t timeout= 0; - if (ntokens == 2) - { - timeout= (uint32_t)strtoul(tokens[1], NULL, 10); - } - - protocol_binary_response_status rval; - rval= client->root->callback->interface.v1.flush_object(client, timeout); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) - raw_response_handler(client, "OK\r\n"); - else - raw_response_handler(client, "SERVER_ERROR: internal error\r\n"); -} - -/** - * Process one of the storage commands - * @param client the client performing the operation - * @param tokens the command tokens - * @param ntokens the number of tokens - * @param start pointer to the first character in the line - * @param end pointer to the pointer where the last character of this - * command is (IN and OUT) - * @param length the number of bytes available - * @return -1 if an error occurs (and we should just terminate the connection - * because we are out of sync) - * 0 storage command completed, continue processing - * 1 We need more data, so just go ahead and wait for more! - */ -static inline int process_storage_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - (void)ntokens; /* already checked */ - char *key= tokens[1]; - uint16_t nkey= parse_ascii_key(&key); - if (nkey == 0) - { - /* return error */ - raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); - return -1; - } - - uint32_t flags= (uint32_t)strtoul(tokens[2], NULL, 10); - uint32_t timeout= (uint32_t)strtoul(tokens[3], NULL, 10); - unsigned long nbytes= strtoul(tokens[4], NULL, 10); - - /* Do we have all data? */ - unsigned long need= nbytes + (unsigned long)((*end - start) + 1) + 2; /* \n\r\n */ - if ((ssize_t)need > length) - { - /* Keep on reading */ - recover_tokenize_command(start, *end); - return 1; - } - - void *data= (*end) + 1; - uint64_t cas= 0; - uint64_t result_cas; - protocol_binary_response_status rval; - switch (client->ascii_command) - { - case SET_CMD: - rval= client->root->callback->interface.v1.set(client, key, - (uint16_t)nkey, - data, - (uint32_t)nbytes, - flags, - timeout, cas, - &result_cas); - break; - case ADD_CMD: - rval= client->root->callback->interface.v1.add(client, key, - (uint16_t)nkey, - data, - (uint32_t)nbytes, - flags, - timeout, &result_cas); - break; - case CAS_CMD: - cas= strtoull(tokens[5], NULL, 10); - /* FALLTHROUGH */ - case REPLACE_CMD: - rval= client->root->callback->interface.v1.replace(client, key, - (uint16_t)nkey, - data, - (uint32_t)nbytes, - flags, - timeout, cas, - &result_cas); - break; - case APPEND_CMD: - rval= client->root->callback->interface.v1.append(client, key, - (uint16_t)nkey, - data, - (uint32_t)nbytes, - cas, - &result_cas); - break; - case PREPEND_CMD: - rval= client->root->callback->interface.v1.prepend(client, key, - (uint16_t)nkey, - data, - (uint32_t)nbytes, - cas, - &result_cas); - break; - - /* gcc complains if I don't put all of the enums in here.. */ - case GET_CMD: - case GETS_CMD: - case DELETE_CMD: - case DECR_CMD: - case INCR_CMD: - case STATS_CMD: - case FLUSH_ALL_CMD: - case VERSION_CMD: - case QUIT_CMD: - case VERBOSITY_CMD: - case UNKNOWN_CMD: - default: - abort(); /* impossible */ - } - - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) - { - raw_response_handler(client, "STORED\r\n"); - } - else - { - if (client->ascii_command == CAS_CMD) - { - if (rval == PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS) - { - raw_response_handler(client, "EXISTS\r\n"); - } - else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT) - { - raw_response_handler(client, "NOT_FOUND\r\n"); - } - else - { - raw_response_handler(client, "NOT_STORED\r\n"); - } - } - else - { - raw_response_handler(client, "NOT_STORED\r\n"); - } - } - - *end += nbytes + 2; - - return 0; -} - -static int process_cas_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 6) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.replace == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -static int process_set_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 5) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.set == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -static int process_add_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 5) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.add == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -static int process_replace_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 5) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.replace == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -static int process_append_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 5) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.append == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -static int process_prepend_command(memcached_protocol_client_st *client, - char **tokens, int ntokens, char *start, - char **end, ssize_t length) -{ - if (ntokens != 5) - { - send_command_usage(client); - return false; - } - - if (client->root->callback->interface.v1.prepend == NULL) - { - raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); - return false; - } - - return process_storage_command(client, tokens, ntokens, start, end, length); -} - -/** - * The ASCII protocol support is just one giant big hack. Instead of adding - * a optimal ascii support, I just convert the ASCII commands to the binary - * protocol and calls back into the command handlers for the binary protocol ;) - */ -memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr) -{ - char *ptr= (char*)client->root->input_buffer; - *endptr= ptr; - - do { - /* Do we have \n (indicating the command preamble)*/ - char *end= memchr(ptr, '\n', (size_t)*length); - if (end == NULL) - { - *endptr= ptr; - return MEMCACHED_PROTOCOL_READ_EVENT; - } - - client->ascii_command= ascii_to_cmd(ptr, (size_t)(*length)); - - /* we got all data available, execute the callback! */ - if (client->root->callback->pre_execute != NULL) - { - client->root->callback->pre_execute(client, NULL); - } - - - /* A multiget lists all of the keys, and I don't want to have an - * avector of let's say 512 pointers to tokenize all of them, so let's - * just handle them immediately - */ - if (client->ascii_command == GET_CMD || - client->ascii_command == GETS_CMD) - { - if (client->root->callback->interface.v1.get != NULL) - { - ascii_process_gets(client, ptr, end); - } - else - { - raw_response_handler(client, "SERVER_ERROR: Command not implemented\n"); - } - } - else - { - /* None of the defined commands takes 10 parameters, so lets just use - * that as a maximum limit. - */ - char *tokens[10]; - int ntokens= ascii_tokenize_command(ptr, end, tokens, 10); - - if (ntokens < 10) - { - client->mute= strcmp(tokens[ntokens - 1], "noreply") == 0; - if (client->mute) - { - --ntokens; /* processed noreply token*/ - } - } - - int error= 0; - - print_ascii_command(client); - switch (client->ascii_command) - { - case SET_CMD: - error= process_set_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case ADD_CMD: - error= process_add_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case REPLACE_CMD: - error= process_replace_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case CAS_CMD: - error= process_cas_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case APPEND_CMD: - error= process_append_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case PREPEND_CMD: - error= process_prepend_command(client, tokens, ntokens, ptr, &end, *length); - break; - - case DELETE_CMD: - process_delete(client, tokens, ntokens); - break; - - case INCR_CMD: /* FALLTHROUGH */ - case DECR_CMD: - process_arithmetic(client, tokens, ntokens); - break; - - case STATS_CMD: - if (client->mute) - { - send_command_usage(client); - } - else - { - recover_tokenize_command(ptr, end); - process_stats(client, ptr + 6, end); - } - break; - - case FLUSH_ALL_CMD: - process_flush(client, tokens, ntokens); - break; - - case VERSION_CMD: - if (client->mute) - { - send_command_usage(client); - } - else - { - process_version(client, tokens, ntokens); - } - break; - - case QUIT_CMD: - if (ntokens != 1 || client->mute) - { - send_command_usage(client); - } - else - { - if (client->root->callback->interface.v1.quit != NULL) - { - client->root->callback->interface.v1.quit(client); - } - - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - break; - - case VERBOSITY_CMD: - if (ntokens != 2) - { - send_command_usage(client); - } - else - { - raw_response_handler(client, "OK\r\n"); - } - break; - - case UNKNOWN_CMD: - send_command_usage(client); - break; - - case GET_CMD: - case GETS_CMD: - default: - /* Should already be handled */ - abort(); - } - - if (error == -1) - { - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - else if (error == 1) - { - return MEMCACHED_PROTOCOL_READ_EVENT; - } - } - - if (client->root->callback->post_execute != NULL) - { - client->root->callback->post_execute(client, NULL); - } - - /* Move past \n */ - ++end; - *length -= end - ptr; - ptr= end; - } while (*length > 0); - - *endptr= ptr; - return MEMCACHED_PROTOCOL_READ_EVENT; -} diff --git a/libmemcachedprotocol/ascii_handler.h b/libmemcachedprotocol/ascii_handler.h deleted file mode 100644 index 02f8831e..00000000 --- a/libmemcachedprotocol/ascii_handler.h +++ /dev/null @@ -1,40 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -LIBMEMCACHED_LOCAL -memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr); diff --git a/libmemcachedprotocol/binary_handler.c b/libmemcachedprotocol/binary_handler.c deleted file mode 100644 index d720424a..00000000 --- a/libmemcachedprotocol/binary_handler.c +++ /dev/null @@ -1,1198 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include -#include -#include -#include -#include -#include - -/* -** ********************************************************************** -** INTERNAL INTERFACE -** ********************************************************************** -*/ - -/** - * Send a preformatted packet back to the client. If the connection is in - * pedantic mode, it will validate the packet and refuse to send it if it - * breaks the specification. - * - * @param cookie client identification - * @param request the original request packet - * @param response the packet to send - * @return The status of the operation - */ -static protocol_binary_response_status raw_response_handler(const void *cookie, - protocol_binary_request_header *request, - protocol_binary_response_header *response) -{ - memcached_protocol_client_st *client= (void*)cookie; - - if (client->root->pedantic && - !memcached_binary_protocol_pedantic_check_response(request, response)) - { - return PROTOCOL_BINARY_RESPONSE_EINVAL; - } - - if (client->root->drain(client) == false) - { - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; - } - - size_t len= sizeof(protocol_binary_response_header) + htonl(response->response.bodylen); - size_t offset= 0; - char *ptr= (void*)response; - - if (client->output == NULL) - { - /* I can write directly to the socket.... */ - do - { - size_t num_bytes= len - offset; - ssize_t nw= client->root->send(client, - client->sock, - ptr + offset, - num_bytes); - if (nw == -1) - { - if (get_socket_errno() == EWOULDBLOCK) - { - break; - } - else if (get_socket_errno() != EINTR) - { - client->error= errno; - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; - } - } - else - { - offset += (size_t)nw; - } - } while (offset < len); - } - - return client->root->spool(client, ptr, len - offset); -} - -static void print_cmd(protocol_binary_command cmd) -{ - switch (cmd) - { - case PROTOCOL_BINARY_CMD_GET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_ADD: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_ADD\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_REPLACE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_REPLACE\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_DELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DELETE\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_INCREMENT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_INCREMENT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_DECREMENT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DECREMENT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_QUIT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_QUIT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_FLUSH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_FLUSH\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_NOOP: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_NOOP\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_VERSION: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_VERSION\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GETK: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETK\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GETKQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETKQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_APPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_APPEND\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_PREPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_PREPEND\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_STAT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_STAT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SETQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_ADDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_ADDQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_REPLACEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_REPLACEQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_DELETEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DELETEQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_INCREMENTQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_INCREMENTQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_DECREMENTQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DECREMENTQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_QUITQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_QUITQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_FLUSHQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_FLUSHQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_APPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_APPENDQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_PREPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_PREPENDQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_VERBOSITY: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_VERBOSITY\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TOUCH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TOUCH\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GAT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GAT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GATQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_LIST_MECHS\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SASL_AUTH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_AUTH\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SASL_STEP: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_STEP\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RGET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RGET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RSET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RSET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RSETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RSETQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RAPPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RAPPEND\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RAPPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RAPPENDQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RPREPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RPREPEND\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RPREPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RPREPENDQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RDELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDELETE\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RDELETEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDELETEQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RINCR: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RINCR\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RINCRQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RINCRQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RDECR: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDECR\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_RDECRQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDECRQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SET_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SET_VBUCKET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GET_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GET_VBUCKET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_DEL_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DEL_VBUCKET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_CONNECT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CONNECT\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_MUTATION: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_MUTATION\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_DELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_DELETE\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_FLUSH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_FLUSH\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_OPAQUE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_OPAQUE\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_LAST_RESERVED: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_LAST_RESERVED\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GATK: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATK\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_GATKQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATKQ\n", __FILE__, __LINE__); return; - case PROTOCOL_BINARY_CMD_SCRUB: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SCRUB\n", __FILE__, __LINE__); return; - default: - abort(); - } -} - -/* - * Version 0 of the interface is really low level and protocol specific, - * while the version 1 of the interface is more API focused. We need a - * way to translate between the command codes on the wire and the - * application level interface in V1, so let's just use the V0 of the - * interface as a map instead of creating a huuuge switch :-) - */ - -/** - * Callback for the GET/GETQ/GETK and GETKQ responses - * @param cookie client identifier - * @param key the key for the item - * @param keylen the length of the key - * @param body the length of the body - * @param bodylen the length of the body - * @param flags the flags for the item - * @param cas the CAS id for the item - */ -static protocol_binary_response_status get_response_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen, - uint32_t flags, - uint64_t cas) -{ - memcached_protocol_client_st *client= (void*)cookie; - uint8_t opcode= client->current_command->request.opcode; - - if (opcode == PROTOCOL_BINARY_CMD_GET || opcode == PROTOCOL_BINARY_CMD_GETQ) - { - keylen= 0; - } - - protocol_binary_response_get response= { - .message.header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= opcode, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= client->current_command->request.opaque, - .cas= memcached_htonll(cas), - .keylen= htons(keylen), - .extlen= 4, - .bodylen= htonl(bodylen + keylen + 4), - }, - }; - - response.message.body.flags= htonl(flags); - - protocol_binary_response_status rval; - const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; - if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || - (rval= client->root->spool(client, key, keylen)) != success || - (rval= client->root->spool(client, body, bodylen)) != success) - { - return rval; - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Callback for the STAT responses - * @param cookie client identifier - * @param key the key for the item - * @param keylen the length of the key - * @param body the length of the body - * @param bodylen the length of the body - */ -static protocol_binary_response_status stat_response_handler(const void *cookie, - const void *key, - uint16_t keylen, - const void *body, - uint32_t bodylen) -{ - - memcached_protocol_client_st *client= (void*)cookie; - - protocol_binary_response_no_extras response= { - .message.header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= client->current_command->request.opcode, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= client->current_command->request.opaque, - .keylen= htons(keylen), - .bodylen= htonl(bodylen + keylen), - .cas= 0 - }, - }; - - protocol_binary_response_status rval; - const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; - if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || - (rval= client->root->spool(client, key, keylen)) != success || - (rval= client->root->spool(client, body, bodylen)) != success) - { - return rval; - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Callback for the VERSION responses - * @param cookie client identifier - * @param text the length of the body - * @param textlen the length of the body - */ -static protocol_binary_response_status version_response_handler(const void *cookie, - const void *text, - uint32_t textlen) -{ - - memcached_protocol_client_st *client= (void*)cookie; - - protocol_binary_response_no_extras response= { - .message.header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= client->current_command->request.opcode, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= client->current_command->request.opaque, - .bodylen= htonl(textlen), - .cas= 0 - }, - }; - - protocol_binary_response_status rval; - const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; - if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || - (rval= client->root->spool(client, text, textlen)) != success) - { - return rval; - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Callback for ADD and ADDQ - * @param cookie the calling client - * @param header the add/addq command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -add_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.add != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_add *request= (void*)header; - uint32_t flags= ntohl(request->message.body.flags); - uint32_t timeout= ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - uint64_t cas; - - rval= client->root->callback->interface.v1.add(cookie, key, keylen, - data, datalen, flags, - timeout, &cas); - - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_ADD) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_ADD, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(cas) - } - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for DECREMENT and DECREMENTQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -decrement_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.decrement != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - protocol_binary_request_decr *request= (void*)header; - uint64_t init= memcached_ntohll(request->message.body.initial); - uint64_t delta= memcached_ntohll(request->message.body.delta); - uint32_t timeout= ntohl(request->message.body.expiration); - void *key= request->bytes + sizeof(request->bytes); - uint64_t result; - uint64_t cas; - - rval= client->root->callback->interface.v1.decrement(cookie, key, keylen, - delta, init, timeout, - &result, &cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_DECREMENT) - { - /* Send a positive request */ - protocol_binary_response_decr response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_DECREMENT, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(cas), - .bodylen= htonl(8) - }, - .body.value= memcached_htonll(result) - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for DELETE and DELETEQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status delete_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.delete_object != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - void *key= (header +1); - uint64_t cas= memcached_ntohll(header->request.cas); - rval= client->root->callback->interface.v1.delete_object(cookie, key, keylen, cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_DELETE) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_DELETE, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - } - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for FLUSH and FLUSHQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -flush_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.flush_object != NULL) - { - protocol_binary_request_flush *flush_object= (void*)header; - uint32_t timeout= 0; - if (htonl(header->request.bodylen) == 4) - { - timeout= ntohl(flush_object->message.body.expiration); - } - - rval= client->root->callback->interface.v1.flush_object(cookie, timeout); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_FLUSH) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_FLUSH, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - } - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for GET, GETK, GETQ, GETKQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -get_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.get != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - void *key= (header + 1); - rval= client->root->callback->interface.v1.get(cookie, key, keylen, - get_response_handler); - - if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT && - (header->request.opcode == PROTOCOL_BINARY_CMD_GETQ || - header->request.opcode == PROTOCOL_BINARY_CMD_GETKQ)) - { - /* Quiet commands shouldn't respond on cache misses */ - rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for INCREMENT and INCREMENTQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -increment_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.increment != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - protocol_binary_request_incr *request= (void*)header; - uint64_t init= memcached_ntohll(request->message.body.initial); - uint64_t delta= memcached_ntohll(request->message.body.delta); - uint32_t timeout= ntohl(request->message.body.expiration); - void *key= request->bytes + sizeof(request->bytes); - uint64_t cas; - uint64_t result; - - rval= client->root->callback->interface.v1.increment(cookie, key, keylen, - delta, init, timeout, - &result, &cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENT) - { - /* Send a positive request */ - protocol_binary_response_incr response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_INCREMENT, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(cas), - .bodylen= htonl(8) - }, - .body.value= memcached_htonll(result) - } - }; - - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for noop. Inform the v1 interface about the noop packet, and - * create and send a packet back to the client - * - * @param cookie the calling client - * @param header the command - * @param response_handler the response handler - * @return the result of the operation - */ -static protocol_binary_response_status -noop_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.noop != NULL) - { - client->root->callback->interface.v1.noop(cookie); - } - - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_NOOP, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - } - } - }; - - return response_handler(cookie, header, (void*)&response); -} - -/** - * Callback for APPEND and APPENDQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -append_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.append != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - uint32_t datalen= ntohl(header->request.bodylen) - keylen; - char *key= (void*)(header +1); - char *data= key +keylen; - uint64_t cas= memcached_ntohll(header->request.cas); - uint64_t result_cas; - - rval= client->root->callback->interface.v1.append(cookie, key, keylen, - data, datalen, cas, - &result_cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_APPEND) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_APPEND, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(result_cas), - }, - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for PREPEND and PREPENDQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -prepend_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.prepend != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - uint32_t datalen= ntohl(header->request.bodylen) - keylen; - char *key= (char*)(header + 1); - char *data= key + keylen; - uint64_t cas= memcached_ntohll(header->request.cas); - uint64_t result_cas; - rval= client->root->callback->interface.v1.prepend(cookie, key, keylen, - data, datalen, cas, - &result_cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_PREPEND) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_PREPEND, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(result_cas), - }, - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for QUIT and QUITQ. Notify the client and shut down the connection - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -quit_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.quit != NULL) - { - client->root->callback->interface.v1.quit(cookie); - } - - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_QUIT, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque - } - } - }; - - if (header->request.opcode == PROTOCOL_BINARY_CMD_QUIT) - { - response_handler(cookie, header, (void*)&response); - } - - /* I need a better way to signal to close the connection */ - return PROTOCOL_BINARY_RESPONSE_EINTERNAL; -} - -/** - * Callback for REPLACE and REPLACEQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -replace_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.replace != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_replace *request= (void*)header; - uint32_t flags= ntohl(request->message.body.flags); - uint32_t timeout= ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - uint64_t cas= memcached_ntohll(header->request.cas); - uint64_t result_cas; - - rval= client->root->callback->interface.v1.replace(cookie, key, keylen, - data, datalen, flags, - timeout, cas, - &result_cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_REPLACE, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(result_cas), - }, - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for SET and SETQ - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status set_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.set != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; - protocol_binary_request_replace *request= (void*)header; - uint32_t flags= ntohl(request->message.body.flags); - uint32_t timeout= ntohl(request->message.body.expiration); - char *key= ((char*)header) + sizeof(*header) + 8; - char *data= key + keylen; - uint64_t cas= memcached_ntohll(header->request.cas); - uint64_t result_cas; - - - rval= client->root->callback->interface.v1.set(cookie, key, keylen, - data, datalen, flags, - timeout, cas, &result_cas); - if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && - header->request.opcode == PROTOCOL_BINARY_CMD_SET) - { - /* Send a positive request */ - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= PROTOCOL_BINARY_CMD_SET, - .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), - .opaque= header->request.opaque, - .cas= memcached_ntohll(result_cas), - }, - } - }; - rval= response_handler(cookie, header, (void*)&response); - } - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for STAT - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -stat_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.stat != NULL) - { - uint16_t keylen= ntohs(header->request.keylen); - - rval= client->root->callback->interface.v1.stat(cookie, - (void*)(header + 1), - keylen, - stat_response_handler); - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * Callback for VERSION - * @param cookie the calling client - * @param header the command - * @param response_handler not used - * @return the result of the operation - */ -static protocol_binary_response_status -version_command_handler(const void *cookie, - protocol_binary_request_header *header, - memcached_binary_protocol_raw_response_handler response_handler) -{ - (void)response_handler; - (void)header; - protocol_binary_response_status rval; - - memcached_protocol_client_st *client= (void*)cookie; - if (client->root->callback->interface.v1.version != NULL) - { - rval= client->root->callback->interface.v1.version(cookie, - version_response_handler); - } - else - { - rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - } - - return rval; -} - -/** - * The map to remap between the com codes and the v1 logical setting - */ -static memcached_binary_protocol_command_handler comcode_v0_v1_remap[256]= { - [PROTOCOL_BINARY_CMD_ADDQ]= add_command_handler, - [PROTOCOL_BINARY_CMD_ADD]= add_command_handler, - [PROTOCOL_BINARY_CMD_APPENDQ]= append_command_handler, - [PROTOCOL_BINARY_CMD_APPEND]= append_command_handler, - [PROTOCOL_BINARY_CMD_DECREMENTQ]= decrement_command_handler, - [PROTOCOL_BINARY_CMD_DECREMENT]= decrement_command_handler, - [PROTOCOL_BINARY_CMD_DELETEQ]= delete_command_handler, - [PROTOCOL_BINARY_CMD_DELETE]= delete_command_handler, - [PROTOCOL_BINARY_CMD_FLUSHQ]= flush_command_handler, - [PROTOCOL_BINARY_CMD_FLUSH]= flush_command_handler, - [PROTOCOL_BINARY_CMD_GETKQ]= get_command_handler, - [PROTOCOL_BINARY_CMD_GETK]= get_command_handler, - [PROTOCOL_BINARY_CMD_GETQ]= get_command_handler, - [PROTOCOL_BINARY_CMD_GET]= get_command_handler, - [PROTOCOL_BINARY_CMD_INCREMENTQ]= increment_command_handler, - [PROTOCOL_BINARY_CMD_INCREMENT]= increment_command_handler, - [PROTOCOL_BINARY_CMD_NOOP]= noop_command_handler, - [PROTOCOL_BINARY_CMD_PREPENDQ]= prepend_command_handler, - [PROTOCOL_BINARY_CMD_PREPEND]= prepend_command_handler, - [PROTOCOL_BINARY_CMD_QUITQ]= quit_command_handler, - [PROTOCOL_BINARY_CMD_QUIT]= quit_command_handler, - [PROTOCOL_BINARY_CMD_REPLACEQ]= replace_command_handler, - [PROTOCOL_BINARY_CMD_REPLACE]= replace_command_handler, - [PROTOCOL_BINARY_CMD_SETQ]= set_command_handler, - [PROTOCOL_BINARY_CMD_SET]= set_command_handler, - [PROTOCOL_BINARY_CMD_STAT]= stat_command_handler, - [PROTOCOL_BINARY_CMD_VERSION]= version_command_handler, -}; - -/** - * Try to execute a command. Fire the pre/post functions and the specialized - * handler function if it's set. If not, the unknown probe should be fired - * if it's present. - * @param client the client connection to operate on - * @param header the command to execute - * @return true if success or false if a fatal error occured so that the - * connection should be shut down. - */ -static protocol_binary_response_status execute_command(memcached_protocol_client_st *client, protocol_binary_request_header *header) -{ - if (client->root->pedantic && - memcached_binary_protocol_pedantic_check_request(header)) - { - /* @todo return invalid command packet */ - } - - /* we got all data available, execute the callback! */ - if (client->root->callback->pre_execute != NULL) - { - client->root->callback->pre_execute(client, header); - } - - protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; - uint8_t cc= header->request.opcode; - - if (client->is_verbose) - { - print_cmd(cc); - } - - switch (client->root->callback->interface_version) - { - case 0: - if (client->root->callback->interface.v0.comcode[cc] != NULL) - { - rval= client->root->callback->interface.v0.comcode[cc](client, header, raw_response_handler); - } - break; - - case 1: - if (comcode_v0_v1_remap[cc] != NULL) - { - rval= comcode_v0_v1_remap[cc](client, header, raw_response_handler); - } - break; - - default: - /* Unknown interface. - * It should be impossible to get here so I'll just call abort - * to avoid getting a compiler warning :-) - */ - abort(); - } - - - if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND && - client->root->callback->unknown != NULL) - { - rval= client->root->callback->unknown(client, header, raw_response_handler); - } - - if (rval != PROTOCOL_BINARY_RESPONSE_SUCCESS && - rval != PROTOCOL_BINARY_RESPONSE_EINTERNAL && - rval != PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED) - { - protocol_binary_response_no_extras response= { - .message= { - .header.response= { - .magic= PROTOCOL_BINARY_RES, - .opcode= cc, - .status= htons(rval), - .opaque= header->request.opaque, - }, - } - }; - rval= raw_response_handler(client, header, (void*)&response); - } - - if (client->root->callback->post_execute != NULL) - { - client->root->callback->post_execute(client, header); - } - - return rval; -} - -/* -** ********************************************************************** -** "PROTOECTED" INTERFACE -** ********************************************************************** -*/ -memcached_protocol_event_t memcached_binary_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr) -{ - /* try to parse all of the received packets */ - protocol_binary_request_header *header; - header= (void*)client->root->input_buffer; - if (header->request.magic != (uint8_t)PROTOCOL_BINARY_REQ) - { - client->error= EINVAL; - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - ssize_t len= *length; - - while (len >= (ssize_t)sizeof(*header) && - (len >= (ssize_t)(sizeof(*header) + ntohl(header->request.bodylen)))) - { - /* I have the complete package */ - client->current_command= header; - protocol_binary_response_status rv= execute_command(client, header); - - if (rv == PROTOCOL_BINARY_RESPONSE_EINTERNAL) - { - *length= len; - *endptr= (void*)header; - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - else if (rv == PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED) - { - return MEMCACHED_PROTOCOL_PAUSE_EVENT; - } - - ssize_t total= (ssize_t)(sizeof(*header) + ntohl(header->request.bodylen)); - len -= total; - if (len > 0) - { - intptr_t ptr= (intptr_t)header; - ptr += total; - if ((ptr % 8) == 0) - { - header= (void*)ptr; - } - else - { - /* Fix alignment */ - memmove(client->root->input_buffer, (void*)ptr, (size_t)len); - header= (void*)client->root->input_buffer; - } - } - *length= len; - *endptr= (void*)header; - } - - return MEMCACHED_PROTOCOL_READ_EVENT; -} - -/* -** ********************************************************************** -** PUBLIC INTERFACE -** ********************************************************************** -*/ -memcached_binary_protocol_callback_st *memcached_binary_protocol_get_callbacks(memcached_protocol_st *instance) -{ - return instance->callback; -} - -void memcached_binary_protocol_set_callbacks(memcached_protocol_st *instance, memcached_binary_protocol_callback_st *callback) -{ - instance->callback= callback; -} - -memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie) -{ - (void)cookie; - return raw_response_handler; -} - -void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable) -{ - instance->pedantic= enable; -} - -bool memcached_binary_protocol_get_pedantic(memcached_protocol_st *instance) -{ - return instance->pedantic; -} - diff --git a/libmemcachedprotocol/binary_handler.h b/libmemcachedprotocol/binary_handler.h deleted file mode 100644 index d5a74e78..00000000 --- a/libmemcachedprotocol/binary_handler.h +++ /dev/null @@ -1,47 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -LIBMEMCACHED_LOCAL -bool memcached_binary_protocol_pedantic_check_request(const protocol_binary_request_header *request); - -LIBMEMCACHED_LOCAL -bool memcached_binary_protocol_pedantic_check_response(const protocol_binary_request_header *request, - const protocol_binary_response_header *response); - -LIBMEMCACHED_LOCAL -memcached_protocol_event_t memcached_binary_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr); diff --git a/libmemcachedprotocol/cache.c b/libmemcachedprotocol/cache.c deleted file mode 100644 index 6240be7d..00000000 --- a/libmemcachedprotocol/cache.c +++ /dev/null @@ -1,189 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -#include "config.h" - -#include -#include -#include - -#ifndef NDEBUG -#include -#endif - -#include - -#ifndef NDEBUG -const uint64_t redzone_pattern = 0xdeadbeefcafebabe; -int cache_error = 0; -#endif - -const size_t initial_pool_size = 64; - -cache_t* cache_create(const char *name, size_t bufsize, size_t align, - cache_constructor_t* constructor, - cache_destructor_t* destructor) { - cache_t* ret = calloc(1, sizeof(cache_t)); - size_t name_length= strlen(name); - char* nm= calloc(1, (sizeof(char) * name_length) +1); - memcpy(nm, name, name_length); - void** ptr = calloc(initial_pool_size, bufsize); - if (ret == NULL || nm == NULL || ptr == NULL || - pthread_mutex_init(&ret->mutex, NULL) == -1) { - free(ret); - free(nm); - free(ptr); - return NULL; - } - - ret->name = nm; - ret->ptr = ptr; - ret->freetotal = initial_pool_size; - ret->constructor = constructor; - ret->destructor = destructor; - -#ifndef NDEBUG - ret->bufsize = bufsize + 2 * sizeof(redzone_pattern); -#else - ret->bufsize = bufsize; -#endif - - (void)align; - - return ret; -} - -static inline void* get_object(void *ptr) { -#ifndef NDEBUG - uint64_t *pre = ptr; - return pre + 1; -#else - return ptr; -#endif -} - -void cache_destroy(cache_t *cache) { - while (cache->freecurr > 0) { - void *ptr = cache->ptr[--cache->freecurr]; - if (cache->destructor) { - cache->destructor(get_object(ptr), NULL); - } - free(ptr); - } - free(cache->name); - free(cache->ptr); - pthread_mutex_destroy(&cache->mutex); -} - -void* cache_alloc(cache_t *cache) { - void *ret; - void *object; - pthread_mutex_lock(&cache->mutex); - if (cache->freecurr > 0) { - ret = cache->ptr[--cache->freecurr]; - object = get_object(ret); - } else { - object = ret = malloc(cache->bufsize); - if (ret != NULL) { - object = get_object(ret); - - if (cache->constructor != NULL && - cache->constructor(object, NULL, 0) != 0) { - free(ret); - object = NULL; - } - } - } - pthread_mutex_unlock(&cache->mutex); - -#ifndef NDEBUG - if (object != NULL) { - /* add a simple form of buffer-check */ - uint64_t *pre = ret; - *pre = redzone_pattern; - ret = pre+1; - memcpy(((char*)ret) + cache->bufsize - (2 * sizeof(redzone_pattern)), - &redzone_pattern, sizeof(redzone_pattern)); - } -#endif - - return object; -} - -void cache_free(cache_t *cache, void *ptr) { - pthread_mutex_lock(&cache->mutex); - -#ifndef NDEBUG - /* validate redzone... */ - if (memcmp(((char*)ptr) + cache->bufsize - (2 * sizeof(redzone_pattern)), - &redzone_pattern, sizeof(redzone_pattern)) != 0) { - raise(SIGABRT); - cache_error = 1; - pthread_mutex_unlock(&cache->mutex); - return; - } - uint64_t *pre = ptr; - --pre; - if (*pre != redzone_pattern) { - raise(SIGABRT); - cache_error = -1; - pthread_mutex_unlock(&cache->mutex); - return; - } - ptr = pre; -#endif - if (cache->freecurr < cache->freetotal) { - cache->ptr[cache->freecurr++] = ptr; - } else { - /* try to enlarge free connections array */ - size_t newtotal = cache->freetotal * 2; - void **new_free = realloc(cache->ptr, sizeof(char *) * newtotal); - if (new_free) { - cache->freetotal = newtotal; - cache->ptr = new_free; - cache->ptr[cache->freecurr++] = ptr; - } else { - if (cache->destructor) { - cache->destructor(ptr, NULL); - } - free(ptr); - - } - } - pthread_mutex_unlock(&cache->mutex); -} - diff --git a/libmemcachedprotocol/cache.h b/libmemcachedprotocol/cache.h deleted file mode 100644 index 6f84feaa..00000000 --- a/libmemcachedprotocol/cache.h +++ /dev/null @@ -1,148 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -#pragma once - -#include - -#ifdef HAVE_UMEM_H -# include -# define cache_t umem_cache_t -# define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT) -# define cache_free(a, b) umem_cache_free(a, b) -# define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0) -# define cache_destroy(a) umem_cache_destroy(a); -#else -# ifndef NDEBUG -/* may be used for debug purposes */ -extern int cache_error; -# endif - -/** - * Constructor used to initialize allocated objects - * - * @param obj pointer to the object to initialized. - * @param notused1 This parameter is currently not used. - * @param notused2 This parameter is currently not used. - * @return you should return 0, but currently this is not checked - */ -typedef int cache_constructor_t(void* obj, void* notused1, int notused2); -/** - * Destructor used to clean up allocated objects before they are - * returned to the operating system. - * - * @param obj pointer to the object to initialized. - * @param notused1 This parameter is currently not used. - * @param notused2 This parameter is currently not used. - * @return you should return 0, but currently this is not checked - */ -typedef void cache_destructor_t(void* obj, void* notused); - -/** - * Definition of the structure to keep track of the internal details of - * the cache allocator. Touching any of these variables results in - * undefined behavior. - */ -typedef struct { - /** Mutex to protect access to the structure */ - pthread_mutex_t mutex; - /** Name of the cache objects in this cache (provided by the caller) */ - char *name; - /** List of pointers to available buffers in this cache */ - void **ptr; - /** The size of each element in this cache */ - size_t bufsize; - /** The capacity of the list of elements */ - size_t freetotal; - /** The current number of free elements */ - size_t freecurr; - /** The constructor to be called each time we allocate more memory */ - cache_constructor_t* constructor; - /** The destructor to be called each time before we release memory */ - cache_destructor_t* destructor; -} cache_t; - -/** - * Create an object cache. - * - * The object cache will let you allocate objects of the same size. It is fully - * MT safe, so you may allocate objects from multiple threads without having to - * do any syncrhonization in the application code. - * - * @param name the name of the object cache. This name may be used for debug purposes - * and may help you track down what kind of object you have problems with - * (buffer overruns, leakage etc) - * @param bufsize the size of each object in the cache - * @param align the alignment requirements of the objects in the cache. - * @param constructor the function to be called to initialize memory when we need - * to allocate more memory from the os. - * @param destructor the function to be called before we release the memory back - * to the os. - * @return a handle to an object cache if successful, NULL otherwise. - */ -cache_t* cache_create(const char* name, size_t bufsize, size_t align, - cache_constructor_t* constructor, - cache_destructor_t* destructor); -/** - * Destroy an object cache. - * - * Destroy and invalidate an object cache. You should return all buffers allocated - * with cache_alloc by using cache_free before calling this function. Not doing - * so results in undefined behavior (the buffers may or may not be invalidated) - * - * @param handle the handle to the object cache to destroy. - */ -void cache_destroy(cache_t* handle); -/** - * Allocate an object from the cache. - * - * @param handle the handle to the object cache to allocate from - * @return a pointer to an initialized object from the cache, or NULL if - * the allocation cannot be satisfied. - */ -void* cache_alloc(cache_t* handle); -/** - * Return an object back to the cache. - * - * The caller should return the object in an initialized state so that - * the object may be returned in an expected state from cache_alloc. - * - * @param handle handle to the object cache to return the object to - * @param ptr pointer to the object to return. - */ -void cache_free(cache_t* handle, void* ptr); -#endif // HAVE_UMEM_H diff --git a/libmemcachedprotocol/common.h b/libmemcachedprotocol/common.h deleted file mode 100644 index 8453ccd8..00000000 --- a/libmemcachedprotocol/common.h +++ /dev/null @@ -1,162 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include "config.h" -#include - -#include -#include -#include -#include - -/* - * I don't really need the following two functions as function pointers - * in the instance handle, but I don't want to put them in the global - * namespace for those linking statically (personally I don't like that, - * but some people still do). If it ever shows up as a performance thing - * I'll look into optimizing this ;-) - */ -typedef bool (*drain_func)(memcached_protocol_client_st *client); -typedef protocol_binary_response_status (*spool_func)(memcached_protocol_client_st *client, - const void *data, - size_t length); - -/** - * Definition of the per instance structure. - */ -struct memcached_protocol_st { - memcached_binary_protocol_callback_st *callback; - memcached_protocol_recv_func recv; - memcached_protocol_send_func send; - - /* - * I really don't need these as funciton pointers, but I don't want - * to clutter the namespace if someone links statically. - */ - drain_func drain; - spool_func spool; - - /* - * To avoid keeping a buffer in each client all the time I have a - * bigger buffer in the instance that I read to initially, and then - * I try to parse and execute as much from the buffer. If I wasn't able - * to process all data I'll keep that in a per-connection buffer until - * the next time I can read from the socket. - */ - uint8_t *input_buffer; - size_t input_buffer_size; - - bool pedantic; - /* @todo use multiple sized buffers */ - cache_t *buffer_cache; -}; - -struct chunk_st { - /* Pointer to the data */ - char *data; - /* The offset to the first byte into the buffer that is used */ - size_t offset; - /* The offset into the buffer for the first free byte */ - size_t nbytes; - /* The number of bytes in the buffer */ - size_t size; - /* Pointer to the next buffer in the chain */ - struct chunk_st *next; -}; - -#define CHUNK_BUFFERSIZE 2048 - -typedef memcached_protocol_event_t (*process_data)(struct memcached_protocol_client_st *client, ssize_t *length, void **endptr); - -enum ascii_cmd { - GET_CMD, - GETS_CMD, - SET_CMD, - ADD_CMD, - REPLACE_CMD, - CAS_CMD, - APPEND_CMD, - PREPEND_CMD, - DELETE_CMD, - INCR_CMD, - DECR_CMD, - STATS_CMD, - FLUSH_ALL_CMD, - VERSION_CMD, - QUIT_CMD, - VERBOSITY_CMD, - UNKNOWN_CMD -}; - -struct memcached_protocol_client_st { - bool is_verbose; - memcached_protocol_st *root; - memcached_socket_t sock; - int error; - - /* Linked list of data to send */ - struct chunk_st *output; - struct chunk_st *output_tail; - - /* - * While we process input data, this is where we spool incomplete commands - * if we need to receive more data.... - * @todo use the buffercace - */ - uint8_t *input_buffer; - size_t input_buffer_size; - size_t input_buffer_offset; - - /* The callback to the protocol handler to use (ascii or binary) */ - process_data work; - - /* - * Should the spool data discard the data to send or not? (aka noreply in - * the ascii protocol.. - */ - bool mute; - - /* Members used by the binary protocol */ - protocol_binary_request_header *current_command; - - /* Members used by the ascii protocol */ - enum ascii_cmd ascii_command; -}; - -#include "ascii_handler.h" -#include "binary_handler.h" diff --git a/libmemcachedprotocol/handler.c b/libmemcachedprotocol/handler.c deleted file mode 100644 index 59b461f6..00000000 --- a/libmemcachedprotocol/handler.c +++ /dev/null @@ -1,437 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/* -** ********************************************************************** -** INTERNAL INTERFACE -** ********************************************************************** -*/ - -/** - * The default function to receive data from the client. This function - * just wraps the recv function to receive from a socket. - * See man -s3socket recv for more information. - * - * @param cookie cookie indentifying a client, not used - * @param sock socket to read from - * @param buf the destination buffer - * @param nbytes the number of bytes to read - * @return the number of bytes transferred of -1 upon error - */ -static ssize_t default_recv(const void *cookie, - memcached_socket_t sock, - void *buf, - size_t nbytes) -{ - (void)cookie; - return recv(sock, buf, nbytes, 0); -} - -/** - * The default function to send data to the server. This function - * just wraps the send function to send through a socket. - * See man -s3socket send for more information. - * - * @param cookie cookie indentifying a client, not used - * @param sock socket to send to - * @param buf the source buffer - * @param nbytes the number of bytes to send - * @return the number of bytes transferred of -1 upon error - */ -static ssize_t default_send(const void *cookie, - memcached_socket_t fd, - const void *buf, - size_t nbytes) -{ - (void)cookie; - return send(fd, buf, nbytes, MSG_NOSIGNAL); -} - -/** - * Try to drain the output buffers without blocking - * - * @param client the client to drain - * @return false if an error occured (connection should be shut down) - * true otherwise (please note that there may be more data to - * left in the buffer to send) - */ -static bool drain_output(struct memcached_protocol_client_st *client) -{ - if (client->is_verbose) - { - fprintf(stderr, "%s:%d %s mute:%d output:%s length:%d\n", __FILE__, __LINE__, __func__, (int)client->mute, - client->output ? "yes" : "no", - client->output ? (int)(client->output->nbytes - client->output->offset) : 0); - } - - /* Do we have pending data to send? */ - while (client->output != NULL) - { - ssize_t len= client->root->send(client, - client->sock, - client->output->data + client->output->offset, - client->output->nbytes - client->output->offset); - - if (len == -1) - { - if (get_socket_errno() == EWOULDBLOCK) - { - return true; - } - else if (get_socket_errno() != EINTR) - { - client->error= get_socket_errno(); - return false; - } - } - else - { - client->output->offset += (size_t)len; - if (client->output->offset == client->output->nbytes) - { - /* This was the complete buffer */ - struct chunk_st *old= client->output; - client->output= client->output->next; - if (client->output == NULL) - { - client->output_tail= NULL; - } - cache_free(client->root->buffer_cache, old); - } - } - } - - return true; -} - -/** - * Allocate an output buffer and chain it into the output list - * - * @param client the client that needs the buffer - * @return pointer to the new chunk if the allocation succeeds, NULL otherwise - */ -static struct chunk_st *allocate_output_chunk(struct memcached_protocol_client_st *client) -{ - struct chunk_st *ret= cache_alloc(client->root->buffer_cache); - - if (ret == NULL) - { - return NULL; - } - - ret->offset= ret->nbytes= 0; - ret->next= NULL; - ret->size= CHUNK_BUFFERSIZE; - ret->data= (void*)(ret + 1); - if (client->output == NULL) - { - client->output= client->output_tail= ret; - } - else - { - client->output_tail->next= ret; - client->output_tail= ret; - } - - return ret; -} - -/** - * Spool data into the send-buffer for a client. - * - * @param client the client to spool the data for - * @param data the data to spool - * @param length the number of bytes of data to spool - * @return PROTOCOL_BINARY_RESPONSE_SUCCESS if success, - * PROTOCOL_BINARY_RESPONSE_ENOMEM if we failed to allocate memory - */ -static protocol_binary_response_status spool_output(struct memcached_protocol_client_st *client, - const void *data, - size_t length) -{ - if (client->is_verbose) - { - fprintf(stderr, "%s:%d %s mute:%d length:%d\n", __FILE__, __LINE__, __func__, (int)client->mute, (int)length); - } - - if (client->mute) - { - return PROTOCOL_BINARY_RESPONSE_SUCCESS; - } - - size_t offset= 0; - - struct chunk_st *chunk= client->output; - while (offset < length) - { - if (chunk == NULL || (chunk->size - chunk->nbytes) == 0) - { - if ((chunk= allocate_output_chunk(client)) == NULL) - { - return PROTOCOL_BINARY_RESPONSE_ENOMEM; - } - } - - size_t bulk= length - offset; - if (bulk > chunk->size - chunk->nbytes) - { - bulk= chunk->size - chunk->nbytes; - } - - memcpy(chunk->data + chunk->nbytes, data, bulk); - chunk->nbytes += bulk; - offset += bulk; - } - - return PROTOCOL_BINARY_RESPONSE_SUCCESS; -} - -/** - * Try to determine the protocol used on this connection. - * If the first byte contains the magic byte PROTOCOL_BINARY_REQ we should - * be using the binary protocol on the connection. I implemented the support - * for the ASCII protocol by wrapping into the simple interface (aka v1), - * so the implementors needs to provide an implementation of that interface - * - */ -static memcached_protocol_event_t determine_protocol(struct memcached_protocol_client_st *client, ssize_t *length, void **endptr) -{ - if (*client->root->input_buffer == (uint8_t)PROTOCOL_BINARY_REQ) - { - if (client->is_verbose) - { - fprintf(stderr, "%s:%d PROTOCOL: memcached_binary_protocol_process_data\n", __FILE__, __LINE__); - } - client->work= memcached_binary_protocol_process_data; - } - else if (client->root->callback->interface_version == 1) - { - if (client->is_verbose) - { - fprintf(stderr, "%s:%d PROTOCOL: memcached_ascii_protocol_process_data\n", __FILE__, __LINE__); - } - - /* - * The ASCII protocol can only be used if the implementors provide - * an implementation for the version 1 of the interface.. - * - * @todo I should allow the implementors to provide an implementation - * for version 0 and 1 at the same time and set the preferred - * interface to use... - */ - client->work= memcached_ascii_protocol_process_data; - } - else - { - if (client->is_verbose) - { - fprintf(stderr, "%s:%d PROTOCOL: Unsupported protocol\n", __FILE__, __LINE__); - } - - /* Let's just output a warning the way it is supposed to look like - * in the ASCII protocol... - */ - const char *err= "CLIENT_ERROR: Unsupported protocol\r\n"; - client->root->spool(client, err, strlen(err)); - client->root->drain(client); - - return MEMCACHED_PROTOCOL_ERROR_EVENT; /* Unsupported protocol */ - } - - return client->work(client, length, endptr); -} - -/* -** ********************************************************************** -** * PUBLIC INTERFACE -** * See protocol_handler.h for function description -** ********************************************************************** -*/ -struct memcached_protocol_st *memcached_protocol_create_instance(void) -{ - struct memcached_protocol_st *ret= calloc(1, sizeof(*ret)); - if (ret != NULL) - { - ret->recv= default_recv; - ret->send= default_send; - ret->drain= drain_output; - ret->spool= spool_output; - ret->input_buffer_size= 1 * 1024 * 1024; - ret->input_buffer= malloc(ret->input_buffer_size); - if (ret->input_buffer == NULL) - { - free(ret); - ret= NULL; - - return NULL; - } - - ret->buffer_cache= cache_create("protocol_handler", - CHUNK_BUFFERSIZE + sizeof(struct chunk_st), - 0, NULL, NULL); - if (ret->buffer_cache == NULL) - { - free(ret->input_buffer); - free(ret); - } - } - - return ret; -} - -void memcached_protocol_destroy_instance(struct memcached_protocol_st *instance) -{ - cache_destroy(instance->buffer_cache); - free(instance->input_buffer); - free(instance); -} - -struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, memcached_socket_t sock) -{ - struct memcached_protocol_client_st *ret= calloc(1, sizeof(memcached_protocol_client_st)); - if (ret != NULL) - { - ret->root= instance; - ret->sock= sock; - ret->work= determine_protocol; - } - - return ret; -} - -void memcached_protocol_client_destroy(struct memcached_protocol_client_st *client) -{ - free(client); -} - -void memcached_protocol_client_set_verbose(struct memcached_protocol_client_st *client, bool arg) -{ - if (client) - { - client->is_verbose= arg; - } -} - -memcached_protocol_event_t memcached_protocol_client_work(struct memcached_protocol_client_st *client) -{ - /* Try to send data and read from the socket */ - bool more_data= true; - do - { - ssize_t len= client->root->recv(client, - client->sock, - client->root->input_buffer + client->input_buffer_offset, - client->root->input_buffer_size - client->input_buffer_offset); - - if (len > 0) - { - /* Do we have the complete packet? */ - if (client->input_buffer_offset > 0) - { - memcpy(client->root->input_buffer, client->input_buffer, - client->input_buffer_offset); - len += (ssize_t)client->input_buffer_offset; - - /* @todo use buffer-cache! */ - free(client->input_buffer); - client->input_buffer_offset= 0; - } - - void *endptr; - memcached_protocol_event_t events= client->work(client, &len, &endptr); - if (events == MEMCACHED_PROTOCOL_ERROR_EVENT) - { - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - - if (len > 0) - { - /* save the data for later on */ - /* @todo use buffer-cache */ - client->input_buffer= malloc((size_t)len); - if (client->input_buffer == NULL) - { - client->error= ENOMEM; - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - memcpy(client->input_buffer, endptr, (size_t)len); - client->input_buffer_offset= (size_t)len; - more_data= false; - } - } - else if (len == 0) - { - /* Connection closed */ - drain_output(client); - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - else - { - if (get_socket_errno() != EWOULDBLOCK) - { - client->error= get_socket_errno(); - /* mark this client as terminated! */ - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - more_data= false; - } - } while (more_data); - - if (!drain_output(client)) - { - return MEMCACHED_PROTOCOL_ERROR_EVENT; - } - - memcached_protocol_event_t ret= MEMCACHED_PROTOCOL_READ_EVENT; - if (client->output) - { - ret|= MEMCACHED_PROTOCOL_READ_EVENT; - } - - return ret; -} diff --git a/libmemcachedprotocol/include.am b/libmemcachedprotocol/include.am deleted file mode 100644 index 33d00fe9..00000000 --- a/libmemcachedprotocol/include.am +++ /dev/null @@ -1,34 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - - -lib_LTLIBRARIES+= libmemcached/libmemcachedprotocol.la - -noinst_HEADERS+= libmemcachedprotocol/ascii_handler.h -noinst_HEADERS+= libmemcachedprotocol/binary_handler.h -noinst_HEADERS+= libmemcachedprotocol/cache.h -noinst_HEADERS+= libmemcachedprotocol/common.h - -libmemcached_libmemcachedprotocol_la_SOURCES= -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcached/byteorder.cc -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcachedprotocol/ascii_handler.c -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcachedprotocol/binary_handler.c -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcachedprotocol/cache.c -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcachedprotocol/handler.c -libmemcached_libmemcachedprotocol_la_SOURCES+= libmemcachedprotocol/pedantic.c - -libmemcached_libmemcachedprotocol_la_CFLAGS= -libmemcached_libmemcachedprotocol_la_CFLAGS+= ${AM_CFLAGS} -libmemcached_libmemcachedprotocol_la_CFLAGS+= ${NO_CONVERSION} -libmemcached_libmemcachedprotocol_la_CFLAGS+= -DBUILDING_LIBMEMCACHED -libmemcached_libmemcachedprotocol_la_CFLAGS+= ${PTHREAD_CFLAGS} - -libmemcached_libmemcachedprotocol_la_CXXFLAGS= -libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${AM_CXXFLAGS} -libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED -libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${PTHREAD_CFLAGS} - -libmemcached_libmemcachedprotocol_la_LIBADD= ${PTHREAD_LIBS} -libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION} diff --git a/libmemcachedprotocol/pedantic.c b/libmemcachedprotocol/pedantic.c deleted file mode 100644 index 54a2add0..00000000 --- a/libmemcachedprotocol/pedantic.c +++ /dev/null @@ -1,237 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ -#include - -#include - -#define ensure(a) if (!(a)) { return false; } - -bool memcached_binary_protocol_pedantic_check_request(const protocol_binary_request_header *request) -{ - ensure(request->request.magic == PROTOCOL_BINARY_REQ); - ensure(request->request.datatype == PROTOCOL_BINARY_RAW_BYTES); - - ensure(request->bytes[6] == 0); - ensure(request->bytes[7] == 0); - - uint8_t opcode= request->request.opcode; - uint16_t keylen= ntohs(request->request.keylen); - uint8_t extlen= request->request.extlen; - uint32_t bodylen= ntohl(request->request.bodylen); - - ensure(bodylen >= (keylen + extlen)); - - switch (opcode) { - case PROTOCOL_BINARY_CMD_GET: - case PROTOCOL_BINARY_CMD_GETK: - case PROTOCOL_BINARY_CMD_GETKQ: - case PROTOCOL_BINARY_CMD_GETQ: - ensure(extlen == 0); - ensure(keylen > 0); - ensure(keylen == bodylen); - ensure(request->request.cas == 0); - break; - - case PROTOCOL_BINARY_CMD_ADD: - case PROTOCOL_BINARY_CMD_ADDQ: - /* it makes no sense to run add with a cas value */ - ensure(request->request.cas == 0); - /* FALLTHROUGH */ - case PROTOCOL_BINARY_CMD_SET: - case PROTOCOL_BINARY_CMD_SETQ: - case PROTOCOL_BINARY_CMD_REPLACE: - case PROTOCOL_BINARY_CMD_REPLACEQ: - ensure(keylen > 0); - ensure(extlen == 8); - break; - - case PROTOCOL_BINARY_CMD_DELETE: - case PROTOCOL_BINARY_CMD_DELETEQ: - ensure(extlen == 0); - ensure(keylen > 0); - ensure(keylen == bodylen); - break; - - case PROTOCOL_BINARY_CMD_INCREMENT: - case PROTOCOL_BINARY_CMD_INCREMENTQ: - case PROTOCOL_BINARY_CMD_DECREMENT: - case PROTOCOL_BINARY_CMD_DECREMENTQ: - ensure(extlen == 20); - ensure(keylen > 0); - ensure(keylen + extlen == bodylen); - break; - - case PROTOCOL_BINARY_CMD_QUIT: - case PROTOCOL_BINARY_CMD_QUITQ: - case PROTOCOL_BINARY_CMD_NOOP: - case PROTOCOL_BINARY_CMD_VERSION: - ensure(extlen == 0); - ensure(keylen == 0); - ensure(bodylen == 0); - break; - - case PROTOCOL_BINARY_CMD_FLUSH: - case PROTOCOL_BINARY_CMD_FLUSHQ: - ensure(extlen == 0 || extlen == 4); - ensure(keylen == 0); - ensure(bodylen == extlen); - break; - - case PROTOCOL_BINARY_CMD_STAT: - ensure(extlen == 0); - /* May have key, but not value */ - ensure(keylen == bodylen); - break; - - case PROTOCOL_BINARY_CMD_APPEND: - case PROTOCOL_BINARY_CMD_APPENDQ: - case PROTOCOL_BINARY_CMD_PREPEND: - case PROTOCOL_BINARY_CMD_PREPENDQ: - ensure(extlen == 0); - ensure(keylen > 0); - break; - default: - /* Unknown command */ - ; - } - - return true; -} - -bool memcached_binary_protocol_pedantic_check_response(const protocol_binary_request_header *request, - const protocol_binary_response_header *response) -{ - ensure(response->response.magic == PROTOCOL_BINARY_RES); - ensure(response->response.datatype == PROTOCOL_BINARY_RAW_BYTES); - ensure(response->response.opaque == request->request.opaque); - - uint16_t status= ntohs(response->response.status); - uint8_t opcode= response->response.opcode; - - if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) - { - switch (opcode) { - case PROTOCOL_BINARY_CMD_ADDQ: - case PROTOCOL_BINARY_CMD_APPENDQ: - case PROTOCOL_BINARY_CMD_DECREMENTQ: - case PROTOCOL_BINARY_CMD_DELETEQ: - case PROTOCOL_BINARY_CMD_FLUSHQ: - case PROTOCOL_BINARY_CMD_INCREMENTQ: - case PROTOCOL_BINARY_CMD_PREPENDQ: - case PROTOCOL_BINARY_CMD_QUITQ: - case PROTOCOL_BINARY_CMD_REPLACEQ: - case PROTOCOL_BINARY_CMD_SETQ: - /* Quiet command shouldn't return on success */ - return false; - default: - break; - } - - switch (opcode) { - case PROTOCOL_BINARY_CMD_ADD: - case PROTOCOL_BINARY_CMD_REPLACE: - case PROTOCOL_BINARY_CMD_SET: - case PROTOCOL_BINARY_CMD_APPEND: - case PROTOCOL_BINARY_CMD_PREPEND: - ensure(response->response.keylen == 0); - ensure(response->response.extlen == 0); - ensure(response->response.bodylen == 0); - ensure(response->response.cas != 0); - break; - case PROTOCOL_BINARY_CMD_FLUSH: - case PROTOCOL_BINARY_CMD_NOOP: - case PROTOCOL_BINARY_CMD_QUIT: - case PROTOCOL_BINARY_CMD_DELETE: - ensure(response->response.keylen == 0); - ensure(response->response.extlen == 0); - ensure(response->response.bodylen == 0); - ensure(response->response.cas == 0); - break; - - case PROTOCOL_BINARY_CMD_DECREMENT: - case PROTOCOL_BINARY_CMD_INCREMENT: - ensure(response->response.keylen == 0); - ensure(response->response.extlen == 0); - ensure(ntohl(response->response.bodylen) == 8); - ensure(response->response.cas != 0); - break; - - case PROTOCOL_BINARY_CMD_STAT: - ensure(response->response.extlen == 0); - /* key and value exists in all packets except in the terminating */ - ensure(response->response.cas == 0); - break; - - case PROTOCOL_BINARY_CMD_VERSION: - ensure(response->response.keylen == 0); - ensure(response->response.extlen == 0); - ensure(response->response.bodylen != 0); - ensure(response->response.cas == 0); - break; - - case PROTOCOL_BINARY_CMD_GET: - case PROTOCOL_BINARY_CMD_GETQ: - ensure(response->response.keylen == 0); - ensure(response->response.extlen == 4); - ensure(response->response.cas != 0); - break; - - case PROTOCOL_BINARY_CMD_GETK: - case PROTOCOL_BINARY_CMD_GETKQ: - ensure(response->response.keylen != 0); - ensure(response->response.extlen == 4); - ensure(response->response.cas != 0); - break; - - default: - /* Undefined command code */ - break; - } - } - else - { - ensure(response->response.cas == 0); - ensure(response->response.extlen == 0); - if (opcode != PROTOCOL_BINARY_CMD_GETK) - { - ensure(response->response.keylen == 0); - } - } - - return true; -} diff --git a/libmemcachedutil-1.0/flush.h b/libmemcachedutil-1.0/flush.h deleted file mode 100644 index dd7e7799..00000000 --- a/libmemcachedutil-1.0/flush.h +++ /dev/null @@ -1,50 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -bool libmemcached_util_flush(const char *hostname, in_port_t port, memcached_return_t *ret); - -#ifdef __cplusplus -} -#endif - diff --git a/libmemcachedutil-1.0/include.am b/libmemcachedutil-1.0/include.am deleted file mode 100644 index 39a15937..00000000 --- a/libmemcachedutil-1.0/include.am +++ /dev/null @@ -1,13 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root - - -nobase_include_HEADERS+= \ - libmemcachedutil-1.0/flush.h \ - libmemcachedutil-1.0/ostream.hpp \ - libmemcachedutil-1.0/pid.h \ - libmemcachedutil-1.0/ping.h \ - libmemcachedutil-1.0/pool.h \ - libmemcachedutil-1.0/util.h \ - libmemcachedutil-1.0/version.h diff --git a/libmemcachedutil-1.0/ostream.hpp b/libmemcachedutil-1.0/ostream.hpp deleted file mode 100644 index cce7bfcd..00000000 --- a/libmemcachedutil-1.0/ostream.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -static inline std::ostream& operator<<(std::ostream& output, const enum memcached_return_t &arg) -{ - output << memcached_strerror(NULL, arg); - return output; -} - -static inline std::ostream& operator<<(std::ostream& output, const memcached_st &arg) -{ - output << " query_id: " << memcached_query_id(&arg); - output << " error: " << memcached_last_error_message(&arg); - return output; -} diff --git a/libmemcachedutil-1.0/pid.h b/libmemcachedutil-1.0/pid.h deleted file mode 100644 index 01738acc..00000000 --- a/libmemcachedutil-1.0/pid.h +++ /dev/null @@ -1,58 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifndef WIN32 -#include -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -pid_t libmemcached_util_getpid(const char *hostname, in_port_t port, memcached_return_t *ret); - -LIBMEMCACHED_API -pid_t libmemcached_util_getpid2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); - -#ifdef __cplusplus -} -#endif - diff --git a/libmemcachedutil-1.0/ping.h b/libmemcachedutil-1.0/ping.h deleted file mode 100644 index faea8b2b..00000000 --- a/libmemcachedutil-1.0/ping.h +++ /dev/null @@ -1,52 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API -bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_return_t *ret); - -LIBMEMCACHED_API -bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcachedutil-1.0/pool.h b/libmemcachedutil-1.0/pool.h deleted file mode 100644 index a11117ca..00000000 --- a/libmemcachedutil-1.0/pool.h +++ /dev/null @@ -1,83 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct memcached_pool_st; -typedef struct memcached_pool_st memcached_pool_st; - -LIBMEMCACHED_API -memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, uint32_t max); - -LIBMEMCACHED_API -memcached_pool_st *memcached_pool(const char *option_string, size_t option_string_length); - -LIBMEMCACHED_API -memcached_st* memcached_pool_destroy(memcached_pool_st* pool); - -LIBMEMCACHED_API -memcached_st* memcached_pool_pop(memcached_pool_st* pool, - bool block, - memcached_return_t* rc); -LIBMEMCACHED_API - memcached_return_t memcached_pool_push(memcached_pool_st* pool, - memcached_st* mmc); -LIBMEMCACHED_API - memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st* mmc); - -LIBMEMCACHED_API -memcached_st* memcached_pool_fetch(memcached_pool_st*, struct timespec* relative_time, memcached_return_t* rc); - -LIBMEMCACHED_API -memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr, - memcached_behavior_t flag, - uint64_t data); -LIBMEMCACHED_API -memcached_return_t memcached_pool_behavior_get(memcached_pool_st *ptr, - memcached_behavior_t flag, - uint64_t *value); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/libmemcachedutil-1.0/util.h b/libmemcachedutil-1.0/util.h deleted file mode 100644 index d3620988..00000000 --- a/libmemcachedutil-1.0/util.h +++ /dev/null @@ -1,46 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include diff --git a/libmemcachedutil-1.0/version.h b/libmemcachedutil-1.0/version.h deleted file mode 100644 index 372283a0..00000000 --- a/libmemcachedutil-1.0/version.h +++ /dev/null @@ -1,53 +0,0 @@ -/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * - * Libmemcached library - * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2010 Brian Aker All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -#ifdef __cplusplus -extern "C" { -#endif - -LIBMEMCACHED_API - bool libmemcached_util_version_check(memcached_st *memc, - uint8_t major_version, - uint8_t minor_version, - uint8_t micro_version); - -#ifdef __cplusplus -} -#endif diff --git a/libmemcachedutil-1.2/flush.h b/libmemcachedutil-1.2/flush.h new file mode 100644 index 00000000..dd7e7799 --- /dev/null +++ b/libmemcachedutil-1.2/flush.h @@ -0,0 +1,50 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +bool libmemcached_util_flush(const char *hostname, in_port_t port, memcached_return_t *ret); + +#ifdef __cplusplus +} +#endif + diff --git a/libmemcachedutil-1.2/include.am b/libmemcachedutil-1.2/include.am new file mode 100644 index 00000000..ef8ad0b2 --- /dev/null +++ b/libmemcachedutil-1.2/include.am @@ -0,0 +1,11 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +nobase_include_HEADERS+= libmemcachedutil-1.2/flush.h +nobase_include_HEADERS+= libmemcachedutil-1.2/ostream.hpp +nobase_include_HEADERS+= libmemcachedutil-1.2/pid.h +nobase_include_HEADERS+= libmemcachedutil-1.2/ping.h +nobase_include_HEADERS+= libmemcachedutil-1.2/pool.h +nobase_include_HEADERS+= libmemcachedutil-1.2/util.h +nobase_include_HEADERS+= libmemcachedutil-1.2/version.h diff --git a/libmemcachedutil-1.2/ostream.hpp b/libmemcachedutil-1.2/ostream.hpp new file mode 100644 index 00000000..cce7bfcd --- /dev/null +++ b/libmemcachedutil-1.2/ostream.hpp @@ -0,0 +1,50 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +static inline std::ostream& operator<<(std::ostream& output, const enum memcached_return_t &arg) +{ + output << memcached_strerror(NULL, arg); + return output; +} + +static inline std::ostream& operator<<(std::ostream& output, const memcached_st &arg) +{ + output << " query_id: " << memcached_query_id(&arg); + output << " error: " << memcached_last_error_message(&arg); + return output; +} diff --git a/libmemcachedutil-1.2/pid.h b/libmemcachedutil-1.2/pid.h new file mode 100644 index 00000000..01738acc --- /dev/null +++ b/libmemcachedutil-1.2/pid.h @@ -0,0 +1,58 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifndef WIN32 +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +pid_t libmemcached_util_getpid(const char *hostname, in_port_t port, memcached_return_t *ret); + +LIBMEMCACHED_API +pid_t libmemcached_util_getpid2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); + +#ifdef __cplusplus +} +#endif + diff --git a/libmemcachedutil-1.2/ping.h b/libmemcachedutil-1.2/ping.h new file mode 100644 index 00000000..faea8b2b --- /dev/null +++ b/libmemcachedutil-1.2/ping.h @@ -0,0 +1,52 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API +bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_return_t *ret); + +LIBMEMCACHED_API +bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcachedutil-1.2/pool.h b/libmemcachedutil-1.2/pool.h new file mode 100644 index 00000000..bcd7f75d --- /dev/null +++ b/libmemcachedutil-1.2/pool.h @@ -0,0 +1,80 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +struct memcached_pool_st; +typedef struct memcached_pool_st memcached_pool_st; + +LIBMEMCACHED_API +memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, uint32_t max); + +LIBMEMCACHED_API +memcached_pool_st *memcached_pool(const char *option_string, size_t option_string_length); + +LIBMEMCACHED_API +memcached_st* memcached_pool_destroy(memcached_pool_st* pool); + +LIBMEMCACHED_API +memcached_st* memcached_pool_pop(memcached_pool_st* pool, + bool block, + memcached_return_t* rc); +LIBMEMCACHED_API + memcached_return_t memcached_pool_push(memcached_pool_st* pool, + memcached_st* mmc); +LIBMEMCACHED_API + memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st* mmc); + +LIBMEMCACHED_API +memcached_st* memcached_pool_fetch(memcached_pool_st*, struct timespec* relative_time, memcached_return_t* rc); + +LIBMEMCACHED_API +memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr, + memcached_behavior_t flag, + uint64_t data); +LIBMEMCACHED_API +memcached_return_t memcached_pool_behavior_get(memcached_pool_st *ptr, + memcached_behavior_t flag, + uint64_t *value); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/libmemcachedutil-1.2/util.h b/libmemcachedutil-1.2/util.h new file mode 100644 index 00000000..9f18e39e --- /dev/null +++ b/libmemcachedutil-1.2/util.h @@ -0,0 +1,46 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include diff --git a/libmemcachedutil-1.2/version.h b/libmemcachedutil-1.2/version.h new file mode 100644 index 00000000..372283a0 --- /dev/null +++ b/libmemcachedutil-1.2/version.h @@ -0,0 +1,53 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2010 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + bool libmemcached_util_version_check(memcached_st *memc, + uint8_t major_version, + uint8_t minor_version, + uint8_t micro_version); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcachedutil/common.h b/libmemcachedutil/common.h index 5c7b59f4..6d0dc08b 100644 --- a/libmemcachedutil/common.h +++ b/libmemcachedutil/common.h @@ -2,7 +2,7 @@ * * Libmemcached Utility library * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -40,6 +40,7 @@ #include -#include +#include + #include #include diff --git a/libtest/comparison.hpp b/libtest/comparison.hpp index 32dc22fa..db9cc8a7 100644 --- a/libtest/comparison.hpp +++ b/libtest/comparison.hpp @@ -39,8 +39,8 @@ #include #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED -#include -#include +#include +#include #include #endif diff --git a/libtest/memcached.cc b/libtest/memcached.cc index 37a3102e..63335bd9 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -37,8 +37,8 @@ #include #include -#include -#include +#include +#include using namespace libtest; diff --git a/tests/cycle.cc b/tests/cycle.cc index e18037df..904d4312 100644 --- a/tests/cycle.cc +++ b/tests/cycle.cc @@ -43,7 +43,7 @@ #include using namespace libtest; -#include +#include static test_return_t server_startup_single_TEST(void *obj) { diff --git a/tests/failure.cc b/tests/failure.cc index b03a0433..fe96745d 100644 --- a/tests/failure.cc +++ b/tests/failure.cc @@ -39,7 +39,7 @@ /* C++ interface test */ -#include +#include #include #include diff --git a/tests/libmemcached-1.0/atomsmasher.cc b/tests/libmemcached-1.0/atomsmasher.cc index 9b246b17..5a82833a 100644 --- a/tests/libmemcached-1.0/atomsmasher.cc +++ b/tests/libmemcached-1.0/atomsmasher.cc @@ -16,7 +16,7 @@ #include -#include +#include #include #include diff --git a/tests/libmemcached-1.0/basic.cc b/tests/libmemcached-1.0/basic.cc index 392c6778..24754270 100644 --- a/tests/libmemcached-1.0/basic.cc +++ b/tests/libmemcached-1.0/basic.cc @@ -38,7 +38,7 @@ #include #include -#include +#include #include "libmemcached/is.h" #include "tests/basic.h" diff --git a/tests/libmemcached-1.0/debug.cc b/tests/libmemcached-1.0/debug.cc index 6808089a..5110d199 100644 --- a/tests/libmemcached-1.0/debug.cc +++ b/tests/libmemcached-1.0/debug.cc @@ -42,7 +42,7 @@ using namespace libtest; -#include +#include #include #include diff --git a/tests/libmemcached-1.0/deprecated.cc b/tests/libmemcached-1.0/deprecated.cc index c5096ff7..e0932ca5 100644 --- a/tests/libmemcached-1.0/deprecated.cc +++ b/tests/libmemcached-1.0/deprecated.cc @@ -38,7 +38,7 @@ #include #include -#include +#include #include test_return_t server_list_null_test(memcached_st *ptr) diff --git a/tests/libmemcached-1.0/dump.cc b/tests/libmemcached-1.0/dump.cc index 27583ead..aa693f3d 100644 --- a/tests/libmemcached-1.0/dump.cc +++ b/tests/libmemcached-1.0/dump.cc @@ -41,8 +41,8 @@ #include -#include -#include +#include +#include using namespace libtest; diff --git a/tests/libmemcached-1.0/encoding_key.cc b/tests/libmemcached-1.0/encoding_key.cc index 8d3e0dbc..dddd122a 100644 --- a/tests/libmemcached-1.0/encoding_key.cc +++ b/tests/libmemcached-1.0/encoding_key.cc @@ -38,8 +38,8 @@ #include #include -#include -#include +#include +#include #include "tests/libmemcached-1.0/encoding_key.h" diff --git a/tests/libmemcached-1.0/error_conditions.cc b/tests/libmemcached-1.0/error_conditions.cc index b5a05c77..18fa1883 100644 --- a/tests/libmemcached-1.0/error_conditions.cc +++ b/tests/libmemcached-1.0/error_conditions.cc @@ -40,7 +40,7 @@ #define BUILDING_LIBMEMCACHED -#include +#include #include "libmemcached/is.h" #include diff --git a/tests/libmemcached-1.0/generate.cc b/tests/libmemcached-1.0/generate.cc index 37f4a36e..7c19265c 100644 --- a/tests/libmemcached-1.0/generate.cc +++ b/tests/libmemcached-1.0/generate.cc @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include diff --git a/tests/libmemcached-1.0/ketama.cc b/tests/libmemcached-1.0/ketama.cc index de8ac905..12e78501 100644 --- a/tests/libmemcached-1.0/ketama.cc +++ b/tests/libmemcached-1.0/ketama.cc @@ -37,7 +37,7 @@ #include #include -#include +#include #include "libmemcached/server_instance.h" #include "libmemcached/continuum.hpp" diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index a1daa8ab..b83ebb86 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -46,7 +46,7 @@ Test cases */ -#include +#include #include #include @@ -76,7 +76,7 @@ using namespace libtest; -#include +#include #include "tests/hash_results.h" @@ -3731,7 +3731,7 @@ test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *) { size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; // Create a handle. memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist @@ -3757,7 +3757,7 @@ test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc) { size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; // See if memcached is reachable. char *value= memcached_get(memc, @@ -3781,7 +3781,7 @@ test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *) { size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; // Create a handle. memcached_st *tl_memc_h= memcached_create(NULL); @@ -3811,7 +3811,7 @@ test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc) { size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; // See if memcached is reachable. char *value= memcached_get_by_key(memc, @@ -4372,7 +4372,7 @@ test_return_t wrong_failure_counter_two_test(memcached_st *memc) /* Check if we still are connected */ uint32_t flags; size_t string_length; - memcached_return rc; + memcached_return_t rc; char *string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); @@ -4437,7 +4437,7 @@ test_return_t regression_bug_490486(memcached_st *original_memc) char blob[1024]= { 0 }; for (size_t x= 0; x < keys.size(); ++x) { - memcached_return rc= memcached_set(memc, + memcached_return_t rc= memcached_set(memc, keys.key_at(x), keys.length_at(x), blob, sizeof(blob), 0, 0); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); // MEMCACHED_TIMEOUT <-- hash been observed on OSX @@ -4447,7 +4447,7 @@ test_return_t regression_bug_490486(memcached_st *original_memc) /* Try to get all of them with a large multiget */ size_t counter= 0; - memcached_execute_function callbacks[]= { &callback_counter }; + memcached_execute_fn callbacks[]= { &callback_counter }; memcached_return_t rc= memcached_mget_execute(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size(), callbacks, &counter, 1); @@ -4635,7 +4635,7 @@ test_return_t regression_bug_490520(memcached_st *original_memc) char key[251]; int key_length= snprintf(key, sizeof(key), "0200%u", x); - memcached_return rc= memcached_set(memc, key, key_length, blob, sizeof(blob), 0, 0); + memcached_return_t rc= memcached_set(memc, key, key_length, blob, sizeof(blob), 0, 0); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc)); } @@ -4728,7 +4728,7 @@ test_return_t regression_bug_854604(memcached_st *) return TEST_SUCCESS; } -static void die_message(memcached_st* mc, memcached_return error, const char* what, uint32_t it) +static void die_message(memcached_st* mc, memcached_return_t error, const char* what, uint32_t it) { fprintf(stderr, "Iteration #%u: ", it); @@ -4759,7 +4759,7 @@ test_return_t regression_bug_(memcached_st *memc) for (uint32_t x= 0; x < TEST_CONSTANT_CREATION; x++) { memcached_st* mc= memcached_create(NULL); - memcached_return rc; + memcached_return_t rc; rc= memcached_behavior_set(mc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); if (rc != MEMCACHED_SUCCESS) diff --git a/tests/libmemcached-1.0/memcached_fetch_execute.cc b/tests/libmemcached-1.0/memcached_fetch_execute.cc index a22393f8..6296cff7 100644 --- a/tests/libmemcached-1.0/memcached_fetch_execute.cc +++ b/tests/libmemcached-1.0/memcached_fetch_execute.cc @@ -37,7 +37,7 @@ #include #include -#include +#include #include using namespace libtest; diff --git a/tests/libmemcached-1.0/memcached_get.cc b/tests/libmemcached-1.0/memcached_get.cc index 1db1a7e3..08fef67f 100644 --- a/tests/libmemcached-1.0/memcached_get.cc +++ b/tests/libmemcached-1.0/memcached_get.cc @@ -41,7 +41,7 @@ Test cases */ -#include +#include #include "tests/libmemcached-1.0/memcached_get.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" diff --git a/tests/libmemcached-1.0/namespace.cc b/tests/libmemcached-1.0/namespace.cc index cbe4d1b8..dd19143e 100644 --- a/tests/libmemcached-1.0/namespace.cc +++ b/tests/libmemcached-1.0/namespace.cc @@ -40,7 +40,7 @@ using namespace libtest; -#include +#include #include diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index 6a75a2dc..ec0e2304 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -44,8 +44,8 @@ using namespace libtest; #include #include -#include -#include +#include +#include #include #include diff --git a/tests/libmemcached-1.0/plus.cpp b/tests/libmemcached-1.0/plus.cpp index e7bfd836..ed14c104 100644 --- a/tests/libmemcached-1.0/plus.cpp +++ b/tests/libmemcached-1.0/plus.cpp @@ -40,7 +40,7 @@ /* C++ interface test */ -#include +#include #include #include diff --git a/tests/libmemcached-1.0/pool.cc b/tests/libmemcached-1.0/pool.cc index b6653139..75920e04 100644 --- a/tests/libmemcached-1.0/pool.cc +++ b/tests/libmemcached-1.0/pool.cc @@ -47,8 +47,8 @@ using namespace libtest; #include -#include -#include +#include +#include #include #include diff --git a/tests/libmemcached-1.0/print.cc b/tests/libmemcached-1.0/print.cc index 11125493..e738aa04 100644 --- a/tests/libmemcached-1.0/print.cc +++ b/tests/libmemcached-1.0/print.cc @@ -43,7 +43,7 @@ using namespace libtest; #include -#include +#include #include "tests/print.h" diff --git a/tests/libmemcached-1.0/replication.cc b/tests/libmemcached-1.0/replication.cc index 2e1808ea..f23c2f49 100644 --- a/tests/libmemcached-1.0/replication.cc +++ b/tests/libmemcached-1.0/replication.cc @@ -40,7 +40,7 @@ using namespace libtest; -#include +#include #include "libmemcached/server_instance.h" diff --git a/tests/libmemcached-1.0/sasl.cc b/tests/libmemcached-1.0/sasl.cc index 65ce0310..6f0bd7ac 100644 --- a/tests/libmemcached-1.0/sasl.cc +++ b/tests/libmemcached-1.0/sasl.cc @@ -43,7 +43,7 @@ using namespace libtest; Test cases */ -#include +#include static test_return_t pre_sasl(memcached_st *) { diff --git a/tests/libmemcached-1.0/server_add.cc b/tests/libmemcached-1.0/server_add.cc index 8fd717c6..0c36ea3c 100644 --- a/tests/libmemcached-1.0/server_add.cc +++ b/tests/libmemcached-1.0/server_add.cc @@ -40,7 +40,7 @@ using namespace libtest; -#include +#include #include diff --git a/tests/libmemcached-1.0/setup_and_teardowns.cc b/tests/libmemcached-1.0/setup_and_teardowns.cc index ad2126fa..49fea874 100644 --- a/tests/libmemcached-1.0/setup_and_teardowns.cc +++ b/tests/libmemcached-1.0/setup_and_teardowns.cc @@ -38,7 +38,7 @@ #include #include -#include +#include #include "tests/print.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" diff --git a/tests/libmemcached-1.0/stat.cc b/tests/libmemcached-1.0/stat.cc index 605c8baa..bb2bf271 100644 --- a/tests/libmemcached-1.0/stat.cc +++ b/tests/libmemcached-1.0/stat.cc @@ -41,8 +41,8 @@ #include -#include -#include +#include +#include using namespace libtest; diff --git a/tests/libmemcached-1.0/string.cc b/tests/libmemcached-1.0/string.cc index babe1bf2..529c7015 100644 --- a/tests/libmemcached-1.0/string.cc +++ b/tests/libmemcached-1.0/string.cc @@ -40,7 +40,7 @@ #include -#include +#include #include "libmemcached/string.hpp" #include "libmemcached/is.h" diff --git a/tests/libmemcached-1.0/touch.cc b/tests/libmemcached-1.0/touch.cc index 07f0096f..751137f6 100644 --- a/tests/libmemcached-1.0/touch.cc +++ b/tests/libmemcached-1.0/touch.cc @@ -40,8 +40,8 @@ using namespace libtest; -#include -#include +#include +#include #include "tests/touch.h" @@ -60,7 +60,7 @@ test_return_t test_memcached_touch(memcached_st *memc) size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; test_null(memcached_get(memc, test_literal_param(__func__), @@ -106,7 +106,7 @@ test_return_t test_memcached_touch_by_key(memcached_st *memc) size_t len; uint32_t flags; - memcached_return rc; + memcached_return_t rc; test_null(memcached_get_by_key(memc, test_literal_param("grouping_key"), diff --git a/tests/libmemcached-1.0/virtual_buckets.cc b/tests/libmemcached-1.0/virtual_buckets.cc index 5ed812fa..5348fbb3 100644 --- a/tests/libmemcached-1.0/virtual_buckets.cc +++ b/tests/libmemcached-1.0/virtual_buckets.cc @@ -42,7 +42,7 @@ using namespace libtest; #include -#include +#include #include diff --git a/tests/mem_udp.cc b/tests/mem_udp.cc index ed657bf4..a6eedfd5 100644 --- a/tests/mem_udp.cc +++ b/tests/mem_udp.cc @@ -45,11 +45,11 @@ using namespace libtest; -#include +#include #include #include #include -#include +#include #include #include diff --git a/tests/memcapable.cc b/tests/memcapable.cc index 09b47efa..647a6341 100644 --- a/tests/memcapable.cc +++ b/tests/memcapable.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memcat.cc b/tests/memcat.cc index ed606d1d..9144fed3 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memcp.cc b/tests/memcp.cc index 3c8d6b02..27562067 100644 --- a/tests/memcp.cc +++ b/tests/memcp.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memdump.cc b/tests/memdump.cc index 840c1a17..cc4d0023 100644 --- a/tests/memdump.cc +++ b/tests/memdump.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memerror.cc b/tests/memerror.cc index 9b3ddd35..b2f90e19 100644 --- a/tests/memerror.cc +++ b/tests/memerror.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memexist.cc b/tests/memexist.cc index 47496a64..f34b2efe 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -42,8 +42,8 @@ #include #include -#include -#include +#include +#include using namespace libtest; diff --git a/tests/memflush.cc b/tests/memflush.cc index 0f708a9b..5a0bb2e3 100644 --- a/tests/memflush.cc +++ b/tests/memflush.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memrm.cc b/tests/memrm.cc index 1f5f722a..d47b58e7 100644 --- a/tests/memrm.cc +++ b/tests/memrm.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memslap.cc b/tests/memslap.cc index 792d15fb..3925029a 100644 --- a/tests/memslap.cc +++ b/tests/memslap.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memstat.cc b/tests/memstat.cc index b2dea7e9..57c6a587 100644 --- a/tests/memstat.cc +++ b/tests/memstat.cc @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace libtest; diff --git a/tests/memtouch.cc b/tests/memtouch.cc index 207ac1dc..bffe48e0 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -42,8 +42,8 @@ #include #include -#include -#include +#include +#include using namespace libtest; diff --git a/tests/parser.cc b/tests/parser.cc index 220d9ef5..15dab12b 100644 --- a/tests/parser.cc +++ b/tests/parser.cc @@ -39,7 +39,7 @@ /* C++ interface test */ -#include +#include #include using namespace libtest; diff --git a/win32/include.am b/win32/include.am index 43e8d9b1..f4578f5b 100644 --- a/win32/include.am +++ b/win32/include.am @@ -6,6 +6,5 @@ noinst_HEADERS+= win32/wrappers.h if BUILD_WIN32_WRAPPERS libhashkit_libhashkit_la_LDFLAGS+=-no-undefined libmemcached_libmemcached_la_LDFLAGS+=-no-undefined -libmemcached_libmemcachedprotocol_la_LDFLAGS+=-no-undefined libmemcached_libmemcachedutil_la_LDFLAGS+=-no-undefined endif -- cgit v1.2.1