2007-12-12 21:09:01 +00:00
|
|
|
/* Copyright (c) 2003, Roger Dingledine
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2008-02-07 05:31:47 +00:00
|
|
|
* Copyright (c) 2007-2008, The Tor Project, Inc. */
|
2004-09-02 18:22:51 +00:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file torgzip.h
|
|
|
|
* \brief Headers for torgzip.h
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __TORGZIP_H
|
|
|
|
#define __TORGZIP_H
|
2004-11-29 22:25:31 +00:00
|
|
|
#define TORGZIP_H_ID "$Id$"
|
2004-09-02 18:22:51 +00:00
|
|
|
|
2007-02-05 18:33:52 +00:00
|
|
|
/** Enumeration of what kind of compression to use. Only ZLIB_METHOD is
|
|
|
|
* guaranteed to be supported by the compress/uncompress functions here;
|
|
|
|
* GZIP_METHOD may be supported if we built against zlib version 1.2 or later
|
|
|
|
* and is_gzip_supported() returns true. */
|
2005-01-19 22:40:33 +00:00
|
|
|
typedef enum {
|
2006-10-09 03:39:06 +00:00
|
|
|
NO_METHOD=0, GZIP_METHOD=1, ZLIB_METHOD=2, UNKNOWN_METHOD=3
|
2005-01-19 22:40:33 +00:00
|
|
|
} compress_method_t;
|
2004-09-02 18:22:51 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
tor_gzip_compress(char **out, size_t *out_len,
|
2004-10-14 04:31:16 +00:00
|
|
|
const char *in, size_t in_len,
|
|
|
|
compress_method_t method);
|
2004-09-02 18:22:51 +00:00
|
|
|
int
|
|
|
|
tor_gzip_uncompress(char **out, size_t *out_len,
|
2004-10-14 04:31:16 +00:00
|
|
|
const char *in, size_t in_len,
|
2005-10-13 22:48:09 +00:00
|
|
|
compress_method_t method,
|
2006-02-12 23:44:02 +00:00
|
|
|
int complete_only,
|
|
|
|
int protocol_warn_level);
|
2004-09-02 18:22:51 +00:00
|
|
|
|
|
|
|
int is_gzip_supported(void);
|
|
|
|
|
2006-10-09 02:35:51 +00:00
|
|
|
compress_method_t detect_compression_method(const char *in, size_t in_len);
|
2005-01-19 22:40:33 +00:00
|
|
|
|
2007-02-05 18:33:52 +00:00
|
|
|
/** Return values from tor_zlib_process; see that function's documentation for
|
|
|
|
* details. */
|
2006-06-18 07:24:29 +00:00
|
|
|
typedef enum {
|
|
|
|
TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
|
2007-02-05 18:33:52 +00:00
|
|
|
} tor_zlib_output_t;
|
2006-06-18 07:24:29 +00:00
|
|
|
typedef struct tor_zlib_state_t tor_zlib_state_t;
|
|
|
|
tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
|
|
|
|
|
|
|
|
tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
|
|
|
|
char **out, size_t *out_len,
|
|
|
|
const char **in, size_t *in_len,
|
|
|
|
int finish);
|
|
|
|
void tor_zlib_free(tor_zlib_state_t *state);
|
|
|
|
|
2004-09-02 18:22:51 +00:00
|
|
|
#endif
|
2005-06-09 19:03:31 +00:00
|
|
|
|