pngdebug.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
  2. *
  3. * Last changed in libpng 1.6.8 [December 19, 2013]
  4. * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
  5. * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  6. * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  7. *
  8. * This code is released under the libpng license.
  9. * For conditions of distribution and use, see the disclaimer
  10. * and license in png.h
  11. */
  12. /* Define PNG_DEBUG at compile time for debugging information. Higher
  13. * numbers for PNG_DEBUG mean more debugging information. This has
  14. * only been added since version 0.95 so it is not implemented throughout
  15. * libpng yet, but more support will be added as needed.
  16. *
  17. * png_debug[1-2]?(level, message ,arg{0-2})
  18. * Expands to a statement (either a simple expression or a compound
  19. * do..while(0) statement) that outputs a message with parameter
  20. * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
  21. * is undefined, 0 or 1 every png_debug expands to a simple expression
  22. * (actually ((void)0)).
  23. *
  24. * level: level of detail of message, starting at 0. A level 'n'
  25. * message is preceded by 'n' 3-space indentations (not implemented
  26. * on Microsoft compilers unless PNG_DEBUG_FILE is also
  27. * defined, to allow debug DLL compilation with no standard IO).
  28. * message: a printf(3) style text string. A trailing '\n' is added
  29. * to the message.
  30. * arg: 0 to 2 arguments for printf(3) style substitution in message.
  31. */
  32. #ifndef PNGDEBUG_H
  33. #define PNGDEBUG_H
  34. /* These settings control the formatting of messages in png.c and pngerror.c */
  35. /* Moved to pngdebug.h at 1.5.0 */
  36. # ifndef PNG_LITERAL_SHARP
  37. # define PNG_LITERAL_SHARP 0x23
  38. # endif
  39. # ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
  40. # define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
  41. # endif
  42. # ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
  43. # define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
  44. # endif
  45. # ifndef PNG_STRING_NEWLINE
  46. # define PNG_STRING_NEWLINE "\n"
  47. # endif
  48. #ifdef PNG_DEBUG
  49. # if (PNG_DEBUG > 0)
  50. # if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
  51. # include <crtdbg.h>
  52. # if (PNG_DEBUG > 1)
  53. # ifndef _DEBUG
  54. # define _DEBUG
  55. # endif
  56. # ifndef png_debug
  57. # define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
  58. # endif
  59. # ifndef png_debug1
  60. # define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
  61. # endif
  62. # ifndef png_debug2
  63. # define png_debug2(l,m,p1,p2) \
  64. _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
  65. # endif
  66. # endif
  67. # else /* PNG_DEBUG_FILE || !_MSC_VER */
  68. # ifndef PNG_STDIO_SUPPORTED
  69. # include <stdio.h> /* not included yet */
  70. # endif
  71. # ifndef PNG_DEBUG_FILE
  72. # define PNG_DEBUG_FILE stderr
  73. # endif /* PNG_DEBUG_FILE */
  74. # if (PNG_DEBUG > 1)
  75. # ifdef __STDC__
  76. # ifndef png_debug
  77. # define png_debug(l,m) \
  78. do { \
  79. int num_tabs=l; \
  80. fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
  81. (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
  82. } while (0)
  83. # endif
  84. # ifndef png_debug1
  85. # define png_debug1(l,m,p1) \
  86. do { \
  87. int num_tabs=l; \
  88. fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
  89. (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
  90. } while (0)
  91. # endif
  92. # ifndef png_debug2
  93. # define png_debug2(l,m,p1,p2) \
  94. do { \
  95. int num_tabs=l; \
  96. fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
  97. (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
  98. } while (0)
  99. # endif
  100. # else /* __STDC __ */
  101. # ifndef png_debug
  102. # define png_debug(l,m) \
  103. do { \
  104. int num_tabs=l; \
  105. char format[256]; \
  106. snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
  107. (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
  108. m,PNG_STRING_NEWLINE); \
  109. fprintf(PNG_DEBUG_FILE,format); \
  110. } while (0)
  111. # endif
  112. # ifndef png_debug1
  113. # define png_debug1(l,m,p1) \
  114. do { \
  115. int num_tabs=l; \
  116. char format[256]; \
  117. snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
  118. (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
  119. m,PNG_STRING_NEWLINE); \
  120. fprintf(PNG_DEBUG_FILE,format,p1); \
  121. } while (0)
  122. # endif
  123. # ifndef png_debug2
  124. # define png_debug2(l,m,p1,p2) \
  125. do { \
  126. int num_tabs=l; \
  127. char format[256]; \
  128. snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
  129. (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
  130. m,PNG_STRING_NEWLINE); \
  131. fprintf(PNG_DEBUG_FILE,format,p1,p2); \
  132. } while (0)
  133. # endif
  134. # endif /* __STDC __ */
  135. # endif /* (PNG_DEBUG > 1) */
  136. # endif /* _MSC_VER */
  137. # endif /* (PNG_DEBUG > 0) */
  138. #endif /* PNG_DEBUG */
  139. #ifndef png_debug
  140. # define png_debug(l, m) ((void)0)
  141. #endif
  142. #ifndef png_debug1
  143. # define png_debug1(l, m, p1) ((void)0)
  144. #endif
  145. #ifndef png_debug2
  146. # define png_debug2(l, m, p1, p2) ((void)0)
  147. #endif
  148. #endif /* PNGDEBUG_H */