Mercurial > hg > xemacs-beta
comparison src/dgif_lib.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
9 * 16 Jun 89 - Version 1.0 by Gershon Elber. * | 9 * 16 Jun 89 - Version 1.0 by Gershon Elber. * |
10 * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * | 10 * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * |
11 * 19 Feb 98 - Version 1.2 by Jareth Hein (Support for user specified I/O) * | 11 * 19 Feb 98 - Version 1.2 by Jareth Hein (Support for user specified I/O) * |
12 ******************************************************************************/ | 12 ******************************************************************************/ |
13 | 13 |
14 #include <config.h> | 14 #ifdef __MSDOS__ |
15 #include "lisp.h" | 15 #include <io.h> |
16 | 16 #include <alloc.h> |
17 #include "sysfile.h" | 17 #include <stdlib.h> |
18 #include <sys\stat.h> | |
19 #else | |
20 #include <sys/types.h> | |
21 #include <sys/stat.h> | |
22 #endif /* __MSDOS__ */ | |
23 | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <string.h> | |
27 | |
28 #ifdef HAVE_FCNTL_H | |
29 #include <fcntl.h> | |
30 #endif | |
18 | 31 |
19 #include "gifrlib.h" | 32 #include "gifrlib.h" |
20 | 33 |
21 #define PROGRAM_NAME "GIFLIB" | 34 #define PROGRAM_NAME "GIFLIB" |
22 | 35 |
37 void DGifOpenFileName(GifFileType *GifFile, const char *FileName) | 50 void DGifOpenFileName(GifFileType *GifFile, const char *FileName) |
38 { | 51 { |
39 FILE *f; | 52 FILE *f; |
40 | 53 |
41 if ((f = fopen(FileName, | 54 if ((f = fopen(FileName, |
42 #ifdef WIN32_NATIVE | 55 #ifdef __MSDOS__ |
43 "rb" | 56 "rb" |
44 #else | 57 #else |
45 "r" | 58 "r" |
46 #endif /* WIN32_NATIVE */ | 59 #endif /* __MSDOS__ */ |
47 )) == NULL) | 60 )) == NULL) |
48 GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED); | 61 GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED); |
49 | 62 |
50 GifStdIOInit(GifFile, f, -1); | 63 GifStdIOInit(GifFile, f, -1); |
51 DGifInitRead(GifFile); | 64 DGifInitRead(GifFile); |
58 ******************************************************************************/ | 71 ******************************************************************************/ |
59 void DGifOpenFileHandle(GifFileType *GifFile, int FileHandle) | 72 void DGifOpenFileHandle(GifFileType *GifFile, int FileHandle) |
60 { | 73 { |
61 FILE *f; | 74 FILE *f; |
62 | 75 |
63 #ifdef WIN32_NATIVE | 76 #ifdef __MSDOS__ |
64 setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ | 77 setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ |
65 f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ | 78 f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ |
66 setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ | 79 setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ |
67 #else | 80 #else |
68 f = fdopen(FileHandle, "r"); /* Make it into a stream: */ | 81 f = fdopen(FileHandle, "r"); /* Make it into a stream: */ |
69 #endif /* WIN32_NATIVE */ | 82 #endif /* __MSDOS__ */ |
70 | 83 |
71 GifStdIOInit(GifFile, f, -1); | 84 GifStdIOInit(GifFile, f, -1); |
72 DGifInitRead(GifFile); | 85 DGifInitRead(GifFile); |
73 } | 86 } |
74 | 87 |
262 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); | 275 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); |
263 } | 276 } |
264 | 277 |
265 if (!LineLen) LineLen = GifFile->Image.Width; | 278 if (!LineLen) LineLen = GifFile->Image.Width; |
266 | 279 |
267 #if defined(WIN32_NATIVE) || defined(__GNUC__) | 280 #if defined(__MSDOS__) || defined(__GNUC__) |
268 if ((Private->PixelCount -= LineLen) > 0xffff0000UL) | 281 if ((Private->PixelCount -= LineLen) > 0xffff0000UL) |
269 #else | 282 #else |
270 if ((Private->PixelCount -= LineLen) > 0xffff0000) | 283 if ((Private->PixelCount -= LineLen) > 0xffff0000) |
271 #endif /* WIN32_NATIVE */ | 284 #endif /* __MSDOS__ */ |
272 { | 285 { |
273 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); | 286 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); |
274 } | 287 } |
275 | 288 |
276 DGifDecompressLine(GifFile, Line, LineLen); | 289 DGifDecompressLine(GifFile, Line, LineLen); |
295 if (!IS_READABLE(Private)) { | 308 if (!IS_READABLE(Private)) { |
296 /* This file was NOT open for reading: */ | 309 /* This file was NOT open for reading: */ |
297 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); | 310 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); |
298 } | 311 } |
299 | 312 |
300 #if defined(WIN32_NATIVE) || defined(__GNUC__) | 313 #if defined(__MSDOS__) || defined(__GNUC__) |
301 if (--Private->PixelCount > 0xffff0000UL) | 314 if (--Private->PixelCount > 0xffff0000UL) |
302 #else | 315 #else |
303 if (--Private->PixelCount > 0xffff0000) | 316 if (--Private->PixelCount > 0xffff0000) |
304 #endif /* WIN32_NATIVE */ | 317 #endif /* __MSDOS__ */ |
305 { | 318 { |
306 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); | 319 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); |
307 } | 320 } |
308 | 321 |
309 DGifDecompressLine(GifFile, &Pixel, 1); | 322 DGifDecompressLine(GifFile, &Pixel, 1); |