From 1fad07ce86fc2a506c59501d7fb7c7d7481525f6 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 7 Oct 2019 13:54:24 +0200 Subject: Rename libsqfshelper to libcommon That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer --- lib/common/compress.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/common/compress.c (limited to 'lib/common/compress.c') diff --git a/lib/common/compress.c b/lib/common/compress.c new file mode 100644 index 0000000..04e1f40 --- /dev/null +++ b/lib/common/compress.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * compress.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "common.h" + +E_SQFS_COMPRESSOR compressor_get_default(void) +{ + if (sqfs_compressor_exists(SQFS_COMP_XZ)) + return SQFS_COMP_XZ; + + if (sqfs_compressor_exists(SQFS_COMP_ZSTD)) + return SQFS_COMP_ZSTD; + + return SQFS_COMP_GZIP; +} + +void compressor_print_available(void) +{ + int i; + + fputs("Available compressors:\n", stdout); + + for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) { + if (sqfs_compressor_exists(i)) + printf("\t%s\n", sqfs_compressor_name_from_id(i)); + } + + printf("\nDefault compressor: %s\n", + sqfs_compressor_name_from_id(compressor_get_default())); +} -- cgit v1.2.3