Skip to content

Commit

Permalink
[libpng16] Added ANSI-C (C90) headers; eliminated the use of FAR/far.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowler authored and Glenn Randers-Pehrson committed Nov 27, 2011
1 parent 2ddb252 commit baeb6d1
Show file tree
Hide file tree
Showing 25 changed files with 310 additions and 1,015 deletions.
19 changes: 17 additions & 2 deletions ANNOUNCE
@@ -1,5 +1,5 @@

Libpng 1.6.0alpha01 - November 24, 2011
Libpng 1.6.0alpha01 - November 27, 2011

This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
Expand Down Expand Up @@ -107,10 +107,25 @@ Version 1.5.7beta05 [(PENDING RELEASE)]
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.

Version 1.6.0alpha01 [November 24, 2011]
Version 1.6.0alpha01 [November 27, 2011]
Added example programs for the new 'simplified' API.
Moved pngvalid.c into contrib/libtests
Rebuilt Makefile.in, configure, etc., with autoconf-2.68
Added ANSI-C (C90) headers and require them, and take advantage of the
change. Also fixed some of the projects/* and contrib/* files that needed
updates for libpng16 and the move of pngvalid.c.
With this change the required ANSI-C header files are assumed to exist: the
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
libpng relies on limits.h and stddef.h existing and behaving as defined
(the other two required headers aren't used). Non-ANSI systems that don't
have stddef.h or limits.h will have to provide an appropriate fake
containing the relevant types and #defines.
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
is now controlled by a flag so that 'small size_t' systems can select it
if necessary. Libpng 1.6 may not currently work on such systems -- it
seems likely that it will ask 'malloc' for more than 65535 bytes with any
image that has a sufficiently large row size (rather than simply failing
to read such images).

Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit
Expand Down
17 changes: 16 additions & 1 deletion CHANGES
Expand Up @@ -3752,10 +3752,25 @@ Version 1.5.7beta05 [(PENDING RELEASE)]
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.

Version 1.6.0alpha01 [November 24, 2011]
Version 1.6.0alpha01 [November 27, 2011]
Added example programs for the new 'simplified' API.
Moved pngvalid.c into contrib/libtests
Rebuilt Makefile.in, configure, etc., with autoconf-2.68
Added ANSI-C (C90) headers and require them, and take advantage of the
change. Also fixed some of the projects/* and contrib/* files that needed
updates for libpng16 and the move of pngvalid.c.
With this change the required ANSI-C header files are assumed to exist: the
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
libpng relies on limits.h and stddef.h existing and behaving as defined
(the other two required headers aren't used). Non-ANSI systems that don't
have stddef.h or limits.h will have to provide an appropriate fake
containing the relevant types and #defines.
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
is now controlled by a flag so that 'small size_t' systems can select it
if necessary. Libpng 1.6 may not currently work on such systems -- it
seems likely that it will ask 'malloc' for more than 65535 bytes with any
image that has a sufficiently large row size (rather than simply failing
to read such images).

Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
Expand Down
4 changes: 4 additions & 0 deletions contrib/libtests/pngstest.c
Expand Up @@ -22,6 +22,10 @@
#include <ctype.h>
#include <math.h>

#ifdef HAVE_CONFIG_H
# include "../../config.h"
#endif

#include "../../png.h"

#include "../sRGBtables/sRGB.h"
Expand Down
4 changes: 2 additions & 2 deletions contrib/libtests/pngvalid.c
Expand Up @@ -26,7 +26,7 @@
#include <signal.h>

#ifdef HAVE_CONFIG_H
# include "config.h"
# include "../../config.h"
#endif

#ifdef HAVE_FEENABLEEXCEPT
Expand Down Expand Up @@ -90,7 +90,7 @@ typedef png_byte *png_const_bytep;
#endif

/***************************** EXCEPTION HANDLING *****************************/
#include "contrib/visupng/cexcept.h"
#include "../visupng/cexcept.h"

#ifdef __cplusplus
# define this not_the_cpp_this
Expand Down
6 changes: 5 additions & 1 deletion contrib/libtests/timepng.c
Expand Up @@ -19,7 +19,11 @@

#include <time.h>

#include "png.h"
#ifdef HAVE_CONFIG_H
# include "../../config.h"
#endif

#include "../../png.h"

static int read_png(FILE *fp)
{
Expand Down
4 changes: 2 additions & 2 deletions png.c
Expand Up @@ -655,13 +655,13 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.6.0alpha01 - November 24, 2011" PNG_STRING_NEWLINE \
"libpng version 1.6.0alpha01 - November 27, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.6.0alpha01 - November 24, 2011\
return "libpng version 1.6.0alpha01 - November 27, 2011\
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
Expand Down
96 changes: 39 additions & 57 deletions png.h
@@ -1,7 +1,7 @@

/* png.h - header file for PNG reference library
*
* libpng version 1.6.0alpha01 - November 24, 2011
* libpng version 1.6.0alpha01 - November 27, 2011
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Expand All @@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.0alpha01 - November 24, 2011: Glenn
* libpng versions 0.97, January 1998, through 1.6.0alpha01 - November 27, 2011: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
Expand Down Expand Up @@ -196,7 +196,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.6.0alpha01, November 24, 2011, are
* libpng versions 1.2.6, August 15, 2004, through 1.6.0alpha01, November 27, 2011, are
* Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
Expand Down Expand Up @@ -308,7 +308,7 @@
* Y2K compliance in libpng:
* =========================
*
* November 24, 2011
* November 27, 2011
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
Expand Down Expand Up @@ -374,7 +374,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.0alpha01"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.0alpha01 - November 24, 2011\n"
" libpng version 1.6.0alpha01 - November 27, 2011\n"

#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
Expand Down Expand Up @@ -426,25 +426,7 @@
#endif

#ifndef PNG_VERSION_INFO_ONLY
# ifndef PNG_BUILDING_SYMBOL_TABLE
/*
* Standard header files (not needed for the version info or while
* building symbol table -- see scripts/pnglibconf.dfa)
*/
# ifdef PNG_SETJMP_SUPPORTED
# include <setjmp.h>
# endif

/* Need the time information for converting tIME chunks, it
* defines struct tm:
*/
# ifdef PNG_CONVERT_tIME_SUPPORTED
/* "time.h" functions are not supported on all operating systems */
# include <time.h>
# endif
# endif

/* Machine specific configuration. */
/* Machine specific configuration. */
# include "pngconf.h"
#endif

Expand Down Expand Up @@ -548,9 +530,9 @@ typedef struct png_color_struct
png_byte green;
png_byte blue;
} png_color;
typedef png_color FAR * png_colorp;
typedef PNG_CONST png_color FAR * png_const_colorp;
typedef png_color FAR * FAR * png_colorpp;
typedef png_color * png_colorp;
typedef const png_color * png_const_colorp;
typedef png_color * * png_colorpp;

typedef struct png_color_16_struct
{
Expand All @@ -560,9 +542,9 @@ typedef struct png_color_16_struct
png_uint_16 blue;
png_uint_16 gray; /* for use in grayscale files */
} png_color_16;
typedef png_color_16 FAR * png_color_16p;
typedef PNG_CONST png_color_16 FAR * png_const_color_16p;
typedef png_color_16 FAR * FAR * png_color_16pp;
typedef png_color_16 * png_color_16p;
typedef const png_color_16 * png_const_color_16p;
typedef png_color_16 * * png_color_16pp;

typedef struct png_color_8_struct
{
Expand All @@ -572,9 +554,9 @@ typedef struct png_color_8_struct
png_byte gray; /* for use in grayscale files */
png_byte alpha; /* for alpha channel files */
} png_color_8;
typedef png_color_8 FAR * png_color_8p;
typedef PNG_CONST png_color_8 FAR * png_const_color_8p;
typedef png_color_8 FAR * FAR * png_color_8pp;
typedef png_color_8 * png_color_8p;
typedef const png_color_8 * png_const_color_8p;
typedef png_color_8 * * png_color_8pp;

/*
* The following two structures are used for the in-core representation
Expand All @@ -588,9 +570,9 @@ typedef struct png_sPLT_entry_struct
png_uint_16 alpha;
png_uint_16 frequency;
} png_sPLT_entry;
typedef png_sPLT_entry FAR * png_sPLT_entryp;
typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp;
typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
typedef png_sPLT_entry * png_sPLT_entryp;
typedef const png_sPLT_entry * png_const_sPLT_entryp;
typedef png_sPLT_entry * * png_sPLT_entrypp;

/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
* occupy the LSB of their respective members, and the MSB of each member
Expand All @@ -604,9 +586,9 @@ typedef struct png_sPLT_struct
png_sPLT_entryp entries; /* palette entries */
png_int_32 nentries; /* number of palette entries */
} png_sPLT_t;
typedef png_sPLT_t FAR * png_sPLT_tp;
typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp;
typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
typedef png_sPLT_t * png_sPLT_tp;
typedef const png_sPLT_t * png_const_sPLT_tp;
typedef png_sPLT_t * * png_sPLT_tpp;

#ifdef PNG_TEXT_SUPPORTED
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
Expand Down Expand Up @@ -643,9 +625,9 @@ typedef struct png_text_struct
png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
chars or a NULL pointer */
} png_text;
typedef png_text FAR * png_textp;
typedef PNG_CONST png_text FAR * png_const_textp;
typedef png_text FAR * FAR * png_textpp;
typedef png_text * png_textp;
typedef const png_text * png_const_textp;
typedef png_text * * png_textpp;
#endif

/* Supported compression types for text in PNG files (tEXt, and zTXt).
Expand Down Expand Up @@ -673,9 +655,9 @@ typedef struct png_time_struct
png_byte minute; /* minute of hour, 0 - 59 */
png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
} png_time;
typedef png_time FAR * png_timep;
typedef PNG_CONST png_time FAR * png_const_timep;
typedef png_time FAR * FAR * png_timepp;
typedef png_time * png_timep;
typedef const png_time * png_const_timep;
typedef png_time * * png_timepp;

#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
Expand All @@ -696,9 +678,9 @@ typedef struct png_unknown_chunk_t


png_unknown_chunk;
typedef png_unknown_chunk FAR * png_unknown_chunkp;
typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;
typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
typedef png_unknown_chunk * png_unknown_chunkp;
typedef const png_unknown_chunk * png_const_unknown_chunkp;
typedef png_unknown_chunk * * png_unknown_chunkpp;
#endif

/* Values for the unknown chunk location byte */
Expand All @@ -712,9 +694,9 @@ typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
* applications. Read libpng-manual.txt or libpng.3 for more info.
*/
typedef struct png_info_def png_info;
typedef png_info FAR * png_infop;
typedef PNG_CONST png_info FAR * png_const_infop;
typedef png_info FAR * FAR * png_infopp;
typedef png_info * png_infop;
typedef const png_info * png_const_infop;
typedef png_info * * png_infopp;

/* Maximum positive integer used in PNG is (2^31)-1 */
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
Expand Down Expand Up @@ -831,16 +813,16 @@ typedef struct png_row_info_struct
png_byte pixel_depth; /* bits per pixel (depth * channels) */
} png_row_info;

typedef png_row_info FAR * png_row_infop;
typedef png_row_info FAR * FAR * png_row_infopp;
typedef png_row_info * png_row_infop;
typedef png_row_info * * png_row_infopp;

/* The complete definition of png_struct has, as of libpng-1.5.0,
* been moved into a separate header file that is not accessible to
* applications. Read libpng-manual.txt or libpng.3 for more info.
*/
typedef struct png_struct_def png_struct;
typedef PNG_CONST png_struct FAR * png_const_structp;
typedef png_struct FAR * png_structp;
typedef const png_struct * png_const_structp;
typedef png_struct * png_structp;

/* These are the function types for the I/O functions and for the functions
* that allow the user to override the default I/O functions with his or her
Expand Down Expand Up @@ -943,7 +925,7 @@ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
png_alloc_size_t));
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));

typedef png_struct FAR * FAR * png_structpp;
typedef png_struct * * png_structpp;

/* Section 3: exported functions
* Here are the function definitions most commonly used. This is not
Expand Down Expand Up @@ -1105,7 +1087,7 @@ PNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123,
#ifdef PNG_CONVERT_tIME_SUPPORTED
/* Convert from a struct tm to png_time */
PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
PNG_CONST struct tm FAR * ttime));
const struct tm * ttime));

/* Convert from time_t to png_time. Uses gmtime() */
PNG_EXPORT(25, void, png_convert_from_time_t,
Expand Down

0 comments on commit baeb6d1

Please sign in to comment.