Mercurial > hg > xemacs-beta
comparison src/dgif_lib.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | c53a95d3c46d |
children | 54cc21c15cbb |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
9 ******************************************************************************* | 9 ******************************************************************************* |
10 * History: * | 10 * History: * |
11 * 16 Jun 89 - Version 1.0 by Gershon Elber. * | 11 * 16 Jun 89 - Version 1.0 by Gershon Elber. * |
12 * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * | 12 * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * |
13 ******************************************************************************/ | 13 ******************************************************************************/ |
14 | |
15 #ifdef __MSDOS__ | |
16 #include <io.h> | |
17 #include <alloc.h> | |
18 #include <stdlib.h> | |
19 #include <sys\stat.h> | |
20 #else | |
21 #include <sys/types.h> | |
22 #include <sys/stat.h> | |
23 #endif /* __MSDOS__ */ | |
24 | |
25 #include <fcntl.h> | |
26 #include <stdio.h> | |
27 #include <string.h> | |
14 | 28 |
15 #ifdef emacs | 29 #ifdef emacs |
16 #include <config.h> | 30 #include <config.h> |
17 void *xmalloc (unsigned int size); | 31 void *xmalloc (unsigned int size); |
18 void *xrealloc (void *ptr, unsigned int size); | 32 void *xrealloc (void *ptr, unsigned int size); |
20 void *xfree_1 (void *); | 34 void *xfree_1 (void *); |
21 #define xfree xfree_1 | 35 #define xfree xfree_1 |
22 #else | 36 #else |
23 void *xfree (void *); | 37 void *xfree (void *); |
24 #endif | 38 #endif |
25 #endif /* emacs */ | 39 #endif |
26 | |
27 #ifdef __MSDOS__ | |
28 #include <io.h> | |
29 #include <alloc.h> | |
30 #include <stdlib.h> | |
31 #include <sys\stat.h> | |
32 #else | |
33 #include <sys/types.h> | |
34 #include <sys/stat.h> | |
35 #endif /* __MSDOS__ */ | |
36 | |
37 #include <fcntl.h> | |
38 #include <stdio.h> | |
39 #include <string.h> | |
40 | 40 |
41 #include "gif_lib.h" | 41 #include "gif_lib.h" |
42 #ifndef emacs | 42 #ifndef emacs |
43 #include "gif_hash.h" | 43 #include "gif_hash.h" |
44 #endif | 44 #endif |
913 int ImageSize; | 913 int ImageSize; |
914 GifRecordType RecordType; | 914 GifRecordType RecordType; |
915 SavedImage *sp; | 915 SavedImage *sp; |
916 ExtensionBlock *ep; | 916 ExtensionBlock *ep; |
917 GifByteType *ExtData; | 917 GifByteType *ExtData; |
918 int ExtCode; | |
919 | 918 |
920 /* Some versions of malloc dislike 0-length requests */ | 919 /* Some versions of malloc dislike 0-length requests */ |
921 GifFile->SavedImages = (SavedImage *)xmalloc(sizeof(SavedImage)); | 920 GifFile->SavedImages = (SavedImage *)xmalloc(sizeof(SavedImage)); |
922 | 921 |
923 do { | 922 do { |
940 return(GIF_ERROR); | 939 return(GIF_ERROR); |
941 | 940 |
942 break; | 941 break; |
943 | 942 |
944 case EXTENSION_RECORD_TYPE: | 943 case EXTENSION_RECORD_TYPE: |
945 /* This code fails if no image_desc record has been read | 944 |
946 yet. I don't know if that's legal, but I've seen GIFs | |
947 that start with an extension record. XEmacs doesn't use | |
948 the extension records anyway, so we'll just ignore them. | |
949 - dkindred@cs.cmu.edu */ | |
950 #if 0 | |
951 if (DGifGetExtension(GifFile,&sp->Function,&ExtData)==GIF_ERROR) | 945 if (DGifGetExtension(GifFile,&sp->Function,&ExtData)==GIF_ERROR) |
952 return(GIF_ERROR); | 946 return(GIF_ERROR); |
953 else | 947 else |
954 { | 948 { |
955 ep = &sp->ExtensionBlocks[sp->ExtensionBlockCount++]; | 949 ep = &sp->ExtensionBlocks[sp->ExtensionBlockCount++]; |
969 ep->ByteCount = ExtData[0]; | 963 ep->ByteCount = ExtData[0]; |
970 ep->Bytes = (GifByteType *)xmalloc(ep->ByteCount * sizeof(GifByteType)); | 964 ep->Bytes = (GifByteType *)xmalloc(ep->ByteCount * sizeof(GifByteType)); |
971 memcpy(ep->Bytes,ExtData,ep->ByteCount * sizeof(char)); | 965 memcpy(ep->Bytes,ExtData,ep->ByteCount * sizeof(char)); |
972 } | 966 } |
973 } | 967 } |
974 #else | |
975 /* Skip any extension blocks in the file. */ | |
976 if (DGifGetExtension (GifFile, &ExtCode, &ExtData) | |
977 == GIF_ERROR) | |
978 return GIF_ERROR; | |
979 | |
980 while (ExtData != NULL) { | |
981 if (DGifGetExtensionNext (GifFile, &ExtData) == GIF_ERROR) | |
982 return GIF_ERROR; | |
983 } | |
984 #endif | |
985 break; | 968 break; |
986 | 969 |
987 case TERMINATE_RECORD_TYPE: | 970 case TERMINATE_RECORD_TYPE: |
988 break; | 971 break; |
989 | 972 |