]>
Commit | Line | Data |
---|---|---|
1 | #pragma once | |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2015 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include <bzlib.h> | |
23 | #include <lzma.h> | |
24 | #include <sys/types.h> | |
25 | #include <zlib.h> | |
26 | ||
27 | #include "macro.h" | |
28 | ||
29 | typedef enum ImportCompressType { | |
30 | IMPORT_COMPRESS_UNKNOWN, | |
31 | IMPORT_COMPRESS_UNCOMPRESSED, | |
32 | IMPORT_COMPRESS_XZ, | |
33 | IMPORT_COMPRESS_GZIP, | |
34 | IMPORT_COMPRESS_BZIP2, | |
35 | _IMPORT_COMPRESS_TYPE_MAX, | |
36 | _IMPORT_COMPRESS_TYPE_INVALID = -1, | |
37 | } ImportCompressType; | |
38 | ||
39 | typedef struct ImportCompress { | |
40 | ImportCompressType type; | |
41 | bool encoding; | |
42 | union { | |
43 | lzma_stream xz; | |
44 | z_stream gzip; | |
45 | bz_stream bzip2; | |
46 | }; | |
47 | } ImportCompress; | |
48 | ||
49 | typedef int (*ImportCompressCallback)(const void *data, size_t size, void *userdata); | |
50 | ||
51 | void import_compress_free(ImportCompress *c); | |
52 | ||
53 | int import_uncompress_detect(ImportCompress *c, const void *data, size_t size); | |
54 | int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCompressCallback callback, void *userdata); | |
55 | ||
56 | int import_compress_init(ImportCompress *c, ImportCompressType t); | |
57 | int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated); | |
58 | int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated); | |
59 | ||
60 | const char* import_compress_type_to_string(ImportCompressType t) _const_; | |
61 | ImportCompressType import_compress_type_from_string(const char *s) _pure_; |