summaryrefslogtreecommitdiff
path: root/src/common/compress_zlib.h
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-04-18 03:14:36 +0200
committerNick Mathewson <nickm@torproject.org>2017-04-25 08:06:01 -0400
commit9d5bc1a9354637aa59025f61e577c6d42f8c53ba (patch)
tree509406ce51588c6a7e38586c593313e5303327b4 /src/common/compress_zlib.h
parente6c6606a17841eaf263967254990db5e9443942d (diff)
downloadtor-9d5bc1a9354637aa59025f61e577c6d42f8c53ba.tar.gz
tor-9d5bc1a9354637aa59025f61e577c6d42f8c53ba.zip
Move zlib compression code into its own module.
This patch refactors the `torgzip` module to allow us to extend a common compression API to support multiple compression backends. Additionally we move the gzip/zlib code into its own module under the name `compress_zlib`. See https://bugs.torproject.org/21664
Diffstat (limited to 'src/common/compress_zlib.h')
-rw-r--r--src/common/compress_zlib.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/common/compress_zlib.h b/src/common/compress_zlib.h
new file mode 100644
index 0000000000..0862678da3
--- /dev/null
+++ b/src/common/compress_zlib.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2003, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file compress_zlib.h
+ * \brief Header for compress_zlib.c
+ **/
+
+#ifndef TOR_COMPRESS_ZLIB_H
+#define TOR_COMPRESS_ZLIB_H
+
+const char *
+tor_zlib_get_version_str(void);
+
+const char *
+tor_zlib_get_header_version_str(void);
+
+int
+tor_zlib_compress(char **out, size_t *out_len,
+ const char *in, size_t in_len,
+ compress_method_t method);
+
+int
+tor_zlib_uncompress(char **out, size_t *out_len,
+ const char *in, size_t in_len,
+ compress_method_t method,
+ int complete_only,
+ int protocol_warn_level);
+
+/** Internal state for an incremental zlib/gzip compression/decompression. */
+typedef struct tor_zlib_compress_state_t tor_zlib_compress_state_t;
+
+tor_zlib_compress_state_t *
+tor_zlib_compress_new(int compress,
+ compress_method_t method,
+ compression_level_t compression_level);
+
+tor_compress_output_t
+tor_zlib_compress_process(tor_zlib_compress_state_t *state,
+ char **out, size_t *out_len,
+ const char **in, size_t *in_len,
+ int finish);
+
+void
+tor_zlib_compress_free(tor_zlib_compress_state_t *state);
+
+size_t
+tor_zlib_compress_state_size(const tor_zlib_compress_state_t *state);
+
+size_t
+tor_zlib_get_total_allocation(void);
+
+#endif // TOR_COMPRESS_ZLIB_H.
+