libsparse: add callback output file type
Add a new output file subclass that will call a callback for
each block as it is written. Will be used to measure the space
used by each sparse block to allow resparsing files.
Also add sparse_file_callback, which will write out a sparse
file by calling the provided write function.
Change-Id: I18707bd9c357b68da319cc07982e93d1c2b2bee2
diff --git a/libsparse/output_file.h b/libsparse/output_file.h
index 24496f7..7a9fa24 100644
--- a/libsparse/output_file.h
+++ b/libsparse/output_file.h
@@ -23,6 +23,9 @@
struct output_file *open_output_fd(int fd, unsigned int block_size, int64_t len,
int gz, int sparse, int chunks, int crc);
+struct output_file *open_output_callback(int (*write)(void *, const void *, int),
+ void *priv, unsigned int block_size, int64_t len, int gz, int sparse,
+ int chunks, int crc);
int write_data_chunk(struct output_file *out, unsigned int len, void *data);
int write_fill_chunk(struct output_file *out, unsigned int len,
uint32_t fill_val);