Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_OUTPUT_H
2
#define MUPDF_FITZ_OUTPUT_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/buffer.h"
7
8
/*
9
Generic output streams - generalise between outputting to a file,
10
a buffer, etc.
11
*/
12
typedef struct fz_output_s fz_output;
13
14
/*
15
fz_new_output_with_file: Open an output stream onto a FILE *.
16
17
The stream does NOT take ownership of the FILE *.
18
*/
19
fz_output *fz_new_output_with_file(fz_context *, FILE *, int close);
20
21
/*
22
fz_new_output_to_filename: Open an output stream to a filename.
23
*/
24
fz_output *fz_new_output_to_filename(fz_context *, const char *filename);
25
26
/*
27
fz_new_output_with_buffer: Open an output stream onto a buffer.
28
29
The stream does NOT take ownership of the buffer.
30
*/
31
fz_output *fz_new_output_with_buffer(fz_context *, fz_buffer *);
32
33
/*
34
fz_printf: fprintf equivalent for output streams.
35
*/
36
int fz_printf(fz_context *, fz_output *, const char *, ...);
37
38
/*
39
fz_puts: fputs equivalent for output streams.
40
*/
41
int fz_puts(fz_context *, fz_output *, const char *);
42
43
/*
44
fz_write: fwrite equivalent for output streams.
45
*/
46
int fz_write(fz_context *, fz_output *out, const void *data, int len);
47
48
/*
49
fz_putc: putc equivalent for output streams.
50
*/
51
void fz_putc(fz_context *, fz_output *out, char c);
52
53
/*
54
fz_drop_output: Close a previously opened fz_output stream.
55
56
Note: whether or not this closes the underlying output method is
57
method dependent. FILE * streams created by fz_new_output_with_file
58
are NOT closed.
59
*/
60
void fz_drop_output(fz_context *, fz_output *);
61
62
static inline int fz_write_int32be(fz_context *ctx, fz_output *out, int x)
63
{
64
char data[4];
65
66
data[0] = x>>24;
67
data[1] = x>>16;
68
data[2] = x>>8;
69
data[3] = x;
70
71
return fz_write(ctx, out, data, 4);
72
}
73
74
static inline void
75
fz_write_byte(fz_context *ctx, fz_output *out, int x)
76
{
77
char data = x;
78
79
fz_write(ctx, out, &data, 1);
80
}
81
82
/*
83
fz_vfprintf: Our customised vfprintf routine. Same supported
84
format specifiers as for fz_vsnprintf.
85
*/
86
int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap);
87
int fz_fprintf(fz_context *ctx, FILE *file, const char *fmt, ...);
88
89
/*
90
fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %u, %x, as usual.
91
Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc).
92
%f and %g both output in "as short as possible hopefully lossless non-exponent" form,
93
see fz_ftoa for specifics.
94
%C outputs a utf8 encoded int.
95
%M outputs a fz_matrix*. %R outputs a fz_rect*. %P outputs a fz_point*.
96
%q and %( output escaped strings in C/PDF syntax.
97
%ll{d,u,x} indicates that the values are 64bit.
98
%z{d,u,x} indicates that the value is a size_t.
99
%Z{d,u,x} indicates that the value is a fz_off_t.
100
*/
101
int fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args);
102
int fz_snprintf(char *buffer, int space, const char *fmt, ...);
103
104
#endif
105
106