625a446ab52abb78e4fc7d5b0acfb0e2145d6c5b
[m6w6/libmemcached] / src / libmemcached / io.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 void initialize_binary_request(memcached_instance_st *server, protocol_binary_request_header &);
19
20 bool memcached_io_write(memcached_instance_st *ptr);
21
22 ssize_t memcached_io_write(memcached_instance_st *ptr, const void *buffer, size_t length,
23 bool with_flush);
24
25 bool memcached_io_writev(memcached_instance_st *ptr, libmemcached_io_vector_st vector[],
26 const size_t number_of, const bool with_flush);
27
28 memcached_return_t memcached_io_wait_for_write(memcached_instance_st *);
29 memcached_return_t memcached_io_wait_for_read(memcached_instance_st *);
30
31 void memcached_io_reset(memcached_instance_st *ptr);
32
33 memcached_return_t memcached_io_read(memcached_instance_st *ptr, void *buffer, size_t length,
34 ssize_t &nread);
35
36 /* Read a line (terminated by '\n') into the buffer */
37 memcached_return_t memcached_io_readline(memcached_instance_st *ptr, char *buffer_ptr, size_t size,
38 size_t &total);
39
40 /* Read n bytes of data from the server and store them in dta */
41 memcached_return_t memcached_safe_read(memcached_instance_st *ptr, void *dta, const size_t size);
42
43 memcached_instance_st *memcached_io_get_readable_server(memcached_st *memc, memcached_return_t &);
44
45 memcached_return_t memcached_io_slurp(memcached_instance_st *ptr);
46
47 #define IO_POLL_CONNECT 0
48 memcached_return_t memcached_io_poll(memcached_instance_st *inst, int16_t events = IO_POLL_CONNECT, int prev_errno = 0);