1 /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 #ifndef MEMCACHED_PROTOCOL_INTERNAL_H
3 #define MEMCACHED_PROTOCOL_INTERNAL_H
8 #include <netinet/in.h>
11 /* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
12 * optimize the conversion functions, but the prototypes generate warnings
13 * from gcc. The conversion methods isn't the bottleneck for my app, so
14 * just remove the warnings by undef'ing the optimization ..
24 /* Define this here, which will turn on the visibilty controls while we're
25 * building libmemcached.
27 #define BUILDING_LIBMEMCACHED 1
29 #include <libmemcached/protocol_handler.h>
30 #include <libmemcached/protocol/cache.h>
32 struct memcached_binary_protocol_st
{
33 struct memcached_binary_protocol_callback_st
*callback
;
34 memcached_binary_protocol_recv_func recv
;
35 memcached_binary_protocol_send_func send
;
37 size_t input_buffer_size
;
39 /* @todo use multiple sized buffers */
40 cache_t
*buffer_cache
;
45 /* Pointer to the data */
47 /* The offset to the first byte into the buffer that is used */
49 /* The offset into the buffer for the first free byte */
51 /* The number of bytes in the buffer */
53 /* Pointer to the next buffer in the chain */
54 struct chunk_st
*next
;
57 #define CHUNK_BUFFERSIZE 2048
59 struct memcached_binary_protocol_client_st
{
60 struct memcached_binary_protocol_st
*root
;
64 /* Linked list of data to send */
65 struct chunk_st
*output
;
66 struct chunk_st
*output_tail
;
71 size_t input_buffer_size
;
72 size_t input_buffer_offset
;
76 struct chunk_st
*input
;
77 /* Pointer to the last chunk to avoid the need to traverse the complete list */
78 struct chunk_st
*input_tail
;
79 size_t bytes_available
;
81 protocol_binary_request_header
*current_command
;
86 bool memcached_binary_protocol_pedantic_check_request(protocol_binary_request_header
*request
);
89 bool memcached_binary_protocol_pedantic_check_response(protocol_binary_request_header
*request
,
90 protocol_binary_response_header
*response
);