Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4680 right-hear 1
 
2
 *
3
 * libpng version 1.5.1 - February 3, 2011
4
 *
5
 * Copyright (c) 1998-2011 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
 * definition file for  machine specific limits, this may impact the
26
 * correctness of the definitons below (see uses of INT_MAX).
27
 */
28
#ifndef PNG_NO_LIMITS_H
29
#  include 
30
#endif
31
32
 
33
 * because this file defines png_memcpy and so on the base APIs must
34
 * be defined here.
35
 */
36
#ifdef BSD
37
#  include 
38
#else
39
#  include 
40
#endif
41
42
 
43
 * FILE
44
 */
45
#ifdef PNG_STDIO_SUPPORTED
46
#  include 
47
#endif
48
49
 
50
 * from PNG files.  It can be set on a per-app-file basis - it
51
 * just changes whether a macro is used to the function is called.
52
 * The library builder sets the default, if read functions are not
53
 * built into the library the macro implementation is forced on.
54
 */
55
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
56
#  define PNG_USE_READ_MACROS
57
#endif
58
#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
59
#  if PNG_DEFAULT_READ_MACROS
60
#    define PNG_USE_READ_MACROS
61
#  endif
62
#endif
63
64
 
65
 *
66
 * These options are provided so that a variety of difficult compilers
67
 * can be used.  Some are fixed at build time (e.g. PNG_API_RULE
68
 * below) but still have compiler specific implementations, others
69
 * may be changed on a per-file basis when compiling against libpng.
70
 */
71
72
 
73
 * prototypes (ie K&R style headers).  If your compiler does not handle
74
 * function prototypes, define this macro and use the included ansi2knr.
75
 * I've always been able to use _NO_PROTO as the indicator, but you may
76
 * need to drag the empty declaration out in front of here, or change the
77
 * ifdef to suit your own needs.
78
 */
79
#ifndef PNGARG
80
81
 
82
#    define PNGARG(arglist) OF(arglist)
83
#  else
84
85
 
86
#      define PNGARG(arglist) ()
87
#    else
88
#      define PNGARG(arglist) arglist
89
#    endif /* _NO_PROTO */
90
91
 
92
93
 
94
95
 
96
 * =============================
97
 * Normally it is not necessary to specify to the compiler how to call
98
 * a function - it just does it - however on x86 systems derived from
99
 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
100
 * and some others) there are multiple ways to call a function and the
101
 * default can be changed on the compiler command line.  For this reason
102
 * libpng specifies the calling convention of every exported function and
103
 * every function called via a user supplied function pointer.  This is
104
 * done in this file by defining the following macros:
105
 *
106
 * PNGAPI    Calling convention for exported functions.
107
 * PNGCBAPI  Calling convention for user provided (callback) functions.
108
 * PNGCAPI   Calling convention used by the ANSI-C library (required
109
 *           for longjmp callbacks and sometimes used internally to
110
 *           specify the calling convention for zlib).
111
 *
112
 * These macros should never be overridden.  If it is necessary to
113
 * change calling convention in a private build this can be done
114
 * by setting PNG_API_RULE (which defaults to 0) to one of the values
115
 * below to select the correct 'API' variants.
116
 *
117
 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
118
 *                This is correct in every known environment.
119
 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
120
 *                the 'C' calling convention (from PNGCAPI) for
121
 *                callbacks (PNGCBAPI).  This is no longer required
122
 *                in any known environment - if it has to be used
123
 *                please post an explanation of the problem to the
124
 *                libpng mailing list.
125
 *
126
 * These cases only differ if the operating system does not use the C
127
 * calling convention, at present this just means the above cases
128
 * (x86 DOS/Windows sytems) and, even then, this does not apply to
129
 * Cygwin running on those systems.
130
 *
131
 * Note that the value must be defined in pnglibconf.h so that what
132
 * the application uses to call the library matches the conventions
133
 * set when building the library.
134
 */
135
136
 
137
 * =============
138
 * When building a shared library it is almost always necessary to tell
139
 * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'
140
 * is used to mark the symbols.  On some systems these symbols can be
141
 * extracted at link time and need no special processing by the compiler,
142
 * on other systems the symbols are flagged by the compiler and just
143
 * the declaration requires a special tag applied (unfortunately) in a
144
 * compiler dependent way.  Some systems can do either.
145
 *
146
 * A small number of older systems also require a symbol from a DLL to
147
 * be flagged to the program that calls it.  This is a problem because
148
 * we do not know in the header file included by application code that
149
 * the symbol will come from a shared library, as opposed to a statically
150
 * linked one.  For this reason the application must tell us by setting
151
 * the magic flag PNG_USE_DLL to turn on the special processing before
152
 * it includes png.h.
153
 *
154
 * Four additional macros are used to make this happen:
155
 *
156
 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
157
 *            the build or imported if PNG_USE_DLL is set - compiler
158
 *            and system specific.
159
 *
160
 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
161
 *                       'type', compiler specific.
162
 *
163
 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
164
 *                make a symbol exported from the DLL.
165
 *
166
 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
167
 *                from a DLL - used to define PNG_IMPEXP when
168
 *                PNG_USE_DLL is set.
169
 */
170
171
 
172
 * ==========================
173
 * This code is used at build time to find PNG_IMPEXP, the API settings
174
 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
175
 * import processing is possible.  On Windows/x86 systems it also sets
176
 * compiler-specific macros to the values required to change the calling
177
 * conventions of the various functions.
178
 */
179
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
180
      defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
181
    ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
182
      defined(_M_X64) || defined(_M_IA64) )
183
  /* Windows system (DOS doesn't support DLLs) running on x86/x64.  Includes
184
   * builds under Cygwin or MinGW.  Also includes Watcom builds but these need
185
   * special treatment because they are not compatible with GCC or Visual C
186
   * because of different calling conventions.
187
   */
188
#  if PNG_API_RULE == 2
189
    /* If this line results in an error, either because __watcall is not
190
     * understood or because of a redefine just below you cannot use *this*
191
     * build of the library with the compiler you are using.  *This* build was
192
     * build using Watcom and applications must also be built using Watcom!
193
     */
194
#    define PNGCAPI __watcall
195
#  endif
196
197
 
198
#    define PNGCAPI __cdecl
199
#    if PNG_API_RULE == 1
200
#      define PNGAPI __stdcall
201
#    endif
202
#  else
203
    /* An older compiler, or one not detected (erroneously) above,
204
     * if necessary override on the command line to get the correct
205
     * variants for the compiler.
206
     */
207
#    ifndef PNGCAPI
208
#      define PNGCAPI _cdecl
209
#    endif
210
#    if PNG_API_RULE == 1 && !defined(PNGAPI)
211
#      define PNGAPI _stdcall
212
#    endif
213
#  endif /* compiler/api */
214
  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
215
216
 
217
   ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
218
#  endif
219
220
 
221
      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
222
    /* older Borland and MSC
223
     * compilers used '__export' and required this to be after
224
     * the type.
225
     */
226
#    ifndef PNG_EXPORT_TYPE
227
#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
228
#    endif
229
#    define PNG_DLL_EXPORT __export
230
#  else /* newer compiler */
231
#    define PNG_DLL_EXPORT __declspec(dllexport)
232
#    ifndef PNG_DLL_IMPORT
233
#      define PNG_DLL_IMPORT __declspec(dllimport)
234
#    endif
235
#  endif /* compiler */
236
237
 
238
#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
239
#    define PNGAPI _System
240
#  else /* !Windows/x86 && !OS/2 */
241
    /* Use the defaults, or define PNG*API on the command line (but
242
     * this will have to be done for every compile!)
243
     */
244
#  endif /* other system, !OS/2 */
245
#endif /* !Windows/x86 */
246
247
 
248
#ifndef PNGCAPI
249
#  define PNGCAPI
250
#endif
251
#ifndef PNGCBAPI
252
#  define PNGCBAPI PNGCAPI
253
#endif
254
#ifndef PNGAPI
255
#  define PNGAPI PNGCAPI
256
#endif
257
258
 
259
 * being built or used.
260
 */
261
#ifndef PNG_IMPEXP
262
#  ifdef PNGLIB_BUILD
263
    /* Building the library */
264
#    if (defined(DLL_EXPORT)/*from libtool*/ ||\
265
        defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
266
        defined(_USRDLL) ||\
267
        defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
268
      /* Building a DLL. */
269
#      define PNG_IMPEXP PNG_DLL_EXPORT
270
#    endif /* DLL */
271
#  else
272
    /* Using the library */
273
#    if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
274
      /* This forces use of a DLL, disallowing static linking */
275
#      define PNG_IMPEXP PNG_DLL_IMPORT
276
#    endif
277
#  endif
278
279
 
280
#    define PNG_IMPEXP
281
#  endif
282
#endif
283
284
 
285
 * declared function in the correct place.  This potentially requires a separate
286
 * PNG_EXPORT function for every compiler.
287
 */
288
#ifndef PNG_FUNCTION
289
#  ifdef __GNUC__
290
#     define PNG_FUNCTION(type, name, args, attributes)\
291
         attributes type name args
292
#  else /* !GNUC */
293
#     ifdef _MSC_VER
294
#        define PNG_FUNCTION(type, name, args, attributes)\
295
         attributes type name args
296
#     else /* !MSC */
297
#        define PNG_FUNCTION(type, name, args, attributes)\
298
            type name args
299
#     endif
300
#  endif
301
#endif
302
303
 
304
#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
305
#endif
306
307
 
308
    * table entries, so we discard it here.  See the .dfn files in the
309
    * scripts directory.
310
    */
311
#ifndef PNG_EXPORTA
312
#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\
313
      extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
314
         attributes)
315
#endif
316
317
 
318
   PNG_EXPORTA(ordinal, type, name, args, )
319
320
 
321
#ifndef PNG_REMOVED
322
#  define PNG_REMOVED(ordinal, type, name, args, attributes)
323
#endif
324
325
 
326
#  define PNG_CALLBACK(type, name, args, attributes)\
327
   type (PNGCBAPI name) PNGARG(args) attributes
328
#endif
329
330
 
331
 * so that where compiler support is available incorrect use of API
332
 * functions in png.h will generate compiler warnings.
333
 *
334
 * Added at libpng-1.2.41.
335
 */
336
337
 
338
#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
339
#    define PNG_PEDANTIC_WARNINGS_SUPPORTED
340
#  endif
341
#endif
342
343
 
344
  /* Support for compiler specific function attributes.  These are used
345
   * so that where compiler support is available incorrect use of API
346
   * functions in png.h will generate compiler warnings.  Added at libpng
347
   * version 1.2.41.
348
   */
349
#  ifdef __GNUC__
350
#    ifndef PNG_USE_RESULT
351
#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
352
#    endif
353
#    ifndef PNG_NORETURN
354
#      define PNG_NORETURN   __attribute__((__noreturn__))
355
#    endif
356
#    ifndef PNG_PTR_NORETURN
357
#      define PNG_PTR_NORETURN   __attribute__((__noreturn__))
358
#    endif
359
#    ifndef PNG_ALLOCATED
360
#      define PNG_ALLOCATED  __attribute__((__malloc__))
361
#    endif
362
363
 
364
     * accessed from within the library, therefore should be empty during
365
     * a library build.
366
     */
367
#    ifndef PNGLIB_BUILD
368
#      ifndef PNG_DEPRECATED
369
#        define PNG_DEPRECATED __attribute__((__deprecated__))
370
#      endif
371
#      ifndef PNG_DEPSTRUCT
372
#        define PNG_DEPSTRUCT  __attribute__((__deprecated__))
373
#      endif
374
#      ifndef PNG_PRIVATE
375
#        if 0 /* Doesn't work so we use deprecated instead*/
376
#          define PNG_PRIVATE \
377
            __attribute__((warning("This function is not exported by libpng.")))
378
#        else
379
#          define PNG_PRIVATE \
380
            __attribute__((__deprecated__))
381
#        endif
382
#      endif /* PNG_PRIVATE */
383
#    endif /* PNGLIB_BUILD */
384
#  endif /* __GNUC__ */
385
#  ifdef _MSC_VER /* may need to check value */
386
#    ifndef PNG_USE_RESULT
387
#      define PNG_USE_RESULT /*not supported*/
388
#    endif
389
#    ifndef PNG_NORETURN
390
#      define PNG_NORETURN   __declspec(noreturn)
391
#    endif
392
#    ifndef PNG_PTR_NORETURN
393
#      define PNG_PTR_NORETURN /*not supported*/
394
#    endif
395
#    ifndef PNG_ALLOCATED
396
#      define PNG_ALLOCATED __declspec(restrict)
397
#    endif
398
399
 
400
     * accessed from within the library, therefore should be empty during
401
     * a library build.
402
     */
403
#    ifndef PNGLIB_BUILD
404
#      ifndef PNG_DEPRECATED
405
#        define PNG_DEPRECATED __declspec(deprecated)
406
#      endif
407
#      ifndef PNG_DEPSTRUCT
408
#        define PNG_DEPSTRUCT  __declspec(deprecated)
409
#      endif
410
#      ifndef PNG_PRIVATE
411
#        define PNG_PRIVATE __declspec(deprecated)
412
#      endif /* PNG_PRIVATE */
413
#    endif /* PNGLIB_BUILD */
414
#  endif /* __GNUC__ */
415
#endif /* PNG_PEDANTIC_WARNINGS */
416
417
 
418
#  define PNG_DEPRECATED  /* Use of this function is deprecated */
419
#endif
420
#ifndef PNG_USE_RESULT
421
#  define PNG_USE_RESULT  /* The result of this function must be checked */
422
#endif
423
#ifndef PNG_NORETURN
424
#  define PNG_NORETURN    /* This function does not return */
425
#endif
426
#ifndef PNG_ALLOCATED
427
#  define PNG_ALLOCATED   /* The result of the function is new memory */
428
#endif
429
#ifndef PNG_DEPSTRUCT
430
#  define PNG_DEPSTRUCT   /* Access to this struct member is deprecated */
431
#endif
432
#ifndef PNG_PRIVATE
433
#  define PNG_PRIVATE     /* This is a private libpng function */
434
#endif
435
#ifndef PNG_FP_EXPORT     /* A floating point API. */
436
#  ifdef PNG_FLOATING_POINT_SUPPORTED
437
#     define PNG_FP_EXPORT(ordinal, type, name, args)\
438
         PNG_EXPORT(ordinal, type, name, args)
439
#  else                   /* No floating point APIs */
440
#     define PNG_FP_EXPORT(ordinal, type, name, args)
441
#  endif
442
#endif
443
#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */
444
#  ifdef PNG_FIXED_POINT_SUPPORTED
445
#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\
446
         PNG_EXPORT(ordinal, type, name, args)
447
#  else                   /* No fixed point APIs */
448
#     define PNG_FIXED_EXPORT(ordinal, type, name, args)
449
#  endif
450
#endif
451
452
 
453
 * and warning message functions, so some compilers won't complain.
454
 * If you do not want to use const, define PNG_NO_CONST here.
455
 *
456
 * This should not change how the APIs are called, so it can be done
457
 * on a per-file basis in the application.
458
 */
459
#ifndef PNG_CONST
460
#  ifndef PNG_NO_CONST
461
#    define PNG_CONST const
462
#  else
463
#    define PNG_CONST
464
#  endif
465
#endif
466
467
 
468
 * common platforms.  The typedefs should be at least as large as the
469
 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
470
 * don't have to be exactly that size.  Some compilers dislike passing
471
 * unsigned shorts as function parameters, so you may be better off using
472
 * unsigned int for png_uint_16.
473
 */
474
475
 
476
typedef unsigned int png_uint_32;
477
typedef int png_int_32;
478
#else
479
typedef unsigned long png_uint_32;
480
typedef long png_int_32;
481
#endif
482
typedef unsigned short png_uint_16;
483
typedef short png_int_16;
484
typedef unsigned char png_byte;
485
486
 
487
typedef unsigned int png_size_t;
488
#else
489
typedef size_t png_size_t;
490
#endif
491
#define png_sizeof(x) (sizeof (x))
492
493
 
494
 * pngpriv.h header.  Needs modification for other compilers besides
495
 * MSC.  Model independent support declares all arrays and pointers to be
496
 * large using the far keyword.  The zlib version used must also support
497
 * model independent data.  As of version zlib 1.0.4, the necessary changes
498
 * have been made in zlib.  The USE_FAR_KEYWORD define triggers other
499
 * changes that are needed. (Tim Wegner)
500
 */
501
502
 
503
 * defines FAR. (SJT)
504
 */
505
#ifdef __BORLANDC__
506
#  if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
507
#    define LDATA 1
508
#  else
509
#    define LDATA 0
510
#  endif
511
  /* GRR:  why is Cygwin in here?  Cygwin is not Borland C... */
512
#  if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
513
#    define PNG_MAX_MALLOC_64K /* only used in build */
514
#    if (LDATA != 1)
515
#      ifndef FAR
516
#        define FAR __far
517
#      endif
518
#      define USE_FAR_KEYWORD
519
#    endif   /* LDATA != 1 */
520
         /* Possibly useful for moving data out of default segment.
521
          * Uncomment it if you want. Could also define FARDATA as
522
          * const if your compiler supports it. (SJT)
523
#        define FARDATA FAR
524
          */
525
#  endif  /* __WIN32__, __FLAT__, __CYGWIN__ */
526
#endif   /* __BORLANDC__ */
527
528
 
529
 
530
 * FAR.  The Watcom compiler defines both __MEDIUM__ and M_I86MM,
531
 * making reliance oncertain keywords suspect. (SJT)
532
 */
533
534
 
535
#ifdef FAR
536
#  ifdef M_I86MM
537
#    define USE_FAR_KEYWORD
538
#    define FARDATA FAR
539
#    include 
540
#  endif
541
#endif
542
543
 
544
#ifndef FAR
545
#  define FAR
546
#endif
547
548
 
549
#ifndef FARDATA
550
#  define FARDATA
551
#endif
552
553
 
554
 * to fixed-point with a multiple of 100,000, e.g., gamma
555
 */
556
typedef png_int_32 png_fixed_point;
557
558
 
559
typedef void                      FAR * png_voidp;
560
typedef PNG_CONST void            FAR * png_const_voidp;
561
typedef png_byte                  FAR * png_bytep;
562
typedef PNG_CONST png_byte        FAR * png_const_bytep;
563
typedef png_uint_32               FAR * png_uint_32p;
564
typedef PNG_CONST png_uint_32     FAR * png_const_uint_32p;
565
typedef png_int_32                FAR * png_int_32p;
566
typedef PNG_CONST png_int_32      FAR * png_const_int_32p;
567
typedef png_uint_16               FAR * png_uint_16p;
568
typedef PNG_CONST png_uint_16     FAR * png_const_uint_16p;
569
typedef png_int_16                FAR * png_int_16p;
570
typedef PNG_CONST png_int_16      FAR * png_const_int_16p;
571
typedef char                      FAR * png_charp;
572
typedef PNG_CONST char            FAR * png_const_charp;
573
typedef png_fixed_point           FAR * png_fixed_point_p;
574
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
575
typedef png_size_t                FAR * png_size_tp;
576
typedef PNG_CONST png_size_t      FAR * png_const_size_tp;
577
578
 
579
typedef FILE            * png_FILE_p;
580
#endif
581
582
 
583
typedef double           FAR * png_doublep;
584
typedef PNG_CONST double FAR * png_const_doublep;
585
#endif
586
587
 
588
typedef png_byte        FAR * FAR * png_bytepp;
589
typedef png_uint_32     FAR * FAR * png_uint_32pp;
590
typedef png_int_32      FAR * FAR * png_int_32pp;
591
typedef png_uint_16     FAR * FAR * png_uint_16pp;
592
typedef png_int_16      FAR * FAR * png_int_16pp;
593
typedef PNG_CONST char  FAR * FAR * png_const_charpp;
594
typedef char            FAR * FAR * png_charpp;
595
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
596
#ifdef PNG_FLOATING_POINT_SUPPORTED
597
typedef double          FAR * FAR * png_doublepp;
598
#endif
599
600
 
601
typedef char            FAR * FAR * FAR * png_charppp;
602
603
 
604
 * and no smaller than png_uint_32.  Casts from png_size_t or png_uint_32
605
 * to png_alloc_size_t are not necessary; in fact, it is recommended
606
 * not to use them at all so that the compiler can complain when something
607
 * turns out to be problematic.
608
 * Casts in the other direction (from png_alloc_size_t to png_size_t or
609
 * png_uint_32) should be explicitly applied; however, we do not expect
610
 * to encounter practical situations that require such conversions.
611
 */
612
#if defined(__TURBOC__) && !defined(__FLAT__)
613
   typedef unsigned long png_alloc_size_t;
614
#else
615
#  if defined(_MSC_VER) && defined(MAXSEG_64K)
616
     typedef unsigned long    png_alloc_size_t;
617
#  else
618
     /* This is an attempt to detect an old Windows system where (int) is
619
      * actually 16 bits, in that case png_malloc must have an argument with a
620
      * bigger size to accomodate the requirements of the library.
621
      */
622
#    if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
623
        (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
624
       typedef DWORD         png_alloc_size_t;
625
#    else
626
       typedef png_size_t    png_alloc_size_t;
627
#    endif
628
#  endif
629
#endif
630
631
 
632