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