LCOV - code coverage report
Current view: top level - frmts/gtiff/libtiff - tif_error.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 14 58 24.1 %
Date: 2024-11-21 22:18:42 Functions: 2 6 33.3 %

          Line data    Source code
       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 _TIFFerrorHandlerExt = NULL;
      31             : 
      32           0 : TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler)
      33             : {
      34           0 :     TIFFErrorHandler prev = _TIFFerrorHandler;
      35           0 :     _TIFFerrorHandler = handler;
      36           0 :     return (prev);
      37             : }
      38             : 
      39           0 : TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
      40             : {
      41           0 :     TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt;
      42           0 :     _TIFFerrorHandlerExt = handler;
      43           0 :     return (prev);
      44             : }
      45             : 
      46           0 : void TIFFError(const char *module, const char *fmt, ...)
      47             : {
      48             :     va_list ap;
      49           0 :     if (_TIFFerrorHandler)
      50             :     {
      51           0 :         va_start(ap, fmt);
      52           0 :         (*_TIFFerrorHandler)(module, fmt, ap);
      53           0 :         va_end(ap);
      54             :     }
      55           0 :     if (_TIFFerrorHandlerExt)
      56             :     {
      57           0 :         va_start(ap, fmt);
      58           0 :         (*_TIFFerrorHandlerExt)(0, module, fmt, ap);
      59           0 :         va_end(ap);
      60             :     }
      61           0 : }
      62             : 
      63          73 : void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt, ...)
      64             : {
      65             :     va_list ap;
      66          73 :     if (_TIFFerrorHandler)
      67             :     {
      68          73 :         va_start(ap, fmt);
      69          73 :         (*_TIFFerrorHandler)(module, fmt, ap);
      70          73 :         va_end(ap);
      71             :     }
      72          73 :     if (_TIFFerrorHandlerExt)
      73             :     {
      74           0 :         va_start(ap, fmt);
      75           0 :         (*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
      76           0 :         va_end(ap);
      77             :     }
      78          73 : }
      79             : 
      80           0 : void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata,
      81             :                      const char *module, const char *fmt, ...)
      82             : {
      83             :     va_list ap;
      84           0 :     if (opts && opts->errorhandler)
      85             :     {
      86           0 :         va_start(ap, fmt);
      87           0 :         int stop = opts->errorhandler(NULL, opts->errorhandler_user_data,
      88             :                                       module, fmt, ap);
      89           0 :         va_end(ap);
      90           0 :         if (stop)
      91           0 :             return;
      92             :     }
      93           0 :     if (_TIFFerrorHandler)
      94             :     {
      95           0 :         va_start(ap, fmt);
      96           0 :         (*_TIFFerrorHandler)(module, fmt, ap);
      97           0 :         va_end(ap);
      98             :     }
      99           0 :     if (_TIFFerrorHandlerExt)
     100             :     {
     101           0 :         va_start(ap, fmt);
     102           0 :         (*_TIFFerrorHandlerExt)(clientdata, module, fmt, ap);
     103           0 :         va_end(ap);
     104             :     }
     105             : }
     106             : 
     107         234 : void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt, ...)
     108             : {
     109             :     va_list ap;
     110         234 :     if (tif && tif->tif_errorhandler)
     111             :     {
     112         234 :         va_start(ap, fmt);
     113         234 :         int stop = (*tif->tif_errorhandler)(
     114             :             tif, tif->tif_errorhandler_user_data, module, fmt, ap);
     115         234 :         va_end(ap);
     116         234 :         if (stop)
     117         234 :             return;
     118             :     }
     119           0 :     if (_TIFFerrorHandler)
     120             :     {
     121           0 :         va_start(ap, fmt);
     122           0 :         (*_TIFFerrorHandler)(module, fmt, ap);
     123           0 :         va_end(ap);
     124             :     }
     125           0 :     if (_TIFFerrorHandlerExt)
     126             :     {
     127           0 :         va_start(ap, fmt);
     128           0 :         (*_TIFFerrorHandlerExt)(tif ? tif->tif_clientdata : NULL, module, fmt,
     129             :                                 ap);
     130           0 :         va_end(ap);
     131             :     }
     132             : }

Generated by: LCOV version 1.14