buffers.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 */
  6. /**
  7. * \file buffers.h
  8. * \brief Header file for buffers.c.
  9. **/
  10. #ifndef _TOR_BUFFERS_H
  11. #define _TOR_BUFFERS_H
  12. buf_t *buf_new(void);
  13. buf_t *buf_new_with_capacity(size_t size);
  14. void buf_free(buf_t *buf);
  15. void buf_clear(buf_t *buf);
  16. void buf_shrink(buf_t *buf);
  17. void buf_shrink_freelists(int free_all);
  18. void buf_dump_freelist_sizes(int severity);
  19. size_t buf_datalen(const buf_t *buf);
  20. size_t buf_allocation(const buf_t *buf);
  21. size_t buf_slack(const buf_t *buf);
  22. int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof,
  23. int *socket_error);
  24. int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf);
  25. int flush_buf(int s, buf_t *buf, size_t sz, size_t *buf_flushlen);
  26. int flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen);
  27. int write_to_buf(const char *string, size_t string_len, buf_t *buf);
  28. int write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state,
  29. const char *data, size_t data_len, int done);
  30. int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen);
  31. int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
  32. int fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto);
  33. int fetch_from_buf_http(buf_t *buf,
  34. char **headers_out, size_t max_headerlen,
  35. char **body_out, size_t *body_used, size_t max_bodylen,
  36. int force_complete);
  37. int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
  38. int log_sockstype, int safe_socks);
  39. int fetch_from_buf_socks_client(buf_t *buf, int state, char **reason);
  40. int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
  41. int peek_buf_has_control0_command(buf_t *buf);
  42. void assert_buf_ok(buf_t *buf);
  43. #ifdef BUFFERS_PRIVATE
  44. int buf_find_string_offset(const buf_t *buf, const char *s, size_t n);
  45. #endif
  46. #endif