Add fz_write_stream function.
authorRobin Watts <[email protected]>
Wed, 12 Jun 2024 11:13:08 +0000 (12:13 +0100)
committerRobin Watts <[email protected]>
Tue, 23 Jul 2024 19:02:01 +0000 (20:02 +0100)
Copy a stream to an output.

include/mupdf/fitz/output.h
source/fitz/output.c

index ce7039d81f372eacd384f79978106c5fb4c8234b..7e17eaa3ae2af15d3aaf46626127d78bf2e5f241 100644 (file)
@@ -326,6 +326,11 @@ void fz_write_bits(fz_context *ctx, fz_output *out, unsigned int data, int num_b
 */
 void fz_write_bits_sync(fz_context *ctx, fz_output *out);
 
+/**
+       Copy the stream contents to the output.
+*/
+void fz_write_stream(fz_context *ctx, fz_output *out, fz_stream *in);
+
 /**
        Our customised 'printf'-like string formatter.
        Takes %c, %d, %s, %u, %x, %X as usual.
index 9d1a5df9b71cfa6f048c3299932e7fc8aeb7da86..b7d16fe4215c93d31e96eabb23ee1b78503254ab 100644 (file)
@@ -836,3 +836,15 @@ void fz_write_bits_sync(fz_context *ctx, fz_output *out)
                return;
        fz_write_bits(ctx, out, 0, 8 - out->buffered);
 }
+
+void
+fz_write_stream(fz_context *ctx, fz_output *out, fz_stream *in)
+{
+       size_t z;
+
+       while ((z = fz_available(ctx, in, 4096)) != 0)
+       {
+               fz_write_data(ctx, out, in->rp, z);
+               in->rp += z;
+       }
+}