summaryrefslogtreecommitdiff
path: root/include/frag_reader.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/frag_reader.h')
-rw-r--r--include/frag_reader.h61
1 files changed, 16 insertions, 45 deletions
diff --git a/include/frag_reader.h b/include/frag_reader.h
index 8a3d4cc..623cc8d 100644
--- a/include/frag_reader.h
+++ b/include/frag_reader.h
@@ -8,11 +8,7 @@
#include <stdint.h>
#include <stddef.h>
-/**
- * @struct frag_reader_t
- *
- * @brief A simple interface for accessing fragments in a SquashFS image
- */
+/* A simple interface for accessing fragments in a SquashFS image */
typedef struct {
sqfs_fragment_t *tbl;
size_t num_fragments;
@@ -25,51 +21,26 @@ typedef struct {
uint8_t buffer[];
} frag_reader_t;
-/**
- * @brief Create a fragment reader
- *
- * @memberof frag_reader_t
- *
- * This function internally reads and decodes the fragment table from the
- * image and prints error messages to stderr on the way if it fails.
- *
- * @param super A pointer to the SquashFS super block read from the image
- * @param fd A file descriptor of opened the SquashFS image
- * @param cmp A pointer to a compressor object to be used for reading meta
- * data blocks from the image.
- *
- * @return A pointer to a new fragment reader or NULL on failure
- */
+/* Reads and decodes the fragment table from the image. Cleans up after itself
+ and prints error messages to stderr on the way if it fails. */
frag_reader_t *frag_reader_create(sqfs_super_t *super, int fd,
compressor_t *cmp);
-/**
- * @brief Destroy a fragment reader and free all memory it uses
- *
- * @memberof frag_reader_t
- *
- * @param f A pointer to a fragment reader object
- */
void frag_reader_destroy(frag_reader_t *f);
-/**
- * @brief Read tail-end packed data from a fragment
- *
- * @memberof frag_reader_t
- *
- * This function internally takes care of loading and uncompressing the
- * fragment block (which is skipped if it has already been loaded earlier).
- * It prints error messages to stderr on the way if it fails, including such
- * errors as trying to index beyond the fragment table.
- *
- * @param f A pointer to a fragment reader object
- * @param index A fragment index such as stored in an inode
- * @param offset A byte offset into the fragment block addressed by the index
- * @param buffer A pointer to a destination buffer to copy decoded data to
- * @param size The number of bytes to copy into the destination buffer
- *
- * @return Zero on success, -1 on failure
- */
+/*
+ Read data from a fragment.
+
+ The function takes care of loading and uncompressing the fragment block
+ (which is skipped if it has already been loaded earlier).
+
+ `index` is a fragment index from an inode, `offset` is a byte offset into
+ the fragment block and `size` is the number of bytes to copy into the
+ destination buffer.
+
+ Returns 0 on success. Prints error messages to stderr on failure (including
+ index out of bounds).
+*/
int frag_reader_read(frag_reader_t *f, size_t index, size_t offset,
void *buffer, size_t size);