summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/buffer.h73
-rw-r--r--include/mupdf/fitz/output.h60
2 files changed, 48 insertions, 85 deletions
diff --git a/include/mupdf/fitz/buffer.h b/include/mupdf/fitz/buffer.h
index df3f216a..96fcc185 100644
--- a/include/mupdf/fitz/buffer.h
+++ b/include/mupdf/fitz/buffer.h
@@ -15,34 +15,27 @@ typedef struct fz_buffer_s fz_buffer;
/*
fz_keep_buffer: Increment the reference count for a buffer.
- buf: The buffer to increment the reference count for.
-
- Returns a pointer to the buffer. Does not throw exceptions.
+ Returns a pointer to the buffer.
*/
fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
/*
fz_drop_buffer: Decrement the reference count for a buffer.
-
- buf: The buffer to decrement the reference count for.
*/
void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_buffer_storage: Retrieve information on the storage currently used
- by a buffer.
+ fz_buffer_storage: Retrieve internal memory of buffer.
- data: Pointer to place to retrieve data pointer.
+ datap: Output parameter that will be pointed to the data.
- Returns length of stream.
+ Returns the current size of the data in bytes.
*/
-size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **data);
+size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap);
/*
fz_string_from_buffer: Ensure that a buffer's data ends in a
0 byte, and return a pointer to it.
-
- Returns pointer to data.
*/
const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
@@ -51,8 +44,7 @@ const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
capacity: Initial capacity.
- Returns pointer to new buffer. Throws exception on allocation
- failure.
+ Returns pointer to new buffer.
*/
fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity);
@@ -85,60 +77,47 @@ fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t s
fz_resize_buffer: Ensure that a buffer has a given capacity,
truncating data if required.
- buf: The buffer to alter.
-
capacity: The desired capacity for the buffer. If the current size
of the buffer contents is smaller than capacity, it is truncated.
-
*/
void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity);
/*
fz_grow_buffer: Make some space within a buffer (i.e. ensure that
capacity > size).
-
- buf: The buffer to grow.
-
- May throw exception on failure to allocate.
*/
void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_trim_buffer: Trim wasted capacity from a buffer.
-
- buf: The buffer to trim.
+ fz_trim_buffer: Trim wasted capacity from a buffer by resizing internal memory.
*/
void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_append_buffer: Concatenate buffers
-
- buf: first to concatenate and the holder of the result
- extra: second to concatenate
-
- May throw exception on failure to allocate.
+ fz_append_buffer: Append the contents of source buffer to destination buffer.
*/
-void fz_append_buffer(fz_context *ctx, fz_buffer *buf, fz_buffer *extra);
+void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source);
/*
- fz_write_buffer*: write to a buffer.
- fz_buffer_printf: print formatted to a buffer.
- fz_buffer_print_pdfstring: Print a string using PDF syntax and escapes.
- The buffer will grow as required.
+ fz_append_*: Append data to a buffer.
+ fz_append_printf: Format and append data to buffer using printf-like formatting (see fz_vsnprintf).
+ fz_append_pdf_string: Append a string with PDF syntax quotes and escapes.
+ The buffer will automatically grow as required.
*/
-void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
-void fz_write_buffer_byte(fz_context *ctx, fz_buffer *buf, int val);
-void fz_write_buffer_rune(fz_context *ctx, fz_buffer *buf, int val);
-void fz_write_buffer_int32_le(fz_context *ctx, fz_buffer *buf, int x);
-void fz_write_buffer_int16_le(fz_context *ctx, fz_buffer *buf, int x);
-void fz_write_buffer_bits(fz_context *ctx, fz_buffer *buf, int val, int bits);
-void fz_write_buffer_pad(fz_context *ctx, fz_buffer *buf);
-size_t fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
-size_t fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
-void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
+void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
+void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data);
+void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c);
+void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c);
+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_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
/*
- fz_terminate_buffer: zero-terminate buffer in order to use as a C string.
+ fz_terminate_buffer: Zero-terminate buffer in order to use as a C string.
This byte is invisible and does not affect the length of the buffer as returned by fz_buffer_storage.
The zero byte is written *after* the data, and subsequent writes will overwrite the terminating byte.
@@ -146,7 +125,7 @@ void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *
void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_md5_buffer: create MD5 digest of buffer contents.
+ fz_md5_buffer: Create MD5 digest of buffer contents.
*/
void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h
index fd57736a..d1282352 100644
--- a/include/mupdf/fitz/output.h
+++ b/include/mupdf/fitz/output.h
@@ -140,41 +140,28 @@ void fz_set_stdout(fz_context *ctx, fz_output *out);
void fz_set_stderr(fz_context *ctx, fz_output *err);
/*
- fz_printf: fprintf equivalent for output streams. See fz_snprintf.
+ fz_write_printf: Format and write data to an output stream.
+ See fz_vsnprintf for formatting details.
*/
-void fz_printf(fz_context *ctx, fz_output *out, const char *fmt, ...);
+void fz_write_printf(fz_context *ctx, fz_output *out, const char *fmt, ...);
/*
- fz_vprintf: vfprintf equivalent for output streams. See fz_vsnprintf.
+ fz_write_vprintf: va_list version of fz_write_printf.
*/
-void fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list ap);
+void fz_write_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list ap);
/*
- fz_putc: fputc equivalent for output streams.
-*/
-#define fz_putc(C,O,B) fz_write_byte(C, O, B)
-
-/*
- fz_puts: fputs equivalent for output streams.
-*/
-#define fz_puts(C,O,S) fz_write(C, O, (S), strlen(S))
-
-/*
- fz_putrune: fz_putc equivalent for utf-8 output.
-*/
-#define fz_putrune(C,O,R) fz_write_rune(C, O, R)
-
-/*
- fz_seek_output: Seek to the specified file position. See fseek
- for arguments.
+ fz_seek_output: Seek to the specified file position.
+ See fseek for arguments.
Throw an error on unseekable outputs.
*/
void fz_seek_output(fz_context *ctx, fz_output *out, fz_off_t off, int whence);
/*
- fz_tell_output: Return the current file position. Throw an error
- on untellable outputs.
+ fz_tell_output: Return the current file position.
+
+ Throw an error on untellable outputs.
*/
fz_off_t fz_tell_output(fz_context *ctx, fz_output *out);
@@ -184,22 +171,27 @@ fz_off_t fz_tell_output(fz_context *ctx, fz_output *out);
void fz_drop_output(fz_context *, fz_output *);
/*
- fz_write: Write data to output. Designed to parallel
- fwrite.
-
- out: Output stream to write to.
+ fz_write_data: Write data to output.
data: Pointer to data to write.
-
- size: Length of data to write.
+ size: Size of data to write in bytes.
*/
-static inline void fz_write(fz_context *ctx, fz_output *out, const void *data, size_t size)
+static inline 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);
}
/*
+ fz_write_string: Write a string. Does not write zero terminator.
+*/
+static inline void fz_write_string(fz_context *ctx, fz_output *out, const char *s)
+{
+ if (out)
+ out->write(ctx, out->state, s, strlen(s));
+}
+
+/*
fz_write_int32_be: Write a big-endian 32-bit binary integer.
*/
static inline void fz_write_int32_be(fz_context *ctx, fz_output *out, int x)
@@ -261,10 +253,6 @@ static inline void fz_write_int16_le(fz_context *ctx, fz_output *out, int x)
/*
fz_write_byte: Write a single byte.
-
- out: stream to write to.
-
- x: value to write
*/
static inline void fz_write_byte(fz_context *ctx, fz_output *out, unsigned char x)
{
@@ -274,10 +262,6 @@ static inline void fz_write_byte(fz_context *ctx, fz_output *out, unsigned char
/*
fz_write_rune: Write a UTF-8 encoded unicode character.
-
- out: stream to write to.
-
- x: value to write
*/
static inline void fz_write_rune(fz_context *ctx, fz_output *out, int rune)
{