23#ifndef MUPDF_FITZ_CONTEXT_H
24#define MUPDF_FITZ_CONTEXT_H
31#ifndef FZ_VERBOSE_EXCEPTIONS
32#define FZ_VERBOSE_EXCEPTIONS 0
53 void *(*malloc)(
void *, size_t);
54 void *(*realloc)(
void *,
void *, size_t);
55 void (*
free)(
void *,
void *);
62#define fz_var(var) fz_var_imp((void *)&(var))
63#define fz_try(ctx) if (!fz_setjmp(*fz_push_try(ctx))) if (fz_do_try(ctx)) do
64#define fz_always(ctx) while (0); if (fz_do_always(ctx)) do
65#define fz_catch(ctx) while (0); if (fz_do_catch(ctx))
177#if FZ_VERBOSE_EXCEPTIONS
178#define fz_vthrow(CTX, ERRCODE, FMT, VA) fz_vthrowFL(CTX, __FILE__, __LINE__, ERRCODE, FMT, VA)
179#define fz_throw(CTX, ERRCODE, ...) fz_throwFL(CTX, __FILE__, __LINE__, ERRCODE, __VA_ARGS__)
180#define fz_rethrow(CTX) fz_rethrowFL(CTX, __FILE__, __LINE__)
181#define fz_morph_error(CTX, FROM, TO) fz_morph_errorFL(CTX, __FILE__, __LINE__, FROM, TO)
182#define fz_vwarn(CTX, FMT, VA) fz_vwarnFL(CTX, __FILE__, __LINE__, FMT, VA)
183#define fz_warn(CTX, ...) fz_warnFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
184#define fz_rethrow_if(CTX, ERRCODE) fz_rethrow_ifFL(CTX, __FILE__, __LINE__, ERRCODE)
185#define fz_rethrow_unless(CTX, ERRCODE) fz_rethrow_unlessFL(CTX, __FILE__, __LINE__, ERRCODE)
186#define fz_log_error_printf(CTX, ...) fz_log_error_printfFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
187#define fz_vlog_error_printf(CTX, FMT, VA) fz_log_error_printfFL(CTX, __FILE__, __LINE__, FMT, VA)
188#define fz_log_error(CTX, STR) fz_log_error_printfFL(CTX, __FILE__, __LINE__, STR)
189#define fz_do_catch(CTX) fz_do_catchFL(CTX, __FILE__, __LINE__)
190FZ_NORETURN void fz_vthrowFL(
fz_context *ctx,
const char *file,
int line,
int errcode,
const char *fmt, va_list ap);
193void fz_morph_errorFL(
fz_context *ctx, const
char *file,
int line,
int fromcode,
int tocode);
194void fz_vwarnFL(
fz_context *ctx, const
char *file,
int line, const
char *fmt, va_list ap);
196void fz_rethrow_ifFL(
fz_context *ctx, const
char *file,
int line,
int errcode);
197void fz_rethrow_unlessFL(
fz_context *ctx, const
char *file,
int line,
int errcode);
198void fz_log_error_printfFL(
fz_context *ctx, const
char *file,
int line, const
char *fmt, ...)
FZ_PRINTFLIKE(4,5);
199void fz_vlog_error_printfFL(
fz_context *ctx, const
char *file,
int line, const
char *fmt, va_list ap);
200void fz_log_errorFL(
fz_context *ctx, const
char *file,
int line, const
char *str);
201int fz_do_catchFL(
fz_context *ctx, const
char *file,
int line);
283#if defined(MEMENTO) || !defined(NDEBUG)
284#define FITZ_DEBUG_LOCKING
287#ifdef FITZ_DEBUG_LOCKING
296#define fz_assert_lock_held(A,B) do { } while (0)
297#define fz_assert_lock_not_held(A,B) do { } while (0)
298#define fz_lock_debug_lock(A,B) do { } while (0)
299#define fz_lock_debug_unlock(A,B) do { } while (0)
345#define fz_new_context(alloc, locks, max_store) fz_new_context_imp(alloc, locks, max_store, FZ_VERSION)
671#define fz_malloc_struct(CTX, TYPE) \
672 ((TYPE*)Memento_label(fz_calloc(CTX, 1, sizeof(TYPE)), #TYPE))
680#define fz_malloc_struct_array(CTX, N, TYPE) \
681 ((TYPE*)Memento_label(fz_calloc(CTX, N, sizeof(TYPE)), #TYPE "[]"))
689#define fz_malloc_array(CTX, COUNT, TYPE) \
690 ((TYPE*)Memento_label(fz_malloc_array_imp((CTX), (COUNT), sizeof(TYPE)), #TYPE "[]"))
691#define fz_realloc_array(CTX, OLD, COUNT, TYPE) \
692 ((TYPE*)Memento_label(fz_realloc_array_imp((CTX), (OLD), (COUNT), sizeof(TYPE)), #TYPE "[]"))
740#define fz_malloc_flexible(ctx, T, M, count) \
741 ((T*)Memento_label(fz_calloc(ctx, 1, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)), #T))
742#define fz_realloc_flexible(ctx, p, T, M, count) \
743 ((T*)Memento_label(fz_realloc(ctx, p, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)), #T))
744#define fz_pool_alloc_flexible(ctx, pool, T, M, count) \
745 ((T*)fz_pool_alloc(ctx, pool, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)))
746#define fz_sizeof_flexible(T, M, count) \
747 (offsetof(T, M) + sizeof(*((T*)0)->M) * (count))
815#define fz_cstring_from_string(A) ((A) == NULL ? NULL : (A)->str)
827#ifndef FZ_JMPBUF_ALIGN
828#define FZ_JMPBUF_ALIGN 32
954#define fz_keep_imp(C,P,R) fz_keep_imp_aux((C), (P), (P) ? (R) : NULL)
955#define fz_keep_imp8(C,P,R) fz_keep_imp8_aux((C), (P), (P) ? (R) : NULL)
956#define fz_keep_imp16(C,P,R) fz_keep_imp16_aux((C), (P), (P) ? (R) : NULL)
958#define fz_keep_imp_locked(C,P,R) fz_keep_imp_locked_aux((C), (P), (P) ? (R) : NULL)
959#define fz_keep_imp8_locked(C,P,R) fz_keep_imp8_locked_aux((C), (P), (P) ? (R) : NULL)
961#define fz_drop_imp(C,P,R) fz_drop_imp_aux((C), (P), (P) ? (R) : NULL)
962#define fz_drop_imp8(C,P,R) fz_drop_imp8_aux((C), (P), (P) ? (R) : NULL)
963#define fz_drop_imp16(C,P,R) fz_drop_imp16_aux((C), (P), (P) ? (R) : NULL)
966fz_keep_imp_aux(
fz_context *ctx,
void *p,
int *refs)
1013fz_keep_imp8_aux(
fz_context *ctx,
void *p, int8_t *refs)
1030fz_keep_imp16_aux(
fz_context *ctx,
void *p, int16_t *refs)
1047fz_drop_imp_aux(
fz_context *ctx,
void *p,
int *refs)
1057 drop = --*refs == 0;
1068fz_drop_imp8_aux(
fz_context *ctx,
void *p, int8_t *refs)
1078 drop = --*refs == 0;
1089fz_drop_imp16_aux(
fz_context *ctx,
void *p, int16_t *refs)
1099 drop = --*refs == 0;
struct fz_glyph_cache fz_glyph_cache
Definition context.h:41
void fz_error_cb(void *user, const char *message)
Definition context.h:417
struct fz_hyph_context fz_hyph_context
Definition context.h:36
void fz_vwarn(fz_context *ctx, const char *fmt, va_list ap)
void fz_rethrow_if(fz_context *ctx, int errcode)
void fz_set_user_context(fz_context *ctx, void *user)
void fz_disable_icc(fz_context *ctx)
void fz_drop_string(fz_context *ctx, fz_string *str)
void fz_flush_warnings(fz_context *ctx)
void fz_tune_image_decode(fz_context *ctx, fz_tune_image_decode_fn *image_decode, void *arg)
void * fz_realloc_no_throw(fz_context *ctx, void *p, size_t size)
FZ_NORETURN void fz_vthrow(fz_context *ctx, int errcode, const char *, va_list ap)
void fz_set_error_callback(fz_context *ctx, fz_error_cb *error_cb, void *user)
void fz_tune_image_decode_fn(void *arg, int w, int h, int l2factor, fz_irect *subarea)
Definition context.h:480
void fz_ignore_error(fz_context *ctx)
void fz_drop_context(fz_context *ctx)
struct fz_font_context fz_font_context
Definition context.h:35
void fz_log_error(fz_context *ctx, const char *str)
fz_string * fz_new_string(fz_context *ctx, const char *str)
struct fz_archive_handler_context fz_archive_handler_context
Definition context.h:43
void fz_load_user_css(fz_context *ctx, const char *filename)
int fz_use_document_css(fz_context *ctx)
void fz_set_warning_callback(fz_context *ctx, fz_warning_cb *warning_cb, void *user)
void fz_set_use_document_css(fz_context *ctx, int use)
int fz_do_always(fz_context *ctx)
#define FZ_JMPBUF_ALIGN
Definition context.h:828
fz_context * fz_clone_context(fz_context *ctx)
void fz_warning_cb(void *user, const char *message)
Definition context.h:424
void fz_lock_debug_unlock(fz_context *ctx, int lock)
const char * fz_user_css(fz_context *ctx)
void fz_activity_fn(fz_context *ctx, void *opaque, fz_activity_reason reason, void *reason_arg)
Definition context.h:875
void fz_enable_icc(fz_context *ctx)
int fz_text_aa_level(fz_context *ctx)
struct fz_tuning_context fz_tuning_context
Definition context.h:39
void * fz_realloc(fz_context *ctx, void *p, size_t size)
void fz_assert_lock_held(fz_context *ctx, int lock)
struct fz_output fz_output
Definition context.h:44
void * fz_realloc_array_imp(fz_context *ctx, void *p, size_t nmemb, size_t size)
int fz_caught(fz_context *ctx)
fz_jmp_buf * fz_push_try(fz_context *ctx)
fz_string * fz_keep_string(fz_context *ctx, fz_string *str)
void fz_set_graphics_min_line_width(fz_context *ctx, float min_line_width)
void fz_log_error_printf(fz_context *ctx, const char *fmt,...) FZ_PRINTFLIKE(2
fz_error_type
Definition context.h:219
@ FZ_ERROR_ARGUMENT
Definition context.h:225
@ FZ_ERROR_FORMAT
Definition context.h:228
@ FZ_ERROR_REPAIRED
Definition context.h:234
@ FZ_ERROR_LIMIT
Definition context.h:226
@ FZ_ERROR_LIBRARY
Definition context.h:224
@ FZ_ERROR_GENERIC
Definition context.h:221
@ FZ_ERROR_ABORT
Definition context.h:233
@ FZ_ERROR_SYNTAX
Definition context.h:229
@ FZ_ERROR_UNSUPPORTED
Definition context.h:227
@ FZ_ERROR_TRYLATER
Definition context.h:232
@ FZ_ERROR_NONE
Definition context.h:220
@ FZ_ERROR_SYSTEM
Definition context.h:223
struct fz_document_handler_context fz_document_handler_context
Definition context.h:42
fz_context * fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, size_t max_store, const char *version)
void fz_rethrow_unless(fz_context *ctx, int errcode)
@ FZ_STORE_UNLIMITED
Definition context.h:313
@ FZ_STORE_DEFAULT
Definition context.h:314
void fz_register_activity_logger(fz_context *ctx, fz_activity_fn *activity, void *opaque)
struct fz_store fz_store
Definition context.h:40
fz_warning_cb * fz_warning_callback(fz_context *ctx, void **user)
void fz_lock_debug_lock(fz_context *ctx, int lock)
FZ_NORETURN void FZ_NORETURN void fz_rethrow(fz_context *ctx)
void fz_report_error(fz_context *ctx)
int fz_tune_image_scale_fn(void *arg, int dst_w, int dst_h, int src_w, int src_h)
Definition context.h:497
const char * fz_convert_error(fz_context *ctx, int *code)
void fz_free(fz_context *ctx, void *p)
int fz_caught_errno(fz_context *ctx)
void * fz_malloc(fz_context *ctx, size_t size)
float fz_graphics_min_line_width(fz_context *ctx)
void const char * fz_caught_message(fz_context *ctx)
void fz_set_user_css(fz_context *ctx, const char *text)
void * fz_malloc_array_imp(fz_context *ctx, size_t nmemb, size_t size)
void * fz_calloc_no_throw(fz_context *ctx, size_t count, size_t size)
struct fz_style_context fz_style_context
Definition context.h:38
fz_error_cb * fz_error_callback(fz_context *ctx, void **user)
void fz_tune_image_rendering(fz_context *ctx, int behavior)
fz_activity_reason
Definition context.h:870
@ FZ_ACTIVITY_NEW_DOC
Definition context.h:871
@ FZ_ACTIVITY_SHUTDOWN
Definition context.h:872
@ FZ_IMAGE_RENDERING_BALANCE
Definition context.h:527
@ FZ_IMAGE_RENDERING_QUALITY
Definition context.h:533
@ FZ_IMAGE_RENDERING_SPEED
Definition context.h:546
void fz_assert_lock_not_held(fz_context *ctx, int lock)
@ FZ_LOCK_GLYPHCACHE
Definition context.h:279
@ FZ_LOCK_FREETYPE
Definition context.h:278
@ FZ_LOCK_MAX
Definition context.h:280
@ FZ_LOCK_ALLOC
Definition context.h:277
void * fz_user_context(fz_context *ctx)
void * fz_malloc_no_throw(fz_context *ctx, size_t size)
int fz_graphics_aa_level(fz_context *ctx)
void fz_tune_image_scale(fz_context *ctx, fz_tune_image_scale_fn *image_scale, void *arg)
struct fz_colorspace_context fz_colorspace_context
Definition context.h:37
void fz_default_error_callback(void *user, const char *message)
void fz_set_aa_level(fz_context *ctx, int bits)
char * fz_strdup(fz_context *ctx, const char *s)
int fz_aa_level(fz_context *ctx)
void * fz_calloc(fz_context *ctx, size_t count, size_t size)
void fz_warn(fz_context *ctx, const char *fmt,...) FZ_PRINTFLIKE(2
FZ_NORETURN void fz_throw(fz_context *ctx, int errcode, const char *,...) FZ_PRINTFLIKE(3
void fz_morph_error(fz_context *ctx, int fromcode, int tocode)
void fz_set_text_aa_level(fz_context *ctx, int bits)
int fz_do_catch(fz_context *ctx)
void fz_set_graphics_aa_level(fz_context *ctx, int bits)
void fz_default_warning_callback(void *user, const char *message)
void void fz_vlog_error_printf(fz_context *ctx, const char *fmt, va_list ap)
void fz_free_aligned(fz_context *ctx, void *p)
int fz_do_try(fz_context *ctx)
void fz_memrnd(fz_context *ctx, uint8_t *block, int len)
void * fz_malloc_aligned(fz_context *ctx, size_t size, int align)
#define Memento_checkIntPointerOrNull(A)
Definition memento.h:405
#define Memento_dropByteRef(A)
Definition memento.h:393
#define Memento_dropShortRef(A)
Definition memento.h:395
#define Memento_checkShortPointerOrNull(A)
Definition memento.h:404
#define Memento_checkBytePointerOrNull(A)
Definition memento.h:403
#define Memento_dropIntRef(A)
Definition memento.h:397
#define Memento_takeRef(A)
Definition memento.h:398
int text_bits
Definition context.h:865
int vscale
Definition context.h:862
int scale
Definition context.h:863
float min_line_width
Definition context.h:866
int hscale
Definition context.h:861
int bits
Definition context.h:864
fz_activity_fn * activity
Definition context.h:880
void * opaque
Definition context.h:879
void * user
Definition context.h:52
void(* free)(void *, void *)
Definition context.h:55
fz_tuning_context * tuning
Definition context.h:919
fz_colorspace_context * colorspace
Definition context.h:925
fz_activity_context activity
Definition context.h:906
fz_document_handler_context * handler
Definition context.h:916
fz_alloc_context alloc
Definition context.h:902
fz_hyph_context * hyph
Definition context.h:924
fz_glyph_cache * glyph_cache
Definition context.h:927
void * user
Definition context.h:887
fz_error_context error
Definition context.h:904
fz_warn_context warn
Definition context.h:905
fz_archive_handler_context * archive
Definition context.h:917
fz_store * store
Definition context.h:926
uint16_t seed48[7]
Definition context.h:910
fz_output * stddbg
Definition context.h:922
fz_context * master
Definition context.h:894
int context_count
Definition context.h:897
fz_font_context * font
Definition context.h:923
fz_aa_context aa
Definition context.h:909
fz_style_context * style
Definition context.h:918
int next_document_id
Definition context.h:900
fz_locks_context locks
Definition context.h:903
void(* print)(void *user, const char *message)
Definition context.h:847
void * print_user
Definition context.h:846
char message[256]
Definition context.h:848
fz_error_stack_slot * top
Definition context.h:840
int errcode
Definition context.h:844
fz_error_stack_slot * stack_base
Definition context.h:843
fz_error_stack_slot padding
Definition context.h:842
int errnum
Definition context.h:845
fz_error_stack_slot stack[256]
Definition context.h:841
int code
Definition context.h:834
int state
Definition context.h:834
char padding[FZ_JMPBUF_ALIGN-sizeof(int) *2]
Definition context.h:835
fz_jmp_buf buffer
Definition context.h:833
Definition geometry.h:248
void(* unlock)(void *user, int lock)
Definition context.h:273
void * user
Definition context.h:271
void(* lock)(void *user, int lock)
Definition context.h:272
char str[FZ_FLEXIBLE_ARRAY]
Definition context.h:794
int refs
Definition context.h:793
void(* print)(void *user, const char *message)
Definition context.h:854
char message[256]
Definition context.h:856
void * print_user
Definition context.h:853
int count
Definition context.h:855
#define FZ_UNUSED
Definition system.h:278
#define FZ_PRINTFLIKE(F, V)
Definition system.h:288
#define FZ_FLEXIBLE_ARRAY
Definition system.h:46
#define FZ_NORETURN
Definition system.h:269
jmp_buf fz_jmp_buf
Definition system.h:160