From 457873fbf7fd6d40242722f3a51b41428302d0ca Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Thu, 4 Jan 2018 15:11:24 +0000 Subject: Add fz_output_as_stream This provides a way for some output streams to also be read, a feature needed for the sake of document signing. Currently this is supported only for file output. --- include/mupdf/fitz/output.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/mupdf/fitz') diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h index 0425e353..2530be47 100644 --- a/include/mupdf/fitz/output.h +++ b/include/mupdf/fitz/output.h @@ -5,6 +5,7 @@ #include "mupdf/fitz/context.h" #include "mupdf/fitz/buffer.h" #include "mupdf/fitz/string-util.h" +#include "mupdf/fitz/stream.h" /* Generic output streams - generalise between outputting to a file, @@ -62,6 +63,13 @@ typedef void (fz_output_close_fn)(fz_context *ctx, void *state); */ typedef void (fz_output_drop_fn)(fz_context *ctx, void *state); +/* + fz_stream_from_output_fn: A function type for use when implementing + fz_outputs. The supplied function of this type is called + when the fz_stream_from_output is called. +*/ +typedef fz_stream *(fz_stream_from_output_fn)(fz_context *ctx, void *state); + struct fz_output_s { @@ -71,6 +79,7 @@ struct fz_output_s fz_output_tell_fn *tell; fz_output_close_fn *close; fz_output_drop_fn *drop; + fz_stream_from_output_fn *as_stream; }; /* @@ -171,6 +180,16 @@ void fz_close_output(fz_context *, fz_output *); */ void fz_drop_output(fz_context *, fz_output *); +/* + fz_stream_from_output: obtain the fz_output in the form of a fz_stream + + This allows data to be read back from some forms of fz_output object. + When finished reading, the fz_stream should be released by calling + fz_drop_stream. Until the fz_stream is dropped, no further operations + should be performed on the fz_output object. +*/ +fz_stream *fz_stream_from_output(fz_context *, fz_output *); + /* fz_write_data: Write data to output. -- cgit v1.2.3