aboutsummaryrefslogtreecommitdiff
path: root/lib/xfrm/compress.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 11:21:30 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 13:51:49 +0100
commitcdccc69c62579b0c13b35fad0728079652b8f3c9 (patch)
tree9fa54c710f73c5e08a9c8466e7a712eb63ee07ac /lib/xfrm/compress.c
parent2182129c8f359c4fa1390eaba7a65b595ccd4182 (diff)
Move library source into src sub-directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/xfrm/compress.c')
-rw-r--r--lib/xfrm/compress.c102
1 files changed, 0 insertions, 102 deletions
diff --git a/lib/xfrm/compress.c b/lib/xfrm/compress.c
deleted file mode 100644
index fbd6987..0000000
--- a/lib/xfrm/compress.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * compress.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "xfrm/compress.h"
-#include "config.h"
-
-#include <string.h>
-
-static const struct {
- int id;
- const char *name;
- const sqfs_u8 *magic;
- size_t count;
- xfrm_stream_t *(*mk_comp_stream)(const compressor_config_t *);
- xfrm_stream_t *(*mk_decomp_stream)(void);
-} compressors[] = {
-#ifdef WITH_GZIP
- { XFRM_COMPRESSOR_GZIP, "gzip", (const sqfs_u8 *)"\x1F\x8B\x08", 3,
- compressor_stream_gzip_create, decompressor_stream_gzip_create },
-#endif
-#ifdef WITH_XZ
- { XFRM_COMPRESSOR_XZ, "xz", (const sqfs_u8 *)("\xFD" "7zXZ"), 6,
- compressor_stream_xz_create, decompressor_stream_xz_create },
-#endif
-#if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM)
- { XFRM_COMPRESSOR_ZSTD, "zstd",
- (const sqfs_u8 *)"\x28\xB5\x2F\xFD", 4,
- compressor_stream_zstd_create, decompressor_stream_zstd_create },
-#endif
-#ifdef WITH_BZIP2
- { XFRM_COMPRESSOR_BZIP2, "bzip2", (const sqfs_u8 *)"BZh", 3,
- compressor_stream_bzip2_create, decompressor_stream_bzip2_create },
-#endif
-};
-
-int xfrm_compressor_id_from_name(const char *name)
-{
- size_t i;
-
- for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
- if (strcmp(name, compressors[i].name) == 0)
- return compressors[i].id;
- }
-
- return -1;
-}
-
-int xfrm_compressor_id_from_magic(const void *data, size_t count)
-{
- size_t i;
- int ret;
-
- for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
- if (compressors[i].count > count)
- continue;
-
- ret = memcmp(compressors[i].magic, data, compressors[i].count);
- if (ret == 0)
- return compressors[i].id;
- }
-
- return -1;
-}
-
-const char *xfrm_compressor_name_from_id(int id)
-{
- size_t i;
-
- for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
- if (compressors[i].id == id)
- return compressors[i].name;
- }
-
- return NULL;
-}
-
-xfrm_stream_t *compressor_stream_create(int id, const compressor_config_t *cfg)
-{
- size_t i;
-
- for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
- if (compressors[i].id == id)
- return compressors[i].mk_comp_stream(cfg);
- }
-
- return NULL;
-}
-
-xfrm_stream_t *decompressor_stream_create(int id)
-{
- size_t i;
-
- for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
- if (compressors[i].id == id)
- return compressors[i].mk_decomp_stream();
- }
-
- return NULL;
-}