torgzip.h 1.8 KB

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