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