summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/sqfs/block_processor.h11
-rw-r--r--include/sqfs/block_writer.h11
-rw-r--r--include/sqfs/compressor.h9
-rw-r--r--include/sqfs/data_reader.h11
-rw-r--r--include/sqfs/dir_reader.h9
-rw-r--r--include/sqfs/dir_writer.h11
-rw-r--r--include/sqfs/frag_table.h9
-rw-r--r--include/sqfs/id_table.h11
-rw-r--r--include/sqfs/io.h9
-rw-r--r--include/sqfs/meta_reader.h11
-rw-r--r--include/sqfs/meta_writer.h11
-rw-r--r--include/sqfs/predef.h27
-rw-r--r--include/sqfs/xattr_reader.h11
-rw-r--r--include/sqfs/xattr_writer.h11
14 files changed, 55 insertions, 107 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index 41cb3d3..cef4459 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -33,6 +33,8 @@
*
* @brief Abstracts generating of file data and fragment blocks.
*
+ * @implements sqfs_object_t
+ *
* This data structure provides a simple begin/append/end interface
* to generate file data blocks (see @ref sqfs_block_processor_begin_file,
* @ref sqfs_block_processor_append and @ref sqfs_block_processor_end
@@ -130,15 +132,6 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_frag_table_t *tbl);
/**
- * @brief Destroy a data writer and free all memory used by it.
- *
- * @memberof sqfs_block_processor_t
- *
- * @param proc A pointer to a data writer object.
- */
-SQFS_API void sqfs_block_processor_destroy(sqfs_block_processor_t *proc);
-
-/**
* @brief Start writing a file.
*
* @memberof sqfs_block_processor_t
diff --git a/include/sqfs/block_writer.h b/include/sqfs/block_writer.h
index e921141..bd1ddfc 100644
--- a/include/sqfs/block_writer.h
+++ b/include/sqfs/block_writer.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_block_writer_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts writing and deduplicating of data and fragment blocks.
*/
@@ -190,15 +192,6 @@ SQFS_API int sqfs_block_writer_set_hooks(sqfs_block_writer_t *wr,
const sqfs_block_hooks_t *hooks);
/**
- * @brief Destroy a block writer object.
- *
- * @memberof sqfs_block_writer_t
- *
- * @param wr A pointer to a block writer object.
- */
-SQFS_API void sqfs_block_writer_destroy(sqfs_block_writer_t *wr);
-
-/**
* @brief Submit a data block to a blokc writer.
*
* @memberof sqfs_block_writer_t
diff --git a/include/sqfs/compressor.h b/include/sqfs/compressor.h
index 5e0be5d..c0fafda 100644
--- a/include/sqfs/compressor.h
+++ b/include/sqfs/compressor.h
@@ -32,16 +32,13 @@
/**
* @interface sqfs_compressor_t
*
+ * @extends sqfs_object_t
+ *
* @brief Encapsultes a compressor with a simple interface to compress or
* extract chunks of data.
*/
struct sqfs_compressor_t {
- /**
- * @brief Destroy a compressor and free all memory used by it.
- *
- * @param cmp A pointer to a compressor object.
- */
- void (*destroy)(sqfs_compressor_t *cmp);
+ sqfs_object_t base;
/**
* @brief Write compressor options to disk if non-default settings
diff --git a/include/sqfs/data_reader.h b/include/sqfs/data_reader.h
index 0c4918c..e058017 100644
--- a/include/sqfs/data_reader.h
+++ b/include/sqfs/data_reader.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_data_reader_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts access to data blocks stored in a SquashFS image.
*
* A SquashFS image can contain a series of file data blocks between the
@@ -69,15 +71,6 @@ SQFS_API sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
sqfs_compressor_t *cmp);
/**
- * @brief Destroy a data reader instance and free all memory used by it.
- *
- * @memberof sqfs_data_reader_t
- *
- * @param data A pointer to a data reader object.
- */
-SQFS_API void sqfs_data_reader_destroy(sqfs_data_reader_t *data);
-
-/**
* @brief Read and decode the fragment table from disk.
*
* @memberof sqfs_data_reader_t
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h
index 82121ed..7b55eb0 100644
--- a/include/sqfs/dir_reader.h
+++ b/include/sqfs/dir_reader.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_dir_reader_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts reading of directory entries
*
* SquashFS stores directory listings and inode structures separated from
@@ -167,13 +169,6 @@ SQFS_API sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
sqfs_file_t *file);
/**
- * @brief Cleanup a directory reader and free all its memory.
- *
- * @memberof sqfs_dir_reader_t
- */
-SQFS_API void sqfs_dir_reader_destroy(sqfs_dir_reader_t *rd);
-
-/**
* @brief Navigate a directory reader to the location of a directory
* represented by an inode.
*
diff --git a/include/sqfs/dir_writer.h b/include/sqfs/dir_writer.h
index 05d054b..e4a26c7 100644
--- a/include/sqfs/dir_writer.h
+++ b/include/sqfs/dir_writer.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_dir_writer_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts generating of directory entries
*
* SquashFS stores directory entries and inodes separated from each other. The
@@ -102,15 +104,6 @@ SQFS_API sqfs_dir_writer_t *sqfs_dir_writer_create(sqfs_meta_writer_t *dm,
sqfs_u32 flags);
/**
- * @brief Destroy a directory writer and free all its memory.
- *
- * @memberof sqfs_dir_writer_t
- *
- * @param writer A pointer to a directory writer object.
- */
-SQFS_API void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer);
-
-/**
* @brief Begin writing a directory, i.e. reset and initialize all internal
* state neccessary.
*
diff --git a/include/sqfs/frag_table.h b/include/sqfs/frag_table.h
index 45ba645..9a66692 100644
--- a/include/sqfs/frag_table.h
+++ b/include/sqfs/frag_table.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_frag_table_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts reading, writing and management of the fragment table.
*/
@@ -50,13 +52,6 @@ extern "C" {
SQFS_API sqfs_frag_table_t *sqfs_frag_table_create(sqfs_u32 flags);
/**
- * @brief Destroy a fragment table and release all associated memory.
- *
- * @memberof sqfs_frag_table_t
- */
-SQFS_API void sqfs_frag_table_destroy(sqfs_frag_table_t *tbl);
-
-/**
* @brief Load a fragment table from a SquashFS image.
*
* @memberof sqfs_frag_table_t
diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h
index 67990db..706687f 100644
--- a/include/sqfs/id_table.h
+++ b/include/sqfs/id_table.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_id_table_t
*
+ * @implements sqfs_object_t
+ *
* @brief A simple data structure that encapsulates ID to index mapping for
* user and group IDs.
*
@@ -57,15 +59,6 @@ extern "C" {
SQFS_API sqfs_id_table_t *sqfs_id_table_create(sqfs_u32 flags);
/**
- * @brief Destroy an ID table object and free all memory used by it.
- *
- * @memberof sqfs_id_table_t
- *
- * @param tbl A pointer to an ID table object.
- */
-SQFS_API void sqfs_id_table_destroy(sqfs_id_table_t *tbl);
-
-/**
* @brief Resolve a 32 bit ID to a unique 16 bit index.
*
* @memberof sqfs_id_table_t
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index 1108a61..578c4fb 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -60,15 +60,12 @@ typedef enum {
/**
* @interface sqfs_file_t
*
+ * @extends sqfs_object_t
+ *
* @brief Abstracts file I/O to make it easy to embedd SquashFS.
*/
struct sqfs_file_t {
- /**
- * @brief Close the file and destroy the interface implementation.
- *
- * @param file A pointer to the file object.
- */
- void (*destroy)(sqfs_file_t *file);
+ sqfs_object_t base;
/**
* @brief Read a chunk of data from an absolute position.
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index e2203de..e8b40d4 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_meta_reader_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts reading of meta data blocks.
*
* SquashFS stores meta data by dividing it into fixed size (8k) chunks
@@ -70,15 +72,6 @@ SQFS_API sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
sqfs_u64 limit);
/**
- * @brief Destroy a meta data reader and free all memory used by it.
- *
- * @memberof sqfs_meta_reader_t
- *
- * @param m A pointer to a meta data reader.
- */
-SQFS_API void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
-
-/**
* @brief Seek to a specific meta data block and offset.
*
* @memberof sqfs_meta_reader_t
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index cf8e16c..be151cc 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_meta_writer_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts generating of meta data blocks, either in memory or
* directly on disk.
*
@@ -88,15 +90,6 @@ SQFS_API sqfs_meta_writer_t *sqfs_meta_writer_create(sqfs_file_t *file,
sqfs_u32 flags);
/**
- * @brief Destroy a meta data writer and free all memory used by it.
- *
- * @memberof sqfs_meta_writer_t
- *
- * @param m A pointer to a meta data writer.
- */
-SQFS_API void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m);
-
-/**
* @brief Finish the current block, even if it isn't full yet.
*
* @memberof sqfs_meta_writer_t
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index d8cc293..6ca3503 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -57,6 +57,12 @@
#endif
#endif
+#ifdef _MSC_VER
+ #define SQFS_INLINE __forceinline
+#else
+ #define SQFS_INLINE __inline__ __attribute__((always_inline))
+#endif
+
typedef uint8_t sqfs_u8;
typedef uint16_t sqfs_u16;
typedef uint32_t sqfs_u32;
@@ -108,4 +114,25 @@ typedef struct sqfs_xattr_value_t sqfs_xattr_value_t;
typedef struct sqfs_xattr_id_t sqfs_xattr_id_t;
typedef struct sqfs_xattr_id_table_t sqfs_xattr_id_table_t;
+/**
+ * @interface sqfs_object_t
+ *
+ * @brief Base interface for all libsquashfs in-memory data structures.
+ */
+typedef struct sqfs_object_t {
+ void (*destroy)(struct sqfs_object_t *instance);
+} sqfs_object_t;
+
+/**
+ * @brief Destroy an object and free all its memory
+ *
+ * @memberof sqfs_object_t
+ *
+ * @param obj A pointer to an object
+ */
+static SQFS_INLINE void sqfs_destroy(void *obj)
+{
+ ((sqfs_object_t *)obj)->destroy(obj);
+}
+
#endif /* SQFS_PREDEF_H */
diff --git a/include/sqfs/xattr_reader.h b/include/sqfs/xattr_reader.h
index 6544a21..7912de4 100644
--- a/include/sqfs/xattr_reader.h
+++ b/include/sqfs/xattr_reader.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_xattr_reader_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts read access to extended attributes in a SquashFS filesystem
*
* SquashFS stores extended attributes using multiple levels of indirection.
@@ -95,15 +97,6 @@ SQFS_API sqfs_xattr_reader_t *sqfs_xattr_reader_create(sqfs_file_t *file,
sqfs_compressor_t *cmp);
/**
- * @brief Destroy an xattr reader and free all memory used by it
- *
- * @memberof sqfs_xattr_reader_t
- *
- * @param xr A pointer to an xattr reader instance
- */
-SQFS_API void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr);
-
-/**
* @brief Load the locations of the xattr meta data blocks into memory
*
* @memberof sqfs_xattr_reader_t
diff --git a/include/sqfs/xattr_writer.h b/include/sqfs/xattr_writer.h
index 5b18659..b25215e 100644
--- a/include/sqfs/xattr_writer.h
+++ b/include/sqfs/xattr_writer.h
@@ -31,6 +31,8 @@
/**
* @struct sqfs_xattr_writer_t
*
+ * @implements sqfs_object_t
+ *
* @brief Abstracts writing of extended attributes to a SquashFS filesystem.
*
* This data structure provides a simple, abstract interface to recording
@@ -64,15 +66,6 @@ extern "C" {
SQFS_API sqfs_xattr_writer_t *sqfs_xattr_writer_create(void);
/**
- * @brief Destroy an xattr writer instance and free all memory it used.
- *
- * @memberof sqfs_xattr_writer_t
- *
- * @param xwr A pointer to an xattr writer instance.
- */
-SQFS_API void sqfs_xattr_writer_destroy(sqfs_xattr_writer_t *xwr);
-
-/**
* @brief Begin recording a block of key-value pairs.
*
* @memberof sqfs_xattr_writer_t