diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-15 22:14:15 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-15 22:17:07 +0800 |
commit | 31a87a1da910e63873f2631eea67f84284822b9b (patch) | |
tree | 4b6de91202d48d9c4d0395bcad7fb0b66cab612a /source/fitz | |
parent | df4728eb7fae4e6bd9de68632a05e1ba036cee7b (diff) | |
download | mupdf-31a87a1da910e63873f2631eea67f84284822b9b.tar.xz |
Make inline fz_write_*() normal public functions.
This avoids a macOS compilation error due to
strlen() being redeclared.
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); |