Added srcdir includes so that the include files could be found in vpath builds.
[m6w6/libmemcached] / libmemcached / memcached_io.h
1 /* Server IO, Not public! */
2 #include <memcached.h>
3
4 #ifndef __MEMCACHED_IO_H__
5 #define __MEMCACHED_IO_H__
6
7 #define MAX_UDP_DATAGRAM_LENGTH 1400
8 #define UDP_DATAGRAM_HEADER_LENGTH 8
9 #define UDP_REQUEST_ID_MSG_SIG_DIGITS 10
10 #define UDP_REQUEST_ID_THREAD_MASK 0xFFFF << UDP_REQUEST_ID_MSG_SIG_DIGITS
11 #define get_udp_datagram_request_id(A) ntohs((A)->request_id)
12 #define get_udp_datagram_seq_num(A) ntohs((A)->sequence_number)
13 #define get_udp_datagram_num_datagrams(A) ntohs((A)->num_datagrams)
14 #define get_msg_num_from_request_id(A) ( (A) & (~(UDP_REQUEST_ID_THREAD_MASK)) )
15 #define get_thread_id_from_request_id(A) ( (A) & (UDP_REQUEST_ID_THREAD_MASK) ) >> UDP_REQUEST_ID_MSG_SIG_DIGITS
16 #define generate_udp_request_thread_id(A) (A) << UDP_REQUEST_ID_MSG_SIG_DIGITS
17 #define UDP_REQUEST_ID_MAX_THREAD_ID get_thread_id_from_request_id(0xFFFF)
18
19 struct udp_datagram_header_st {
20 uint16_t request_id;
21 uint16_t sequence_number;
22 uint16_t num_datagrams;
23 uint16_t reserved;
24 };
25
26 ssize_t memcached_io_write(memcached_server_st *ptr,
27 const void *buffer, size_t length, char with_flush);
28 void memcached_io_reset(memcached_server_st *ptr);
29 memcached_return memcached_io_read(memcached_server_st *ptr,
30 void *buffer, size_t length, ssize_t *nread);
31 /* Read a line (terminated by '\n') into the buffer */
32 memcached_return memcached_io_readline(memcached_server_st *ptr,
33 char *buffer_ptr,
34 size_t size);
35 memcached_return memcached_io_close(memcached_server_st *ptr);
36 /* Read n bytes of data from the server and store them in dta */
37 memcached_return memcached_safe_read(memcached_server_st *ptr,
38 void *dta,
39 size_t size);
40 /* Read a single response from the server */
41 memcached_return memcached_read_one_response(memcached_server_st *ptr,
42 char *buffer, size_t buffer_length,
43 memcached_result_st *result);
44 memcached_return memcached_io_init_udp_header(memcached_server_st *ptr,
45 uint16_t thread_id);
46
47 memcached_server_st *memcached_io_get_readable_server(memcached_st *memc);
48
49 #endif /* __MEMCACHED_IO_H__ */