Skip to content

Instantly share code, notes, and snippets.

@scottjg
Last active August 29, 2015 14:14
Show Gist options
  • Save scottjg/3766197a478a84c383df to your computer and use it in GitHub Desktop.
Save scottjg/3766197a478a84c383df to your computer and use it in GitHub Desktop.
patch to compile mapserver 6.2.1 with giflib 5.x
--- mapserver-6.2.1.orig/mapimageio.c 2013-04-19 21:08:49.000000000 -0700
+++ mapserver-6.2.1/mapimageio.c 2015-01-30 16:47:46.000000000 -0800
@@ -994,11 +994,18 @@
}
}
#ifdef USE_GIF
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+#define gif_error_msg() _gif_error_msg(image->Error)
+static char const *_gif_error_msg(int code)
+#else
static char const *gif_error_msg()
+#endif
{
static char msg[80];
+#if !(defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5)
int code = GifLastError();
+#endif
switch (code) {
case E_GIF_ERR_OPEN_FAILED: /* should not see this */
return "Failed to open given file";
@@ -1075,7 +1082,6 @@
}
}
-
/* not fully implemented and tested */
/* missing: set the first pointer to a,r,g,b */
int readGIF(char *path, rasterBufferObj *rb)
@@ -1092,12 +1098,21 @@
int interlacedJumps[] = {8,8,4,2};
- rb->type = MS_BUFFER_BYTE_RGBA;
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ int err = 0;
+ image = DGifOpenFileName(path, &err);
+ if (image == NULL) {
+ msSetError(MS_MISCERR,"failed to load gif image: %s","readGIF()", _gif_error_msg(err));
+ return MS_FAILURE;
+ }
+#else
image = DGifOpenFileName(path);
if (image == NULL) {
msSetError(MS_MISCERR,"failed to load gif image: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
+#endif
+ rb->type = MS_BUFFER_BYTE_RGBA;
rb->width = image->SWidth;
rb->height = image->SHeight;
rb->data.rgba.row_step = rb->width * 4;
@@ -1253,11 +1268,17 @@
} while (recordType != TERMINATE_RECORD_TYPE);
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ if (DGifCloseFile(image, &err) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"failed to close gif after loading: %s","readGIF()", _gif_error_msg(err));
+ return MS_FAILURE;
+ }
+#else
if (DGifCloseFile(image) == GIF_ERROR) {
msSetError(MS_MISCERR,"failed to close gif after loading: %s","readGIF()", gif_error_msg());
return MS_FAILURE;
}
-
+#endif
return MS_SUCCESS;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment