torgzip.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright 2003 Roger Dingledine
  2. * Copyright 2004-2007 Roger Dingledine, Nick Mathewson */
  3. /* See LICENSE for licensing information */
  4. /* $Id$ */
  5. /**
  6. * \file torgzip.h
  7. * \brief Headers for torgzip.h
  8. **/
  9. #ifndef __TORGZIP_H
  10. #define __TORGZIP_H
  11. #define TORGZIP_H_ID "$Id$"
  12. /** Enumeration of what kind of compression to use. Only ZLIB_METHOD is
  13. * guaranteed to be supported by the compress/uncompress functions here;
  14. * GZIP_METHOD may be supported if we built against zlib version 1.2 or later
  15. * and is_gzip_supported() returns true. */
  16. typedef enum {
  17. NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3
  18. } compress_method_t;
  19. int
  20. tor_gzip_compress(char **out, size_t *out_len,
  21. const char *in, size_t in_len,
  22. compress_method_t method);
  23. int
  24. tor_gzip_uncompress(char **out, size_t *out_len,
  25. const char *in, size_t in_len,
  26. compress_method_t method,
  27. int complete_only,
  28. int protocol_warn_level);
  29. int is_gzip_supported(void);
  30. compress_method_t detect_compression_method(const char *in, size_t in_len);
  31. /** Return values from tor_zlib_process; see that function's documentation for
  32. * details. */
  33. typedef enum {
  34. TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
  35. } tor_zlib_output_t;
  36. typedef struct tor_zlib_state_t tor_zlib_state_t;
  37. tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
  38. tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
  39. char **out, size_t *out_len,
  40. const char **in, size_t *in_len,
  41. int finish);
  42. void tor_zlib_free(tor_zlib_state_t *state);
  43. #endif