diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-04-20 15:56:38 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-25 08:10:09 -0400 |
commit | 1c77d8690caa1ad80b9d9581cac8eddae95e82d1 (patch) | |
tree | 87cb3f07a2919f11fef5eafe671bd97f8c825710 /src/common/compress.c | |
parent | 04682d302aeeb0c2a0d9859bc0c1feee38daf16a (diff) | |
download | tor-1c77d8690caa1ad80b9d9581cac8eddae95e82d1.tar.gz tor-1c77d8690caa1ad80b9d9581cac8eddae95e82d1.zip |
Add function to check if a given compression method is supported.
This patch adds support for checking if a given `compress_method_t` is
supported by the currently running Tor instance using
`tor_compress_supports_method()`.
See: https://bugs.torproject.org/21662
Diffstat (limited to 'src/common/compress.c')
-rw-r--r-- | src/common/compress.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index 52ff13258a..725dde53e0 100644 --- a/src/common/compress.c +++ b/src/common/compress.c @@ -154,6 +154,25 @@ detect_compression_method(const char *in, size_t in_len) } } +/** Return 1 if a given <b>method</b> is supported; otherwise 0. */ +int +tor_compress_supports_method(compress_method_t method) +{ + switch (method) { + case GZIP_METHOD: + case ZLIB_METHOD: + return tor_zlib_method_supported(); + case LZMA_METHOD: + return tor_lzma_method_supported(); + case ZSTD_METHOD: + return tor_zstd_method_supported(); + case NO_METHOD: + case UNKNOWN_METHOD: + default: + return 0; + } +} + /** Return the approximate number of bytes allocated for all * supported compression schemas. */ size_t |