Fork of DMemWin by
png/pngerror.c@4:20387dbf7ecf, 2016-06-02 (annotated)
- Committer:
- destinyXfate
- Date:
- Thu Jun 02 04:55:08 2016 +0000
- Revision:
- 4:20387dbf7ecf
- Parent:
- 2:0e2ef1edf01b
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
destinyXfate | 2:0e2ef1edf01b | 1 | |
destinyXfate | 2:0e2ef1edf01b | 2 | /* pngerror.c - stub functions for i/o and memory allocation |
destinyXfate | 2:0e2ef1edf01b | 3 | * |
destinyXfate | 2:0e2ef1edf01b | 4 | * Last changed in libpng 1.2.13 November 13, 2006 |
destinyXfate | 2:0e2ef1edf01b | 5 | * For conditions of distribution and use, see copyright notice in png.h |
destinyXfate | 2:0e2ef1edf01b | 6 | * Copyright (c) 1998-2006 Glenn Randers-Pehrson |
destinyXfate | 2:0e2ef1edf01b | 7 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
destinyXfate | 2:0e2ef1edf01b | 8 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
destinyXfate | 2:0e2ef1edf01b | 9 | * |
destinyXfate | 2:0e2ef1edf01b | 10 | * This file provides a location for all error handling. Users who |
destinyXfate | 2:0e2ef1edf01b | 11 | * need special error handling are expected to write replacement functions |
destinyXfate | 2:0e2ef1edf01b | 12 | * and use png_set_error_fn() to use those functions. See the instructions |
destinyXfate | 2:0e2ef1edf01b | 13 | * at each function. |
destinyXfate | 2:0e2ef1edf01b | 14 | */ |
destinyXfate | 2:0e2ef1edf01b | 15 | |
destinyXfate | 2:0e2ef1edf01b | 16 | #define PNG_INTERNAL |
destinyXfate | 2:0e2ef1edf01b | 17 | #include "png.h" |
destinyXfate | 2:0e2ef1edf01b | 18 | |
destinyXfate | 2:0e2ef1edf01b | 19 | #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
destinyXfate | 2:0e2ef1edf01b | 20 | static void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 21 | png_default_error PNGARG((png_structp png_ptr, |
destinyXfate | 2:0e2ef1edf01b | 22 | png_const_charp error_message)); |
destinyXfate | 2:0e2ef1edf01b | 23 | static void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 24 | png_default_warning PNGARG((png_structp png_ptr, |
destinyXfate | 2:0e2ef1edf01b | 25 | png_const_charp warning_message)); |
destinyXfate | 2:0e2ef1edf01b | 26 | |
destinyXfate | 2:0e2ef1edf01b | 27 | /* This function is called whenever there is a fatal error. This function |
destinyXfate | 2:0e2ef1edf01b | 28 | * should not be changed. If there is a need to handle errors differently, |
destinyXfate | 2:0e2ef1edf01b | 29 | * you should supply a replacement error function and use png_set_error_fn() |
destinyXfate | 2:0e2ef1edf01b | 30 | * to replace the error function at run-time. |
destinyXfate | 2:0e2ef1edf01b | 31 | */ |
destinyXfate | 2:0e2ef1edf01b | 32 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 33 | png_error(png_structp png_ptr, png_const_charp error_message) |
destinyXfate | 2:0e2ef1edf01b | 34 | { |
destinyXfate | 2:0e2ef1edf01b | 35 | #ifdef PNG_ERROR_NUMBERS_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 36 | char msg[16]; |
destinyXfate | 2:0e2ef1edf01b | 37 | if (png_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 38 | { |
destinyXfate | 2:0e2ef1edf01b | 39 | if (png_ptr->flags& |
destinyXfate | 2:0e2ef1edf01b | 40 | (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) |
destinyXfate | 2:0e2ef1edf01b | 41 | { |
destinyXfate | 2:0e2ef1edf01b | 42 | if (*error_message == '#') |
destinyXfate | 2:0e2ef1edf01b | 43 | { |
destinyXfate | 2:0e2ef1edf01b | 44 | int offset; |
destinyXfate | 2:0e2ef1edf01b | 45 | for (offset=1; offset<15; offset++) |
destinyXfate | 2:0e2ef1edf01b | 46 | if (*(error_message+offset) == ' ') |
destinyXfate | 2:0e2ef1edf01b | 47 | break; |
destinyXfate | 2:0e2ef1edf01b | 48 | if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) |
destinyXfate | 2:0e2ef1edf01b | 49 | { |
destinyXfate | 2:0e2ef1edf01b | 50 | int i; |
destinyXfate | 2:0e2ef1edf01b | 51 | for (i=0; i<offset-1; i++) |
destinyXfate | 2:0e2ef1edf01b | 52 | msg[i]=error_message[i+1]; |
destinyXfate | 2:0e2ef1edf01b | 53 | msg[i]='\0'; |
destinyXfate | 2:0e2ef1edf01b | 54 | error_message=msg; |
destinyXfate | 2:0e2ef1edf01b | 55 | } |
destinyXfate | 2:0e2ef1edf01b | 56 | else |
destinyXfate | 2:0e2ef1edf01b | 57 | error_message+=offset; |
destinyXfate | 2:0e2ef1edf01b | 58 | } |
destinyXfate | 2:0e2ef1edf01b | 59 | else |
destinyXfate | 2:0e2ef1edf01b | 60 | { |
destinyXfate | 2:0e2ef1edf01b | 61 | if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) |
destinyXfate | 2:0e2ef1edf01b | 62 | { |
destinyXfate | 2:0e2ef1edf01b | 63 | msg[0]='0'; |
destinyXfate | 2:0e2ef1edf01b | 64 | msg[1]='\0'; |
destinyXfate | 2:0e2ef1edf01b | 65 | error_message=msg; |
destinyXfate | 2:0e2ef1edf01b | 66 | } |
destinyXfate | 2:0e2ef1edf01b | 67 | } |
destinyXfate | 2:0e2ef1edf01b | 68 | } |
destinyXfate | 2:0e2ef1edf01b | 69 | } |
destinyXfate | 2:0e2ef1edf01b | 70 | #endif |
destinyXfate | 2:0e2ef1edf01b | 71 | if (png_ptr != NULL && png_ptr->error_fn != NULL) |
destinyXfate | 2:0e2ef1edf01b | 72 | (*(png_ptr->error_fn))(png_ptr, error_message); |
destinyXfate | 2:0e2ef1edf01b | 73 | |
destinyXfate | 2:0e2ef1edf01b | 74 | /* If the custom handler doesn't exist, or if it returns, |
destinyXfate | 2:0e2ef1edf01b | 75 | use the default handler, which will not return. */ |
destinyXfate | 2:0e2ef1edf01b | 76 | png_default_error(png_ptr, error_message); |
destinyXfate | 2:0e2ef1edf01b | 77 | } |
destinyXfate | 2:0e2ef1edf01b | 78 | |
destinyXfate | 2:0e2ef1edf01b | 79 | /* This function is called whenever there is a non-fatal error. This function |
destinyXfate | 2:0e2ef1edf01b | 80 | * should not be changed. If there is a need to handle warnings differently, |
destinyXfate | 2:0e2ef1edf01b | 81 | * you should supply a replacement warning function and use |
destinyXfate | 2:0e2ef1edf01b | 82 | * png_set_error_fn() to replace the warning function at run-time. |
destinyXfate | 2:0e2ef1edf01b | 83 | */ |
destinyXfate | 2:0e2ef1edf01b | 84 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 85 | png_warning(png_structp png_ptr, png_const_charp warning_message) |
destinyXfate | 2:0e2ef1edf01b | 86 | { |
destinyXfate | 2:0e2ef1edf01b | 87 | int offset = 0; |
destinyXfate | 2:0e2ef1edf01b | 88 | if (png_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 89 | { |
destinyXfate | 2:0e2ef1edf01b | 90 | #ifdef PNG_ERROR_NUMBERS_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 91 | if (png_ptr->flags& |
destinyXfate | 2:0e2ef1edf01b | 92 | (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) |
destinyXfate | 2:0e2ef1edf01b | 93 | #endif |
destinyXfate | 2:0e2ef1edf01b | 94 | { |
destinyXfate | 2:0e2ef1edf01b | 95 | if (*warning_message == '#') |
destinyXfate | 2:0e2ef1edf01b | 96 | { |
destinyXfate | 2:0e2ef1edf01b | 97 | for (offset=1; offset<15; offset++) |
destinyXfate | 2:0e2ef1edf01b | 98 | if (*(warning_message+offset) == ' ') |
destinyXfate | 2:0e2ef1edf01b | 99 | break; |
destinyXfate | 2:0e2ef1edf01b | 100 | } |
destinyXfate | 2:0e2ef1edf01b | 101 | } |
destinyXfate | 2:0e2ef1edf01b | 102 | if (png_ptr != NULL && png_ptr->warning_fn != NULL) |
destinyXfate | 2:0e2ef1edf01b | 103 | (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); |
destinyXfate | 2:0e2ef1edf01b | 104 | } |
destinyXfate | 2:0e2ef1edf01b | 105 | else |
destinyXfate | 2:0e2ef1edf01b | 106 | png_default_warning(png_ptr, warning_message+offset); |
destinyXfate | 2:0e2ef1edf01b | 107 | } |
destinyXfate | 2:0e2ef1edf01b | 108 | |
destinyXfate | 2:0e2ef1edf01b | 109 | /* These utilities are used internally to build an error message that relates |
destinyXfate | 2:0e2ef1edf01b | 110 | * to the current chunk. The chunk name comes from png_ptr->chunk_name, |
destinyXfate | 2:0e2ef1edf01b | 111 | * this is used to prefix the message. The message is limited in length |
destinyXfate | 2:0e2ef1edf01b | 112 | * to 63 bytes, the name characters are output as hex digits wrapped in [] |
destinyXfate | 2:0e2ef1edf01b | 113 | * if the character is invalid. |
destinyXfate | 2:0e2ef1edf01b | 114 | */ |
destinyXfate | 2:0e2ef1edf01b | 115 | #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) |
destinyXfate | 2:0e2ef1edf01b | 116 | static PNG_CONST char png_digit[16] = { |
destinyXfate | 2:0e2ef1edf01b | 117 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
destinyXfate | 2:0e2ef1edf01b | 118 | 'A', 'B', 'C', 'D', 'E', 'F' |
destinyXfate | 2:0e2ef1edf01b | 119 | }; |
destinyXfate | 2:0e2ef1edf01b | 120 | |
destinyXfate | 2:0e2ef1edf01b | 121 | static void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 122 | png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp |
destinyXfate | 2:0e2ef1edf01b | 123 | error_message) |
destinyXfate | 2:0e2ef1edf01b | 124 | { |
destinyXfate | 2:0e2ef1edf01b | 125 | int iout = 0, iin = 0; |
destinyXfate | 2:0e2ef1edf01b | 126 | |
destinyXfate | 2:0e2ef1edf01b | 127 | while (iin < 4) |
destinyXfate | 2:0e2ef1edf01b | 128 | { |
destinyXfate | 2:0e2ef1edf01b | 129 | int c = png_ptr->chunk_name[iin++]; |
destinyXfate | 2:0e2ef1edf01b | 130 | if (isnonalpha(c)) |
destinyXfate | 2:0e2ef1edf01b | 131 | { |
destinyXfate | 2:0e2ef1edf01b | 132 | buffer[iout++] = '['; |
destinyXfate | 2:0e2ef1edf01b | 133 | buffer[iout++] = png_digit[(c & 0xf0) >> 4]; |
destinyXfate | 2:0e2ef1edf01b | 134 | buffer[iout++] = png_digit[c & 0x0f]; |
destinyXfate | 2:0e2ef1edf01b | 135 | buffer[iout++] = ']'; |
destinyXfate | 2:0e2ef1edf01b | 136 | } |
destinyXfate | 2:0e2ef1edf01b | 137 | else |
destinyXfate | 2:0e2ef1edf01b | 138 | { |
destinyXfate | 2:0e2ef1edf01b | 139 | buffer[iout++] = (png_byte)c; |
destinyXfate | 2:0e2ef1edf01b | 140 | } |
destinyXfate | 2:0e2ef1edf01b | 141 | } |
destinyXfate | 2:0e2ef1edf01b | 142 | |
destinyXfate | 2:0e2ef1edf01b | 143 | if (error_message == NULL) |
destinyXfate | 2:0e2ef1edf01b | 144 | buffer[iout] = 0; |
destinyXfate | 2:0e2ef1edf01b | 145 | else |
destinyXfate | 2:0e2ef1edf01b | 146 | { |
destinyXfate | 2:0e2ef1edf01b | 147 | buffer[iout++] = ':'; |
destinyXfate | 2:0e2ef1edf01b | 148 | buffer[iout++] = ' '; |
destinyXfate | 2:0e2ef1edf01b | 149 | png_strncpy(buffer+iout, error_message, 63); |
destinyXfate | 2:0e2ef1edf01b | 150 | buffer[iout+63] = 0; |
destinyXfate | 2:0e2ef1edf01b | 151 | } |
destinyXfate | 2:0e2ef1edf01b | 152 | } |
destinyXfate | 2:0e2ef1edf01b | 153 | |
destinyXfate | 2:0e2ef1edf01b | 154 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 155 | png_chunk_error(png_structp png_ptr, png_const_charp error_message) |
destinyXfate | 2:0e2ef1edf01b | 156 | { |
destinyXfate | 2:0e2ef1edf01b | 157 | char msg[18+64]; |
destinyXfate | 2:0e2ef1edf01b | 158 | if (png_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 159 | png_error(png_ptr, error_message); |
destinyXfate | 2:0e2ef1edf01b | 160 | else |
destinyXfate | 2:0e2ef1edf01b | 161 | { |
destinyXfate | 2:0e2ef1edf01b | 162 | png_format_buffer(png_ptr, msg, error_message); |
destinyXfate | 2:0e2ef1edf01b | 163 | png_error(png_ptr, msg); |
destinyXfate | 2:0e2ef1edf01b | 164 | } |
destinyXfate | 2:0e2ef1edf01b | 165 | } |
destinyXfate | 2:0e2ef1edf01b | 166 | |
destinyXfate | 2:0e2ef1edf01b | 167 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 168 | png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) |
destinyXfate | 2:0e2ef1edf01b | 169 | { |
destinyXfate | 2:0e2ef1edf01b | 170 | char msg[18+64]; |
destinyXfate | 2:0e2ef1edf01b | 171 | if (png_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 172 | png_warning(png_ptr, warning_message); |
destinyXfate | 2:0e2ef1edf01b | 173 | else |
destinyXfate | 2:0e2ef1edf01b | 174 | { |
destinyXfate | 2:0e2ef1edf01b | 175 | png_format_buffer(png_ptr, msg, warning_message); |
destinyXfate | 2:0e2ef1edf01b | 176 | png_warning(png_ptr, msg); |
destinyXfate | 2:0e2ef1edf01b | 177 | } |
destinyXfate | 2:0e2ef1edf01b | 178 | } |
destinyXfate | 2:0e2ef1edf01b | 179 | |
destinyXfate | 2:0e2ef1edf01b | 180 | /* This is the default error handling function. Note that replacements for |
destinyXfate | 2:0e2ef1edf01b | 181 | * this function MUST NOT RETURN, or the program will likely crash. This |
destinyXfate | 2:0e2ef1edf01b | 182 | * function is used by default, or if the program supplies NULL for the |
destinyXfate | 2:0e2ef1edf01b | 183 | * error function pointer in png_set_error_fn(). |
destinyXfate | 2:0e2ef1edf01b | 184 | */ |
destinyXfate | 2:0e2ef1edf01b | 185 | static void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 186 | png_default_error(png_structp png_ptr, png_const_charp error_message) |
destinyXfate | 2:0e2ef1edf01b | 187 | { |
destinyXfate | 2:0e2ef1edf01b | 188 | #ifndef PNG_NO_CONSOLE_IO |
destinyXfate | 2:0e2ef1edf01b | 189 | #ifdef PNG_ERROR_NUMBERS_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 190 | if (*error_message == '#') |
destinyXfate | 2:0e2ef1edf01b | 191 | { |
destinyXfate | 2:0e2ef1edf01b | 192 | int offset; |
destinyXfate | 2:0e2ef1edf01b | 193 | char error_number[16]; |
destinyXfate | 2:0e2ef1edf01b | 194 | for (offset=0; offset<15; offset++) |
destinyXfate | 2:0e2ef1edf01b | 195 | { |
destinyXfate | 2:0e2ef1edf01b | 196 | error_number[offset] = *(error_message+offset+1); |
destinyXfate | 2:0e2ef1edf01b | 197 | if (*(error_message+offset) == ' ') |
destinyXfate | 2:0e2ef1edf01b | 198 | break; |
destinyXfate | 2:0e2ef1edf01b | 199 | } |
destinyXfate | 2:0e2ef1edf01b | 200 | if((offset > 1) && (offset < 15)) |
destinyXfate | 2:0e2ef1edf01b | 201 | { |
destinyXfate | 2:0e2ef1edf01b | 202 | error_number[offset-1]='\0'; |
destinyXfate | 2:0e2ef1edf01b | 203 | fprintf(stderr, "libpng error no. %s: %s\n", error_number, |
destinyXfate | 2:0e2ef1edf01b | 204 | error_message+offset); |
destinyXfate | 2:0e2ef1edf01b | 205 | } |
destinyXfate | 2:0e2ef1edf01b | 206 | else |
destinyXfate | 2:0e2ef1edf01b | 207 | fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); |
destinyXfate | 2:0e2ef1edf01b | 208 | } |
destinyXfate | 2:0e2ef1edf01b | 209 | else |
destinyXfate | 2:0e2ef1edf01b | 210 | #endif |
destinyXfate | 2:0e2ef1edf01b | 211 | fprintf(stderr, "libpng error: %s\n", error_message); |
destinyXfate | 2:0e2ef1edf01b | 212 | #endif |
destinyXfate | 2:0e2ef1edf01b | 213 | |
destinyXfate | 2:0e2ef1edf01b | 214 | #ifdef PNG_SETJMP_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 215 | if (png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 216 | { |
destinyXfate | 2:0e2ef1edf01b | 217 | # ifdef USE_FAR_KEYWORD |
destinyXfate | 2:0e2ef1edf01b | 218 | { |
destinyXfate | 2:0e2ef1edf01b | 219 | jmp_buf jmpbuf; |
destinyXfate | 2:0e2ef1edf01b | 220 | png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); |
destinyXfate | 2:0e2ef1edf01b | 221 | longjmp(jmpbuf, 1); |
destinyXfate | 2:0e2ef1edf01b | 222 | } |
destinyXfate | 2:0e2ef1edf01b | 223 | # else |
destinyXfate | 2:0e2ef1edf01b | 224 | longjmp(png_ptr->jmpbuf, 1); |
destinyXfate | 2:0e2ef1edf01b | 225 | # endif |
destinyXfate | 2:0e2ef1edf01b | 226 | } |
destinyXfate | 2:0e2ef1edf01b | 227 | #else |
destinyXfate | 2:0e2ef1edf01b | 228 | PNG_ABORT(); |
destinyXfate | 2:0e2ef1edf01b | 229 | #endif |
destinyXfate | 2:0e2ef1edf01b | 230 | #ifdef PNG_NO_CONSOLE_IO |
destinyXfate | 2:0e2ef1edf01b | 231 | /* make compiler happy */ ; |
destinyXfate | 2:0e2ef1edf01b | 232 | if (&error_message != NULL) |
destinyXfate | 2:0e2ef1edf01b | 233 | return; |
destinyXfate | 2:0e2ef1edf01b | 234 | #endif |
destinyXfate | 2:0e2ef1edf01b | 235 | } |
destinyXfate | 2:0e2ef1edf01b | 236 | |
destinyXfate | 2:0e2ef1edf01b | 237 | /* This function is called when there is a warning, but the library thinks |
destinyXfate | 2:0e2ef1edf01b | 238 | * it can continue anyway. Replacement functions don't have to do anything |
destinyXfate | 2:0e2ef1edf01b | 239 | * here if you don't want them to. In the default configuration, png_ptr is |
destinyXfate | 2:0e2ef1edf01b | 240 | * not used, but it is passed in case it may be useful. |
destinyXfate | 2:0e2ef1edf01b | 241 | */ |
destinyXfate | 2:0e2ef1edf01b | 242 | static void /* PRIVATE */ |
destinyXfate | 2:0e2ef1edf01b | 243 | png_default_warning(png_structp png_ptr, png_const_charp warning_message) |
destinyXfate | 2:0e2ef1edf01b | 244 | { |
destinyXfate | 2:0e2ef1edf01b | 245 | #ifndef PNG_NO_CONSOLE_IO |
destinyXfate | 2:0e2ef1edf01b | 246 | # ifdef PNG_ERROR_NUMBERS_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 247 | if (*warning_message == '#') |
destinyXfate | 2:0e2ef1edf01b | 248 | { |
destinyXfate | 2:0e2ef1edf01b | 249 | int offset; |
destinyXfate | 2:0e2ef1edf01b | 250 | char warning_number[16]; |
destinyXfate | 2:0e2ef1edf01b | 251 | for (offset=0; offset<15; offset++) |
destinyXfate | 2:0e2ef1edf01b | 252 | { |
destinyXfate | 2:0e2ef1edf01b | 253 | warning_number[offset]=*(warning_message+offset+1); |
destinyXfate | 2:0e2ef1edf01b | 254 | if (*(warning_message+offset) == ' ') |
destinyXfate | 2:0e2ef1edf01b | 255 | break; |
destinyXfate | 2:0e2ef1edf01b | 256 | } |
destinyXfate | 2:0e2ef1edf01b | 257 | if((offset > 1) && (offset < 15)) |
destinyXfate | 2:0e2ef1edf01b | 258 | { |
destinyXfate | 2:0e2ef1edf01b | 259 | warning_number[offset-1]='\0'; |
destinyXfate | 2:0e2ef1edf01b | 260 | fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, |
destinyXfate | 2:0e2ef1edf01b | 261 | warning_message+offset); |
destinyXfate | 2:0e2ef1edf01b | 262 | } |
destinyXfate | 2:0e2ef1edf01b | 263 | else |
destinyXfate | 2:0e2ef1edf01b | 264 | fprintf(stderr, "libpng warning: %s\n", warning_message); |
destinyXfate | 2:0e2ef1edf01b | 265 | } |
destinyXfate | 2:0e2ef1edf01b | 266 | else |
destinyXfate | 2:0e2ef1edf01b | 267 | # endif |
destinyXfate | 2:0e2ef1edf01b | 268 | fprintf(stderr, "libpng warning: %s\n", warning_message); |
destinyXfate | 2:0e2ef1edf01b | 269 | #else |
destinyXfate | 2:0e2ef1edf01b | 270 | /* make compiler happy */ ; |
destinyXfate | 2:0e2ef1edf01b | 271 | if (warning_message) |
destinyXfate | 2:0e2ef1edf01b | 272 | return; |
destinyXfate | 2:0e2ef1edf01b | 273 | #endif |
destinyXfate | 2:0e2ef1edf01b | 274 | /* make compiler happy */ ; |
destinyXfate | 2:0e2ef1edf01b | 275 | if (png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 276 | return; |
destinyXfate | 2:0e2ef1edf01b | 277 | } |
destinyXfate | 2:0e2ef1edf01b | 278 | |
destinyXfate | 2:0e2ef1edf01b | 279 | /* This function is called when the application wants to use another method |
destinyXfate | 2:0e2ef1edf01b | 280 | * of handling errors and warnings. Note that the error function MUST NOT |
destinyXfate | 2:0e2ef1edf01b | 281 | * return to the calling routine or serious problems will occur. The return |
destinyXfate | 2:0e2ef1edf01b | 282 | * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) |
destinyXfate | 2:0e2ef1edf01b | 283 | */ |
destinyXfate | 2:0e2ef1edf01b | 284 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 285 | png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, |
destinyXfate | 2:0e2ef1edf01b | 286 | png_error_ptr error_fn, png_error_ptr warning_fn) |
destinyXfate | 2:0e2ef1edf01b | 287 | { |
destinyXfate | 2:0e2ef1edf01b | 288 | if (png_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 289 | return; |
destinyXfate | 2:0e2ef1edf01b | 290 | png_ptr->error_ptr = error_ptr; |
destinyXfate | 2:0e2ef1edf01b | 291 | png_ptr->error_fn = error_fn; |
destinyXfate | 2:0e2ef1edf01b | 292 | png_ptr->warning_fn = warning_fn; |
destinyXfate | 2:0e2ef1edf01b | 293 | } |
destinyXfate | 2:0e2ef1edf01b | 294 | |
destinyXfate | 2:0e2ef1edf01b | 295 | |
destinyXfate | 2:0e2ef1edf01b | 296 | /* This function returns a pointer to the error_ptr associated with the user |
destinyXfate | 2:0e2ef1edf01b | 297 | * functions. The application should free any memory associated with this |
destinyXfate | 2:0e2ef1edf01b | 298 | * pointer before png_write_destroy and png_read_destroy are called. |
destinyXfate | 2:0e2ef1edf01b | 299 | */ |
destinyXfate | 2:0e2ef1edf01b | 300 | png_voidp PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 301 | png_get_error_ptr(png_structp png_ptr) |
destinyXfate | 2:0e2ef1edf01b | 302 | { |
destinyXfate | 2:0e2ef1edf01b | 303 | if (png_ptr == NULL) |
destinyXfate | 2:0e2ef1edf01b | 304 | return NULL; |
destinyXfate | 2:0e2ef1edf01b | 305 | return ((png_voidp)png_ptr->error_ptr); |
destinyXfate | 2:0e2ef1edf01b | 306 | } |
destinyXfate | 2:0e2ef1edf01b | 307 | |
destinyXfate | 2:0e2ef1edf01b | 308 | |
destinyXfate | 2:0e2ef1edf01b | 309 | #ifdef PNG_ERROR_NUMBERS_SUPPORTED |
destinyXfate | 2:0e2ef1edf01b | 310 | void PNGAPI |
destinyXfate | 2:0e2ef1edf01b | 311 | png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) |
destinyXfate | 2:0e2ef1edf01b | 312 | { |
destinyXfate | 2:0e2ef1edf01b | 313 | if(png_ptr != NULL) |
destinyXfate | 2:0e2ef1edf01b | 314 | { |
destinyXfate | 2:0e2ef1edf01b | 315 | png_ptr->flags &= |
destinyXfate | 2:0e2ef1edf01b | 316 | ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); |
destinyXfate | 2:0e2ef1edf01b | 317 | } |
destinyXfate | 2:0e2ef1edf01b | 318 | } |
destinyXfate | 2:0e2ef1edf01b | 319 | #endif |
destinyXfate | 2:0e2ef1edf01b | 320 | #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
destinyXfate | 2:0e2ef1edf01b | 321 |