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