summaryrefslogtreecommitdiff
path: root/doc/functions/TIFFWarning.rst
blob: 48467d79312c330883e388fd632f4a428a006b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
TIFFWarning
===========

Synopsis
--------

.. highlight:: c

::

    #include <tiffio.h>
    #include <stdarg.h>

.. c:function:: void TIFFWarning(const char* module, const char* fmt, ...)

.. c:function:: void TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)

.. c:function:: void TIFFWarningExtR(TIFF *tif, const char* module, const char* fmt, ...)

.. c:type:: void (*TIFFWarningHandler)(const char * module, const char* fmt, va_list ap)

.. c:type:: void (*TIFFWarningHandlerExt)(thandle_t fd, const char* module, const char* fmt, va_list ap)

.. c:type:: int (*TIFFWarningHandlerExtR)(TIFF* tif, void* user_data, const char* module, const char* fmt, va_list ap)

.. c:function:: TIFFWarningHandler TIFFSetWarningHandler(TIFFWarningHandler handler)

.. c:function:: TIFFWarningHandlerExt TIFFSetWarningHandlerExt(TIFFWarningHandlerExt handler)

Description
-----------

:c:func:`TIFFWarning` invokes the library-wide warning handler function
to (normally) write a warning message to the ``stderr``.
The *fmt* parameter is a :c:func:`printf` format string, and any number
arguments can be supplied. The *module* parameter is interpreted as a
string that, if non-zero, should be printed before the message; it
typically is used to identify the software module in which a warning is
detected.

Applications that desire to capture control in the event of a warning
should use :c:func:`TIFFSetWarningHandler` to override the default
warning handler. A :c:macro:`NULL` (0) warning handler function may be
installed to suppress warning messages.

Two more application-specific warning handler callbacks are available,
each with different call parameters and passing parameters to the handler.
Each handler is also linked with a warning message function, i.e.
:c:func:`TIFFWarningExt` and :c:func:`TIFFWarningExtR` if the application
intends to call the handler with those extended parameters.

:c:func:`TIFFWarningExt` provides a file handle as parameter.
Within ``libtiff`` :c:func:`TIFFWarningExt` is called passing ``tif->tif_clientdata``
as *fd*, which represents the TIFF file handle (file descriptor).
The application-specific and library-wide handler for :c:func:`TIFFWarningExt`
is setup with :c:func:`TIFFSetWarningHandlerExt`.

:c:func:`TIFFWarningExtR` (introduced with libtiff 4.5) is called with its
TIFF handle and thus provides access to a per-TIFF handle (re-entrant)
warning handler. That means for different TIFF handles, different warning
handlers can be setup. This application-specific handler
can be setup when a TIFF file is opened with one of the following functions:
:c:func:`TIFFOpenExt`, :c:func:`TIFFOpenWExt`, :c:func:`TIFFFdOpenExt`
or :c:func:`TIFFClientOpenExt`.
Furthermore, a **custom defined data structure** *user_data* for the
warning handler can be given along.

Note
----

Both functions :c:func:`TIFFWarning` and :c:func:`TIFFWarningExt`
each attempt to call both handler functions if they are defined.
First :c:func:`TIFFWarningHandler` is called and then :c:func:`TIFFWarningHandlerExt`.
However, :c:func:`TIFFWarning` passes a "0" as a file handle to
:c:func:`TIFFWarningHandlerExt`.

:c:func:`TIFFWarningExtR` tries first to call the per-TIFF handle defined
warning handler. If :c:func:`TIFFWarningHandlerExtR` is not defined or
returns 0, :c:func:`TIFFWarningHandler` and then :c:func:`TIFFWarningHandlerExt`
are called. From libtiff 4.5 onwards :c:func:`TIFFWarningExtR` is used
within the ``libtiff`` library.

Return values
-------------

:c:func:`TIFFSetWarningHandler` and :c:func:`TIFFSetWarningHandlerExt`
returns a reference to the previous warning handler function.

:c:func:`TIFFWarningHandlerExtR` returns an integer as "stop" to control the call
of furhter warning handler functions within :c:func:`TIFFWarningExtR`:

  - 0: both functions :c:func:`TIFFWarningHandler` and :c:func:`TIFFWarningHandlerExt` are called.
  - non-zero: no further warning message function is called.

See also
--------

:doc:`TIFFError` (3tiff),
:doc:`TIFFOpen` (3tiff),
:doc:`libtiff` (3tiff),
printf (3)