~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to libpng/pngerror.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngerror.c - stub functions for i/o and memory allocation
3
3
 *
4
 
 * Last changed in libpng 1.2.13 November 13, 2006
 
4
 * Last changed in libpng 1.2.22 [October 13, 2007]
5
5
 * For conditions of distribution and use, see copyright notice in png.h
6
 
 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
 
6
 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
7
7
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8
8
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9
9
 *
20
20
static void /* PRIVATE */
21
21
png_default_error PNGARG((png_structp png_ptr,
22
22
  png_const_charp error_message));
 
23
#ifndef PNG_NO_WARNINGS
23
24
static void /* PRIVATE */
24
25
png_default_warning PNGARG((png_structp png_ptr,
25
26
  png_const_charp warning_message));
 
27
#endif /* PNG_NO_WARNINGS */
26
28
 
27
29
/* This function is called whenever there is a fatal error.  This function
28
30
 * should not be changed.  If there is a need to handle errors differently,
29
31
 * you should supply a replacement error function and use png_set_error_fn()
30
32
 * to replace the error function at run-time.
31
33
 */
 
34
#ifndef PNG_NO_ERROR_TEXT
32
35
void PNGAPI
33
36
png_error(png_structp png_ptr, png_const_charp error_message)
34
37
{
75
78
      use the default handler, which will not return. */
76
79
   png_default_error(png_ptr, error_message);
77
80
}
78
 
 
 
81
#else
 
82
void PNGAPI
 
83
png_err(png_structp png_ptr)
 
84
{
 
85
   if (png_ptr != NULL && png_ptr->error_fn != NULL)
 
86
      (*(png_ptr->error_fn))(png_ptr, '\0');
 
87
 
 
88
   /* If the custom handler doesn't exist, or if it returns,
 
89
      use the default handler, which will not return. */
 
90
   png_default_error(png_ptr, '\0');
 
91
}
 
92
#endif /* PNG_NO_ERROR_TEXT */
 
93
 
 
94
#ifndef PNG_NO_WARNINGS
79
95
/* This function is called whenever there is a non-fatal error.  This function
80
96
 * should not be changed.  If there is a need to handle warnings differently,
81
97
 * you should supply a replacement warning function and use
105
121
   else
106
122
      png_default_warning(png_ptr, warning_message+offset);
107
123
}
 
124
#endif /* PNG_NO_WARNINGS */
 
125
 
108
126
 
109
127
/* These utilities are used internally to build an error message that relates
110
128
 * to the current chunk.  The chunk name comes from png_ptr->chunk_name,
113
131
 * if the character is invalid.
114
132
 */
115
133
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
116
 
static const char png_digit[16] = {
 
134
static PNG_CONST char png_digit[16] = {
117
135
   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
118
136
   'A', 'B', 'C', 'D', 'E', 'F'
119
137
};
120
138
 
 
139
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
121
140
static void /* PRIVATE */
122
141
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
123
142
   error_message)
141
160
   }
142
161
 
143
162
   if (error_message == NULL)
144
 
      buffer[iout] = 0;
 
163
      buffer[iout] = '\0';
145
164
   else
146
165
   {
147
166
      buffer[iout++] = ':';
148
167
      buffer[iout++] = ' ';
149
168
      png_strncpy(buffer+iout, error_message, 63);
150
 
      buffer[iout+63] = 0;
 
169
      buffer[iout+63] = '\0';
151
170
   }
152
171
}
153
172
 
 
173
#ifdef PNG_READ_SUPPORTED
154
174
void PNGAPI
155
175
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
156
176
{
163
183
     png_error(png_ptr, msg);
164
184
   }
165
185
}
 
186
#endif /* PNG_READ_SUPPORTED */
 
187
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
166
188
 
 
189
#ifndef PNG_NO_WARNINGS
167
190
void PNGAPI
168
191
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
169
192
{
176
199
     png_warning(png_ptr, msg);
177
200
   }
178
201
}
 
202
#endif /* PNG_NO_WARNINGS */
 
203
 
179
204
 
180
205
/* This is the default error handling function.  Note that replacements for
181
206
 * this function MUST NOT RETURN, or the program will likely crash.  This
217
242
#  ifdef USE_FAR_KEYWORD
218
243
   {
219
244
      jmp_buf jmpbuf;
220
 
      png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf));
 
245
      png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
221
246
      longjmp(jmpbuf, 1);
222
247
   }
223
248
#  else
228
253
   PNG_ABORT();
229
254
#endif
230
255
#ifdef PNG_NO_CONSOLE_IO
231
 
   /* make compiler happy */ ;
232
 
   if (&error_message != NULL)
233
 
      return;
 
256
   error_message = error_message; /* make compiler happy */
234
257
#endif
235
258
}
236
259
 
 
260
#ifndef PNG_NO_WARNINGS
237
261
/* This function is called when there is a warning, but the library thinks
238
262
 * it can continue anyway.  Replacement functions don't have to do anything
239
263
 * here if you don't want them to.  In the default configuration, png_ptr is
267
291
#  endif
268
292
     fprintf(stderr, "libpng warning: %s\n", warning_message);
269
293
#else
270
 
   /* make compiler happy */ ;
271
 
   if (warning_message)
272
 
     return;
 
294
   warning_message = warning_message; /* make compiler happy */
273
295
#endif
274
 
   /* make compiler happy */ ;
275
 
   if (png_ptr)
276
 
      return;
 
296
   png_ptr = png_ptr; /* make compiler happy */
277
297
}
 
298
#endif /* PNG_NO_WARNINGS */
278
299
 
279
300
/* This function is called when the application wants to use another method
280
301
 * of handling errors and warnings.  Note that the error function MUST NOT