tif_warning.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * TIFF Library.
  26. */
  27. #include "tiffiop.h"
  28. TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL;
  29. TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler)
  30. {
  31. TIFFErrorHandler prev = _TIFFwarningHandler;
  32. _TIFFwarningHandler = handler;
  33. return (prev);
  34. }
  35. TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
  36. {
  37. TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
  38. _TIFFwarningHandlerExt = handler;
  39. return (prev);
  40. }
  41. void TIFFWarning(const char *module, const char *fmt, ...)
  42. {
  43. va_list ap;
  44. if (_TIFFwarningHandler)
  45. {
  46. va_start(ap, fmt);
  47. (*_TIFFwarningHandler)(module, fmt, ap);
  48. va_end(ap);
  49. }
  50. if (_TIFFwarningHandlerExt)
  51. {
  52. va_start(ap, fmt);
  53. (*_TIFFwarningHandlerExt)(0, module, fmt, ap);
  54. va_end(ap);
  55. }
  56. }
  57. void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt, ...)
  58. {
  59. va_list ap;
  60. if (_TIFFwarningHandler)
  61. {
  62. va_start(ap, fmt);
  63. (*_TIFFwarningHandler)(module, fmt, ap);
  64. va_end(ap);
  65. }
  66. if (_TIFFwarningHandlerExt)
  67. {
  68. va_start(ap, fmt);
  69. (*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
  70. va_end(ap);
  71. }
  72. }
  73. void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt, ...)
  74. {
  75. va_list ap;
  76. if (tif && tif->tif_warnhandler)
  77. {
  78. va_start(ap, fmt);
  79. int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data,
  80. module, fmt, ap);
  81. va_end(ap);
  82. if (stop)
  83. return;
  84. }
  85. if (_TIFFwarningHandler)
  86. {
  87. va_start(ap, fmt);
  88. (*_TIFFwarningHandler)(module, fmt, ap);
  89. va_end(ap);
  90. }
  91. if (_TIFFwarningHandlerExt)
  92. {
  93. va_start(ap, fmt);
  94. (*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt,
  95. ap);
  96. va_end(ap);
  97. }
  98. }