Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
 *
3
 * libpng version 1.6.5 - September 14, 2013
4
 *
5
 * Copyright (c) 1998-2013 Glenn Randers-Pehrson
6
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8
 *
9
 * This code is released under the libpng license.
10
 * For conditions of distribution and use, see the disclaimer
11
 * and license in png.h
12
 *
13
 */
14
15
 
16
 * are configuring libpng for a machine, you may want to read the section
17
 * starting here down to where it starts to typedef png_color, png_text,
18
 * and png_info.
19
 */
20
21
 
22
#define PNGCONF_H
23
24
 
25
#ifdef PNG_SAFE_LIMITS_SUPPORTED
26
#  ifdef PNG_USER_WIDTH_MAX
27
#    undef PNG_USER_WIDTH_MAX
28
#    define PNG_USER_WIDTH_MAX 1000000L
29
#  endif
30
#  ifdef PNG_USER_HEIGHT_MAX
31
#    undef PNG_USER_HEIGHT_MAX
32
#    define PNG_USER_HEIGHT_MAX 1000000L
33
#  endif
34
#  ifdef PNG_USER_CHUNK_MALLOC_MAX
35
#    undef PNG_USER_CHUNK_MALLOC_MAX
36
#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L
37
#  endif
38
#  ifdef PNG_USER_CHUNK_CACHE_MAX
39
#    undef PNG_USER_CHUNK_CACHE_MAX
40
#    define PNG_USER_CHUNK_CACHE_MAX 128
41
#  endif
42
#endif
43
44
 
45
46
 
47
 * compiler for correct compilation.  The following header files are required by
48
 * the standard.  If your compiler doesn't provide these header files, or they
49
 * do not match the standard, you will need to provide/improve them.
50
 */
51
#include 
52
#include 
53
54
 
55
 * expects conformant implementations, however, an ISOC90 conformant system need
56
 * not provide these header files if the functionality cannot be implemented.
57
 * In this case it will be necessary to disable the relevant parts of libpng in
58
 * the build of pnglibconf.h.
59
 *
60
 * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
61
 * include this unnecessary header file.
62
 */
63
64
 
65
   /* Required for the definition of FILE: */
66
#  include 
67
#endif
68
69
 
70
   /* Required for the definition of jmp_buf and the declaration of longjmp: */
71
#  include 
72
#endif
73
74
 
75
   /* Required for struct tm: */
76
#  include 
77
#endif
78
79
 
80
81
 
82
 * PNG_NO_CONST; this is no longer supported except for data declarations which
83
 * apparently still cause problems in 2011 on some compilers.
84
 */
85
#define PNG_CONST const /* backward compatibility only */
86
87
 
88
 * from PNG files.  It can be set on a per-app-file basis - it
89
 * just changes whether a macro is used when the function is called.
90
 * The library builder sets the default; if read functions are not
91
 * built into the library the macro implementation is forced on.
92
 */
93
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
94
#  define PNG_USE_READ_MACROS
95
#endif
96
#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
97
#  if PNG_DEFAULT_READ_MACROS
98
#    define PNG_USE_READ_MACROS
99
#  endif
100
#endif
101
102
 
103
 *
104
 * These options are provided so that a variety of difficult compilers
105
 * can be used.  Some are fixed at build time (e.g. PNG_API_RULE
106
 * below) but still have compiler specific implementations, others
107
 * may be changed on a per-file basis when compiling against libpng.
108
 */
109
110
 
111
 * against legacy (pre ISOC90) compilers that did not understand function
112
 * prototypes.  It is not required for modern C compilers.
113
 */
114
#ifndef PNGARG
115
#  define PNGARG(arglist) arglist
116
#endif
117
118
 
119
 * =============================
120
 * Normally it is not necessary to specify to the compiler how to call
121
 * a function - it just does it - however on x86 systems derived from
122
 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
123
 * and some others) there are multiple ways to call a function and the
124
 * default can be changed on the compiler command line.  For this reason
125
 * libpng specifies the calling convention of every exported function and
126
 * every function called via a user supplied function pointer.  This is
127
 * done in this file by defining the following macros:
128
 *
129
 * PNGAPI    Calling convention for exported functions.
130
 * PNGCBAPI  Calling convention for user provided (callback) functions.
131
 * PNGCAPI   Calling convention used by the ANSI-C library (required
132
 *           for longjmp callbacks and sometimes used internally to
133
 *           specify the calling convention for zlib).
134
 *
135
 * These macros should never be overridden.  If it is necessary to
136
 * change calling convention in a private build this can be done
137
 * by setting PNG_API_RULE (which defaults to 0) to one of the values
138
 * below to select the correct 'API' variants.
139
 *
140
 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
141
 *                This is correct in every known environment.
142
 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
143
 *                the 'C' calling convention (from PNGCAPI) for
144
 *                callbacks (PNGCBAPI).  This is no longer required
145
 *                in any known environment - if it has to be used
146
 *                please post an explanation of the problem to the
147
 *                libpng mailing list.
148
 *
149
 * These cases only differ if the operating system does not use the C
150
 * calling convention, at present this just means the above cases
151
 * (x86 DOS/Windows sytems) and, even then, this does not apply to
152
 * Cygwin running on those systems.
153
 *
154
 * Note that the value must be defined in pnglibconf.h so that what
155
 * the application uses to call the library matches the conventions
156
 * set when building the library.
157
 */
158
159
 
160
 * =============
161
 * When building a shared library it is almost always necessary to tell
162
 * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'
163
 * is used to mark the symbols.  On some systems these symbols can be
164
 * extracted at link time and need no special processing by the compiler,
165
 * on other systems the symbols are flagged by the compiler and just
166
 * the declaration requires a special tag applied (unfortunately) in a
167
 * compiler dependent way.  Some systems can do either.
168
 *
169
 * A small number of older systems also require a symbol from a DLL to
170
 * be flagged to the program that calls it.  This is a problem because
171
 * we do not know in the header file included by application code that
172
 * the symbol will come from a shared library, as opposed to a statically
173
 * linked one.  For this reason the application must tell us by setting
174
 * the magic flag PNG_USE_DLL to turn on the special processing before
175
 * it includes png.h.
176
 *
177
 * Four additional macros are used to make this happen:
178
 *
179
 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
180
 *            the build or imported if PNG_USE_DLL is set - compiler
181
 *            and system specific.
182
 *
183
 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
184
 *                       'type', compiler specific.
185
 *
186
 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
187
 *                make a symbol exported from the DLL.  Not used in the
188
 *                public header files; see pngpriv.h for how it is used
189
 *                in the libpng build.
190
 *
191
 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
192
 *                from a DLL - used to define PNG_IMPEXP when
193
 *                PNG_USE_DLL is set.
194
 */
195
196
 
197
 * ==========================
198
 * This code is used at build time to find PNG_IMPEXP, the API settings
199
 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
200
 * import processing is possible.  On Windows systems it also sets
201
 * compiler-specific macros to the values required to change the calling
202
 * conventions of the various functions.
203
 */
204
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
205
    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
206
  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or
207
   * MinGW on any architecture currently supported by Windows.  Also includes
208
   * Watcom builds but these need special treatment because they are not
209
   * compatible with GCC or Visual C because of different calling conventions.
210
   */
211
#  if PNG_API_RULE == 2
212
    /* If this line results in an error, either because __watcall is not
213
     * understood or because of a redefine just below you cannot use *this*
214
     * build of the library with the compiler you are using.  *This* build was
215
     * build using Watcom and applications must also be built using Watcom!
216
     */
217
#    define PNGCAPI __watcall
218
#  endif
219
220
 
221
#    define PNGCAPI __cdecl
222
#    if PNG_API_RULE == 1
223
       /* If this line results in an error __stdcall is not understood and
224
        * PNG_API_RULE should not have been set to '1'.
225
        */
226
#      define PNGAPI __stdcall
227
#    endif
228
#  else
229
    /* An older compiler, or one not detected (erroneously) above,
230
     * if necessary override on the command line to get the correct
231
     * variants for the compiler.
232
     */
233
#    ifndef PNGCAPI
234
#      define PNGCAPI _cdecl
235
#    endif
236
#    if PNG_API_RULE == 1 && !defined(PNGAPI)
237
#      define PNGAPI _stdcall
238
#    endif
239
#  endif /* compiler/api */
240
241
 
242
243
 
244
#     error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
245
#  endif
246
247
 
248
      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
249
    /* older Borland and MSC
250
     * compilers used '__export' and required this to be after
251
     * the type.
252
     */
253
#    ifndef PNG_EXPORT_TYPE
254
#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
255
#    endif
256
#    define PNG_DLL_EXPORT __export
257
#  else /* newer compiler */
258
#    define PNG_DLL_EXPORT __declspec(dllexport)
259
#    ifndef PNG_DLL_IMPORT
260
#      define PNG_DLL_IMPORT __declspec(dllimport)
261
#    endif
262
#  endif /* compiler */
263
264
 
265
#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
266
#    define PNGAPI _System
267
#  else /* !Windows/x86 && !OS/2 */
268
    /* Use the defaults, or define PNG*API on the command line (but
269
     * this will have to be done for every compile!)
270
     */
271
#  endif /* other system, !OS/2 */
272
#endif /* !Windows/x86 */
273
274
 
275
#ifndef PNGCAPI
276
#  define PNGCAPI
277
#endif
278
#ifndef PNGCBAPI
279
#  define PNGCBAPI PNGCAPI
280
#endif
281
#ifndef PNGAPI
282
#  define PNGAPI PNGCAPI
283
#endif
284
285
 
286
 * then in an internal header file when building the library, otherwise (when
287
 * using the library) it is set here.
288
 */
289
#ifndef PNG_IMPEXP
290
#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
291
     /* This forces use of a DLL, disallowing static linking */
292
#    define PNG_IMPEXP PNG_DLL_IMPORT
293
#  endif
294
295
 
296
#    define PNG_IMPEXP
297
#  endif
298
#endif
299
300
 
301
 * 'attributes' as a storage class - the attributes go at the start of the
302
 * function definition, and attributes are always appended regardless of the
303
 * compiler.  This considerably simplifies these macros but may cause problems
304
 * if any compilers both need function attributes and fail to handle them as
305
 * a storage class (this is unlikely.)
306
 */
307
#ifndef PNG_FUNCTION
308
#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args
309
#endif
310
311
 
312
#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
313
#endif
314
315
 
316
    * table entries, so we discard it here.  See the .dfn files in the
317
    * scripts directory.
318
    */
319
#ifndef PNG_EXPORTA
320
321
 
322
      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
323
        extern attributes)
324
#endif
325
326
 
327
 * so make something non-empty to satisfy the requirement:
328
 */
329
#define PNG_EMPTY /*empty list*/
330
331
 
332
   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
333
334
 
335
#ifndef PNG_REMOVED
336
#  define PNG_REMOVED(ordinal, type, name, args, attributes)
337
#endif
338
339
 
340
#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
341
#endif
342
343
 
344
 * so that where compiler support is available incorrect use of API
345
 * functions in png.h will generate compiler warnings.
346
 *
347
 * Added at libpng-1.2.41.
348
 */
349
350
 
351
#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
352
#    define PNG_PEDANTIC_WARNINGS_SUPPORTED
353
#  endif
354
#endif
355
356
 
357
  /* Support for compiler specific function attributes.  These are used
358
   * so that where compiler support is available, incorrect use of API
359
   * functions in png.h will generate compiler warnings.  Added at libpng
360
   * version 1.2.41.  Disabling these removes the warnings but may also produce
361
   * less efficient code.
362
   */
363
#  if defined(__GNUC__)
364
#    ifndef PNG_USE_RESULT
365
#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
366
#    endif
367
#    ifndef PNG_NORETURN
368
#      define PNG_NORETURN   __attribute__((__noreturn__))
369
#    endif
370
#    if __GNUC__ >= 3
371
#      ifndef PNG_ALLOCATED
372
#        define PNG_ALLOCATED  __attribute__((__malloc__))
373
#      endif
374
#      ifndef PNG_DEPRECATED
375
#        define PNG_DEPRECATED __attribute__((__deprecated__))
376
#      endif
377
#      ifndef PNG_PRIVATE
378
#        if 0 /* Doesn't work so we use deprecated instead*/
379
#          define PNG_PRIVATE \
380
            __attribute__((warning("This function is not exported by libpng.")))
381
#        else
382
#          define PNG_PRIVATE \
383
            __attribute__((__deprecated__))
384
#        endif
385
#      endif
386
#      if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
387
#        ifndef PNG_RESTRICT
388
#          define PNG_RESTRICT __restrict
389
#        endif
390
#      endif /*  __GNUC__ == 3.0 */
391
#    endif /*  __GNUC__ >= 3 */
392
393
 
394
#    ifndef PNG_USE_RESULT
395
#      define PNG_USE_RESULT /* not supported */
396
#    endif
397
#    ifndef PNG_NORETURN
398
#      define PNG_NORETURN   __declspec(noreturn)
399
#    endif
400
#    ifndef PNG_ALLOCATED
401
#      if (_MSC_VER >= 1400)
402
#        define PNG_ALLOCATED __declspec(restrict)
403
#      endif
404
#    endif
405
#    ifndef PNG_DEPRECATED
406
#      define PNG_DEPRECATED __declspec(deprecated)
407
#    endif
408
#    ifndef PNG_PRIVATE
409
#      define PNG_PRIVATE __declspec(deprecated)
410
#    endif
411
#    ifndef PNG_RESTRICT
412
#      if (_MSC_VER >= 1400)
413
#        define PNG_RESTRICT __restrict
414
#      endif
415
#    endif
416
417
 
418
#    ifndef PNG_RESTRICT
419
#      define PNG_RESTRICT __restrict
420
#    endif
421
#  endif /* _MSC_VER */
422
#endif /* PNG_PEDANTIC_WARNINGS */
423
424
 
425
#  define PNG_DEPRECATED  /* Use of this function is deprecated */
426
#endif
427
#ifndef PNG_USE_RESULT
428
#  define PNG_USE_RESULT  /* The result of this function must be checked */
429
#endif
430
#ifndef PNG_NORETURN
431
#  define PNG_NORETURN    /* This function does not return */
432
#endif
433
#ifndef PNG_ALLOCATED
434
#  define PNG_ALLOCATED   /* The result of the function is new memory */
435
#endif
436
#ifndef PNG_PRIVATE
437
#  define PNG_PRIVATE     /* This is a private libpng function */
438
#endif
439
#ifndef PNG_RESTRICT
440
#  define PNG_RESTRICT    /* The C99 "restrict" feature */
441
#endif
442
#ifndef PNG_FP_EXPORT     /* A floating point API. */
443
#  ifdef PNG_FLOATING_POINT_SUPPORTED
444
#     define PNG_FP_EXPORT(ordinal, type, name, args)\
445
         PNG_EXPORT(ordinal, type, name, args);
446
#  else                   /* No floating point APIs */
447
#     define PNG_FP_EXPORT(ordinal, type, name, args)
448
#  endif
449
#endif
450
#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */
451
#  ifdef PNG_FIXED_POINT_SUPPORTED
452
#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\
453
         PNG_EXPORT(ordinal, type, name, args);
454
#  else                   /* No fixed point APIs */
455
#     define PNG_FIXED_EXPORT(ordinal, type, name, args)
456
#  endif
457
#endif
458
459
 
460
/* Some typedefs to get us started.  These should be safe on most of the common
461
 * platforms.
462
 *
463
 * png_uint_32 and png_int_32 may, currently, be larger than required to hold a
464
 * 32-bit value however this is not normally advisable.
465
 *
466
 * png_uint_16 and png_int_16 should always be two bytes in size - this is
467
 * verified at library build time.
468
 *
469
 * png_byte must always be one byte in size.
470
 *
471
 * The checks below use constants from limits.h, as defined by the ISOC90
472
 * standard.
473
 */
474
#if CHAR_BIT == 8 && UCHAR_MAX == 255
475
   typedef unsigned char png_byte;
476
#else
477
#  error "libpng requires 8 bit bytes"
478
#endif
479
480
 
481
   typedef int png_int_16;
482
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
483
   typedef short png_int_16;
484
#else
485
#  error "libpng requires a signed 16 bit type"
486
#endif
487
488
 
489
   typedef unsigned int png_uint_16;
490
#elif USHRT_MAX == 65535
491
   typedef unsigned short png_uint_16;
492
#else
493
#  error "libpng requires an unsigned 16 bit type"
494
#endif
495
496
 
497
   typedef int png_int_32;
498
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
499
   typedef long int png_int_32;
500
#else
501
#  error "libpng requires a signed 32 bit (or more) type"
502
#endif
503
504
 
505
   typedef unsigned int png_uint_32;
506
#elif ULONG_MAX > 4294967294
507
   typedef unsigned long int png_uint_32;
508
#else
509
#  error "libpng requires an unsigned 32 bit (or more) type"
510
#endif
511
512
 
513
 * requires an ISOC90 compiler and relies on consistent behavior of sizeof.
514
 */
515
typedef size_t png_size_t;
516
typedef ptrdiff_t png_ptrdiff_t;
517
518
 
519
 * definition of png_alloc_size_t, below.  This maximum value of size_t limits
520
 * but does not control the maximum allocations the library makes - there is
521
 * direct application control of this through png_set_user_limits().
522
 */
523
#ifndef PNG_SMALL_SIZE_T
524
   /* Compiler specific tests for systems where size_t is known to be less than
525
    * 32 bits (some of these systems may no longer work because of the lack of
526
    * 'far' support; see above.)
527
    */
528
#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
529
   (defined(_MSC_VER) && defined(MAXSEG_64K))
530
#     define PNG_SMALL_SIZE_T
531
#  endif
532
#endif
533
534
 
535
 * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to
536
 * png_alloc_size_t are not necessary; in fact, it is recommended not to use
537
 * them at all so that the compiler can complain when something turns out to be
538
 * problematic.
539
 *
540
 * Casts in the other direction (from png_alloc_size_t to png_size_t or
541
 * png_uint_32) should be explicitly applied; however, we do not expect to
542
 * encounter practical situations that require such conversions.
543
 *
544
 * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
545
 * 4294967295 - i.e. less than the maximum value of png_uint_32.
546
 */
547
#ifdef PNG_SMALL_SIZE_T
548
   typedef png_uint_32 png_alloc_size_t;
549
#else
550
   typedef png_size_t png_alloc_size_t;
551
#endif
552
553
 
554
 * implementations of Intel CPU specific support of user-mode segmented address
555
 * spaces, where 16-bit pointers address more than 65536 bytes of memory using
556
 * separate 'segment' registers.  The implementation requires two different
557
 * types of pointer (only one of which includes the segment value.)
558
 *
559
 * If required this support is available in version 1.2 of libpng and may be
560
 * available in versions through 1.5, although the correctness of the code has
561
 * not been verified recently.
562
 */
563
564
 
565
 * multiple of 100,000, e.g., gamma
566
 */
567
typedef png_int_32 png_fixed_point;
568
569
 
570
typedef void                  * png_voidp;
571
typedef const void            * png_const_voidp;
572
typedef png_byte              * png_bytep;
573
typedef const png_byte        * png_const_bytep;
574
typedef png_uint_32           * png_uint_32p;
575
typedef const png_uint_32     * png_const_uint_32p;
576
typedef png_int_32            * png_int_32p;
577
typedef const png_int_32      * png_const_int_32p;
578
typedef png_uint_16           * png_uint_16p;
579
typedef const png_uint_16     * png_const_uint_16p;
580
typedef png_int_16            * png_int_16p;
581
typedef const png_int_16      * png_const_int_16p;
582
typedef char                  * png_charp;
583
typedef const char            * png_const_charp;
584
typedef png_fixed_point       * png_fixed_point_p;
585
typedef const png_fixed_point * png_const_fixed_point_p;
586
typedef png_size_t            * png_size_tp;
587
typedef const png_size_t      * png_const_size_tp;
588
589
 
590
typedef FILE            * png_FILE_p;
591
#endif
592
593
 
594
typedef double       * png_doublep;
595
typedef const double * png_const_doublep;
596
#endif
597
598
 
599
typedef png_byte        * * png_bytepp;
600
typedef png_uint_32     * * png_uint_32pp;
601
typedef png_int_32      * * png_int_32pp;
602
typedef png_uint_16     * * png_uint_16pp;
603
typedef png_int_16      * * png_int_16pp;
604
typedef const char      * * png_const_charpp;
605
typedef char            * * png_charpp;
606
typedef png_fixed_point * * png_fixed_point_pp;
607
#ifdef PNG_FLOATING_POINT_SUPPORTED
608
typedef double          * * png_doublepp;
609
#endif
610
611
 
612
typedef char            * * * png_charppp;
613
614
 
615
616
 
617