Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-node
  • evseev/cellframe-node
  • dmitry.puzyrkov/cellframe-node
  • MIKA83/cellframe-node
4 results
Show changes
Showing
with 0 additions and 1481 deletions
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Server IO, Not public!
*
*/
#ifndef __LIBMEMCACHED_IO_H__
#define __LIBMEMCACHED_IO_H__
#if defined(BUILDING_LIBMEMCACHED)
#include "libmemcached/memcached.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_UDP_DATAGRAM_LENGTH 1400
#define UDP_DATAGRAM_HEADER_LENGTH 8
#define UDP_REQUEST_ID_MSG_SIG_DIGITS 10
#define UDP_REQUEST_ID_THREAD_MASK 0xFFFF << UDP_REQUEST_ID_MSG_SIG_DIGITS
#define get_udp_datagram_request_id(A) ntohs((A)->request_id)
#define get_udp_datagram_seq_num(A) ntohs((A)->sequence_number)
#define get_udp_datagram_num_datagrams(A) ntohs((A)->num_datagrams)
#define get_msg_num_from_request_id(A) ( (A) & (~(UDP_REQUEST_ID_THREAD_MASK)) )
#define get_thread_id_from_request_id(A) ( (A) & (UDP_REQUEST_ID_THREAD_MASK) ) >> UDP_REQUEST_ID_MSG_SIG_DIGITS
#define generate_udp_request_thread_id(A) (A) << UDP_REQUEST_ID_MSG_SIG_DIGITS
#define UDP_REQUEST_ID_MAX_THREAD_ID get_thread_id_from_request_id(0xFFFF)
struct udp_datagram_header_st
{
uint16_t request_id;
uint16_t sequence_number;
uint16_t num_datagrams;
uint16_t reserved;
};
struct libmemcached_io_vector_st
{
size_t length;
const void *buffer;
};
LIBMEMCACHED_LOCAL
memcached_return_t memcached_io_wait_for_write(memcached_server_write_instance_st ptr);
LIBMEMCACHED_LOCAL
ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
const struct libmemcached_io_vector_st *vector,
size_t number_of, bool with_flush);
LIBMEMCACHED_LOCAL
ssize_t memcached_io_write(memcached_server_write_instance_st ptr,
const void *buffer, size_t length, bool with_flush);
LIBMEMCACHED_LOCAL
void memcached_io_reset(memcached_server_write_instance_st ptr);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
void *buffer, size_t length, ssize_t *nread);
/* Read a line (terminated by '\n') into the buffer */
LIBMEMCACHED_LOCAL
memcached_return_t memcached_io_readline(memcached_server_write_instance_st ptr,
char *buffer_ptr,
size_t size);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_io_close(memcached_server_write_instance_st ptr);
/* Read n bytes of data from the server and store them in dta */
LIBMEMCACHED_LOCAL
memcached_return_t memcached_safe_read(memcached_server_write_instance_st ptr,
void *dta,
size_t size);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_io_init_udp_header(memcached_server_write_instance_st ptr,
uint16_t thread_id);
LIBMEMCACHED_LOCAL
memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st *memc);
#ifdef __cplusplus
}
#endif
#endif /* BUILDING_LIBMEMCACHED */
#endif /* __LIBMEMCACHED_IO_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary:
*
*/
/*
* This file contains the definition of the various probes supported by
* libmemcached. Currently it only support DTRACE, but just create an
* implementation of the following macros to create your own sort of
* probing :)
*/
#ifndef __LIBMEMCACHED_PROBES_H__
#define __LIBMEMCACHED_PROBES_H__
#ifdef HAVE_DTRACE
/*
* Create the DTrace probes on the system using it (to support both Solaris
* and MacOS X
*/
#include "libmemcached/dtrace_probes.h"
#else
/*
* Provide dummy macros so that we don't need to clutter the code with
* ifdefs when we want to use the probes.
*/
#define LIBMEMCACHED_MEMCACHED_ADD_END()
#define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_ADD_START()
#define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_CONNECT_END()
#define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_CONNECT_START()
#define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DECREMENT_END()
#define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DECREMENT_START()
#define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END()
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START()
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DELETE_END()
#define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_DELETE_START()
#define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_FLUSH_END()
#define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_FLUSH_START()
#define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_GET_END()
#define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_GET_START()
#define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_INCREMENT_END()
#define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_INCREMENT_START()
#define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END()
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START()
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_MGET_END()
#define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_MGET_START()
#define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_REPLACE_END()
#define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_REPLACE_START()
#define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END()
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START()
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_SET_END()
#define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() (0)
#define LIBMEMCACHED_MEMCACHED_SET_START()
#define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() (0)
#endif
#endif /* __LIBMEMCACHED_PROBES_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: interface for memcached server
* Description: main include file for libmemcached
*
*/
#ifndef __LIBMEMCACHED_MEMCACHED_H__
#define __LIBMEMCACHED_MEMCACHED_H__
#include <inttypes.h>
#include <stdlib.h>
#include <sys/types.h>
#if !defined(__cplusplus)
# include <stdbool.h>
#endif
#include <libmemcached/visibility.h>
//#include <libmemcached/configure.h>
#include <libmemcached/platform.h>
#include <libmemcached/constants.h>
#include <libmemcached/types.h>
#include <libmemcached/string.h>
#include <libmemcached/stats.h>
#include <libhashkit/hashkit.h>
// Everything above this line must be in the order specified.
#include <libmemcached/allocators.h>
#include <libmemcached/analyze.h>
#include <libmemcached/auto.h>
#include <libmemcached/behavior.h>
#include <libmemcached/callback.h>
#include <libmemcached/delete.h>
#include <libmemcached/dump.h>
#include <libmemcached/fetch.h>
#include <libmemcached/flush.h>
#include <libmemcached/flush_buffers.h>
#include <libmemcached/get.h>
#include <libmemcached/hash.h>
#include <libmemcached/parse.h>
#include <libmemcached/quit.h>
#include <libmemcached/result.h>
#include <libmemcached/server.h>
#include <libmemcached/server_list.h>
#include <libmemcached/storage.h>
#include <libmemcached/strerror.h>
#include <libmemcached/verbosity.h>
#include <libmemcached/version.h>
#include <libmemcached/sasl.h>
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;
} state;
struct {
// Everything below here is pretty static.
bool auto_eject_hosts:1;
bool binary_protocol:1;
bool buffer_requests:1;
bool cork:1;
bool hash_with_prefix_key:1;
bool ketama_weighted:1;
bool no_block:1; // Don't block
bool no_reply:1;
bool randomize_replica_read:1;
bool reuse_memory:1;
bool support_cas:1;
bool tcp_nodelay:1;
bool use_cache_lookups:1;
bool use_sort_hosts:1;
bool use_udp:1;
bool verify_key:1;
bool tcp_keepalive:1;
} flags;
memcached_server_distribution_t distribution;
hashkit_st hashkit;
uint32_t continuum_points_counter; // Ketama
uint32_t number_of_hosts;
memcached_server_st *servers;
memcached_server_st *last_disconnected_server;
int32_t snd_timeout;
int32_t rcv_timeout;
uint32_t server_failure_limit;
uint32_t io_msg_watermark;
uint32_t io_bytes_watermark;
uint32_t io_key_prefetch;
uint32_t tcp_keepidle;
int cached_errno;
int32_t poll_timeout;
int32_t connect_timeout;
int32_t retry_timeout;
uint32_t continuum_count; // Ketama
int send_size;
int recv_size;
void *user_data;
time_t next_distribution_rebuild; // Ketama
size_t prefix_key_length;
uint32_t number_of_replicas;
hashkit_st distribution_hashkit;
memcached_result_st result;
memcached_continuum_item_st *continuum; // Ketama
struct _allocators_st {
memcached_calloc_fn calloc;
memcached_free_fn free;
memcached_malloc_fn malloc;
memcached_realloc_fn realloc;
void *context;
} 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;
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
struct {
bool is_allocated:1;
} options;
};
#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
void memcached_free(memcached_st *ptr);
LIBMEMCACHED_API
void memcached_reset_last_disconnected_server(memcached_st *ptr);
LIBMEMCACHED_API
memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr);
LIBMEMCACHED_API
void *memcached_get_user_data(const memcached_st *ptr);
LIBMEMCACHED_API
void *memcached_set_user_data(memcached_st *ptr, void *data);
LIBMEMCACHED_API
memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source);
LIBMEMCACHED_API
memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key);
LIBMEMCACHED_API
uint32_t memcached_server_count(const memcached_st *);
#ifdef __cplusplus
} // extern "C"
#endif
#ifdef __cplusplus
class Memcached : private memcached_st {
public:
Memcached()
{
memcached_create(this);
}
~Memcached()
{
memcached_free(this);
}
Memcached(const Memcached& source)
{
memcached_clone(this, &source);
}
Memcached& operator=(const Memcached& source)
{
memcached_free(this);
memcached_clone(this, &source);
return *this;
}
};
#endif
#endif /* __LIBMEMCACHED_MEMCACHED_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Connection pool library.
*
* Author: Trond Norbye, Brian Aker
*
*/
#ifndef __LIBMEMCACHED__MEMCACHED_UTIL_H__
#define __LIBMEMCACHED__MEMCACHED_UTIL_H__
#include <libmemcached/util/ping.h>
#include <libmemcached/util/pool.h>
#include <libmemcached/util/version.h>
#endif /* __LIBMEMCACHED__MEMCACHED_UTIL_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Work with fetching results
*
*/
#ifndef __LIBMEMCACHED_PARSE_H__
#define __LIBMEMCACHED_PARSE_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_server_list_st memcached_servers_parse(const char *server_strings);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_PARSE_H__ */
/* LibMemcached
* Copyright (C) 2006-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: Try to hide platform-specific stuff
*
*/
#ifndef LIBMEMCACHED_PLATFORM_H
#define LIBMEMCACHED_PLATFORM_H 1
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
typedef short in_port_t;
typedef SOCKET memcached_socket_t;
#else
typedef int memcached_socket_t;
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/un.h>
#include <netinet/tcp.h>
#endif /* WIN32 */
#endif /* LIBMEMCACHED_PLATFORM_H */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Definition of the callback interface to the protocol handler
*
* Author: Trond Norbye
*
*/
#ifndef __LIBMEMCACHED_PROTOCOL_H__
#define __LIBMEMCACHED_PROTOCOL_H__
#include <sys/types.h>
#if !defined(__cplusplus)
# include <stdbool.h>
#endif
#include <libmemcached/platform.h>
#include <libmemcached/memcached/protocol_binary.h>
#include <libmemcached/visibility.h>
#include <libmemcached/protocol/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);
/**
* 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
#endif
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: returns a human readable string for the error message
*
*/
#ifndef __LIBMEMCACHED_QUIT_H__
#define __LIBMEMCACHED_QUIT_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
void memcached_quit(memcached_st *ptr);
LIBMEMCACHED_LOCAL
void memcached_quit_server(memcached_server_st *ptr, bool io_death);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_QUIT_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Change the behavior of the memcached connection.
*
*/
#ifndef __LIBMEMCACHED_RESPONSE_H__
#define __LIBMEMCACHED_RESPONSE_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Read a single response from the server */
LIBMEMCACHED_LOCAL
memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_RESPONSE_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Functions to manipulate the result structure.
*
*/
#ifndef __LIBMEMCACHED_RESULT_H__
#define __LIBMEMCACHED_RESULT_H__
struct memcached_result_st {
uint32_t item_flags;
time_t item_expiration;
size_t key_length;
uint64_t item_cas;
const memcached_st *root;
memcached_string_st value;
char item_key[MEMCACHED_MAX_KEY];
struct {
bool is_allocated:1;
bool is_initialized:1;
} options;
/* Add result callback function */
};
#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
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
#endif /* __LIBMEMCACHED_RESULT_H__ */
/* LibMemcached
* Copyright (C) 2006-2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: interface for memcached server
* Description: main include file for libmemcached
*
*/
#ifndef LIBMEMCACHED_MEMCACHED_SASL_H
#define LIBMEMCACHED_MEMCACHED_SASL_H
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
#include <sasl/sasl.h>
#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
const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st *source);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *server);
#ifdef __cplusplus
}
#endif
#endif /* LIBMEMCACHED_WITH_SASL_SUPPORT */
struct memcached_sasl_st {
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
const sasl_callback_t *callbacks;
#else
const void *callbacks;
#endif
/*
** Did we allocate data inside the callbacks, or did the user
** supply that.
*/
bool is_allocated;
};
#endif /* LIBMEMCACHED_MEMCACHED_SASL_H */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: String structure used for libmemcached.
*
*/
#ifndef __LIBMEMCACHED_SERVER_H__
#define __LIBMEMCACHED_SERVER_H__
struct memcached_server_st {
struct {
bool is_allocated:1;
bool is_initialized:1;
bool sockaddr_inited:1;
bool is_shutting_down:1;
} options;
uint32_t number_of_hosts;
uint32_t cursor_active;
in_port_t port;
int cached_errno;
memcached_socket_t fd;
uint32_t io_bytes_sent; /* # bytes sent since last read */
uint32_t server_failure_counter;
uint32_t weight;
struct { // Place any "state" sort variables in here.
bool is_corked:1;
bool is_dead:1;
} state;
struct {
uint32_t read;
uint32_t write;
} io_wait_count;
uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
uint8_t micro_version; // ditto
uint8_t minor_version; // ditto
memcached_connection_t type;
char *read_ptr;
char *cached_server_error;
size_t read_buffer_length;
size_t read_data_length;
size_t write_buffer_offset;
struct addrinfo *address_info;
time_t next_retry;
const memcached_st *root;
uint64_t limit_maxbytes;
char read_buffer[MEMCACHED_MAX_BUFFER];
char write_buffer[MEMCACHED_MAX_BUFFER];
char hostname[NI_MAXHOST];
};
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_server_cursor(const memcached_st *ptr,
const memcached_server_fn *callback,
void *context,
uint32_t number_of_callbacks);
LIBMEMCACHED_API
memcached_server_instance_st memcached_server_by_key(const 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_LOCAL
memcached_server_st *memcached_server_clone(memcached_server_st *destination,
const memcached_server_st *source);
LIBMEMCACHED_API
memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr);
LIBMEMCACHED_API
memcached_return_t memcached_server_add_udp(memcached_st *ptr,
const char *hostname,
in_port_t port);
LIBMEMCACHED_API
memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr,
const char *filename);
LIBMEMCACHED_API
memcached_return_t memcached_server_add(memcached_st *ptr,
const char *hostname, in_port_t port);
LIBMEMCACHED_API
memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr,
const char *hostname,
in_port_t port,
uint32_t weight);
LIBMEMCACHED_API
memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
const char *filename,
uint32_t weight);
LIBMEMCACHED_API
memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
in_port_t port,
uint32_t weight);
/**
Operations on Single Servers.
*/
LIBMEMCACHED_API
uint32_t memcached_server_response_count(memcached_server_instance_st self);
LIBMEMCACHED_API
const char *memcached_server_name(memcached_server_instance_st self);
LIBMEMCACHED_API
in_port_t memcached_server_port(memcached_server_instance_st self);
LIBMEMCACHED_API
const char *memcached_server_error(memcached_server_instance_st ptr);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* __LIBMEMCACHED_SERVER_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Types for libmemcached
*
*/
#ifndef __LIBMEMCACHED_SERVER_LIST_H__
#define __LIBMEMCACHED_SERVER_LIST_H__
#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);
LIBMEMCACHED_LOCAL
uint32_t memcached_servers_set_count(memcached_server_list_st servers, uint32_t count);
LIBMEMCACHED_LOCAL
memcached_server_st *memcached_server_list(const memcached_st *);
LIBMEMCACHED_LOCAL
void memcached_server_list_set(memcached_st *self, memcached_server_list_st list);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* __LIBMEMCACHED_SERVER_LIST_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Collect up the stats for a memcached server.
*
*/
#ifndef __LIBMEMCACHED_STATS_H__
#define __LIBMEMCACHED_STATS_H__
struct memcached_stat_st {
uint32_t connection_structures;
uint32_t curr_connections;
uint32_t curr_items;
uint32_t pid;
uint32_t pointer_size;
uint32_t rusage_system_microseconds;
uint32_t rusage_system_seconds;
uint32_t rusage_user_microseconds;
uint32_t rusage_user_seconds;
uint32_t threads;
uint32_t time;
uint32_t total_connections;
uint32_t total_items;
uint32_t uptime;
uint64_t bytes;
uint64_t bytes_read;
uint64_t bytes_written;
uint64_t cmd_get;
uint64_t cmd_set;
uint64_t evictions;
uint64_t get_hits;
uint64_t get_misses;
uint64_t limit_maxbytes;
char version[MEMCACHED_VERSION_STRING_LENGTH];
memcached_st *root;
};
#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(const 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
#endif /* __LIBMEMCACHED_STATS_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Storage related functions, aka set, replace,..
*
*/
#ifndef __LIBMEMCACHED_STORAGE_H__
#define __LIBMEMCACHED_STORAGE_H__
#include "libmemcached/memcached.h"
#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 *master_key, size_t master_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 *master_key, size_t master_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 *master_key, size_t master_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 *master_key, size_t master_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 *master_key, size_t master_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 *master_key, size_t master_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
#endif /* __LIBMEMCACHED_STORAGE_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: returns a human readable string for the error message
*
*/
#ifndef __LIBMEMCACHED_STRERROR_H__
#define __LIBMEMCACHED_STRERROR_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_STRERROR_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: String structure used for libmemcached.
*
*/
#ifndef __LIBMEMCACHED_STRING_H__
#define __LIBMEMCACHED_STRING_H__
/**
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;
const memcached_st *root;
struct {
bool is_allocated:1;
bool is_initialized:1;
} options;
};
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_LOCAL
memcached_string_st *memcached_string_create(const memcached_st *ptr,
memcached_string_st *string,
size_t initial_size);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_string_check(memcached_string_st *string, size_t need);
LIBMEMCACHED_LOCAL
char *memcached_string_c_copy(memcached_string_st *string);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_string_append_character(memcached_string_st *string,
char character);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_string_append(memcached_string_st *string,
const char *value, size_t length);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_string_reset(memcached_string_st *string);
LIBMEMCACHED_LOCAL
void memcached_string_free(memcached_string_st *string);
LIBMEMCACHED_LOCAL
size_t memcached_string_length(const memcached_string_st *self);
LIBMEMCACHED_LOCAL
size_t memcached_string_size(const memcached_string_st *self);
LIBMEMCACHED_LOCAL
const char *memcached_string_value(const memcached_string_st *self);
LIBMEMCACHED_LOCAL
char *memcached_string_value_mutable(const memcached_string_st *self);
LIBMEMCACHED_LOCAL
void memcached_string_set_length(memcached_string_st *self, size_t length);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_STRING_H__ */
//extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
\ No newline at end of file
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Types for libmemcached
*
*/
#ifndef __LIBMEMCACHED_TYPES_H__
#define __LIBMEMCACHED_TYPES_H__
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;
// All of the flavors of memcache_server_st
typedef struct memcached_server_st memcached_server_st;
typedef const struct memcached_server_st *memcached_server_instance_st;
typedef struct memcached_server_st *memcached_server_list_st;
typedef struct memcached_callback_st memcached_callback_st;
// The following two structures are internal, and never exposed to users.
typedef struct memcached_string_st memcached_string_st;
typedef struct memcached_continuum_item_st memcached_continuum_item_st;
#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);
/**
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);
typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);
typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);
typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server,
const char *key, size_t key_length,
const char *value, size_t value_length,
void *context);
/**
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
/**
@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;
#endif /* __LIBMEMCACHED_TYPES_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Connection pool library.
*
* Author: Trond Norbye, Brian Aker
*
*/
#ifndef __LIBMEMCACHED__UTIL_H__
#define __LIBMEMCACHED__UTIL_H__
#include <libmemcached/memcached_util.h>
#endif /* __LIBMEMCACHED__UTIL_H__ */