LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Functions

Track borrowed streams and implement their client I/O callbacks. More...

Collaboration diagram for C++ stream adapters:

Data Structures

struct  tiffis_data
 Track a borrowed input stream and its initial position. More...
 
struct  tiffos_data
 Track a borrowed output stream and its initial position. More...
 

Functions

static tmsize_t _tiffosReadProc (thandle_t fd, void *buf, tmsize_t size)
 Refuse reads on an output-stream adapter.
 
static tmsize_t _tiffisReadProc (thandle_t fd, void *buf, tmsize_t size)
 Read bytes from the borrowed input stream.
 
static tmsize_t _tiffosWriteProc (thandle_t fd, void *buf, tmsize_t size)
 Write bytes to the borrowed output stream.
 
static tmsize_t _tiffisWriteProc (thandle_t fd, void *buf, tmsize_t size)
 Refuse writes on an input-stream adapter.
 
static uint64_t _tiffosSeekProc (thandle_t fd, uint64_t off, int whence)
 Seek the borrowed output stream, with a zero-fill extension fallback.
 
static uint64_t _tiffisSeekProc (thandle_t fd, uint64_t off, int whence)
 Seek the borrowed input stream relative to its recorded TIFF origin.
 
static uint64_t _tiffosSizeProc (thandle_t fd)
 Query the absolute end position of the borrowed stream.
 
static uint64_t _tiffisSizeProc (thandle_t fd)
 Query the absolute end position of the borrowed stream.
 
static int _tiffosCloseProc (thandle_t fd)
 Delete a stream adapter without closing the borrowed stream.
 
static int _tiffisCloseProc (thandle_t fd)
 Delete a stream adapter without closing the borrowed stream.
 
static int _tiffDummyMapProcCxx (thandle_t fd, void **base, toff_t *size)
 Decline mapping for the C++ stream adapter.
 
static void _tiffDummyUnmapProcCxx (thandle_t fd, void *base, toff_t size)
 Provide a no-op unmapper for the C++ stream adapter.
 
static TIFF * _tiffStreamOpen (const char *name, const char *mode, void *fd)
 Allocate a stream context and attach it through TIFFClientOpen().
 

Detailed Description

Track borrowed streams and implement their client I/O callbacks.

Function Documentation

◆ _tiffDummyMapProcCxx()

static int _tiffDummyMapProcCxx ( thandle_t  fd,
void **  base,
toff_t *  size 
)
static

Decline mapping for the C++ stream adapter.

Performs no I/O, allocation, or diagnostic; outputs must not be used as a view.

Parameters
[in]fdUnused client context.
[in]baseUnused view output; not written.
[in]sizeUnused length output; not written.
Returns
Zero, indicating mapping is unavailable.

Definition at line 600 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffDummyUnmapProcCxx()

static void _tiffDummyUnmapProcCxx ( thandle_t  fd,
void *  base,
toff_t  size 
)
static

Provide a no-op unmapper for the C++ stream adapter.

Does not release storage, perform I/O, or emit diagnostics. Returns no status; the stream mapper never supplies a view.

Parameters
[in]fdUnused client context.
[in]baseUnused view address.
[in]sizeUnused view byte length.

Definition at line 607 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffisCloseProc()

static int _tiffisCloseProc ( thandle_t  fd)
static

Delete a stream adapter without closing the borrowed stream.

Deletes only the adapter allocated by _tiffStreamOpen(). Does not close, flush, or delete the caller-owned stream and does not emit a diagnostic.

Parameters
[in]fdLive tiffis_data allocation; invalid after return.
Returns
Zero.

Definition at line 593 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffisReadProc()

static tmsize_t _tiffisReadProc ( thandle_t  fd,
void *  buf,
tmsize_t  size 
)
static

Read bytes from the borrowed input stream.

Reads at the current get position, which advances by the transferred bytes. Stream fail/eof state may change, and a failed/short read may modify part of buf. Does not emit a library diagnostic or take buffer ownership. Stream exceptions propagate without cleanup or status conversion.

Parameters
[in,out]fdLive tiffis_data context.
[out]bufDestination with at least size writable bytes.
[in]sizeRequested nonnegative byte count.
Returns
gcount() after the read, or -1 if conversion to streamsize fails.

Definition at line 326 of file tif_stream.cxx.

References tiffis_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffisSeekProc()

static uint64_t _tiffisSeekProc ( thandle_t  fd,
uint64_t  off,
int  whence 
)
static

Seek the borrowed input stream relative to its recorded TIFF origin.

SEEK_SET adds start_pos; other origins use stream-relative seeking. Does not clear an existing fail state, restore position on failure, allocate, or emit a library diagnostic. Input stream state can change and exceptions propagate.

Parameters
[in,out]fdLive tiffis_data context.
[in]offUnsigned byte offset interpreted by whence.
[in]whenceSEEK_SET, SEEK_CUR, or SEEK_END; any other value performs no seek and returns the current relative position.
Returns
The resulting tellg() minus start_pos, or UINT64_MAX if the start position could not be recorded, an offset conversion fails, tellg() fails, or the position precedes start_pos.

Definition at line 459 of file tif_stream.cxx.

References tiffis_data::start_pos, and tiffis_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffisSizeProc()

static uint64_t _tiffisSizeProc ( thandle_t  fd)
static

Query the absolute end position of the borrowed stream.

Saves the get position, seeks to the end, then restores the saved position. If the initial tellg() fails, returns zero without seeking. If the end seek or end query fails, temporarily clears failbit to restore the position, then reinstates the failed stream state; restoration itself is not guaranteed. The size does not subtract start_pos. Does not release or explicitly flush the stream, and emits no library diagnostic. Stream exceptions propagate.

Parameters
[in,out]fdLive tiffis_data context.
Returns
The absolute end position as uint64_t, or zero if the initial/end position query or end seek fails.

Definition at line 551 of file tif_stream.cxx.

References tiffis_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffisWriteProc()

static tmsize_t _tiffisWriteProc ( thandle_t  fd,
void *  buf,
tmsize_t  size 
)
static

Refuse writes on an input-stream adapter.

Performs no I/O, allocation, release, or diagnostic; an input adapter cannot write.

Parameters
[in]fdUnused client context.
[in]bufUnused caller buffer; not read.
[in]sizeUnused requested byte count.
Returns
Zero for every request.

Definition at line 356 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffosCloseProc()

static int _tiffosCloseProc ( thandle_t  fd)
static

Delete a stream adapter without closing the borrowed stream.

Deletes only the adapter allocated by _tiffStreamOpen(). Does not close, flush, or delete the caller-owned stream and does not emit a diagnostic.

Parameters
[in]fdLive tiffos_data allocation; invalid after return.
Returns
Zero.

Definition at line 586 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffosReadProc()

static tmsize_t _tiffosReadProc ( thandle_t  fd,
void *  buf,
tmsize_t  size 
)
static

Refuse reads on an output-stream adapter.

Performs no I/O, allocation, release, or diagnostic; an output adapter cannot read.

Parameters
[in]fdUnused client context.
[in]bufUnused caller buffer; not written.
[in]sizeUnused requested byte count.
Returns
Zero for every request.

Definition at line 324 of file tif_stream.cxx.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffosSeekProc()

static uint64_t _tiffosSeekProc ( thandle_t  fd,
uint64_t  off,
int  whence 
)
static

Seek the borrowed output stream, with a zero-fill extension fallback.

SEEK_SET adds start_pos. If the seek fails, clears failbit and, when the target lies beyond start_pos, extends the stream with null bytes up to the target and seeks again. This can change bytes, position, and flags even on failure. An unrecognised whence performs no seek. Final tellp() is not normalised to the TIFF origin; nonzero-origin output is not reliably supported. No library diagnostic or allocation ownership transfer occurs; exceptions propagate.

Parameters
[in,out]fdLive tiffos_data context.
[in]offUnsigned byte offset interpreted by whence.
[in]whenceSEEK_SET, SEEK_CUR, or SEEK_END; any other value leaves the position unchanged.
Returns
The absolute underlying tellp() cast to uint64_t, or UINT64_MAX for an already-failed stream, a rejected offset conversion, or a stream that is still failed after the fallback.

Definition at line 358 of file tif_stream.cxx.

References tiffos_data::start_pos, and tiffos_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffosSizeProc()

static uint64_t _tiffosSizeProc ( thandle_t  fd)
static

Query the absolute end position of the borrowed stream.

Saves the put position, seeks to the end, then restores the saved position. If the initial tellp() fails, returns zero without seeking. If the end seek or end query fails, temporarily clears failbit to restore the position, then reinstates the failed stream state; restoration itself is not guaranteed. The size does not subtract start_pos. Does not release or explicitly flush the stream, and emits no library diagnostic. Stream exceptions propagate.

Parameters
[in,out]fdLive tiffos_data context.
Returns
The absolute end position as uint64_t, or zero if the initial/end position query or end seek fails.

Definition at line 515 of file tif_stream.cxx.

References tiffos_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffosWriteProc()

static tmsize_t _tiffosWriteProc ( thandle_t  fd,
void *  buf,
tmsize_t  size 
)
static

Write bytes to the borrowed output stream.

Writes at the current put position without explicitly flushing the stream. Failure changes stream state and may follow partial output; failed tellp() values are not independently checked here, so the difference is not a reliable general failure sentinel. Buffer ownership is unchanged. Stream exceptions propagate.

Parameters
[in,out]fdLive tiffos_data context.
[in]bufSource with at least size readable bytes.
[in]sizeRequested nonnegative byte count.
Returns
The post-write tellp() minus its pre-write value, cast to tmsize_t; -1 if the request cannot be represented by streamsize.

Definition at line 340 of file tif_stream.cxx.

References tiffos_data::stream.

Referenced by _tiffStreamOpen().

Here is the caller graph for this function:

◆ _tiffStreamOpen()

static TIFF * _tiffStreamOpen ( const char *  name,
const char *  mode,
void *  fd 
)
static

Allocate a stream context and attach it through TIFFClientOpen().

Allocates the appropriate tiffos_data/tiffis_data object, records tellp()/tellg(), and installs its callbacks. Successful handles release the adapter through the client close callback. A normal NULL return deletes the adapter; the borrowed stream remains alive but may have changed bytes, position, or flags. No exception cleanup guard protects an adapter already allocated before a throwing stream/library callback.

Parameters
[in]nameNon-NULL copied diagnostic name.
[in]modeInternal mode string; presence of w selects output, otherwise input.
[in,out]fdBorrowed ostream or istream pointer matching mode.
Returns
An owned TIFF handle, or NULL on ordinary client-open failure. C++ exceptions propagate.

Definition at line 616 of file tif_stream.cxx.

References _tiffDummyMapProcCxx(), _tiffDummyUnmapProcCxx(), _tiffisCloseProc(), _tiffisReadProc(), _tiffisSeekProc(), _tiffisSizeProc(), _tiffisWriteProc(), _tiffosCloseProc(), _tiffosReadProc(), _tiffosSeekProc(), _tiffosSizeProc(), _tiffosWriteProc(), tiffis_data::start_pos, tiffos_data::start_pos, tiffis_data::stream, tiffos_data::stream, and TIFFClientOpen().

Referenced by TIFFStreamOpen(), and TIFFStreamOpen().

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