diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-08 11:28:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-08 11:28:07 +0000 |
commit | 0f4a6dabe46a75ceb41f962e9f60e4a164feb9ec (patch) | |
tree | 3507d5e0cd7da76fa245989a01f22786138e6ed6 /src/include/gnunet_container_lib.h | |
parent | 383814672c031e49c4dffca0a69af3b0973d2248 (diff) | |
download | gnunet-0f4a6dabe46a75ceb41f962e9f60e4a164feb9ec.tar.gz gnunet-0f4a6dabe46a75ceb41f962e9f60e4a164feb9ec.zip |
export compression/decompression functions
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r-- | src/include/gnunet_container_lib.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 4375cdbb1..aa6a17150 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -36,6 +36,45 @@ | |||
36 | /* add error and config prototypes */ | 36 | /* add error and config prototypes */ |
37 | #include "gnunet_crypto_lib.h" | 37 | #include "gnunet_crypto_lib.h" |
38 | 38 | ||
39 | |||
40 | /** | ||
41 | * Try to compress the given block of data using libz. Only returns | ||
42 | * the compressed block if compression worked and the new block is | ||
43 | * actually smaller. Decompress using #GNUNET_decompress(). | ||
44 | * | ||
45 | * @param data block to compress; if compression | ||
46 | * resulted in a smaller block, the first | ||
47 | * bytes of data are updated to the compressed | ||
48 | * data | ||
49 | * @param old_size number of bytes in data | ||
50 | * @param[out] result set to the compressed data, if compression worked | ||
51 | * @param[out] new_size set to size of result, if compression worked | ||
52 | * @return #GNUNET_YES if compression reduce the size, | ||
53 | * #GNUNET_NO if compression did not help | ||
54 | */ | ||
55 | int | ||
56 | GNUNET_try_compression (const char *data, | ||
57 | size_t old_size, | ||
58 | char **result, | ||
59 | size_t *new_size); | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Decompress input, return the decompressed data as output. Dual to | ||
64 | * #GNUNET_try_compression(). Caller must set @a output_size to the | ||
65 | * number of bytes that were originally compressed. | ||
66 | * | ||
67 | * @param input compressed data | ||
68 | * @param input_size number of bytes in input | ||
69 | * @param output_size expected size of the output | ||
70 | * @return NULL on error, buffer of @a output_size decompressed bytes otherwise | ||
71 | */ | ||
72 | char * | ||
73 | GNUNET_decompress (const char *input, | ||
74 | size_t input_size, | ||
75 | size_t output_size); | ||
76 | |||
77 | |||
39 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR | 78 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR |
40 | 79 | ||
41 | #include <extractor.h> | 80 | #include <extractor.h> |