mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] libpng updated to version 1.2.42
This commit is contained in:
parent
de118ab6f2
commit
6847fba41f
20 changed files with 28599 additions and 28075 deletions
2025
GRRLIB/lib/png/png.c
2025
GRRLIB/lib/png/png.c
File diff suppressed because it is too large
Load diff
7497
GRRLIB/lib/png/png.h
7497
GRRLIB/lib/png/png.h
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,364 +1,386 @@
|
||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.37 [June 4, 2009]
|
* Last changed in libpng 1.2.41 [December 3, 2009]
|
||||||
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*
|
*
|
||||||
* This file provides a location for all error handling. Users who
|
* This file provides a location for all error handling. Users who
|
||||||
* need special error handling are expected to write replacement functions
|
* need special error handling are expected to write replacement functions
|
||||||
* and use png_set_error_fn() to use those functions. See the instructions
|
* and use png_set_error_fn() to use those functions. See the instructions
|
||||||
* at each function.
|
* at each function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#define PNG_NO_PEDANTIC_WARNINGS
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
static void /* PRIVATE */
|
|
||||||
png_default_error PNGARG((png_structp png_ptr,
|
static void /* PRIVATE */
|
||||||
png_const_charp error_message));
|
png_default_error PNGARG((png_structp png_ptr,
|
||||||
#ifndef PNG_NO_WARNINGS
|
png_const_charp error_message)) PNG_NORETURN;
|
||||||
static void /* PRIVATE */
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
png_default_warning PNGARG((png_structp png_ptr,
|
static void /* PRIVATE */
|
||||||
png_const_charp warning_message));
|
png_default_warning PNGARG((png_structp png_ptr,
|
||||||
#endif /* PNG_NO_WARNINGS */
|
png_const_charp warning_message));
|
||||||
|
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||||
/* This function is called whenever there is a fatal error. This function
|
|
||||||
* should not be changed. If there is a need to handle errors differently,
|
/* This function is called whenever there is a fatal error. This function
|
||||||
* you should supply a replacement error function and use png_set_error_fn()
|
* should not be changed. If there is a need to handle errors differently,
|
||||||
* to replace the error function at run-time.
|
* you should supply a replacement error function and use png_set_error_fn()
|
||||||
*/
|
* to replace the error function at run-time.
|
||||||
#ifndef PNG_NO_ERROR_TEXT
|
*/
|
||||||
void PNGAPI
|
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||||
png_error(png_structp png_ptr, png_const_charp error_message)
|
void PNGAPI
|
||||||
{
|
png_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
{
|
||||||
char msg[16];
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
if (png_ptr != NULL)
|
char msg[16];
|
||||||
{
|
if (png_ptr != NULL)
|
||||||
if (png_ptr->flags&
|
{
|
||||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
if (png_ptr->flags&
|
||||||
{
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||||
if (*error_message == '#')
|
{
|
||||||
{
|
if (*error_message == PNG_LITERAL_SHARP)
|
||||||
/* Strip "#nnnn " from beginning of error message. */
|
{
|
||||||
int offset;
|
/* Strip "#nnnn " from beginning of error message. */
|
||||||
for (offset = 1; offset<15; offset++)
|
int offset;
|
||||||
if (error_message[offset] == ' ')
|
for (offset = 1; offset<15; offset++)
|
||||||
break;
|
if (error_message[offset] == ' ')
|
||||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
break;
|
||||||
{
|
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||||
int i;
|
{
|
||||||
for (i = 0; i < offset - 1; i++)
|
int i;
|
||||||
msg[i] = error_message[i + 1];
|
for (i = 0; i < offset - 1; i++)
|
||||||
msg[i - 1] = '\0';
|
msg[i] = error_message[i + 1];
|
||||||
error_message = msg;
|
msg[i - 1] = '\0';
|
||||||
}
|
error_message = msg;
|
||||||
else
|
}
|
||||||
error_message += offset;
|
else
|
||||||
}
|
error_message += offset;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
{
|
||||||
{
|
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||||
msg[0] = '0';
|
{
|
||||||
msg[1] = '\0';
|
msg[0] = '0';
|
||||||
error_message = msg;
|
msg[1] = '\0';
|
||||||
}
|
error_message = msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
#endif
|
||||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
|
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
|
||||||
use the default handler, which will not return. */
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
png_default_error(png_ptr, error_message);
|
use the default handler, which will not return. */
|
||||||
}
|
png_default_error(png_ptr, error_message);
|
||||||
#else
|
}
|
||||||
void PNGAPI
|
#else
|
||||||
png_err(png_structp png_ptr)
|
void PNGAPI
|
||||||
{
|
png_err(png_structp png_ptr)
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
{
|
||||||
(*(png_ptr->error_fn))(png_ptr, '\0');
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
|
(*(png_ptr->error_fn))(png_ptr, '\0');
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
|
||||||
use the default handler, which will not return. */
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
png_default_error(png_ptr, '\0');
|
use the default handler, which will not return. */
|
||||||
}
|
png_default_error(png_ptr, '\0');
|
||||||
#endif /* PNG_NO_ERROR_TEXT */
|
}
|
||||||
|
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||||
#ifndef PNG_NO_WARNINGS
|
|
||||||
/* This function is called whenever there is a non-fatal error. This function
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
* should not be changed. If there is a need to handle warnings differently,
|
/* This function is called whenever there is a non-fatal error. This function
|
||||||
* you should supply a replacement warning function and use
|
* should not be changed. If there is a need to handle warnings differently,
|
||||||
* png_set_error_fn() to replace the warning function at run-time.
|
* you should supply a replacement warning function and use
|
||||||
*/
|
* png_set_error_fn() to replace the warning function at run-time.
|
||||||
void PNGAPI
|
*/
|
||||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
void PNGAPI
|
||||||
{
|
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
int offset = 0;
|
{
|
||||||
if (png_ptr != NULL)
|
int offset = 0;
|
||||||
{
|
if (png_ptr != NULL)
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
{
|
||||||
if (png_ptr->flags&
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
if (png_ptr->flags&
|
||||||
#endif
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||||
{
|
#endif
|
||||||
if (*warning_message == '#')
|
{
|
||||||
{
|
if (*warning_message == PNG_LITERAL_SHARP)
|
||||||
for (offset = 1; offset < 15; offset++)
|
{
|
||||||
if (warning_message[offset] == ' ')
|
for (offset = 1; offset < 15; offset++)
|
||||||
break;
|
if (warning_message[offset] == ' ')
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
}
|
||||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||||
else
|
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||||
png_default_warning(png_ptr, warning_message + offset);
|
else
|
||||||
}
|
png_default_warning(png_ptr, warning_message + offset);
|
||||||
#endif /* PNG_NO_WARNINGS */
|
}
|
||||||
|
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||||
|
|
||||||
/* These utilities are used internally to build an error message that relates
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
void PNGAPI
|
||||||
* this is used to prefix the message. The message is limited in length
|
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
{
|
||||||
* if the character is invalid.
|
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||||
*/
|
png_warning(png_ptr, error_message);
|
||||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
else
|
||||||
static PNG_CONST char png_digit[16] = {
|
png_error(png_ptr, error_message);
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
}
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
#endif
|
||||||
};
|
|
||||||
|
/* These utilities are used internally to build an error message that relates
|
||||||
#define PNG_MAX_ERROR_TEXT 64
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
|
* this is used to prefix the message. The message is limited in length
|
||||||
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
|
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
||||||
static void /* PRIVATE */
|
* if the character is invalid.
|
||||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
*/
|
||||||
error_message)
|
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||||
{
|
static PNG_CONST char png_digit[16] = {
|
||||||
int iout = 0, iin = 0;
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
while (iin < 4)
|
};
|
||||||
{
|
|
||||||
int c = png_ptr->chunk_name[iin++];
|
#define PNG_MAX_ERROR_TEXT 64
|
||||||
if (isnonalpha(c))
|
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||||
{
|
static void /* PRIVATE */
|
||||||
buffer[iout++] = '[';
|
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
error_message)
|
||||||
buffer[iout++] = png_digit[c & 0x0f];
|
{
|
||||||
buffer[iout++] = ']';
|
int iout = 0, iin = 0;
|
||||||
}
|
|
||||||
else
|
while (iin < 4)
|
||||||
{
|
{
|
||||||
buffer[iout++] = (png_byte)c;
|
int c = png_ptr->chunk_name[iin++];
|
||||||
}
|
if (isnonalpha(c))
|
||||||
}
|
{
|
||||||
|
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||||
if (error_message == NULL)
|
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||||
buffer[iout] = '\0';
|
buffer[iout++] = png_digit[c & 0x0f];
|
||||||
else
|
buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;
|
||||||
{
|
}
|
||||||
buffer[iout++] = ':';
|
else
|
||||||
buffer[iout++] = ' ';
|
{
|
||||||
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
|
buffer[iout++] = (png_byte)c;
|
||||||
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (error_message == NULL)
|
||||||
#ifdef PNG_READ_SUPPORTED
|
buffer[iout] = '\0';
|
||||||
void PNGAPI
|
else
|
||||||
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
{
|
||||||
{
|
buffer[iout++] = ':';
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
buffer[iout++] = ' ';
|
||||||
if (png_ptr == NULL)
|
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||||
png_error(png_ptr, error_message);
|
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
png_format_buffer(png_ptr, msg, error_message);
|
|
||||||
png_error(png_ptr, msg);
|
#ifdef PNG_READ_SUPPORTED
|
||||||
}
|
void PNGAPI
|
||||||
}
|
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
{
|
||||||
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
if (png_ptr == NULL)
|
||||||
#ifndef PNG_NO_WARNINGS
|
png_error(png_ptr, error_message);
|
||||||
void PNGAPI
|
else
|
||||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
{
|
||||||
{
|
png_format_buffer(png_ptr, msg, error_message);
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
png_error(png_ptr, msg);
|
||||||
if (png_ptr == NULL)
|
}
|
||||||
png_warning(png_ptr, warning_message);
|
}
|
||||||
else
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
{
|
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||||
png_format_buffer(png_ptr, msg, warning_message);
|
|
||||||
png_warning(png_ptr, msg);
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
}
|
void PNGAPI
|
||||||
}
|
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
#endif /* PNG_NO_WARNINGS */
|
{
|
||||||
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
if (png_ptr == NULL)
|
||||||
/* This is the default error handling function. Note that replacements for
|
png_warning(png_ptr, warning_message);
|
||||||
* this function MUST NOT RETURN, or the program will likely crash. This
|
else
|
||||||
* function is used by default, or if the program supplies NULL for the
|
{
|
||||||
* error function pointer in png_set_error_fn().
|
png_format_buffer(png_ptr, msg, warning_message);
|
||||||
*/
|
png_warning(png_ptr, msg);
|
||||||
static void /* PRIVATE */
|
}
|
||||||
png_default_error(png_structp png_ptr, png_const_charp error_message)
|
}
|
||||||
{
|
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||||
#ifndef PNG_NO_CONSOLE_IO
|
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
if (*error_message == '#')
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
{
|
void PNGAPI
|
||||||
/* Strip "#nnnn " from beginning of error message. */
|
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
int offset;
|
{
|
||||||
char error_number[16];
|
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||||
for (offset = 0; offset<15; offset++)
|
png_chunk_warning(png_ptr, error_message);
|
||||||
{
|
else
|
||||||
error_number[offset] = error_message[offset + 1];
|
png_chunk_error(png_ptr, error_message);
|
||||||
if (error_message[offset] == ' ')
|
}
|
||||||
break;
|
#endif
|
||||||
}
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
if ((offset > 1) && (offset < 15))
|
|
||||||
{
|
/* This is the default error handling function. Note that replacements for
|
||||||
error_number[offset - 1] = '\0';
|
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||||
fprintf(stderr, "libpng error no. %s: %s",
|
* function is used by default, or if the program supplies NULL for the
|
||||||
error_number, error_message + offset + 1);
|
* error function pointer in png_set_error_fn().
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
*/
|
||||||
}
|
static void /* PRIVATE */
|
||||||
else
|
png_default_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "libpng error: %s, offset=%d",
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
error_message, offset);
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
if (*error_message == PNG_LITERAL_SHARP)
|
||||||
}
|
{
|
||||||
}
|
/* Strip "#nnnn " from beginning of error message. */
|
||||||
else
|
int offset;
|
||||||
#endif
|
char error_number[16];
|
||||||
{
|
for (offset = 0; offset<15; offset++)
|
||||||
fprintf(stderr, "libpng error: %s", error_message);
|
{
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
error_number[offset] = error_message[offset + 1];
|
||||||
}
|
if (error_message[offset] == ' ')
|
||||||
#endif
|
break;
|
||||||
|
}
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
if ((offset > 1) && (offset < 15))
|
||||||
if (png_ptr)
|
{
|
||||||
{
|
error_number[offset - 1] = '\0';
|
||||||
# ifdef USE_FAR_KEYWORD
|
fprintf(stderr, "libpng error no. %s: %s",
|
||||||
{
|
error_number, error_message + offset + 1);
|
||||||
jmp_buf jmpbuf;
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
}
|
||||||
longjmp(jmpbuf, 1);
|
else
|
||||||
}
|
{
|
||||||
# else
|
fprintf(stderr, "libpng error: %s, offset=%d",
|
||||||
longjmp(png_ptr->jmpbuf, 1);
|
error_message, offset);
|
||||||
# endif
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
}
|
}
|
||||||
#else
|
}
|
||||||
PNG_ABORT();
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_NO_CONSOLE_IO
|
{
|
||||||
error_message = error_message; /* Make compiler happy */
|
fprintf(stderr, "libpng error: %s", error_message);
|
||||||
#endif
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifndef PNG_NO_WARNINGS
|
|
||||||
/* This function is called when there is a warning, but the library thinks
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
* it can continue anyway. Replacement functions don't have to do anything
|
if (png_ptr)
|
||||||
* here if you don't want them to. In the default configuration, png_ptr is
|
{
|
||||||
* not used, but it is passed in case it may be useful.
|
# ifdef USE_FAR_KEYWORD
|
||||||
*/
|
{
|
||||||
static void /* PRIVATE */
|
jmp_buf jmpbuf;
|
||||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||||
{
|
longjmp(jmpbuf,1);
|
||||||
#ifndef PNG_NO_CONSOLE_IO
|
}
|
||||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
# else
|
||||||
if (*warning_message == '#')
|
longjmp(png_ptr->jmpbuf, 1);
|
||||||
{
|
# endif
|
||||||
int offset;
|
}
|
||||||
char warning_number[16];
|
#endif
|
||||||
for (offset = 0; offset < 15; offset++)
|
/* Here if not setjmp support or if png_ptr is null. */
|
||||||
{
|
PNG_ABORT();
|
||||||
warning_number[offset] = warning_message[offset + 1];
|
#ifndef PNG_CONSOLE_IO_SUPPORTED
|
||||||
if (warning_message[offset] == ' ')
|
error_message = error_message; /* Make compiler happy */
|
||||||
break;
|
#endif
|
||||||
}
|
}
|
||||||
if ((offset > 1) && (offset < 15))
|
|
||||||
{
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
warning_number[offset + 1] = '\0';
|
/* This function is called when there is a warning, but the library thinks
|
||||||
fprintf(stderr, "libpng warning no. %s: %s",
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
warning_number, warning_message + offset);
|
* here if you don't want them to. In the default configuration, png_ptr is
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
* not used, but it is passed in case it may be useful.
|
||||||
}
|
*/
|
||||||
else
|
static void /* PRIVATE */
|
||||||
{
|
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
fprintf(stderr, "libpng warning: %s",
|
{
|
||||||
warning_message);
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
}
|
if (*warning_message == PNG_LITERAL_SHARP)
|
||||||
}
|
{
|
||||||
else
|
int offset;
|
||||||
# endif
|
char warning_number[16];
|
||||||
{
|
for (offset = 0; offset < 15; offset++)
|
||||||
fprintf(stderr, "libpng warning: %s", warning_message);
|
{
|
||||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
warning_number[offset] = warning_message[offset + 1];
|
||||||
}
|
if (warning_message[offset] == ' ')
|
||||||
#else
|
break;
|
||||||
warning_message = warning_message; /* Make compiler happy */
|
}
|
||||||
#endif
|
if ((offset > 1) && (offset < 15))
|
||||||
png_ptr = png_ptr; /* Make compiler happy */
|
{
|
||||||
}
|
warning_number[offset + 1] = '\0';
|
||||||
#endif /* PNG_NO_WARNINGS */
|
fprintf(stderr, "libpng warning no. %s: %s",
|
||||||
|
warning_number, warning_message + offset);
|
||||||
/* This function is called when the application wants to use another method
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
* of handling errors and warnings. Note that the error function MUST NOT
|
}
|
||||||
* return to the calling routine or serious problems will occur. The return
|
else
|
||||||
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
{
|
||||||
*/
|
fprintf(stderr, "libpng warning: %s",
|
||||||
void PNGAPI
|
warning_message);
|
||||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
}
|
||||||
{
|
}
|
||||||
if (png_ptr == NULL)
|
else
|
||||||
return;
|
# endif
|
||||||
png_ptr->error_ptr = error_ptr;
|
{
|
||||||
png_ptr->error_fn = error_fn;
|
fprintf(stderr, "libpng warning: %s", warning_message);
|
||||||
png_ptr->warning_fn = warning_fn;
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
warning_message = warning_message; /* Make compiler happy */
|
||||||
/* This function returns a pointer to the error_ptr associated with the user
|
#endif
|
||||||
* functions. The application should free any memory associated with this
|
png_ptr = png_ptr; /* Make compiler happy */
|
||||||
* pointer before png_write_destroy and png_read_destroy are called.
|
}
|
||||||
*/
|
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||||
png_voidp PNGAPI
|
|
||||||
png_get_error_ptr(png_structp png_ptr)
|
/* This function is called when the application wants to use another method
|
||||||
{
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
if (png_ptr == NULL)
|
* return to the calling routine or serious problems will occur. The return
|
||||||
return NULL;
|
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||||
return ((png_voidp)png_ptr->error_ptr);
|
*/
|
||||||
}
|
void PNGAPI
|
||||||
|
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
|
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
{
|
||||||
void PNGAPI
|
if (png_ptr == NULL)
|
||||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
return;
|
||||||
{
|
png_ptr->error_ptr = error_ptr;
|
||||||
if (png_ptr != NULL)
|
png_ptr->error_fn = error_fn;
|
||||||
{
|
png_ptr->warning_fn = warning_fn;
|
||||||
png_ptr->flags &=
|
}
|
||||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
|
||||||
}
|
|
||||||
}
|
/* This function returns a pointer to the error_ptr associated with the user
|
||||||
#endif
|
* functions. The application should free any memory associated with this
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
|
*/
|
||||||
|
png_voidp PNGAPI
|
||||||
|
png_get_error_ptr(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
return ((png_voidp)png_ptr->error_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
|
void PNGAPI
|
||||||
|
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_ptr->flags &=
|
||||||
|
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,103 +1,103 @@
|
||||||
/* pnggccrd.c was removed from libpng-1.2.20. */
|
/* pnggccrd.c was removed from libpng-1.2.20. */
|
||||||
|
|
||||||
/* This code snippet is for use by configure's compilation test. */
|
/* This code snippet is for use by configure's compilation test. */
|
||||||
|
|
||||||
#if (!defined _MSC_VER) && \
|
#if (!defined _MSC_VER) && \
|
||||||
defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
|
defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
|
||||||
defined(PNG_MMX_CODE_SUPPORTED)
|
defined(PNG_MMX_CODE_SUPPORTED)
|
||||||
|
|
||||||
int PNGAPI png_dummy_mmx_support(void);
|
int PNGAPI png_dummy_mmx_support(void);
|
||||||
|
|
||||||
static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested
|
static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested
|
||||||
|
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_dummy_mmx_support(void) __attribute__((noinline));
|
png_dummy_mmx_support(void) __attribute__((noinline));
|
||||||
|
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_dummy_mmx_support(void)
|
png_dummy_mmx_support(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
#if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck
|
#ifdef PNG_MMX_CODE_SUPPORTED // superfluous, but what the heck
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
#if defined(__x86_64__)
|
#ifdef __x86_64__
|
||||||
"pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction
|
"pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction
|
||||||
"pushq %%rcx \n\t" // so does rcx...
|
"pushq %%rcx \n\t" // so does rcx...
|
||||||
"pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux)
|
"pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux)
|
||||||
"pushfq \n\t" // save Eflag to stack
|
"pushfq \n\t" // save Eflag to stack
|
||||||
"popq %%rax \n\t" // get Eflag from stack into rax
|
"popq %%rax \n\t" // get Eflag from stack into rax
|
||||||
"movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx
|
"movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx
|
||||||
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
||||||
"pushq %%rax \n\t" // save modified Eflag back to stack
|
"pushq %%rax \n\t" // save modified Eflag back to stack
|
||||||
"popfq \n\t" // restore modified value to Eflag reg
|
"popfq \n\t" // restore modified value to Eflag reg
|
||||||
"pushfq \n\t" // save Eflag to stack
|
"pushfq \n\t" // save Eflag to stack
|
||||||
"popq %%rax \n\t" // get Eflag from stack
|
"popq %%rax \n\t" // get Eflag from stack
|
||||||
"pushq %%rcx \n\t" // save original Eflag to stack
|
"pushq %%rcx \n\t" // save original Eflag to stack
|
||||||
"popfq \n\t" // restore original Eflag
|
"popfq \n\t" // restore original Eflag
|
||||||
#else
|
#else
|
||||||
"pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction
|
"pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction
|
||||||
"pushl %%ecx \n\t" // so does ecx...
|
"pushl %%ecx \n\t" // so does ecx...
|
||||||
"pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux)
|
"pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux)
|
||||||
"pushfl \n\t" // save Eflag to stack
|
"pushfl \n\t" // save Eflag to stack
|
||||||
"popl %%eax \n\t" // get Eflag from stack into eax
|
"popl %%eax \n\t" // get Eflag from stack into eax
|
||||||
"movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx
|
"movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx
|
||||||
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
||||||
"pushl %%eax \n\t" // save modified Eflag back to stack
|
"pushl %%eax \n\t" // save modified Eflag back to stack
|
||||||
"popfl \n\t" // restore modified value to Eflag reg
|
"popfl \n\t" // restore modified value to Eflag reg
|
||||||
"pushfl \n\t" // save Eflag to stack
|
"pushfl \n\t" // save Eflag to stack
|
||||||
"popl %%eax \n\t" // get Eflag from stack
|
"popl %%eax \n\t" // get Eflag from stack
|
||||||
"pushl %%ecx \n\t" // save original Eflag to stack
|
"pushl %%ecx \n\t" // save original Eflag to stack
|
||||||
"popfl \n\t" // restore original Eflag
|
"popfl \n\t" // restore original Eflag
|
||||||
#endif
|
#endif
|
||||||
"xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag
|
"xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag
|
||||||
"jz 0f \n\t" // if same, CPUID instr. is not supported
|
"jz 0f \n\t" // if same, CPUID instr. is not supported
|
||||||
|
|
||||||
"xorl %%eax, %%eax \n\t" // set eax to zero
|
"xorl %%eax, %%eax \n\t" // set eax to zero
|
||||||
// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode)
|
// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode)
|
||||||
"cpuid \n\t" // get the CPU identification info
|
"cpuid \n\t" // get the CPU identification info
|
||||||
"cmpl $1, %%eax \n\t" // make sure eax return non-zero value
|
"cmpl $1, %%eax \n\t" // make sure eax return non-zero value
|
||||||
"jl 0f \n\t" // if eax is zero, MMX is not supported
|
"jl 0f \n\t" // if eax is zero, MMX is not supported
|
||||||
|
|
||||||
"xorl %%eax, %%eax \n\t" // set eax to zero and...
|
"xorl %%eax, %%eax \n\t" // set eax to zero and...
|
||||||
"incl %%eax \n\t" // ...increment eax to 1. This pair is
|
"incl %%eax \n\t" // ...increment eax to 1. This pair is
|
||||||
// faster than the instruction "mov eax, 1"
|
// faster than the instruction "mov eax, 1"
|
||||||
"cpuid \n\t" // get the CPU identification info again
|
"cpuid \n\t" // get the CPU identification info again
|
||||||
"andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23)
|
"andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23)
|
||||||
"cmpl $0, %%edx \n\t" // 0 = MMX not supported
|
"cmpl $0, %%edx \n\t" // 0 = MMX not supported
|
||||||
"jz 0f \n\t" // non-zero = yes, MMX IS supported
|
"jz 0f \n\t" // non-zero = yes, MMX IS supported
|
||||||
|
|
||||||
"movl $1, %%eax \n\t" // set return value to 1
|
"movl $1, %%eax \n\t" // set return value to 1
|
||||||
"jmp 1f \n\t" // DONE: have MMX support
|
"jmp 1f \n\t" // DONE: have MMX support
|
||||||
|
|
||||||
"0: \n\t" // .NOT_SUPPORTED: target label for jump instructions
|
"0: \n\t" // .NOT_SUPPORTED: target label for jump instructions
|
||||||
"movl $0, %%eax \n\t" // set return value to 0
|
"movl $0, %%eax \n\t" // set return value to 0
|
||||||
"1: \n\t" // .RETURN: target label for jump instructions
|
"1: \n\t" // .RETURN: target label for jump instructions
|
||||||
#if defined(__x86_64__)
|
#ifdef __x86_64__
|
||||||
"popq %%rdx \n\t" // restore rdx
|
"popq %%rdx \n\t" // restore rdx
|
||||||
"popq %%rcx \n\t" // restore rcx
|
"popq %%rcx \n\t" // restore rcx
|
||||||
"popq %%rbx \n\t" // restore rbx
|
"popq %%rbx \n\t" // restore rbx
|
||||||
#else
|
#else
|
||||||
"popl %%edx \n\t" // restore edx
|
"popl %%edx \n\t" // restore edx
|
||||||
"popl %%ecx \n\t" // restore ecx
|
"popl %%ecx \n\t" // restore ecx
|
||||||
"popl %%ebx \n\t" // restore ebx
|
"popl %%ebx \n\t" // restore ebx
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// "ret \n\t" // DONE: no MMX support
|
// "ret \n\t" // DONE: no MMX support
|
||||||
// (fall through to standard C "ret")
|
// (fall through to standard C "ret")
|
||||||
|
|
||||||
: "=a" (result) // output list
|
: "=a" (result) // output list
|
||||||
|
|
||||||
: // any variables used on input (none)
|
: // any variables used on input (none)
|
||||||
|
|
||||||
// no clobber list
|
// no clobber list
|
||||||
// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
|
// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
|
||||||
// , "memory" // if write to a variable gcc thought was in a reg
|
// , "memory" // if write to a variable gcc thought was in a reg
|
||||||
// , "cc" // "condition codes" (flag bits)
|
// , "cc" // "condition codes" (flag bits)
|
||||||
);
|
);
|
||||||
_mmx_supported = result;
|
_mmx_supported = result;
|
||||||
#else
|
#else
|
||||||
_mmx_supported = 0;
|
_mmx_supported = 0;
|
||||||
#endif /* PNG_MMX_CODE_SUPPORTED */
|
#endif /* PNG_MMX_CODE_SUPPORTED */
|
||||||
|
|
||||||
return _mmx_supported;
|
return _mmx_supported;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,177 +1,179 @@
|
||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.37 [June 4, 2009]
|
* Last changed in libpng 1.2.41 [December 3, 2009]
|
||||||
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*
|
*
|
||||||
* This file provides a location for all input. Users who need
|
* This file provides a location for all input. Users who need
|
||||||
* special handling are expected to write a function that has the same
|
* special handling are expected to write a function that has the same
|
||||||
* arguments as this and performs a similar function, but that possibly
|
* arguments as this and performs a similar function, but that possibly
|
||||||
* has a different input method. Note that you shouldn't change this
|
* has a different input method. Note that you shouldn't change this
|
||||||
* function, but rather write a replacement function and then make
|
* function, but rather write a replacement function and then make
|
||||||
* libpng use it at run time with png_set_read_fn(...).
|
* libpng use it at run time with png_set_read_fn(...).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#define PNG_NO_PEDANTIC_WARNINGS
|
||||||
#if defined(PNG_READ_SUPPORTED)
|
#include "png.h"
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
/* Read the data from whatever input you are using. The default routine
|
|
||||||
* reads from a file pointer. Note that this routine sometimes gets called
|
/* Read the data from whatever input you are using. The default routine
|
||||||
* with very small lengths, so you should implement some kind of simple
|
* reads from a file pointer. Note that this routine sometimes gets called
|
||||||
* buffering if you are using unbuffered reads. This should never be asked
|
* with very small lengths, so you should implement some kind of simple
|
||||||
* to read more then 64K on a 16 bit machine.
|
* buffering if you are using unbuffered reads. This should never be asked
|
||||||
*/
|
* to read more then 64K on a 16 bit machine.
|
||||||
void /* PRIVATE */
|
*/
|
||||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
void /* PRIVATE */
|
||||||
{
|
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_debug1(4, "reading %d bytes", (int)length);
|
{
|
||||||
if (png_ptr->read_data_fn != NULL)
|
png_debug1(4, "reading %d bytes", (int)length);
|
||||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
|
||||||
else
|
if (png_ptr->read_data_fn != NULL)
|
||||||
png_error(png_ptr, "Call to NULL read function");
|
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||||
}
|
else
|
||||||
|
png_error(png_ptr, "Call to NULL read function");
|
||||||
#if !defined(PNG_NO_STDIO)
|
}
|
||||||
/* This is the function that does the actual reading of data. If you are
|
|
||||||
* not reading from a standard C stream, you should create a replacement
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
/* This is the function that does the actual reading of data. If you are
|
||||||
* than changing the library.
|
* not reading from a standard C stream, you should create a replacement
|
||||||
*/
|
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
#ifndef USE_FAR_KEYWORD
|
* than changing the library.
|
||||||
void PNGAPI
|
*/
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
#ifndef USE_FAR_KEYWORD
|
||||||
{
|
void PNGAPI
|
||||||
png_size_t check;
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
if (png_ptr == NULL)
|
png_size_t check;
|
||||||
return;
|
|
||||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
if (png_ptr == NULL)
|
||||||
* instead of an int, which is what fread() actually returns.
|
return;
|
||||||
*/
|
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||||
#if defined(_WIN32_WCE)
|
* instead of an int, which is what fread() actually returns.
|
||||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
*/
|
||||||
check = 0;
|
#ifdef _WIN32_WCE
|
||||||
#else
|
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
check = 0;
|
||||||
(png_FILE_p)png_ptr->io_ptr);
|
#else
|
||||||
#endif
|
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||||
|
(png_FILE_p)png_ptr->io_ptr);
|
||||||
if (check != length)
|
#endif
|
||||||
png_error(png_ptr, "Read Error");
|
|
||||||
}
|
if (check != length)
|
||||||
#else
|
png_error(png_ptr, "Read Error");
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
}
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
#else
|
||||||
the data.
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
*/
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
|
the data.
|
||||||
#define NEAR_BUF_SIZE 1024
|
*/
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
|
||||||
|
#define NEAR_BUF_SIZE 1024
|
||||||
static void PNGAPI
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|
||||||
{
|
static void PNGAPI
|
||||||
int check;
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_byte *n_data;
|
{
|
||||||
png_FILE_p io_ptr;
|
int check;
|
||||||
|
png_byte *n_data;
|
||||||
if (png_ptr == NULL)
|
png_FILE_p io_ptr;
|
||||||
return;
|
|
||||||
/* Check if data really is near. If so, use usual code. */
|
if (png_ptr == NULL)
|
||||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
return;
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
/* Check if data really is near. If so, use usual code. */
|
||||||
if ((png_bytep)n_data == data)
|
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
{
|
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||||
#if defined(_WIN32_WCE)
|
if ((png_bytep)n_data == data)
|
||||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
{
|
||||||
check = 0;
|
#ifdef _WIN32_WCE
|
||||||
#else
|
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||||
check = fread(n_data, 1, length, io_ptr);
|
check = 0;
|
||||||
#endif
|
#else
|
||||||
}
|
check = fread(n_data, 1, length, io_ptr);
|
||||||
else
|
#endif
|
||||||
{
|
}
|
||||||
png_byte buf[NEAR_BUF_SIZE];
|
else
|
||||||
png_size_t read, remaining, err;
|
{
|
||||||
check = 0;
|
png_byte buf[NEAR_BUF_SIZE];
|
||||||
remaining = length;
|
png_size_t read, remaining, err;
|
||||||
do
|
check = 0;
|
||||||
{
|
remaining = length;
|
||||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
do
|
||||||
#if defined(_WIN32_WCE)
|
{
|
||||||
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
|
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
err = 0;
|
#ifdef _WIN32_WCE
|
||||||
#else
|
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
|
||||||
err = fread(buf, (png_size_t)1, read, io_ptr);
|
err = 0;
|
||||||
#endif
|
#else
|
||||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||||
if (err != read)
|
#endif
|
||||||
break;
|
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||||
else
|
if (err != read)
|
||||||
check += err;
|
break;
|
||||||
data += read;
|
else
|
||||||
remaining -= read;
|
check += err;
|
||||||
}
|
data += read;
|
||||||
while (remaining != 0);
|
remaining -= read;
|
||||||
}
|
}
|
||||||
if ((png_uint_32)check != (png_uint_32)length)
|
while (remaining != 0);
|
||||||
png_error(png_ptr, "read Error");
|
}
|
||||||
}
|
if ((png_uint_32)check != (png_uint_32)length)
|
||||||
#endif
|
png_error(png_ptr, "read Error");
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
/* This function allows the application to supply a new input function
|
#endif
|
||||||
* for libpng if standard C streams aren't being used.
|
|
||||||
*
|
/* This function allows the application to supply a new input function
|
||||||
* This function takes as its arguments:
|
* for libpng if standard C streams aren't being used.
|
||||||
* png_ptr - pointer to a png input data structure
|
*
|
||||||
* io_ptr - pointer to user supplied structure containing info about
|
* This function takes as its arguments:
|
||||||
* the input functions. May be NULL.
|
* png_ptr - pointer to a png input data structure
|
||||||
* read_data_fn - pointer to a new input function that takes as its
|
* io_ptr - pointer to user supplied structure containing info about
|
||||||
* arguments a pointer to a png_struct, a pointer to
|
* the input functions. May be NULL.
|
||||||
* a location where input data can be stored, and a 32-bit
|
* read_data_fn - pointer to a new input function that takes as its
|
||||||
* unsigned int that is the number of bytes to be read.
|
* arguments a pointer to a png_struct, a pointer to
|
||||||
* To exit and output any fatal error messages the new write
|
* a location where input data can be stored, and a 32-bit
|
||||||
* function should call png_error(png_ptr, "Error msg").
|
* unsigned int that is the number of bytes to be read.
|
||||||
* May be NULL, in which case libpng's default function will
|
* To exit and output any fatal error messages the new write
|
||||||
* be used.
|
* function should call png_error(png_ptr, "Error msg").
|
||||||
*/
|
* May be NULL, in which case libpng's default function will
|
||||||
void PNGAPI
|
* be used.
|
||||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
*/
|
||||||
png_rw_ptr read_data_fn)
|
void PNGAPI
|
||||||
{
|
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
if (png_ptr == NULL)
|
png_rw_ptr read_data_fn)
|
||||||
return;
|
{
|
||||||
png_ptr->io_ptr = io_ptr;
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
#if !defined(PNG_NO_STDIO)
|
png_ptr->io_ptr = io_ptr;
|
||||||
if (read_data_fn != NULL)
|
|
||||||
png_ptr->read_data_fn = read_data_fn;
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
else
|
if (read_data_fn != NULL)
|
||||||
png_ptr->read_data_fn = png_default_read_data;
|
png_ptr->read_data_fn = read_data_fn;
|
||||||
#else
|
else
|
||||||
png_ptr->read_data_fn = read_data_fn;
|
png_ptr->read_data_fn = png_default_read_data;
|
||||||
#endif
|
#else
|
||||||
|
png_ptr->read_data_fn = read_data_fn;
|
||||||
/* It is an error to write to a read device */
|
#endif
|
||||||
if (png_ptr->write_data_fn != NULL)
|
|
||||||
{
|
/* It is an error to write to a read device */
|
||||||
png_ptr->write_data_fn = NULL;
|
if (png_ptr->write_data_fn != NULL)
|
||||||
png_warning(png_ptr,
|
{
|
||||||
"It's an error to set both read_data_fn and write_data_fn in the ");
|
png_ptr->write_data_fn = NULL;
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"same structure. Resetting write_data_fn to NULL.");
|
"It's an error to set both read_data_fn and write_data_fn in the ");
|
||||||
}
|
png_warning(png_ptr,
|
||||||
|
"same structure. Resetting write_data_fn to NULL.");
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
}
|
||||||
png_ptr->output_flush_fn = NULL;
|
|
||||||
#endif
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
}
|
png_ptr->output_flush_fn = NULL;
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1 +1 @@
|
||||||
/* pnggvrd.c was removed from libpng-1.2.20. */
|
/* pnggvrd.c was removed from libpng-1.2.20. */
|
||||||
|
|
|
@ -1,259 +1,260 @@
|
||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.37 [June 4, 2009]
|
* Last changed in libpng 1.2.41 [December 3, 2009]
|
||||||
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*
|
*
|
||||||
* This file provides a location for all output. Users who need
|
* This file provides a location for all output. Users who need
|
||||||
* special handling are expected to write functions that have the same
|
* special handling are expected to write functions that have the same
|
||||||
* arguments as these and perform similar functions, but that possibly
|
* arguments as these and perform similar functions, but that possibly
|
||||||
* use different output methods. Note that you shouldn't change these
|
* use different output methods. Note that you shouldn't change these
|
||||||
* functions, but rather write replacement functions and then change
|
* functions, but rather write replacement functions and then change
|
||||||
* them at run time with png_set_write_fn(...).
|
* them at run time with png_set_write_fn(...).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#define PNG_NO_PEDANTIC_WARNINGS
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#include "png.h"
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
/* Write the data to whatever output you are using. The default routine
|
|
||||||
* writes to a file pointer. Note that this routine sometimes gets called
|
/* Write the data to whatever output you are using. The default routine
|
||||||
* with very small lengths, so you should implement some kind of simple
|
* writes to a file pointer. Note that this routine sometimes gets called
|
||||||
* buffering if you are using unbuffered writes. This should never be asked
|
* with very small lengths, so you should implement some kind of simple
|
||||||
* to write more than 64K on a 16 bit machine.
|
* buffering if you are using unbuffered writes. This should never be asked
|
||||||
*/
|
* to write more than 64K on a 16 bit machine.
|
||||||
|
*/
|
||||||
void /* PRIVATE */
|
|
||||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
void /* PRIVATE */
|
||||||
{
|
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
if (png_ptr->write_data_fn != NULL )
|
{
|
||||||
(*(png_ptr->write_data_fn))(png_ptr, data, length);
|
if (png_ptr->write_data_fn != NULL )
|
||||||
else
|
(*(png_ptr->write_data_fn))(png_ptr, data, length);
|
||||||
png_error(png_ptr, "Call to NULL write function");
|
else
|
||||||
}
|
png_error(png_ptr, "Call to NULL write function");
|
||||||
|
}
|
||||||
#if !defined(PNG_NO_STDIO)
|
|
||||||
/* This is the function that does the actual writing of data. If you are
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
* not writing to a standard C stream, you should create a replacement
|
/* This is the function that does the actual writing of data. If you are
|
||||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
* not writing to a standard C stream, you should create a replacement
|
||||||
* than changing the library.
|
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
*/
|
* than changing the library.
|
||||||
#ifndef USE_FAR_KEYWORD
|
*/
|
||||||
void PNGAPI
|
#ifndef USE_FAR_KEYWORD
|
||||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
void PNGAPI
|
||||||
{
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_uint_32 check;
|
{
|
||||||
|
png_uint_32 check;
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
if (png_ptr == NULL)
|
||||||
#if defined(_WIN32_WCE)
|
return;
|
||||||
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
#ifdef _WIN32_WCE
|
||||||
check = 0;
|
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||||
#else
|
check = 0;
|
||||||
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
#else
|
||||||
#endif
|
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||||
if (check != length)
|
#endif
|
||||||
png_error(png_ptr, "Write Error");
|
if (check != length)
|
||||||
}
|
png_error(png_ptr, "Write Error");
|
||||||
#else
|
}
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
#else
|
||||||
* can't handle far buffers in the medium and small models, we have to copy
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
* the data.
|
* can't handle far buffers in the medium and small models, we have to copy
|
||||||
*/
|
* the data.
|
||||||
|
*/
|
||||||
#define NEAR_BUF_SIZE 1024
|
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
#define NEAR_BUF_SIZE 1024
|
||||||
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
void PNGAPI
|
|
||||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
void PNGAPI
|
||||||
{
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_uint_32 check;
|
{
|
||||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
png_uint_32 check;
|
||||||
png_FILE_p io_ptr;
|
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||||
|
png_FILE_p io_ptr;
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
if (png_ptr == NULL)
|
||||||
/* Check if data really is near. If so, use usual code. */
|
return;
|
||||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
/* Check if data really is near. If so, use usual code. */
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
if ((png_bytep)near_data == data)
|
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||||
{
|
if ((png_bytep)near_data == data)
|
||||||
#if defined(_WIN32_WCE)
|
{
|
||||||
if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
|
#ifdef _WIN32_WCE
|
||||||
check = 0;
|
if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
|
||||||
#else
|
check = 0;
|
||||||
check = fwrite(near_data, 1, length, io_ptr);
|
#else
|
||||||
#endif
|
check = fwrite(near_data, 1, length, io_ptr);
|
||||||
}
|
#endif
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
png_byte buf[NEAR_BUF_SIZE];
|
{
|
||||||
png_size_t written, remaining, err;
|
png_byte buf[NEAR_BUF_SIZE];
|
||||||
check = 0;
|
png_size_t written, remaining, err;
|
||||||
remaining = length;
|
check = 0;
|
||||||
do
|
remaining = length;
|
||||||
{
|
do
|
||||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
{
|
||||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
#if defined(_WIN32_WCE)
|
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||||
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
|
#ifdef _WIN32_WCE
|
||||||
err = 0;
|
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
|
||||||
#else
|
err = 0;
|
||||||
err = fwrite(buf, 1, written, io_ptr);
|
#else
|
||||||
#endif
|
err = fwrite(buf, 1, written, io_ptr);
|
||||||
if (err != written)
|
#endif
|
||||||
break;
|
if (err != written)
|
||||||
|
break;
|
||||||
else
|
|
||||||
check += err;
|
else
|
||||||
|
check += err;
|
||||||
data += written;
|
|
||||||
remaining -= written;
|
data += written;
|
||||||
}
|
remaining -= written;
|
||||||
while (remaining != 0);
|
}
|
||||||
}
|
while (remaining != 0);
|
||||||
if (check != length)
|
}
|
||||||
png_error(png_ptr, "Write Error");
|
if (check != length)
|
||||||
}
|
png_error(png_ptr, "Write Error");
|
||||||
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
/* This function is called to output any data pending writing (normally
|
|
||||||
* to disk). After png_flush is called, there should be no data pending
|
/* This function is called to output any data pending writing (normally
|
||||||
* writing in any buffers.
|
* to disk). After png_flush is called, there should be no data pending
|
||||||
*/
|
* writing in any buffers.
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
*/
|
||||||
void /* PRIVATE */
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
png_flush(png_structp png_ptr)
|
void /* PRIVATE */
|
||||||
{
|
png_flush(png_structp png_ptr)
|
||||||
if (png_ptr->output_flush_fn != NULL)
|
{
|
||||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
if (png_ptr->output_flush_fn != NULL)
|
||||||
}
|
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||||
|
}
|
||||||
#if !defined(PNG_NO_STDIO)
|
|
||||||
void PNGAPI
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
png_default_flush(png_structp png_ptr)
|
void PNGAPI
|
||||||
{
|
png_default_flush(png_structp png_ptr)
|
||||||
#if !defined(_WIN32_WCE)
|
{
|
||||||
png_FILE_p io_ptr;
|
#ifndef _WIN32_WCE
|
||||||
#endif
|
png_FILE_p io_ptr;
|
||||||
if (png_ptr == NULL)
|
#endif
|
||||||
return;
|
if (png_ptr == NULL)
|
||||||
#if !defined(_WIN32_WCE)
|
return;
|
||||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
#ifndef _WIN32_WCE
|
||||||
fflush(io_ptr);
|
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||||
#endif
|
fflush(io_ptr);
|
||||||
}
|
#endif
|
||||||
#endif
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
/* This function allows the application to supply new output functions for
|
|
||||||
* libpng if standard C streams aren't being used.
|
/* This function allows the application to supply new output functions for
|
||||||
*
|
* libpng if standard C streams aren't being used.
|
||||||
* This function takes as its arguments:
|
*
|
||||||
* png_ptr - pointer to a png output data structure
|
* This function takes as its arguments:
|
||||||
* io_ptr - pointer to user supplied structure containing info about
|
* png_ptr - pointer to a png output data structure
|
||||||
* the output functions. May be NULL.
|
* io_ptr - pointer to user supplied structure containing info about
|
||||||
* write_data_fn - pointer to a new output function that takes as its
|
* the output functions. May be NULL.
|
||||||
* arguments a pointer to a png_struct, a pointer to
|
* write_data_fn - pointer to a new output function that takes as its
|
||||||
* data to be written, and a 32-bit unsigned int that is
|
* arguments a pointer to a png_struct, a pointer to
|
||||||
* the number of bytes to be written. The new write
|
* data to be written, and a 32-bit unsigned int that is
|
||||||
* function should call png_error(png_ptr, "Error msg")
|
* the number of bytes to be written. The new write
|
||||||
* to exit and output any fatal error messages. May be
|
* function should call png_error(png_ptr, "Error msg")
|
||||||
* NULL, in which case libpng's default function will
|
* to exit and output any fatal error messages. May be
|
||||||
* be used.
|
* NULL, in which case libpng's default function will
|
||||||
* flush_data_fn - pointer to a new flush function that takes as its
|
* be used.
|
||||||
* arguments a pointer to a png_struct. After a call to
|
* flush_data_fn - pointer to a new flush function that takes as its
|
||||||
* the flush function, there should be no data in any buffers
|
* arguments a pointer to a png_struct. After a call to
|
||||||
* or pending transmission. If the output method doesn't do
|
* the flush function, there should be no data in any buffers
|
||||||
* any buffering of ouput, a function prototype must still be
|
* or pending transmission. If the output method doesn't do
|
||||||
* supplied although it doesn't have to do anything. If
|
* any buffering of ouput, a function prototype must still be
|
||||||
* PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
* supplied although it doesn't have to do anything. If
|
||||||
* time, output_flush_fn will be ignored, although it must be
|
* PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||||
* supplied for compatibility. May be NULL, in which case
|
* time, output_flush_fn will be ignored, although it must be
|
||||||
* libpng's default function will be used, if
|
* supplied for compatibility. May be NULL, in which case
|
||||||
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
* libpng's default function will be used, if
|
||||||
* a good idea if io_ptr does not point to a standard
|
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||||
* *FILE structure.
|
* a good idea if io_ptr does not point to a standard
|
||||||
*/
|
* *FILE structure.
|
||||||
void PNGAPI
|
*/
|
||||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
void PNGAPI
|
||||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
{
|
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||||
if (png_ptr == NULL)
|
{
|
||||||
return;
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->io_ptr = io_ptr;
|
|
||||||
|
png_ptr->io_ptr = io_ptr;
|
||||||
#if !defined(PNG_NO_STDIO)
|
|
||||||
if (write_data_fn != NULL)
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
png_ptr->write_data_fn = write_data_fn;
|
if (write_data_fn != NULL)
|
||||||
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
else
|
|
||||||
png_ptr->write_data_fn = png_default_write_data;
|
else
|
||||||
#else
|
png_ptr->write_data_fn = png_default_write_data;
|
||||||
png_ptr->write_data_fn = write_data_fn;
|
#else
|
||||||
#endif
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
if (output_flush_fn != NULL)
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
png_ptr->output_flush_fn = output_flush_fn;
|
if (output_flush_fn != NULL)
|
||||||
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
else
|
|
||||||
png_ptr->output_flush_fn = png_default_flush;
|
else
|
||||||
#else
|
png_ptr->output_flush_fn = png_default_flush;
|
||||||
png_ptr->output_flush_fn = output_flush_fn;
|
#else
|
||||||
#endif
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
#endif
|
||||||
|
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||||
/* It is an error to read while writing a png file */
|
|
||||||
if (png_ptr->read_data_fn != NULL)
|
/* It is an error to read while writing a png file */
|
||||||
{
|
if (png_ptr->read_data_fn != NULL)
|
||||||
png_ptr->read_data_fn = NULL;
|
{
|
||||||
png_warning(png_ptr,
|
png_ptr->read_data_fn = NULL;
|
||||||
"Attempted to set both read_data_fn and write_data_fn in");
|
png_warning(png_ptr,
|
||||||
png_warning(png_ptr,
|
"Attempted to set both read_data_fn and write_data_fn in");
|
||||||
"the same structure. Resetting read_data_fn to NULL.");
|
png_warning(png_ptr,
|
||||||
}
|
"the same structure. Resetting read_data_fn to NULL.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#if defined(USE_FAR_KEYWORD)
|
|
||||||
#if defined(_MSC_VER)
|
#ifdef USE_FAR_KEYWORD
|
||||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
#ifdef _MSC_VER
|
||||||
{
|
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||||
void *near_ptr;
|
{
|
||||||
void FAR *far_ptr;
|
void *near_ptr;
|
||||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
void FAR *far_ptr;
|
||||||
far_ptr = (void FAR *)near_ptr;
|
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||||
|
far_ptr = (void FAR *)near_ptr;
|
||||||
if (check != 0)
|
|
||||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
if (check != 0)
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||||
|
png_error(png_ptr, "segment lost in conversion");
|
||||||
return(near_ptr);
|
|
||||||
}
|
return(near_ptr);
|
||||||
# else
|
}
|
||||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
# else
|
||||||
{
|
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||||
void *near_ptr;
|
{
|
||||||
void FAR *far_ptr;
|
void *near_ptr;
|
||||||
near_ptr = (void FAR *)ptr;
|
void FAR *far_ptr;
|
||||||
far_ptr = (void FAR *)near_ptr;
|
near_ptr = (void FAR *)ptr;
|
||||||
|
far_ptr = (void FAR *)near_ptr;
|
||||||
if (check != 0)
|
|
||||||
if (far_ptr != ptr)
|
if (check != 0)
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
if (far_ptr != ptr)
|
||||||
|
png_error(png_ptr, "segment lost in conversion");
|
||||||
return(near_ptr);
|
|
||||||
}
|
return(near_ptr);
|
||||||
# endif
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif /* PNG_WRITE_SUPPORTED */
|
# endif
|
||||||
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue