blob: 986a27d2e15ce966a1924238eb48f43d7a907463 [file] [log] [blame]
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002/* pngconf.h - machine configurable file for libpng
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06003 *
Glenn Randers-Pehrsonaaf377c2010-03-08 11:20:30 -06004 * libpng version 1.5.0beta12 - March 8, 2010
Glenn Randers-Pehrsonc17c9572010-03-08 21:26:48 -06005 *
Glenn Randers-Pehrsone69b55d2010-01-01 10:29:06 -06006 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05007 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -05009 *
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050010 * This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050011 * For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050012 * and license in png.h
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050013 *
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060014 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050015
16/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060017 * are configuring libpng for a machine, you may want to read the section
18 * starting here down to where it starts to typedef png_color, png_text,
19 * and png_info.
20 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050021
22#ifndef PNGCONF_H
23#define PNGCONF_H
24
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050025#ifndef PNG_NO_LIMITS_H
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050026# include <limits.h>
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050027#endif
28
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050029/* Added at libpng-1.2.9 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050030
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060031/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure"
32 * script.
33 */
Glenn Randers-Pehrsond5d63602006-04-15 06:37:45 -050034#ifdef PNG_CONFIGURE_LIBPNG
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050035# ifdef HAVE_CONFIG_H
36# include "config.h"
37# endif
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060038#endif
39
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060040/*
41 * Added at libpng-1.2.8
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050042 *
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050043 * PNG_USER_CONFIG has to be defined on the compiler command line. This
44 * includes the resource compiler for Windows DLL configurations.
45 */
46#ifdef PNG_USER_CONFIG
47# ifndef PNG_USER_PRIVATEBUILD
48# define PNG_USER_PRIVATEBUILD
49# endif
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050050# include "pngusr.h"
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050051#endif
52
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050053/*
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060054 * If you create a private DLL you need to define in "pngusr.h" the followings:
55 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
56 * the DLL was built>
57 * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
58 * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
59 * distinguish your DLL from those of the official release. These
60 * correspond to the trailing letters that come after the version
61 * number and must match your private DLL name>
62 * e.g. // private DLL "libpng13gx.dll"
63 * #define PNG_USER_DLLFNAME_POSTFIX "gx"
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050064 *
65 * The following macros are also at your disposal if you want to complete the
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060066 * DLL VERSIONINFO structure.
67 * - PNG_USER_VERSIONINFO_COMMENTS
68 * - PNG_USER_VERSIONINFO_COMPANYNAME
69 * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
70 */
71
72#ifdef __STDC__
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050073# ifdef SPECIALBUILD
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -060074# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD) \
75 are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050076# endif
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060077
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050078# ifdef PRIVATEBUILD
79# pragma message("PRIVATEBUILD is deprecated.\
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -060080 Use PNG_USER_PRIVATEBUILD instead.")
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050081# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
82# endif
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060083#endif /* __STDC__ */
84
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -060085/* End of material added to libpng-1.2.8 */
Glenn Randers-Pehrson878b31e2004-11-12 22:04:56 -060086
Glenn Randers-Pehrson5d95de72009-09-01 11:28:09 -050087#ifndef PNG_VERSION_INFO_ONLY
88
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060089/* This is the size of the compression buffer, and thus the size of
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060090 * an IDAT chunk. Make this whatever size you feel is best for your
91 * machine. One of these will be allocated per png_struct. When this
92 * is full, it writes the data to the disk, and does some other
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -060093 * calculations. Making this an extremely small size will slow
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060094 * the library down, but you may want to experiment to determine
95 * where it becomes significant, if you are concerned with memory
96 * usage. Note that zlib allocates at least 32Kb also. For readers,
97 * this describes the size of the buffer available to read the data in.
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -060098 * Unless this gets smaller than the size of a row (compressed),
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060099 * it should not make much difference how big this is.
100 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500101
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600102#ifndef PNG_ZBUF_SIZE
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600103# define PNG_ZBUF_SIZE 8192
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600104#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500105
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600106/* Enable if you want a write-only libpng */
107
108#ifndef PNG_NO_READ_SUPPORTED
109# define PNG_READ_SUPPORTED
110#endif
111
112/* Enable if you want a read-only libpng */
113
114#ifndef PNG_NO_WRITE_SUPPORTED
115# define PNG_WRITE_SUPPORTED
116#endif
117
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500118/* Enabled in 1.4.0. */
119#ifdef PNG_ALLOW_BENIGN_ERRORS
120# define png_benign_error png_warning
121# define png_chunk_benign_error png_chunk_warning
122#else
123# ifndef PNG_BENIGN_ERRORS_SUPPORTED
124# define png_benign_error png_error
125# define png_chunk_benign_error png_chunk_error
126# endif
127#endif
128
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500129/* Added at libpng version 1.4.0 */
130#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
131# define PNG_WARNINGS_SUPPORTED
132#endif
133
Glenn Randers-Pehrson311c8472009-11-20 09:45:08 -0600134/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500135#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
136# define PNG_ERROR_TEXT_SUPPORTED
137#endif
138
Glenn Randers-Pehrson311c8472009-11-20 09:45:08 -0600139/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500140#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
141# define PNG_CHECK_cHRM_SUPPORTED
142#endif
143
Glenn Randers-Pehrson311c8472009-11-20 09:45:08 -0600144/* Added at libpng version 1.4.0 */
145#if !defined(PNG_NO_ALIGNED_MEMORY) && !defined(PNG_ALIGNED_MEMORY_SUPPORTED)
146# define PNG_ALIGNED_MEMORY_SUPPORTED
147#endif
148
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500149/* Enabled by default in 1.2.0. You can disable this if you don't need to
150 support PNGs that are embedded in MNG datastreams */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500151#ifndef PNG_NO_MNG_FEATURES
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600152# ifndef PNG_MNG_FEATURES_SUPPORTED
153# define PNG_MNG_FEATURES_SUPPORTED
154# endif
155#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600156
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500157/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600158#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600159# ifndef PNG_FLOATING_POINT_SUPPORTED
160# define PNG_FLOATING_POINT_SUPPORTED
161# endif
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -0500162#endif
163
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500164/* Added at libpng-1.4.0beta49 for testing (this test is no longer used
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600165 * in libpng and png_calloc() is always present)
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500166 */
Glenn Randers-Pehrson5d95de72009-09-01 11:28:09 -0500167#define PNG_CALLOC_SUPPORTED
168
Andreas Dilger47a0c421997-05-16 02:46:07 -0500169/* If you are running on a machine where you cannot allocate more
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600170 * than 64K of memory at once, uncomment this. While libpng will not
171 * normally need that much memory in a chunk (unless you load up a very
172 * large file), zlib needs to know how big of a chunk it can use, and
173 * libpng thus makes sure to check any memory allocation to verify it
174 * will fit into memory.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500175#define PNG_MAX_MALLOC_64K
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600176 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500177#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600178# define PNG_MAX_MALLOC_64K
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500179#endif
180
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500181/* Special munging to support doing things the 'cygwin' way:
182 * 'Normal' png-on-win32 defines/defaults:
183 * PNG_BUILD_DLL -- building dll
184 * PNG_USE_DLL -- building an application, linking to dll
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -0600185 * (no define) -- building static library, or building an
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500186 * application and linking to the static lib
187 * 'Cygwin' defines/defaults:
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500188 * PNG_BUILD_DLL -- (ignored) building the dll
189 * (no define) -- (ignored) building an application, linking to the dll
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500190 * PNG_STATIC -- (ignored) building the static lib, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500191 * application that links to the static lib.
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500192 * ALL_STATIC -- (ignored) building various static libs, or building an
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500193 * application that links to the static libs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500194 * Thus,
195 * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
196 * this bit of #ifdefs will define the 'correct' config variables based on
197 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
198 * unnecessary.
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500199 *
200 * Also, the precedence order is:
201 * ALL_STATIC (since we can't #undef something outside our namespace)
202 * PNG_BUILD_DLL
203 * PNG_STATIC
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500204 * (nothing) == PNG_USE_DLL
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500205 *
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500206 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500207 * of auto-import in binutils, we no longer need to worry about
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500208 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500209 * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500210 * to __declspec() stuff. However, we DO need to worry about
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500211 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
Glenn Randers-Pehrson86312502009-08-31 14:17:23 -0500212 * such as CONSOLE_IO.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500213 */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500214#ifdef __CYGWIN__
215# ifdef ALL_STATIC
216# ifdef PNG_BUILD_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500217# undef PNG_BUILD_DLL
218# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500219# ifdef PNG_USE_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500220# undef PNG_USE_DLL
221# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500222# ifdef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500223# undef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500224# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500225# ifndef PNG_STATIC
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -0600226# define PNG_STATIC
227# endif
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500228# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500229# ifdef PNG_BUILD_DLL
230# ifdef PNG_STATIC
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500231# undef PNG_STATIC
232# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500233# ifdef PNG_USE_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500234# undef PNG_USE_DLL
235# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500236# ifndef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500237# define PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500238# endif
239# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500240# ifdef PNG_STATIC
241# ifdef PNG_USE_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500242# undef PNG_USE_DLL
243# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500244# ifdef PNG_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500245# undef PNG_DLL
246# endif
247# else
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500248# ifndef PNG_USE_DLL
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -0500249# define PNG_USE_DLL
250# endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500251# ifndef PNG_DLL
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500252# define PNG_DLL
253# endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500254# endif
255# endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500256# endif
257#endif
258
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500259/* This protects us against compilers that run on a windowing system
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600260 * and thus don't have or would rather us not use the stdio types:
261 * stdin, stdout, and stderr. The only one currently used is stderr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600262 * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
263 * prevent these from being compiled and used. #defining PNG_NO_STDIO
264 * will also prevent these, plus will prevent the entire set of stdio
265 * macros and functions (FILE *, printf, etc.) from being compiled and used,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500266 * unless (PNG_DEBUG > 0) has been #defined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600267 *
268 * #define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600269 * #define PNG_NO_STDIO
270 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600271
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500272#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
273# define PNG_STDIO_SUPPORTED
274#endif
275
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500276
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500277#ifdef PNG_BUILD_DLL
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500278# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
279# define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -0500280# endif
281#endif
282
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600283#ifdef PNG_NO_STDIO
284# ifndef PNG_NO_CONSOLE_IO
285# define PNG_NO_CONSOLE_IO
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600286# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600287# ifdef PNG_DEBUG
288# if (PNG_DEBUG > 0)
289# include <stdio.h>
290# endif
291# endif
292#else
293# include <stdio.h>
294#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600295
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500296#if !(defined PNG_NO_CONSOLE_IO) && !defined(PNG_CONSOLE_IO_SUPPORTED)
297# define PNG_CONSOLE_IO_SUPPORTED
298#endif
299
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600300/* This macro protects us against machines that don't have function
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600301 * prototypes (ie K&R style headers). If your compiler does not handle
302 * function prototypes, define this macro and use the included ansi2knr.
303 * I've always been able to use _NO_PROTO as the indicator, but you may
304 * need to drag the empty declaration out in front of here, or change the
305 * ifdef to suit your own needs.
306 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500307#ifndef PNGARG
308
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600309# ifdef OF /* zlib prototype munger */
310# define PNGARG(arglist) OF(arglist)
311# else
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500312
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600313# ifdef _NO_PROTO
314# define PNGARG(arglist) ()
315# else
316# define PNGARG(arglist) arglist
317# endif /* _NO_PROTO */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500318
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600319# endif /* OF */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500320
321#endif /* PNGARG */
322
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600323/* Try to determine if we are compiling on a Mac. Note that testing for
324 * just __MWERKS__ is not good enough, because the Codewarrior is now used
325 * on non-Mac platforms.
326 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600327#ifndef MACOS
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600328# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
329 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
330# define MACOS
331# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600332#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600333
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500334/* Enough people need this for various reasons to include it here */
Glenn Randers-Pehrson418783e2009-11-01 06:45:09 -0600335#if !defined(MACOS) && !defined(RISCOS)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600336#include <sys/types.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500337#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600338
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500339/* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */
340#if !defined(PNG_NO_SETJMP) && \
341 !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600342# define PNG_SETJMP_SUPPORTED
343#endif
344
345#ifdef PNG_SETJMP_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600346# include <setjmp.h>
Glenn Randers-Pehrson6c2e9192010-03-03 05:37:04 -0600347#endif
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600348
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500349#ifdef BSD
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600350# include <strings.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500351#else
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600352# include <string.h>
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500353#endif
354
Andreas Dilger47a0c421997-05-16 02:46:07 -0500355/* Other defines for things like memory and the like can go here. */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500356
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500357/* This controls how fine the dithering gets. As this allocates
358 * a largish chunk of memory (32K), those who are not as concerned
359 * with dithering quality can decrease some or all of these.
360 */
361#ifndef PNG_DITHER_RED_BITS
362# define PNG_DITHER_RED_BITS 5
363#endif
364#ifndef PNG_DITHER_GREEN_BITS
365# define PNG_DITHER_GREEN_BITS 5
366#endif
367#ifndef PNG_DITHER_BLUE_BITS
368# define PNG_DITHER_BLUE_BITS 5
369#endif
370
371/* This controls how fine the gamma correction becomes when you
372 * are only interested in 8 bits anyway. Increasing this value
373 * results in more memory being used, and more pow() functions
374 * being called to fill in the gamma tables. Don't set this value
375 * less then 8, and even that may not work (I haven't tested it).
376 */
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500377#ifndef PNG_MAX_GAMMA_8
378# define PNG_MAX_GAMMA_8 11
379#endif
380
381/* This controls how much a difference in gamma we can tolerate before
382 * we actually start doing gamma conversion.
383 */
384#ifndef PNG_GAMMA_THRESHOLD
385# define PNG_GAMMA_THRESHOLD 0.05
386#endif
387
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600388/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600389 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600390 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600391 */
Glenn Randers-Pehrson28d4aae2009-11-13 16:29:45 -0600392#ifndef PNG_CONST
393# ifndef PNG_NO_CONST
394# define PNG_CONST const
395# else
396# define PNG_CONST
397# endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600398#endif
399
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600400/* The following defines give you the ability to remove code from the
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600401 * library that you will not be using. I wish I could figure out how to
402 * automate this, but I can't do that without making it seriously hard
403 * on the users. So if you are not using an ability, change the #define
404 * to and #undef, and that part of the library will not be compiled. If
405 * your linker can't find a function, you may want to make sure the
406 * ability is defined here. Some of these depend upon some others being
407 * defined. I haven't figured out all the interactions here, so you may
408 * have to experiment awhile to get everything to compile. If you are
409 * creating or using a shared library, you probably shouldn't touch this,
410 * as it will affect the size of the structures, and this will cause bad
411 * things to happen if the library and/or application ever change.
412 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500413
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500414/* Any features you will not be using can be undef'ed here */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600415
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600416/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500417 * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line,
418 * then pick and choose which ones to define without having to edit this
419 * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500420 * if you only want to have a png-compliant reader/writer but don't need
421 * any of the extra transformations. This saves about 80 kbytes in a
422 * typical installation of the library. (PNG_NO_* form added in version
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500423 * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in
424 * 1.4.0)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600425 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600426
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500427/* Ignore attempt to turn off both floating and fixed point support */
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -0500428#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600429 !defined(PNG_NO_FIXED_POINT_SUPPORTED)
430# define PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -0500431#endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600432
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500433#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600434
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500435/* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600436# if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600437 !defined(PNG_NO_READ_TRANSFORMS)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600438# define PNG_READ_TRANSFORMS_SUPPORTED
439# endif
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600440
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600441# ifdef PNG_READ_TRANSFORMS_SUPPORTED
442# ifndef PNG_NO_READ_EXPAND
443# define PNG_READ_EXPAND_SUPPORTED
444# endif
445# ifndef PNG_NO_READ_SHIFT
446# define PNG_READ_SHIFT_SUPPORTED
447# endif
448# ifndef PNG_NO_READ_PACK
449# define PNG_READ_PACK_SUPPORTED
450# endif
451# ifndef PNG_NO_READ_BGR
452# define PNG_READ_BGR_SUPPORTED
453# endif
454# ifndef PNG_NO_READ_SWAP
455# define PNG_READ_SWAP_SUPPORTED
456# endif
457# ifndef PNG_NO_READ_PACKSWAP
458# define PNG_READ_PACKSWAP_SUPPORTED
459# endif
460# ifndef PNG_NO_READ_INVERT
461# define PNG_READ_INVERT_SUPPORTED
462# endif
463# if 0 /* removed from libpng-1.4.0 */
464# ifndef PNG_NO_READ_DITHER
465# define PNG_READ_DITHER_SUPPORTED
466# endif
467# endif /* 0 */
468# ifndef PNG_NO_READ_BACKGROUND
469# define PNG_READ_BACKGROUND_SUPPORTED
470# endif
471# ifndef PNG_NO_READ_16_TO_8
472# define PNG_READ_16_TO_8_SUPPORTED
473# endif
474# ifndef PNG_NO_READ_FILLER
475# define PNG_READ_FILLER_SUPPORTED
476# endif
477# ifndef PNG_NO_READ_GAMMA
478# define PNG_READ_GAMMA_SUPPORTED
479# endif
480# ifndef PNG_NO_READ_GRAY_TO_RGB
481# define PNG_READ_GRAY_TO_RGB_SUPPORTED
482# endif
483# ifndef PNG_NO_READ_SWAP_ALPHA
484# define PNG_READ_SWAP_ALPHA_SUPPORTED
485# endif
486# ifndef PNG_NO_READ_INVERT_ALPHA
487# define PNG_READ_INVERT_ALPHA_SUPPORTED
488# endif
489# ifndef PNG_NO_READ_STRIP_ALPHA
490# define PNG_READ_STRIP_ALPHA_SUPPORTED
491# endif
492# ifndef PNG_NO_READ_USER_TRANSFORM
493# define PNG_READ_USER_TRANSFORM_SUPPORTED
494# endif
495# ifndef PNG_NO_READ_RGB_TO_GRAY
496# define PNG_READ_RGB_TO_GRAY_SUPPORTED
497# endif
498# endif /* PNG_READ_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600499
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600500# ifndef PNG_NO_PROGRESSIVE_READ
501# define PNG_PROGRESSIVE_READ_SUPPORTED
502# endif
503/* You can define PNG_NO_PROGRESSIVE_READ if you don't do progressive reading.
504 * This is not talking about interlacing capability! You'll still have
505 * interlacing unless you change the following define which is required
506 * for PNG-compliant decoders:
507 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600508
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600509# define PNG_READ_INTERLACING_SUPPORTED
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500510
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500511/* PNG_NO_SEQUENTIAL_READ_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600512# if !defined(PNG_NO_SEQUENTIAL_READ) && \
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500513 !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \
514 !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600515# define PNG_SEQUENTIAL_READ_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600516# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500517
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600518# ifndef PNG_NO_READ_COMPOSITE_NODIV
519# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600520 /* well tested on Intel, SGI */
521# define PNG_READ_COMPOSITE_NODIV_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600522# endif
523# endif
524
525# if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500526 defined(PNG_READ_pCAL_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600527# ifndef PNG_GET_INT_32_SUPPORTED
528# define PNG_GET_INT_32_SUPPORTED
529# endif
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500530# endif
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500531
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600532#endif /* PNG_READ_SUPPORTED */
533
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500534#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600535
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500536/* PNG_WRITE_TRANSFORMS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600537# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600538 !defined(PNG_NO_WRITE_TRANSFORMS)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600539# define PNG_WRITE_TRANSFORMS_SUPPORTED
540# endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600541
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600542# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
543# ifndef PNG_NO_WRITE_SHIFT
544# define PNG_WRITE_SHIFT_SUPPORTED
545# endif
546# ifndef PNG_NO_WRITE_PACK
547# define PNG_WRITE_PACK_SUPPORTED
548# endif
549# ifndef PNG_NO_WRITE_BGR
550# define PNG_WRITE_BGR_SUPPORTED
551# endif
552# ifndef PNG_NO_WRITE_SWAP
553# define PNG_WRITE_SWAP_SUPPORTED
554# endif
555# ifndef PNG_NO_WRITE_PACKSWAP
556# define PNG_WRITE_PACKSWAP_SUPPORTED
557# endif
558# ifndef PNG_NO_WRITE_INVERT
559# define PNG_WRITE_INVERT_SUPPORTED
560# endif
561# ifndef PNG_NO_WRITE_FILLER
562# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
563# endif
564# ifndef PNG_NO_WRITE_SWAP_ALPHA
565# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
566# endif
567# ifndef PNG_NO_WRITE_INVERT_ALPHA
568# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
569# endif
570# ifndef PNG_NO_WRITE_USER_TRANSFORM
571# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
572# endif
573# endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600574
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600575# if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600576 !defined(PNG_WRITE_INTERLACING_SUPPORTED)
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500577 /* This is not required for PNG-compliant encoders, but can cause
578 * trouble if left undefined
579 */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600580# define PNG_WRITE_INTERLACING_SUPPORTED
581# endif
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600582
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600583# if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600584 !defined(PNG_WRITE_WEIGHTED_FILTER) && \
585 defined(PNG_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600586# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500587# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600588
589# ifndef PNG_NO_WRITE_FLUSH
590# define PNG_WRITE_FLUSH_SUPPORTED
591# endif
592
593# if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600594 defined(PNG_WRITE_pCAL_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600595# ifndef PNG_SAVE_INT_32_SUPPORTED
596# define PNG_SAVE_INT_32_SUPPORTED
597# endif
598# endif
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500599
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600600#endif /* PNG_WRITE_SUPPORTED */
601
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500602#define PNG_NO_ERROR_NUMBERS
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500603
604#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
605 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
606# ifndef PNG_NO_USER_TRANSFORM_PTR
607# define PNG_USER_TRANSFORM_PTR_SUPPORTED
608# endif
609#endif
610
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500611#if defined(PNG_STDIO_SUPPORTED) && !defined(PNG_TIME_RFC1123_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600612# define PNG_TIME_RFC1123_SUPPORTED
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -0600613#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500614
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600615/* This adds extra functions in pngget.c for accessing data from the
616 * info pointer (added in version 0.99)
617 * png_get_image_width()
618 * png_get_image_height()
619 * png_get_bit_depth()
620 * png_get_color_type()
621 * png_get_compression_type()
622 * png_get_filter_type()
623 * png_get_interlace_type()
624 * png_get_pixel_aspect_ratio()
625 * png_get_pixels_per_meter()
626 * png_get_x_offset_pixels()
627 * png_get_y_offset_pixels()
628 * png_get_x_offset_microns()
629 * png_get_y_offset_microns()
630 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500631#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600632# define PNG_EASY_ACCESS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600633#endif
634
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500635/* Added at libpng-1.2.0 */
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500636#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
637# define PNG_USER_MEM_SUPPORTED
638#endif
639
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500640/* Added at libpng-1.2.6 */
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600641#ifndef PNG_NO_SET_USER_LIMITS
642# ifndef PNG_SET_USER_LIMITS_SUPPORTED
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500643# define PNG_SET_USER_LIMITS_SUPPORTED
644# endif
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600645 /* Feature added at libpng-1.4.0, this flag added at 1.4.1 */
646# ifndef PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
647# define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
648# endif
649 /* Feature added at libpng-1.4.1, this flag added at 1.4.1 */
650# ifndef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
651# define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
652# endif
653#endif
654
655/* Added at libpng-1.2.43 */
656#ifndef PNG_NO_USER_LIMITS
657# ifndef PNG_USER_LIMITS_SUPPORTED
658# define PNG_USER_LIMITS_SUPPORTED
659# endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500660#endif
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500661
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500662/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGs no matter
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600663 * how large, set these two limits to 0x7fffffffL
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500664 */
665#ifndef PNG_USER_WIDTH_MAX
666# define PNG_USER_WIDTH_MAX 1000000L
667#endif
668#ifndef PNG_USER_HEIGHT_MAX
669# define PNG_USER_HEIGHT_MAX 1000000L
670#endif
671
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600672/* Added at libpng-1.2.43. To accept all valid PNGs no matter
673 * how large, set these two limits to 0.
674 */
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500675#ifndef PNG_USER_CHUNK_CACHE_MAX
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600676# define PNG_USER_CHUNK_CACHE_MAX 0
677#endif
678
679/* Added at libpng-1.2.43 */
680#ifndef PNG_USER_CHUNK_MALLOC_MAX
681# define PNG_USER_CHUNK_MALLOC_MAX 0
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500682#endif
683
684/* Added at libpng-1.4.0 */
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500685#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500686# define PNG_IO_STATE_SUPPORTED
687#endif
688
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500689#ifndef PNG_LITERAL_SHARP
690# define PNG_LITERAL_SHARP 0x23
691#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500692#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500693# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500694#endif
695#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
Glenn Randers-Pehrson51650b82008-08-05 07:44:42 -0500696# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500697#endif
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500698#ifndef PNG_STRING_NEWLINE
Glenn Randers-Pehrsone0784c72008-08-09 07:11:44 -0500699#define PNG_STRING_NEWLINE "\n"
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -0500700#endif
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -0500701
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600702/* These are currently experimental features, define them if you want */
703
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600704/* Very little testing, not enabled by default. */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600705/*
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600706#ifdef PNG_READ_SUPPORTED
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600707# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
708# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
709# endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600710#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600711*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500712
713/* This is only for PowerPC big-endian and 680x0 systems */
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600714/* some testing, not enabled by default. */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600715/*
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500716#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600717# define PNG_READ_BIG_ENDIAN_SUPPORTED
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600718#endif
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600719*/
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500720
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500721#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
722# define PNG_USE_READ_MACROS
723#endif
724
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500725/* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING */
726
727#if !defined(PNG_NO_POINTER_INDEXING) && \
728 !defined(PNG_POINTER_INDEXING_SUPPORTED)
729# define PNG_POINTER_INDEXING_SUPPORTED
730#endif
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -0500731
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600732
Andreas Dilger47a0c421997-05-16 02:46:07 -0500733/* Any chunks you are not interested in, you can undef here. The
734 * ones that allocate memory may be expecially important (hIST,
735 * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600736 * a bit smaller.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500737 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500738
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500739/* The size of the png_text structure changed in libpng-1.0.6 when
740 * iTXt support was added. iTXt support was turned off by default through
741 * libpng-1.2.x, to support old apps that malloc the png_text structure
742 * instead of calling png_set_text() and letting libpng malloc it. It
743 * was turned on by default in libpng-1.4.0.
744 */
745
746/* PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600747#if defined(PNG_READ_SUPPORTED) && \
748 !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500749 !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600750# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600751#endif
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600752
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500753/* PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -0600754#if defined(PNG_WRITE_SUPPORTED) && \
755 !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500756 !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600757# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600758#endif
759
760#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600761
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600762# ifdef PNG_NO_READ_TEXT
763# define PNG_NO_READ_iTXt
764# define PNG_NO_READ_tEXt
765# define PNG_NO_READ_zTXt
766# endif
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500767
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600768# ifndef PNG_NO_READ_bKGD
769# define PNG_READ_bKGD_SUPPORTED
770# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500771# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600772# ifndef PNG_NO_READ_cHRM
773# define PNG_READ_cHRM_SUPPORTED
774# define PNG_cHRM_SUPPORTED
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500775# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600776# ifndef PNG_NO_READ_gAMA
777# define PNG_READ_gAMA_SUPPORTED
778# define PNG_gAMA_SUPPORTED
779# endif
780# ifndef PNG_NO_READ_hIST
781# define PNG_READ_hIST_SUPPORTED
782# define PNG_hIST_SUPPORTED
783# endif
784# ifndef PNG_NO_READ_iCCP
785# define PNG_READ_iCCP_SUPPORTED
786# define PNG_iCCP_SUPPORTED
787# endif
788# ifndef PNG_NO_READ_iTXt
789# ifndef PNG_READ_iTXt_SUPPORTED
790# define PNG_READ_iTXt_SUPPORTED
791# endif
792# ifndef PNG_iTXt_SUPPORTED
793# define PNG_iTXt_SUPPORTED
794# endif
795# endif
796# ifndef PNG_NO_READ_oFFs
797# define PNG_READ_oFFs_SUPPORTED
798# define PNG_oFFs_SUPPORTED
799# endif
800# ifndef PNG_NO_READ_pCAL
801# define PNG_READ_pCAL_SUPPORTED
802# define PNG_pCAL_SUPPORTED
803# endif
804# ifndef PNG_NO_READ_sCAL
805# define PNG_READ_sCAL_SUPPORTED
806# define PNG_sCAL_SUPPORTED
807# endif
808# ifndef PNG_NO_READ_pHYs
809# define PNG_READ_pHYs_SUPPORTED
810# define PNG_pHYs_SUPPORTED
811# endif
812# ifndef PNG_NO_READ_sBIT
813# define PNG_READ_sBIT_SUPPORTED
814# define PNG_sBIT_SUPPORTED
815# endif
816# ifndef PNG_NO_READ_sPLT
817# define PNG_READ_sPLT_SUPPORTED
818# define PNG_sPLT_SUPPORTED
819# endif
820# ifndef PNG_NO_READ_sRGB
821# define PNG_READ_sRGB_SUPPORTED
822# define PNG_sRGB_SUPPORTED
823# endif
824# ifndef PNG_NO_READ_tEXt
825# define PNG_READ_tEXt_SUPPORTED
826# define PNG_tEXt_SUPPORTED
827# endif
828# ifndef PNG_NO_READ_tIME
829# define PNG_READ_tIME_SUPPORTED
830# define PNG_tIME_SUPPORTED
831# endif
832# ifndef PNG_NO_READ_tRNS
833# define PNG_READ_tRNS_SUPPORTED
834# define PNG_tRNS_SUPPORTED
835# endif
836# ifndef PNG_NO_READ_zTXt
837# define PNG_READ_zTXt_SUPPORTED
838# define PNG_zTXt_SUPPORTED
839# endif
840# ifndef PNG_NO_READ_OPT_PLTE
841# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
842# endif /* optional PLTE chunk in RGB and RGBA images */
843# if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600844 defined(PNG_READ_zTXt_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600845# define PNG_READ_TEXT_SUPPORTED
846# define PNG_TEXT_SUPPORTED
847# endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -0500848
849#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
850
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -0500851#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600852# ifndef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
853# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
854# endif
Glenn Randers-Pehrson98c9d732000-05-03 21:06:11 -0500855# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
856# define PNG_UNKNOWN_CHUNKS_SUPPORTED
857# endif
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600858# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
859# define PNG_READ_USER_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600860# endif
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600861#endif
862#ifndef PNG_NO_READ_USER_CHUNKS
863# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
864# define PNG_READ_USER_CHUNKS_SUPPORTED
865# endif
866# ifndef PNG_USER_CHUNKS_SUPPORTED
867# define PNG_USER_CHUNKS_SUPPORTED
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600868# endif
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600869#endif
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500870#ifndef PNG_NO_HANDLE_AS_UNKNOWN
871# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
872# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
873# endif
874#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500875
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -0500876#ifdef PNG_WRITE_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600877# ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600878
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600879# ifdef PNG_NO_WRITE_TEXT
880# define PNG_NO_WRITE_iTXt
881# define PNG_NO_WRITE_tEXt
882# define PNG_NO_WRITE_zTXt
883# endif
884# ifndef PNG_NO_WRITE_bKGD
885# define PNG_WRITE_bKGD_SUPPORTED
886# ifndef PNG_bKGD_SUPPORTED
887# define PNG_bKGD_SUPPORTED
Glenn Randers-Pehrson45b87612009-11-03 11:42:05 -0600888# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600889# endif
890# ifndef PNG_NO_WRITE_cHRM
891# define PNG_WRITE_cHRM_SUPPORTED
892# ifndef PNG_cHRM_SUPPORTED
893# define PNG_cHRM_SUPPORTED
894# endif
895# endif
896# ifndef PNG_NO_WRITE_gAMA
897# define PNG_WRITE_gAMA_SUPPORTED
898# ifndef PNG_gAMA_SUPPORTED
899# define PNG_gAMA_SUPPORTED
900# endif
901# endif
902# ifndef PNG_NO_WRITE_hIST
903# define PNG_WRITE_hIST_SUPPORTED
904# ifndef PNG_hIST_SUPPORTED
905# define PNG_hIST_SUPPORTED
906# endif
907# endif
908# ifndef PNG_NO_WRITE_iCCP
909# define PNG_WRITE_iCCP_SUPPORTED
910# ifndef PNG_iCCP_SUPPORTED
911# define PNG_iCCP_SUPPORTED
912# endif
913# endif
914# ifndef PNG_NO_WRITE_iTXt
915# ifndef PNG_WRITE_iTXt_SUPPORTED
916# define PNG_WRITE_iTXt_SUPPORTED
917# endif
918# ifndef PNG_iTXt_SUPPORTED
919# define PNG_iTXt_SUPPORTED
920# endif
921# endif
922# ifndef PNG_NO_WRITE_oFFs
923# define PNG_WRITE_oFFs_SUPPORTED
924# ifndef PNG_oFFs_SUPPORTED
925# define PNG_oFFs_SUPPORTED
926# endif
927# endif
928# ifndef PNG_NO_WRITE_pCAL
929# define PNG_WRITE_pCAL_SUPPORTED
930# ifndef PNG_pCAL_SUPPORTED
931# define PNG_pCAL_SUPPORTED
932# endif
933# endif
934# ifndef PNG_NO_WRITE_sCAL
935# define PNG_WRITE_sCAL_SUPPORTED
936# ifndef PNG_sCAL_SUPPORTED
937# define PNG_sCAL_SUPPORTED
938# endif
939# endif
940# ifndef PNG_NO_WRITE_pHYs
941# define PNG_WRITE_pHYs_SUPPORTED
942# ifndef PNG_pHYs_SUPPORTED
943# define PNG_pHYs_SUPPORTED
944# endif
945# endif
946# ifndef PNG_NO_WRITE_sBIT
947# define PNG_WRITE_sBIT_SUPPORTED
948# ifndef PNG_sBIT_SUPPORTED
949# define PNG_sBIT_SUPPORTED
950# endif
951# endif
952# ifndef PNG_NO_WRITE_sPLT
953# define PNG_WRITE_sPLT_SUPPORTED
954# ifndef PNG_sPLT_SUPPORTED
955# define PNG_sPLT_SUPPORTED
956# endif
957# endif
958# ifndef PNG_NO_WRITE_sRGB
959# define PNG_WRITE_sRGB_SUPPORTED
960# ifndef PNG_sRGB_SUPPORTED
961# define PNG_sRGB_SUPPORTED
962# endif
963# endif
964# ifndef PNG_NO_WRITE_tEXt
965# define PNG_WRITE_tEXt_SUPPORTED
966# ifndef PNG_tEXt_SUPPORTED
967# define PNG_tEXt_SUPPORTED
968# endif
969# endif
970# ifndef PNG_NO_WRITE_tIME
971# define PNG_WRITE_tIME_SUPPORTED
972# ifndef PNG_tIME_SUPPORTED
973# define PNG_tIME_SUPPORTED
974# endif
975# endif
976# ifndef PNG_NO_WRITE_tRNS
977# define PNG_WRITE_tRNS_SUPPORTED
978# ifndef PNG_tRNS_SUPPORTED
979# define PNG_tRNS_SUPPORTED
980# endif
981# endif
982# ifndef PNG_NO_WRITE_zTXt
983# define PNG_WRITE_zTXt_SUPPORTED
984# ifndef PNG_zTXt_SUPPORTED
985# define PNG_zTXt_SUPPORTED
986# endif
987# endif
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600988# if defined(PNG_WRITE_iTXt_SUPPORTED) || \
989 defined(PNG_WRITE_tEXt_SUPPORTED) || \
990 defined(PNG_WRITE_zTXt_SUPPORTED)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600991# define PNG_WRITE_TEXT_SUPPORTED
992# ifndef PNG_TEXT_SUPPORTED
993# define PNG_TEXT_SUPPORTED
994# endif
995# endif
Glenn Randers-Pehrson658ea432009-06-16 16:24:57 -0500996
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600997# ifdef PNG_WRITE_tIME_SUPPORTED
998# ifndef PNG_NO_CONVERT_tIME
999# ifndef _WIN32_WCE
1000/* The "tm" structure is not supported on WindowsCE */
1001# ifndef PNG_CONVERT_tIME_SUPPORTED
1002# define PNG_CONVERT_tIME_SUPPORTED
1003# endif
1004# endif
1005# endif
1006# endif
Glenn Randers-Pehrsond6ea40a2009-11-02 07:32:00 -06001007
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001008# endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -05001009
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001010# ifndef PNG_NO_WRITE_FILTER
1011# ifndef PNG_WRITE_FILTER_SUPPORTED
1012# define PNG_WRITE_FILTER_SUPPORTED
1013# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001014# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001015
1016# ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
1017# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1018# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
1019# define PNG_UNKNOWN_CHUNKS_SUPPORTED
1020# endif
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001021# endif
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001022# ifndef PNG_NO_HANDLE_AS_UNKNOWN
1023# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1024# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1025# endif
1026# endif
Glenn Randers-Pehrson3b3e0902009-06-16 17:20:43 -05001027#endif /* PNG_WRITE_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001028
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001029/* Turn this off to disable png_read_png() and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001030 * png_write_png() and leave the row_pointers member
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001031 * out of the info structure.
1032 */
1033#ifndef PNG_NO_INFO_IMAGE
1034# define PNG_INFO_IMAGE_SUPPORTED
1035#endif
1036
Glenn Randers-Pehrson45b87612009-11-03 11:42:05 -06001037/* Need the time information for converting tIME chunks */
1038#ifdef PNG_CONVERT_tIME_SUPPORTED
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -06001039 /* "time.h" functions are not supported on WindowsCE */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001040# include <time.h>
Andreas Dilger47a0c421997-05-16 02:46:07 -05001041#endif
1042
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001043/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001044 * common platforms. The typedefs should be at least as large as the
1045 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
1046 * don't have to be exactly that size. Some compilers dislike passing
1047 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001048 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001049 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001050
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001051#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
1052typedef unsigned int png_uint_32;
1053typedef int png_int_32;
1054#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001055typedef unsigned long png_uint_32;
1056typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001057#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001058typedef unsigned short png_uint_16;
1059typedef short png_int_16;
1060typedef unsigned char png_byte;
1061
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001062#ifdef PNG_NO_SIZE_T
1063 typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001064#else
1065 typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05001066#endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001067#define png_sizeof(x) sizeof(x)
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001068
Andreas Dilger47a0c421997-05-16 02:46:07 -05001069/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001070 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -05001071 * MSC. Model independent support declares all arrays and pointers to be
1072 * large using the far keyword. The zlib version used must also support
1073 * model independent data. As of version zlib 1.0.4, the necessary changes
1074 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
1075 * changes that are needed. (Tim Wegner)
1076 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001077
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001078/* Separate compiler dependencies (problem here is that zlib.h always
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001079 * defines FAR. (SJT)
1080 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001081#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001082# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
1083# define LDATA 1
1084# else
1085# define LDATA 0
1086# endif
1087 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
1088# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
1089# define PNG_MAX_MALLOC_64K
1090# if (LDATA != 1)
1091# ifndef FAR
1092# define FAR __far
1093# endif
1094# define USE_FAR_KEYWORD
1095# endif /* LDATA != 1 */
1096 /* Possibly useful for moving data out of default segment.
1097 * Uncomment it if you want. Could also define FARDATA as
1098 * const if your compiler supports it. (SJT)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001099# define FARDATA FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001100 */
1101# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -06001102#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -06001103
1104
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001105/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001106 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
1107 * making reliance oncertain keywords suspect. (SJT)
1108 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001109
1110/* MSC Medium model */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001111#ifdef FAR
1112# ifdef M_I86MM
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001113# define USE_FAR_KEYWORD
1114# define FARDATA FAR
1115# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -06001116# endif
1117#endif
1118
1119/* SJT: default case */
1120#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001121# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001122#endif
1123
Andreas Dilger47a0c421997-05-16 02:46:07 -05001124/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -06001125#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001126# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -06001127#endif
1128
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001129/* Typedef for floating-point numbers that are converted
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -06001130 * to fixed-point with a multiple of 100,000, e.g., int_gamma
1131 */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001132typedef png_int_32 png_fixed_point;
1133
Andreas Dilger47a0c421997-05-16 02:46:07 -05001134/* Add typedefs for pointers */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001135typedef void FAR * png_voidp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001136typedef png_byte FAR * png_bytep;
1137typedef png_uint_32 FAR * png_uint_32p;
1138typedef png_int_32 FAR * png_int_32p;
1139typedef png_uint_16 FAR * png_uint_16p;
1140typedef png_int_16 FAR * png_int_16p;
1141typedef PNG_CONST char FAR * png_const_charp;
1142typedef char FAR * png_charp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001143typedef png_fixed_point FAR * png_fixed_point_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001144
1145#ifndef PNG_NO_STDIO
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -05001146typedef FILE * png_FILE_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -06001147#endif
1148
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001149#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001150typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001151#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001152
Andreas Dilger47a0c421997-05-16 02:46:07 -05001153/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -06001154typedef png_byte FAR * FAR * png_bytepp;
1155typedef png_uint_32 FAR * FAR * png_uint_32pp;
1156typedef png_int_32 FAR * FAR * png_int_32pp;
1157typedef png_uint_16 FAR * FAR * png_uint_16pp;
1158typedef png_int_16 FAR * FAR * png_int_16pp;
1159typedef PNG_CONST char FAR * FAR * png_const_charpp;
1160typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001161typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001162#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001163typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001164#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001165
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001166/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001167typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -06001168
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001169/* Define PNG_BUILD_DLL if the module being built is a Windows
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001170 * LIBPNG DLL.
1171 *
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001172 * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
Glenn Randers-Pehrsond4e81092001-01-31 05:56:52 -06001173 * It is equivalent to Microsoft predefined macro _DLL that is
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001174 * automatically defined when you compile using the share
1175 * version of the CRT (C Run-Time library)
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001176 *
1177 * The cygwin mods make this behavior a little different:
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001178 * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
1179 * Define PNG_STATIC if you are building a static library for use with cygwin,
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001180 * -or- if you are building an application that you want to link to the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001181 * static library.
1182 * PNG_USE_DLL is defined by default (no user action needed) unless one of
1183 * the other flags is defined.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001184 */
1185
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05001186#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001187# define PNG_DLL
1188#endif
Glenn Randers-Pehrsonec61c232000-05-16 06:17:36 -05001189
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001190#ifdef __CYGWIN__
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001191# undef PNGAPI
1192# define PNGAPI __cdecl
1193# undef PNG_IMPEXP
1194# define PNG_IMPEXP
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -05001195#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001196
Glenn Randers-Pehrson9e978842009-08-31 14:28:33 -05001197#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
1198
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -05001199/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
1200 * you may get warnings regarding the linkage of png_zalloc and png_zfree.
1201 * Don't ignore those warnings; you must also reset the default calling
1202 * convention in your compiler to match your PNGAPI, and you must build
1203 * zlib and your applications the same way you build libpng.
1204 */
1205
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -05001206#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001207# ifndef PNG_NO_MODULEDEF
1208# define PNG_NO_MODULEDEF
1209# endif
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001210#endif
1211
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001212#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001213# define PNG_IMPEXP
1214#endif
1215
1216#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001217 (( defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -06001218 defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001219
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001220# ifndef PNGAPI
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001221# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
1222# define PNGAPI __cdecl
1223# else
1224# define PNGAPI _cdecl
1225# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001226# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001227
1228# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -06001229 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001230# define PNG_IMPEXP
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001231# endif
1232
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001233# ifndef PNG_IMPEXP
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001234
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001235# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
1236# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001237
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001238 /* Borland/Microsoft */
1239# if defined(_MSC_VER) || defined(__BORLANDC__)
1240# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001241# define PNG_EXPORT PNG_EXPORT_TYPE1
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001242# else
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001243# define PNG_EXPORT PNG_EXPORT_TYPE2
1244# ifdef PNG_BUILD_DLL
1245# define PNG_IMPEXP __export
1246# else
1247# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -06001248# endif /* Exists in Borland C++ for
1249 C++ classes (== huge) */
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001250# endif
1251# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001252
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001253# ifndef PNG_IMPEXP
1254# ifdef PNG_BUILD_DLL
1255# define PNG_IMPEXP __declspec(dllexport)
1256# else
1257# define PNG_IMPEXP __declspec(dllimport)
1258# endif
1259# endif
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001260# endif /* PNG_IMPEXP */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05001261#else /* !(DLL || non-cygwin WINDOWS) */
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001262# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
1263# ifndef PNGAPI
1264# define PNGAPI _System
1265# endif
1266# else
1267# if 0 /* ... other platforms, with other meanings */
1268# endif
1269# endif
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001270#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001271
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001272#ifndef PNGAPI
1273# define PNGAPI
1274#endif
1275#ifndef PNG_IMPEXP
1276# define PNG_IMPEXP
1277#endif
1278
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001279#ifdef PNG_BUILDSYMS
1280# ifndef PNG_EXPORT
1281# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
1282# endif
Glenn Randers-Pehrsonc3dda6d2004-11-27 18:22:29 -06001283#endif
1284
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001285#ifndef PNG_EXPORT
Glenn Randers-Pehrson13944802000-06-24 07:42:42 -05001286# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001287#endif
1288
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001289/* Support for compiler specific function attributes. These are used
1290 * so that where compiler support is available incorrect use of API
1291 * functions in png.h will generate compiler warnings.
Glenn Randers-Pehrsonce00e7d2009-11-12 08:52:03 -06001292 *
1293 * Added at libpng-1.2.41.
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001294 */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001295
Glenn Randers-Pehrson451fd6c2009-12-04 08:46:31 -06001296#ifndef PNG_NO_PEDANTIC_WARNINGS
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001297#ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
1298# define PNG_PEDANTIC_WARNINGS_SUPPORTED
1299#endif
Glenn Randers-Pehrson451fd6c2009-12-04 08:46:31 -06001300#endif
1301
1302#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
1303/* Support for compiler specific function attributes. These are used
1304 * so that where compiler support is available incorrect use of API
1305 * functions in png.h will generate compiler warnings. Added at libpng
1306 * version 1.2.41.
1307 */
1308# ifdef __GNUC__
1309# ifndef PNG_USE_RESULT
1310# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
1311# endif
1312# ifndef PNG_NORETURN
1313# define PNG_NORETURN __attribute__((__noreturn__))
1314# endif
1315# ifndef PNG_ALLOCATED
1316# define PNG_ALLOCATED __attribute__((__malloc__))
1317# endif
1318
Glenn Randers-Pehrson44db6e32009-11-08 20:36:28 -06001319 /* This specifically protects structure members that should only be
1320 * accessed from within the library, therefore should be empty during
1321 * a library build.
1322 */
Glenn Randers-Pehrson451fd6c2009-12-04 08:46:31 -06001323# ifndef PNG_DEPRECATED
1324# define PNG_DEPRECATED __attribute__((__deprecated__))
1325# endif
Glenn Randers-Pehrson44db6e32009-11-08 20:36:28 -06001326# ifndef PNG_DEPSTRUCT
1327# define PNG_DEPSTRUCT __attribute__((__deprecated__))
1328# endif
Glenn Randers-Pehrson4e1e1992009-11-12 08:29:21 -06001329# ifndef PNG_PRIVATE
Glenn Randers-Pehrson451fd6c2009-12-04 08:46:31 -06001330# if 0 /* Doesn't work so we use deprecated instead*/
1331# define PNG_PRIVATE \
1332 __attribute__((warning("This function is not exported by libpng.")))
1333# else
1334# define PNG_PRIVATE \
1335 __attribute__((__deprecated__))
1336# endif
1337# endif /* PNG_PRIVATE */
1338# endif /* __GNUC__ */
1339#endif /* PNG_PEDANTIC_WARNINGS */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001340
1341#ifndef PNG_DEPRECATED
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001342# define PNG_DEPRECATED /* Use of this function is deprecated */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001343#endif
1344#ifndef PNG_USE_RESULT
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001345# define PNG_USE_RESULT /* The result of this function must be checked */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001346#endif
1347#ifndef PNG_NORETURN
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001348# define PNG_NORETURN /* This function does not return */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001349#endif
1350#ifndef PNG_ALLOCATED
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001351# define PNG_ALLOCATED /* The result of the function is new memory */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001352#endif
1353#ifndef PNG_DEPSTRUCT
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001354# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001355#endif
Glenn Randers-Pehrson4e1e1992009-11-12 08:29:21 -06001356#ifndef PNG_PRIVATE
1357# define PNG_PRIVATE /* This is a private libpng function */
1358#endif
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -06001359
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001360/* Users may want to use these so they are not private. Any library
1361 * functions that are passed far data must be model-independent.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001362 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001363
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001364/* memory model/platform independent fns */
1365#ifndef PNG_ABORT
1366# ifdef _WINDOWS_
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001367# define PNG_ABORT() ExitProcess(0)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001368# else
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001369# define PNG_ABORT() abort()
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001370# endif
1371#endif
1372
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -05001373#ifdef USE_FAR_KEYWORD
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001374/* Use this to make far-to-near assignments */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001375# define CHECK 1
1376# define NOCHECK 0
1377# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
1378# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001379# define png_strcpy _fstrcpy
1380# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
1381# define png_strlen _fstrlen
1382# define png_memcmp _fmemcmp /* SJT: added */
1383# define png_memcpy _fmemcpy
Glenn Randers-Pehrson8551d592009-08-29 16:25:19 -05001384# define png_memset _fmemset
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001385# define png_sprintf sprintf
1386#else
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -06001387# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001388# define CVT_PTR(ptr) (ptr)
1389# define CVT_PTR_NOCHECK(ptr) (ptr)
1390# define png_strcpy lstrcpyA
1391# define png_strncpy lstrcpynA
1392# define png_strlen lstrlenA
1393# define png_memcmp memcmp
1394# define png_memcpy CopyMemory
1395# define png_memset memset
1396# define png_sprintf wsprintfA
1397# else
1398# define CVT_PTR(ptr) (ptr)
1399# define CVT_PTR_NOCHECK(ptr) (ptr)
1400# define png_strcpy strcpy
1401# define png_strncpy strncpy /* Added to v 1.2.6 */
1402# define png_strlen strlen
1403# define png_memcmp memcmp /* SJT: added */
1404# define png_memcpy memcpy
1405# define png_memset memset
1406# define png_sprintf sprintf
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001407# ifndef PNG_NO_SNPRINTF
1408# ifdef _MSC_VER
1409# define png_snprintf _snprintf /* Added to v 1.2.19 */
1410# define png_snprintf2 _snprintf
1411# define png_snprintf6 _snprintf
1412# else
1413# define png_snprintf snprintf /* Added to v 1.2.19 */
1414# define png_snprintf2 snprintf
1415# define png_snprintf6 snprintf
1416# endif
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001417# else
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -05001418 /* You don't have or don't want to use snprintf(). Caution: Using
1419 * sprintf instead of snprintf exposes your application to accidental
1420 * or malevolent buffer overflows. If you don't have snprintf()
1421 * as a general rule you should provide one (you can get one from
1422 * Portable OpenSSH).
1423 */
1424# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
1425# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
1426# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
1427 sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05001428# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001429# endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001430#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001431
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001432/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
1433 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
1434 * to png_alloc_size_t are not necessary; in fact, it is recommended
1435 * not to use them at all so that the compiler can complain when something
1436 * turns out to be problematic.
1437 * Casts in the other direction (from png_alloc_size_t to png_size_t or
1438 * png_uint_32) should be explicitly applied; however, we do not expect
1439 * to encounter practical situations that require such conversions.
1440 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001441#if defined(__TURBOC__) && !defined(__FLAT__)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001442# define png_mem_alloc farmalloc
1443# define png_mem_free farfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001444 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001445#else
1446# if defined(_MSC_VER) && defined(MAXSEG_64K)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001447# define png_mem_alloc(s) halloc(s, 1)
1448# define png_mem_free hfree
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001449 typedef unsigned long png_alloc_size_t;
1450# else
1451# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001452# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
1453# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001454 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001455# else
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -06001456# define png_mem_alloc malloc
1457# define png_mem_free free
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05001458 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05001459# endif
1460# endif
1461#endif
1462/* End of memory model/platform independent support */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001463
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06001464/* Just a little check that someone hasn't tried to define something
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001465 * contradictory.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001466 */
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001467#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001468# undef PNG_ZBUF_SIZE
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001469# define PNG_ZBUF_SIZE 65536L
Andreas Dilger47a0c421997-05-16 02:46:07 -05001470#endif
1471
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06001472
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001473/* Added at libpng-1.2.8 */
1474#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06001475
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001476#endif /* PNGCONF_H */