blob: 50c005589974870905b08fa79fddb52b6c0b6afd [file] [log] [blame]
--- a/rd/read-gif.c
+++ b/rd/read-gif.c
@@ -25,7 +25,13 @@
if (GIF_ERROR == DGifGetRecordType(h->gif,&RecordType)) {
if (debug)
fprintf(stderr,"gif: DGifGetRecordType failed\n");
- PrintGifError();
+#if GIFLIB_MAJOR >= 5
+ GifErrorString(D_GIF_ERR_NOT_GIF_FILE);
+#elif (GIFLIB_MAJOR >= 4 && GIFLIB_MINOR >=2)
+ GifErrorString();
+#else
+ PrintGifError();
+#endif
return -1;
}
switch (RecordType) {
@@ -42,7 +48,13 @@
if (rc == GIF_ERROR) {
if (debug)
fprintf(stderr,"gif: DGifGetExtension failed\n");
+#if GIFLIB_MAJOR >= 5
+ GifErrorString(D_GIF_ERR_NOT_GIF_FILE);
+#elif (GIFLIB_MAJOR >= 4 && GIFLIB_MINOR >=2)
+ GifErrorString();
+#else
PrintGifError();
+#endif
return -1;
}
if (debug) {
@@ -93,12 +105,19 @@
struct gif_state *h;
GifRecordType RecordType;
int i, image = 0;
+#if (GIFLIB_MAJOR >=5 && GIFLIB_MINOR >= 1)
+ int ErrorCode;
+#endif
h = malloc(sizeof(*h));
memset(h,0,sizeof(*h));
h->infile = fp;
+#if GIFLIB_MAJOR >= 5
+ h->gif = DGifOpenFileHandle(fileno(fp), NULL);
+#else
h->gif = DGifOpenFileHandle(fileno(fp));
+#endif
h->row = malloc(h->gif->SWidth * sizeof(GifPixelType));
while (0 == image) {
@@ -108,7 +127,15 @@
if (GIF_ERROR == DGifGetImageDesc(h->gif)) {
if (debug)
fprintf(stderr,"gif: DGifGetImageDesc failed\n");
+#if (GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1)
+ GifErrorString(D_GIF_ERR_NO_IMAG_DSCR);
+#elif GIFLIB_MAJOR >= 5
+ GifErrorString(NULL);
+#elif (GIFLIB_MAJOR >= 4 && GIFLIB_MINOR >=2)
+ GifErrorString();
+#else
PrintGifError();
+#endif
}
if (NULL == h->gif->SColorMap &&
NULL == h->gif->Image.ColorMap) {
@@ -156,7 +183,11 @@
oops:
if (debug)
fprintf(stderr,"gif: fatal error, aborting\n");
+#if (GIFLIB_MAJOR >=5 && GIFLIB_MINOR >= 1)
+ DGifCloseFile(h->gif, &ErrorCode);
+#else
DGifCloseFile(h->gif);
+#endif
fclose(h->infile);
free(h->row);
free(h);
@@ -193,10 +224,17 @@
gif_done(void *data)
{
struct gif_state *h = data;
+#if (GIFLIB_MAJOR >=5 && GIFLIB_MINOR >= 1)
+ int ErrorCode;
+#endif
if (debug)
fprintf(stderr,"gif: done, cleaning up\n");
+#if (GIFLIB_MAJOR >=5 && GIFLIB_MINOR >= 1)
+ DGifCloseFile(h->gif, &ErrorCode);
+#else
DGifCloseFile(h->gif);
+#endif
fclose(h->infile);
if (h->il)
free(h->il);