#ifndef MUPDF_FITZ_OUTPUT_H1#define MUPDF_FITZ_OUTPUT_H23#include "mupdf/fitz/system.h"4#include "mupdf/fitz/context.h"5#include "mupdf/fitz/buffer.h"67/*8Generic output streams - generalise between outputting to a file,9a buffer, etc.10*/11typedef struct fz_output_s fz_output;1213/*14fz_new_output_with_file: Open an output stream onto a FILE *.1516The stream does NOT take ownership of the FILE *.17*/18fz_output *fz_new_output_with_file(fz_context *, FILE *, int close);1920/*21fz_new_output_to_filename: Open an output stream to a filename.22*/23fz_output *fz_new_output_to_filename(fz_context *, const char *filename);2425/*26fz_new_output_with_buffer: Open an output stream onto a buffer.2728The stream does NOT take ownership of the buffer.29*/30fz_output *fz_new_output_with_buffer(fz_context *, fz_buffer *);3132/*33fz_printf: fprintf equivalent for output streams.34*/35int fz_printf(fz_context *, fz_output *, const char *, ...);3637/*38fz_puts: fputs equivalent for output streams.39*/40int fz_puts(fz_context *, fz_output *, const char *);4142/*43fz_write: fwrite equivalent for output streams.44*/45int fz_write(fz_context *, fz_output *out, const void *data, int len);4647/*48fz_putc: putc equivalent for output streams.49*/50void fz_putc(fz_context *, fz_output *out, char c);5152/*53fz_drop_output: Close a previously opened fz_output stream.5455Note: whether or not this closes the underlying output method is56method dependent. FILE * streams created by fz_new_output_with_file57are NOT closed.58*/59void fz_drop_output(fz_context *, fz_output *);6061static inline int fz_write_int32be(fz_context *ctx, fz_output *out, int x)62{63char data[4];6465data[0] = x>>24;66data[1] = x>>16;67data[2] = x>>8;68data[3] = x;6970return fz_write(ctx, out, data, 4);71}7273static inline void74fz_write_byte(fz_context *ctx, fz_output *out, int x)75{76char data = x;7778fz_write(ctx, out, &data, 1);79}8081/*82fz_vfprintf: Our customised vfprintf routine. Same supported83format specifiers as for fz_vsnprintf.84*/85int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap);86int fz_fprintf(fz_context *ctx, FILE *file, const char *fmt, ...);8788/*89fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %u, %x, as usual.90Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc).91%f and %g both output in "as short as possible hopefully lossless non-exponent" form,92see fz_ftoa for specifics.93%C outputs a utf8 encoded int.94%M outputs a fz_matrix*. %R outputs a fz_rect*. %P outputs a fz_point*.95%q and %( output escaped strings in C/PDF syntax.96%ll{d,u,x} indicates that the values are 64bit.97%z{d,u,x} indicates that the value is a size_t.98%Z{d,u,x} indicates that the value is a fz_off_t.99*/100int fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args);101int fz_snprintf(char *buffer, int space, const char *fmt, ...);102103#endif104105106