Coverage Report

Created: 2024-06-18 06:05

/src/libtiff/libtiff/tif_warning.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 1988-1997 Sam Leffler
3
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4
 *
5
 * Permission to use, copy, modify, distribute, and sell this software and
6
 * its documentation for any purpose is hereby granted without fee, provided
7
 * that (i) the above copyright notices and this permission notice appear in
8
 * all copies of the software and related documentation, and (ii) the names of
9
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10
 * publicity relating to the software without the specific, prior written
11
 * permission of Sam Leffler and Silicon Graphics.
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22
 * OF THIS SOFTWARE.
23
 */
24
25
/*
26
 * TIFF Library.
27
 */
28
#include "tiffiop.h"
29
30
TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL;
31
32
TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler)
33
0
{
34
0
    TIFFErrorHandler prev = _TIFFwarningHandler;
35
0
    _TIFFwarningHandler = handler;
36
0
    return (prev);
37
0
}
38
39
TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
40
0
{
41
0
    TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
42
0
    _TIFFwarningHandlerExt = handler;
43
0
    return (prev);
44
0
}
45
46
void TIFFWarning(const char *module, const char *fmt, ...)
47
0
{
48
0
    va_list ap;
49
0
    if (_TIFFwarningHandler)
50
0
    {
51
0
        va_start(ap, fmt);
52
0
        (*_TIFFwarningHandler)(module, fmt, ap);
53
0
        va_end(ap);
54
0
    }
55
0
    if (_TIFFwarningHandlerExt)
56
0
    {
57
0
        va_start(ap, fmt);
58
0
        (*_TIFFwarningHandlerExt)(0, module, fmt, ap);
59
0
        va_end(ap);
60
0
    }
61
0
}
62
63
void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt, ...)
64
0
{
65
0
    va_list ap;
66
0
    if (_TIFFwarningHandler)
67
0
    {
68
0
        va_start(ap, fmt);
69
0
        (*_TIFFwarningHandler)(module, fmt, ap);
70
0
        va_end(ap);
71
0
    }
72
0
    if (_TIFFwarningHandlerExt)
73
0
    {
74
0
        va_start(ap, fmt);
75
0
        (*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
76
0
        va_end(ap);
77
0
    }
78
0
}
79
80
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt, ...)
81
0
{
82
0
    va_list ap;
83
0
    if (tif && tif->tif_warnhandler)
84
0
    {
85
0
        va_start(ap, fmt);
86
0
        int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data,
87
0
                                           module, fmt, ap);
88
0
        va_end(ap);
89
0
        if (stop)
90
0
            return;
91
0
    }
92
0
    if (_TIFFwarningHandler)
93
0
    {
94
0
        va_start(ap, fmt);
95
0
        (*_TIFFwarningHandler)(module, fmt, ap);
96
0
        va_end(ap);
97
0
    }
98
0
    if (_TIFFwarningHandlerExt)
99
0
    {
100
0
        va_start(ap, fmt);
101
0
        (*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt,
102
0
                                  ap);
103
0
        va_end(ap);
104
0
    }
105
0
}