|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Support initialisation, resource callbacks, and handle cleanup. More...
Modules | |
| C++ stream adapters | |
| Track borrowed streams and implement their client I/O callbacks. | |
Data Structures | |
| union | fd_as_handle_union |
| Carry descriptor bits through the opaque client-handle representation. More... | |
Macros | |
| #define | TIFF_IO_MAX 2147483647U |
| Limit one descriptor read/write request to 2147483647 bytes. | |
Typedefs | |
| typedef union fd_as_handle_union | fd_as_handle_union_t |
| Carry descriptor bits through the opaque client-handle representation. | |
Functions | |
| static tmsize_t | _tiffReadProc (thandle_t fd, void *buf, tmsize_t size) |
| Read bytes from the descriptor with read(). | |
| static tmsize_t | _tiffWriteProc (thandle_t fd, void *buf, tmsize_t size) |
| Write bytes to the descriptor with write(). | |
| static uint64_t | _tiffSeekProc (thandle_t fd, uint64_t off, int whence) |
| Seek the platform resource and return its reported position. | |
| static int | _tiffCloseProc (thandle_t fd) |
| Release the backend OS resource. | |
| static uint64_t | _tiffSizeProc (thandle_t fd) |
| Query the backend resource length in bytes. | |
| static int | _tiffMapProc (thandle_t fd, void **pbase, toff_t *psize) |
| Create a read-only view of the entire backend resource. | |
| static void | _tiffUnmapProc (thandle_t fd, void *base, toff_t size) |
| Release a read-only backend mapping. | |
| static thandle_t | thandle_from_int (int ifd) |
| Convert the native Windows integer handle representation to thandle_t. | |
| static int | thandle_to_int (thandle_t fd) |
| Convert a native Windows handle to the backend integer representation. | |
| int | _tiffDummyMapProc (thandle_t fd, void **pbase, toff_t *psize) |
| Decline mapping when the client supplies no mapping implementation. | |
| void | _tiffDummyUnmapProc (thandle_t fd, void *base, toff_t size) |
| Provide a no-op unmapper when the client omits one. | |
| int | _TIFFgetMode (TIFFOpenOptions *opts, thandle_t clientdata, const char *mode, const char *module) |
| Translate the leading open-mode characters into OS access flags. | |
| void | _TIFFErrorEarly (TIFFOpenOptions *opts, thandle_t clientdata, const char *module, const char *fmt,...) |
| Report an opening error before a complete TIFF handle is available. | |
| void | _TIFFCleanupIFDOffsetAndNumberMaps (TIFF *tif) |
| Release a handle's directory-offset/index lookup maps. | |
Support initialisation, resource callbacks, and handle cleanup.
| #define TIFF_IO_MAX 2147483647U |
Limit one descriptor read/write request to 2147483647 bytes.
Definition at line 68 of file tif_unix.c.
| typedef union fd_as_handle_union fd_as_handle_union_t |
Carry descriptor bits through the opaque client-handle representation.
Used only by the descriptor backend; the union does not own a resource.
|
extern |
Release a handle's directory-offset/index lookup maps.
Destroys each existing map and sets its member pointer to NULL. Borrowed entries/views into the maps become invalid. Does not free the TIFF handle or close client I/O and has no status result or direct diagnostic.
| [in,out] | tif | Non-NULL TIFF handle whose maps may be NULL. |
Definition at line 127 of file tif_close.c.
References tiff::tif_map_dir_number_to_offset, tiff::tif_map_dir_offset_to_number, and TIFFHashSetDestroy().
Referenced by TIFFCleanup(), TIFFCreateCustomDirectory(), TIFFSetDirectory(), TIFFSetSubDirectory(), and TIFFUnlinkDirectory().
|
static |
Release the backend OS resource.
Calls close() and forwards its status/errno without retry or library diagnostics. Resource state after a failed close follows the platform close contract; a successful close invalidates the descriptor.
| [in,out] | fd | Live file descriptor carried by fd_as_handle_union_t. |
Definition at line 223 of file tif_unix.c.
References fd_as_handle_union::fd, and fd_as_handle_union::h.
Referenced by TIFFFdOpenExt().
Decline mapping when the client supplies no mapping implementation.
Allocates nothing, performs no I/O, and emits no diagnostic. The unchanged outputs must not be used as a mapped view.
| [in] | fd | Unused client context. |
| [out] | pbase | Unused view-base output; left unchanged. |
| [out] | psize | Unused size output; left unchanged. |
Definition at line 45 of file tif_open.c.
Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().
Provide a no-op unmapper when the client omits one.
Does not release storage, perform I/O, or emit diagnostics. Returns no status; pairing this with a real mapper is safe only if the view needs no explicit release.
| [in] | fd | Unused client context. |
| [in] | base | Unused view base. |
| [in] | size | Unused byte length. |
Definition at line 53 of file tif_open.c.
Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().
| void _TIFFErrorEarly | ( | TIFFOpenOptions * | opts, |
| thandle_t | clientdata, | ||
| const char * | module, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Report an opening error before a complete TIFF handle is available.
Invokes opts->errorhandler, if present, with tif = NULL and the borrowed error context. A nonzero callback result suppresses the legacy global handlers for this message; otherwise the global ordinary and extended handlers run if installed. The extended handler receives clientdata. Returns no status and does not itself abort opening or own any argument storage. Callback effects and exceptions are not rolled back.
| [in] | opts | Optional borrowed open options containing a per-handle error callback. |
| [in] | clientdata | Opaque context supplied to the legacy extended handler. |
| [in] | module | Borrowed diagnostic module name, possibly NULL. |
| [in] | fmt | Non-NULL printf-style format string. |
| [in] | ... | Arguments matching the format string and default variadic promotions. |
Definition at line 85 of file tif_error.c.
References _TIFFerrorHandler, _TIFFerrorHandlerExt, TIFFOpenOptions::errorhandler, and TIFFOpenOptions::errorhandler_user_data.
Referenced by _TIFFgetMode(), TIFFClientOpenExt(), TIFFOpenExt(), and TIFFOpenWExt().
|
extern |
Translate the leading open-mode characters into OS access flags.
Inspects only the first character and an immediately following + after r; library modifiers are processed later. An invalid first character emits _TIFFErrorEarly() and returns -1. Does not open, close, allocate, or take ownership of a resource. Callback contexts remain borrowed.
| [in] | opts | Optional borrowed settings for early error reporting. |
| [in] | clientdata | Client context passed to legacy extended early- error handling. |
| [in] | mode | Non-NULL null-terminated mode string. |
| [in] | module | Borrowed diagnostic module name. |
Definition at line 60 of file tif_open.c.
References _TIFFErrorEarly().
Referenced by TIFFClientOpenExt(), TIFFOpenExt(), and TIFFOpenWExt().
Create a read-only view of the entire backend resource.
Queries the length with _tiffSizeProc() and calls mmap(PROT_READ, MAP_SHARED). If mmap() fails, *pbase is left holding MAP_FAILED; earlier failures leave it unchanged. A successful view must be released through _tiffUnmapProc(), not an allocator. errno follows attempted platform operations; no library diagnostic is emitted.
| [in] | fd | Live file descriptor carried by fd_as_handle_union_t. |
| [out] | pbase | Output view base on success; do not rely on it after failure. |
| [out] | psize | Output view length in bytes on success; unchanged on failure. |
Definition at line 273 of file tif_unix.c.
References _tiffSizeProc(), fd_as_handle_union::fd, and fd_as_handle_union::h.
Referenced by TIFFFdOpenExt().
Read bytes from the descriptor with read().
Loops over chunks limited by TIFF_IO_MAX until the request completes, read() returns zero (end of file), or read() fails. Does not retry EINTR. A -1 result can follow earlier successful chunks, so the file position and the destination bytes may already have changed. errno follows read(); a size that does not survive conversion to size_t sets EINVAL. Does not issue a library diagnostic or take buffer ownership.
| [in,out] | fd | Live file descriptor carried by fd_as_handle_union_t. |
| [out] | buf | Writable destination of at least size bytes. |
| [in] | size | Nonnegative byte request representable by tmsize_t and the backend. |
Definition at line 102 of file tif_unix.c.
References fd_as_handle_union::fd, fd_as_handle_union::h, and TIFF_IO_MAX.
Referenced by TIFFFdOpenExt().
|
static |
Seek the platform resource and return its reported position.
Converts to _TIFF_off_t and checks the unsigned round trip, then calls _TIFF_lseek_f. A failed conversion sets EINVAL without seeking. Other errors follow the platform call and errno. Does not emit library diagnostics or transfer ownership.
| [in,out] | fd | Live file descriptor carried by fd_as_handle_union_t. |
| [in] | off | Byte offset converted to the platform signed offset type. |
| [in] | whence | Seek origin requested by the library. |
Definition at line 199 of file tif_unix.c.
References _TIFF_lseek_f, _TIFF_off_t, fd_as_handle_union::fd, and fd_as_handle_union::h.
Referenced by TIFFFdOpenExt().
|
static |
Query the backend resource length in bytes.
Uses _TIFF_fstat_f() without seeking. errno follows OS failure. Does not transfer ownership or emit library diagnostics.
| [in] | fd | Live file descriptor carried by fd_as_handle_union_t. |
Definition at line 241 of file tif_unix.c.
References _TIFF_fstat_f, _TIFF_stat_s, fd_as_handle_union::fd, and fd_as_handle_union::h.
Referenced by _tiffMapProc(), and TIFFFdOpenExt().
Release a read-only backend mapping.
Calls munmap() and discards its result. A released view is invalid. Failure has no callback status or library diagnostic and does not close the file descriptor.
| [in] | fd | Unused client context. |
| [in] | base | Mapped-view base, or NULL during early failed-open cleanup. |
| [in] | size | Mapped length in bytes. |
Definition at line 304 of file tif_unix.c.
Referenced by TIFFFdOpenExt().
Write bytes to the descriptor with write().
Loops over chunks limited by TIFF_IO_MAX until the request completes, write() returns zero, or write() fails. Does not retry EINTR. A -1 result can follow earlier successful chunks, so the file position and contents may already have changed. errno follows write(); a size that does not survive conversion to size_t sets EINVAL. Does not issue a library diagnostic or take buffer ownership.
| [in,out] | fd | Live file descriptor carried by fd_as_handle_union_t. |
| [in] | buf | Readable source of at least size bytes. |
| [in] | size | Nonnegative byte request representable by tmsize_t and the backend. |
Definition at line 151 of file tif_unix.c.
References fd_as_handle_union::fd, fd_as_handle_union::h, and TIFF_IO_MAX.
Referenced by TIFFFdOpenExt().
|
inlinestatic |
Convert the native Windows integer handle representation to thandle_t.
Performs no OS validation, allocation, close, or diagnostic. Does not transfer ownership.
| [in] | ifd | Integer representation of a Windows HANDLE, not a CRT descriptor. |
Definition at line 74 of file tif_win32.c.
Referenced by TIFFFdOpenExt().
|
inlinestatic |
Convert a native Windows handle to the backend integer representation.
Performs no OS validation, allocation, close, or diagnostic. Does not transfer ownership; this is the backend HANDLE convention, not a CRT- descriptor conversion.
| [in] | fd | Native Windows HANDLE represented as thandle_t. |
Definition at line 90 of file tif_win32.c.
Referenced by TIFFOpenExt(), and TIFFOpenWExt().