diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-12-13 09:15:19 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-19 16:24:56 +0100 |
commit | 551dd3879c288a2b6b6fbaca5c09c04fbe994ff4 (patch) | |
tree | f3437139699edffd034168999854258f30c4023b /lib/io/xfrm.c | |
parent | 722ecf27eaf83685dfc6e92adc9d66f0107da5ea (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/xfrm.c')
-rw-r--r-- | lib/io/xfrm.c | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/lib/io/xfrm.c b/lib/io/xfrm.c deleted file mode 100644 index 22fd953..0000000 --- a/lib/io/xfrm.c +++ /dev/null @@ -1,67 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * compressor.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "internal.h" - -int io_compressor_id_from_name(const char *name) -{ - if (strcmp(name, "gzip") == 0) - return IO_COMPRESSOR_GZIP; - - if (strcmp(name, "xz") == 0) - return IO_COMPRESSOR_XZ; - - if (strcmp(name, "zstd") == 0) - return IO_COMPRESSOR_ZSTD; - - if (strcmp(name, "bzip2") == 0) - return IO_COMPRESSOR_BZIP2; - - return -1; -} - -const char *io_compressor_name_from_id(int id) -{ - if (id == IO_COMPRESSOR_GZIP) - return "gzip"; - - if (id == IO_COMPRESSOR_XZ) - return "xz"; - - if (id == IO_COMPRESSOR_ZSTD) - return "zstd"; - - if (id == IO_COMPRESSOR_BZIP2) - return "bzip2"; - - return NULL; -} - -bool io_compressor_exists(int id) -{ - switch (id) { -#ifdef WITH_GZIP - case IO_COMPRESSOR_GZIP: - return true; -#endif -#ifdef WITH_XZ - case IO_COMPRESSOR_XZ: - return true; -#endif -#if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM) - case IO_COMPRESSOR_ZSTD: - return true; -#endif -#ifdef WITH_BZIP2 - case IO_COMPRESSOR_BZIP2: - return true; -#endif - default: - break; - } - - return false; -} |