From 551dd3879c288a2b6b6fbaca5c09c04fbe994ff4 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 13 Dec 2022 09:15:19 +0100 Subject: Split stream compression out of libio Move it to a separate libxfrm library, where it can be independently tested as well. The bulk of the new code is also mainly test cases for the compressors. Signed-off-by: David Oberhollenzer --- lib/io/uncompress/istream_compressor.c | 67 ---------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 lib/io/uncompress/istream_compressor.c (limited to 'lib/io/uncompress/istream_compressor.c') diff --git a/lib/io/uncompress/istream_compressor.c b/lib/io/uncompress/istream_compressor.c deleted file mode 100644 index d4e1aea..0000000 --- a/lib/io/uncompress/istream_compressor.c +++ /dev/null @@ -1,67 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * istream_compressor.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "../internal.h" - -static const char *comp_get_filename(istream_t *strm) -{ - istream_comp_t *comp = (istream_comp_t *)strm; - - return comp->wrapped->get_filename(comp->wrapped); -} - -static void comp_destroy(sqfs_object_t *obj) -{ - istream_comp_t *comp = (istream_comp_t *)obj; - - comp->cleanup(comp); - sqfs_drop(comp->wrapped); - free(comp); -} - -istream_t *istream_compressor_create(istream_t *strm, int comp_id) -{ - istream_comp_t *comp = NULL; - istream_t *base; - - switch (comp_id) { - case IO_COMPRESSOR_GZIP: -#ifdef WITH_GZIP - comp = istream_gzip_create(strm->get_filename(strm)); -#endif - break; - case IO_COMPRESSOR_XZ: -#ifdef WITH_XZ - comp = istream_xz_create(strm->get_filename(strm)); -#endif - break; - case IO_COMPRESSOR_ZSTD: -#if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM) - comp = istream_zstd_create(strm->get_filename(strm)); -#endif - break; - case IO_COMPRESSOR_BZIP2: -#ifdef WITH_BZIP2 - comp = istream_bzip2_create(strm->get_filename(strm)); -#endif - break; - default: - break; - } - - if (comp == NULL) - return NULL; - - sqfs_object_init(comp, comp_destroy, NULL); - - comp->wrapped = sqfs_grab(strm); - - base = (istream_t *)comp; - base->get_filename = comp_get_filename; - base->buffer = comp->uncompressed; - base->eof = false; - return base; -} -- cgit v1.2.3