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