diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-01-21 16:42:45 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-02-17 18:05:39 +0100 |
commit | f84a189d5f94250e46d2cbd1a75aba00130e2dd6 (patch) | |
tree | 8ee614ab90de1baa8941f91ae4946ed5c2e70721 /include/mupdf/fitz/output.h | |
parent | 681039767f2ccc72e236246178893eb0989169c9 (diff) | |
download | mupdf-f84a189d5f94250e46d2cbd1a75aba00130e2dd6.tar.xz |
Add ctx parameter and remove embedded contexts for API regularity.
Purge several embedded contexts:
Remove embedded context in fz_output.
Remove embedded context in fz_stream.
Remove embedded context in fz_device.
Remove fz_rebind_stream (since it is no longer necessary).
Remove embedded context in svg_device.
Remove embedded context in XML parser.
Add ctx argument to fz_document functions.
Remove embedded context in fz_document.
Remove embedded context in pdf_document.
Remove embedded context in pdf_obj.
Make fz_page independent of fz_document in the interface.
We shouldn't need to pass the document to all functions handling a page.
If a page is tied to the source document, it's redundant; otherwise it's
just pointless.
Fix reference counting oddity in fz_new_image_from_pixmap.
Diffstat (limited to 'include/mupdf/fitz/output.h')
-rw-r--r-- | include/mupdf/fitz/output.h | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h index 8398f83a..ea87a2ff 100644 --- a/include/mupdf/fitz/output.h +++ b/include/mupdf/fitz/output.h @@ -11,21 +11,12 @@ */ typedef struct fz_output_s fz_output; -struct fz_output_s -{ - fz_context *ctx; - void *opaque; - int (*printf)(fz_output *, const char *, va_list ap); - int (*write)(fz_output *, const void *, int n); - void (*close)(fz_output *); -}; - /* fz_new_output_with_file: Open an output stream onto a FILE *. The stream does NOT take ownership of the FILE *. */ -fz_output *fz_new_output_with_file(fz_context *, FILE *); +fz_output *fz_new_output_with_file(fz_context *, FILE *, int close); /* fz_new_output_to_filename: Open an output stream to a filename. @@ -42,22 +33,22 @@ fz_output *fz_new_output_with_buffer(fz_context *, fz_buffer *); /* fz_printf: fprintf equivalent for output streams. */ -int fz_printf(fz_output *, const char *, ...); +int fz_printf(fz_context *, fz_output *, const char *, ...); /* fz_puts: fputs equivalent for output streams. */ -int fz_puts(fz_output *, const char *); +int fz_puts(fz_context *, fz_output *, const char *); /* fz_write: fwrite equivalent for output streams. */ -int fz_write(fz_output *out, const void *data, int len); +int fz_write(fz_context *, fz_output *out, const void *data, int len); /* fz_putc: putc equivalent for output streams. */ -void fz_putc(fz_output *out, char c); +void fz_putc(fz_context *, fz_output *out, char c); /* fz_drop_output: Close a previously opened fz_output stream. @@ -66,11 +57,9 @@ void fz_putc(fz_output *out, char c); method dependent. FILE * streams created by fz_new_output_with_file are NOT closed. */ -void fz_drop_output(fz_output *); - -void fz_rebind_output(fz_output *, fz_context *ctx); +void fz_drop_output(fz_context *, fz_output *); -static inline int fz_write_int32be(fz_output *out, int x) +static inline int fz_write_int32be(fz_context *ctx, fz_output *out, int x) { char data[4]; @@ -79,18 +68,24 @@ static inline int fz_write_int32be(fz_output *out, int x) data[2] = x>>8; data[3] = x; - return fz_write(out, data, 4); + return fz_write(ctx, out, data, 4); } static inline void -fz_write_byte(fz_output *out, int x) +fz_write_byte(fz_context *ctx, fz_output *out, int x) { char data = x; - fz_write(out, &data, 1); + fz_write(ctx, out, &data, 1); } /* + fz_vfprintf: Our customised vfprintf routine. Same supported + format specifiers as for fz_vsnprintf. +*/ +int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap); + +/* fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %x, as usual. Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc). %f and %g both output in "as short as possible hopefully lossless non-exponent" form, @@ -100,14 +95,6 @@ fz_write_byte(fz_output *out, int x) %q and %( output escaped strings in C/PDF syntax. */ int fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args); - -/* - fz_vfprintf: Our customised vfprintf routine. Same supported - format specifiers as for fz_vsnprintf. -*/ -int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap); - - int fz_snprintf(char *buffer, int space, const char *fmt, ...); #endif |