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