TOR: update to v0.2.5.12
[tomato.git] / release / src / router / tor / src / common / torgzip.h
blob5db03fe6e0ba1897b437d549f682c668deb2a944
1 /* Copyright (c) 2003, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2013, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file torgzip.h
8 * \brief Headers for torgzip.h
9 **/
11 #ifndef TOR_TORGZIP_H
12 #define TOR_TORGZIP_H
14 /** Enumeration of what kind of compression to use. Only ZLIB_METHOD is
15 * guaranteed to be supported by the compress/uncompress functions here;
16 * GZIP_METHOD may be supported if we built against zlib version 1.2 or later
17 * and is_gzip_supported() returns true. */
18 typedef enum {
19 NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3
20 } compress_method_t;
22 int
23 tor_gzip_compress(char **out, size_t *out_len,
24 const char *in, size_t in_len,
25 compress_method_t method);
26 int
27 tor_gzip_uncompress(char **out, size_t *out_len,
28 const char *in, size_t in_len,
29 compress_method_t method,
30 int complete_only,
31 int protocol_warn_level);
33 int is_gzip_supported(void);
35 const char *
36 tor_zlib_get_version_str(void);
38 const char *
39 tor_zlib_get_header_version_str(void);
41 compress_method_t detect_compression_method(const char *in, size_t in_len);
43 /** Return values from tor_zlib_process; see that function's documentation for
44 * details. */
45 typedef enum {
46 TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
47 } tor_zlib_output_t;
48 /** Internal state for an incremental zlib compression/decompression. */
49 typedef struct tor_zlib_state_t tor_zlib_state_t;
50 tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
52 tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
53 char **out, size_t *out_len,
54 const char **in, size_t *in_len,
55 int finish);
56 void tor_zlib_free(tor_zlib_state_t *state);
58 #endif