aboutsummaryrefslogtreecommitdiffstats
path: root/rd
diff options
context:
space:
mode:
authorIsaac Dunham <ibid.ag@gmail.com>2014-11-25 09:23:42 -0800
committerGerd Hoffmann <kraxel@redhat.com>2014-11-26 09:06:22 +0100
commitd55d20b766701063152bf02c99f9e4db07aab213 (patch)
treece0cbb19d65cbabd60259b14025a0af93b33cd8f /rd
parent0dbd41825d5c5189cd8c1e6a41cbe918e51b8c36 (diff)
downloadfbida-d55d20b766701063152bf02c99f9e4db07aab213.tar.gz
Port gif reader to giflib 5.
-define and use compatability macros that will make giflib 4 look like giflib 5 -provide our own PrintGifError() if it's missing -since we don't check the error for DGifCloseFile, use NULL The documented behavior of giflib5 is if (&error) error =...; so this isn't supposed to break. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'rd')
-rw-r--r--rd/read-gif.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/rd/read-gif.c b/rd/read-gif.c
index b841dc7..2ea2947 100644
--- a/rd/read-gif.c
+++ b/rd/read-gif.c
@@ -5,6 +5,19 @@
#include "readers.h"
+#if defined(GIFLIB_MAJOR) && (GIFLIB_MAJOR >= 5)
+#define GIF5DATA(e) e
+static void PrintGifError(int err)
+{
+ fprintf(stderr, "GIF library error: %s\n", GifErrorString(err));
+}
+#else
+#define GIF5DATA(x)
+#define PrintGifError(e) PrintGifError()
+#define DGifOpenFileHandle(x,e) DGifOpenFileHandle(x)
+#define DGifCloseFile(x,e) DGifCloseFile(x)
+#endif
+
struct gif_state {
FILE *infile;
GifFileType *gif;
@@ -25,7 +38,7 @@ gif_fileread(struct gif_state *h)
if (GIF_ERROR == DGifGetRecordType(h->gif,&RecordType)) {
if (debug)
fprintf(stderr,"gif: DGifGetRecordType failed\n");
- PrintGifError();
+ PrintGifError(h->gif->Error);
return -1;
}
switch (RecordType) {
@@ -42,7 +55,7 @@ gif_fileread(struct gif_state *h)
if (rc == GIF_ERROR) {
if (debug)
fprintf(stderr,"gif: DGifGetExtension failed\n");
- PrintGifError();
+ PrintGifError(h->gif->Error);
return -1;
}
if (debug) {
@@ -93,12 +106,13 @@ gif_init(FILE *fp, char *filename, unsigned int page,
struct gif_state *h;
GifRecordType RecordType;
int i, image = 0;
+ GIF5DATA(int giferror = 0;)
h = malloc(sizeof(*h));
memset(h,0,sizeof(*h));
h->infile = fp;
- h->gif = DGifOpenFileHandle(fileno(fp));
+ h->gif = DGifOpenFileHandle(fileno(fp), &giferror);
h->row = malloc(h->gif->SWidth * sizeof(GifPixelType));
while (0 == image) {
@@ -108,7 +122,7 @@ gif_init(FILE *fp, char *filename, unsigned int page,
if (GIF_ERROR == DGifGetImageDesc(h->gif)) {
if (debug)
fprintf(stderr,"gif: DGifGetImageDesc failed\n");
- PrintGifError();
+ PrintGifError(giferror);
}
if (NULL == h->gif->SColorMap &&
NULL == h->gif->Image.ColorMap) {
@@ -156,7 +170,7 @@ gif_init(FILE *fp, char *filename, unsigned int page,
oops:
if (debug)
fprintf(stderr,"gif: fatal error, aborting\n");
- DGifCloseFile(h->gif);
+ DGifCloseFile(h->gif, NULL);
fclose(h->infile);
free(h->row);
free(h);
@@ -196,7 +210,7 @@ gif_done(void *data)
if (debug)
fprintf(stderr,"gif: done, cleaning up\n");
- DGifCloseFile(h->gif);
+ DGifCloseFile(h->gif, NULL);
fclose(h->infile);
if (h->il)
free(h->il);
@@ -208,7 +222,7 @@ static struct ida_loader gif_loader = {
magic: "GIF",
moff: 0,
mlen: 3,
- name: "libungif",
+ name: "giflib",
init: gif_init,
read: gif_read,
done: gif_done,