00001 /***************************************************************************** 00002 * "Gif-Lib" - Yet another gif library. * 00003 * * 00004 * Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 * 00005 ****************************************************************************** 00006 * Handle error reporting for the GIF library. * 00007 ****************************************************************************** 00008 * History: * 00009 * 17 Jun 89 - Version 1.0 by Gershon Elber. * 00010 *****************************************************************************/ 00011 00012 #ifdef _WIN32 00013 #include "../win32/config.h" 00014 #else 00015 #include "../config.h" 00016 #endif 00017 00018 #include <stdio.h> 00019 #include "gif_lib.h" 00020 00021 #define PROGRAM_NAME "GIF_LIBRARY" 00022 00023 int _GifError = 0; 00024 00025 #ifdef SYSV 00026 static char *VersionStr = 00027 "Gif library module,\t\tEric S. Raymond\n\ 00028 (C) Copyright 1997 Eric S. Raymond\n"; 00029 #else 00030 static char *VersionStr = 00031 PROGRAM_NAME 00032 " IBMPC " 00033 GIF_LIB_VERSION 00034 " Eric S. Raymond, " 00035 __DATE__ ", " __TIME__ "\n" 00036 "(C) Copyright 1997 Eric S. Raymond\n"; 00037 #endif /* SYSV */ 00038 00039 const char *GetGifVersionStr() 00040 { 00041 return VersionStr; 00042 } 00043 00044 /***************************************************************************** 00045 * Return the last GIF error (0 if none) and reset the error. * 00046 *****************************************************************************/ 00047 int GifLastError(void) 00048 { 00049 int i = _GifError; 00050 00051 _GifError = 0; 00052 00053 return i; 00054 } 00055 00056 /***************************************************************************** 00057 * Print the last GIF error to stderr. * 00058 *****************************************************************************/ 00059 void PrintGifError(void) 00060 { 00061 char *Err; 00062 00063 switch(_GifError) { 00064 case E_GIF_ERR_OPEN_FAILED: 00065 Err = "Failed to open given file"; 00066 break; 00067 case E_GIF_ERR_WRITE_FAILED: 00068 Err = "Failed to Write to given file"; 00069 break; 00070 case E_GIF_ERR_HAS_SCRN_DSCR: 00071 Err = "Screen Descriptor already been set"; 00072 break; 00073 case E_GIF_ERR_HAS_IMAG_DSCR: 00074 Err = "Image Descriptor is still active"; 00075 break; 00076 case E_GIF_ERR_NO_COLOR_MAP: 00077 Err = "Neither Global Nor Local color map"; 00078 break; 00079 case E_GIF_ERR_DATA_TOO_BIG: 00080 Err = "#Pixels bigger than Width * Height"; 00081 break; 00082 case E_GIF_ERR_NOT_ENOUGH_MEM: 00083 Err = "Fail to allocate required memory"; 00084 break; 00085 case E_GIF_ERR_DISK_IS_FULL: 00086 Err = "Write failed (disk full?)"; 00087 break; 00088 case E_GIF_ERR_CLOSE_FAILED: 00089 Err = "Failed to close given file"; 00090 break; 00091 case E_GIF_ERR_NOT_WRITEABLE: 00092 Err = "Given file was not opened for write"; 00093 break; 00094 case D_GIF_ERR_OPEN_FAILED: 00095 Err = "Failed to open given file"; 00096 break; 00097 case D_GIF_ERR_READ_FAILED: 00098 Err = "Failed to Read from given file"; 00099 break; 00100 case D_GIF_ERR_NOT_GIF_FILE: 00101 Err = "Given file is NOT GIF file"; 00102 break; 00103 case D_GIF_ERR_NO_SCRN_DSCR: 00104 Err = "No Screen Descriptor detected"; 00105 break; 00106 case D_GIF_ERR_NO_IMAG_DSCR: 00107 Err = "No Image Descriptor detected"; 00108 break; 00109 case D_GIF_ERR_NO_COLOR_MAP: 00110 Err = "Neither Global Nor Local color map"; 00111 break; 00112 case D_GIF_ERR_WRONG_RECORD: 00113 Err = "Wrong record type detected"; 00114 break; 00115 case D_GIF_ERR_DATA_TOO_BIG: 00116 Err = "#Pixels bigger than Width * Height"; 00117 break; 00118 case D_GIF_ERR_NOT_ENOUGH_MEM: 00119 Err = "Fail to allocate required memory"; 00120 break; 00121 case D_GIF_ERR_CLOSE_FAILED: 00122 Err = "Failed to close given file"; 00123 break; 00124 case D_GIF_ERR_NOT_READABLE: 00125 Err = "Given file was not opened for read"; 00126 break; 00127 case D_GIF_ERR_IMAGE_DEFECT: 00128 Err = "Image is defective, decoding aborted"; 00129 break; 00130 case D_GIF_ERR_EOF_TOO_SOON: 00131 Err = "Image EOF detected, before image complete"; 00132 break; 00133 default: 00134 Err = NULL; 00135 break; 00136 } 00137 if (Err != NULL) 00138 fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); 00139 else 00140 fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError); 00141 }