summaryrefslogtreecommitdiff
path: root/doc/functions/TIFFWarning.rst
blob: 281341f02b40d11a8b9353517c4f51d2e8e2f3d7 (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
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: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:function:: TIFFWarningHandler TIFFSetWarningHandler(TIFFWarningHandler handler)

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

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

.. c:function:: void TIFFSetWarningHandlerExtR(TIFF* tif, TIFFWarningHandlerExtR handler, void* warnhandler_user_data)


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.

The function :c:func:`TIFFWarningExt` provides a file handle.
Within ``libtiff`` :c:func:`TIFFWarningExt` is called passing ``tif->tif_clientdata``
as *fd*, which represents the TIFF file handle (file descriptor).

.. TODO: Check description, how to setup a TIFFWarningExt handler and
   its file handle.

With :c:func:`TIFFSetWarningHandlerExt` an extra warning handler can be
setup up.

:c:func:`TIFFSetWarningHandlerExtR` (added in libtiff 4.5) installs a warning
handler for a given TIFF handle. The R suffix means re-entrant, in that it avoids
the global effects of :c:func:`TIFFSetWarningHandler` or :c:func:`TIFFSetWarningHandlerExt`.
The installed handler replaces any previously set handler with that function.
The handler should nominally return a non-0 value. If it returns 0, then the
global handler set with :c:func:`TIFFSetWarningHandler` or :c:func:`TIFFSetWarningHandlerExt`
will also be called.
Note that this per-TIFF handler may also be installed with :c:func:`TIFFOpenExt`
or :c:func:`TIFFClientOpenExt`

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`. 

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

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

See also
--------

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