aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 18:46:50 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 18:46:50 +0200
commit320ae4f8e752f6652c7b5c8201d7267cd4de17c1 (patch)
tree4423514c5433dc3b70e32fd5950a139827b94ac9 /include
parentf92cf3b98f51d355c92900f1d316b141b2b9d4fd (diff)
Cleanup naming scheme of compressor
Add sqfs_* prefix to compressor, move implementation prefix up front. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/data_reader.h2
-rw-r--r--include/data_writer.h2
-rw-r--r--include/highlevel.h15
-rw-r--r--include/sqfs/block_processor.h4
-rw-r--r--include/sqfs/compress.h39
-rw-r--r--include/sqfs/id_table.h4
-rw-r--r--include/sqfs/meta_reader.h2
-rw-r--r--include/sqfs/meta_writer.h2
-rw-r--r--include/sqfs/table.h4
-rw-r--r--include/sqfs/xattr.h2
10 files changed, 39 insertions, 37 deletions
diff --git a/include/data_reader.h b/include/data_reader.h
index feba7a1..a45c3e2 100644
--- a/include/data_reader.h
+++ b/include/data_reader.h
@@ -24,7 +24,7 @@ typedef struct data_reader_t data_reader_t;
Prints error messsages to stderr on failure.
*/
data_reader_t *data_reader_create(int fd, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
void data_reader_destroy(data_reader_t *data);
diff --git a/include/data_writer.h b/include/data_writer.h
index 081c468..89eb2c8 100644
--- a/include/data_writer.h
+++ b/include/data_writer.h
@@ -35,7 +35,7 @@ enum {
Returns NULL on failure and prints errors to stderr.
*/
-data_writer_t *data_writer_create(sqfs_super_t *super, compressor_t *cmp,
+data_writer_t *data_writer_create(sqfs_super_t *super, sqfs_compressor_t *cmp,
int outfd, size_t devblksize,
unsigned int num_jobs);
diff --git a/include/highlevel.h b/include/highlevel.h
index 701754a..ffcc44c 100644
--- a/include/highlevel.h
+++ b/include/highlevel.h
@@ -24,7 +24,7 @@
#include <stddef.h>
typedef struct {
- compressor_t *cmp;
+ sqfs_compressor_t *cmp;
data_reader_t *data;
sqfs_super_t super;
fstree_t fs;
@@ -53,7 +53,7 @@ enum RDTREE_FLAGS {
Returns 0 on success. Prints error messages to stderr on failure.
*/
int sqfs_serialize_fstree(int outfd, sqfs_super_t *super, fstree_t *fs,
- compressor_t *cmp, sqfs_id_table_t *idtbl);
+ sqfs_compressor_t *cmp, sqfs_id_table_t *idtbl);
/*
Convert a generic squashfs tree node to an fstree_t node.
@@ -71,8 +71,8 @@ tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode,
Returns 0 on success. Prints error messages to stderr on failure.
*/
-int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
- int fd, int flags);
+int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
+ sqfs_compressor_t *cmp, int fd, int flags);
/*
Generate a squahfs xattr table from a file system tree.
@@ -80,7 +80,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
Returns 0 on success. Prints error messages to stderr on failure.
*/
int write_xattr(int outfd, fstree_t *fs, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
/*
Generate an NFS export table.
@@ -88,7 +88,7 @@ int write_xattr(int outfd, fstree_t *fs, sqfs_super_t *super,
Returns 0 on success. Prints error messages to stderr on failure.
*/
int write_export_table(int outfd, fstree_t *fs, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
/* Print out fancy statistics for squashfs packing tools */
void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super);
@@ -107,7 +107,8 @@ void compressor_print_available(void);
E_SQFS_COMPRESSOR compressor_get_default(void);
-int compressor_cfg_init_options(compressor_config_t *cfg, E_SQFS_COMPRESSOR id,
+int compressor_cfg_init_options(sqfs_compressor_config_t *cfg,
+ E_SQFS_COMPRESSOR id,
size_t block_size, char *options);
void compressor_print_help(E_SQFS_COMPRESSOR id);
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index 552bd89..bde0a2e 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -68,7 +68,7 @@ extern "C" {
#endif
sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
- compressor_t *cmp,
+ sqfs_compressor_t *cmp,
unsigned int num_workers,
void *user,
sqfs_block_cb callback);
@@ -99,7 +99,7 @@ int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
Convenience function to process a data block. Returns 0 on success,
prints to stderr on failure.
*/
-int sqfs_block_process(sqfs_block_t *block, compressor_t *cmp,
+int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
uint8_t *scratch, size_t scratch_size);
#ifdef __cplusplus
diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h
index cb3994f..c826c84 100644
--- a/include/sqfs/compress.h
+++ b/include/sqfs/compress.h
@@ -4,8 +4,8 @@
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#ifndef COMPRESS_H
-#define COMPRESS_H
+#ifndef SQFS_COMPRESS_H
+#define SQFS_COMPRESS_H
#include "config.h"
@@ -16,20 +16,22 @@
#include "sqfs/super.h"
-typedef struct compressor_t compressor_t;
+typedef struct sqfs_compressor_t sqfs_compressor_t;
/* Encapsultes a compressor with a simple interface to compress or
uncompress/extract blocks of data. */
-struct compressor_t {
+struct sqfs_compressor_t {
+ void (*destroy)(sqfs_compressor_t *cmp);
+
/* Write compressor options to the output file if necessary.
Returns the number of bytes written or -1 on failure.
Internally prints error messages to stderr. */
- int (*write_options)(compressor_t *cmp, int fd);
+ int (*write_options)(sqfs_compressor_t *cmp, int fd);
/* Read compressor options to the input file.
Returns zero on success, -1 on failure.
Internally prints error messages to stderr. */
- int (*read_options)(compressor_t *cmp, int fd);
+ int (*read_options)(sqfs_compressor_t *cmp, int fd);
/*
Compress or uncompress a chunk of data.
@@ -41,14 +43,12 @@ struct compressor_t {
Internally prints compressor specific error messages to stderr.
*/
- ssize_t (*do_block)(compressor_t *cmp, const uint8_t *in, size_t size,
- uint8_t *out, size_t outsize);
+ ssize_t (*do_block)(sqfs_compressor_t *cmp, const uint8_t *in,
+ size_t size, uint8_t *out, size_t outsize);
/* create another compressor just like this one, i.e.
with the exact same settings */
- compressor_t *(*create_copy)(compressor_t *cmp);
-
- void (*destroy)(compressor_t *stream);
+ sqfs_compressor_t *(*create_copy)(sqfs_compressor_t *cmp);
};
typedef struct {
@@ -75,7 +75,7 @@ typedef struct {
uint32_t dict_size;
} xz;
} opt;
-} compressor_config_t;
+} sqfs_compressor_config_t;
typedef enum {
SQFS_COMP_FLAG_LZ4_HC = 0x0001,
@@ -132,19 +132,20 @@ typedef enum {
extern "C" {
#endif
-int compressor_config_init(compressor_config_t *cfg, E_SQFS_COMPRESSOR id,
- size_t block_size, uint16_t flags);
+int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg,
+ E_SQFS_COMPRESSOR id,
+ size_t block_size, uint16_t flags);
-bool compressor_exists(E_SQFS_COMPRESSOR id);
+bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id);
-compressor_t *compressor_create(const compressor_config_t *cfg);
+sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg);
-const char *compressor_name_from_id(E_SQFS_COMPRESSOR id);
+const char *sqfs_compressor_name_from_id(E_SQFS_COMPRESSOR id);
-int compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out);
+int sqfs_compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out);
#ifdef __cplusplus
}
#endif
-#endif /* COMPRESS_H */
+#endif /* SQFS_COMPRESS_H */
diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h
index 65e77bc..0e652ec 100644
--- a/include/sqfs/id_table.h
+++ b/include/sqfs/id_table.h
@@ -32,12 +32,12 @@ int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out);
/* Write an ID table to a SquashFS image.
Returns 0 on success. Internally prints error message to stderr. */
int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
/* Read an ID table from a SquashFS image.
Returns 0 on success. Internally prints error messages to stderr. */
int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index,
uint32_t *out);
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index 1517e67..6f0d184 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -24,7 +24,7 @@ extern "C" {
Start offset and limit can be specified to do bounds checking against
a subregion of the filesystem image.
*/
-sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, compressor_t *cmp,
+sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, sqfs_compressor_t *cmp,
uint64_t start, uint64_t limit);
void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index a155f3e..bb14993 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -24,7 +24,7 @@ extern "C" {
If keep_in_mem is true, the blocks are collected in memory and must
be explicitly flushed to disk using meta_write_write_to_file.
*/
-sqfs_meta_writer_t *sqfs_meta_writer_create(int fd, compressor_t *cmp,
+sqfs_meta_writer_t *sqfs_meta_writer_create(int fd, sqfs_compressor_t *cmp,
bool keep_in_mem);
void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m);
diff --git a/include/sqfs/table.h b/include/sqfs/table.h
index bc4c7e8..b5eeb54 100644
--- a/include/sqfs/table.h
+++ b/include/sqfs/table.h
@@ -28,10 +28,10 @@ extern "C" {
Returns 0 on success. Internally prints error messages to stderr.
*/
-int sqfs_write_table(int outfd, sqfs_super_t *super, compressor_t *cmp,
+int sqfs_write_table(int outfd, sqfs_super_t *super, sqfs_compressor_t *cmp,
const void *data, size_t table_size, uint64_t *start);
-void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size,
+void *sqfs_read_table(int fd, sqfs_compressor_t *cmp, size_t table_size,
uint64_t location, uint64_t lower_limit,
uint64_t upper_limit);
diff --git a/include/sqfs/xattr.h b/include/sqfs/xattr.h
index fb855f5..5350534 100644
--- a/include/sqfs/xattr.h
+++ b/include/sqfs/xattr.h
@@ -65,7 +65,7 @@ bool sqfs_has_xattr(const char *key);
void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr);
sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd, sqfs_super_t *super,
- compressor_t *cmp);
+ sqfs_compressor_t *cmp);
int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
sqfs_xattr_id_t *desc);