mupdf
Loading...
Searching...
No Matches
buffer.h
Go to the documentation of this file.
1// Copyright (C) 2004-2023 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_FITZ_BUFFER_H
24#define MUPDF_FITZ_BUFFER_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28
40typedef struct
41{
42 int refs;
43 unsigned char *data;
44 size_t cap, len;
46 int shared;
47} fz_buffer;
48
56
64
72size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap);
73
79
80fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity);
81
95fz_buffer *fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, size_t size);
96
100fz_buffer *fz_new_buffer_from_shared_data(fz_context *ctx, const unsigned char *data, size_t size);
101
105fz_buffer *fz_new_buffer_from_copied_data(fz_context *ctx, const unsigned char *data, size_t size);
106
110fz_buffer *fz_new_buffer_from_printf(fz_context *ctx, const char *fmt, ...);
111
117
121fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size);
122
131void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity);
132
138
143
151
160fz_buffer *fz_slice_buffer(fz_context *ctx, fz_buffer *buf, int64_t start, int64_t end);
161
168void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source);
169
173void fz_append_base64(fz_context *ctx, fz_buffer *out, const unsigned char *data, size_t size, int newline);
174
178void fz_append_base64_buffer(fz_context *ctx, fz_buffer *out, fz_buffer *data, int newline);
179
185void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
186void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data);
187void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c);
188void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c);
189
190void fz_append_uint32_le(fz_context *ctx, fz_buffer *buf, uint32_t x);
191void fz_append_uint16_le(fz_context *ctx, fz_buffer *buf, uint16_t x);
192void fz_append_uint32_be(fz_context *ctx, fz_buffer *buf, uint32_t x);
193void fz_append_uint16_be(fz_context *ctx, fz_buffer *buf, uint16_t x);
194
195void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int32_t x);
196void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int16_t x);
197void fz_append_int32_be(fz_context *ctx, fz_buffer *buf, int32_t x);
198void fz_append_int16_be(fz_context *ctx, fz_buffer *buf, int16_t x);
199
200void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count);
202
209void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
210
217void fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
218
223void fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
224
238
244void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
245
260size_t fz_buffer_extract(fz_context *ctx, fz_buffer *buf, unsigned char **data);
261
262#endif
void fz_append_int16_be(fz_context *ctx, fz_buffer *buf, int16_t x)
void fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt,...)
void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf)
void fz_clear_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_base64_buffer(fz_context *ctx, fz_buffer *out, fz_buffer *data, int newline)
void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int32_t x)
void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source)
void fz_trim_buffer(fz_context *ctx, fz_buffer *buf)
void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity)
void fz_drop_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args)
size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap)
void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text)
void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int16_t x)
fz_buffer * fz_new_buffer_from_copied_data(fz_context *ctx, const unsigned char *data, size_t size)
void fz_grow_buffer(fz_context *ctx, fz_buffer *buf)
fz_buffer * fz_slice_buffer(fz_context *ctx, fz_buffer *buf, int64_t start, int64_t end)
fz_buffer * fz_keep_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_uint32_le(fz_context *ctx, fz_buffer *buf, uint32_t x)
void fz_append_base64(fz_context *ctx, fz_buffer *out, const unsigned char *data, size_t size, int newline)
fz_buffer * fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size)
fz_buffer * fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, size_t size)
size_t fz_buffer_extract(fz_context *ctx, fz_buffer *buf, unsigned char **data)
fz_buffer * fz_clone_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data)
void fz_append_uint16_be(fz_context *ctx, fz_buffer *buf, uint16_t x)
void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c)
void fz_append_int32_be(fz_context *ctx, fz_buffer *buf, int32_t x)
fz_buffer * fz_new_buffer(fz_context *ctx, size_t capacity)
void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count)
void fz_append_uint32_be(fz_context *ctx, fz_buffer *buf, uint32_t x)
void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16])
fz_buffer * fz_new_buffer_from_printf(fz_context *ctx, const char *fmt,...)
const char * fz_string_from_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len)
fz_buffer * fz_new_buffer_from_shared_data(fz_context *ctx, const unsigned char *data, size_t size)
void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf)
void fz_append_uint16_le(fz_context *ctx, fz_buffer *buf, uint16_t x)
void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c)
Definition buffer.h:41
int refs
Definition buffer.h:42
size_t cap
Definition buffer.h:44
unsigned char * data
Definition buffer.h:43
int unused_bits
Definition buffer.h:45
size_t len
Definition buffer.h:44
int shared
Definition buffer.h:46
Definition context.h:886