fukasawa e60969
fukasawa e60969
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
fukasawa e60969
 *
fukasawa e60969
 * Last changed in libpng 1.6.8 [December 19, 2013]
fukasawa e60969
 * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
fukasawa e60969
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
fukasawa e60969
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
fukasawa e60969
 *
fukasawa e60969
 * This code is released under the libpng license.
fukasawa e60969
 * For conditions of distribution and use, see the disclaimer
fukasawa e60969
 * and license in png.h
fukasawa e60969
 */
fukasawa e60969
fukasawa e60969
/* Define PNG_DEBUG at compile time for debugging information.  Higher
fukasawa e60969
 * numbers for PNG_DEBUG mean more debugging information.  This has
fukasawa e60969
 * only been added since version 0.95 so it is not implemented throughout
fukasawa e60969
 * libpng yet, but more support will be added as needed.
fukasawa e60969
 *
fukasawa e60969
 * png_debug[1-2]?(level, message ,arg{0-2})
fukasawa e60969
 *   Expands to a statement (either a simple expression or a compound
fukasawa e60969
 *   do..while(0) statement) that outputs a message with parameter
fukasawa e60969
 *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG
fukasawa e60969
 *   is undefined, 0 or 1 every png_debug expands to a simple expression
fukasawa e60969
 *   (actually ((void)0)).
fukasawa e60969
 *
fukasawa e60969
 *   level: level of detail of message, starting at 0.  A level 'n'
fukasawa e60969
 *          message is preceded by 'n' 3-space indentations (not implemented
fukasawa e60969
 *          on Microsoft compilers unless PNG_DEBUG_FILE is also
fukasawa e60969
 *          defined, to allow debug DLL compilation with no standard IO).
fukasawa e60969
 *   message: a printf(3) style text string.  A trailing '\n' is added
fukasawa e60969
 *            to the message.
fukasawa e60969
 *   arg: 0 to 2 arguments for printf(3) style substitution in message.
fukasawa e60969
 */
fukasawa e60969
#ifndef PNGDEBUG_H
fukasawa e60969
#define PNGDEBUG_H
fukasawa e60969
/* These settings control the formatting of messages in png.c and pngerror.c */
fukasawa e60969
/* Moved to pngdebug.h at 1.5.0 */
fukasawa e60969
#  ifndef PNG_LITERAL_SHARP
fukasawa e60969
#    define PNG_LITERAL_SHARP 0x23
fukasawa e60969
#  endif
fukasawa e60969
#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
fukasawa e60969
#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
fukasawa e60969
#  endif
fukasawa e60969
#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
fukasawa e60969
#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
fukasawa e60969
#  endif
fukasawa e60969
#  ifndef PNG_STRING_NEWLINE
fukasawa e60969
#    define PNG_STRING_NEWLINE "\n"
fukasawa e60969
#  endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_DEBUG
fukasawa e60969
#  if (PNG_DEBUG > 0)
fukasawa e60969
#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
fukasawa e60969
#      include <crtdbg.h></crtdbg.h>
fukasawa e60969
#      if (PNG_DEBUG > 1)
fukasawa e60969
#        ifndef _DEBUG
fukasawa e60969
#          define _DEBUG
fukasawa e60969
#        endif
fukasawa e60969
#        ifndef png_debug
fukasawa e60969
#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
fukasawa e60969
#        endif
fukasawa e60969
#        ifndef png_debug1
fukasawa e60969
#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
fukasawa e60969
#        endif
fukasawa e60969
#        ifndef png_debug2
fukasawa e60969
#          define png_debug2(l,m,p1,p2) \
fukasawa e60969
             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
fukasawa e60969
#        endif
fukasawa e60969
#      endif
fukasawa e60969
#    else /* PNG_DEBUG_FILE || !_MSC_VER */
fukasawa e60969
#      ifndef PNG_STDIO_SUPPORTED
fukasawa e60969
#        include <stdio.h> /* not included yet */</stdio.h>
fukasawa e60969
#      endif
fukasawa e60969
#      ifndef PNG_DEBUG_FILE
fukasawa e60969
#        define PNG_DEBUG_FILE stderr
fukasawa e60969
#      endif /* PNG_DEBUG_FILE */
fukasawa e60969
fukasawa e60969
#      if (PNG_DEBUG > 1)
fukasawa e60969
#        ifdef __STDC__
fukasawa e60969
#          ifndef png_debug
fukasawa e60969
#            define png_debug(l,m) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? "   " : \
fukasawa e60969
         (num_tabs==2 ? "      " : (num_tabs>2 ? "         " : "")))); \
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#          ifndef png_debug1
fukasawa e60969
#            define png_debug1(l,m,p1) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? "   " : \
fukasawa e60969
         (num_tabs==2 ? "      " : (num_tabs>2 ? "         " : ""))),p1); \
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#          ifndef png_debug2
fukasawa e60969
#            define png_debug2(l,m,p1,p2) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? "   " : \
fukasawa e60969
         (num_tabs==2 ? "      " : (num_tabs>2 ? "         " : ""))),p1,p2);\
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#        else /* __STDC __ */
fukasawa e60969
#          ifndef png_debug
fukasawa e60969
#            define png_debug(l,m) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       char format[256]; \
fukasawa e60969
       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
fukasawa e60969
         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
fukasawa e60969
         m,PNG_STRING_NEWLINE); \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,format); \
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#          ifndef png_debug1
fukasawa e60969
#            define png_debug1(l,m,p1) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       char format[256]; \
fukasawa e60969
       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
fukasawa e60969
         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
fukasawa e60969
         m,PNG_STRING_NEWLINE); \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,format,p1); \
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#          ifndef png_debug2
fukasawa e60969
#            define png_debug2(l,m,p1,p2) \
fukasawa e60969
       do { \
fukasawa e60969
       int num_tabs=l; \
fukasawa e60969
       char format[256]; \
fukasawa e60969
       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
fukasawa e60969
         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
fukasawa e60969
         m,PNG_STRING_NEWLINE); \
fukasawa e60969
       fprintf(PNG_DEBUG_FILE,format,p1,p2); \
fukasawa e60969
       } while (0)
fukasawa e60969
#          endif
fukasawa e60969
#        endif /* __STDC __ */
fukasawa e60969
#      endif /* (PNG_DEBUG > 1) */
fukasawa e60969
fukasawa e60969
#    endif /* _MSC_VER */
fukasawa e60969
#  endif /* (PNG_DEBUG > 0) */
fukasawa e60969
#endif /* PNG_DEBUG */
fukasawa e60969
#ifndef png_debug
fukasawa e60969
#  define png_debug(l, m) ((void)0)
fukasawa e60969
#endif
fukasawa e60969
#ifndef png_debug1
fukasawa e60969
#  define png_debug1(l, m, p1) ((void)0)
fukasawa e60969
#endif
fukasawa e60969
#ifndef png_debug2
fukasawa e60969
#  define png_debug2(l, m, p1, p2) ((void)0)
fukasawa e60969
#endif
fukasawa e60969
#endif /* PNGDEBUG_H */