Merge branch 'maint-0.2.1' into maint-0.2.2
[tor/rransom.git] / src / or / buffers.h
blobe50b9ff6fbf0a08e2d1f5ee0069ca322f602bba6
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2011, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file buffers.h
9 * \brief Header file for buffers.c.
10 **/
12 #ifndef _TOR_BUFFERS_H
13 #define _TOR_BUFFERS_H
15 buf_t *buf_new(void);
16 buf_t *buf_new_with_capacity(size_t size);
17 void buf_free(buf_t *buf);
18 void buf_clear(buf_t *buf);
19 void buf_shrink(buf_t *buf);
20 void buf_shrink_freelists(int free_all);
21 void buf_dump_freelist_sizes(int severity);
23 size_t buf_datalen(const buf_t *buf);
24 size_t buf_allocation(const buf_t *buf);
25 size_t buf_slack(const buf_t *buf);
27 int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof,
28 int *socket_error);
29 int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf);
31 int flush_buf(int s, buf_t *buf, size_t sz, size_t *buf_flushlen);
32 int flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen);
34 int write_to_buf(const char *string, size_t string_len, buf_t *buf);
35 int write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state,
36 const char *data, size_t data_len, int done);
37 int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen);
38 int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
39 int fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto);
40 int fetch_from_buf_http(buf_t *buf,
41 char **headers_out, size_t max_headerlen,
42 char **body_out, size_t *body_used, size_t max_bodylen,
43 int force_complete);
44 int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
45 int log_sockstype, int safe_socks);
46 int fetch_from_buf_socks_client(buf_t *buf, int state, char **reason);
47 int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
49 int peek_buf_has_control0_command(buf_t *buf);
51 void assert_buf_ok(buf_t *buf);
53 #ifdef BUFFERS_PRIVATE
54 int buf_find_string_offset(const buf_t *buf, const char *s, size_t n);
55 #endif
57 #endif