0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * This file is available under and governed by the GNU General Public 0N/A * License version 2 only, as published by the Free Software Foundation. 0N/A * However, the following notice accompanied the original version of this 0N/A * file and, per its terms, should not be removed: 4418N/A * Last changed in libpng 1.5.4 [July 7, 2011] 4418N/A * Copyright (c) 1998-2011 Glenn Randers-Pehrson 0N/A * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 0N/A * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 4418N/A * This code is released under the libpng license. 4418N/A * For conditions of distribution and use, see the disclaimer 0N/A * This file provides a location for all error handling. Users who 0N/A * need special error handling are expected to write replacement functions 0N/A * and use png_set_error_fn() to use those functions. See the instructions 0N/Astatic void /* PRIVATE */ 4418N/A#
endif /* PNG_WARNINGS_SUPPORTED */ 0N/A/* This function is called whenever there is a fatal error. This function 0N/A * should not be changed. If there is a need to handle errors differently, 0N/A * you should supply a replacement error function and use png_set_error_fn() 0N/A * to replace the error function at run-time. 4418N/A /* Strip "#nnnn " from beginning of error message. */ 0N/A /* If the custom handler doesn't exist, or if it returns, 0N/A use the default handler, which will not return. */ 4418N/A /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed 4418N/A * erroneously as '\0', instead of the empty string "". This was 4418N/A * apparently an error, introduced in libpng-1.2.20, and png_default_error 4418N/A /* If the custom handler doesn't exist, or if it returns, 4418N/A use the default handler, which will not return. */ 4418N/A#
endif /* PNG_ERROR_TEXT_SUPPORTED */ 4418N/A/* Utility to safely appends strings to a buffer. This never errors out so 4418N/A * error checking is not required in the caller. 4418N/A/* Utility to dump an unsigned value into a buffer, given a start pointer and 4418N/A * and end pointer (which should point just *beyond* the end of the buffer!) 4418N/A * Returns the pointer to the start of the formatted string. 4418N/A int output = 0;
/* digit output (for the fixed point format) */ 4418N/A /* This is written so that the loop always runs at least once, even with 4418N/A /* Needs five digits (the fraction) */ 4418N/A /* Expects at least 2 digits. */ 4418N/A /* This format expects at least two digits */ 4418N/A /* Keep track of the number of digits added */ 4418N/A /* Float a fixed number here: */ 4418N/A /* End of the fraction, but maybe nothing was output? In that case 4418N/A * drop the decimal point. If the number is a true zero handle that 0N/A/* This function is called whenever there is a non-fatal error. This function 0N/A * should not be changed. If there is a need to handle warnings differently, 0N/A * you should supply a replacement warning function and use 0N/A * png_set_error_fn() to replace the warning function at run-time. 4418N/A/* These functions support 'formatted' warning messages with up to 4418N/A * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter 4418N/A * is introduced by @<number>, where 'number' starts at 1. This follows the 4418N/A * standard established by X/Open for internationalizable error messages. 4418N/A /* Avoid overflow by doing the negate in a png_alloc_size_t: */ 4418N/A /* The internal buffer is just 128 bytes - enough for all our messages, 4418N/A * overflow doesn't happen because this code checks! 4418N/A continue;
/* To break out of the for loop above. */ 4418N/A /* Append this parameter */ 4418N/A /* No need to copy the trailing '\0' here, but there is no guarantee 4418N/A * that parm[] has been initialized, so there is no guarantee of a 4418N/A /* else not a parameter and there is a character after the @ sign; just 4418N/A /* At this point *message can't be '\0', even in the bad parameter case 4418N/A * above where there is a lone '@' at the end of the message string. 4418N/A /* i is always less than (sizeof msg), so: */ 4418N/A /* And this is the formatted message: */ 4418N/A#
endif /* PNG_WARNINGS_SUPPORTED */ 0N/A/* These utilities are used internally to build an error message that relates 0N/A * to the current chunk. The chunk name comes from png_ptr->chunk_name, 0N/A * this is used to prefix the message. The message is limited in length 0N/A * to 63 bytes, the name characters are output as hex digits wrapped in [] 0N/A * if the character is invalid. 0N/A#
define isnonalpha(c) ((c) <
65 || (c) >
122 || ((c) >
90 && (c) <
97))
0N/A '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
0N/A 'A',
'B',
'C',
'D',
'E',
'F' 0N/Astatic void /* PRIVATE */ 4418N/A /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ 4418N/A#
endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ 4418N/A#
endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */ 4418N/A#
endif /* PNG_WARNINGS_SUPPORTED */ 4418N/A#
endif /* PNG_READ_SUPPORTED */ 4418N/A/* This API only exists if ANSI-C style error handling is used, 4418N/A * otherwise it is necessary for png_default_error to be overridden. 0N/A/* This is the default error handling function. Note that replacements for 0N/A * this function MUST NOT RETURN, or the program will likely crash. This 0N/A * function is used by default, or if the program supplies NULL for the 0N/A * error function pointer in png_set_error_fn(). 4418N/A /* Check on NULL only added in 1.5.4 */ 4418N/A /* Strip "#nnnn " from beginning of error message. */ 4418N/A /* Here if not setjmp support or if png_ptr is null. */ 0N/A/* This function is called when there is a warning, but the library thinks 0N/A * it can continue anyway. Replacement functions don't have to do anything 0N/A * here if you don't want them to. In the default configuration, png_ptr is 0N/A * not used, but it is passed in case it may be useful. 0N/Astatic void /* PRIVATE */ 4418N/A#
endif /* PNG_WARNINGS_SUPPORTED */ 0N/A/* This function is called when the application wants to use another method 0N/A * of handling errors and warnings. Note that the error function MUST NOT 0N/A * return to the calling routine or serious problems will occur. The return 4418N/A * method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1) 0N/A/* This function returns a pointer to the error_ptr associated with the user 0N/A * functions. The application should free any memory associated with this 0N/A * pointer before png_write_destroy and png_read_destroy are called. 0N/A#
endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */