diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-01 22:42:49 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-01 22:42:49 +0200 |
commit | 307107ecd2fc3ffbf6fe91497daf767700f3572f (patch) | |
tree | 87c2c5993ab10cd4aa791a4e6d34f251db208ed2 /lib/sqfshelper/compress.c | |
parent | 2e28c45601a57b1d23e9cad33d2bdcc59e8a3f4f (diff) |
Move command line processing stuff out of compressor code
This commit moves stuff like printing help text, command line option
processing and enumerating available processors on stdout out of
the generic compressor code.
The option string is replaced with a structure that directly exposese
the tweakable parameters for all compressors. A function for parsing
the command line arguments into this structure is added in sqfshelper.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper/compress.c')
-rw-r--r-- | lib/sqfshelper/compress.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/sqfshelper/compress.c b/lib/sqfshelper/compress.c new file mode 100644 index 0000000..3d53e9e --- /dev/null +++ b/lib/sqfshelper/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 "highlevel.h" + +E_SQFS_COMPRESSOR compressor_get_default(void) +{ + if (compressor_exists(SQFS_COMP_XZ)) + return SQFS_COMP_XZ; + + if (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 (compressor_exists(i)) + printf("\t%s\n", compressor_name_from_id(i)); + } + + printf("\nDefault compressor: %s\n", + compressor_name_from_id(compressor_get_default())); +} |