Back to index

tor  0.2.3.19-rc
torgzip.h
Go to the documentation of this file.
00001 /* Copyright (c) 2003, Roger Dingledine
00002  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00003  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00004 /* See LICENSE for licensing information */
00005 
00011 #ifndef _TOR_TORGZIP_H
00012 #define _TOR_TORGZIP_H
00013 
00018 typedef enum {
00019   NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3
00020 } compress_method_t;
00021 
00022 int
00023 tor_gzip_compress(char **out, size_t *out_len,
00024                   const char *in, size_t in_len,
00025                   compress_method_t method);
00026 int
00027 tor_gzip_uncompress(char **out, size_t *out_len,
00028                     const char *in, size_t in_len,
00029                     compress_method_t method,
00030                     int complete_only,
00031                     int protocol_warn_level);
00032 
00033 int is_gzip_supported(void);
00034 
00035 compress_method_t detect_compression_method(const char *in, size_t in_len);
00036 
00039 typedef enum {
00040   TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
00041 } tor_zlib_output_t;
00043 typedef struct tor_zlib_state_t tor_zlib_state_t;
00044 tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
00045 
00046 tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
00047                                    char **out, size_t *out_len,
00048                                    const char **in, size_t *in_len,
00049                                    int finish);
00050 void tor_zlib_free(tor_zlib_state_t *state);
00051 
00052 #endif
00053