string(TOUPPER ${LIBRARY} LIBRARY_UCASE)
math(EXPR DASH "${DASH} + 1")
string(SUBSTRING ${TOP} ${DASH} -1 VERSION)
- if(NOT ${LIBRARY_UCASE}_VERSION_INC VERSION_EQUAL ${VERSION})
- message(SEND_ERROR "${LIBRARY} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_INC})
+ if(NOT ${LIBRARY_UCASE}_VERSION_MAJOR VERSION_EQUAL ${VERSION})
+ message(SEND_ERROR "${LIBRARY} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_MAJOR})
set(ENV{INVALID_CONFIGURATION} 1)
endif()
endif()
#
set(LIBMEMCACHED_VERSION_MAJOR 1)
-set(LIBMEMCACHED_VERSION_MINOR 0)
-set(LIBMEMCACHED_VERSION_PATCH 99)
+set(LIBMEMCACHED_VERSION_MINOR 1)
+set(LIBMEMCACHED_VERSION_PATCH 0)
set(LIBMEMCACHED_VERSION ${LIBMEMCACHED_VERSION_MAJOR}.${LIBMEMCACHED_VERSION_MINOR}.${LIBMEMCACHED_VERSION_PATCH})
-set(LIBMEMCACHED_VERSION_INC ${LIBMEMCACHED_VERSION_MAJOR}.${LIBMEMCACHED_VERSION_MINOR})
to_hex(LIBMEMCACHED_VERSION_HEX ${LIBMEMCACHED_VERSION_MAJOR} ${LIBMEMCACHED_VERSION_MINOR} ${LIBMEMCACHED_VERSION_PATCH})
# libmemcached.so
set(LIBMEMCACHEDUTIL_VERSION_PATCH 0)
set(LIBMEMCACHEDUTIL_VERSION ${LIBMEMCACHEDUTIL_VERSION_MAJOR}.${LIBMEMCACHEDUTIL_VERSION_MINOR}.${LIBMEMCACHEDUTIL_VERSION_PATCH})
-set(LIBMEMCACHEDUTIL_VERSION_INC ${LIBMEMCACHEDUTIL_VERSION_MAJOR}.${LIBMEMCACHEDUTIL_VERSION_MINOR})
to_hex(LIBMEMCACHEDUTIL_VERSION_HEX ${LIBMEMCACHEDUTIL_VERSION_MAJOR} ${LIBMEMCACHEDUTIL_VERSION_MINOR} ${LIBMEMCACHEDUTIL_VERSION_PATCH})
# libmemcachedutil.so
set(LIBMEMCACHEDPROTOCOL_VERSION_PATCH 0)
set(LIBMEMCACHEDPROTOCOL_VERSION ${LIBMEMCACHEDPROTOCOL_VERSION_MAJOR}.${LIBMEMCACHEDPROTOCOL_VERSION_MINOR}.${LIBMEMCACHEDPROTOCOL_VERSION_PATCH})
-set(LIBMEMCACHEDPROTOCOL_VERSION_INC ${LIBMEMCACHEDPROTOCOL_VERSION_MAJOR}.${LIBMEMCACHEDPROTOCOL_VERSION_MINOR})
to_hex(LIBMEMCACHEDPROTOCOL_VERSION_HEX ${LIBMEMCACHEDPROTOCOL_VERSION_MAJOR} ${LIBMEMCACHEDPROTOCOL_VERSION_MINOR} ${LIBMEMCACHEDPROTOCOL_VERSION_PATCH})
# libmemcachedprotocol.so
set(LIBHASHKIT_VERSION_PATCH 0)
set(LIBHASHKIT_VERSION ${LIBHASHKIT_VERSION_MAJOR}.${LIBHASHKIT_VERSION_MINOR}.${LIBHASHKIT_VERSION_PATCH})
-set(LIBHASHKIT_VERSION_INC ${LIBHASHKIT_VERSION_MAJOR}.${LIBHASHKIT_VERSION_MINOR})
to_hex(LIBHASHKIT_VERSION_HEX ${LIBHASHKIT_VERSION_MAJOR} ${LIBHASHKIT_VERSION_MINOR} ${LIBHASHKIT_VERSION_PATCH})
# libhashkit.so
* Ported test suite to Catch2.
* Build requires C++11 compiler support.
* Tests require C++17 compiler support.
+* Moved to the Semantic Versioning Specification: https://semver.org
* Moved the project from launchpad to github:
* Source: https://github.com/m6w6/libmemcached
* Documentation: https://m6w6.github.io/libmemcached
#include <netdb.h>
#include "ms_task.h"
-#include "libmemcachedprotocol-0.0/binary.h"
+#include "libmemcachedprotocol-0/binary.h"
#ifdef __cplusplus
extern "C" {
libmemcached Versioning
=======================
-Libmemcached is laid out by interface version. The 1.0 version would be found
-in: ``libmemcached-1.0/memcached.h``
+Libmemcached is laid out by interface version and strives to adhere to the
+``Semantic Versioning Specification`` since version ``1.1``.
-The historic ``libmemcached/memcached.h`` includes
-``libmemcached-1.0/memcached.h``. For best practice you should include the
-version of libmemcached that you used during development.
+.. seealso::
+ `https://semver.org/ <http://semver.org/>`_
+The 1.x version would be found in: ``libmemcached-1/memcached.h``. The historic
+``libmemcached/memcached.h`` includes ``libmemcached-1/memcached.h`` and on
+previously supported platforms ``libmemcached-1.0`` points to ``libmemcached-1``.
#include <cstdlib>
#include <cstring>
-#include <libmemcachedprotocol-0.0/handler.h>
+#include <libmemcachedprotocol-0/handler.h>
#include <example/byteorder.h>
#include "example/memcached_light.h"
#include "example/storage.h"
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
-#include <libmemcachedprotocol-0.0/handler.h>
+#include <libmemcachedprotocol-0/handler.h>
#include <example/byteorder.h>
#include "example/memcached_light.h"
#include "example/storage.h"
#include <mem_config.h>
-#include <libmemcachedprotocol-0.0/handler.h>
+#include <libmemcachedprotocol-0/handler.h>
#include <libmemcached/socket.hpp>
#include <example/byteorder.h>
#include "example/storage.h"
-add_subdirectory(libhashkit-1.0)
-add_subdirectory(libmemcached-1.0)
-add_subdirectory(libmemcachedutil-1.0)
-add_subdirectory(libmemcachedprotocol-0.0)
+add_subdirectory(libhashkit-1)
+add_subdirectory(libmemcached-1)
+add_subdirectory(libmemcachedutil-1)
+add_subdirectory(libmemcachedprotocol-0)
+
+# v1.0 compatibility
+if(NOT WIN32)
+ file(COPY libhashkit-1.0 DESTINATION .)
+ file(COPY libmemcached-1.0 DESTINATION .)
+ file(COPY libmemcachedutil-1.0 DESTINATION .)
+ file(COPY libmemcachedprotocol-0.0 DESTINATION .)
+ install(CODE "
+ file(INSTALL
+ ${CMAKE_CURRENT_BINARY_DIR}/libhashkit-1.0
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcached-1.0
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedutil-1.0
+ ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedprotocol-0.0
+ DESTINATION \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
+ ")
+endif()
--- /dev/null
+libhashkit-1
\ No newline at end of file
+++ /dev/null
-
-install_public_headers(libhashkit-1.0
- @configure.h
- algorithm.h
- basic_string.h
- behavior.h
- digest.h
- function.h
- has.h
- hashkit.h
- hashkit.hpp
- str_algorithm.h
- strerror.h
- string.h
- types.h
- visibility.h
- )
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_fnv1_64(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_fnv1a_64(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_fnv1_32(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_fnv1a_32(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_crc32(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_hsieh(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_murmur(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_murmur3(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_jenkins(const char *key, size_t key_length);
-
-HASHKIT_API
-uint32_t libhashkit_md5(const char *key, size_t key_length);
-
-HASHKIT_API
-void libhashkit_md5_signature(const unsigned char *key, size_t length, unsigned char *result);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-// No assumptions of NULL should be made
-
-#define hashkit_size(X) (X).size;
-#define hashkit_c_str(X) (X).c_str;
-#define hashkit_string_param(X) (X).c_str, (X).size
-
-#ifdef __cplusplus
-# define hashkit_string_printf(X) int((X).size), (X).c_str
-#else
-# define hashkit_string_printf(X) (int) ((X).size), (X).c_str
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#define LIBHASHKIT_VERSION_STRING "@LIBHASHKIT_VERSION@"
-#define LIBHASHKIT_VERSION_HEX @LIBHASHKIT_VERSION_HEX@
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_length);
-
-/**
- This is a utilitly function provided so that you can directly access hashes with a hashkit_st.
-*/
-
-HASHKIT_API
-uint32_t libhashkit_digest(const char *key, size_t key_length,
- hashkit_hash_algorithm_t hash_algorithm);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- This sets/gets the default function we will be using.
-*/
-HASHKIT_API
-hashkit_return_t hashkit_set_function(hashkit_st *hash, hashkit_hash_algorithm_t hash_algorithm);
-
-HASHKIT_API
-hashkit_return_t hashkit_set_custom_function(hashkit_st *hash, hashkit_hash_fn function,
- void *context);
-
-HASHKIT_API
-hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash);
-
-/**
- This sets/gets the function we use for distribution.
-*/
-HASHKIT_API
-hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash,
- hashkit_hash_algorithm_t hash_algorithm);
-
-HASHKIT_API
-hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st *self,
- hashkit_hash_fn function, void *context);
-
-HASHKIT_API
-hashkit_hash_algorithm_t hashkit_get_distribution_function(const hashkit_st *self);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#if !defined(__cplusplus)
-# include <stdbool.h>
-# include <inttypes.h>
-#else
-# include <cinttypes>
-#endif
-#include <sys/types.h>
-
-#include <libhashkit-1.0/visibility.h>
-#include <libhashkit-1.0/configure.h>
-#include <libhashkit-1.0/types.h>
-#include <libhashkit-1.0/has.h>
-#include <libhashkit-1.0/algorithm.h>
-#include <libhashkit-1.0/behavior.h>
-#include <libhashkit-1.0/digest.h>
-#include <libhashkit-1.0/function.h>
-#include <libhashkit-1.0/str_algorithm.h>
-#include <libhashkit-1.0/strerror.h>
-#include <libhashkit-1.0/string.h>
-
-struct hashkit_st {
- struct hashkit_function_st {
- hashkit_hash_fn function;
- void *context;
- } base_hash, distribution_hash;
-
- struct {
- bool is_base_same_distributed : 1;
- } flags;
-
- struct {
- bool is_allocated : 1;
- } options;
-
- void *_key;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-hashkit_st *hashkit_create(hashkit_st *hash);
-
-HASHKIT_API
-hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr);
-
-HASHKIT_API
-bool hashkit_compare(const hashkit_st *first, const hashkit_st *second);
-
-HASHKIT_API
-void hashkit_free(hashkit_st *hash);
-
-HASHKIT_API
-hashkit_string_st *hashkit_encrypt(hashkit_st *, const char *source, size_t source_length);
-
-HASHKIT_API
-hashkit_string_st *hashkit_decrypt(hashkit_st *, const char *source, size_t source_length);
-
-HASHKIT_API
-bool hashkit_key(hashkit_st *, const char *key, const size_t key_length);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include <libhashkit-1.0/hashkit.h>
-#include <string>
-
-class Hashkit {
-public:
- Hashkit() { hashkit_create(&self); }
-
- Hashkit(const Hashkit &source) { hashkit_clone(&self, &source.self); }
-
- Hashkit &operator=(const Hashkit &source) {
- hashkit_free(&self);
- hashkit_clone(&self, &source.self);
-
- return *this;
- }
-
- friend bool operator==(const Hashkit &left, const Hashkit &right) {
- return hashkit_compare(&left.self, &right.self);
- }
-
- uint32_t digest(std::string &str) { return hashkit_digest(&self, str.c_str(), str.length()); }
-
- uint32_t digest(const char *key, size_t key_length) {
- return hashkit_digest(&self, key, key_length);
- }
-
- hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) {
- return hashkit_set_function(&self, hash_algorithm);
- }
-
- hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_algorithm) {
- return hashkit_set_distribution_function(&self, hash_algorithm);
- }
-
- ~Hashkit() { hashkit_free(&self); }
-
-private:
- hashkit_st self;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-const char *libhashkit_string_hash(hashkit_hash_algorithm_t type);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-struct hashkit_string_st;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HASHKIT_API
-void hashkit_string_free(hashkit_string_st *ptr);
-
-HASHKIT_API
-size_t hashkit_string_length(const hashkit_string_st *self);
-
-HASHKIT_API
-const char *hashkit_string_c_str(const hashkit_string_st *self);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-typedef enum {
- HASHKIT_SUCCESS,
- HASHKIT_FAILURE,
- HASHKIT_MEMORY_ALLOCATION_FAILURE,
- HASHKIT_INVALID_HASH,
- HASHKIT_INVALID_ARGUMENT,
- HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
-} hashkit_return_t;
-
-static inline bool hashkit_success(const hashkit_return_t rc) {
- return (rc == HASHKIT_SUCCESS);
-}
-
-static inline bool hashkit_failed(const hashkit_return_t rc) {
- return (rc != HASHKIT_SUCCESS);
-}
-
-typedef enum {
- HASHKIT_HASH_DEFAULT = 0, // hashkit_one_at_a_time()
- HASHKIT_HASH_MD5,
- HASHKIT_HASH_CRC,
- HASHKIT_HASH_FNV1_64,
- HASHKIT_HASH_FNV1A_64,
- HASHKIT_HASH_FNV1_32,
- HASHKIT_HASH_FNV1A_32,
- HASHKIT_HASH_HSIEH,
- HASHKIT_HASH_MURMUR,
- HASHKIT_HASH_JENKINS,
- HASHKIT_HASH_MURMUR3,
- HASHKIT_HASH_CUSTOM,
- HASHKIT_HASH_MAX
-} hashkit_hash_algorithm_t;
-
-/**
- * Hash distributions that are available to use.
- */
-typedef enum {
- HASHKIT_DISTRIBUTION_MODULA,
- HASHKIT_DISTRIBUTION_RANDOM,
- HASHKIT_DISTRIBUTION_KETAMA,
- HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
-} hashkit_distribution_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct hashkit_st hashkit_st;
-typedef struct hashkit_string_st hashkit_string_st;
-
-typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-/**
- *
- * HASHKIT_API is used for the public API symbols. It either DLL imports or
- * DLL exports (or does nothing for static build).
- *
- * HASHKIT_LOCAL is used for non-api symbols.
- */
-
-#if defined(BUILDING_HASHKIT)
-# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
-# define HASHKIT_API __attribute__((visibility("default")))
-# define HASHKIT_LOCAL __attribute__((visibility("hidden")))
-# elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-# define HASHKIT_API __global
-# define HASHKIT_LOCAL __hidden
-# elif defined(_MSC_VER)
-# define HASHKIT_API extern __declspec(dllexport)
-# define HASHKIT_LOCAL
-# else
-# define HASHKIT_API
-# define HASHKIT_LOCAL
-# endif /* defined(HAVE_VISIBILITY) */
-#else /* defined(BUILDING_HASHKIT) */
-# if defined(_MSC_VER)
-# define HASHKIT_API extern __declspec(dllimport)
-# define HASHKIT_LOCAL
-# else
-# define HASHKIT_API
-# define HASHKIT_LOCAL
-# endif /* defined(_MSC_VER) */
-#endif /* defined(BUILDING_HASHKIT) */
--- /dev/null
+
+install_public_headers(libhashkit-1
+ @configure.h
+ algorithm.h
+ basic_string.h
+ behavior.h
+ digest.h
+ function.h
+ has.h
+ hashkit.h
+ hashkit.hpp
+ str_algorithm.h
+ strerror.h
+ string.h
+ types.h
+ visibility.h
+ )
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_fnv1_64(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_fnv1a_64(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_fnv1_32(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_fnv1a_32(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_crc32(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_hsieh(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_murmur(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_murmur3(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_jenkins(const char *key, size_t key_length);
+
+HASHKIT_API
+uint32_t libhashkit_md5(const char *key, size_t key_length);
+
+HASHKIT_API
+void libhashkit_md5_signature(const unsigned char *key, size_t length, unsigned char *result);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+// No assumptions of NULL should be made
+
+#define hashkit_size(X) (X).size;
+#define hashkit_c_str(X) (X).c_str;
+#define hashkit_string_param(X) (X).c_str, (X).size
+
+#ifdef __cplusplus
+# define hashkit_string_printf(X) int((X).size), (X).c_str
+#else
+# define hashkit_string_printf(X) (int) ((X).size), (X).c_str
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#define LIBHASHKIT_VERSION_STRING "@LIBHASHKIT_VERSION@"
+#define LIBHASHKIT_VERSION_HEX @LIBHASHKIT_VERSION_HEX@
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_length);
+
+/**
+ This is a utilitly function provided so that you can directly access hashes with a hashkit_st.
+*/
+
+HASHKIT_API
+uint32_t libhashkit_digest(const char *key, size_t key_length,
+ hashkit_hash_algorithm_t hash_algorithm);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ This sets/gets the default function we will be using.
+*/
+HASHKIT_API
+hashkit_return_t hashkit_set_function(hashkit_st *hash, hashkit_hash_algorithm_t hash_algorithm);
+
+HASHKIT_API
+hashkit_return_t hashkit_set_custom_function(hashkit_st *hash, hashkit_hash_fn function,
+ void *context);
+
+HASHKIT_API
+hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash);
+
+/**
+ This sets/gets the function we use for distribution.
+*/
+HASHKIT_API
+hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash,
+ hashkit_hash_algorithm_t hash_algorithm);
+
+HASHKIT_API
+hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st *self,
+ hashkit_hash_fn function, void *context);
+
+HASHKIT_API
+hashkit_hash_algorithm_t hashkit_get_distribution_function(const hashkit_st *self);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#if !defined(__cplusplus)
+# include <stdbool.h>
+# include <inttypes.h>
+#else
+# include <cinttypes>
+#endif
+#include <sys/types.h>
+
+#include <libhashkit-1/visibility.h>
+#include <libhashkit-1/configure.h>
+#include <libhashkit-1/types.h>
+#include <libhashkit-1/has.h>
+#include <libhashkit-1/algorithm.h>
+#include <libhashkit-1/behavior.h>
+#include <libhashkit-1/digest.h>
+#include <libhashkit-1/function.h>
+#include <libhashkit-1/str_algorithm.h>
+#include <libhashkit-1/strerror.h>
+#include <libhashkit-1/string.h>
+
+struct hashkit_st {
+ struct hashkit_function_st {
+ hashkit_hash_fn function;
+ void *context;
+ } base_hash, distribution_hash;
+
+ struct {
+ bool is_base_same_distributed : 1;
+ } flags;
+
+ struct {
+ bool is_allocated : 1;
+ } options;
+
+ void *_key;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+hashkit_st *hashkit_create(hashkit_st *hash);
+
+HASHKIT_API
+hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr);
+
+HASHKIT_API
+bool hashkit_compare(const hashkit_st *first, const hashkit_st *second);
+
+HASHKIT_API
+void hashkit_free(hashkit_st *hash);
+
+HASHKIT_API
+hashkit_string_st *hashkit_encrypt(hashkit_st *, const char *source, size_t source_length);
+
+HASHKIT_API
+hashkit_string_st *hashkit_decrypt(hashkit_st *, const char *source, size_t source_length);
+
+HASHKIT_API
+bool hashkit_key(hashkit_st *, const char *key, const size_t key_length);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include <libhashkit-1/hashkit.h>
+#include <string>
+
+class Hashkit {
+public:
+ Hashkit() { hashkit_create(&self); }
+
+ Hashkit(const Hashkit &source) { hashkit_clone(&self, &source.self); }
+
+ Hashkit &operator=(const Hashkit &source) {
+ hashkit_free(&self);
+ hashkit_clone(&self, &source.self);
+
+ return *this;
+ }
+
+ friend bool operator==(const Hashkit &left, const Hashkit &right) {
+ return hashkit_compare(&left.self, &right.self);
+ }
+
+ uint32_t digest(std::string &str) { return hashkit_digest(&self, str.c_str(), str.length()); }
+
+ uint32_t digest(const char *key, size_t key_length) {
+ return hashkit_digest(&self, key, key_length);
+ }
+
+ hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) {
+ return hashkit_set_function(&self, hash_algorithm);
+ }
+
+ hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_algorithm) {
+ return hashkit_set_distribution_function(&self, hash_algorithm);
+ }
+
+ ~Hashkit() { hashkit_free(&self); }
+
+private:
+ hashkit_st self;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+const char *libhashkit_string_hash(hashkit_hash_algorithm_t type);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+struct hashkit_string_st;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HASHKIT_API
+void hashkit_string_free(hashkit_string_st *ptr);
+
+HASHKIT_API
+size_t hashkit_string_length(const hashkit_string_st *self);
+
+HASHKIT_API
+const char *hashkit_string_c_str(const hashkit_string_st *self);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+typedef enum {
+ HASHKIT_SUCCESS,
+ HASHKIT_FAILURE,
+ HASHKIT_MEMORY_ALLOCATION_FAILURE,
+ HASHKIT_INVALID_HASH,
+ HASHKIT_INVALID_ARGUMENT,
+ HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
+} hashkit_return_t;
+
+static inline bool hashkit_success(const hashkit_return_t rc) {
+ return (rc == HASHKIT_SUCCESS);
+}
+
+static inline bool hashkit_failed(const hashkit_return_t rc) {
+ return (rc != HASHKIT_SUCCESS);
+}
+
+typedef enum {
+ HASHKIT_HASH_DEFAULT = 0, // hashkit_one_at_a_time()
+ HASHKIT_HASH_MD5,
+ HASHKIT_HASH_CRC,
+ HASHKIT_HASH_FNV1_64,
+ HASHKIT_HASH_FNV1A_64,
+ HASHKIT_HASH_FNV1_32,
+ HASHKIT_HASH_FNV1A_32,
+ HASHKIT_HASH_HSIEH,
+ HASHKIT_HASH_MURMUR,
+ HASHKIT_HASH_JENKINS,
+ HASHKIT_HASH_MURMUR3,
+ HASHKIT_HASH_CUSTOM,
+ HASHKIT_HASH_MAX
+} hashkit_hash_algorithm_t;
+
+/**
+ * Hash distributions that are available to use.
+ */
+typedef enum {
+ HASHKIT_DISTRIBUTION_MODULA,
+ HASHKIT_DISTRIBUTION_RANDOM,
+ HASHKIT_DISTRIBUTION_KETAMA,
+ HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
+} hashkit_distribution_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct hashkit_st hashkit_st;
+typedef struct hashkit_string_st hashkit_string_st;
+
+typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+/**
+ *
+ * HASHKIT_API is used for the public API symbols. It either DLL imports or
+ * DLL exports (or does nothing for static build).
+ *
+ * HASHKIT_LOCAL is used for non-api symbols.
+ */
+
+#if defined(BUILDING_HASHKIT)
+# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
+# define HASHKIT_API __attribute__((visibility("default")))
+# define HASHKIT_LOCAL __attribute__((visibility("hidden")))
+# elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define HASHKIT_API __global
+# define HASHKIT_LOCAL __hidden
+# elif defined(_MSC_VER)
+# define HASHKIT_API extern __declspec(dllexport)
+# define HASHKIT_LOCAL
+# else
+# define HASHKIT_API
+# define HASHKIT_LOCAL
+# endif /* defined(HAVE_VISIBILITY) */
+#else /* defined(BUILDING_HASHKIT) */
+# if defined(_MSC_VER)
+# define HASHKIT_API extern __declspec(dllimport)
+# define HASHKIT_LOCAL
+# else
+# define HASHKIT_API
+# define HASHKIT_LOCAL
+# endif /* defined(_MSC_VER) */
+#endif /* defined(BUILDING_HASHKIT) */
--- /dev/null
+libmemcached-1
\ No newline at end of file
+++ /dev/null
-
-add_subdirectory(struct)
-add_subdirectory(types)
-
-install_public_headers(
- libmemcached-1.0
-
- @configure.h
- alloc.h
- allocators.h
- analyze.h
- auto.h
- basic_string.h
- behavior.h
- callback.h
- callbacks.h
- defaults.h
- delete.h
- deprecated_types.h
- dump.h
- encoding_key.h
- error.h
- exception.hpp
- exist.h
- fetch.h
- flush_buffers.h
- flush.h
- get.h
- hash.h
- limits.h
- memcached.h
- memcached.hpp
- options.h
- parse.h
- platform.h
- quit.h
- result.h
- return.h
- sasl.h
- server.h
- server_list.h
- stats.h
- storage.h
- strerror.h
- touch.h
- triggers.h
- types.h
- verbosity.h
- version.h
- visibility.h
- )
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "libmemcached-1.0/struct/analysis.h"
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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,
- const memcached_instance_st *server,
- void *context);
-typedef memcached_return_t (*memcached_stat_fn)(const memcached_instance_st *server,
- const char *key, size_t key_length,
- const char *value, size_t value_length,
- void *context);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#cmakedefine01 LIBMEMCACHED_ENABLE_DEPRECATED
-#cmakedefine01 LIBMEMCACHED_WITH_SASL_SUPPORT
-
-#cmakedefine HAVE_VISIBILITY 1
-
-#cmakedefine HAVE_NETDB_H 1
-
-#cmakedefine HAVE_IN_PORT_T 1
-#cmakedefine HAVE_PID_T 1
-#cmakedefine HAVE_SSIZE_T 1
-
-#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION@"
-#define LIBMEMCACHED_VERSION_HEX @LIBMEMCACHED_VERSION_HEX@
-
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-/* Public defines */
-#define MEMCACHED_DEFAULT_PORT 11211
-#define MEMCACHED_DEFAULT_PORT_STRING "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
-#define MEMCACHED_SERVER_TIMEOUT_LIMIT 0
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
-typedef memcached_instance_st *memcached_server_instance_st;
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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_instance_st *ptr);
-
-LIBMEMCACHED_API
-memcached_return_t memcached_server_error_return(const memcached_instance_st *ptr);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include <stdexcept>
-#include <string>
-
-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 memcache
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-memcached_return_t memcached_flush_buffers(memcached_st *mem);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#define MEMCACHED_MAX_BUFFER 8196
-#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
-#define MEMCACHED_MAX_NAMESPACE 128
-
-#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */
-#define MEMCACHED_MAX_INTEGER_DISPLAY_LENGTH 20
-#define MEMCACHED_VERSION_STRING_LENGTH 24
-
-/* legacy */
-#define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH MEMCACHED_MAX_INTEGER_DISPLAY_LENGTH
-#define MEMCACHED_PREFIX_KEY_MAX_SIZE MEMCACHED_MAX_NAMESPACE
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/configure.h"
-#include "libmemcached-1.0/visibility.h"
-#include "libmemcached-1.0/platform.h"
-
-#include "libmemcached-1.0/limits.h"
-#include "libmemcached-1.0/defaults.h"
-
-#include "libmemcached-1.0/types/behavior.h"
-#include "libmemcached-1.0/types/callback.h"
-#include "libmemcached-1.0/types/connection.h"
-#include "libmemcached-1.0/types/hash.h"
-#include "libmemcached-1.0/types/return.h"
-#include "libmemcached-1.0/types/server_distribution.h"
-
-#include "libmemcached-1.0/return.h"
-
-#include "libmemcached-1.0/types.h"
-#include "libmemcached-1.0/callbacks.h"
-#include "libmemcached-1.0/alloc.h"
-#include "libmemcached-1.0/triggers.h"
-
-#include "libhashkit-1.0/hashkit.h"
-
-#include "libmemcached-1.0/struct/callback.h"
-#include "libmemcached-1.0/struct/string.h"
-#include "libmemcached-1.0/struct/result.h"
-#include "libmemcached-1.0/struct/allocator.h"
-#include "libmemcached-1.0/struct/sasl.h"
-#include "libmemcached-1.0/struct/memcached.h"
-#include "libmemcached-1.0/struct/server.h"
-#include "libmemcached-1.0/struct/stat.h"
-
-#include "libmemcached-1.0/basic_string.h"
-#include "libmemcached-1.0/error.h"
-#include "libmemcached-1.0/stats.h"
-
-// Everything above this line must be in the order specified.
-#include "libmemcached-1.0/allocators.h"
-#include "libmemcached-1.0/analyze.h"
-#include "libmemcached-1.0/auto.h"
-#include "libmemcached-1.0/behavior.h"
-#include "libmemcached-1.0/callback.h"
-#include "libmemcached-1.0/delete.h"
-#include "libmemcached-1.0/dump.h"
-#include "libmemcached-1.0/encoding_key.h"
-#include "libmemcached-1.0/exist.h"
-#include "libmemcached-1.0/fetch.h"
-#include "libmemcached-1.0/flush.h"
-#include "libmemcached-1.0/flush_buffers.h"
-#include "libmemcached-1.0/get.h"
-#include "libmemcached-1.0/hash.h"
-#include "libmemcached-1.0/options.h"
-#include "libmemcached-1.0/parse.h"
-#include "libmemcached-1.0/quit.h"
-#include "libmemcached-1.0/result.h"
-#include "libmemcached-1.0/server.h"
-#include "libmemcached-1.0/server_list.h"
-#include "libmemcached-1.0/storage.h"
-#include "libmemcached-1.0/strerror.h"
-#include "libmemcached-1.0/touch.h"
-#include "libmemcached-1.0/verbosity.h"
-#include "libmemcached-1.0/version.h"
-#include "libmemcached-1.0/sasl.h"
-
-#include "libmemcached-1.0/deprecated_types.h"
-
-#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
-const memcached_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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/memcached.h"
-#if 0
-# include "libmemcached/exception.hpp"
-#endif
-
-#include <cstring>
-#include <sstream>
-#include <string>
-#include <vector>
-#include <map>
-
-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<char> &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<char> &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<char> &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<char> &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<std::string> &keys) {
- std::vector<const char *> real_keys;
- std::vector<size_t> 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<std::string>::const_iterator it = keys.begin();
-
- while (it != keys.end()) {
- real_keys.push_back(const_cast<char *>((*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<char> &value, time_t expiration,
- uint32_t flags) {
- memcached_return_t rc = memcached_set(memc_, key.c_str(), key.length(), value.data(),
- 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<char> &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<std::string> &keys, const std::vector<std::vector<char> *> &values,
- time_t expiration, uint32_t flags) {
- bool retval = true;
- std::vector<std::string>::const_iterator key_it = keys.begin();
- std::vector<std::vector<char> *>::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<const std::string, std::vector<char>> &key_value_map,
- time_t expiration, uint32_t flags) {
- std::map<const std::string, std::vector<char>>::const_iterator it = key_value_map.begin();
-
- while (it != key_value_map.end()) {
- if (!set(it->first, it->second, expiration, flags)) {
- // 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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<std::string, std::string>> &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++) {
- const memcached_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<std::string, std::string> 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_;
-};
-
-} // namespace memcache
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-memcached_server_list_st memcached_servers_parse(const char *server_strings);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/configure.h"
-
-/* 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 <cinttypes>
-# include <cstddef>
-# include <cstdlib>
-#else
-# include <inttypes.h>
-# include <stddef.h>
-# include <stdlib.h>
-# include <stdbool.h>
-#endif
-
-#include <sys/types.h>
-
-#if defined HAVE_NETDB_H
-# include <netdb.h>
-#endif
-
-#if !defined HAVE_IN_PORT_T
-typedef int in_port_t;
-#endif
-
-#if !defined HAVE_PID_T
-typedef int pid_t;
-#endif
-
-#ifndef HAVE_SSIZE_T
-typedef long int ssize_t;
-#endif
-
-#if defined _WIN32
-# include <winsock2.h>
-# include <ws2tcpip.h>
-typedef SOCKET memcached_socket_t;
-#else
-typedef int memcached_socket_t;
-#endif // _WIN32
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-void memcached_quit(memcached_st *ptr);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "libmemcached-1.0/struct/result.h"
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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_AUTH_CONTINUE && 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_fatal(memcached_return_t rc) {
- return (rc != MEMCACHED_AUTH_CONTINUE && rc != MEMCACHED_BUFFERED && rc != MEMCACHED_CLIENT_ERROR
- && 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)
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
-# include <sasl/sasl.h>
-#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 "libmemcached-1.0/struct/sasl.h"
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/struct/server.h"
-
-#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
-const memcached_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
-const memcached_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_instance_st *self);
-
-LIBMEMCACHED_API
-const char *memcached_server_name(const memcached_instance_st *self);
-
-LIBMEMCACHED_API
-in_port_t memcached_server_port(const memcached_instance_st *self);
-
-LIBMEMCACHED_API
-in_port_t memcached_server_srcport(const memcached_instance_st *self);
-
-LIBMEMCACHED_API
-void memcached_instance_next_retry(const memcached_instance_st *self, const time_t absolute_time);
-
-LIBMEMCACHED_API
-const char *memcached_server_type(const memcached_instance_st *ptr);
-
-LIBMEMCACHED_API
-uint8_t memcached_server_major_version(const memcached_instance_st *ptr);
-
-LIBMEMCACHED_API
-uint8_t memcached_server_minor_version(const memcached_instance_st *ptr);
-
-LIBMEMCACHED_API
-uint8_t memcached_server_micro_version(const memcached_instance_st *ptr);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#include "libmemcached-1.0/struct/stat.h"
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-const char *memcached_strerror(const memcached_st *ptr, memcached_return_t rc);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-
-install_public_headers(
- libmemcached-1.0/struct
-
- allocator.h
- analysis.h
- callback.h
- memcached.h
- result.h
- sasl.h
- server.h
- stat.h
- string.h
-)
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-struct memcached_allocator_t {
- memcached_calloc_fn calloc;
- memcached_free_fn free;
- memcached_malloc_fn malloc;
- memcached_realloc_fn realloc;
- void *context;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-struct memcached_callback_st {
- memcached_execute_fn *callback;
- void *context;
- uint32_t number_of_callback;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
- memcached_instance_st *servers;
- memcached_instance_st *last_disconnected_server;
- int32_t snd_timeout;
- int32_t rcv_timeout;
- uint32_t server_failure_limit;
- uint32_t server_timeout_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;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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 */
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
-# include <sasl/sasl.h>
-#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;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/configure.h"
-
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#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 server_timeout_counter;
- uint64_t server_timeout_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];
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
-};
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-
-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 struct memcached_instance_st memcached_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 struct memcached_instance_st memcached_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
+++ /dev/null
-
-install_public_headers(
- libmemcached-1.0/types
-
- behavior.h
- callback.h
- connection.h
- hash.h
- return.h
- server_distribution.h
- )
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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_SERVER_TIMEOUT_LIMIT,
- MEMCACHED_BEHAVIOR_MAX
-};
-
-#ifndef __cplusplus
-typedef enum memcached_behavior_t memcached_behavior_t;
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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_MURMUR3,
- MEMCACHED_HASH_CUSTOM,
- MEMCACHED_HASH_MAX
-};
-
-#ifndef __cplusplus
-typedef enum memcached_hash_t memcached_hash_t;
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBMEMCACHED_API
-memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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) */
--- /dev/null
+
+add_subdirectory(struct)
+add_subdirectory(types)
+
+install_public_headers(
+ libmemcached-1
+
+ @configure.h
+ alloc.h
+ allocators.h
+ analyze.h
+ auto.h
+ basic_string.h
+ behavior.h
+ callback.h
+ callbacks.h
+ defaults.h
+ delete.h
+ deprecated_types.h
+ dump.h
+ encoding_key.h
+ error.h
+ exception.hpp
+ exist.h
+ fetch.h
+ flush_buffers.h
+ flush.h
+ get.h
+ hash.h
+ limits.h
+ memcached.h
+ memcached.hpp
+ options.h
+ parse.h
+ platform.h
+ quit.h
+ result.h
+ return.h
+ sasl.h
+ server.h
+ server_list.h
+ stats.h
+ storage.h
+ strerror.h
+ touch.h
+ triggers.h
+ types.h
+ verbosity.h
+ version.h
+ visibility.h
+ )
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#include "libmemcached-1/struct/analysis.h"
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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,
+ const memcached_instance_st *server,
+ void *context);
+typedef memcached_return_t (*memcached_stat_fn)(const memcached_instance_st *server,
+ const char *key, size_t key_length,
+ const char *value, size_t value_length,
+ void *context);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#cmakedefine01 LIBMEMCACHED_ENABLE_DEPRECATED
+#cmakedefine01 LIBMEMCACHED_WITH_SASL_SUPPORT
+
+#cmakedefine HAVE_VISIBILITY 1
+
+#cmakedefine HAVE_NETDB_H 1
+
+#cmakedefine HAVE_IN_PORT_T 1
+#cmakedefine HAVE_PID_T 1
+#cmakedefine HAVE_SSIZE_T 1
+
+#define LIBMEMCACHED_VERSION_STRING "@LIBMEMCACHED_VERSION@"
+#define LIBMEMCACHED_VERSION_HEX @LIBMEMCACHED_VERSION_HEX@
+
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+/* Public defines */
+#define MEMCACHED_DEFAULT_PORT 11211
+#define MEMCACHED_DEFAULT_PORT_STRING "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
+#define MEMCACHED_SERVER_TIMEOUT_LIMIT 0
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+typedef memcached_instance_st *memcached_server_instance_st;
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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_instance_st *ptr);
+
+LIBMEMCACHED_API
+memcached_return_t memcached_server_error_return(const memcached_instance_st *ptr);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include <stdexcept>
+#include <string>
+
+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 memcache
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+memcached_return_t memcached_flush_buffers(memcached_st *mem);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#define MEMCACHED_MAX_BUFFER 8196
+#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
+#define MEMCACHED_MAX_NAMESPACE 128
+
+#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */
+#define MEMCACHED_MAX_INTEGER_DISPLAY_LENGTH 20
+#define MEMCACHED_VERSION_STRING_LENGTH 24
+
+/* legacy */
+#define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH MEMCACHED_MAX_INTEGER_DISPLAY_LENGTH
+#define MEMCACHED_PREFIX_KEY_MAX_SIZE MEMCACHED_MAX_NAMESPACE
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/configure.h"
+#include "libmemcached-1/visibility.h"
+#include "libmemcached-1/platform.h"
+
+#include "libmemcached-1/limits.h"
+#include "libmemcached-1/defaults.h"
+
+#include "libmemcached-1/types/behavior.h"
+#include "libmemcached-1/types/callback.h"
+#include "libmemcached-1/types/connection.h"
+#include "libmemcached-1/types/hash.h"
+#include "libmemcached-1/types/return.h"
+#include "libmemcached-1/types/server_distribution.h"
+
+#include "libmemcached-1/return.h"
+
+#include "libmemcached-1/types.h"
+#include "libmemcached-1/callbacks.h"
+#include "libmemcached-1/alloc.h"
+#include "libmemcached-1/triggers.h"
+
+#include "libhashkit-1/hashkit.h"
+
+#include "libmemcached-1/struct/callback.h"
+#include "libmemcached-1/struct/string.h"
+#include "libmemcached-1/struct/result.h"
+#include "libmemcached-1/struct/allocator.h"
+#include "libmemcached-1/struct/sasl.h"
+#include "libmemcached-1/struct/memcached.h"
+#include "libmemcached-1/struct/server.h"
+#include "libmemcached-1/struct/stat.h"
+
+#include "libmemcached-1/basic_string.h"
+#include "libmemcached-1/error.h"
+#include "libmemcached-1/stats.h"
+
+// Everything above this line must be in the order specified.
+#include "libmemcached-1/allocators.h"
+#include "libmemcached-1/analyze.h"
+#include "libmemcached-1/auto.h"
+#include "libmemcached-1/behavior.h"
+#include "libmemcached-1/callback.h"
+#include "libmemcached-1/delete.h"
+#include "libmemcached-1/dump.h"
+#include "libmemcached-1/encoding_key.h"
+#include "libmemcached-1/exist.h"
+#include "libmemcached-1/fetch.h"
+#include "libmemcached-1/flush.h"
+#include "libmemcached-1/flush_buffers.h"
+#include "libmemcached-1/get.h"
+#include "libmemcached-1/hash.h"
+#include "libmemcached-1/options.h"
+#include "libmemcached-1/parse.h"
+#include "libmemcached-1/quit.h"
+#include "libmemcached-1/result.h"
+#include "libmemcached-1/server.h"
+#include "libmemcached-1/server_list.h"
+#include "libmemcached-1/storage.h"
+#include "libmemcached-1/strerror.h"
+#include "libmemcached-1/touch.h"
+#include "libmemcached-1/verbosity.h"
+#include "libmemcached-1/version.h"
+#include "libmemcached-1/sasl.h"
+
+#include "libmemcached-1/deprecated_types.h"
+
+#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
+const memcached_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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/memcached.h"
+#if 0
+# include "libmemcached/exception.hpp"
+#endif
+
+#include <cstring>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <map>
+
+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<char> &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<char> &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<char> &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<char> &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<std::string> &keys) {
+ std::vector<const char *> real_keys;
+ std::vector<size_t> 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<std::string>::const_iterator it = keys.begin();
+
+ while (it != keys.end()) {
+ real_keys.push_back(const_cast<char *>((*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<char> &value, time_t expiration,
+ uint32_t flags) {
+ memcached_return_t rc = memcached_set(memc_, key.c_str(), key.length(), value.data(),
+ 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<char> &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<std::string> &keys, const std::vector<std::vector<char> *> &values,
+ time_t expiration, uint32_t flags) {
+ bool retval = true;
+ std::vector<std::string>::const_iterator key_it = keys.begin();
+ std::vector<std::vector<char> *>::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<const std::string, std::vector<char>> &key_value_map,
+ time_t expiration, uint32_t flags) {
+ std::map<const std::string, std::vector<char>>::const_iterator it = key_value_map.begin();
+
+ while (it != key_value_map.end()) {
+ if (!set(it->first, it->second, expiration, flags)) {
+ // 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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<char> &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<std::string, std::string>> &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++) {
+ const memcached_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<std::string, std::string> 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_;
+};
+
+} // namespace memcache
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+memcached_server_list_st memcached_servers_parse(const char *server_strings);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/configure.h"
+
+/* 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 <cinttypes>
+# include <cstddef>
+# include <cstdlib>
+#else
+# include <inttypes.h>
+# include <stddef.h>
+# include <stdlib.h>
+# include <stdbool.h>
+#endif
+
+#include <sys/types.h>
+
+#if defined HAVE_NETDB_H
+# include <netdb.h>
+#endif
+
+#if !defined HAVE_IN_PORT_T
+typedef int in_port_t;
+#endif
+
+#if !defined HAVE_PID_T
+typedef int pid_t;
+#endif
+
+#ifndef HAVE_SSIZE_T
+typedef long int ssize_t;
+#endif
+
+#if defined _WIN32
+# include <winsock2.h>
+# include <ws2tcpip.h>
+typedef SOCKET memcached_socket_t;
+#else
+typedef int memcached_socket_t;
+#endif // _WIN32
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+void memcached_quit(memcached_st *ptr);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#include "libmemcached-1/struct/result.h"
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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_AUTH_CONTINUE && 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_fatal(memcached_return_t rc) {
+ return (rc != MEMCACHED_AUTH_CONTINUE && rc != MEMCACHED_BUFFERED && rc != MEMCACHED_CLIENT_ERROR
+ && 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)
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+# include <sasl/sasl.h>
+#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 "libmemcached-1/struct/sasl.h"
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/struct/server.h"
+
+#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
+const memcached_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
+const memcached_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_instance_st *self);
+
+LIBMEMCACHED_API
+const char *memcached_server_name(const memcached_instance_st *self);
+
+LIBMEMCACHED_API
+in_port_t memcached_server_port(const memcached_instance_st *self);
+
+LIBMEMCACHED_API
+in_port_t memcached_server_srcport(const memcached_instance_st *self);
+
+LIBMEMCACHED_API
+void memcached_instance_next_retry(const memcached_instance_st *self, const time_t absolute_time);
+
+LIBMEMCACHED_API
+const char *memcached_server_type(const memcached_instance_st *ptr);
+
+LIBMEMCACHED_API
+uint8_t memcached_server_major_version(const memcached_instance_st *ptr);
+
+LIBMEMCACHED_API
+uint8_t memcached_server_minor_version(const memcached_instance_st *ptr);
+
+LIBMEMCACHED_API
+uint8_t memcached_server_micro_version(const memcached_instance_st *ptr);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#include "libmemcached-1/struct/stat.h"
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+const char *memcached_strerror(const memcached_st *ptr, memcached_return_t rc);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+
+install_public_headers(
+ libmemcached-1/struct
+
+ allocator.h
+ analysis.h
+ callback.h
+ memcached.h
+ result.h
+ sasl.h
+ server.h
+ stat.h
+ string.h
+)
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+struct memcached_allocator_t {
+ memcached_calloc_fn calloc;
+ memcached_free_fn free;
+ memcached_malloc_fn malloc;
+ memcached_realloc_fn realloc;
+ void *context;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+struct memcached_callback_st {
+ memcached_execute_fn *callback;
+ void *context;
+ uint32_t number_of_callback;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+ memcached_instance_st *servers;
+ memcached_instance_st *last_disconnected_server;
+ int32_t snd_timeout;
+ int32_t rcv_timeout;
+ uint32_t server_failure_limit;
+ uint32_t server_timeout_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;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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 */
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+# include <sasl/sasl.h>
+#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;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/configure.h"
+
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#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 server_timeout_counter;
+ uint64_t server_timeout_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];
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+};
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+
+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 struct memcached_instance_st memcached_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 struct memcached_instance_st memcached_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
--- /dev/null
+
+install_public_headers(
+ libmemcached-1/types
+
+ behavior.h
+ callback.h
+ connection.h
+ hash.h
+ return.h
+ server_distribution.h
+ )
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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_SERVER_TIMEOUT_LIMIT,
+ MEMCACHED_BEHAVIOR_MAX
+};
+
+#ifndef __cplusplus
+typedef enum memcached_behavior_t memcached_behavior_t;
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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_MURMUR3,
+ MEMCACHED_HASH_CUSTOM,
+ MEMCACHED_HASH_MAX
+};
+
+#ifndef __cplusplus
+typedef enum memcached_hash_t memcached_hash_t;
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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) */
--- /dev/null
+libmemcachedprotocol-0
\ No newline at end of file
+++ /dev/null
-
-install_public_headers(
- libmemcachedprotocol-0.0
-
- binary.h
- callback.h
- handler.h
- vbucket.h
-)
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#ifndef PROTOCOL_BINARY_H
-#define PROTOCOL_BINARY_H
-
-#include "libmemcachedprotocol-0.0/vbucket.h"
-
-/**
- * \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
-# include <cstdint>
-extern "C" {
-#else
-# include <stdint.h>
-#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 */
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifdef __cplusplus
-# include <cstdint>
-extern "C" {
-#else
-# include <stdint.h>
-#endif
-
-#ifdef _MSC_VER
-# undef interface
-#endif
-
-/**
- * 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
- * <u>anything</u> 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 <b>existing</b> 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 <b>existing</b> 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 <b>existing</b> 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 <b>must</b> 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 <b>must</b> 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 <b>must</b>
- * 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;
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include <sys/types.h>
-#ifndef HAVE_SSIZE_T
-typedef long int ssize_t;
-#endif
-
-#ifndef __cplusplus
-# include <stdbool.h>
-# include <stdint.h>
-# include <stddef.h>
-#else
-# include <cstdint>
-#endif
-
-#include "libmemcached-1.0/visibility.h"
-#include "libmemcached-1.0/platform.h"
-#include "libmemcachedprotocol-0.0/binary.h"
-#include "libmemcachedprotocol-0.0/callback.h"
-
-/* 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
- * <b>before</b> 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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
--- /dev/null
+
+install_public_headers(
+ libmemcachedprotocol-0
+
+ binary.h
+ callback.h
+ handler.h
+ vbucket.h
+)
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#ifndef PROTOCOL_BINARY_H
+#define PROTOCOL_BINARY_H
+
+#include "libmemcachedprotocol-0/vbucket.h"
+
+/**
+ * \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
+# include <cstdint>
+extern "C" {
+#else
+# include <stdint.h>
+#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 */
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifdef __cplusplus
+# include <cstdint>
+extern "C" {
+#else
+# include <stdint.h>
+#endif
+
+#ifdef _MSC_VER
+# undef interface
+#endif
+
+/**
+ * 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
+ * <u>anything</u> 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 <b>existing</b> 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 <b>existing</b> 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 <b>existing</b> 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 <b>must</b> 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 <b>must</b> 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 <b>must</b>
+ * 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;
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include <sys/types.h>
+#ifndef HAVE_SSIZE_T
+typedef long int ssize_t;
+#endif
+
+#ifndef __cplusplus
+# include <stdbool.h>
+# include <stdint.h>
+# include <stddef.h>
+#else
+# include <cstdint>
+#endif
+
+#include "libmemcached-1/visibility.h"
+#include "libmemcached-1/platform.h"
+#include "libmemcachedprotocol-0/binary.h"
+#include "libmemcachedprotocol-0/callback.h"
+
+/* 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
+ * <b>before</b> 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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+libmemcachedutil-1
\ No newline at end of file
+++ /dev/null
-
-install_public_headers(
- libmemcachedutil-1.0
-
- flush.h
- ostream.hpp
- pid.h
- ping.h
- pool.h
- util.h
- version.h
- )
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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;
-}
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#ifndef _WIN32
-# include <netdb.h>
-#endif
-
-#include <sys/types.h>
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/memcached.h"
-
-#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
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#pragma once
-
-#include "libmemcached-1.0/memcached.h"
-
-#include "libmemcachedutil-1.0/pid.h"
-#include "libmemcachedutil-1.0/flush.h"
-#include "libmemcachedutil-1.0/ping.h"
-#include "libmemcachedutil-1.0/pool.h"
-#include "libmemcachedutil-1.0/version.h"
+++ /dev/null
-/*
- +--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
- +--------------------------------------------------------------------+
- | Redistribution and use in source and binary forms, with or without |
- | modification, are permitted under the terms of the BSD license. |
- | You should have received a copy of the license in a bundled file |
- | named LICENSE; in case you did not receive a copy you can review |
- | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
- +--------------------------------------------------------------------+
- | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
- +--------------------------------------------------------------------+
-*/
-
-#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
--- /dev/null
+
+install_public_headers(
+ libmemcachedutil-1
+
+ flush.h
+ ostream.hpp
+ pid.h
+ ping.h
+ pool.h
+ util.h
+ version.h
+ )
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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;
+}
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#ifndef _WIN32
+# include <netdb.h>
+#endif
+
+#include <sys/types.h>
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/memcached.h"
+
+#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
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#pragma once
+
+#include "libmemcached-1/memcached.h"
+
+#include "libmemcachedutil-1/pid.h"
+#include "libmemcachedutil-1/flush.h"
+#include "libmemcachedutil-1/ping.h"
+#include "libmemcachedutil-1/pool.h"
+#include "libmemcachedutil-1/version.h"
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | libmemcached - C/C++ Client Library for memcached |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted under the terms of the BSD license. |
+ | You should have received a copy of the license in a bundled file |
+ | named LICENSE; in case you did not receive a copy you can review |
+ | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
+ | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#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
#include "p9y/socket.hpp"
#include "p9y/poll.hpp"
-#include "libmemcached-1.0/memcached.h"
-#include "libmemcachedprotocol-0.0/binary.h"
+#include "libmemcached-1/memcached.h"
+#include "libmemcachedprotocol-0/binary.h"
#include "libmemcached/byteorder.h"
#include <vector>
#include <cstring>
#include <iostream>
-#include "libmemcached-1.0/memcached.h"
+#include "libmemcached-1/memcached.h"
int main(int argc, char *argv[]) {
if (argc < 2) {
# endif
#endif
-#include "libhashkit-1.0/hashkit.h"
+#include "libhashkit-1/hashkit.h"
#include "libhashkit/algorithm.h"
#include "libhashkit/is.h"
#include "libhashkit/string.h"
#pragma once
-#include "libhashkit-1.0/hashkit.h"
+#include "libhashkit-1/hashkit.h"
# include <dlfcn.h>
#endif
-#include "libmemcached-1.0/memcached.h"
+#include "libmemcached-1/memcached.h"
#include "libmemcached/watchpoint.h"
#include "libmemcached/is.h"
typedef struct memcached_st Memcached;
#include "libmemcached/io.h"
#ifdef __cplusplus
# include "libmemcached/string.hpp"
-# include "libmemcachedprotocol-0.0/binary.h"
+# include "libmemcachedprotocol-0/binary.h"
# include "libmemcached/io.hpp"
# include "libmemcached/udp.hpp"
# include "libmemcached/do.hpp"
#pragma once
-#include "libmemcached-1.0/memcached.h"
+#include "libmemcached-1/memcached.h"
#pragma once
-#include "libmemcached-1.0/memcached.hpp"
+#include "libmemcached-1/memcached.hpp"
#pragma once
-#include "libmemcachedutil-1.0/util.h"
+#include "libmemcachedutil-1/util.h"
#include "mem_config.h"
#include <assert.h>
-#include "libmemcachedprotocol-0.0/handler.h"
+#include "libmemcachedprotocol-0/handler.h"
#include "libmemcachedprotocol/cache.h"
#include "libmemcached/byteorder.h"
#include <cstdio>
#include <ciso646>
-#include "libmemcachedutil-1.0/util.h"
+#include "libmemcachedutil-1/util.h"
#include "libmemcached/assert.hpp"
#include "libmemcached/backtrace.hpp"
#pragma once
-#include "libmemcached-1.0/platform.h"
+#include "libmemcached-1/platform.h"
#include <time.h>
#if defined HAVE_SYS_TIME_H
#pragma once
-#include "libmemcached-1.0/platform.h"
+#include "libmemcached-1/platform.h"
#if defined HAVE_SYS_POLL_H
# include <sys/poll.h>
#pragma once
-#include "libmemcached-1.0/platform.h"
+#include "libmemcached-1/platform.h"
#if defined __cplusplus
# include <cerrno>
+++ /dev/null
-/* LibMemcached
- * Copyright (C) 2010 Brian Aker, Trond Norbye
- * All rights reserved.
- *
- * Use and distribution licensed under the BSD license. See
- * the COPYING file in the parent directory for full text.
- *
- * Summary: "Implementation" of the function we don't have on windows
- * to avoid a bunch of ifdefs in the rest of the code
- *
- */
-#pragma once
-
-#include <inttypes.h>
-
-/*
- * One of the Windows headers define interface as a macro, but that
- * is causing problems with the member named "interface" in some of the
- * structs.
- */
-#undef interface
-
-#undef malloc
-#undef realloc
-
-
-/*
- * WinSock use a separate range for error codes. Let's just map to the
- * WinSock ones.
- */
-#ifndef EADDRINUSE
-# define EADDRINUSE WSAEADDRINUSE
-#endif
-
-#ifndef EWOULDBLOCK
-# define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-
-#ifndef EINPROGRESS
-# define EINPROGRESS WSAEINPROGRESS
-#endif
-
-#ifndef EALREADY
-# define EALREADY WSAEALREADY
-#endif
-
-#ifndef EISCONN
-# define EISCONN WSAEISCONN
-#endif
-
-#ifndef ENOTCONN
-# define ENOTCONN WSAENOTCONN
-#endif
-
-#ifndef ENOBUFS
-# define ENOBUFS WSAENOBUFS
-#endif
-
-#ifndef SHUT_RDWR
-# define SHUT_RDWR SD_BOTH
-#endif
-#ifndef SHUT_WR
-# define SHUT_WR SD_SEND
-#endif
-#ifndef SHUT_RD
-# define SHUT_RD SD_RECEIVE
-#endif
-
-/* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */
-#ifndef EAI_SYSTEM
-# define EAI_SYSTEM 11
-#endif
-
-/* Best effort mapping of functions to alternative functions */
-#define index(a,b) strchr(a,b)
-#define rindex(a,b) strrchr(a,b)
-#define random() rand()
-#define srandom(a) while (false) {}
-#define kill(a, b) while (false) {}
-#define fork() (-1)
-#define waitpid(a,b,c) (-1)
-#define fnmatch(a,b,c) (-1)
-#define sleep(a) Sleep(a*1000)
-
-#ifdef __cplusplus
-# include <chrono>
-static inline int gettimeofday(struct timeval* tp, struct timezone* tzp) {
- using clock = std::chrono::system_clock;
- auto as_sec = [] (auto d) {
- return std::chrono::duration_cast<std::chrono::seconds>(d);
- };
- auto as_usec = [] (auto d) {
- return std::chrono::duration_cast<std::chrono::microseconds>(d);
- };
-
- auto now = clock::now().time_since_epoch();
- auto sec = as_sec(now);
- auto usec = as_usec(now - sec);
-
- tp->tv_sec = sec.count();
- tp->tv_usec = usec.count();
- return 0;
-}
-#endif
\ No newline at end of file
#serial 1
AC_DEFUN([AX_LIBMEMCACHED], [
- AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [
+ AC_CHECK_HEADER([libmemcached-1/memcached.h], [
AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [
AC_LANG_PUSH([C])
AX_SAVE_FLAGS
LIBS="-lmemcached $LIBS"
AC_RUN_IFELSE([
- AC_LANG_PROGRAM([#include <libmemcached-1.0/memcached.h>], [
+ AC_LANG_PROGRAM([#include <libmemcached-1/memcached.h>], [
memcached_st *memc;
memc= memcached(NULL, 0);
memcached_free(memc);
])
AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [
- AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h])
+ AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1/memcached.h])
],[
- AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h])
+ AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1/memcached.h])
])
])
AC_DEFUN([AX_LIBMEMCACHED_UTIL], [
AC_REQUIRE([AX_LIBMEMCACHED])
AS_IF([test "$ax_cv_libmemcached" = yes], [
- AC_CHECK_HEADER([libmemcachedutil-1.0/util.h], [
+ AC_CHECK_HEADER([libmemcachedutil-1/util.h], [
AC_CACHE_CHECK([check for -lmemcachedutil], [ax_cv_libmemcached_util], [
AX_SAVE_FLAGS
AC_LANG_PUSH([C])
LIBS="-lmemcachedutil -lmemcached $LIBS"
AC_RUN_IFELSE([
- AC_LANG_PROGRAM([#include <libmemcachedutil-1.0/util.h>], [
+ AC_LANG_PROGRAM([#include <libmemcachedutil-1/util.h>], [
memcached_pool_st *memc_pool= memcached_pool_create(NULL, 0, 3);
memcached_pool_destroy(memc_pool);
])],
])
AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
- AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h])
+ AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1/util.h])
],[
- AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h])
+ AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1/util.h])
])
])
#include "test/lib/common.hpp"
#include "test/fixtures/hashes.hpp"
-#include "libhashkit-1.0/hashkit.hpp"
+#include "libhashkit-1/hashkit.hpp"
TEST_CASE("hashkit") {
hashkit_st st, *hp = hashkit_create(nullptr);
#include "test/lib/common.hpp"
#include "test/lib/MemcachedCluster.hpp"
-#include "libmemcachedutil-1.0/pool.h"
+#include "libmemcachedutil-1/pool.h"
#include <atomic>
#include <sstream>
#include "test/lib/common.hpp"
-#include "libmemcachedutil-1.0/pool.h"
+#include "libmemcachedutil-1/pool.h"
#include <cassert>
struct test_pool_context_st {
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 2012-2013 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.
- *
- */
-
-
-#if defined(HAVE_UUID_UUID_H) && HAVE_UUID_UUID_H
-#include <uuid/uuid.h>
-#endif
-
-struct keys_st {
-public:
- keys_st(size_t arg)
- {
- init(arg, UUID_STRING_MAXLENGTH);
- }
-
- keys_st(size_t arg, size_t padding)
- {
- init(arg, padding);
- }
-
- void init(size_t arg, size_t padding)
- {
- _lengths.resize(arg);
- _keys.resize(arg);
-
- for (size_t x= 0; x < _keys.size(); x++)
- {
- libtest::vchar_t key_buffer;
- key_buffer.resize(padding +1);
- memset(&key_buffer[0], 'x', padding);
-
-#if defined(HAVE_UUID_UUID_H) && HAVE_UUID_UUID_H
- if (HAVE_UUID_UUID_H)
- {
- uuid_t out;
- uuid_generate(out);
-
- uuid_unparse(out, &key_buffer[0]);
- _keys[x]= strdup(&key_buffer[0]);
- (_keys[x])[UUID_STRING_MAXLENGTH]= 'x';
- }
- else // We just use a number and pad the string if UUID is not available
-#endif
- {
- char int_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(int_buffer, sizeof(int_buffer), "%u", uint32_t(x));
- memcpy(&key_buffer[0], int_buffer, key_length);
- _keys[x]= strdup(&key_buffer[0]);
- }
- _lengths[x]= padding;
- }
- }
-
- ~keys_st()
- {
- for (libtest::vchar_ptr_t::iterator iter= _keys.begin();
- iter != _keys.end();
- ++iter)
- {
- ::free(*iter);
- }
- }
-
- libtest::vchar_ptr_t::iterator begin()
- {
- return _keys.begin();
- }
-
- libtest::vchar_ptr_t::iterator end()
- {
- return _keys.end();
- }
-
- size_t size() const
- {
- return _keys.size();
- }
-
- std::vector<size_t>& lengths()
- {
- return _lengths;
- }
-
- libtest::vchar_ptr_t& keys()
- {
- return _keys;
- }
-
- size_t* lengths_ptr()
- {
- return &_lengths[0];
- }
-
- char** keys_ptr()
- {
- return &_keys[0];
- }
-
- char* key_at(size_t arg)
- {
- return _keys[arg];
- }
-
- size_t length_at(size_t arg)
- {
- return _lengths[arg];
- }
-
-private:
- libtest::vchar_ptr_t _keys;
- std::vector<size_t> _lengths;
-};
+++ /dev/null
-
-add_executable(internals internals.cc string.cc)
-target_link_libraries(internals PRIVATE libtest libmemcachedinternal Threads::Threads)
-add_test(internals internals)
-
-if(LIBMEMCACHED_WITH_SASL_SUPPORT)
- add_executable(testsasl
- basic.cc
- debug.cc
- deprecated.cc
- error_conditions.cc
- ketama.cc
- namespace.cc
- parser.cc
- pool.cc
- print.cc
- replication.cc
- sasl.cc
- virtual_buckets.cc
- callback_counter.cc
- fetch_all_results.cc
- generate.cc
- )
- target_link_libraries(testsasl PRIVATE
- libclient_utilities
- libhashkit
- libmemcached
- libmemcachedutil
- libtest
- Threads::Threads
- )
- add_test(testsasl testsasl)
-endif()
-
-add_executable(atomsmasher atomsmasher.cc)
-add_executable(testplus plus.cpp)
-
-foreach(TEST IN ITEMS atomsmasher testplus)
- target_sources(${TEST} PRIVATE
- callback_counter.cc
- debug.cc
- fetch_all_results.cc
- generate.cc
- print.cc
- )
- target_link_libraries(${TEST} PRIVATE
- libclient_utilities
- libhashkit
- libmemcached
- libmemcachedutil
- libtest
- )
- add_test(${TEST} ${TEST})
-endforeach()
-
-
-add_executable(testapp all_tests.cc)
-add_executable(testsocket all_tests_socket.cc)
-
-foreach(TEST IN ITEMS testapp testsocket)
- target_sources(${TEST} PRIVATE
- basic.cc
- callback_counter.cc
- callbacks.cc
- debug.cc
- deprecated.cc
- dump.cc
- encoding_key.cc
- error_conditions.cc
- exist.cc
- fetch_all_results.cc
- generate.cc
- haldenbrand.cc
- ketama.cc
- mem_functions.cc
- memcached_get.cc
- namespace.cc
- parser.cc
- pool.cc
- print.cc
- replication.cc
- server_add.cc
- setup_and_teardowns.cc
- stat.cc
- touch.cc
- virtual_buckets.cc
- )
- target_link_libraries(${TEST} PRIVATE
- libclient_utilities
- libhashkit
- libmemcached
- libmemcachedutil
- libtest
- Threads::Threads
- ${LIBUUID_LIBRARIES}
- )
- target_include_directories(${TEST} PRIVATE ${LIBUUID_INCLUDEDIR})
- add_test(${TEST} ${TEST})
-endforeach()
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-#include "libmemcached-1.0/memcached.h"
-#include "tests/basic.h"
-#include "tests/debug.h"
-#include "tests/deprecated.h"
-#include "tests/error_conditions.h"
-#include "tests/exist.h"
-#include "tests/ketama.h"
-#include "tests/namespace.h"
-#include "tests/libmemcached-1.0/dump.h"
-#include "tests/libmemcached-1.0/generate.h"
-#include "tests/libmemcached-1.0/haldenbrand.h"
-#include "tests/libmemcached-1.0/parser.h"
-#include "tests/libmemcached-1.0/stat.h"
-#include "tests/touch.h"
-#include "tests/callbacks.h"
-#include "tests/pool.h"
-#include "tests/print.h"
-#include "tests/replication.h"
-#include "tests/server_add.h"
-#include "tests/virtual_buckets.h"
-
-#include "tests/libmemcached-1.0/setup_and_teardowns.h"
-
-
-#include "tests/libmemcached-1.0/mem_functions.h"
-#include "tests/libmemcached-1.0/encoding_key.h"
-
-/* Collections we are running */
-#include "tests/libmemcached-1.0/all_tests.h"
-
-#include "tests/libmemcached_world.h"
-
-#include <algorithm>
-
-void get_world(libtest::Framework* world)
-{
- if (getenv("LIBMEMCACHED_SERVER_NUMBER"))
- {
- unsigned long int set_count= strtoul(getenv("LIBMEMCACHED_SERVER_NUMBER"), (char **) NULL, 10);
- fatal_assert(set_count >= 1);
- world->servers().set_servers_to_run(set_count);
- }
- else
- {
- // Assume a minimum of 3, and a maximum of 8
- world->servers().set_servers_to_run((libtest::number_of_cpus() > 3) ?
- std::min(libtest::number_of_cpus(), size_t(8)) : 3);
- }
-
- world->collections(collection);
-
- world->create((test_callback_create_fn*)world_create);
- world->destroy((test_callback_destroy_fn*)world_destroy);
-
- world->set_runner(new LibmemcachedRunner);
-
- world->set_socket();
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-#include "libmemcached-1.0/memcached.h"
-#include "tests/basic.h"
-#include "tests/debug.h"
-#include "tests/deprecated.h"
-#include "tests/error_conditions.h"
-#include "tests/exist.h"
-#include "tests/ketama.h"
-#include "tests/namespace.h"
-#include "tests/libmemcached-1.0/parser.h"
-#include "tests/libmemcached-1.0/dump.h"
-#include "tests/libmemcached-1.0/generate.h"
-#include "tests/libmemcached-1.0/haldenbrand.h"
-#include "tests/libmemcached-1.0/stat.h"
-#include "tests/touch.h"
-#include "tests/callbacks.h"
-#include "tests/pool.h"
-#include "tests/print.h"
-#include "tests/replication.h"
-#include "tests/server_add.h"
-#include "tests/virtual_buckets.h"
-
-#include "tests/libmemcached-1.0/setup_and_teardowns.h"
-
-
-#include "tests/libmemcached-1.0/mem_functions.h"
-#include "tests/libmemcached-1.0/encoding_key.h"
-
-/* Collections we are running */
-#include "tests/libmemcached-1.0/all_tests.h"
-
-#include "tests/libmemcached_world_socket.h"
-
-void get_world(libtest::Framework* world)
-{
- world->collections(collection);
-
- world->create((test_callback_create_fn*)world_create);
- world->destroy((test_callback_destroy_fn*)world_destroy);
-
- world->set_runner(new LibmemcachedRunner);
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-
-#include "libmemcachedutil-1.0/util.h"
-#include "libmemcached/is.h"
-
-#include "tests/libmemcached-1.0/generate.h"
-#include "tests/libmemcached-1.0/fetch_all_results.h"
-#include "tests/libmemcached-1.0/callback_counter.h"
-
-#include "bin/generator.h"
-#include "bin/execute.h"
-
-#include "tests/memc.hpp"
-
-#ifdef __APPLE__
-# define GLOBAL_COUNT 3000
-#else
-# define GLOBAL_COUNT 10000
-#endif
-
-#define GLOBAL2_COUNT 100
-
-using namespace libtest;
-
-static pairs_st *global_pairs= NULL;
-static const char *global_keys[GLOBAL_COUNT];
-static size_t global_keys_length[GLOBAL_COUNT];
-static size_t global_count= 0;
-
-test_return_t cleanup_pairs(memcached_st*)
-{
- pairs_free(global_pairs);
- global_pairs= NULL;
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_pairs(memcached_st *)
-{
- global_pairs= pairs_generate(GLOBAL_COUNT, 400);
-
- for (size_t x= 0; x < GLOBAL_COUNT; ++x)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t generate_large_pairs(memcached_st *memc)
-{
- global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
-
- for (size_t x= 0; x < GLOBAL2_COUNT; x++)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
-
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
- global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL2_COUNT);
-
- ASSERT_TRUE(global_count > (GLOBAL2_COUNT / 2));
-
- return TEST_SUCCESS;
-}
-
-test_return_t generate_data(memcached_st *memc)
-{
- test_compare(TEST_SUCCESS, generate_pairs(memc));
-
- global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL_COUNT);
-
- /* Possible false, positive, memcached may have ejected key/value based on
- * memory needs. */
-
- ASSERT_TRUE(global_count > (GLOBAL2_COUNT / 2));
-
- return TEST_SUCCESS;
-}
-
-test_return_t generate_data_with_stats(memcached_st *memc)
-{
- test_compare(TEST_SUCCESS, generate_pairs(memc));
-
- global_count= execute_set(memc, global_pairs, (unsigned int)GLOBAL2_COUNT);
-
- ASSERT_EQ(global_count, GLOBAL2_COUNT);
-
- // @todo hosts used size stats
- memcached_return_t rc;
- memcached_stat_st *stat_p= memcached_stat(memc, NULL, &rc);
- test_true(stat_p);
-
- for (uint32_t host_index= 0; host_index < memcached_server_count(memc); host_index++)
- {
- /* This test was changes so that "make test" would work properlly */
- if (DEBUG)
- {
- const memcached_instance_st * instance=
- memcached_server_instance_by_position(memc, host_index);
-
- printf("\nserver %u|%s|%u bytes: %llu\n",
- host_index,
- memcached_server_name(instance),
- memcached_server_port(instance),
- (unsigned long long)(stat_p + host_index)->bytes);
- }
- test_true((unsigned long long)(stat_p + host_index)->bytes);
- }
-
- memcached_stat_free(NULL, stat_p);
-
- return TEST_SUCCESS;
-}
-
-test_return_t generate_buffer_data(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
- generate_data(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t get_read_count(memcached_st *memc)
-{
- memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone);
-
- memcached_server_add_with_weight(memc_clone, "localhost", 6666, 0);
-
- {
- char *return_value;
- size_t return_value_length;
- uint32_t flags;
- uint32_t count;
-
- for (size_t x= count= 0; x < global_count; ++x)
- {
- memcached_return_t rc;
- return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- if (rc == MEMCACHED_SUCCESS)
- {
- count++;
- if (return_value)
- {
- free(return_value);
- }
- }
- }
- }
-
- memcached_free(memc_clone);
-
- return TEST_SUCCESS;
-}
-
-test_return_t get_read(memcached_st *memc)
-{
- test::Memc clone(memc);
- size_t keys_returned= 0;
- for (size_t x= 0; x < global_count; ++x)
- {
- size_t return_value_length;
- uint32_t flags;
- memcached_return_t rc;
- char *return_value= memcached_get(&clone, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- /*
- test_true(return_value);
- test_compare(MEMCACHED_SUCCESS, rc);
- */
- if (rc == MEMCACHED_SUCCESS && return_value)
- {
- keys_returned++;
- free(return_value);
- }
- }
- /*
- Possible false, positive, memcached may have ejected key/value based on memory needs.
- */
- test_true(keys_returned > (global_count / 2));
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_read(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // Go fetch the keys and test to see if all of them were returned
- {
- unsigned int keys_returned;
- test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
- test_true(keys_returned > (global_count / 2));
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_read_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- /* Turn this into a help function */
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- if (rc == MEMCACHED_IN_PROGRESS)
- {
- continue;
- }
-
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_read_partial_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // We will scan for just one key
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
-
- memcached_return_t rc;
- results= memcached_fetch_result(memc, results, &rc);
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- memcached_result_free(&results_obj);
- }
-
- // We already have a read happening, lets start up another one.
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
- test_false(memcached_is_allocated(results));
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_read_function(memcached_st *memc)
-{
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- memcached_execute_fn callbacks[]= { &callback_counter };
- size_t counter= 0;
- test_compare(MEMCACHED_SUCCESS,
- memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
-
- return TEST_SUCCESS;
-}
-
-test_return_t delete_generate(memcached_st *memc)
-{
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
-
- /*
- Possible false, positive, memcached may have ejected key/value based on memory needs.
- */
- ASSERT_TRUE(total);
-
- return TEST_SUCCESS;
-}
-
-test_return_t delete_buffer_generate(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
-
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
-
- ASSERT_TRUE(total);
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_read_internal_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st *results= NULL;
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, results, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(results);
- }
-
- return TEST_SUCCESS;
-}
-
+++ /dev/null
-/* 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 "mem_config.h"
-#include "libtest/test.hpp"
-
-#if defined(HAVE_LIBUUID) && HAVE_LIBUUID
-# include <uuid/uuid.h>
-#endif
-
-/*
- Test cases
-*/
-
-#include "libmemcached-1.0/memcached.h"
-#include "libmemcached/is.h"
-#include "libmemcached/server_instance.h"
-
-#include "libhashkit-1.0/hashkit.h"
-
-#include "libtest/memcached.hpp"
-
-#include <cerrno>
-#include <memory>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-#include <sys/types.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <iostream>
-
-#include "libtest/server.h"
-
-#include "bin/generator.h"
-
-#define SMALL_STRING_LEN 1024
-
-#include "libtest/test.hpp"
-
-using namespace libtest;
-
-#include "libmemcachedutil-1.0/util.h"
-
-#include "tests/hash_results.h"
-
-#include "tests/libmemcached-1.0/callback_counter.h"
-#include "tests/libmemcached-1.0/fetch_all_results.h"
-#include "tests/libmemcached-1.0/mem_functions.h"
-#include "tests/libmemcached-1.0/setup_and_teardowns.h"
-#include "tests/print.h"
-#include "tests/debug.h"
-#include "tests/memc.hpp"
-
-#define UUID_STRING_MAXLENGTH 36
-
-#include "tests/keys.hpp"
-
-#include "libmemcached/instance.hpp"
-
-
-test_return_t mget_end(memcached_st *memc)
-{
- const char *keys[]= { "foo", "foo2" };
- size_t lengths[]= { 3, 4 };
- const char *values[]= { "fjord", "41" };
-
- // Set foo and foo2
- for (size_t x= 0; x < test_array_length(keys); x++)
- {
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc,
- keys[x], lengths[x],
- values[x], strlen(values[x]),
- time_t(0), uint32_t(0)));
- }
-
- char *string;
- size_t string_length;
- uint32_t flags;
-
- // retrieve both via mget
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc,
- keys, lengths,
- test_array_length(keys)));
-
- char key[MEMCACHED_MAX_KEY];
- size_t key_length;
- memcached_return_t rc;
-
- // this should get both
- for (size_t x= 0; x < test_array_length(keys); x++)
- {
- string= memcached_fetch(memc, key, &key_length, &string_length,
- &flags, &rc);
- test_compare(MEMCACHED_SUCCESS, rc);
- int val = 0;
- if (key_length == 4)
- {
- val= 1;
- }
-
- test_compare(string_length, strlen(values[val]));
- test_true(strncmp(values[val], string, string_length) == 0);
- free(string);
- }
-
- // this should indicate end
- string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
- test_compare(MEMCACHED_END, rc);
- test_null(string);
-
- // now get just one
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, lengths, 1));
-
- string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
- test_compare(key_length, lengths[0]);
- test_true(strncmp(keys[0], key, key_length) == 0);
- test_compare(string_length, strlen(values[0]));
- test_true(strncmp(values[0], string, string_length) == 0);
- test_compare(MEMCACHED_SUCCESS, rc);
- free(string);
-
- // this should indicate end
- string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
- test_compare(MEMCACHED_END, rc);
- test_null(string);
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_result_test(memcached_st *memc)
-{
- const char *keys[]= {"fudge", "son", "food"};
- size_t key_length[]= {5, 3, 4};
-
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
- test_true(&results_obj == results);
-
- /* We need to empty the server before continueing test */
- test_compare(MEMCACHED_SUCCESS,
- memcached_flush(memc, 0));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- test_true(results);
- }
-
- while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(false); /* We should never see a value returned */ };
- test_false(results);
- test_compare(MEMCACHED_NOTFOUND, rc);
-
- for (uint32_t x= 0; x < 3; x++)
- {
- rc= memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- (time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- test_true(results);
- test_true(&results_obj == results);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_memcmp(memcached_result_key_value(results),
- memcached_result_value(results),
- memcached_result_length(results));
- test_compare(memcached_result_key_length(results), memcached_result_length(results));
- }
-
- memcached_result_free(&results_obj);
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_result_alloc_test(memcached_st *memc)
-{
- const char *keys[]= {"fudge", "son", "food"};
- size_t key_length[]= {5, 3, 4};
-
- memcached_result_st *results;
-
- /* We need to empty the server before continueing test */
- test_compare(MEMCACHED_SUCCESS,
- memcached_flush(memc, 0));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, NULL, &rc)))
- {
- test_true(results);
- }
- test_false(results);
- test_compare(MEMCACHED_NOTFOUND, rc);
-
- for (uint32_t x= 0; x < 3; x++)
- {
- rc= memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- (time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- uint32_t x= 0;
- while ((results= memcached_fetch_result(memc, NULL, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_compare(memcached_result_key_length(results), memcached_result_length(results));
- test_memcmp(memcached_result_key_value(results),
- memcached_result_value(results),
- memcached_result_length(results));
- memcached_result_free(results);
- x++;
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_result_function(memcached_st *memc)
-{
- const char *keys[]= {"fudge", "son", "food"};
- size_t key_length[]= {5, 3, 4};
- size_t counter;
- memcached_execute_fn callbacks[1];
-
- for (uint32_t x= 0; x < 3; x++)
- {
- test_compare(return_value_based_on_buffering(memc),
- memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- time_t(50), uint32_t(9)));
- }
- test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
- memcached_quit(memc);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- callbacks[0]= &callback_counter;
- counter= 0;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
-
- test_compare(size_t(3), counter);
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_test(memcached_st *memc)
-{
- const char *keys[]= {"fudge", "son", "food"};
- size_t key_length[]= {5, 3, 4};
-
- char return_key[MEMCACHED_MAX_KEY];
- size_t return_key_length;
- char *return_value;
- size_t return_value_length;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- uint32_t flags;
- memcached_return_t rc;
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)))
- {
- test_true(return_value);
- }
- test_false(return_value);
- test_zero(return_value_length);
- test_compare(MEMCACHED_NOTFOUND, rc);
-
- for (uint32_t x= 0; x < 3; x++)
- {
- rc= memcached_set(memc, keys[x], key_length[x],
- keys[x], key_length[x],
- (time_t)50, (uint32_t)9);
- test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- }
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 3));
-
- uint32_t x= 0;
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)))
- {
- test_true(return_value);
- test_compare(MEMCACHED_SUCCESS, rc);
- if (not memc->_namespace)
- {
- test_compare(return_key_length, return_value_length);
- test_memcmp(return_value, return_key, return_value_length);
- }
- free(return_value);
- x++;
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t mget_execute(memcached_st *original_memc)
-{
- test_skip(true, memcached_behavior_get(original_memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
- memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL");
- test_true(memc);
-
- keys_st keys(20480);
-
- /* First add all of the items.. */
- char blob[1024] = {0};
-
- for (size_t x= 0; x < keys.size(); ++x)
- {
- uint64_t query_id= memcached_query_id(memc);
- memcached_return_t rc= memcached_add(memc,
- keys.key_at(x), keys.length_at(x),
- blob, sizeof(blob),
- 0, 0);
- ASSERT_TRUE_(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, "Returned %s", memcached_strerror(NULL, rc));
- test_compare(query_id +1, memcached_query_id(memc));
- }
-
- /* Try to get all of them with a large multiget */
- size_t counter= 0;
- memcached_execute_fn callbacks[]= { &callback_counter };
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget_execute(memc,
- keys.keys_ptr(), keys.lengths_ptr(),
- keys.size(), callbacks, &counter, 1));
-
- {
- uint64_t query_id= memcached_query_id(memc);
- test_compare(MEMCACHED_SUCCESS,
- memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
- test_compare(query_id, memcached_query_id(memc));
-
- /* Verify that we got all of the items */
- test_compare(keys.size(), counter);
- }
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-
-
-test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc)
-{
- memcached_return_t rc;
-
- const char *key= "not_found";
- size_t key_length= test_literal_param_size("not_found");
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, &key, &key_length, 1));
-
- memcached_result_st *result= memcached_fetch_result(memc, NULL, &rc);
- test_null(result);
- test_compare(MEMCACHED_NOTFOUND, rc);
-
- memcached_result_free(result);
-
- return TEST_SUCCESS;
-}
-
-/*
- Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist.
-*/
-test_return_t user_supplied_bug12(memcached_st *memc)
-{
- memcached_return_t rc;
- uint32_t flags;
- size_t value_length;
- char *value;
- uint64_t number_value;
-
- value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
- &value_length, &flags, &rc);
- test_null(value);
- test_compare(MEMCACHED_NOTFOUND, rc);
-
- rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"),
- 1, &number_value);
- test_null(value);
- /* The binary protocol will set the key if it doesn't exist */
- if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1)
- {
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- else
- {
- test_compare(MEMCACHED_NOTFOUND, rc);
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0));
-
- value= memcached_get(memc, "autoincrement", strlen("autoincrement"), &value_length, &flags, &rc);
- test_true(value);
- free(value);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_increment(memc, "autoincrement", strlen("autoincrement"), 1, &number_value));
- test_compare(2UL, number_value);
-
- return TEST_SUCCESS;
-}
-
-/*
- Bug found where command total one more than MEMCACHED_MAX_BUFFER
- set key34567890 0 0 8169 \r\n is sent followed by buffer of size 8169, followed by 8169
-*/
-test_return_t user_supplied_bug13(memcached_st *memc)
-{
- char key[] = "key34567890";
-
- char commandFirst[]= "set key34567890 0 0 ";
- char commandLast[] = " \r\n"; /* first line of command sent to server */
- size_t commandLength;
-
- commandLength = strlen(commandFirst) + strlen(commandLast) + 4; /* 4 is number of characters in size, probably 8196 */
-
- size_t overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
-
- for (size_t testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
- {
- char *overflow= new (std::nothrow) char[testSize];
- test_true(overflow);
-
- memset(overflow, 'x', testSize);
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc, key, strlen(key),
- overflow, testSize, 0, 0));
- delete [] overflow;
- }
-
- return TEST_SUCCESS;
-}
-
-
-/*
- Test values of many different sizes
- Bug found where command total one more than MEMCACHED_MAX_BUFFER
- set key34567890 0 0 8169 \r\n
- is sent followed by buffer of size 8169, followed by 8169
-*/
-test_return_t user_supplied_bug14(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true);
-
- libtest::vchar_t value;
- value.reserve(18000);
- for (ptrdiff_t x= 0; x < 18000; x++)
- {
- value.push_back((char) (x % 127));
- }
-
- for (size_t current_length= 1; current_length < value.size(); current_length++)
- {
- memcached_return_t rc= memcached_set(memc, test_literal_param("foo"),
- &value[0], current_length,
- (time_t)0, (uint32_t)0);
- ASSERT_TRUE_(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, "Instead got %s", memcached_strerror(NULL, rc));
-
- size_t string_length;
- uint32_t flags;
- char *string= memcached_get(memc, test_literal_param("foo"),
- &string_length, &flags, &rc);
-
- test_compare(MEMCACHED_SUCCESS, rc);
- test_compare(string_length, current_length);
- char buffer[1024];
- snprintf(buffer, sizeof(buffer), "%u", uint32_t(string_length));
- test_memcmp(string, &value[0], string_length);
-
- free(string);
- }
-
- return TEST_SUCCESS;
-}
-
-/*
- From Andrei on IRC
-*/
-
-test_return_t user_supplied_bug19(memcached_st *)
-{
- memcached_return_t res;
-
- memcached_st *memc= memcached(test_literal_param("--server=localhost:11311/?100 --server=localhost:11312/?100"));
-
- const memcached_instance_st * server= memcached_server_by_key(memc, "a", 1, &res);
- test_true(server);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-/* CAS test from Andei */
-test_return_t user_supplied_bug20(memcached_st *memc)
-{
- const char *key= "abc";
- size_t key_len= strlen("abc");
-
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, true));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc,
- test_literal_param("abc"),
- test_literal_param("foobar"),
- (time_t)0, (uint32_t)0));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, &key, &key_len, 1));
-
- memcached_result_st result_obj;
- memcached_result_st *result= memcached_result_create(memc, &result_obj);
- test_true(result);
-
- memcached_result_create(memc, &result_obj);
- memcached_return_t status;
- result= memcached_fetch_result(memc, &result_obj, &status);
-
- test_true(result);
- test_compare(MEMCACHED_SUCCESS, status);
-
- memcached_result_free(result);
-
- return TEST_SUCCESS;
-}
-
-/* Large mget() of missing keys with binary proto
- *
- * If many binary quiet commands (such as getq's in an mget) fill the output
- * buffer and the server chooses not to respond, memcached_flush hangs. See
- * http://lists.tangent.org/pipermail/libmemcached/2009-August/000918.html
- */
-
-/* sighandler_t function that always asserts false */
-static __attribute__((noreturn)) void fail(int)
-{
- fatal_assert(0);
-}
-
-
-test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count)
-{
-#ifdef WIN32
- (void)memc;
- (void)key_count;
- return TEST_SKIPPED;
-#else
- void (*oldalarm)(int);
-
- memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone);
-
- /* only binproto uses getq for mget */
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
-
- /* empty the cache to ensure misses (hence non-responses) */
- test_compare(MEMCACHED_SUCCESS, memcached_flush(memc_clone, 0));
-
- keys_st keys(key_count);
-
- oldalarm= signal(SIGALRM, fail);
- alarm(5);
-
- test_compare_got(MEMCACHED_SUCCESS,
- memcached_mget(memc_clone, keys.keys_ptr(), keys.lengths_ptr(), keys.size()),
- memcached_last_error_message(memc_clone));
-
- alarm(0);
- signal(SIGALRM, oldalarm);
-
- memcached_return_t rc;
- uint32_t flags;
- char return_key[MEMCACHED_MAX_KEY];
- size_t return_key_length;
- char *return_value;
- size_t return_value_length;
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
- &return_value_length, &flags, &rc)))
- {
- test_false(return_value); // There are no keys to fetch, so the value should never be returned
- }
- test_compare(MEMCACHED_NOTFOUND, rc);
- test_zero(return_value_length);
- test_zero(return_key_length);
- test_false(return_key[0]);
- test_false(return_value);
-
- memcached_free(memc_clone);
-
- return TEST_SUCCESS;
-#endif
-}
-
-test_return_t user_supplied_bug21(memcached_st *memc)
-{
- test_skip(TEST_SUCCESS, pre_binary(memc));
-
- /* should work as of r580 */
- test_compare(TEST_SUCCESS,
- _user_supplied_bug21(memc, 10));
-
- /* should fail as of r580 */
- test_compare(TEST_SUCCESS,
- _user_supplied_bug21(memc, 1000));
-
- return TEST_SUCCESS;
-}
-
-test_return_t comparison_operator_memcached_st_and__memcached_return_t_TEST(memcached_st *)
-{
- test::Memc memc_;
-
- memcached_st *memc= &memc_;
-
- ASSERT_EQ(memc, MEMCACHED_SUCCESS);
- test_compare(memc, MEMCACHED_SUCCESS);
-
- ASSERT_NEQ(memc, MEMCACHED_FAILURE);
-
- return TEST_SUCCESS;
-}
-
-
-static void my_free(const memcached_st *ptr, void *mem, void *context)
-{
- (void)context;
- (void)ptr;
-#ifdef HARD_MALLOC_TESTS
- void *real_ptr= (mem == NULL) ? mem : (void*)((caddr_t)mem - 8);
- free(real_ptr);
-#else
- free(mem);
-#endif
-}
-
-
-static void *my_malloc(const memcached_st *ptr, const size_t size, void *context)
-{
- (void)context;
- (void)ptr;
-#ifdef HARD_MALLOC_TESTS
- void *ret= malloc(size + 8);
- if (ret != NULL)
- {
- ret= (void*)((caddr_t)ret + 8);
- }
-#else
- void *ret= malloc(size);
-#endif
-
- if (ret != NULL)
- {
- memset(ret, 0xff, size);
- }
-
- return ret;
-}
-
-
-static void *my_realloc(const memcached_st *ptr, void *mem, const size_t size, void *)
-{
-#ifdef HARD_MALLOC_TESTS
- void *real_ptr= (mem == NULL) ? NULL : (void*)((caddr_t)mem - 8);
- void *nmem= realloc(real_ptr, size + 8);
-
- void *ret= NULL;
- if (nmem != NULL)
- {
- ret= (void*)((caddr_t)nmem + 8);
- }
-
- return ret;
-#else
- (void)ptr;
- return realloc(mem, size);
-#endif
-}
-
-
-static void *my_calloc(const memcached_st *ptr, size_t nelem, const size_t size, void *)
-{
-#ifdef HARD_MALLOC_TESTS
- void *mem= my_malloc(ptr, nelem * size);
- if (mem)
- {
- memset(mem, 0, nelem * size);
- }
-
- return mem;
-#else
- (void)ptr;
- return calloc(nelem, size);
-#endif
-}
-
-#ifdef MEMCACHED_ENABLE_DEPRECATED
-test_return_t deprecated_set_memory_alloc(memcached_st *memc)
-{
- void *test_ptr= NULL;
- void *cb_ptr= NULL;
- {
- memcached_malloc_fn malloc_cb= (memcached_malloc_fn)my_malloc;
- cb_ptr= *(void **)&malloc_cb;
- memcached_return_t rc;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr));
- test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(test_ptr == cb_ptr);
- }
-
- {
- memcached_realloc_fn realloc_cb=
- (memcached_realloc_fn)my_realloc;
- cb_ptr= *(void **)&realloc_cb;
- memcached_return_t rc;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr));
- test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(test_ptr == cb_ptr);
- }
-
- {
- memcached_free_fn free_cb=
- (memcached_free_fn)my_free;
- cb_ptr= *(void **)&free_cb;
- memcached_return_t rc;
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr));
- test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(test_ptr == cb_ptr);
- }
-
- return TEST_SUCCESS;
-}
-#endif
-
-
-test_return_t set_memory_alloc(memcached_st *memc)
-{
- test_compare(MEMCACHED_INVALID_ARGUMENTS,
- memcached_set_memory_allocators(memc, NULL, my_free,
- my_realloc, my_calloc, NULL));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_set_memory_allocators(memc, my_malloc, my_free,
- my_realloc, my_calloc, NULL));
-
- memcached_malloc_fn mem_malloc;
- memcached_free_fn mem_free;
- memcached_realloc_fn mem_realloc;
- memcached_calloc_fn mem_calloc;
- memcached_get_memory_allocators(memc, &mem_malloc, &mem_free,
- &mem_realloc, &mem_calloc);
-
- test_true(mem_malloc == my_malloc);
- test_true(mem_realloc == my_realloc);
- test_true(mem_calloc == my_calloc);
- test_true(mem_free == my_free);
-
- return TEST_SUCCESS;
-}
-
-
-
-/*
- Test case adapted from John Gorman <johngorman2@gmail.com>
-
- We are testing the error condition when we connect to a server via memcached_get()
- but find that the server is not available.
-*/
-test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *)
-{
- size_t len;
- uint32_t flags;
- memcached_return rc;
-
- // Create a handle.
- memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist
-
- // See if memcached is reachable.
- char *value= memcached_get(tl_memc_h,
- test_literal_param(__func__),
- &len, &flags, &rc);
-
- test_false(value);
- test_zero(len);
- test_true(memcached_failed(rc));
-
- memcached_free(tl_memc_h);
-
- return TEST_SUCCESS;
-}
-
-/*
- Test case adapted from John Gorman <johngorman2@gmail.com>
-
- We are testing the error condition when we connect to a server via memcached_get_by_key()
- but find that the server is not available.
-*/
-test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *)
-{
- size_t len;
- uint32_t flags;
- memcached_return rc;
-
- // Create a handle.
- memcached_st *tl_memc_h= memcached_create(NULL);
- memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
- memcached_server_push(tl_memc_h, servers);
- memcached_server_list_free(servers);
-
- // See if memcached is reachable.
- char *value= memcached_get_by_key(tl_memc_h,
- test_literal_param(__func__), // Key
- test_literal_param(__func__), // Value
- &len, &flags, &rc);
-
- test_false(value);
- test_zero(len);
- test_true(memcached_failed(rc));
-
- memcached_free(tl_memc_h);
-
- return TEST_SUCCESS;
-}
-
-/* Test memcached_server_get_last_disconnect
- * For a working server set, shall be NULL
- * For a set of non existing server, shall not be NULL
- */
-test_return_t test_get_last_disconnect(memcached_st *memc)
-{
- memcached_return_t rc;
- const memcached_instance_st * disconnected_server;
-
- /* With the working set of server */
- const char *key= "marmotte";
- const char *value= "milka";
-
- memcached_reset_last_disconnected_server(memc);
- test_false(memc->last_disconnected_server);
- rc= memcached_set(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
-
- disconnected_server = memcached_server_get_last_disconnect(memc);
- test_false(disconnected_server);
-
- /* With a non existing server */
- memcached_st *mine;
- memcached_server_st *servers;
-
- const char *server_list= "localhost:9";
-
- servers= memcached_servers_parse(server_list);
- test_true(servers);
- mine= memcached_create(NULL);
- rc= memcached_server_push(mine, servers);
- test_compare(MEMCACHED_SUCCESS, rc);
- memcached_server_list_free(servers);
- test_true(mine);
-
- rc= memcached_set(mine, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
- test_true(memcached_failed(rc));
-
- disconnected_server= memcached_server_get_last_disconnect(mine);
- test_true_got(disconnected_server, memcached_strerror(mine, rc));
- test_compare(in_port_t(9), memcached_server_port(disconnected_server));
- test_false(strncmp(memcached_server_name(disconnected_server),"localhost",9));
-
- memcached_quit(mine);
- memcached_free(mine);
-
- return TEST_SUCCESS;
-}
-
-test_return_t test_multiple_get_last_disconnect(memcached_st *)
-{
- const char *server_string= "--server=localhost:8888 --server=localhost:8889 --server=localhost:8890 --server=localhost:8891 --server=localhost:8892";
- char buffer[BUFSIZ];
-
- test_compare(MEMCACHED_SUCCESS,
- libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer)));
-
- memcached_st *memc= memcached(server_string, strlen(server_string));
- test_true(memc);
-
- // We will just use the error strings as our keys
- uint32_t counter= 100;
- while (--counter)
- {
- for (int x= int(MEMCACHED_SUCCESS); x < int(MEMCACHED_MAXIMUM_RETURN); ++x)
- {
- const char *msg= memcached_strerror(memc, memcached_return_t(x));
- memcached_return_t ret= memcached_set(memc, msg, strlen(msg), NULL, 0, (time_t)0, (uint32_t)0);
- test_true_got((ret == MEMCACHED_CONNECTION_FAILURE or ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED), memcached_last_error_message(memc));
-
- const memcached_instance_st * disconnected_server= memcached_server_get_last_disconnect(memc);
- test_true(disconnected_server);
- test_strcmp("localhost", memcached_server_name(disconnected_server));
- test_true(memcached_server_port(disconnected_server) >= 8888 and memcached_server_port(disconnected_server) <= 8892);
-
- if (random() % 2)
- {
- memcached_reset_last_disconnected_server(memc);
- }
- }
- }
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-/*
- * This test ensures that the failure counter isn't incremented during
- * normal termination of the memcached instance.
- */
-test_return_t wrong_failure_counter_test(memcached_st *original_memc)
-{
- memcached_st* memc= create_single_instance_memcached(original_memc, NULL);
-
- /* Ensure that we are connected to the server by setting a value */
- memcached_return_t rc= memcached_set(memc,
- test_literal_param(__func__), // Key
- test_literal_param(__func__), // Value
- time_t(0), uint32_t(0));
- test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
-
-
- const memcached_instance_st * instance= memcached_server_instance_by_position(memc, 0);
-
- /* The test is to see that the memcached_quit doesn't increase the
- * the server failure conter, so let's ensure that it is zero
- * before sending quit
- */
- ((memcached_server_write_instance_st)instance)->server_failure_counter= 0;
-
- memcached_quit(memc);
-
- /* Verify that it memcached_quit didn't increment the failure counter
- * Please note that this isn't bullet proof, because an error could
- * occur...
- */
- test_zero(instance->server_failure_counter);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-/*
- * This tests ensures expected disconnections (for some behavior changes
- * for instance) do not wrongly increase failure counter
- */
-test_return_t wrong_failure_counter_two_test(memcached_st *memc)
-{
- /* Set value to force connection to the server */
- const char *key= "marmotte";
- const char *value= "milka";
-
- test_compare_hint(MEMCACHED_SUCCESS,
- memcached_set(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0),
- memcached_last_error_message(memc));
-
-
- /* put failure limit to 1 */
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, true));
-
- /* Put a retry timeout to effectively activate failure_limit effect */
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1));
-
- /* change behavior that triggers memcached_quit()*/
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-
- /* Check if we still are connected */
- uint32_t flags;
- size_t string_length;
- memcached_return rc;
- char *string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
-
- test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
- test_true(string);
- free(string);
-
- return TEST_SUCCESS;
-}
-
-
-#define regression_bug_655423_COUNT 6000
-test_return_t regression_bug_655423(memcached_st *memc)
-{
- memcached_st *clone= memcached_clone(NULL, memc);
- memc= NULL; // Just to make sure it is not used
- test_true(clone);
- char payload[100];
-
-#ifdef __APPLE__
- return TEST_SKIPPED;
-#endif
-
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1));
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1));
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 1));
-
- memset(payload, int('x'), sizeof(payload));
-
- keys_st keys(regression_bug_655423_COUNT);
-
- for (size_t x= 0; x < keys.size(); x++)
- {
- test_compare(MEMCACHED_SUCCESS, memcached_set(clone,
- keys.key_at(x),
- keys.length_at(x),
- payload, sizeof(payload), 0, 0));
- }
-
- for (size_t x= 0; x < keys.size(); x++)
- {
- size_t value_length;
- memcached_return_t rc;
- char *value= memcached_get(clone,
- keys.key_at(x),
- keys.length_at(x),
- &value_length, NULL, &rc);
-
- if (rc == MEMCACHED_NOTFOUND)
- {
- test_false(value);
- test_zero(value_length);
- continue;
- }
-
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(value);
- test_compare(100LLU, value_length);
- free(value);
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(clone,
- keys.keys_ptr(), keys.lengths_ptr(),
- keys.size()));
-
- uint32_t count= 0;
- memcached_result_st *result= NULL;
- while ((result= memcached_fetch_result(clone, result, NULL)))
- {
- test_compare(size_t(100), memcached_result_length(result));
- count++;
- }
-
- test_true(count > 100); // If we don't get back atleast this, something is up
-
- memcached_free(clone);
-
- return TEST_SUCCESS;
-}
-
-/*
- * Test that ensures that buffered set to not trigger problems during io_flush
- */
-#define regression_bug_490520_COUNT 200480
-test_return_t regression_bug_490520(memcached_st *original_memc)
-{
- memcached_st* memc= create_single_instance_memcached(original_memc, NULL);
-
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,1);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1000);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,1);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 3600);
-
- /* First add all of the items.. */
- char blob[3333] = {0};
- for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x)
- {
- 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);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc));
- }
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t regression_bug_1251482(memcached_st*)
-{
- test::Memc memc("--server=localhost:5");
-
- memcached_behavior_set(&memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 0);
-
- for (size_t x= 0; x < 5; ++x)
- {
- size_t value_length;
- memcached_return_t rc;
- char *value= memcached_get(&memc,
- test_literal_param(__func__),
- &value_length, NULL, &rc);
-
- test_false(value);
- test_compare(0LLU, value_length);
- if (x) {
- test_ne_compare(MEMCACHED_SUCCESS, rc);
- } else {
- test_compare(MEMCACHED_CONNECTION_FAILURE, rc);
- }
- }
-
- return TEST_SUCCESS;
-}
-
-test_return_t regression_1009493_TEST(memcached_st*)
-{
- memcached_st* memc= memcached_create(NULL);
- test_true(memc);
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, true));
-
- memcached_st* clone= memcached_clone(NULL, memc);
- test_true(clone);
-
- test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED),
- memcached_behavior_get(clone, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
-
- memcached_free(memc);
- memcached_free(clone);
-
- return TEST_SUCCESS;
-}
-
-test_return_t regression_994772_TEST(memcached_st* memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc,
- test_literal_param(__func__), // Key
- test_literal_param(__func__), // Value
- time_t(0), uint32_t(0)));
-
- const char *keys[] = { __func__ };
- size_t key_length[]= { strlen(__func__) };
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, keys, key_length, 1));
-
- memcached_return_t rc;
- memcached_result_st *results= memcached_fetch_result(memc, NULL, &rc);
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- test_strcmp(__func__, memcached_result_value(results));
- uint64_t cas_value= memcached_result_cas(results);
- test_true(cas_value);
-
- char* take_value= memcached_result_take_value(results);
- test_strcmp(__func__, take_value);
- free(take_value);
-
- memcached_result_free(results);
-
- // Bad cas value, sanity check
- test_true(cas_value != 9999);
- test_compare(MEMCACHED_END,
- memcached_cas(memc,
- test_literal_param(__func__), // Key
- test_literal_param(__FILE__), // Value
- time_t(0), uint32_t(0), 9999));
-
- test_compare(MEMCACHED_SUCCESS, memcached_set(memc,
- "different", strlen("different"), // Key
- test_literal_param(__FILE__), // Value
- time_t(0), uint32_t(0)));
-
- return TEST_SUCCESS;
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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
-
-test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc);
-test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc);
-test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc);
-test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc);
-test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count);
-test_return_t add_host_test(memcached_st *memc);
-test_return_t add_host_test1(memcached_st *memc);
-test_return_t memcached_add_SUCCESS_TEST(memcached_st*);
-test_return_t add_test(memcached_st *memc);
-test_return_t add_wrapper(memcached_st *memc);
-test_return_t allocation_test(memcached_st *not_used);
-test_return_t analyzer_test(memcached_st *memc);
-test_return_t append_binary_test(memcached_st *memc);
-test_return_t append_test(memcached_st *memc);
-test_return_t bad_key_test(memcached_st *memc);
-test_return_t behavior_test(memcached_st *memc);
-test_return_t binary_add_regression(memcached_st *memc);
-test_return_t binary_increment_with_prefix_test(memcached_st *memc);
-test_return_t block_add_regression(memcached_st *memc);
-test_return_t callback_test(memcached_st *memc);
-test_return_t cas2_test(memcached_st *memc);
-test_return_t cas_test(memcached_st *memc);
-test_return_t check_for_1_2_3(memcached_st *memc);
-test_return_t clone_test(memcached_st *memc);
-test_return_t connection_test(memcached_st *memc);
-test_return_t crc_run (memcached_st *);
-test_return_t decrement_by_key_test(memcached_st *memc);
-test_return_t decrement_test(memcached_st *memc);
-test_return_t decrement_with_initial_by_key_test(memcached_st *memc);
-test_return_t decrement_with_initial_test(memcached_st *memc);
-test_return_t decrement_with_initial_999_test(memcached_st *memc);
-test_return_t delete_test(memcached_st *memc);
-test_return_t deprecated_set_memory_alloc(memcached_st *memc);
-test_return_t enable_cas(memcached_st *memc);
-test_return_t enable_consistent_crc(memcached_st *memc);
-test_return_t enable_consistent_hsieh(memcached_st *memc);
-test_return_t flush_test(memcached_st *memc);
-test_return_t fnv1_32_run (memcached_st *);
-test_return_t fnv1_64_run (memcached_st *);
-test_return_t fnv1a_32_run (memcached_st *);
-test_return_t fnv1a_64_run (memcached_st *);
-test_return_t get_stats(memcached_st *memc);
-test_return_t get_stats_keys(memcached_st *memc);
-test_return_t getpid_connection_failure_test(memcached_st *memc);
-test_return_t getpid_test(memcached_st *memc);
-test_return_t hash_sanity_test (memcached_st *memc);
-test_return_t hsieh_avaibility_test (memcached_st *memc);
-test_return_t hsieh_run (memcached_st *);
-test_return_t increment_by_key_test(memcached_st *memc);
-test_return_t increment_test(memcached_st *memc);
-test_return_t increment_with_initial_by_key_test(memcached_st *memc);
-test_return_t increment_with_initial_test(memcached_st *memc);
-test_return_t increment_with_initial_999_test(memcached_st *memc);
-test_return_t init_test(memcached_st *not_used);
-test_return_t jenkins_run (memcached_st *);
-test_return_t key_setup(memcached_st *memc);
-test_return_t key_teardown(memcached_st *);
-test_return_t libmemcached_string_behavior_test(memcached_st *);
-test_return_t libmemcached_string_distribution_test(memcached_st *);
-test_return_t md5_run (memcached_st *);
-test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc);
-test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *);
-test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc);
-test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc);
-test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc);
-test_return_t memcached_get_hashkit_test (memcached_st *);
-test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc);
-test_return_t memcached_return_t_TEST(memcached_st *memc);
-test_return_t memcached_server_cursor_test(memcached_st *memc);
-test_return_t memcached_server_remove_test(memcached_st*);
-test_return_t memcached_stat_execute_test(memcached_st *memc);
-test_return_t mget_end(memcached_st *memc);
-test_return_t mget_execute(memcached_st *original_memc);
-test_return_t MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST(memcached_st *original_memc);
-test_return_t mget_result_alloc_test(memcached_st *memc);
-test_return_t mget_result_function(memcached_st *memc);
-test_return_t mget_result_test(memcached_st *memc);
-test_return_t mget_test(memcached_st *memc);
-test_return_t murmur_avaibility_test (memcached_st *memc);
-test_return_t murmur_run (memcached_st *);
-test_return_t murmur3_TEST(hashkit_st *);
-test_return_t noreply_test(memcached_st *memc);
-test_return_t one_at_a_time_run (memcached_st *);
-test_return_t ketama_TEST(memcached_st *);
-test_return_t output_ketama_weighted_keys(memcached_st *);
-test_return_t libmemcached_util_ping_TEST(memcached_st*);
-test_return_t prepend_test(memcached_st *memc);
-test_return_t quit_test(memcached_st *memc);
-test_return_t read_through(memcached_st *memc);
-test_return_t regression_bug_(memcached_st*);
-test_return_t regression_bug_421108(memcached_st*);
-test_return_t regression_bug_434484(memcached_st*);
-test_return_t regression_bug_434843(memcached_st*);
-test_return_t regression_bug_434843_buffered(memcached_st*);
-test_return_t regression_bug_442914(memcached_st*);
-test_return_t regression_bug_447342(memcached_st*);
-test_return_t regression_bug_463297(memcached_st*);
-test_return_t regression_bug_490486(memcached_st*);
-test_return_t regression_bug_490520(memcached_st*);
-test_return_t regression_bug_581030(memcached_st*);
-test_return_t regression_bug_583031(memcached_st*);
-test_return_t regression_1021819_TEST(memcached_st*);
-test_return_t regression_bug_655423(memcached_st*);
-test_return_t regression_bug_854604(memcached_st*);
-test_return_t replace_test(memcached_st *memc);
-test_return_t result_alloc(memcached_st *memc);
-test_return_t result_static(memcached_st *memc);
-test_return_t selection_of_namespace_tests(memcached_st *memc);
-test_return_t server_sort2_test(memcached_st *ptr);
-test_return_t server_sort_test(memcached_st *ptr);
-test_return_t server_unsort_test(memcached_st *ptr);
-test_return_t set_memory_alloc(memcached_st *memc);
-test_return_t set_namespace(memcached_st *memc);
-test_return_t set_namespace_and_binary(memcached_st *memc);
-test_return_t set_test(memcached_st *memc);
-test_return_t set_test2(memcached_st *memc);
-test_return_t set_test3(memcached_st *memc);
-test_return_t stats_servername_test(memcached_st *memc);
-test_return_t test_get_last_disconnect(memcached_st *memc);
-test_return_t test_multiple_get_last_disconnect(memcached_st *);
-test_return_t test_verbosity(memcached_st *memc);
-test_return_t user_supplied_bug10(memcached_st *memc);
-test_return_t user_supplied_bug11(memcached_st *memc);
-test_return_t user_supplied_bug12(memcached_st *memc);
-test_return_t user_supplied_bug13(memcached_st *memc);
-test_return_t user_supplied_bug14(memcached_st *memc);
-test_return_t user_supplied_bug15(memcached_st *memc);
-test_return_t user_supplied_bug16(memcached_st *memc);
-test_return_t user_supplied_bug17(memcached_st *memc);
-test_return_t user_supplied_bug19(memcached_st *);
-test_return_t user_supplied_bug20(memcached_st *memc);
-test_return_t user_supplied_bug21(memcached_st *memc);
-test_return_t user_supplied_bug4(memcached_st *memc);
-test_return_t user_supplied_bug5(memcached_st *memc);
-test_return_t user_supplied_bug6(memcached_st *memc);
-test_return_t user_supplied_bug7(memcached_st *memc);
-test_return_t user_supplied_bug8(memcached_st *);
-test_return_t user_supplied_bug9(memcached_st *memc);
-test_return_t userdata_test(memcached_st *memc);
-test_return_t util_version_test(memcached_st *memc);
-test_return_t version_string_test(memcached_st *);
-test_return_t wrong_failure_counter_test(memcached_st *memc);
-test_return_t wrong_failure_counter_two_test(memcached_st *memc);
-test_return_t kill_TEST(memcached_st *memc);
-test_return_t regression_996813_TEST(memcached_st*);
-test_return_t regression_994772_TEST(memcached_st*);
-test_return_t regression_1009493_TEST(memcached_st*);
-test_return_t regression_1048945_TEST(memcached_st*);
-test_return_t regression_1067242_TEST(memcached_st*);
-test_return_t comparison_operator_memcached_st_and__memcached_return_t_TEST(memcached_st*);
-test_return_t regression_bug_1251482(memcached_st*);
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-
-#include "libmemcached-1.0/memcached.h"
-#include "libmemcached/util.h"
-
-using namespace libtest;
-
-static test_return_t memcached_fetch_execute_MEMCACHED_SUCCESS_TEST(memcached_st *memc)
-{
- (void)memc;
- return TEST_SUCCESS;
-}
-
-static test_return_t memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST(memcached_st *memc)
-{
- (void)memc;
- return TEST_SUCCESS;
-}
-
-test_st memcached_fetch_execute_TESTS[] ={
- {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_SUCCESS_TEST },
- {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST },
- { 0, 0, (test_callback_fn*)0 }
-};
-
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 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.
- *
- */
-
-#pragma once
-
-extern test_st *memcached_fetch_execute_TESTS;
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-
-/*
- Test cases
-*/
-
-#include "libmemcached-1.0/memcached.h"
-#include "tests/libmemcached-1.0/memcached_get.h"
-#include "tests/libmemcached-1.0/setup_and_teardowns.h"
-
-test_return_t get_test(memcached_st *memc)
-{
- uint64_t query_id= memcached_query_id(memc);
- memcached_return_t rc= memcached_delete(memc,
- test_literal_param(__func__),
- time_t(0));
- test_true(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND);
- test_compare(query_id +1, memcached_query_id(memc));
-
- size_t string_length;
- uint32_t flags;
- char *string= memcached_get(memc,
- test_literal_param(__func__),
- &string_length, &flags, &rc);
-
- test_compare(MEMCACHED_NOTFOUND, rc);
- test_false(string_length);
- test_false(string);
-
- return TEST_SUCCESS;
-}
-
-test_return_t get_test2(memcached_st *memc)
-{
- const char *value= "when we sanitize";
-
- uint64_t query_id= memcached_query_id(memc);
- test_compare(return_value_based_on_buffering(memc),
- memcached_set(memc,
- test_literal_param(__func__),
- value, strlen(value),
- time_t(0), uint32_t(0)));
- test_compare(query_id +1, memcached_query_id(memc));
-
- query_id= memcached_query_id(memc);
- test_true(query_id);
-
- uint32_t flags;
- size_t string_length;
- memcached_return_t rc;
- char *string= memcached_get(memc,
- test_literal_param(__func__),
- &string_length, &flags, &rc);
- test_compare(query_id +1, memcached_query_id(memc));
-
- test_compare(MEMCACHED_SUCCESS, rc);
- test_compare(MEMCACHED_SUCCESS, memcached_last_error(memc));
- test_true(string);
- test_compare(strlen(value), string_length);
- test_memcmp(string, value, string_length);
-
- free(string);
-
- return TEST_SUCCESS;
-}
-
-test_return_t get_test3(memcached_st *memc)
-{
- size_t value_length= 8191;
-
- libtest::vchar_t value;
- value.reserve(value_length);
- for (uint32_t x= 0; x < value_length; x++)
- {
- value.push_back(char(x % 127));
- }
-
- test_compare(return_value_based_on_buffering(memc),
- memcached_set(memc,
- test_literal_param(__func__),
- &value[0], value.size(),
- time_t(0), uint32_t(0)));
-
- size_t string_length;
- uint32_t flags;
- memcached_return_t rc;
- char *string= memcached_get(memc,
- test_literal_param(__func__),
- &string_length, &flags, &rc);
-
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(string);
- test_compare(value.size(), string_length);
- test_memcmp(string, &value[0], string_length);
-
- free(string);
-
- return TEST_SUCCESS;
-}
-
-test_return_t get_test4(memcached_st *memc)
-{
- size_t value_length= 8191;
-
- libtest::vchar_t value;
- value.reserve(value_length);
- for (uint32_t x= 0; x < value_length; x++)
- {
- value.push_back(char(x % 127));
- }
-
- test_compare(return_value_based_on_buffering(memc),
- memcached_set(memc,
- test_literal_param(__func__),
- &value[0], value.size(),
- time_t(0), uint32_t(0)));
-
- for (uint32_t x= 0; x < 10; x++)
- {
- uint32_t flags;
- size_t string_length;
- memcached_return_t rc;
- char *string= memcached_get(memc,
- test_literal_param(__func__),
- &string_length, &flags, &rc);
-
- test_compare(MEMCACHED_SUCCESS, rc);
- test_true(string);
- test_compare(value.size(), string_length);
- test_memcmp(string, &value[0], string_length);
- free(string);
- }
-
- return TEST_SUCCESS;
-}
-
-/*
- * This test verifies that memcached_read_one_response doesn't try to
- * dereference a NIL-pointer if you issue a multi-get and don't read out all
- * responses before you execute a storage command.
- */
-test_return_t get_test5(memcached_st *memc)
-{
- /*
- ** Request the same key twice, to ensure that we hash to the same server
- ** (so that we have multiple response values queued up) ;-)
- */
- const char *keys[]= { "key", "key" };
- size_t lengths[]= { 3, 3 };
- uint32_t flags;
- size_t rlen;
-
- test_compare(return_value_based_on_buffering(memc),
- memcached_set(memc, keys[0], lengths[0],
- keys[0], lengths[0],
- time_t(0), uint32_t(0)));
- test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, lengths, test_array_length(keys)));
-
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
-
- memcached_return_t rc;
- results= memcached_fetch_result(memc, &results_obj, &rc);
- test_true(results);
-
- memcached_result_free(&results_obj);
-
- /* Don't read out the second result, but issue a set instead.. */
- test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0));
-
- char *val= memcached_get_by_key(memc, keys[0], lengths[0], "yek", 3,
- &rlen, &flags, &rc);
- test_false(val);
- test_compare(MEMCACHED_NOTFOUND, rc);
- val= memcached_get(memc, keys[0], lengths[0], &rlen, &flags, &rc);
- test_true(val);
- test_compare(MEMCACHED_SUCCESS, rc);
- free(val);
-
- return TEST_SUCCESS;
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 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.
- *
- */
-
-#pragma once
-
-test_return_t get_test(memcached_st*);
-test_return_t get_test2(memcached_st*);
-test_return_t get_test3(memcached_st*);
-test_return_t get_test4(memcached_st*);
-test_return_t get_test5(memcached_st*);
-
+++ /dev/null
-/* 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 "mem_config.h"
-
-/*
- C++ interface test
-*/
-#include "libmemcached-1.0/memcached.hpp"
-#include "libtest/test.hpp"
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <ctime>
-
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace memcache;
-using namespace libtest;
-
-static void populate_vector(vector<char> &vec, const string &str)
-{
- vec.reserve(str.length());
- vec.assign(str.begin(), str.end());
-}
-
-static void copy_vec_to_string(vector<char> &vec, string &str)
-{
- str.clear();
- if (not vec.empty())
- {
- str.assign(vec.begin(), vec.end());
- }
-}
-
-static test_return_t basic_test(memcached_st *memc)
-{
- Memcache foo(memc);
- const string value_set("This is some data");
- std::vector<char> value;
- std::vector<char> test_value;
-
- populate_vector(value, value_set);
-
- test_true(foo.set("mine", value, 0, 0));
- test_true(foo.get("mine", test_value));
-
- test_compare(test_value.size(), value.size());
- test_memcmp(&test_value[0], &value[0], test_value.size());
- test_false(foo.set("", value, 0, 0));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t increment_test(memcached_st *original)
-{
- Memcache mcach(original);
- const string key("blah");
- const string inc_value("1");
- std::vector<char> inc_val;
- vector<char> ret_value;
- string ret_string;
- uint64_t int_inc_value;
- uint64_t int_ret_value;
-
- populate_vector(inc_val, inc_value);
-
- test_true(mcach.set(key, inc_val, 0, 0));
-
- test_true(mcach.get(key, ret_value));
- test_false(ret_value.empty());
- copy_vec_to_string(ret_value, ret_string);
-
- int_inc_value= uint64_t(atol(inc_value.c_str()));
- int_ret_value= uint64_t(atol(ret_string.c_str()));
- test_compare(int_inc_value, int_ret_value);
-
- test_true(mcach.increment(key, 1, &int_ret_value));
- test_compare(uint64_t(2), int_ret_value);
-
- test_true(mcach.increment(key, 1, &int_ret_value));
- test_compare(uint64_t(3), int_ret_value);
-
- test_true(mcach.increment(key, 5, &int_ret_value));
- test_compare(uint64_t(8), int_ret_value);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t basic_master_key_test(memcached_st *original)
-{
- Memcache foo(original);
- const string value_set("Data for server A");
- vector<char> value;
- vector<char> test_value;
- const string master_key_a("server-a");
- const string master_key_b("server-b");
- const string key("xyz");
-
- populate_vector(value, value_set);
-
- test_true(foo.setByKey(master_key_a, key, value, 0, 0));
- test_true(foo.getByKey(master_key_a, key, test_value));
-
- test_compare(value.size(), test_value.size());
- test_memcmp(&value[0], &test_value[0], value.size());
-
- test_value.clear();
-
-#if 0
- test_false(foo.getByKey(master_key_b, key, test_value));
- test_zero(test_value.size());
-#endif
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_test(memcached_st *original)
-{
- Memcache memc(original);
- memcached_return_t mc_rc;
- vector<string> keys;
- vector< vector<char> *> values;
- keys.reserve(3);
- keys.push_back("fudge");
- keys.push_back("son");
- keys.push_back("food");
- vector<char> val1;
- vector<char> val2;
- vector<char> val3;
- populate_vector(val1, "fudge");
- populate_vector(val2, "son");
- populate_vector(val3, "food");
- values.reserve(3);
- values.push_back(&val1);
- values.push_back(&val2);
- values.push_back(&val3);
-
- string return_key;
- vector<char> return_value;
-
- /* We need to empty the server before we continue the test */
- bool flush_res= memc.flush();
- if (flush_res == false)
- {
- std::string error_string;
- ASSERT_TRUE(memc.error(error_string));
- Error << error_string;
- }
- test_true(memc.flush());
-
- test_true(memc.mget(keys));
-
- test_compare(MEMCACHED_NOTFOUND,
- memc.fetch(return_key, return_value));
-
- test_true(memc.setAll(keys, values, 50, 9));
-
- test_true(memc.mget(keys));
- size_t count= 0;
- while (memcached_success(mc_rc= memc.fetch(return_key, return_value)))
- {
- test_compare(return_key.length(), return_value.size());
- test_memcmp(&return_value[0], return_key.c_str(), return_value.size());
- count++;
- }
- test_compare(values.size(), count);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t lp_1010899_TEST(void*)
-{
- // Check to see everything is setup internally even when no initial hosts are
- // given.
- Memcache memc;
-
- test_false(memc.increment(__func__, 0, NULL));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t lp_1010899_with_args_TEST(memcached_st *original)
-{
- // Check to see everything is setup internally even when a host is specified
- // on creation.
- const memcached_instance_st* instance= memcached_server_instance_by_position(original, 0);
- Memcache memc(memcached_server_name(instance), memcached_server_port(instance));
-
- test_false(memc.increment(__func__, 0, NULL));
- test_true(memc.set(__func__, test_literal_param("12"), 0, 0));
- test_true(memc.increment(__func__, 3, NULL));
-
- std::vector<char> ret_val;
- test_true(memc.get(__func__, ret_val));
-
- test_strcmp(&ret_val[0], "15");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t basic_behavior(memcached_st *original)
-{
- Memcache memc(original);
- test_true(memc.setBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY, true));
- test_compare(true, memc.getBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t error_test(memcached_st *)
-{
- Memcache memc("--server=localhost:178");
- std::vector<char> value;
-
- test_false(memc.set("key", value, time_t(0), uint32_t(0)));
-
- test_true(memc.error());
-
- return TEST_SUCCESS;
-}
-
-static test_return_t error_std_string_test(memcached_st *)
-{
- Memcache memc("--server=localhost:178");
- std::vector<char> value;
-
- test_false(memc.set("key", value, time_t(0), uint32_t(0)));
-
- std::string error_message;
- test_true(memc.error(error_message));
- test_false(error_message.empty());
-
- return TEST_SUCCESS;
-}
-
-static test_return_t error_memcached_return_t_test(memcached_st *)
-{
- Memcache memc("--server=localhost:178");
- std::vector<char> value;
-
- test_false(memc.set("key", value, time_t(0), uint32_t(0)));
-
- memcached_return_t rc;
- test_true(memc.error(rc));
- test_compare(MEMCACHED_CONNECTION_FAILURE, rc);
-
- return TEST_SUCCESS;
-}
-
-test_st error_tests[] ={
- { "error()", false, reinterpret_cast<test_callback_fn*>(error_test) },
- { "error(std::string&)", false, reinterpret_cast<test_callback_fn*>(error_std_string_test) },
- { "error(memcached_return_t&)", false, reinterpret_cast<test_callback_fn*>(error_memcached_return_t_test) },
- {0, 0, 0}
-};
-
-test_st tests[] ={
- { "basic", false,
- reinterpret_cast<test_callback_fn*>(basic_test) },
- { "basic_master_key", false,
- reinterpret_cast<test_callback_fn*>(basic_master_key_test) },
- { "increment_test", false,
- reinterpret_cast<test_callback_fn*>(increment_test) },
- { "mget", true,
- reinterpret_cast<test_callback_fn*>(mget_test) },
- { "basic_behavior", false,
- reinterpret_cast<test_callback_fn*>(basic_behavior) },
- {0, 0, 0}
-};
-
-test_st regression_TESTS[] ={
- { "lp:1010899 Memcache()", false, lp_1010899_TEST },
- { "lp:1010899 Memcache(localhost, port)", false,
- reinterpret_cast<test_callback_fn*>(lp_1010899_with_args_TEST) },
- {0, 0, 0}
-};
-
-collection_st collection[] ={
- {"block", 0, 0, tests},
- {"error()", 0, 0, error_tests},
- {"regression", 0, 0, regression_TESTS},
- {0, 0, 0, 0}
-};
-
-#define SERVERS_TO_CREATE 5
-
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
-#include "tests/libmemcached_world.h"
-
-void get_world(libtest::Framework* world)
-{
- world->collections(collection);
-
- world->create((test_callback_create_fn*)world_create);
- world->destroy((test_callback_destroy_fn*)world_destroy);
-
- world->set_runner(new LibmemcachedRunner);
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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.
- *
- */
-
-#include "mem_config.h"
-#include "libtest/test.hpp"
-
-#include "libmemcachedutil-1.0/util.h"
-
-#include "tests/print.h"
-#include "tests/libmemcached-1.0/setup_and_teardowns.h"
-
-#include <sys/stat.h>
-
-using namespace libtest;
-
-memcached_return_t return_value_based_on_buffering(memcached_st *memc)
-{
- if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS))
- {
- return MEMCACHED_BUFFERED;
- }
-
- return MEMCACHED_SUCCESS;
-}
-
-/**
- @note This should be testing to see if the server really supports the binary protocol.
-*/
-test_return_t pre_binary(memcached_st *memc)
-{
- test_true(memcached_server_count(memc) > 0);
- test_skip(true, libmemcached_util_version_check(memc, 1, 4, 4));
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_buffer(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_unix_socket(memcached_st *memc)
-{
- struct stat buf;
-
- memcached_servers_reset(memc);
- const char *socket_file= libtest::default_socket();
- test_skip(true, bool(socket_file));
-
- test_skip(0, stat(socket_file, &buf));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_server_add_unix_socket_with_weight(memc, socket_file, 0));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_nodelay(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_settimer(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_murmur(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
- return TEST_SUCCESS;
-}
-
-test_return_t pre_jenkins(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS);
-
- return TEST_SKIPPED;
-}
-
-
-test_return_t pre_md5(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_crc(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_hsieh(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH));
- return TEST_SUCCESS;
-}
-
-test_return_t pre_hash_fnv1_64(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_hash_fnv1a_64(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_hash_fnv1_32(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_hash_fnv1a_32(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32);
-
- return TEST_SUCCESS;
-}
-
-test_return_t memcached_servers_reset_SETUP(memcached_st *memc)
-{
- memcached_servers_reset(memc);
- test_compare(0U, memcached_server_count(memc));
- return TEST_SUCCESS;
-}
-
-test_return_t memcached_servers_reset_CONTINUUM(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT);
- memcached_servers_reset(memc);
- test_zero(memc->ketama.continuum_count);
- // If memc->ketama.continuum_count is non-zero at this point, any call to
- // memcached_server_add will cause a segfault.
- return TEST_SUCCESS;
-}
-
-test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_SETUP(memcached_st *memc)
-{
- test_compare(TEST_SUCCESS, memcached_servers_reset_SETUP(memc));
-
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT));
- test_compare(memcached_behavior_get_distribution(memc), MEMCACHED_DISTRIBUTION_CONSISTENT);
-
- return TEST_SUCCESS;
-}
-
-test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED_SETUP(memcached_st *memc)
-{
- test_compare(TEST_SUCCESS, memcached_servers_reset_SETUP(memc));
- ASSERT_EQ(0U, memcached_server_count(0));
-
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED));
- test_compare(memcached_behavior_get_distribution(memc), MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_behavior_ketama(memcached_st *memc)
-{
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1));
-
- test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA), uint64_t(1));
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_behavior_ketama_weighted(memcached_st *memc)
-{
- test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, true), MEMCACHED_SUCCESS);
-
- test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED), uint64_t(1));
-
- test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5), MEMCACHED_SUCCESS);
-
- test_compare(memcached_hash_t(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH)), MEMCACHED_HASH_MD5);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_replication(memcached_st *memc)
-{
- test_skip(TEST_SUCCESS, pre_binary(memc));
-
- /*
- * Make sure that we store the item on all servers
- * (master + replicas == number of servers)
- */
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(memc) - 1));
- test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS), uint64_t(memcached_server_count(memc) - 1));
-
- return TEST_SUCCESS;
-}
-
-
-test_return_t pre_replication_noblock(memcached_st *memc)
-{
- test_skip(TEST_SUCCESS, pre_replication(memc));
-
- return pre_nonblock(memc);
-}
-
-test_return_t pre_nonblock(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
-
- return TEST_SUCCESS;
-}
-
-test_return_t pre_nonblock_binary(memcached_st *memc)
-{
- memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone);
-
- // The memcached_version needs to be done on a clone, because the server
- // will not toggle protocol on an connection.
- memcached_version(memc_clone);
-
- memcached_return_t rc= MEMCACHED_FAILURE;
- if (libmemcached_util_version_check(memc_clone, 1, 4, 4))
- {
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
- test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
- }
- else
- {
- memcached_free(memc_clone);
- return TEST_SKIPPED;
- }
-
- memcached_free(memc_clone);
-
- return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached Client and Server
- *
- * 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
-
-memcached_return_t return_value_based_on_buffering(memcached_st*);
-
-test_return_t pre_behavior_ketama(memcached_st*);
-test_return_t pre_behavior_ketama_weighted(memcached_st*);
-test_return_t pre_binary(memcached_st*);
-test_return_t pre_cork(memcached_st*);
-test_return_t pre_cork_and_nonblock(memcached_st*);
-test_return_t pre_crc(memcached_st*);
-test_return_t pre_hash_fnv1_32(memcached_st*);
-test_return_t pre_hash_fnv1_64(memcached_st*);
-test_return_t pre_hash_fnv1a_32(memcached_st*);
-test_return_t pre_hash_fnv1a_64(memcached_st*);
-test_return_t pre_hsieh(memcached_st*);
-test_return_t pre_jenkins(memcached_st*);
-test_return_t pre_md5(memcached_st*);
-test_return_t pre_murmur(memcached_st*);
-test_return_t pre_nodelay(memcached_st*);
-test_return_t pre_nonblock(memcached_st*);
-test_return_t pre_nonblock_binary(memcached_st*);
-test_return_t pre_replication(memcached_st*);
-test_return_t pre_replication_noblock(memcached_st*);
-test_return_t pre_settimer(memcached_st*);
-test_return_t pre_unix_socket(memcached_st*);
-test_return_t pre_buffer(memcached_st*);
-test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_SETUP(memcached_st *memc);
-test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED_SETUP(memcached_st *memc);
-test_return_t memcached_servers_reset_SETUP(memcached_st *memc);
-test_return_t memcached_servers_reset_CONTINUUM(memcached_st *memc);
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached client and server 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.
- *
- */
-
-// We let libmemcached/common.h define config since we are looking at
-// library internals.
-
-#include "mem_config.h"
-
-#include "libmemcached-1.0/memcached.h"
-
-#include "libmemcached/string.hpp"
-#include "libmemcached/is.h"
-
-#include "libtest/test.hpp"
-
-#include "tests/string.h"
-
-test_return_t string_static_null(void*)
-{
- memcached_st *memc= memcached_create(NULL);
- memcached_string_st string;
-
- memcached_string_st *string_ptr= memcached_string_create(memc, &string, 0);
- test_true(string.options.is_initialized);
- test_true(string_ptr);
-
- /* The following two better be the same! */
- test_false(memcached_is_allocated(string_ptr));
- test_false(memcached_is_allocated(&string));
- test_true(&string == string_ptr);
-
- test_true(string.options.is_initialized);
- test_true(memcached_is_initialized(&string));
- memcached_string_free(&string);
- test_false(memcached_is_initialized(&string));
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_null(void*)
-{
- memcached_st *memc= memcached_create(NULL);
-
- memcached_string_st *string= memcached_string_create(memc, NULL, 0);
- test_true(string);
- test_true(memcached_is_allocated(string));
- test_true(memcached_is_initialized(string));
- memcached_string_free(string);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_with_size(void*)
-{
- memcached_st *memc= memcached_create(NULL);
- memcached_string_st *string= memcached_string_create(memc, NULL, 1024);
- test_true(string);
- test_true(memcached_is_allocated(string));
- test_true(memcached_is_initialized(string));
- memcached_string_free(string);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_with_size_toobig(void*)
-{
- memcached_st *memc= memcached_create(NULL);
- memcached_string_st *string= memcached_string_create(memc, NULL, SIZE_MAX);
- test_zero(string);
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_append(void*)
-{
- memcached_st *memc= memcached_create(NULL);
-
- char buffer[BUFSIZ];
- memcached_string_st *string;
-
- /* Ring the bell! */
- memset(buffer, 6, BUFSIZ);
-
- string= memcached_string_create(memc, NULL, 100);
- test_true(string);
- test_true(memcached_is_allocated(string));
- test_true(memcached_is_initialized(string));
-
- for (unsigned int x= 0; x < 1024; x++)
- {
- memcached_return_t rc;
- rc= memcached_string_append(string, buffer, BUFSIZ);
- test_true(rc == MEMCACHED_SUCCESS);
- }
- test_true(memcached_is_allocated(string));
- memcached_string_free(string);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_append_toobig(void*)
-{
- memcached_st *memc= memcached_create(NULL);
-
- memcached_return_t rc;
- char buffer[BUFSIZ];
- memcached_string_st *string;
-
- /* Ring the bell! */
- memset(buffer, 6, sizeof(buffer));
-
- string= memcached_string_create(memc, NULL, 100);
- test_true(string);
- test_true(memcached_is_allocated(string));
- test_true(memcached_is_initialized(string));
-
- for (unsigned int x= 0; x < 1024; x++)
- {
- rc= memcached_string_append(string, buffer, BUFSIZ);
- test_true(rc == MEMCACHED_SUCCESS);
- }
- rc= memcached_string_append(string, buffer, SIZE_MAX);
- test_true(rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE);
- test_true(memcached_is_allocated(string));
- memcached_string_free(string);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-test_return_t string_alloc_append_multiple(void*)
-{
- memcached_st *memc= memcached_create(NULL);
-
- memcached_string_st *error_string= memcached_string_create(memc, NULL, 1024);
- memcached_string_append(error_string, test_literal_param("Error occured while parsing: "));
- memcached_string_append(error_string, test_string_make_from_cstr("jog the strlen() method"));
- memcached_string_append(error_string, test_literal_param(" ("));
-
- memcached_string_append(error_string, test_string_make_from_cstr(memcached_strerror(NULL, MEMCACHED_SUCCESS)));
- memcached_string_append(error_string, test_literal_param(")"));
-
- memcached_string_free(error_string);
-
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}