summaryrefslogtreecommitdiff
path: root/graphics/ocaml-images/files/patch-src_gifwrite.c
blob: 0fbcede2549c77bfe57e966037ffee13e0887d85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- src/gifwrite.c.orig	2011-06-22 18:04:32 UTC
+++ src/gifwrite.c
@@ -25,7 +25,7 @@
 
 #include <gif_lib.h>
 
-int list_length( value list )
+static int list_length( value list )
 {
   CAMLparam1(list);
   CAMLlocal1(l);
@@ -52,7 +52,11 @@ ColorMapObject *ColorMapObject_val( valu
 fprintf(stderr, "Creating map with length = %d ...\n", len);
 fflush(stderr);
 */
+#if GIFLIB_MAJOR >= 5
+  cmapobj = GifMakeMapObject( len, NULL );
+#else
   cmapobj = MakeMapObject( len, NULL );
+#endif
   for(i=0; i< len; i++){
     cmapobj->Colors[i].Red   = Int_val(Field(Field(cmap,i),0));
     cmapobj->Colors[i].Green = Int_val(Field(Field(cmap,i),1));
@@ -68,7 +72,11 @@ value eGifOpenFileName( name )
 
   GifFileType *GifFileOut;
 
+#if GIFLIB_MAJOR >= 5
+  if ((GifFileOut = EGifOpenFileName( String_val( name ), 0, NULL) )== NULL) {
+#else
   if ((GifFileOut = EGifOpenFileName( String_val( name ), 0) )== NULL) {
+#endif
     failwith("EGifOpenFileName");
   }
   /* gcc -fwritable-strings is required to compile libungif */
@@ -88,7 +96,11 @@ value eGifCloseFile( value hdl )
      segmentation faults */
   ((GifFileType *)hdl)->Image.ColorMap = NULL; 
 
+#if GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1 || GIFLIB_MAJOR > 5
+  EGifCloseFile( (GifFileType *) hdl, NULL );
+#else
   EGifCloseFile( (GifFileType *) hdl );
+#endif
   CAMLreturn(Val_unit);
 }
 
@@ -133,7 +145,6 @@ value eGifPutLine( value oc, value buf )
 
   if ( EGifPutLine(GifFileOut, String_val(buf), GifFileOut->Image.Width) 
        == GIF_ERROR ){
-    PrintGifError ();
     failwith("EGifPutLine");
   }
   CAMLreturn(Val_unit);