LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Typedefs
Client I/O callbacks

Define the client-resource operations used by a TIFF handle. More...

Collaboration diagram for Client I/O callbacks:

Typedefs

typedef tmsize_t(* TIFFReadWriteProc) (thandle_t fd, void *buf, tmsize_t size)
 Transfer bytes at the current position of a client I/O resource.
 
typedef toff_t(* TIFFSeekProc) (thandle_t fd, toff_t off, int whence)
 Change the current position of a client I/O resource.
 
typedef int(* TIFFCloseProc) (thandle_t fd)
 Release a client I/O resource or its adapter context.
 
typedef toff_t(* TIFFSizeProc) (thandle_t fd)
 Query the byte length of a client I/O resource.
 
typedef int(* TIFFMapFileProc) (thandle_t fd, void **base, toff_t *size)
 Provide a readable whole-file view of a client resource.
 
typedef void(* TIFFUnmapFileProc) (thandle_t fd, void *base, toff_t size)
 Release a whole-file view supplied by a mapping callback.
 

Detailed Description

Define the client-resource operations used by a TIFF handle.

Typedef Documentation

◆ TIFFCloseProc

typedef int(* TIFFCloseProc) (thandle_t fd)

Release a client I/O resource or its adapter context.

TIFFClose() calls this once after TIFFCleanup() has invalidated the handle. TIFFCleanup() and a NULL-returning client open do not call it. The callback defines whether it closes a resource, frees a wrapper, or both; it must not access the freed TIFF handle. A C++ stream callback deletes the adapter but leaves the borrowed stream open. Failure does not restore the TIFF handle, and no automatic library diagnostic for close failure is guaranteed.

Parameters
[in,out]fdClient context passed to close after the TIFF handle is freed.
Returns
Conventionally zero on success and -1 on failure; TIFFClose() discards this result.

Definition at line 951 of file tiffio.h.

◆ TIFFMapFileProc

typedef int(* TIFFMapFileProc) (thandle_t fd, void **base, toff_t *size)

Provide a readable whole-file view of a client resource.

The view starts at TIFF-file offset zero and must remain readable and valid until its matching TIFFUnmapFileProc call. Library mapping paths are read-only. The library borrows the view and releases it through the supplied unmapper, not _TIFFfree(). On failure the outputs are not guaranteed valid and must not be used. A failed mapping normally permits fallback to read/seek I/O without a library error. NULL mapproc is replaced by an always-failing dummy.

Parameters
[in,out]fdOpaque client context used to obtain a mapping.
[out]baseNon-NULL output pointer for the view base on success.
[out]sizeNon-NULL output pointer for the view length in bytes on success.
Returns
Nonzero if a valid readable view is supplied; zero if mapping is unavailable or fails. Do not use the mmap() pointer/error convention as this status.

Definition at line 989 of file tiffio.h.

◆ TIFFReadWriteProc

typedef tmsize_t(* TIFFReadWriteProc) (thandle_t fd, void *buf, tmsize_t size)

Transfer bytes at the current position of a client I/O resource.

Used for both readproc and writeproc. Reads fill buf, writes consume buf; either may advance the client position. Library callers normally require an exact transfer and do not provide general retry/rollback. A failure may follow partial I/O. Buffer storage remains caller-owned and can be reused immediately after return; do not retain it. Zero- length behaviour and errno/GetLastError are backend-specific. Callbacks must remain valid for the handle lifetime and must not destroy or recursively perform I/O on the invoking handle.

Parameters
[in,out]fdOpaque client context; the callback may update its I/O state.
[in,out]bufFor reads, writable destination; for writes, readable source that must not be modified. Capacity is at least size bytes.
[in]sizeRequested nonnegative byte count representable by tmsize_t.
Returns
The transferred byte count. Short counts or a negative result indicate an incomplete transfer; zero may denote end-of-input or a backend error. The native Windows backend returns zero on API failure.

Definition at line 911 of file tiffio.h.

◆ TIFFSeekProc

typedef toff_t(* TIFFSeekProc) (thandle_t fd, toff_t off, int whence)

Change the current position of a client I/O resource.

Offsets and returned positions use TIFF-file coordinates. A callback must support the seeks needed by the chosen operations, including absolute seeks from the beginning of the TIFF data. A failed seek need not preserve position. No storage ownership transfers. Backend diagnostics are not implied; the library may separately diagnose an unexpected position. Do not destroy or recursively perform I/O on the invoking handle.

Parameters
[in,out]fdOpaque client context whose position may change.
[in]offByte offset interpreted according to whence; the interface uses an unsigned type.
[in]whenceSEEK_SET, SEEK_CUR, or SEEK_END.
Returns
The resulting absolute byte position. The conventional failure sentinel is (toff_t)-1, but the current native Windows adapter returns zero on failure; see Current implementation limits.

Definition at line 933 of file tiffio.h.

◆ TIFFSizeProc

typedef toff_t(* TIFFSizeProc) (thandle_t fd)

Query the byte length of a client I/O resource.

If implemented by seeking, restore the prior position where possible. The library performs no independent position rollback and does not acquire storage ownership. Failure reporting and errno/GetLastError follow the callback. Keep the callback and context valid for the handle lifetime.

Parameters
[in,out]fdOpaque client context; a seek-based implementation may temporarily change position.
Returns
The resource length in TIFF-file byte coordinates. The built- in backends use zero for size-query failure, so there is no uniform distinct error sentinel.

Definition at line 968 of file tiffio.h.

◆ TIFFUnmapFileProc

typedef void(* TIFFUnmapFileProc) (thandle_t fd, void *base, toff_t size)

Release a whole-file view supplied by a mapping callback.

Invalidates the mapped view according to the client mapping contract. Returns no status; the library cannot detect or report an unmap failure through this interface. It does not replace the client close callback. A NULL unmapproc installs a no-op, so supply a real unmapper whenever a successful mapping requires explicit release. The current early read-open failure cleanup can also invoke this callback with base = NULL and size = 0 before any mapping call. Tolerate that no-view case without assuming that a mapping was acquired.

Parameters
[in,out]fdMatching client context, still valid for view release.
[in]baseMapped-view base, or NULL in early no-view cleanup.
[in]sizeMapped length in bytes, or zero in early no-view cleanup.

Definition at line 1008 of file tiffio.h.