[mapserver-commits] r10324 - sandbox/mapserver6
svn at osgeo.org
svn at osgeo.org
Fri Jul 9 03:09:13 EDT 2010
Author: tbonfort
Date: 2010-07-09 07:09:12 +0000 (Fri, 09 Jul 2010)
New Revision: 10324
Modified:
sandbox/mapserver6/mapimageio.c
Log:
libgif error reporting
Modified: sandbox/mapserver6/mapimageio.c
===================================================================
--- sandbox/mapserver6/mapimageio.c 2010-07-09 04:06:36 UTC (rev 10323)
+++ sandbox/mapserver6/mapimageio.c 2010-07-09 07:09:12 UTC (rev 10324)
@@ -833,6 +833,87 @@
}
}
+static char const *gif_error_msg() {
+ static char msg[80];
+
+ int code = GifLastError();
+ switch (code) {
+ case E_GIF_ERR_OPEN_FAILED: /* should not see this */
+ return "Failed to open given file";
+
+ case E_GIF_ERR_WRITE_FAILED:
+ return "Write failed";
+
+ case E_GIF_ERR_HAS_SCRN_DSCR: /* should not see this */
+ return "Screen descriptor already passed to giflib";
+
+ case E_GIF_ERR_HAS_IMAG_DSCR: /* should not see this */
+ return "Image descriptor already passed to giflib";
+
+ case E_GIF_ERR_NO_COLOR_MAP: /* should not see this */
+ return "Neither global nor local color map set";
+
+ case E_GIF_ERR_DATA_TOO_BIG: /* should not see this */
+ return "Too much pixel data passed to giflib";
+
+ case E_GIF_ERR_NOT_ENOUGH_MEM:
+ return "Out of memory";
+
+ case E_GIF_ERR_DISK_IS_FULL:
+ return "Disk is full";
+
+ case E_GIF_ERR_CLOSE_FAILED: /* should not see this */
+ return "File close failed";
+
+ case E_GIF_ERR_NOT_WRITEABLE: /* should not see this */
+ return "File not writable";
+
+ case D_GIF_ERR_OPEN_FAILED:
+ return "Failed to open file";
+
+ case D_GIF_ERR_READ_FAILED:
+ return "Failed to read from file";
+
+ case D_GIF_ERR_NOT_GIF_FILE:
+ return "File is not a GIF file";
+
+ case D_GIF_ERR_NO_SCRN_DSCR:
+ return "No screen descriptor detected - invalid file";
+
+ case D_GIF_ERR_NO_IMAG_DSCR:
+ return "No image descriptor detected - invalid file";
+
+ case D_GIF_ERR_NO_COLOR_MAP:
+ return "No global or local color map found";
+
+ case D_GIF_ERR_WRONG_RECORD:
+ return "Wrong record type detected - invalid file?";
+
+ case D_GIF_ERR_DATA_TOO_BIG:
+ return "Data in file too big for image";
+
+ case D_GIF_ERR_NOT_ENOUGH_MEM:
+ return "Out of memory";
+
+ case D_GIF_ERR_CLOSE_FAILED:
+ return "Close failed";
+
+ case D_GIF_ERR_NOT_READABLE:
+ return "File not opened for read";
+
+ case D_GIF_ERR_IMAGE_DEFECT:
+ return "Defective image";
+
+ case D_GIF_ERR_EOF_TOO_SOON:
+ return "Unexpected EOF - invalid file";
+
+ default:
+ sprintf(msg, "Unknown giflib error code %d", code);
+ return msg;
+ }
+}
+
+
/* not fully implemented and tested */
/* missing: set the first pointer to a,r,g,b */
int readGIF(FILE *stream, rasterBufferObj *rb)
@@ -852,7 +933,7 @@
rb->type = MS_BUFFER_BYTE_RGBA;
image = DGifOpenFileHandle(fileno(stream));
if (image == NULL) {
- msSetError(MS_MISCERR,"failed to load gif image","readGIF()");
+ msSetError(MS_MISCERR,"failed to load gif image: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
rb->width = image->SWidth;
@@ -880,7 +961,7 @@
do
{
if (DGifGetRecordType(image, &recordType) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
@@ -891,7 +972,7 @@
break;
case IMAGE_DESC_RECORD_TYPE:
if (DGifGetImageDesc(image) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
if (!firstImageRead)
@@ -919,7 +1000,7 @@
g = rb->data.rgba.g + offset;
b = rb->data.rgba.b + offset;
if (DGifGetLine(image, line, width) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()",gif_error_msg());
return MS_FAILURE;
}
@@ -948,7 +1029,7 @@
g = rb->data.rgba.g + offset;
b = rb->data.rgba.b + offset;
if (DGifGetLine(image, line, width) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()",gif_error_msg());
return MS_FAILURE;
}
for(j=0; j<width; j++) {
@@ -974,12 +1055,12 @@
else
{ /* Skip all next images */
if (DGifGetCode(image, &codeSize, &codeBlock) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
while (codeBlock != NULL) {
if (DGifGetCodeNext(image, &codeBlock) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
}
@@ -988,14 +1069,14 @@
case EXTENSION_RECORD_TYPE:
/* skip all extension blocks */
if (DGifGetExtension(image, &extCode, &extension) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
if(extCode == 249 && (extension[1] & 1))
transIdx = extension[4];
for (;;) {
if (DGifGetExtensionNext(image, &extension) == GIF_ERROR) {
- msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ msSetError(MS_MISCERR,"corrupted gif image?: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
if (extension == NULL)
@@ -1015,7 +1096,7 @@
} while (recordType != TERMINATE_RECORD_TYPE);
if (DGifCloseFile(image) == GIF_ERROR) {
- msSetError(MS_MISCERR,"failed to close gif after loading","readGIF()");
+ msSetError(MS_MISCERR,"failed to close gif after loading: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
More information about the mapserver-commits
mailing list