comparison src/gif_err.c @ 0:376386a54a3c r19-14

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