summaryrefslogtreecommitdiff
path: root/lib/common/compress.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
commit1fad07ce86fc2a506c59501d7fb7c7d7481525f6 (patch)
tree6ba41c514e2ddc692cb95a0fb2070dd222897c7c /lib/common/compress.c
parent5597dca9c6053cd19104e18d88edb199b32e3743 (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common/compress.c')
-rw-r--r--lib/common/compress.c33
1 files changed, 33 insertions, 0 deletions
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 <goliath@infraroot.at>
+ */
+#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()));
+}