summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-14 16:17:15 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commit5f637f97c3427dc6e1a68678aefee1f62ca34d62 (patch)
tree75254191b93adce81e188069d54de383c0123984 /include
parent0a0cbefc6ebb6174aad3e6f0b8a6dea87aed49da (diff)
Implement ostream compressor wrapper
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/fstream.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/include/fstream.h b/include/fstream.h
index cc562ca..cb992f8 100644
--- a/include/fstream.h
+++ b/include/fstream.h
@@ -55,6 +55,21 @@ enum {
OSTREAM_OPEN_SPARSE = 0x02,
};
+enum {
+ /**
+ * @brief Deflate compressor with gzip headers.
+ *
+ * This actually creates a gzip compatible file, including a
+ * gzip header and trailer.
+ */
+ FSTREAM_COMPRESSOR_GZIP = 1,
+
+ FSTREAM_COMPRESSOR_XZ = 2,
+
+ FSTREAM_COMPRESSOR_MIN = 1,
+ FSTREAM_COMPRESSOR_MAX = 2,
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -109,6 +124,27 @@ SQFS_INTERNAL istream_t *istream_open_file(const char *path);
SQFS_INTERNAL istream_t *istream_open_stdin(void);
/**
+ * @brief Create an output stream that transparently compresses data.
+ *
+ * @memberof ostream_t
+ *
+ * This function creates an output stream that transparently compresses all
+ * data appended to it and writes the compressed data to an underlying, wrapped
+ * output stream.
+ *
+ * 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 output stream on success, NULL on failure.
+ */
+SQFS_INTERNAL ostream_t *ostream_compressor_create(ostream_t *strm,
+ int comp_id);
+
+/**
* @brief Append a block of data to an output stream.
*
* @memberof ostream_t
@@ -245,6 +281,33 @@ SQFS_INTERNAL sqfs_s32 ostream_append_from_istream(ostream_t *out,
istream_t *in,
sqfs_u32 size);
+/**
+ * @brief Resolve a compressor name to an ID.
+ *
+ * @param name A compressor name.
+ *
+ * @return A compressor ID on success, -1 on failure.
+ */
+SQFS_INTERNAL int fstream_compressor_id_from_name(const char *name);
+
+/**
+ * @brief Resolve a id to a compressor name.
+ *
+ * @param id A compressor ID.
+ *
+ * @return A compressor name on success, NULL on failure.
+ */
+SQFS_INTERNAL const char *fstream_compressor_name_from_id(int id);
+
+/**
+ * @brief Check if support for a given compressor has been built in.
+ *
+ * @param id A compressor ID.
+ *
+ * @return True if the compressor is supported, false if not.
+ */
+SQFS_INTERNAL bool fstream_compressor_exists(int id);
+
#ifdef __cplusplus
}
#endif