summaryrefslogtreecommitdiff
path: root/include/fstream.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-14 14:59:31 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commitc9f5cfd3df2706da940a39d6d816ad084ba80fbd (patch)
tree3aac86238ce840c3c25ff89892f6109c081f60d8 /include/fstream.h
parentf757737060d4daebb24a32e90d912661428708a8 (diff)
Implement istream decompression support
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/fstream.h')
-rw-r--r--include/fstream.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/fstream.h b/include/fstream.h
index cb992f8..c62e5ad 100644
--- a/include/fstream.h
+++ b/include/fstream.h
@@ -145,6 +145,46 @@ SQFS_INTERNAL ostream_t *ostream_compressor_create(ostream_t *strm,
int comp_id);
/**
+ * @brief Create an input stream that transparently uncompresses data.
+ *
+ * @memberof istream_t
+ *
+ * This function creates an input stream that wraps an underlying input stream
+ * that is compressed and transparently uncompresses the data when reading
+ * from it.
+ *
+ * The new stream takes ownership of the wrapped stream and destroys it when
+ * the compressor stream is destroyed. If this function fails, the wrapped
+ * stream is also destroyed.
+ *
+ * @param strm A pointer to another stream that should be wrapped.
+ * @param comp_id An identifier describing the compressor to use.
+ *
+ * @return A pointer to an input stream on success, NULL on failure.
+ */
+SQFS_INTERNAL istream_t *istream_compressor_create(istream_t *strm,
+ int comp_id);
+
+/**
+ * @brief Probe the buffered data in an istream to check if it is compressed.
+ *
+ * @memberof istream_t
+ *
+ * This function peeks into the internal buffer of an input stream to check
+ * for magic signatures of various compressors.
+ *
+ * @param strm A pointer to an input stream to check
+ * @param probe A callback used to check if raw/decoded data matches an
+ * expected format. Returns 0 if not, -1 on failure and +1
+ * on success.
+ *
+ * @return A compressor ID on success, 0 if no match was found, -1 on failure.
+ */
+SQFS_INTERNAL int istream_detect_compressor(istream_t *strm,
+ int (*probe)(const sqfs_u8 *data,
+ size_t size));
+
+/**
* @brief Append a block of data to an output stream.
*
* @memberof ostream_t