summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-03-15 16:27:15 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-03-22 12:07:26 +0100
commite013fd7d0f5ae8f5c994aad4d02f5169946f1a26 (patch)
treebe8a7c8006b1e22a04d70c8db9bb95120b1c7f3a /include
parent8e791ab5cd73dc783aded93f2dd7c77d89623fe8 (diff)
downloadmupdf-e013fd7d0f5ae8f5c994aad4d02f5169946f1a26.tar.xz
Simplify string formatter API.
Emit characters with callbacks so we don't need to do two passes using vsnprintf to count, format, and copy the result.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/buffer.h4
-rw-r--r--include/mupdf/fitz/output.h12
2 files changed, 13 insertions, 3 deletions
diff --git a/include/mupdf/fitz/buffer.h b/include/mupdf/fitz/buffer.h
index 96fcc185..73f254a3 100644
--- a/include/mupdf/fitz/buffer.h
+++ b/include/mupdf/fitz/buffer.h
@@ -112,8 +112,8 @@ void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count);
void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf);
-size_t fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
-size_t fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
+void fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
+void fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
/*
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h
index 023153a9..48bcc502 100644
--- a/include/mupdf/fitz/output.h
+++ b/include/mupdf/fitz/output.h
@@ -271,7 +271,8 @@ static inline void fz_write_rune(fz_context *ctx, fz_output *out, int rune)
}
/*
- fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %u, %x, as usual.
+ fz_format_string: Our customised 'printf'-like string formatter.
+ Takes %c, %d, %o, %s, %u, %x, as usual.
Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc).
%g output in "as short as possible hopefully lossless non-exponent" form,
see fz_ftoa for specifics.
@@ -282,6 +283,15 @@ static inline void fz_write_rune(fz_context *ctx, fz_output *out, int rune)
%ll{d,u,x} indicates that the values are 64bit.
%z{d,u,x} indicates that the value is a size_t.
%Z{d,u,x} indicates that the value is a fz_off_t.
+
+ user: An opaque pointer that is passed to the emit function.
+ emit: A function pointer called to emit output bytes as the string is being formatted.
+*/
+void
+fz_format_string(fz_context *ctx, void *user, void (*emit)(fz_context *ctx, void *user, int c), const char *fmt, va_list args);
+
+/*
+ fz_vsnprintf: A vsnprintf work-alike, using our custom formatter.
*/
size_t fz_vsnprintf(char *buffer, size_t space, const char *fmt, va_list args);