summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-25 09:13:39 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-27 01:05:42 +0100
commit3c1a4c2548cbbae96f44469278b53046c8b48868 (patch)
treecf528c5338f850012744e3376eae502767bfdc21 /lib/common
parentc9429aeece3b8642de637f7a21e68046bd690658 (diff)
Add a function to the compressor interface to get the configuration
This allows getting the compressor configuration back after creating it, for various purposes. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/comp_lzo.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index a0c838a..8d0335e 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -48,6 +48,7 @@ static const struct {
typedef struct {
sqfs_compressor_t base;
+ size_t block_size;
int algorithm;
int level;
@@ -182,6 +183,22 @@ static sqfs_s32 lzo_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return len;
}
+static void lzo_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const lzo_compressor_t *lzo = (const lzo_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_LZO;
+ cfg->block_size = lzo->block_size;
+
+ cfg->opt.lzo.algorithm = lzo->algorithm;
+ cfg->opt.lzo.level = lzo->level;
+
+ if (base->do_block == lzo_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *lzo_create_copy(sqfs_compressor_t *cmp)
{
lzo_compressor_t *other = (lzo_compressor_t *)cmp;
@@ -242,11 +259,13 @@ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
if (lzo == NULL)
return NULL;
+ lzo->block_size = cfg->block_size;
lzo->algorithm = cfg->opt.lzo.algorithm;
lzo->level = cfg->opt.lzo.level;
lzo->buf_size = scratch_size;
lzo->work_size = lzo_algs[cfg->opt.lzo.algorithm].bufsize;
+ base->get_configuration = lzo_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
lzo_uncomp_block : lzo_comp_block;
base->write_options = lzo_write_options;