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