]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/import/import-compress.h
Merge pull request #2495 from heftig/master
[thirdparty/systemd.git] / src / import / import-compress.h
... / ...
CommitLineData
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
29typedef 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
39typedef 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
49typedef int (*ImportCompressCallback)(const void *data, size_t size, void *userdata);
50
51void import_compress_free(ImportCompress *c);
52
53int import_uncompress_detect(ImportCompress *c, const void *data, size_t size);
54int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCompressCallback callback, void *userdata);
55
56int import_compress_init(ImportCompress *c, ImportCompressType t);
57int import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
58int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
59
60const char* import_compress_type_to_string(ImportCompressType t) _const_;
61ImportCompressType import_compress_type_from_string(const char *s) _pure_;