1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * Last changed in libpng 1.6.8 [December 19, 2013]
33 * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
34 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
35 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
36 *
37 * This code is released under the libpng license.
38 * For conditions of distribution and use, see the disclaimer
39 * and license in png.h
40 */
41
42/* Define PNG_DEBUG at compile time for debugging information. Higher
43 * numbers for PNG_DEBUG mean more debugging information. This has
44 * only been added since version 0.95 so it is not implemented throughout
45 * libpng yet, but more support will be added as needed.
46 *
47 * png_debug[1-2]?(level, message ,arg{0-2})
48 * Expands to a statement (either a simple expression or a compound
49 * do..while(0) statement) that outputs a message with parameter
50 * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
51 * is undefined, 0 or 1 every png_debug expands to a simple expression
52 * (actually ((void)0)).
53 *
54 * level: level of detail of message, starting at 0. A level 'n'
55 * message is preceded by 'n' 3-space indentations (not implemented
56 * on Microsoft compilers unless PNG_DEBUG_FILE is also
57 * defined, to allow debug DLL compilation with no standard IO).
58 * message: a printf(3) style text string. A trailing '\n' is added
59 * to the message.
60 * arg: 0 to 2 arguments for printf(3) style substitution in message.
61 */
62#ifndef PNGDEBUG_H
63#define PNGDEBUG_H
64/* These settings control the formatting of messages in png.c and pngerror.c */
65/* Moved to pngdebug.h at 1.5.0 */
66# ifndef PNG_LITERAL_SHARP
67# define PNG_LITERAL_SHARP 0x23
68# endif
69# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
70# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
71# endif
72# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
73# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
74# endif
75# ifndef PNG_STRING_NEWLINE
76# define PNG_STRING_NEWLINE "\n"
77# endif
78
79#ifdef PNG_DEBUG
80# if (PNG_DEBUG > 0)
81# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
82# include <crtdbg.h>
83# if (PNG_DEBUG > 1)
84# ifndef _DEBUG
85# define _DEBUG
86# endif
87# ifndef png_debug
88# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
89# endif
90# ifndef png_debug1
91# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
92# endif
93# ifndef png_debug2
94# define png_debug2(l,m,p1,p2) \
95 _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
96# endif
97# endif
98# else /* PNG_DEBUG_FILE || !_MSC_VER */
99# ifndef PNG_STDIO_SUPPORTED
100# include <stdio.h> /* not included yet */
101# endif
102# ifndef PNG_DEBUG_FILE
103# define PNG_DEBUG_FILE stderr
104# endif /* PNG_DEBUG_FILE */
105
106# if (PNG_DEBUG > 1)
107# ifdef __STDC__
108# ifndef png_debug
109# define png_debug(l,m) \
110 do { \
111 int num_tabs=l; \
112 fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
113 (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
114 } while (0)
115# endif
116# ifndef png_debug1
117# define png_debug1(l,m,p1) \
118 do { \
119 int num_tabs=l; \
120 fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
121 (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
122 } while (0)
123# endif
124# ifndef png_debug2
125# define png_debug2(l,m,p1,p2) \
126 do { \
127 int num_tabs=l; \
128 fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
129 (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
130 } while (0)
131# endif
132# else /* __STDC __ */
133# ifndef png_debug
134# define png_debug(l,m) \
135 do { \
136 int num_tabs=l; \
137 char format[256]; \
138 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
139 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
140 m,PNG_STRING_NEWLINE); \
141 fprintf(PNG_DEBUG_FILE,format); \
142 } while (0)
143# endif
144# ifndef png_debug1
145# define png_debug1(l,m,p1) \
146 do { \
147 int num_tabs=l; \
148 char format[256]; \
149 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
150 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
151 m,PNG_STRING_NEWLINE); \
152 fprintf(PNG_DEBUG_FILE,format,p1); \
153 } while (0)
154# endif
155# ifndef png_debug2
156# define png_debug2(l,m,p1,p2) \
157 do { \
158 int num_tabs=l; \
159 char format[256]; \
160 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
161 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
162 m,PNG_STRING_NEWLINE); \
163 fprintf(PNG_DEBUG_FILE,format,p1,p2); \
164 } while (0)
165# endif
166# endif /* __STDC __ */
167# endif /* (PNG_DEBUG > 1) */
168
169# endif /* _MSC_VER */
170# endif /* (PNG_DEBUG > 0) */
171#endif /* PNG_DEBUG */
172#ifndef png_debug
173# define png_debug(l, m) ((void)0)
174#endif
175#ifndef png_debug1
176# define png_debug1(l, m, p1) ((void)0)
177#endif
178#ifndef png_debug2
179# define png_debug2(l, m, p1, p2) ((void)0)
180#endif
181#endif /* PNGDEBUG_H */
182