Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/doc/functions/TIFFError.rst

raw
1 TIFFError
2 =========
3
4 Synopsis
5 --------
6
7 .. highlight:: c
8
9 ::
10
11 #include <tiffio.h>
12 #include <stdarg.h>
13
14 .. c:function:: void TIFFError(const char * module, const char * fmt, ...)
15
16 .. c:function:: void TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
17
18 .. c:function:: void TIFFErrorExtR(TIFF *tif, const char* module, const char* fmt, ...)
19
20 .. c:type:: void (*TIFFErrorHandler)(const char * module, const char* fmt, va_list ap)
21
22 .. c:type:: void (*TIFFErrorHandlerExt)(thandle_t fd, const char * module, const char* fmt, va_list ap)
23
24 .. c:type:: int (*TIFFErrorHandlerExtR)(TIFF* tif, void* user_data, const char* module, const char* fmt, va_list ap)
25
26 .. c:function:: TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler)
27
28 .. c:function:: TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
29
30 Description
31 -----------
32
33 :c:func:`TIFFError` invokes the library-wide error handler function
34 to (normally) write an error message to ``stderr``.
35 The *fmt* parameter is a :c:func:`printf` format string, and any number
36 arguments can be supplied. The *module* parameter is interpreted as a
37 string that, if non-zero, should be printed before the message; it
38 typically is used to identify the software module in which an error is
39 detected.
40
41 Applications that desire to capture control in the event of an error
42 should use :c:func:`TIFFSetErrorHandler` to override the default
43 error handler. A :c:macro:`NULL` (0) error handler function may be
44 installed to suppress error messages.
45
46 Two more application-specific error handler callbacks are available,
47 each with different call parameters and passing parameters to the handler.
48 Each handler is also linked with an error message function, i.e.
49 :c:func:`TIFFErrorExt` and :c:func:`TIFFErrorExtR` if the application
50 intends to call the handler with those extended parameters.
51
52 :c:func:`TIFFErrorExt` provides a file handle as parameter.
53 Within ``libtiff`` :c:func:`TIFFErrorExt` is called passing ``tif->tif_clientdata``
54 as *fd*, which represents the TIFF file handle (file descriptor).
55 The application-specific and library-wide handler for :c:func:`TIFFErrorExt`
56 is setup with :c:func:`TIFFSetErrorHandlerExt`.
57
58 :c:func:`TIFFErrorExtR` (introduced with libtiff 4.5) is called with its
59 TIFF handle and thus provides access to a per-TIFF handle (re-entrant)
60 error handler. That means for different TIFF handles, different error
61 handlers can be setup. This application-specific handler
62 can be setup when a TIFF file is opened with one of the following functions:
63 :c:func:`TIFFOpenExt`, :c:func:`TIFFOpenWExt`, :c:func:`TIFFFdOpenExt`
64 or :c:func:`TIFFClientOpenExt`.
65 Furthermore, a **custom defined data structure** *user_data* for the
66 error handler can be given along.
67
68 Please refer to :doc:`/functions/TIFFOpenOptions` for how to setup the
69 application-specific handler introduced with libtiff 4.5.
70
71 Note
72 ----
73
74 Both functions :c:func:`TIFFError` and :c:func:`TIFFErrorExt`
75 each attempt to call both handler functions if they are defined.
76 First :c:func:`TIFFErrorHandler` is called and then :c:func:`TIFFErrorHandlerExt`.
77 However, :c:func:`TIFFError` passes a "0" as a file handle to
78 :c:func:`TIFFErrorHandlerExt`.
79
80 :c:func:`TIFFErrorExtR` tries first to call the per-TIFF handle defined
81 error handler. If :c:func:`TIFFErrorHandlerExtR` is not defined or
82 returns 0, :c:func:`TIFFErrorHandler` and then :c:func:`TIFFErrorHandlerExt`
83 are called. From libtiff 4.5 onwards :c:func:`TIFFErrorExtR` is used
84 within the ``libtiff`` library where the TIFF handle is available.
85 Otherwise, :c:func:`TIFFErrorExt` is used!
86
87 Return values
88 -------------
89
90 :c:func:`TIFFSetErrorHandler` and :c:func:`TIFFSetErrorHandlerExt`
91 returns a reference to the previous error handler function.
92
93 :c:func:`TIFFErrorHandlerExtR` returns an integer as "stop" to control the call
94 of further error handler functions within :c:func:`TIFFErrorExtR`:
95
96 - 0: both functions :c:func:`TIFFErrorHandler` and :c:func:`TIFFErrorHandlerExt` are called.
97 - non-zero: no further error message function is called.
98
99 See also
100 --------
101
102 :doc:`TIFFWarning` (3tiff),
103 :doc:`TIFFOpen` (3tiff),
104 :doc:`libtiff` (3tiff),
105 printf (3)