Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpngerror.c
Go to the documentation of this file.
00001 00002 /* pngerror.c - stub functions for i/o and memory allocation 00003 * 00004 * Last changed in libpng 1.5.8 [February 1, 2011] 00005 * Copyright (c) 1998-2012 Glenn Randers-Pehrson 00006 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 00007 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 00008 * 00009 * This code is released under the libpng license. 00010 * For conditions of distribution and use, see the disclaimer 00011 * and license in png.h 00012 * 00013 * This file provides a location for all error handling. Users who 00014 * need special error handling are expected to write replacement functions 00015 * and use png_set_error_fn() to use those functions. See the instructions 00016 * at each function. 00017 */ 00018 00019 #include "pngpriv.h" 00020 00021 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 00022 00023 static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr, 00024 png_const_charp error_message)),PNG_NORETURN); 00025 00026 #ifdef PNG_WARNINGS_SUPPORTED 00027 static void /* PRIVATE */ 00028 png_default_warning PNGARG((png_structp png_ptr, 00029 png_const_charp warning_message)); 00030 #endif /* PNG_WARNINGS_SUPPORTED */ 00031 00032 /* This function is called whenever there is a fatal error. This function 00033 * should not be changed. If there is a need to handle errors differently, 00034 * you should supply a replacement error function and use png_set_error_fn() 00035 * to replace the error function at run-time. 00036 */ 00037 #ifdef PNG_ERROR_TEXT_SUPPORTED 00038 PNG_FUNCTION(void,PNGAPI 00039 png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN) 00040 { 00041 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 00042 char msg[16]; 00043 if (png_ptr != NULL) 00044 { 00045 if (png_ptr->flags& 00046 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) 00047 { 00048 if (*error_message == PNG_LITERAL_SHARP) 00049 { 00050 /* Strip "#nnnn " from beginning of error message. */ 00051 int offset; 00052 for (offset = 1; offset<15; offset++) 00053 if (error_message[offset] == ' ') 00054 break; 00055 00056 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 00057 { 00058 int i; 00059 for (i = 0; i < offset - 1; i++) 00060 msg[i] = error_message[i + 1]; 00061 msg[i - 1] = '\0'; 00062 error_message = msg; 00063 } 00064 00065 else 00066 error_message += offset; 00067 } 00068 00069 else 00070 { 00071 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 00072 { 00073 msg[0] = '0'; 00074 msg[1] = '\0'; 00075 error_message = msg; 00076 } 00077 } 00078 } 00079 } 00080 #endif 00081 if (png_ptr != NULL && png_ptr->error_fn != NULL) 00082 (*(png_ptr->error_fn))(png_ptr, error_message); 00083 00084 /* If the custom handler doesn't exist, or if it returns, 00085 use the default handler, which will not return. */ 00086 png_default_error(png_ptr, error_message); 00087 } 00088 #else 00089 PNG_FUNCTION(void,PNGAPI 00090 png_err,(png_structp png_ptr),PNG_NORETURN) 00091 { 00092 /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed 00093 * erroneously as '\0', instead of the empty string "". This was 00094 * apparently an error, introduced in libpng-1.2.20, and png_default_error 00095 * will crash in this case. 00096 */ 00097 if (png_ptr != NULL && png_ptr->error_fn != NULL) 00098 (*(png_ptr->error_fn))(png_ptr, ""); 00099 00100 /* If the custom handler doesn't exist, or if it returns, 00101 use the default handler, which will not return. */ 00102 png_default_error(png_ptr, ""); 00103 } 00104 #endif /* PNG_ERROR_TEXT_SUPPORTED */ 00105 00106 /* Utility to safely appends strings to a buffer. This never errors out so 00107 * error checking is not required in the caller. 00108 */ 00109 size_t 00110 png_safecat(png_charp buffer, size_t bufsize, size_t pos, 00111 png_const_charp string) 00112 { 00113 if (buffer != NULL && pos < bufsize) 00114 { 00115 if (string != NULL) 00116 while (*string != '\0' && pos < bufsize-1) 00117 buffer[pos++] = *string++; 00118 00119 buffer[pos] = '\0'; 00120 } 00121 00122 return pos; 00123 } 00124 00125 #if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) 00126 /* Utility to dump an unsigned value into a buffer, given a start pointer and 00127 * and end pointer (which should point just *beyond* the end of the buffer!) 00128 * Returns the pointer to the start of the formatted string. 00129 */ 00130 png_charp 00131 png_format_number(png_const_charp start, png_charp end, int format, 00132 png_alloc_size_t number) 00133 { 00134 int count = 0; /* number of digits output */ 00135 int mincount = 1; /* minimum number required */ 00136 int output = 0; /* digit output (for the fixed point format) */ 00137 00138 *--end = '\0'; 00139 00140 /* This is written so that the loop always runs at least once, even with 00141 * number zero. 00142 */ 00143 while (end > start && (number != 0 || count < mincount)) 00144 { 00145 00146 static const char digits[] = "0123456789ABCDEF"; 00147 00148 switch (format) 00149 { 00150 case PNG_NUMBER_FORMAT_fixed: 00151 /* Needs five digits (the fraction) */ 00152 mincount = 5; 00153 if (output || number % 10 != 0) 00154 { 00155 *--end = digits[number % 10]; 00156 output = 1; 00157 } 00158 number /= 10; 00159 break; 00160 00161 case PNG_NUMBER_FORMAT_02u: 00162 /* Expects at least 2 digits. */ 00163 mincount = 2; 00164 /* fall through */ 00165 00166 case PNG_NUMBER_FORMAT_u: 00167 *--end = digits[number % 10]; 00168 number /= 10; 00169 break; 00170 00171 case PNG_NUMBER_FORMAT_02x: 00172 /* This format expects at least two digits */ 00173 mincount = 2; 00174 /* fall through */ 00175 00176 case PNG_NUMBER_FORMAT_x: 00177 *--end = digits[number & 0xf]; 00178 number >>= 4; 00179 break; 00180 00181 default: /* an error */ 00182 number = 0; 00183 break; 00184 } 00185 00186 /* Keep track of the number of digits added */ 00187 ++count; 00188 00189 /* Float a fixed number here: */ 00190 if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start) 00191 { 00192 /* End of the fraction, but maybe nothing was output? In that case 00193 * drop the decimal point. If the number is a true zero handle that 00194 * here. 00195 */ 00196 if (output) 00197 *--end = '.'; 00198 else if (number == 0) /* and !output */ 00199 *--end = '0'; 00200 } 00201 } 00202 00203 return end; 00204 } 00205 #endif 00206 00207 #ifdef PNG_WARNINGS_SUPPORTED 00208 /* This function is called whenever there is a non-fatal error. This function 00209 * should not be changed. If there is a need to handle warnings differently, 00210 * you should supply a replacement warning function and use 00211 * png_set_error_fn() to replace the warning function at run-time. 00212 */ 00213 void PNGAPI 00214 png_warning(png_structp png_ptr, png_const_charp warning_message) 00215 { 00216 int offset = 0; 00217 if (png_ptr != NULL) 00218 { 00219 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 00220 if (png_ptr->flags& 00221 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) 00222 #endif 00223 { 00224 if (*warning_message == PNG_LITERAL_SHARP) 00225 { 00226 for (offset = 1; offset < 15; offset++) 00227 if (warning_message[offset] == ' ') 00228 break; 00229 } 00230 } 00231 } 00232 if (png_ptr != NULL && png_ptr->warning_fn != NULL) 00233 (*(png_ptr->warning_fn))(png_ptr, warning_message + offset); 00234 else 00235 png_default_warning(png_ptr, warning_message + offset); 00236 } 00237 00238 /* These functions support 'formatted' warning messages with up to 00239 * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter 00240 * is introduced by @<number>, where 'number' starts at 1. This follows the 00241 * standard established by X/Open for internationalizable error messages. 00242 */ 00243 void 00244 png_warning_parameter(png_warning_parameters p, int number, 00245 png_const_charp string) 00246 { 00247 if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) 00248 (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); 00249 } 00250 00251 void 00252 png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, 00253 png_alloc_size_t value) 00254 { 00255 char buffer[PNG_NUMBER_BUFFER_SIZE]; 00256 png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); 00257 } 00258 00259 void 00260 png_warning_parameter_signed(png_warning_parameters p, int number, int format, 00261 png_int_32 value) 00262 { 00263 png_alloc_size_t u; 00264 png_charp str; 00265 char buffer[PNG_NUMBER_BUFFER_SIZE]; 00266 00267 /* Avoid overflow by doing the negate in a png_alloc_size_t: */ 00268 u = (png_alloc_size_t)value; 00269 if (value < 0) 00270 u = ~u + 1; 00271 00272 str = PNG_FORMAT_NUMBER(buffer, format, u); 00273 00274 if (value < 0 && str > buffer) 00275 *--str = '-'; 00276 00277 png_warning_parameter(p, number, str); 00278 } 00279 00280 void 00281 png_formatted_warning(png_structp png_ptr, png_warning_parameters p, 00282 png_const_charp message) 00283 { 00284 /* The internal buffer is just 192 bytes - enough for all our messages, 00285 * overflow doesn't happen because this code checks! If someone figures 00286 * out how to send us a message longer than 192 bytes, all that will 00287 * happen is that the message will be truncated appropriately. 00288 */ 00289 size_t i = 0; /* Index in the msg[] buffer: */ 00290 char msg[192]; 00291 00292 /* Each iteration through the following loop writes at most one character 00293 * to msg[i++] then returns here to validate that there is still space for 00294 * the trailing '\0'. It may (in the case of a parameter) read more than 00295 * one character from message[]; it must check for '\0' and continue to the 00296 * test if it finds the end of string. 00297 */ 00298 while (i<(sizeof msg)-1 && *message != '\0') 00299 { 00300 /* '@' at end of string is now just printed (previously it was skipped); 00301 * it is an error in the calling code to terminate the string with @. 00302 */ 00303 if (p != NULL && *message == '@' && message[1] != '\0') 00304 { 00305 int parameter_char = *++message; /* Consume the '@' */ 00306 static const char valid_parameters[] = "123456789"; 00307 int parameter = 0; 00308 00309 /* Search for the parameter digit, the index in the string is the 00310 * parameter to use. 00311 */ 00312 while (valid_parameters[parameter] != parameter_char && 00313 valid_parameters[parameter] != '\0') 00314 ++parameter; 00315 00316 /* If the parameter digit is out of range it will just get printed. */ 00317 if (parameter < PNG_WARNING_PARAMETER_COUNT) 00318 { 00319 /* Append this parameter */ 00320 png_const_charp parm = p[parameter]; 00321 png_const_charp pend = p[parameter] + (sizeof p[parameter]); 00322 00323 /* No need to copy the trailing '\0' here, but there is no guarantee 00324 * that parm[] has been initialized, so there is no guarantee of a 00325 * trailing '\0': 00326 */ 00327 while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend) 00328 msg[i++] = *parm++; 00329 00330 /* Consume the parameter digit too: */ 00331 ++message; 00332 continue; 00333 } 00334 00335 /* else not a parameter and there is a character after the @ sign; just 00336 * copy that. This is known not to be '\0' because of the test above. 00337 */ 00338 } 00339 00340 /* At this point *message can't be '\0', even in the bad parameter case 00341 * above where there is a lone '@' at the end of the message string. 00342 */ 00343 msg[i++] = *message++; 00344 } 00345 00346 /* i is always less than (sizeof msg), so: */ 00347 msg[i] = '\0'; 00348 00349 /* And this is the formatted message, it may be larger than 00350 * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are 00351 * not (currently) formatted. 00352 */ 00353 png_warning(png_ptr, msg); 00354 } 00355 #endif /* PNG_WARNINGS_SUPPORTED */ 00356 00357 #ifdef PNG_BENIGN_ERRORS_SUPPORTED 00358 void PNGAPI 00359 png_benign_error(png_structp png_ptr, png_const_charp error_message) 00360 { 00361 if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) 00362 png_warning(png_ptr, error_message); 00363 else 00364 png_error(png_ptr, error_message); 00365 } 00366 #endif 00367 00368 /* These utilities are used internally to build an error message that relates 00369 * to the current chunk. The chunk name comes from png_ptr->chunk_name, 00370 * this is used to prefix the message. The message is limited in length 00371 * to 63 bytes, the name characters are output as hex digits wrapped in [] 00372 * if the character is invalid. 00373 */ 00374 #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) 00375 static PNG_CONST char png_digit[16] = { 00376 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 00377 'A', 'B', 'C', 'D', 'E', 'F' 00378 }; 00379 00380 #define PNG_MAX_ERROR_TEXT 64 00381 #if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) 00382 static void /* PRIVATE */ 00383 png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp 00384 error_message) 00385 { 00386 png_uint_32 chunk_name = png_ptr->chunk_name; 00387 int iout = 0, ishift = 24; 00388 00389 while (ishift >= 0) 00390 { 00391 int c = (int)(chunk_name >> ishift) & 0xff; 00392 00393 ishift -= 8; 00394 if (isnonalpha(c)) 00395 { 00396 buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; 00397 buffer[iout++] = png_digit[(c & 0xf0) >> 4]; 00398 buffer[iout++] = png_digit[c & 0x0f]; 00399 buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; 00400 } 00401 00402 else 00403 { 00404 buffer[iout++] = (char)c; 00405 } 00406 } 00407 00408 if (error_message == NULL) 00409 buffer[iout] = '\0'; 00410 00411 else 00412 { 00413 int iin = 0; 00414 00415 buffer[iout++] = ':'; 00416 buffer[iout++] = ' '; 00417 00418 while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') 00419 buffer[iout++] = error_message[iin++]; 00420 00421 /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ 00422 buffer[iout] = '\0'; 00423 } 00424 } 00425 #endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ 00426 00427 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) 00428 PNG_FUNCTION(void,PNGAPI 00429 png_chunk_error,(png_structp png_ptr, png_const_charp error_message), 00430 PNG_NORETURN) 00431 { 00432 char msg[18+PNG_MAX_ERROR_TEXT]; 00433 if (png_ptr == NULL) 00434 png_error(png_ptr, error_message); 00435 00436 else 00437 { 00438 png_format_buffer(png_ptr, msg, error_message); 00439 png_error(png_ptr, msg); 00440 } 00441 } 00442 #endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */ 00443 00444 #ifdef PNG_WARNINGS_SUPPORTED 00445 void PNGAPI 00446 png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) 00447 { 00448 char msg[18+PNG_MAX_ERROR_TEXT]; 00449 if (png_ptr == NULL) 00450 png_warning(png_ptr, warning_message); 00451 00452 else 00453 { 00454 png_format_buffer(png_ptr, msg, warning_message); 00455 png_warning(png_ptr, msg); 00456 } 00457 } 00458 #endif /* PNG_WARNINGS_SUPPORTED */ 00459 00460 #ifdef PNG_READ_SUPPORTED 00461 #ifdef PNG_BENIGN_ERRORS_SUPPORTED 00462 void PNGAPI 00463 png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message) 00464 { 00465 if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) 00466 png_chunk_warning(png_ptr, error_message); 00467 00468 else 00469 png_chunk_error(png_ptr, error_message); 00470 } 00471 #endif 00472 #endif /* PNG_READ_SUPPORTED */ 00473 00474 #ifdef PNG_ERROR_TEXT_SUPPORTED 00475 #ifdef PNG_FLOATING_POINT_SUPPORTED 00476 PNG_FUNCTION(void, 00477 png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN) 00478 { 00479 # define fixed_message "fixed point overflow in " 00480 # define fixed_message_ln ((sizeof fixed_message)-1) 00481 int iin; 00482 char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; 00483 png_memcpy(msg, fixed_message, fixed_message_ln); 00484 iin = 0; 00485 if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) 00486 { 00487 msg[fixed_message_ln + iin] = name[iin]; 00488 ++iin; 00489 } 00490 msg[fixed_message_ln + iin] = 0; 00491 png_error(png_ptr, msg); 00492 } 00493 #endif 00494 #endif 00495 00496 #ifdef PNG_SETJMP_SUPPORTED 00497 /* This API only exists if ANSI-C style error handling is used, 00498 * otherwise it is necessary for png_default_error to be overridden. 00499 */ 00500 jmp_buf* PNGAPI 00501 png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn, 00502 size_t jmp_buf_size) 00503 { 00504 if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf)) 00505 return NULL; 00506 00507 png_ptr->longjmp_fn = longjmp_fn; 00508 return &png_ptr->longjmp_buffer; 00509 } 00510 #endif 00511 00512 /* This is the default error handling function. Note that replacements for 00513 * this function MUST NOT RETURN, or the program will likely crash. This 00514 * function is used by default, or if the program supplies NULL for the 00515 * error function pointer in png_set_error_fn(). 00516 */ 00517 static PNG_FUNCTION(void /* PRIVATE */, 00518 png_default_error,(png_structp png_ptr, png_const_charp error_message), 00519 PNG_NORETURN) 00520 { 00521 #ifdef PNG_CONSOLE_IO_SUPPORTED 00522 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 00523 /* Check on NULL only added in 1.5.4 */ 00524 if (error_message != NULL && *error_message == PNG_LITERAL_SHARP) 00525 { 00526 /* Strip "#nnnn " from beginning of error message. */ 00527 int offset; 00528 char error_number[16]; 00529 for (offset = 0; offset<15; offset++) 00530 { 00531 error_number[offset] = error_message[offset + 1]; 00532 if (error_message[offset] == ' ') 00533 break; 00534 } 00535 00536 if ((offset > 1) && (offset < 15)) 00537 { 00538 error_number[offset - 1] = '\0'; 00539 fprintf(stderr, "libpng error no. %s: %s", 00540 error_number, error_message + offset + 1); 00541 fprintf(stderr, PNG_STRING_NEWLINE); 00542 } 00543 00544 else 00545 { 00546 fprintf(stderr, "libpng error: %s, offset=%d", 00547 error_message, offset); 00548 fprintf(stderr, PNG_STRING_NEWLINE); 00549 } 00550 } 00551 else 00552 #endif 00553 { 00554 fprintf(stderr, "libpng error: %s", error_message ? error_message : 00555 "undefined"); 00556 fprintf(stderr, PNG_STRING_NEWLINE); 00557 } 00558 #else 00559 PNG_UNUSED(error_message) /* Make compiler happy */ 00560 #endif 00561 png_longjmp(png_ptr, 1); 00562 } 00563 00564 PNG_FUNCTION(void,PNGAPI 00565 png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN) 00566 { 00567 #ifdef PNG_SETJMP_SUPPORTED 00568 if (png_ptr && png_ptr->longjmp_fn) 00569 { 00570 # ifdef USE_FAR_KEYWORD 00571 { 00572 jmp_buf tmp_jmpbuf; 00573 png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf)); 00574 png_ptr->longjmp_fn(tmp_jmpbuf, val); 00575 } 00576 00577 # else 00578 png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val); 00579 # endif 00580 } 00581 #endif 00582 /* Here if not setjmp support or if png_ptr is null. */ 00583 PNG_ABORT(); 00584 } 00585 00586 #ifdef PNG_WARNINGS_SUPPORTED 00587 /* This function is called when there is a warning, but the library thinks 00588 * it can continue anyway. Replacement functions don't have to do anything 00589 * here if you don't want them to. In the default configuration, png_ptr is 00590 * not used, but it is passed in case it may be useful. 00591 */ 00592 static void /* PRIVATE */ 00593 png_default_warning(png_structp png_ptr, png_const_charp warning_message) 00594 { 00595 #ifdef PNG_CONSOLE_IO_SUPPORTED 00596 # ifdef PNG_ERROR_NUMBERS_SUPPORTED 00597 if (*warning_message == PNG_LITERAL_SHARP) 00598 { 00599 int offset; 00600 char warning_number[16]; 00601 for (offset = 0; offset < 15; offset++) 00602 { 00603 warning_number[offset] = warning_message[offset + 1]; 00604 if (warning_message[offset] == ' ') 00605 break; 00606 } 00607 00608 if ((offset > 1) && (offset < 15)) 00609 { 00610 warning_number[offset + 1] = '\0'; 00611 fprintf(stderr, "libpng warning no. %s: %s", 00612 warning_number, warning_message + offset); 00613 fprintf(stderr, PNG_STRING_NEWLINE); 00614 } 00615 00616 else 00617 { 00618 fprintf(stderr, "libpng warning: %s", 00619 warning_message); 00620 fprintf(stderr, PNG_STRING_NEWLINE); 00621 } 00622 } 00623 else 00624 # endif 00625 00626 { 00627 fprintf(stderr, "libpng warning: %s", warning_message); 00628 fprintf(stderr, PNG_STRING_NEWLINE); 00629 } 00630 #else 00631 PNG_UNUSED(warning_message) /* Make compiler happy */ 00632 #endif 00633 PNG_UNUSED(png_ptr) /* Make compiler happy */ 00634 } 00635 #endif /* PNG_WARNINGS_SUPPORTED */ 00636 00637 /* This function is called when the application wants to use another method 00638 * of handling errors and warnings. Note that the error function MUST NOT 00639 * return to the calling routine or serious problems will occur. The return 00640 * method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1) 00641 */ 00642 void PNGAPI 00643 png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, 00644 png_error_ptr error_fn, png_error_ptr warning_fn) 00645 { 00646 if (png_ptr == NULL) 00647 return; 00648 00649 png_ptr->error_ptr = error_ptr; 00650 png_ptr->error_fn = error_fn; 00651 #ifdef PNG_WARNINGS_SUPPORTED 00652 png_ptr->warning_fn = warning_fn; 00653 #else 00654 PNG_UNUSED(warning_fn) 00655 #endif 00656 } 00657 00658 00659 /* This function returns a pointer to the error_ptr associated with the user 00660 * functions. The application should free any memory associated with this 00661 * pointer before png_write_destroy and png_read_destroy are called. 00662 */ 00663 png_voidp PNGAPI 00664 png_get_error_ptr(png_const_structp png_ptr) 00665 { 00666 if (png_ptr == NULL) 00667 return NULL; 00668 00669 return ((png_voidp)png_ptr->error_ptr); 00670 } 00671 00672 00673 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 00674 void PNGAPI 00675 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) 00676 { 00677 if (png_ptr != NULL) 00678 { 00679 png_ptr->flags &= 00680 ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | 00681 PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); 00682 } 00683 } 00684 #endif 00685 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ Generated on Sat May 26 2012 04:18:16 for ReactOS by
1.7.6.1
|