summaryrefslogtreecommitdiff
path: root/include/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 22:42:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 22:42:49 +0200
commit307107ecd2fc3ffbf6fe91497daf767700f3572f (patch)
tree87c2c5993ab10cd4aa791a4e6d34f251db208ed2 /include/sqfs
parent2e28c45601a57b1d23e9cad33d2bdcc59e8a3f4f (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 'include/sqfs')
-rw-r--r--include/sqfs/compress.h91
1 files changed, 81 insertions, 10 deletions
diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h
index 3860353..cb3994f 100644
--- a/include/sqfs/compress.h
+++ b/include/sqfs/compress.h
@@ -51,22 +51,93 @@ struct compressor_t {
void (*destroy)(compressor_t *stream);
};
+typedef struct {
+ uint16_t id;
+ uint16_t flags;
+ uint32_t block_size;
+
+ union {
+ struct {
+ uint16_t level;
+ uint16_t window_size;
+ } gzip;
+
+ struct {
+ uint16_t level;
+ } zstd;
+
+ struct {
+ uint16_t algorithm;
+ uint16_t level;
+ } lzo;
+
+ struct {
+ uint32_t dict_size;
+ } xz;
+ } opt;
+} compressor_config_t;
+
+typedef enum {
+ SQFS_COMP_FLAG_LZ4_HC = 0x0001,
+ SQFS_COMP_FLAG_LZ4_ALL = 0x0001,
+
+ SQFS_COMP_FLAG_XZ_X86 = 0x0001,
+ SQFS_COMP_FLAG_XZ_POWERPC = 0x0002,
+ SQFS_COMP_FLAG_XZ_IA64 = 0x0004,
+ SQFS_COMP_FLAG_XZ_ARM = 0x0008,
+ SQFS_COMP_FLAG_XZ_ARMTHUMB = 0x0010,
+ SQFS_COMP_FLAG_XZ_SPARC = 0x0020,
+ SQFS_COMP_FLAG_XZ_ALL = 0x003F,
+
+ SQFS_COMP_FLAG_GZIP_DEFAULT = 0x0001,
+ SQFS_COMP_FLAG_GZIP_FILTERED = 0x0002,
+ SQFS_COMP_FLAG_GZIP_HUFFMAN = 0x0004,
+ SQFS_COMP_FLAG_GZIP_RLE = 0x0008,
+ SQFS_COMP_FLAG_GZIP_FIXED = 0x0010,
+ SQFS_COMP_FLAG_GZIP_ALL = 0x001F,
+
+ SQFS_COMP_FLAG_UNCOMPRESS = 0x8000,
+ SQFS_COMP_FLAG_GENERIC_ALL = 0x8000,
+} SQFS_COMP_FLAG;
+
+typedef enum {
+ SQFS_LZO1X_1 = 0,
+ SQFS_LZO1X_1_11 = 1,
+ SQFS_LZO1X_1_12 = 2,
+ SQFS_LZO1X_1_15 = 3,
+ SQFS_LZO1X_999 = 4,
+} SQFS_LZO_ALGORITHM;
+
+#define SQFS_GZIP_DEFAULT_LEVEL (9)
+#define SQFS_GZIP_DEFAULT_WINDOW (15)
+
+#define SQFS_LZO_DEFAULT_ALG SQFS_LZO1X_999
+#define SQFS_LZO_DEFAULT_LEVEL (8)
+
+#define SQFS_ZSTD_DEFAULT_LEVEL (15)
+
+#define SQFS_GZIP_MIN_LEVEL (1)
+#define SQFS_GZIP_MAX_LEVEL (9)
+
+#define SQFS_LZO_MIN_LEVEL (0)
+#define SQFS_LZO_MAX_LEVEL (9)
+
+#define SQFS_ZSTD_MIN_LEVEL (1)
+#define SQFS_ZSTD_MAX_LEVEL (22)
+
+#define SQFS_GZIP_MIN_WINDOW (8)
+#define SQFS_GZIP_MAX_WINDOW (15)
+
#ifdef __cplusplus
extern "C" {
#endif
-bool compressor_exists(E_SQFS_COMPRESSOR id);
-
-/* block_size is the configured block size for the SquashFS image. Needed
- by some compressors to set internal defaults. */
-compressor_t *compressor_create(E_SQFS_COMPRESSOR id, bool compress,
- size_t block_size, char *options);
+int compressor_config_init(compressor_config_t *cfg, E_SQFS_COMPRESSOR id,
+ size_t block_size, uint16_t flags);
-void compressor_print_help(E_SQFS_COMPRESSOR id);
-
-void compressor_print_available(void);
+bool compressor_exists(E_SQFS_COMPRESSOR id);
-E_SQFS_COMPRESSOR compressor_get_default(void);
+compressor_t *compressor_create(const compressor_config_t *cfg);
const char *compressor_name_from_id(E_SQFS_COMPRESSOR id);