diff options
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/output.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/source/fitz/output.c b/source/fitz/output.c index a8194aed..ba2936b3 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -296,6 +296,88 @@ fz_write_printf(fz_context *ctx, fz_output *out, const char *fmt, ...) } void +fz_write_data(fz_context *ctx, fz_output *out, const void *data, size_t size) +{ + if (out) + out->write(ctx, out->state, data, size); +} + +void +fz_write_string(fz_context *ctx, fz_output *out, const char *s) +{ + extern size_t strlen(const char *s); /* avoid including string.h in public header */ + if (out) + out->write(ctx, out->state, s, strlen(s)); +} + +void +fz_write_int32_be(fz_context *ctx, fz_output *out, int x) +{ + char data[4]; + + data[0] = x>>24; + data[1] = x>>16; + data[2] = x>>8; + data[3] = x; + + if (out) + out->write(ctx, out->state, data, 4); +} + +void +fz_write_int32_le(fz_context *ctx, fz_output *out, int x) +{ + char data[4]; + + data[0] = x; + data[1] = x>>8; + data[2] = x>>16; + data[3] = x>>24; + + if (out) + out->write(ctx, out->state, data, 4); +} + +void +fz_write_int16_be(fz_context *ctx, fz_output *out, int x) +{ + char data[2]; + + data[0] = x>>8; + data[1] = x; + + if (out) + out->write(ctx, out->state, data, 2); +} + +void +fz_write_int16_le(fz_context *ctx, fz_output *out, int x) +{ + char data[2]; + + data[0] = x; + data[1] = x>>8; + + if (out) + out->write(ctx, out->state, data, 2); +} + +void +fz_write_byte(fz_context *ctx, fz_output *out, unsigned char x) +{ + if (out) + out->write(ctx, out->state, &x, 1); +} + +void +fz_write_rune(fz_context *ctx, fz_output *out, int rune) +{ + char data[10]; + if (out) + out->write(ctx, out->state, data, fz_runetochar(data, rune)); +} + +void fz_save_buffer(fz_context *ctx, fz_buffer *buf, const char *filename) { fz_output *out = fz_new_output_with_path(ctx, filename, 0); |