]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e3bff60a MP |
2 | #pragma once |
3 | ||
6e866b33 | 4 | #if HAVE_BZIP2 |
4c89c718 | 5 | #include <bzlib.h> |
6e866b33 | 6 | #endif |
e3bff60a | 7 | #include <lzma.h> |
4c89c718 | 8 | #include <sys/types.h> |
e3bff60a | 9 | #include <zlib.h> |
e3bff60a MP |
10 | |
11 | #include "macro.h" | |
12 | ||
13 | typedef enum ImportCompressType { | |
14 | IMPORT_COMPRESS_UNKNOWN, | |
15 | IMPORT_COMPRESS_UNCOMPRESSED, | |
16 | IMPORT_COMPRESS_XZ, | |
17 | IMPORT_COMPRESS_GZIP, | |
18 | IMPORT_COMPRESS_BZIP2, | |
19 | _IMPORT_COMPRESS_TYPE_MAX, | |
20 | _IMPORT_COMPRESS_TYPE_INVALID = -1, | |
21 | } ImportCompressType; | |
22 | ||
23 | typedef struct ImportCompress { | |
24 | ImportCompressType type; | |
25 | bool encoding; | |
26 | union { | |
27 | lzma_stream xz; | |
28 | z_stream gzip; | |
6e866b33 | 29 | #if HAVE_BZIP2 |
e3bff60a | 30 | bz_stream bzip2; |
6e866b33 | 31 | #endif |
e3bff60a MP |
32 | }; |
33 | } ImportCompress; | |
34 | ||
35 | typedef int (*ImportCompressCallback)(const void *data, size_t size, void *userdata); | |
36 | ||
37 | void import_compress_free(ImportCompress *c); | |
38 | ||
39 | int import_uncompress_detect(ImportCompress *c, const void *data, size_t size); | |
40 | int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCompressCallback callback, void *userdata); | |
41 | ||
42 | int import_compress_init(ImportCompress *c, ImportCompressType t); | |
43 | int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated); | |
44 | int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated); | |
45 | ||
46 | const char* import_compress_type_to_string(ImportCompressType t) _const_; | |
47 | ImportCompressType import_compress_type_from_string(const char *s) _pure_; |