Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_tiff.c File Reference

Reading the tags of a TIFF structured buffer. More...

#include "nilorea/n_tiff.h"
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include <string.h>
Include dependency graph for n_tiff.c:

Go to the source code of this file.

Macros

#define N_TIFF_MAX_ENTRIES   4096
 Most entries a directory is read for: a real TIFF directory holds tens, a DCP a few dozen; a count past this is a corrupt or hostile file.

Functions

static size_t _n_tiff_type_size (uint16_t type)
 Bytes one value of a field type takes.
static uint16_t _n_tiff_u16 (const N_TIFF *tiff, const unsigned char *p)
 Read a 16 bit value in the buffer's byte order.
static uint32_t _n_tiff_u32 (const N_TIFF *tiff, const unsigned char *p)
 Read a 32 bit value in the buffer's byte order.
static uint64_t _n_tiff_u64 (const N_TIFF *tiff, const unsigned char *p)
 Read a 64 bit value in the buffer's byte order.
size_t n_tiff_count (const N_TIFF *tiff, uint16_t tag)
 How many values a tag has.
const N_TIFF_ENTRY * n_tiff_find (const N_TIFF *tiff, uint16_t tag)
 Find an entry by tag.
void n_tiff_free (N_TIFF **tiff)
 Release a parse, and set the pointer to NULL.
int n_tiff_get_ascii (const N_TIFF *tiff, uint16_t tag, char *out, size_t out_len)
 Read an ASCII tag.
size_t n_tiff_get_doubles (const N_TIFF *tiff, uint16_t tag, double *out, size_t max)
 Read a numeric tag as doubles.
N_TIFF * n_tiff_parse (const unsigned char *data, size_t len)
 Parse the first directory of a TIFF structured buffer.

Detailed Description

Reading the tags of a TIFF structured buffer.

Author
Castagnier Mickael
Version
1.0
Date
28/09/2026

Definition in file n_tiff.c.

Macro Definition Documentation

◆ N_TIFF_MAX_ENTRIES

#define N_TIFF_MAX_ENTRIES   4096

Most entries a directory is read for: a real TIFF directory holds tens, a DCP a few dozen; a count past this is a corrupt or hostile file.

Definition at line 36 of file n_tiff.c.

Referenced by n_tiff_parse().

Function Documentation

◆ _n_tiff_type_size()

size_t _n_tiff_type_size ( uint16_t type)
static

Bytes one value of a field type takes.

Parameters
typeTIFF field type
Returns
its size, 0 for a type this reader does not know

Definition at line 41 of file n_tiff.c.

References type().

Referenced by n_tiff_get_doubles(), and n_tiff_parse().

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

◆ _n_tiff_u16()

uint16_t _n_tiff_u16 ( const N_TIFF * tiff,
const unsigned char * p )
static

Read a 16 bit value in the buffer's byte order.

Parameters
tiffthe parse, for the byte order
pwhere, already checked to be inside the buffer
Returns
the value

Definition at line 68 of file n_tiff.c.

References N_TIFF::big_endian.

Referenced by n_tiff_get_doubles(), and n_tiff_parse().

Here is the caller graph for this function:

◆ _n_tiff_u32()

uint32_t _n_tiff_u32 ( const N_TIFF * tiff,
const unsigned char * p )
static

Read a 32 bit value in the buffer's byte order.

Parameters
tiffthe parse, for the byte order
pwhere, already checked to be inside the buffer
Returns
the value

Definition at line 78 of file n_tiff.c.

References N_TIFF::big_endian.

Referenced by _n_tiff_u64(), n_tiff_get_doubles(), and n_tiff_parse().

Here is the caller graph for this function:

◆ _n_tiff_u64()

uint64_t _n_tiff_u64 ( const N_TIFF * tiff,
const unsigned char * p )
static

Read a 64 bit value in the buffer's byte order.

Parameters
tiffthe parse, for the byte order
pwhere, already checked to be inside the buffer
Returns
the value

Definition at line 88 of file n_tiff.c.

References _n_tiff_u32(), and N_TIFF::big_endian.

Referenced by n_tiff_get_doubles().

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