+/*
+ * Callback function for reading chunks. Called whenever the next chunk of
+ * uncompressed data is available, passing 'ctx' as the last argument. 'size' is
+ * guaranteed to be nonzero. Must return 0 on success, or a positive wimlib
+ * error code on failure.
+ */
+struct consume_chunk_callback {
+ int (*func)(const void *chunk, size_t size, void *ctx);
+ void *ctx;
+};
+
+/* Pass a chunk of data to the specified consume_chunk callback */
+static inline int
+consume_chunk(const struct consume_chunk_callback *cb,
+ const void *chunk, size_t size)
+{
+ return (*cb->func)(chunk, size, cb->ctx);
+}
+