mupdf
Loading...
Searching...
No Matches
buffer.h File Reference
Include dependency graph for buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fz_buffer

Functions

fz_bufferfz_keep_buffer (fz_context *ctx, fz_buffer *buf)
void fz_drop_buffer (fz_context *ctx, fz_buffer *buf)
size_t fz_buffer_storage (fz_context *ctx, fz_buffer *buf, unsigned char **datap)
const char * fz_string_from_buffer (fz_context *ctx, fz_buffer *buf)
fz_bufferfz_new_buffer (fz_context *ctx, size_t capacity)
fz_bufferfz_new_buffer_from_data (fz_context *ctx, unsigned char *data, size_t size)
fz_bufferfz_new_buffer_from_shared_data (fz_context *ctx, const unsigned char *data, size_t size)
fz_bufferfz_new_buffer_from_copied_data (fz_context *ctx, const unsigned char *data, size_t size)
fz_bufferfz_new_buffer_from_printf (fz_context *ctx, const char *fmt,...)
fz_bufferfz_clone_buffer (fz_context *ctx, fz_buffer *buf)
fz_bufferfz_new_buffer_from_base64 (fz_context *ctx, const char *data, size_t size)
void fz_resize_buffer (fz_context *ctx, fz_buffer *buf, size_t capacity)
void fz_grow_buffer (fz_context *ctx, fz_buffer *buf)
void fz_trim_buffer (fz_context *ctx, fz_buffer *buf)
void fz_clear_buffer (fz_context *ctx, fz_buffer *buf)
fz_bufferfz_slice_buffer (fz_context *ctx, fz_buffer *buf, int64_t start, int64_t end)
void fz_append_buffer (fz_context *ctx, fz_buffer *destination, fz_buffer *source)
void fz_append_base64 (fz_context *ctx, fz_buffer *out, const unsigned char *data, size_t size, int newline)
void fz_append_base64_buffer (fz_context *ctx, fz_buffer *out, fz_buffer *data, int newline)
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_uint32_le (fz_context *ctx, fz_buffer *buf, uint32_t x)
void fz_append_uint16_le (fz_context *ctx, fz_buffer *buf, uint16_t x)
void fz_append_uint32_be (fz_context *ctx, fz_buffer *buf, uint32_t x)
void fz_append_uint16_be (fz_context *ctx, fz_buffer *buf, uint16_t x)
void fz_append_int32_le (fz_context *ctx, fz_buffer *buf, int32_t x)
void fz_append_int16_le (fz_context *ctx, fz_buffer *buf, int16_t x)
void fz_append_int32_be (fz_context *ctx, fz_buffer *buf, int32_t x)
void fz_append_int16_be (fz_context *ctx, fz_buffer *buf, int16_t 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)
void fz_append_pdf_string (fz_context *ctx, fz_buffer *buffer, const char *text)
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_terminate_buffer (fz_context *ctx, fz_buffer *buf)
void fz_md5_buffer (fz_context *ctx, fz_buffer *buffer, unsigned char digest[16])
size_t fz_buffer_extract (fz_context *ctx, fz_buffer *buf, unsigned char **data)

Function Documentation

◆ fz_append_base64()

void fz_append_base64 ( fz_context * ctx,
fz_buffer * out,
const unsigned char * data,
size_t size,
int newline )

Write a base64 encoded data block, optionally with periodic newlines.

◆ fz_append_base64_buffer()

void fz_append_base64_buffer ( fz_context * ctx,
fz_buffer * out,
fz_buffer * data,
int newline )

Append a base64 encoded fz_buffer, optionally with periodic newlines.

◆ fz_append_bits()

void fz_append_bits ( fz_context * ctx,
fz_buffer * buf,
int value,
int count )

◆ fz_append_bits_pad()

void fz_append_bits_pad ( fz_context * ctx,
fz_buffer * buf )

◆ fz_append_buffer()

void fz_append_buffer ( fz_context * ctx,
fz_buffer * destination,
fz_buffer * source )

Append the contents of the source buffer onto the end of the destination buffer, extending automatically as required.

Ownership of buffers does not change.

◆ fz_append_byte()

void fz_append_byte ( fz_context * ctx,
fz_buffer * buf,
int c )

◆ fz_append_data()

void fz_append_data ( fz_context * ctx,
fz_buffer * buf,
const void * data,
size_t len )

fz_append_*: Append data to a buffer.

The buffer will automatically grow as required.

◆ fz_append_int16_be()

void fz_append_int16_be ( fz_context * ctx,
fz_buffer * buf,
int16_t x )

◆ fz_append_int16_le()

void fz_append_int16_le ( fz_context * ctx,
fz_buffer * buf,
int16_t x )

◆ fz_append_int32_be()

void fz_append_int32_be ( fz_context * ctx,
fz_buffer * buf,
int32_t x )

◆ fz_append_int32_le()

void fz_append_int32_le ( fz_context * ctx,
fz_buffer * buf,
int32_t x )

◆ fz_append_pdf_string()

void fz_append_pdf_string ( fz_context * ctx,
fz_buffer * buffer,
const char * text )

fz_append_pdf_string: Append a string with PDF syntax quotes and escapes.

The buffer will automatically grow as required.

◆ fz_append_printf()

void fz_append_printf ( fz_context * ctx,
fz_buffer * buffer,
const char * fmt,
... )

fz_append_printf: Format and append data to buffer using printf-like formatting (see fz_vsnprintf).

The buffer will automatically grow as required.

◆ fz_append_rune()

void fz_append_rune ( fz_context * ctx,
fz_buffer * buf,
int c )

◆ fz_append_string()

void fz_append_string ( fz_context * ctx,
fz_buffer * buf,
const char * data )

◆ fz_append_uint16_be()

void fz_append_uint16_be ( fz_context * ctx,
fz_buffer * buf,
uint16_t x )

◆ fz_append_uint16_le()

void fz_append_uint16_le ( fz_context * ctx,
fz_buffer * buf,
uint16_t x )

◆ fz_append_uint32_be()

void fz_append_uint32_be ( fz_context * ctx,
fz_buffer * buf,
uint32_t x )

◆ fz_append_uint32_le()

void fz_append_uint32_le ( fz_context * ctx,
fz_buffer * buf,
uint32_t x )

◆ fz_append_vprintf()

void fz_append_vprintf ( fz_context * ctx,
fz_buffer * buffer,
const char * fmt,
va_list args )

fz_append_vprintf: Format and append data to buffer using printf-like formatting with varargs (see fz_vsnprintf).

◆ fz_buffer_extract()

size_t fz_buffer_extract ( fz_context * ctx,
fz_buffer * buf,
unsigned char ** data )

Take ownership of buffer contents.

Performs the same task as fz_buffer_storage, but ownership of the data buffer returns with this call. The buffer is left empty.

Note: Bad things may happen if this is called on a buffer with multiple references that is being used from multiple threads.

data: Pointer to place to retrieve data pointer.

Returns length of stream.

◆ fz_buffer_storage()

size_t fz_buffer_storage ( fz_context * ctx,
fz_buffer * buf,
unsigned char ** datap )

Retrieve internal memory of buffer.

datap: Output parameter that will be pointed to the data.

Returns the current size of the data in bytes.

◆ fz_clear_buffer()

void fz_clear_buffer ( fz_context * ctx,
fz_buffer * buf )

Empties the buffer. Storage is not freed, but is held ready to be reused as the buffer is refilled.

Never throws exceptions.

◆ fz_clone_buffer()

fz_buffer * fz_clone_buffer ( fz_context * ctx,
fz_buffer * buf )

Make a new buffer, containing a copy of the data used in the original.

◆ fz_drop_buffer()

void fz_drop_buffer ( fz_context * ctx,
fz_buffer * buf )

Drop a reference to the buffer. When the reference count reaches zero, the buffer is destroyed.

Never throws exceptions.

◆ fz_grow_buffer()

void fz_grow_buffer ( fz_context * ctx,
fz_buffer * buf )

Make some space within a buffer (i.e. ensure that capacity > size).

◆ fz_keep_buffer()

fz_buffer * fz_keep_buffer ( fz_context * ctx,
fz_buffer * buf )

Take an additional reference to the buffer. The same pointer is returned.

Never throws exceptions.

◆ fz_md5_buffer()

void fz_md5_buffer ( fz_context * ctx,
fz_buffer * buffer,
unsigned char digest[16] )

Create an MD5 digest from buffer contents.

Never throws exceptions.

◆ fz_new_buffer()

fz_buffer * fz_new_buffer ( fz_context * ctx,
size_t capacity )

◆ fz_new_buffer_from_base64()

fz_buffer * fz_new_buffer_from_base64 ( fz_context * ctx,
const char * data,
size_t size )

Create a new buffer with data decoded from a base64 input string.

◆ fz_new_buffer_from_copied_data()

fz_buffer * fz_new_buffer_from_copied_data ( fz_context * ctx,
const unsigned char * data,
size_t size )

Create a new buffer containing a copy of the passed data.

◆ fz_new_buffer_from_data()

fz_buffer * fz_new_buffer_from_data ( fz_context * ctx,
unsigned char * data,
size_t size )

Create a new buffer with existing data.

data: Pointer to existing data. size: Size of existing data.

Takes ownership of data. Does not make a copy. Calls fz_free on the data when the buffer is deallocated. Do not use 'data' after passing to this function.

Returns pointer to new buffer. Throws exception on allocation failure.

◆ fz_new_buffer_from_printf()

fz_buffer * fz_new_buffer_from_printf ( fz_context * ctx,
const char * fmt,
... )

Create a new buffer with printf formatted data.

◆ fz_new_buffer_from_shared_data()

fz_buffer * fz_new_buffer_from_shared_data ( fz_context * ctx,
const unsigned char * data,
size_t size )

Like fz_new_buffer, but does not take ownership.

◆ fz_resize_buffer()

void fz_resize_buffer ( fz_context * ctx,
fz_buffer * buf,
size_t capacity )

Ensure that a buffer has a given capacity, truncating data if required.

capacity: The desired capacity for the buffer. If the current size of the buffer contents is smaller than capacity, it is truncated.

◆ fz_slice_buffer()

fz_buffer * fz_slice_buffer ( fz_context * ctx,
fz_buffer * buf,
int64_t start,
int64_t end )

Create a new buffer with a (subset of) the data from the buffer.

start: if >= 0, offset from start of buffer, if < 0 offset from end of buffer.

end: if >= 0, offset from start of buffer, if < 0 offset from end of buffer.

◆ fz_string_from_buffer()

const char * fz_string_from_buffer ( fz_context * ctx,
fz_buffer * buf )

Ensure that a buffer's data ends in a 0 byte, and return a pointer to it.

◆ fz_terminate_buffer()

void fz_terminate_buffer ( fz_context * ctx,
fz_buffer * buf )

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.

Subsequent changes to the size of the buffer (such as by fz_buffer_trim, fz_buffer_grow, fz_resize_buffer, etc) may invalidate this.

◆ fz_trim_buffer()

void fz_trim_buffer ( fz_context * ctx,
fz_buffer * buf )

Trim wasted capacity from a buffer by resizing internal memory.