annotate src/gif_err.c @ 165:5a88923fcbfe r20-3b9

Import from CVS: tag r20-3b9
author cvs
date Mon, 13 Aug 2007 09:44:42 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 * "Gif-Lib" - Yet another gif library. *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 * *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 * Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ******************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 * Handle error reporting for the GIF library. *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ******************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 * History: *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 * 17 Jun 89 - Version 1.0 by Gershon Elber. *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 *****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 #include "gif_lib.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 #define PROGRAM_NAME "GIF_LIBRARY"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 int _GifError;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #ifndef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #ifdef SYSV
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 static char *VersionStr =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 "Gif library module,\t\tGershon Elber\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 static char *VersionStr =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 PROGRAM_NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 " IBMPC "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 GIF_LIB_VERSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 " Gershon Elber, "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 __DATE__ ", " __TIME__ "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #endif /* SYSV */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #endif /* !emacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 * Return the last GIF error (0 if none) and reset the error. *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 *****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 int GifLastError(void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 int i = _GifError;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 _GifError = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 return i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 * Print the last GIF error to stderr. *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 *****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 CONST char *EmacsPrintGifError(void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 void PrintGifError(void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 CONST char *Err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 switch(_GifError) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 case E_GIF_ERR_OPEN_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Err = "Failed to open given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 case E_GIF_ERR_WRITE_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Err = "Failed to Write to given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 case E_GIF_ERR_HAS_SCRN_DSCR:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 Err = "Screen Descriptor already been set";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 case E_GIF_ERR_HAS_IMAG_DSCR:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Err = "Image Descriptor is still active";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 case E_GIF_ERR_NO_COLOR_MAP:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 Err = "Neither Global Nor Local color map";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 case E_GIF_ERR_DATA_TOO_BIG:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Err = "#Pixels bigger than Width * Height";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 case E_GIF_ERR_NOT_ENOUGH_MEM:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Err = "Fail to allocate required memory";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 case E_GIF_ERR_DISK_IS_FULL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Err = "Write failed (disk full?)";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 case E_GIF_ERR_CLOSE_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Err = "Failed to close given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 case E_GIF_ERR_NOT_WRITEABLE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Err = "Given file was not opened for write";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 case D_GIF_ERR_OPEN_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Err = "Failed to open given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 case D_GIF_ERR_READ_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Err = "Failed to Read from given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 case D_GIF_ERR_NOT_GIF_FILE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Err = "Given file is NOT GIF file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 case D_GIF_ERR_NO_SCRN_DSCR:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Err = "No Screen Descriptor detected";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 case D_GIF_ERR_NO_IMAG_DSCR:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 Err = "No Image Descriptor detected";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 case D_GIF_ERR_NO_COLOR_MAP:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Err = "Neither Global Nor Local color map";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 case D_GIF_ERR_WRONG_RECORD:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Err = "Wrong record type detected";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 case D_GIF_ERR_DATA_TOO_BIG:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Err = "#Pixels bigger than Width * Height";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 case D_GIF_ERR_NOT_ENOUGH_MEM:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Err = "Fail to allocate required memory";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 case D_GIF_ERR_CLOSE_FAILED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Err = "Failed to close given file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 case D_GIF_ERR_NOT_READABLE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Err = "Given file was not opened for read";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 case D_GIF_ERR_IMAGE_DEFECT:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Err = "Image is defective, decoding aborted";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 case D_GIF_ERR_EOF_TOO_SOON:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Err = "Image EOF detected, before image complete";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Err = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 if (Err != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 return Err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 return "Unknown error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 if (Err != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 void init_gif_err (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 init_gif_err (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 _GifError = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 }