LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs
Handle state and utility definitions

Describe per-handle storage, state flags, and basic internal helpers. More...

Collaboration diagram for Handle state and utility definitions:

Data Structures

struct  client_info
 Link a named client-data association to a TIFF handle. More...
 
struct  TIFFOffsetAndDirNumber
 Pair a directory file offset with its main-IFD index. More...
 
struct  tiff
 Hold private state for one open TIFF library instance. More...
 
struct  TIFFOpenOptions
 Hold allocation limits and diagnostics used when opening a TIFF handle. More...
 

Macros

#define TIFF_NON_EXISTENT_DIR_NUMBER   UINT_MAX
 Mark an unknown or nonexistent directory index.
 
#define streq(a, b)   (strcmp(a, b) == 0)
 Compare two null-terminated strings for equality.
 
#define strneq(a, b, n)   (strncmp(a, b, n) == 0)
 Compare up to n bytes of two strings for equality.
 
#define TRUE   1
 Represent the legacy internal true value.
 
#define FALSE   0
 Represent the legacy internal false value.
 
#define TIFF_FILLORDER   0x00003U
 Mask the selected data bit-fill-order bits in tif_flags.
 
#define TIFF_DIRTYHEADER   0x00004U
 Mark a file header that needs writing.
 
#define TIFF_DIRTYDIRECT   0x00008U
 Mark a current directory that needs writing.
 
#define TIFF_BUFFERSETUP   0x00010U
 Mark completed data-buffer setup.
 
#define TIFF_CODERSETUP   0x00020U
 Mark completed codec setup.
 
#define TIFF_BEENWRITING   0x00040U
 Record that scanline or image-data writing has begun.
 
#define TIFF_SWAB   0x00080U
 Request swapping multibyte file values to or from host order.
 
#define TIFF_NOBITREV   0x00100U
 Suppress automatic bit reversal.
 
#define TIFF_MYBUFFER   0x00200U
 Mark a raw buffer owned and released by the handle.
 
#define TIFF_ISTILED   0x00400U
 Mark tile-based rather than strip-based image storage.
 
#define TIFF_MAPPED   0x00800U
 Request or record memory-mapped file access.
 
#define TIFF_POSTENCODE   0x01000U
 Request a pending codec postencode call.
 
#define TIFF_INSUBIFD   0x02000U
 Mark writing within a SubIFD sequence.
 
#define TIFF_UPSAMPLED   0x04000U
 Mark codec output that has already been upsampled.
 
#define TIFF_STRIPCHOP   0x08000U
 Enable internal chopping of a large uncompressed strip.
 
#define TIFF_HEADERONLY   0x10000U
 Request header-only opening without reading the first IFD.
 
#define TIFF_NOREADRAW   0x20000U
 Suppress the normal raw-data read path.
 
#define TIFF_INCUSTOMIFD   0x40000U
 Mark writing of a custom IFD.
 
#define TIFF_BIGTIFF   0x80000U
 Mark the BigTIFF file format.
 
#define TIFF_BUF4WRITE   0x100000U
 Interpret the raw buffer and its byte count as pending output.
 
#define TIFF_DIRTYSTRIP   0x200000U
 Mark strip/tile offset or byte-count arrays that need writing.
 
#define TIFF_PERSAMPLE   0x400000U
 Select per-sample arrays for supported sample-valued fields.
 
#define TIFF_BUFFERMMAP   0x800000U
 Mark raw data that borrows mapped-file storage.
 
#define TIFF_DEFERSTRILELOAD   0x1000000U
 Defer loading strip/tile offset and byte-count arrays.
 
#define TIFF_LAZYSTRILELOAD_DONE   0x2000000U
 Record a switch from on-demand to full strip/tile-array loading.
 
#define TIFF_CHOPPEDUPARRAYS   0x4000000U
 Mark strip arrays replaced by the strip-chopping operation.
 
#define TIFF_LAZYSTRILELOAD_ASKED   0x8000000U
 Record a lazy strip/tile loading request from the O open flag.
 
#define isPseudoTag(t)   (t > 0xffff) /* is tag value normal or pseudo */
 Test whether a tag identifier is outside the on-disk 16-bit range.
 
#define isTiled(tif)   (((tif)->tif_flags & TIFF_ISTILED) != 0)
 Test whether a handle uses tiled storage.
 
#define isMapped(tif)   (((tif)->tif_flags & TIFF_MAPPED) != 0)
 Test whether TIFF_MAPPED is set on a handle.
 
#define isFillOrder(tif, o)   (((tif)->tif_flags & (o)) != 0)
 Test whether selected bit-fill-order bits are present in a handle.
 
#define isUpSampled(tif)   (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
 Test whether the codec reports upsampled output.
 
#define TIFFReadFile(tif, buf, size)    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
 Invoke the handle's client read callback.
 
#define TIFFWriteFile(tif, buf, size)    ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))
 Invoke the handle's client write callback.
 
#define TIFFSeekFile(tif, off, whence)    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
 Invoke the handle's client seek callback.
 
#define TIFFCloseFile(tif)   ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
 Invoke the handle's client close callback.
 
#define TIFFGetFileSize(tif)   ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
 Invoke the handle's client size callback.
 
#define TIFFMapFileContents(tif, paddr, psize)    ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))
 Invoke the handle's client mapping callback.
 
#define TIFFUnmapFileContents(tif, addr, size)    ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))
 Invoke the handle's client unmapping callback.
 
#define ReadOK(tif, buf, size)    (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))
 Test whether one client read transfers the entire requested byte count.
 
#define SeekOK(tif, off)   _TIFFSeekOK(tif, off)
 Test whether an absolute seek reaches the requested file position.
 
#define WriteOK(tif, buf, size)    (TIFFWriteFile((tif), (buf), (size)) == (tmsize_t)(size))
 Test whether one client write transfers the entire requested byte count.
 
#define TIFFhowmany_32(x, y)
 Compute a guarded 32-bit ceiling quotient.
 
#define TIFFhowmany_32_maxuint_compat(x, y)
 Compute a 32-bit ceiling quotient without adding x and y first.
 
#define TIFFhowmany8_32(x)    (((x) & 0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)
 Compute the byte count needed to hold a 32-bit bit count.
 
#define TIFFroundup_32(x, y)   ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))
 Round a 32-bit value up to a multiple using the guarded quotient.
 
#define TIFFhowmany_64(x, y)    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
 Compute a 64-bit ceiling quotient using an unchecked addition.
 
#define TIFFhowmany8_64(x)    (((x) & 0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
 Compute the byte count needed to hold a 64-bit bit count.
 
#define TIFFroundup_64(x, y)   ((uint64_t)(TIFFhowmany_64(x, y) * (uint64_t)(y)))
 Round a 64-bit value up to a multiple without overflow checks.
 
#define TIFFSafeMultiply(t, v, m)
 Multiply in a caller-selected unsigned type with a reverse-division check.
 
#define TIFFSafeModMul32(tif, module, index, count, dimension, result)
 Compute (index modulo count) times dimension with a checked product.
 
#define TIFFmax(A, B)   ((A) > (B) ? (A) : (B))
 Select the first operand if it is greater, otherwise the second.
 
#define TIFFmin(A, B)   ((A) < (B) ? (A) : (B))
 Select the first operand if it is smaller, otherwise the second.
 
#define TIFFArrayCount(a)   (sizeof(a) / sizeof((a)[0]))
 Compute the element count of an actual array.
 
#define TIFF_FLOAT_EQ(x, y)   (!(fabsf((x) - (y)) > 0.0f))
 Test whether a float difference is not greater than zero in magnitude.
 
#define TIFF_DOUBLE_EQ(x, y)   (!(fabs((x) - (y)) > 0.0))
 Test whether a double difference is not greater than zero in magnitude.
 
#define _TIFF_lseek_f(fildes, offset, whence)   lseek(fildes, offset, whence)
 Seek a file descriptor through the platform large-file interface.
 
#define _TIFF_fseek_f(stream, offset, whence)   fseek(stream, offset, whence)
 Seek a stream through the platform large-file interface.
 
#define _TIFF_fstat_f(fildes, stat_buff)   fstat(fildes, stat_buff)
 Query file status through the platform large-file interface.
 
#define _TIFF_stat_s   struct stat
 Select the platform file-status structure type.
 
#define _TIFF_off_t   off_t
 Select the platform large-file offset type.
 
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
 Suppress unsigned-overflow instrumentation on supported Clang functions.
 

Typedefs

typedef struct client_info TIFFClientInfoLink
 Link a named client-data association to a TIFF handle.
 
typedef unsigned char tidataval_t
 Name a legacy internal image byte.
 
typedef tidataval_t * tidata_t
 Name a legacy pointer to internal image bytes.
 
typedef struct TIFFOffsetAndDirNumber TIFFOffsetAndDirNumber
 Name the TIFFOffsetAndDirNumber record type.
 
typedef size_t TIFFIOSize_t
 Represent a native POSIX I/O byte count.
 

Detailed Description

Describe per-handle storage, state flags, and basic internal helpers.

Macro Definition Documentation

◆ _TIFF_fseek_f

#define _TIFF_fseek_f (   stream,
  offset,
  whence 
)    fseek(stream, offset, whence)

Seek a stream through the platform large-file interface.

Forwards arguments and results to the selected C runtime interface. File position, errno, output validity after failure, and other effects follow that interface. This wrapper adds no library diagnostics or ownership transfer. Each argument is evaluated once.

Parameters
[in,out]streamValid FILE stream.
[in]offsetOffset in bytes interpreted by whence.
[in]whenceStandard seek origin.
Returns
Zero on success; nonzero on failure, with errno set according to the selected C runtime interface.

Definition at line 1431 of file tiffiop.h.

◆ _TIFF_fstat_f

#define _TIFF_fstat_f (   fildes,
  stat_buff 
)    fstat(fildes, stat_buff)

Query file status through the platform large-file interface.

Forwards arguments and results to the selected C runtime interface. File position, errno, output validity after failure, and other effects follow that interface. This wrapper adds no library diagnostics or ownership transfer. Each argument is evaluated once.

Parameters
[in]fildesValid file descriptor.
[out]stat_buffNon-NULL pointer to the platform status structure.
Returns
Zero on success, or -1 on failure with errno set by the selected C runtime interface; output validity on failure follows that interface.

Definition at line 1446 of file tiffiop.h.

◆ _TIFF_lseek_f

#define _TIFF_lseek_f (   fildes,
  offset,
  whence 
)    lseek(fildes, offset, whence)

Seek a file descriptor through the platform large-file interface.

Forwards arguments and results to the selected C runtime interface. File position, errno, output validity after failure, and other effects follow that interface. This wrapper adds no library diagnostics or ownership transfer. Each argument is evaluated once.

Parameters
[in]fildesValid file descriptor.
[in]offsetOffset in bytes interpreted by whence.
[in]whenceStandard seek origin.
Returns
The resulting byte position, or -1 on failure; errno follows the selected C runtime interface.

Definition at line 1414 of file tiffiop.h.

◆ _TIFF_off_t

#define _TIFF_off_t   off_t

Select the platform large-file offset type.

Definition at line 1458 of file tiffiop.h.

◆ _TIFF_stat_s

#define _TIFF_stat_s   struct stat

Select the platform file-status structure type.

Definition at line 1453 of file tiffiop.h.

◆ FALSE

#define FALSE   0

Represent the legacy internal false value.

Definition at line 136 of file tiffiop.h.

◆ isFillOrder

#define isFillOrder (   tif,
  o 
)    (((tif)->tif_flags & (o)) != 0)

Test whether selected bit-fill-order bits are present in a handle.

Uses a bitwise intersection rather than comparing the masked value for equality. Does not modify state or transfer ownership. Use side-effect-free macro arguments.

Parameters
[in]tifNon-NULL TIFF handle.
[in]oFill-order bit value to test.
Returns
Nonzero if any tested bits are set; zero otherwise.

Definition at line 858 of file tiffiop.h.

◆ isMapped

#define isMapped (   tif)    (((tif)->tif_flags & TIFF_MAPPED) != 0)

Test whether TIFF_MAPPED is set on a handle.

See TIFF_MAPPED: during opening the flag may be set before a view exists. Reads handle flags without modifying state or transferring ownership. Use side-effect-free macro arguments.

Parameters
[in]tifNon-NULL TIFF handle.
Returns
Nonzero if TIFF_MAPPED is set; zero otherwise.

Definition at line 845 of file tiffiop.h.

◆ isPseudoTag

#define isPseudoTag (   t)    (t > 0xffff) /* is tag value normal or pseudo */

Test whether a tag identifier is outside the on-disk 16-bit range.

The macro does not fully parenthesise its argument. Use a simple value or explicit parentheses around a compound expression. No diagnostics occur. Use side-effect-free macro arguments.

Parameters
[in]tUnsigned tag identifier; pass a simple value expression.
Returns
Nonzero for identifiers above 65535; zero otherwise.

Definition at line 821 of file tiffiop.h.

◆ isTiled

#define isTiled (   tif)    (((tif)->tif_flags & TIFF_ISTILED) != 0)

Test whether a handle uses tiled storage.

Reads handle flags without modifying state or transferring ownership. Use side-effect-free macro arguments.

Parameters
[in]tifNon-NULL TIFF handle.
Returns
Nonzero if TIFF_ISTILED is set; zero otherwise.

Definition at line 833 of file tiffiop.h.

◆ isUpSampled

#define isUpSampled (   tif)    (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)

Test whether the codec reports upsampled output.

Reads handle flags without modifying state or transferring ownership. Use side-effect-free macro arguments.

Parameters
[in]tifNon-NULL TIFF handle.
Returns
Nonzero if TIFF_UPSAMPLED is set; zero otherwise.

Definition at line 869 of file tiffiop.h.

◆ ReadOK

#define ReadOK (   tif,
  buf,
  size 
)     (TIFFReadFile((tif), (buf), (size)) == (tmsize_t)(size))

Test whether one client read transfers the entire requested byte count.

Partial transfers and errors both produce zero; partial output remains in buf according to the callback. No retry or extra diagnostic is performed. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL TIFF handle.
[out]bufCaller-owned destination with at least size writable bytes.
[in]sizeRequested nonnegative byte count representable by tmsize_t.
Returns
Nonzero only if the callback returns exactly size bytes.

Definition at line 1000 of file tiffiop.h.

◆ SeekOK

#define SeekOK (   tif,
  off 
)    _TIFFSeekOK(tif, off)

Test whether an absolute seek reaches the requested file position.

Rejects offsets above UINT64_MAX / 2 without calling the client. Otherwise performs one SEEK_SET callback and tests that its result equals off. The helper emits no additional diagnostics and does not transfer ownership. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL TIFF handle.
[in]offAbsolute byte offset from the start of the file.
Returns
Nonzero if an allowed offset is reached exactly; zero otherwise.

Definition at line 1017 of file tiffiop.h.

◆ streq

#define streq (   a,
  b 
)    (strcmp(a, b) == 0)

Compare two null-terminated strings for equality.

No ownership transfer or library diagnostics occur. Use side-effect-free macro arguments.

Parameters
[in]aFirst non-NULL string.
[in]bSecond non-NULL string.
Returns
Nonzero if strcmp() reports equality; zero otherwise.

Definition at line 108 of file tiffiop.h.

◆ strneq

#define strneq (   a,
  b,
  n 
)    (strncmp(a, b, n) == 0)

Compare up to n bytes of two strings for equality.

Reads at most n bytes from either argument, stopping at a null byte. No ownership transfer or library diagnostics occur. Use side-effect-free macro arguments.

Parameters
[in]aFirst string or byte sequence readable through the comparison.
[in]bSecond string or byte sequence readable through the comparison.
[in]nMaximum number of bytes to compare.
Returns
Nonzero if strncmp() reports equality; zero otherwise.

Definition at line 124 of file tiffiop.h.

◆ TIFF_BEENWRITING

#define TIFF_BEENWRITING   0x00040U

Record that scanline or image-data writing has begun.

Definition at line 436 of file tiffiop.h.

◆ TIFF_BIGTIFF

#define TIFF_BIGTIFF   0x80000U

Mark the BigTIFF file format.

Definition at line 508 of file tiffiop.h.

◆ TIFF_BUF4WRITE

#define TIFF_BUF4WRITE   0x100000U

Interpret the raw buffer and its byte count as pending output.

Definition at line 513 of file tiffiop.h.

◆ TIFF_BUFFERMMAP

#define TIFF_BUFFERMMAP   0x800000U

Mark raw data that borrows mapped-file storage.

Definition at line 528 of file tiffiop.h.

◆ TIFF_BUFFERSETUP

#define TIFF_BUFFERSETUP   0x00010U

Mark completed data-buffer setup.

Definition at line 426 of file tiffiop.h.

◆ TIFF_CHOPPEDUPARRAYS

#define TIFF_CHOPPEDUPARRAYS   0x4000000U

Mark strip arrays replaced by the strip-chopping operation.

Definition at line 547 of file tiffiop.h.

◆ TIFF_CODERSETUP

#define TIFF_CODERSETUP   0x00020U

Mark completed codec setup.

Definition at line 431 of file tiffiop.h.

◆ TIFF_DEFERSTRILELOAD

#define TIFF_DEFERSTRILELOAD   0x1000000U

Defer loading strip/tile offset and byte-count arrays.

Definition at line 533 of file tiffiop.h.

◆ TIFF_DIRTYDIRECT

#define TIFF_DIRTYDIRECT   0x00008U

Mark a current directory that needs writing.

Definition at line 421 of file tiffiop.h.

◆ TIFF_DIRTYHEADER

#define TIFF_DIRTYHEADER   0x00004U

Mark a file header that needs writing.

Currently unused; reserved bit value retained for compatibility.

Definition at line 416 of file tiffiop.h.

◆ TIFF_DIRTYSTRIP

#define TIFF_DIRTYSTRIP   0x200000U

Mark strip/tile offset or byte-count arrays that need writing.

Definition at line 518 of file tiffiop.h.

◆ TIFF_DOUBLE_EQ

#define TIFF_DOUBLE_EQ (   x,
  y 
)    (!(fabs((x) - (y)) > 0.0))

Test whether a double difference is not greater than zero in magnitude.

This is not a general IEEE equality test: a NaN difference also yields nonzero. Normal floating-point exception behaviour applies; no library diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]xFirst floating-point value.
[in]ySecond floating-point value.
Returns
Nonzero if fabs(x - y) is not greater than zero; zero otherwise.

Definition at line 1271 of file tiffiop.h.

◆ TIFF_FILLORDER

#define TIFF_FILLORDER   0x00003U

Mask the selected data bit-fill-order bits in tif_flags.

Definition at line 409 of file tiffiop.h.

◆ TIFF_FLOAT_EQ

#define TIFF_FLOAT_EQ (   x,
  y 
)    (!(fabsf((x) - (y)) > 0.0f))

Test whether a float difference is not greater than zero in magnitude.

This is not a general IEEE equality test: a NaN difference also yields nonzero. Normal floating-point exception behaviour applies; no library diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]xFirst floating-point value.
[in]ySecond floating-point value.
Returns
Nonzero if fabsf(x - y) is not greater than zero; zero otherwise.

Definition at line 1256 of file tiffiop.h.

◆ TIFF_HEADERONLY

#define TIFF_HEADERONLY   0x10000U

Request header-only opening without reading the first IFD.

Definition at line 491 of file tiffiop.h.

◆ TIFF_INCUSTOMIFD

#define TIFF_INCUSTOMIFD   0x40000U

Mark writing of a custom IFD.

Currently unused; reserved bit value retained for compatibility.

Definition at line 503 of file tiffiop.h.

◆ TIFF_INSUBIFD

#define TIFF_INSUBIFD   0x02000U

Mark writing within a SubIFD sequence.

Definition at line 476 of file tiffiop.h.

◆ TIFF_ISTILED

#define TIFF_ISTILED   0x00400U

Mark tile-based rather than strip-based image storage.

Definition at line 456 of file tiffiop.h.

◆ TIFF_LAZYSTRILELOAD_ASKED

#define TIFF_LAZYSTRILELOAD_ASKED   0x8000000U

Record a lazy strip/tile loading request from the O open flag.

Definition at line 552 of file tiffiop.h.

◆ TIFF_LAZYSTRILELOAD_DONE

#define TIFF_LAZYSTRILELOAD_DONE   0x2000000U

Record a switch from on-demand to full strip/tile-array loading.

Set by _TIFFFillStriles() when it discards the entries loaded on demand for an 'O'-mode directory so that the full arrays are loaded; cleared by TIFFReadDirectory().

Definition at line 542 of file tiffiop.h.

◆ TIFF_MAPPED

#define TIFF_MAPPED   0x00800U

Request or record memory-mapped file access.

Set during opening for read-only modes (unless 'm' is given) before mapping is attempted, and cleared if mapping fails, so it can be set while tif_base is still NULL. After a successful open it is set only while tif_base and tif_size describe a view. TIFFInitJBIG() clears it without unmapping.

Definition at line 466 of file tiffiop.h.

◆ TIFF_MYBUFFER

#define TIFF_MYBUFFER   0x00200U

Mark a raw buffer owned and released by the handle.

Definition at line 451 of file tiffiop.h.

◆ TIFF_NOBITREV

#define TIFF_NOBITREV   0x00100U

Suppress automatic bit reversal.

Definition at line 446 of file tiffiop.h.

◆ TIFF_NON_EXISTENT_DIR_NUMBER

#define TIFF_NON_EXISTENT_DIR_NUMBER   UINT_MAX

Mark an unknown or nonexistent directory index.

Definition at line 95 of file tiffiop.h.

◆ TIFF_NOREADRAW

#define TIFF_NOREADRAW   0x20000U

Suppress the normal raw-data read path.

Definition at line 496 of file tiffiop.h.

◆ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW

#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW

Suppress unsigned-overflow instrumentation on supported Clang functions.

Definition at line 1484 of file tiffiop.h.

◆ TIFF_PERSAMPLE

#define TIFF_PERSAMPLE   0x400000U

Select per-sample arrays for supported sample-valued fields.

Definition at line 523 of file tiffiop.h.

◆ TIFF_POSTENCODE

#define TIFF_POSTENCODE   0x01000U

Request a pending codec postencode call.

Definition at line 471 of file tiffiop.h.

◆ TIFF_STRIPCHOP

#define TIFF_STRIPCHOP   0x08000U

Enable internal chopping of a large uncompressed strip.

Definition at line 486 of file tiffiop.h.

◆ TIFF_SWAB

#define TIFF_SWAB   0x00080U

Request swapping multibyte file values to or from host order.

Definition at line 441 of file tiffiop.h.

◆ TIFF_UPSAMPLED

#define TIFF_UPSAMPLED   0x04000U

Mark codec output that has already been upsampled.

Definition at line 481 of file tiffiop.h.

◆ TIFFArrayCount

#define TIFFArrayCount (   a)    (sizeof(a) / sizeof((a)[0]))

Compute the element count of an actual array.

Does not validate that the argument is an array. Normal sizeof rules apply, including runtime evaluation for variably modified types. No allocation occurs. Use side-effect-free macro arguments.

Parameters
[in]aArray object, not a pointer to its first element.
Returns
The array size divided by its element size, as size_t.

Definition at line 1239 of file tiffiop.h.

◆ TIFFCloseFile

#define TIFFCloseFile (   tif)    ((*(tif)->tif_closeproc)((tif)->tif_clientdata))

Invoke the handle's client close callback.

May release the underlying client I/O resource. This does not free the TIFF handle and adds no diagnostics or error handling. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed close callback.
Returns
The client close callback's status, unchanged; the conventional file-close result is zero on success and -1 on failure.

Definition at line 934 of file tiffiop.h.

◆ TIFFGetFileSize

#define TIFFGetFileSize (   tif)    ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))

Invoke the handle's client size callback.

Client-state and file-position effects follow the callback implementation. The wrapper adds no diagnostics or ownership transfer. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed size callback.
Returns
The size callback's result, unchanged.

Definition at line 946 of file tiffiop.h.

◆ TIFFhowmany8_32

#define TIFFhowmany8_32 (   x)     (((x) & 0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)

Compute the byte count needed to hold a 32-bit bit count.

No allocation, library-state changes, or error reporting occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative bit count representable by uint32_t.
Returns
The ceiling of x divided by eight, in bytes.

Definition at line 1087 of file tiffiop.h.

◆ TIFFhowmany8_64

#define TIFFhowmany8_64 (   x)     (((x) & 0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)

Compute the byte count needed to hold a 64-bit bit count.

No allocation, library-state changes, or error reporting occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative bit count representable by uint64_t.
Returns
The ceiling of x divided by eight, in bytes.

Definition at line 1127 of file tiffiop.h.

◆ TIFFhowmany_32

#define TIFFhowmany_32 (   x,
  y 
)
Value:
(((uint32_t)x < (0xffffffff - (uint32_t)(y - 1))) \
? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y))) \
: 0U)

Compute a guarded 32-bit ceiling quotient.

Uses the strict guard x < UINT32_MAX - (y - 1), so the equality boundary also returns zero. A zero result is not a unique error sentinel. The guard does not parenthesise x and subtracts one from y before conversion to uint32_t, so pass simple uint32_t-typed expressions. No diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative value representable by uint32_t.
[in]yPositive divisor representable by uint32_t.
Returns
The ceiling quotient, or zero when the conservative addition guard rejects it.

Definition at line 1056 of file tiffiop.h.

◆ TIFFhowmany_32_maxuint_compat

#define TIFFhowmany_32_maxuint_compat (   x,
  y 
)
Value:
(((uint32_t)(x) / (uint32_t)(y)) + \
((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))

Compute a 32-bit ceiling quotient without adding x and y first.

Handles x near UINT32_MAX, but multiplying the result by y can still overflow. No diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative value representable by uint32_t.
[in]yPositive divisor representable by uint32_t.
Returns
The ceiling of x divided by y.

Definition at line 1074 of file tiffiop.h.

◆ TIFFhowmany_64

#define TIFFhowmany_64 (   x,
  y 
)     ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))

Compute a 64-bit ceiling quotient using an unchecked addition.

The caller must ensure x + y - 1 fits uint64_t. Overflow wraps without diagnostics. No allocation or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative value representable by uint64_t.
[in]yPositive divisor representable by uint64_t.
Returns
The ceiling quotient when the addition is representable.

Definition at line 1115 of file tiffiop.h.

◆ TIFFMapFileContents

#define TIFFMapFileContents (   tif,
  paddr,
  psize 
)     ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))

Invoke the handle's client mapping callback.

On success the returned view has the lifetime and release contract of the client mapping callback. On failure output validity is defined by that callback. The wrapper performs no independent allocation or error handling. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed mapping callback.
[out]paddrNon-NULL output pointer for the mapped-file base.
[out]psizeNon-NULL output pointer for the mapped length in bytes.
Returns
Nonzero on callback success, zero on callback failure, unchanged.

Definition at line 962 of file tiffiop.h.

◆ TIFFmax

#define TIFFmax (   A,
  B 
)    ((A) > (B) ? (A) : (B))

Select the first operand if it is greater, otherwise the second.

The selected operand is evaluated again after comparison. No library diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]AFirst comparable value.
[in]BSecond comparable value.
Returns
A when A > B; B otherwise, using the usual C conversions.

Definition at line 1213 of file tiffiop.h.

◆ TIFFmin

#define TIFFmin (   A,
  B 
)    ((A) < (B) ? (A) : (B))

Select the first operand if it is smaller, otherwise the second.

The selected operand is evaluated again after comparison. No library diagnostic or ownership transfer occurs. Use side-effect-free macro arguments.

Parameters
[in]AFirst comparable value.
[in]BSecond comparable value.
Returns
A when A < B; B otherwise, using the usual C conversions.

Definition at line 1226 of file tiffiop.h.

◆ TIFFReadFile

#define TIFFReadFile (   tif,
  buf,
  size 
)     ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))

Invoke the handle's client read callback.

The callback may advance file position and modify client state. This wrapper adds no diagnostics, retry, or ownership transfer. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed read callback.
[out]bufCaller-owned destination with at least size writable bytes.
[in]sizeRequested nonnegative byte count.
Returns
The transferred byte count, or the callback's negative error result, unchanged; a short count is a partial read.

Definition at line 885 of file tiffiop.h.

◆ TIFFroundup_32

#define TIFFroundup_32 (   x,
  y 
)    ((uint32_t)(TIFFhowmany_32(x, y) * (uint32_t)(y)))

Round a 32-bit value up to a multiple using the guarded quotient.

Inherits the conservative guard and ambiguous zero result of TIFFhowmany_32(). No allocation or diagnostic occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative value representable by uint32_t.
[in]yPositive alignment representable by uint32_t.
Returns
The rounded value, or zero if TIFFhowmany_32() rejects the addition.

Definition at line 1102 of file tiffiop.h.

◆ TIFFroundup_64

#define TIFFroundup_64 (   x,
  y 
)    ((uint64_t)(TIFFhowmany_64(x, y) * (uint64_t)(y)))

Round a 64-bit value up to a multiple without overflow checks.

The caller must ensure x + y - 1 and the final product fit uint64_t. Overflow wraps without diagnostics. No allocation occurs. Use side-effect-free macro arguments.

Parameters
[in]xNonnegative value representable by uint64_t.
[in]yPositive alignment representable by uint64_t.
Returns
The rounded value when both addition and multiplication are representable.

Definition at line 1142 of file tiffiop.h.

◆ TIFFSafeModMul32

#define TIFFSafeModMul32 (   tif,
  module,
  index,
  count,
  dimension,
  result 
)
Value:
((dimension) == 0 || ((index) % (count) == 0) \
? ((result) = 0, 0) \
: (((result) = _TIFFMultiply32((tif), (index) % (count), (dimension), \
(module))) == 0))
uint32_t _TIFFMultiply32(TIFF *tif, uint32_t first, uint32_t second, const char *where)
Multiply two unsigned values with an overflow check.
Definition tif_aux.c:40

Compute (index modulo count) times dimension with a checked product.

If dimension is zero or index % count is zero, sets result to zero and returns zero without calling _TIFFMultiply32(); count must be nonzero unless dimension is zero. index and count may be evaluated twice. On overflow _TIFFMultiply32() emits an error and result becomes zero. Does not allocate or transfer storage ownership. Use side-effect-free macro arguments.

Parameters
[in,out]tifHandle used by _TIFFMultiply32() for error reporting.
[in]moduleNon-NULL diagnostic module name.
[in]indexUnsigned 32-bit index.
[in]countPositive unsigned divisor unless dimension is zero.
[in]dimensionUnsigned 32-bit multiplier.
[out]resultAssignable uint32_t lvalue receiving the product or zero.
Returns
Zero on success; nonzero if the checked nonzero product overflows.

Definition at line 1195 of file tiffiop.h.

◆ TIFFSafeMultiply

#define TIFFSafeMultiply (   t,
  v,
  m 
)
Value:
((((t)(m) != (t)0) && (((t)((((t)(v)) * ((t)(m))) / ((t)(m)))) == (t)(v))) \
? (t)(((t)(v)) * ((t)(m))) \
: (t)0)

Multiply in a caller-selected unsigned type with a reverse-division check.

Use an unsigned type of at least unsigned-int rank. Signed types and narrow unsigned types subject to signed integer promotion are not covered by this check. Zero can be a valid product and is not a unique error sentinel. The macro emits no diagnostic and transfers no ownership. Use side-effect-free macro arguments.

Parameters
[in]tUnsigned integer type whose multiplication is performed unsigned.
[in]vFirst operand, representable in t.
[in]mSecond operand, representable in t.
Returns
The product in t, or zero if m is zero or the reverse-division check fails.

Definition at line 1164 of file tiffiop.h.

◆ TIFFSeekFile

#define TIFFSeekFile (   tif,
  off,
  whence 
)     ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))

Invoke the handle's client seek callback.

May change file position and client state. The wrapper adds no error handling or ownership transfer. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed seek callback.
[in]offByte offset interpreted according to whence.
[in]whenceSEEK_SET, SEEK_CUR, or SEEK_END as supported by the callback.
Returns
The callback's resulting byte position, unchanged; the failure value is callback-defined (the POSIX backend returns (toff_t)-1, the Win32 backend 0).

Definition at line 920 of file tiffiop.h.

◆ TIFFUnmapFileContents

#define TIFFUnmapFileContents (   tif,
  addr,
  size 
)     ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))

Invoke the handle's client unmapping callback.

Invalidates the mapped view according to the callback contract. Adds no independent diagnostics or error handling. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed unmapping callback.
[in]addrMapped-file base, or NULL during early failed-open cleanup.
[in]sizeMapped length in bytes, or zero during no-view cleanup.
Returns
No value; expands to the unmapping callback invocation.

Definition at line 977 of file tiffiop.h.

◆ TIFFWriteFile

#define TIFFWriteFile (   tif,
  buf,
  size 
)     ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))

Invoke the handle's client write callback.

The callback may write data, advance file position, and modify client state. This wrapper adds no diagnostics, retry, or ownership transfer. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL handle with an installed write callback.
[in]bufCaller-owned source containing at least size readable bytes.
[in]sizeRequested nonnegative byte count.
Returns
The transferred byte count, or the callback's negative error result, unchanged; a short count is a partial write.

Definition at line 902 of file tiffiop.h.

◆ TRUE

#define TRUE   1

Represent the legacy internal true value.

Definition at line 131 of file tiffiop.h.

◆ WriteOK

#define WriteOK (   tif,
  buf,
  size 
)     (TIFFWriteFile((tif), (buf), (size)) == (tmsize_t)(size))

Test whether one client write transfers the entire requested byte count.

Partial transfers and errors both produce zero; partial writes are not rolled back. No retry or extra diagnostic is performed. Use side-effect-free macro arguments.

Parameters
[in,out]tifNon-NULL TIFF handle.
[in]bufCaller-owned source with at least size readable bytes.
[in]sizeRequested nonnegative byte count representable by tmsize_t.
Returns
Nonzero only if the callback returns exactly size bytes.

Definition at line 1035 of file tiffiop.h.

Typedef Documentation

◆ tidata_t

Name a legacy pointer to internal image bytes.

Deprecated:
Use an explicitly typed pointer in new internal code.

Definition at line 170 of file tiffiop.h.

◆ tidataval_t

typedef unsigned char tidataval_t

Name a legacy internal image byte.

Deprecated:
Use an explicit byte type in new internal code.

Definition at line 165 of file tiffiop.h.

◆ TIFFClientInfoLink

Link a named client-data association to a TIFF handle.

TIFFSetClientInfo() allocates the node and copies its name, but retains the payload pointer without taking ownership. TIFFCleanup() frees the name and node; the client remains responsible for payload lifetime and release.

◆ TIFFIOSize_t

typedef size_t TIFFIOSize_t

Represent a native POSIX I/O byte count.

Definition at line 1398 of file tiffiop.h.

◆ TIFFOffsetAndDirNumber

Name the TIFFOffsetAndDirNumber record type.

Definition at line 350 of file tiffiop.h.