comparison src/dgif_lib.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 00f374c78661
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
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 #ifdef __MSDOS__ 14 #include <config.h>
15 #include <io.h> 15 #include "lisp.h"
16 #include <alloc.h> 16
17 #include <stdlib.h> 17 #include "sysfile.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
31 18
32 #include "gifrlib.h" 19 #include "gifrlib.h"
33 20
34 #define PROGRAM_NAME "GIFLIB" 21 #define PROGRAM_NAME "GIFLIB"
35 22
50 void DGifOpenFileName(GifFileType *GifFile, const char *FileName) 37 void DGifOpenFileName(GifFileType *GifFile, const char *FileName)
51 { 38 {
52 FILE *f; 39 FILE *f;
53 40
54 if ((f = fopen(FileName, 41 if ((f = fopen(FileName,
55 #ifdef __MSDOS__ 42 #ifdef WIN32_NATIVE
56 "rb" 43 "rb"
57 #else 44 #else
58 "r" 45 "r"
59 #endif /* __MSDOS__ */ 46 #endif /* WIN32_NATIVE */
60 )) == NULL) 47 )) == NULL)
61 GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED); 48 GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED);
62 49
63 GifStdIOInit(GifFile, f, -1); 50 GifStdIOInit(GifFile, f, -1);
64 DGifInitRead(GifFile); 51 DGifInitRead(GifFile);
71 ******************************************************************************/ 58 ******************************************************************************/
72 void DGifOpenFileHandle(GifFileType *GifFile, int FileHandle) 59 void DGifOpenFileHandle(GifFileType *GifFile, int FileHandle)
73 { 60 {
74 FILE *f; 61 FILE *f;
75 62
76 #ifdef __MSDOS__ 63 #ifdef WIN32_NATIVE
77 setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ 64 setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
78 f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ 65 f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
79 setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ 66 setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/
80 #else 67 #else
81 f = fdopen(FileHandle, "r"); /* Make it into a stream: */ 68 f = fdopen(FileHandle, "r"); /* Make it into a stream: */
82 #endif /* __MSDOS__ */ 69 #endif /* WIN32_NATIVE */
83 70
84 GifStdIOInit(GifFile, f, -1); 71 GifStdIOInit(GifFile, f, -1);
85 DGifInitRead(GifFile); 72 DGifInitRead(GifFile);
86 } 73 }
87 74
275 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); 262 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE);
276 } 263 }
277 264
278 if (!LineLen) LineLen = GifFile->Image.Width; 265 if (!LineLen) LineLen = GifFile->Image.Width;
279 266
280 #if defined(__MSDOS__) || defined(__GNUC__) 267 #if defined(WIN32_NATIVE) || defined(__GNUC__)
281 if ((Private->PixelCount -= LineLen) > 0xffff0000UL) 268 if ((Private->PixelCount -= LineLen) > 0xffff0000UL)
282 #else 269 #else
283 if ((Private->PixelCount -= LineLen) > 0xffff0000) 270 if ((Private->PixelCount -= LineLen) > 0xffff0000)
284 #endif /* __MSDOS__ */ 271 #endif /* WIN32_NATIVE */
285 { 272 {
286 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); 273 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG);
287 } 274 }
288 275
289 DGifDecompressLine(GifFile, Line, LineLen); 276 DGifDecompressLine(GifFile, Line, LineLen);
308 if (!IS_READABLE(Private)) { 295 if (!IS_READABLE(Private)) {
309 /* This file was NOT open for reading: */ 296 /* This file was NOT open for reading: */
310 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); 297 GifInternError(GifFile, D_GIF_ERR_NOT_READABLE);
311 } 298 }
312 299
313 #if defined(__MSDOS__) || defined(__GNUC__) 300 #if defined(WIN32_NATIVE) || defined(__GNUC__)
314 if (--Private->PixelCount > 0xffff0000UL) 301 if (--Private->PixelCount > 0xffff0000UL)
315 #else 302 #else
316 if (--Private->PixelCount > 0xffff0000) 303 if (--Private->PixelCount > 0xffff0000)
317 #endif /* __MSDOS__ */ 304 #endif /* WIN32_NATIVE */
318 { 305 {
319 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); 306 GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG);
320 } 307 }
321 308
322 DGifDecompressLine(GifFile, &Pixel, 1); 309 DGifDecompressLine(GifFile, &Pixel, 1);