LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Typedefs | Functions
Open options and diagnostic context

Configure checked allocations and per-handle diagnostics for opening. More...

Collaboration diagram for Open options and diagnostic context:

Typedefs

typedef int(* TIFFErrorHandlerExtR) (TIFF *tif, void *user_data, const char *module, const char *fmt, va_list ap)
 Handle a diagnostic using a per-handle borrowed context.
 

Functions

TIFFOpenOptions * TIFFOpenOptionsAlloc (void)
 Allocate default options for opening a TIFF handle.
 
void TIFFOpenOptionsFree (TIFFOpenOptions *opts)
 Release an open-options object.
 
void TIFFOpenOptionsSetMaxSingleMemAlloc (TIFFOpenOptions *opts, tmsize_t max_single_mem_alloc)
 Set the single checked allocation limit for subsequent opens.
 
void TIFFOpenOptionsSetMaxCumulatedMemAlloc (TIFFOpenOptions *opts, tmsize_t max_cumulated_mem_alloc)
 Set the cumulative checked allocation limit for subsequent opens.
 
void TIFFOpenOptionsSetWarnAboutUnknownTags (TIFFOpenOptions *opts, int warn_about_unknown_tags)
 Select whether subsequent opens warn about unknown tags.
 
void TIFFOpenOptionsSetErrorHandlerExtR (TIFFOpenOptions *opts, TIFFErrorHandlerExtR handler, void *errorhandler_user_data)
 Set the per-handle error callback for subsequent opens.
 
void TIFFOpenOptionsSetWarningHandlerExtR (TIFFOpenOptions *opts, TIFFErrorHandlerExtR handler, void *warnhandler_user_data)
 Set the per-handle warning callback for subsequent opens.
 

Detailed Description

Configure checked allocations and per-handle diagnostics for opening.

Typedef Documentation

◆ TIFFErrorHandlerExtR

typedef int(* TIFFErrorHandlerExtR) (TIFF *tif, void *user_data, const char *module, const char *fmt, va_list ap)

Handle a diagnostic using a per-handle borrowed context.

The same signature is used for per-handle errors and warnings. Invocation is synchronous; do not destroy the invoking handle or recursively mutate its I/O state. The callback and context must remain valid through opening, normal use, and close. The library does not own the context or retain module/fmt/ap beyond the call. Early errors may supply tif = NULL. Callback exceptions are not caught by the C library.

Parameters
[in]tifInvoking handle, or NULL for an error before a handle exists.
[in,out]user_dataBorrowed context supplied through open options; possibly NULL.
[in]moduleBorrowed diagnostic module name, possibly NULL.
[in]fmtBorrowed printf-style format string.
[in,out]apBorrowed argument list valid during this invocation; use va_copy() for an independent traversal.
Returns
Nonzero to suppress the legacy global handlers for this message; zero to let them run. This does not abort, retry, or change the operation's status.

Definition at line 884 of file tiffio.h.

Function Documentation

◆ TIFFOpenOptionsAlloc()

TIFFOpenOptions * TIFFOpenOptionsAlloc ( void  )
extern

Allocate default options for opening a TIFF handle.

The object starts with no per-handle diagnostic callbacks, no allocation limits, and unknown-tag warnings disabled. Allocation failure is reported only by NULL; this function does not emit a library diagnostic. The object has no owned callback-context storage.

Returns
An owned options object, or NULL if allocation fails. Release it with TIFFOpenOptionsFree().

Definition at line 85 of file tif_open.c.

References _TIFFcalloc().

Here is the call graph for this function:

◆ TIFFOpenOptionsFree()

void TIFFOpenOptionsFree ( TIFFOpenOptions *  opts)
extern

Release an open-options object.

Invalidates opts without freeing callback contexts or affecting settings already copied into an open handle. NULL is accepted. There is no status result or library diagnostic. Any callback contexts copied into a handle must remain alive until their last invocation, including during close.

Parameters
[in]optsOptions returned by TIFFOpenOptionsAlloc(), or NULL.

Definition at line 92 of file tif_open.c.

References _TIFFfree().

Here is the call graph for this function:

◆ TIFFOpenOptionsSetErrorHandlerExtR()

void TIFFOpenOptionsSetErrorHandlerExtR ( TIFFOpenOptions *  opts,
TIFFErrorHandlerExtR  handler,
void *  errorhandler_user_data 
)
extern

Set the per-handle error callback for subsequent opens.

Stores the callback and borrowed context for subsequent opens; existing handles are unchanged. NULL removes the per-handle callback from these options. There is no allocation, context copy, diagnostic, or status result.

Opening copies the function and context pointers, so the options may then be freed while the context remains valid through the last callback on the resulting handle. The callback is synchronous and may run during opening and closing. Nonzero callback return suppresses the legacy global handlers for that message, not the underlying operation. Early opening errors can invoke the handler with a NULL TIFF pointer; no callback may assume that a fully initialised handle exists.

Parameters
[in,out]optsNon-NULL open-options object.
[in]handlerCallback to store, or NULL for the normal global- handler path.
[in]errorhandler_user_dataBorrowed context, possibly NULL, passed to the callback.

Definition at line 112 of file tif_open.c.

References TIFFOpenOptions::errorhandler, and TIFFOpenOptions::errorhandler_user_data.

◆ TIFFOpenOptionsSetMaxCumulatedMemAlloc()

void TIFFOpenOptionsSetMaxCumulatedMemAlloc ( TIFFOpenOptions *  opts,
tmsize_t  max_cumulated_mem_alloc 
)
extern

Set the cumulative checked allocation limit for subsequent opens.

Stores the value for subsequent opens; already-open handles are unchanged. Zero is the default and means unlimited. Negative values are stored without validation and do not activate the positive-limit checks. No allocation or diagnostic occurs and no status is returned.

The positive limit applies to the total tracked by the handle-aware allocation helpers, not total process memory. The initial handle/name allocation is checked against this limit separately, but is not added to that tracked total. Direct _TIFFmalloc()/_TIFFrealloc() calls, mappings, caller storage, and other untracked allocations are not covered.

Parameters
[in,out]optsNon-NULL open-options object.
[in]max_cumulated_mem_allocByte limit; positive enables checking, zero leaves it unlimited.

Definition at line 100 of file tif_open.c.

References TIFFOpenOptions::max_cumulated_mem_alloc.

◆ TIFFOpenOptionsSetMaxSingleMemAlloc()

void TIFFOpenOptionsSetMaxSingleMemAlloc ( TIFFOpenOptions *  opts,
tmsize_t  max_single_mem_alloc 
)
extern

Set the single checked allocation limit for subsequent opens.

Stores the value for subsequent opens; already-open handles are unchanged. Zero is the default and means unlimited. Negative values are stored without validation and do not activate the positive-limit checks. No allocation or diagnostic occurs and no status is returned.

The positive limit is applied to the initial handle/name allocation and requests through the handle-aware allocation helpers. It does not limit direct calls to _TIFFmalloc() or _TIFFrealloc(), caller storage, or allocations outside those checked paths.

Parameters
[in,out]optsNon-NULL open-options object.
[in]max_single_mem_allocByte limit; positive enables checking, zero leaves it unlimited.

Definition at line 94 of file tif_open.c.

References TIFFOpenOptions::max_single_mem_alloc.

◆ TIFFOpenOptionsSetWarnAboutUnknownTags()

void TIFFOpenOptionsSetWarnAboutUnknownTags ( TIFFOpenOptions *  opts,
int  warn_about_unknown_tags 
)
extern

Select whether subsequent opens warn about unknown tags.

Stores the value without allocating, emitting diagnostics, or changing existing handles. There is no status result. The default is zero since 4.7.1; this setting controls unknown-tag warnings rather than making unknown tags valid or invalid.

Parameters
[in,out]optsNon-NULL open-options object.
[in]warn_about_unknown_tagsZero disables warnings; nonzero enables them.

Definition at line 106 of file tif_open.c.

References TIFFOpenOptions::warn_about_unknown_tags.

◆ TIFFOpenOptionsSetWarningHandlerExtR()

void TIFFOpenOptionsSetWarningHandlerExtR ( TIFFOpenOptions *  opts,
TIFFErrorHandlerExtR  handler,
void *  warnhandler_user_data 
)
extern

Set the per-handle warning callback for subsequent opens.

Stores the callback and borrowed context for subsequent opens; existing handles are unchanged. NULL removes the per-handle callback from these options. There is no allocation, context copy, diagnostic, or status result.

Opening copies the function and context pointers, so the options may then be freed while the context remains valid through the last callback on the resulting handle. The callback is synchronous and may run during opening and closing. Nonzero callback return suppresses the legacy global handlers for that message, not the underlying operation. The callback follows the TIFFErrorHandlerExtR signature; its return value does not change operation success.

Parameters
[in,out]optsNon-NULL open-options object.
[in]handlerCallback to store, or NULL for the normal global- handler path.
[in]warnhandler_user_dataBorrowed context, possibly NULL, passed to the callback.

Definition at line 120 of file tif_open.c.

References TIFFOpenOptions::warnhandler, and TIFFOpenOptions::warnhandler_user_data.