7 * external interface to gifin.c
9 * Copyright 1989 Kirk L. Johnson (see the included file
10 * "kljcpyrght.h" for complete copyright information)
16 #define GIFIN_SUCCESS 0 /* success */
17 #define GIFIN_DONE 1 /* no more images */
19 #define GIFIN_ERR_BAD_SD -1 /* bad screen descriptor */
20 #define GIFIN_ERR_BAD_SEP -2 /* bad image separator */
21 #define GIFIN_ERR_BAD_SIG -3 /* bad signature */
22 #define GIFIN_ERR_EOD -4 /* unexpected end of raster data */
23 #define GIFIN_ERR_EOF -5 /* unexpected end of input stream */
24 #define GIFIN_ERR_FAO -6 /* file already open */
25 #define GIFIN_ERR_IAO -7 /* image already open */
26 #define GIFIN_ERR_NFO -8 /* no file open */
27 #define GIFIN_ERR_NIO -9 /* no image open */
28 #define GIFIN_ERR_PSO -10 /* pixel stack overflow */
29 #define GIFIN_ERR_TAO -11 /* table overflow */
30 #define GIFIN_ERR_BAD_DES -12 /* bad image descriptor */
32 #define GIFIN_ERR_BAD_SD_STR "Bad screen descriptor"
33 #define GIFIN_ERR_BAD_SEP_STR "Bad image separator"
34 #define GIFIN_ERR_BAD_SIG_STR "Bad signature"
35 #define GIFIN_ERR_EOD_STR "Unexpected end of raster data"
36 #define GIFIN_ERR_EOF_STR "Unexpected end of input stream"
37 #define GIFIN_ERR_FAO_STR "File already open"
38 #define GIFIN_ERR_IAO_STR "Image already open"
39 #define GIFIN_ERR_NFO_STR "No file open"
40 #define GIFIN_ERR_NIO_STR "No image open"
41 #define GIFIN_ERR_PSO_STR "Pixel stack overflow"
42 #define GIFIN_ERR_TAO_STR "Table overflow"
43 #define GIFIN_ERR_BAD_DES_STR "Bad image descriptor"
51 gif_err_string gif_err_strings[] = {
52 {GIFIN_ERR_BAD_SD, GIFIN_ERR_BAD_SD_STR},
53 {GIFIN_ERR_BAD_SEP, GIFIN_ERR_BAD_SEP_STR},
54 {GIFIN_ERR_BAD_SIG, GIFIN_ERR_BAD_SIG_STR},
55 {GIFIN_ERR_EOD, GIFIN_ERR_EOD_STR},
56 {GIFIN_ERR_EOF, GIFIN_ERR_EOF_STR},
57 {GIFIN_ERR_FAO, GIFIN_ERR_FAO_STR},
58 {GIFIN_ERR_IAO, GIFIN_ERR_IAO_STR},
59 {GIFIN_ERR_NFO, GIFIN_ERR_NFO_STR},
60 {GIFIN_ERR_NIO, GIFIN_ERR_NIO_STR},
61 {GIFIN_ERR_PSO, GIFIN_ERR_PSO_STR},
62 {GIFIN_ERR_TAO, GIFIN_ERR_TAO_STR},
63 {GIFIN_ERR_BAD_DES, GIFIN_ERR_BAD_DES_STR},
77 * typedef BYTE for convenience
80 typedef unsigned char BYTE;
82 static int gifin_open_file();
83 static int gifin_open_image();
84 static int gifin_get_pixel();
86 static int gifin_close_image();
88 static int gifin_close_file();
89 static int gifin_load_cmap();
90 static int gifin_skip_extension();
91 static int gifin_read_data_block();
92 static int gifin_add_string();
94 /* #defines, typedefs, and such
97 #define GIF_SIG "GIF87a"
98 #define GIF_SIG_89 "GIF89a"
100 #define GIF87a 0 /* Gif file version type */
101 #define GIF89a 1 /* Gif file version type */
103 #define GIF_SIG_LEN 6 /* GIF signature length */
104 #define GIF_SD_SIZE 7 /* GIF screen descriptor size */
105 #define GIF_ID_SIZE 9 /* GIF image descriptor size */
107 #define GIF_SEPARATOR ',' /* GIF image separator */
108 #define GIF_EXTENSION '!' /* GIF extension block marker */
109 #define GIF_TERMINATOR ';' /* GIF terminator */
111 #define STAB_SIZE 4096 /* string table size */
112 #define PSTK_SIZE 4096 /* pixel stack size */
114 #define NULL_CODE -1 /* string table null code */
117 char *gif_version_name[] = {