LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
Directory formatting helpers

Format custom fields, labels, and private escaped text. More...

Collaboration diagram for Directory formatting helpers:

Data Structures

struct  tagname
 Associate an anonymous on-disk tag with a friendly print label. More...
 

Macros

#define NPHOTONAMES   (sizeof(photoNames) / sizeof(photoNames[0]))
 Count the entries in photoNames, including the reserved placeholder.
 
#define NORIENTNAMES   (sizeof(orientNames) / sizeof(orientNames[0]))
 Count orientation display entries, including the zero placeholder.
 
#define NTAGS   (sizeof(tagnames) / sizeof(tagnames[0]))
 Count the anonymous-tag friendly-name overrides.
 

Functions

static void _TIFFPrintField (FILE *fd, const TIFFField *fip, uint32_t value_count, void *raw_data)
 Print a custom field using its generic numeric or string representation.
 
static int _TIFFPrettyPrintField (TIFF *tif, const TIFFField *fip, FILE *fd, uint32_t tag, uint32_t value_count, void *raw_data)
 Try specialised formatting for selected named custom tags.
 
static void _TIFFprintAsciiBounded (FILE *fd, const char *cp, size_t max_chars)
 Print at most a byte bound using the private ASCII escape convention.
 
void _TIFFprintAscii (FILE *fd, const char *cp)
 Print a terminated string using the private ASCII escape convention.
 
void _TIFFprintAsciiTag (FILE *fd, const char *name, const char *value)
 Print a labelled quoted value using the private ASCII formatter.
 

Variables

static const char *const photoNames []
 Map common photometric identifiers to display names.
 
static const char *const orientNames []
 Map orientation identifiers to display descriptions.
 
static const struct tagname tagnames []
 Supply display labels for anonymous GDAL metadata and nodata tags.
 

Detailed Description

Format custom fields, labels, and private escaped text.

Macro Definition Documentation

◆ NORIENTNAMES

#define NORIENTNAMES   (sizeof(orientNames) / sizeof(orientNames[0]))

Count orientation display entries, including the zero placeholder.

Orientation values at or above this count are printed numerically.

Definition at line 95 of file tif_print.c.

◆ NPHOTONAMES

#define NPHOTONAMES   (sizeof(photoNames) / sizeof(photoNames[0]))

Count the entries in photoNames, including the reserved placeholder.

Photometric values at or above this count are printed numerically.

Definition at line 69 of file tif_print.c.

◆ NTAGS

#define NTAGS   (sizeof(tagnames) / sizeof(tagnames[0]))

Count the anonymous-tag friendly-name overrides.

Number of entries in tagnames[] searched by the generic field printer.

Definition at line 131 of file tif_print.c.

Function Documentation

◆ _TIFFPrettyPrintField()

static int _TIFFPrettyPrintField ( TIFF *  tif,
const TIFFField *  fip,
FILE *  fd,
uint32_t  tag,
uint32_t  value_count,
void *  raw_data 
)
static

Try specialised formatting for selected named custom tags.

Anonymous fields return zero without output. Handles DotRange, WhitePoint, XMP, IPTC, Photoshop, ICCProfile, StoNits, and a special InkSet shape. Shape/type checks differ by tag; WhitePoint explicitly assumes two float elements even if a private descriptor would use double rationals. InkSet requires count two and SHORT but reads only the first element; usual count-one InkSet falls back to generic printing. XMP writes exactly value_count raw bytes with fputc(), including embedded NULs; binary summaries label the supplied element count as bytes without converting it. Does not allocate, change values, retain pointers, or use tif. Output is locale/stdio formatting, not escaped serialisation; stdio errors do not affect the handled result.

Parameters
[in]tifUnused compatibility context; no handle access, may be NULL.
[in]fipNon-NULL borrowed live field descriptor with representation matching raw_data.
[in,out]fdNon-NULL writable caller-owned stdio stream; not closed or flushed by this helper.
[in]tagTag identifier to select specialised formatting; normally matches fip.
[in]value_countReadable element count; specialised predicates determine required shape.
[in]raw_dataBorrowed matching data, including two floats for WhitePoint; must be readable on any selected output path.
Returns
One if a specialised output path was selected, zero for anonymous/unhandled/shape-mismatched tags; one does not indicate successful stream output.

Definition at line 268 of file tif_print.c.

References _TIFFField::field_type, INKSET_CMYK, tagname::tag, TIFF_DOUBLE, TIFF_RATIONAL, TIFF_SHORT, TIFFFieldIsAnonymous(), TIFFTAG_DOTRANGE, TIFFTAG_ICCPROFILE, TIFFTAG_INKSET, TIFFTAG_PHOTOSHOP, TIFFTAG_RICHTIFFIPTC, TIFFTAG_STONITS, TIFFTAG_WHITEPOINT, and TIFFTAG_XMLPACKET.

Referenced by TIFFPrintDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFprintAscii()

void _TIFFprintAscii ( FILE *  fd,
const char *  cp 
)
extern

Print a terminated string using the private ASCII escape convention.

Writes at the stream's current position without flushing, closing, allocating, or taking ownership. Printable bytes depend on the current C locale; quotes and backslashes are written unchanged. Nonprintable tab, backspace, carriage return, newline, and vertical tab use named backslash escapes; other bytes use three octal digits. The implementation passes plain char to isprint(), so portable input is seven-bit ASCII; high-bit bytes on signed-char hosts are outside the classifier's valid domain except EOF. Does not check/report stdio failures and returns no status. Computes strlen() before formatting, so input must terminate in readable storage. Adds no quotes or newline.

Parameters
[in,out]fdNon-NULL writable caller-owned stdio stream; not closed or flushed by this helper.
[in]cpNon-NULL borrowed terminated string satisfying the classifier domain; no alias with stream storage.

Definition at line 856 of file tif_print.c.

References _TIFFprintAsciiBounded().

Referenced by _TIFFprintAsciiTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFprintAsciiBounded()

static void _TIFFprintAsciiBounded ( FILE *  fd,
const char *  cp,
size_t  max_chars 
)
static

Print at most a byte bound using the private ASCII escape convention.

Writes at the stream's current position without flushing, closing, allocating, or taking ownership. Printable bytes depend on the current C locale; quotes and backslashes are written unchanged. Nonprintable tab, backspace, carriage return, newline, and vertical tab use named backslash escapes; other bytes use three octal digits. The implementation passes plain char to isprint(), so portable input is seven-bit ASCII; high-bit bytes on signed-char hosts are outside the classifier's valid domain except EOF. Does not check/report stdio failures and returns no status. Stops at the first NUL or max_chars, whichever comes first, without a strlen() pre-scan. The bound limits source bytes, not output bytes; one source byte can expand to four. No quotes/newline are added.

Parameters
[in,out]fdNon-NULL writable caller-owned stdio stream; not closed or flushed by this helper.
[in]cpBorrowed readable source through the first NUL or max_chars bytes; may be NULL only when max_chars is zero. Seven-bit ASCII is portable.
[in]max_charsMaximum number of source bytes examined; zero emits nothing.

Definition at line 885 of file tif_print.c.

Referenced by _TIFFprintAscii(), and TIFFPrintDirectory().

Here is the caller graph for this function:

◆ _TIFFprintAsciiTag()

void _TIFFprintAsciiTag ( FILE *  fd,
const char *  name,
const char *  value 
)
extern

Print a labelled quoted value using the private ASCII formatter.

Writes at the stream's current position without flushing, closing, allocating, or taking ownership. Printable bytes depend on the current C locale; quotes and backslashes are written unchanged. Nonprintable tab, backspace, carriage return, newline, and vertical tab use named backslash escapes; other bytes use three octal digits. The implementation passes plain char to isprint(), so portable input is seven-bit ASCII; high-bit bytes on signed-char hosts are outside the classifier's valid domain except EOF. Does not check/report stdio failures and returns no status. Writes two leading spaces, the raw label, colon/space, quote-delimited escaped value, and a final newline. The label is not escaped; unchanged quotes/backslashes in the value prevent reliable round-trip parsing.

Parameters
[in,out]fdNon-NULL writable caller-owned stdio stream; not closed or flushed by this helper.
[in]nameNon-NULL borrowed null-terminated label, printed raw.
[in]valueNon-NULL borrowed terminated value satisfying _TIFFprintAscii() preconditions.

Definition at line 906 of file tif_print.c.

References _TIFFprintAscii(), and tagname::name.

Here is the call graph for this function:

◆ _TIFFPrintField()

static void _TIFFPrintField ( FILE *  fd,
const TIFFField *  fip,
uint32_t  value_count,
void *  raw_data 
)
static

Print a custom field using its generic numeric or string representation.

Prints a label, comma-separated values, and a newline; zero count prints only the label/newline. Anonymous GDAL tags use the local friendly-name overrides. Integers/IFDs follow field_type widths (IFDs hexadecimal); rationals use float or double storage according to TIFFFieldSetGetSize(). ASCII with nonzero count uses unbounded s, ignoring the count as a byte limit and adding no escapes. Requires matching readable storage and a terminating ASCII string. Other unsupported types print a placeholder. Does not allocate, mutate input, retain values, or invoke callbacks. Stream failures are ignored, with no status/diagnostic or flush. Private schema representations that disagree with the selected file-type width are not normalised here.

Parameters
[in,out]fdNon-NULL writable caller-owned stdio stream; not closed or flushed by this helper.
[in]fipNon-NULL borrowed live field descriptor with representation matching raw_data.
[in]value_countNumber of readable internal elements; zero permits raw_data NULL.
[in]raw_dataBorrowed matching element array; ASCII must terminate if count is nonzero. Numeric representation must match the selected formatting path.

Definition at line 160 of file tif_print.c.

References _TIFFField::field_name, _TIFFField::field_tag, _TIFFField::field_type, tagname::name, NTAGS, tagname::tag, tagnames, TIFF_ASCII, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_UNDEFINED, TIFFFieldIsAnonymous(), and TIFFFieldSetGetSize().

Referenced by TIFFPrintDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ orientNames

const char* const orientNames[]
static
Initial value:
= {
"0 (0x0)",
"row 0 top, col 0 lhs",
"row 0 top, col 0 rhs",
"row 0 bottom, col 0 rhs",
"row 0 bottom, col 0 lhs",
"row 0 lhs, col 0 top",
"row 0 rhs, col 0 top",
"row 0 rhs, col 0 bottom",
"row 0 lhs, col 0 bottom",
}

Map orientation identifiers to display descriptions.

Static borrowed strings including a numeric zero placeholder; valid TIFF orientation values occupy indices one through eight.

Definition at line 78 of file tif_print.c.

Referenced by TIFFPrintDirectory().

◆ photoNames

const char* const photoNames[]
static
Initial value:
= {
"min-is-white",
"min-is-black",
"RGB color",
"palette color (RGB from colormap)",
"transparency mask",
"separated",
"YCbCr",
"7 (0x7)",
"CIE L*a*b*",
"ICC L*a*b*",
"ITU L*a*b*"
}

Map common photometric identifiers to display names.

Static borrowed strings indexed by photometric codes zero through ten, including a numeric reserved-code placeholder. Higher LogL/LogLuv values are handled explicitly by TIFFPrintDirectory().

Definition at line 50 of file tif_print.c.

Referenced by TIFFPrintDirectory().

◆ tagnames

const struct tagname tagnames[]
static
Initial value:
= {
{TIFFTAG_GDAL_METADATA, "GDAL Metadata"},
{TIFFTAG_GDAL_NODATA, "GDAL NoDataValue"},
}
#define TIFFTAG_GDAL_METADATA
TIFF tag: Used by the GDAL library.
Definition tiff.h:945
#define TIFFTAG_GDAL_NODATA
TIFF tag: Used by the GDAL library.
Definition tiff.h:947

Supply display labels for anonymous GDAL metadata and nodata tags.

Only generic printing consults these static overrides, and only for anonymous descriptors; no registration or ownership change occurs.

Definition at line 120 of file tif_print.c.

Referenced by _TIFFPrintField().