From 0abe1816da2706f87432c4e04918ad0eec902479 Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Date: Fri, 16 Jun 2023 19:46:46 +0200
Subject: Move data writer ostream into libsquashfs

It is mainly a very thin wrapper on top of the block processor so far.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 include/common.h               |  5 -----
 include/sqfs/block_processor.h | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)

(limited to 'include')

diff --git a/include/common.h b/include/common.h
index d4827a8..8e24d03 100644
--- a/include/common.h
+++ b/include/common.h
@@ -63,11 +63,6 @@ int parse_size(const char *what, size_t *out, const char *str,
 
 void print_size(sqfs_u64 size, char *buffer, bool round_to_int);
 
-sqfs_ostream_t *data_writer_ostream_create(const char *filename,
-					   sqfs_block_processor_t *proc,
-					   sqfs_inode_generic_t **inode,
-					   int flags);
-
 /*
   Parse a comma separated list (e.g. "uid=...,gid=..." of defaults for
   fstree nodes. Used for command line parsing. Returns 0 on success,
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index a5eed33..cc40605 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -381,6 +381,27 @@ SQFS_API int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
 SQFS_API const sqfs_block_processor_stats_t
 *sqfs_block_processor_get_stats(const sqfs_block_processor_t *proc);
 
+/**
+ * @brief Create an @ref sqfs_ostream_t that writes to a data writer
+ *
+ * @memberof sqfs_block_processor_t
+ *
+ * @param out Receives a pointer to an @ref sqfs_ostream_t on success
+ * @param filename A filename that the ostream returns when queried.
+ * @param proc A pointer to a data writer object.
+ * @param inode An optional pointer to a pointer to an inode. If not NULL, the
+ *              block processor creates a file inode and stores a pointer to
+ *              it here and keeps updating the inode as the file grows.
+ * @param flags A combination of @ref SQFS_BLK_FLAGS that can be used to
+ *              micro manage how the data is processed.
+ *
+ * @return Zero on sucess, a negative @ref SQFS_ERROR value on failure.
+ */
+SQFS_API int sqfs_block_processor_create_ostream(sqfs_ostream_t **out,
+						 const char *filename,
+						 sqfs_block_processor_t *proc,
+						 sqfs_inode_generic_t **inode,
+						 sqfs_u32 flags);
 #ifdef __cplusplus
 }
 #endif
-- 
cgit v1.2.3