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