3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering#pragma once
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering/***
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering This file is part of systemd.
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering Copyright 2015 Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering (at your option) any later version.
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering systemd is distributed in the hope that it will be useful, but
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering Lesser General Public License for more details.
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering***/
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include <bzlib.h>
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering#include <lzma.h>
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include <sys/types.h>
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering#include <zlib.h>
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering#include "macro.h"
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringtypedef enum ImportCompressType {
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering IMPORT_COMPRESS_UNKNOWN,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering IMPORT_COMPRESS_UNCOMPRESSED,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering IMPORT_COMPRESS_XZ,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering IMPORT_COMPRESS_GZIP,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering IMPORT_COMPRESS_BZIP2,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering _IMPORT_COMPRESS_TYPE_MAX,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering _IMPORT_COMPRESS_TYPE_INVALID = -1,
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering} ImportCompressType;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringtypedef struct ImportCompress {
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering ImportCompressType type;
587fec427c80b6c34dcf1d7570f891fcb652a7c5Lennart Poettering bool encoding;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering union {
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering lzma_stream xz;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering z_stream gzip;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering bz_stream bzip2;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering };
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering} ImportCompress;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringtypedef int (*ImportCompressCallback)(const void *data, size_t size, void *userdata);
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringvoid import_compress_free(ImportCompress *c);
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringint import_uncompress_detect(ImportCompress *c, const void *data, size_t size);
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringint import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCompressCallback callback, void *userdata);
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poettering
587fec427c80b6c34dcf1d7570f891fcb652a7c5Lennart Poetteringint import_compress_init(ImportCompress *c, ImportCompressType t);
587fec427c80b6c34dcf1d7570f891fcb652a7c5Lennart Poetteringint import_compress(ImportCompress *c, const void *data, size_t size, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
587fec427c80b6c34dcf1d7570f891fcb652a7c5Lennart Poetteringint import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size, size_t *buffer_allocated);
587fec427c80b6c34dcf1d7570f891fcb652a7c5Lennart Poettering
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart Poetteringconst char* import_compress_type_to_string(ImportCompressType t) _const_;
3e2cda698f05d7290a8b9444d2c7d5c2599b2a27Lennart PoetteringImportCompressType import_compress_type_from_string(const char *s) _pure_;