6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /***************************************************************************** 26 * "Gif-Lib" - Yet another gif library. 27 * 28 * Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 29 ***************************************************************************** 30 * Handle error reporting for the GIF library. 31 ***************************************************************************** 32 * History: 33 * 17 Jun 89 - Version 1.0 by Gershon Elber. 34 ****************************************************************************/ 35 36 #ifdef HAVE_CONFIG_H 37 #include <config.h> 38 #endif 39 40 #include <stdio.h> 41 #include "gif_lib.h" 42 43 int _GifError = 0; 44 45 /***************************************************************************** 46 * Return the last GIF error (0 if none) and reset the error. 47 ****************************************************************************/ 48 int 49 GifLastError(void) { 50 int i = _GifError; 51 52 _GifError = 0; 53 54 return i; 55 } 56 57 /***************************************************************************** 58 * Print the last GIF error to stderr. 59 ****************************************************************************/ 60 void 61 PrintGifError(void) { 62 char *Err; 63 64 switch (_GifError) { 65 case D_GIF_ERR_OPEN_FAILED: 66 Err = "Failed to open given file"; 67 break; 68 case D_GIF_ERR_READ_FAILED: 69 Err = "Failed to Read from given file"; 70 break; 71 case D_GIF_ERR_NOT_GIF_FILE: 72 Err = "Given file is NOT GIF file"; 73 break; 74 case D_GIF_ERR_NO_SCRN_DSCR: 75 Err = "No Screen Descriptor detected"; 76 break; 77 case D_GIF_ERR_NO_IMAG_DSCR: 78 Err = "No Image Descriptor detected"; 79 break; 80 case D_GIF_ERR_NO_COLOR_MAP: 81 Err = "Neither Global Nor Local color map"; 82 break; 83 case D_GIF_ERR_WRONG_RECORD: 84 Err = "Wrong record type detected"; 85 break; 86 case D_GIF_ERR_DATA_TOO_BIG: 87 Err = "#Pixels bigger than Width * Height"; 88 break; 89 case D_GIF_ERR_NOT_ENOUGH_MEM: 90 Err = "Fail to allocate required memory"; 91 break; 92 case D_GIF_ERR_CLOSE_FAILED: 93 Err = "Failed to close given file"; 94 break; 95 case D_GIF_ERR_NOT_READABLE: 96 Err = "Given file was not opened for read"; 97 break; 98 case D_GIF_ERR_IMAGE_DEFECT: 99 Err = "Image is defective, decoding aborted"; 100 break; 101 case D_GIF_ERR_EOF_TOO_SOON: 102 Err = "Image EOF detected, before image complete"; 103 break; 104 default: 105 Err = NULL; 106 break; 107 } 108 if (Err != NULL) 109 fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); 110 else 111 fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError); 112 } | 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /***************************************************************************** 26 27 gif_err.c - handle error reporting for the GIF library. 28 29 ****************************************************************************/ 30 31 #include <stdio.h> 32 33 #include "gif_lib.h" 34 #include "gif_lib_private.h" 35 36 /***************************************************************************** 37 Return a string description of the last GIF error 38 *****************************************************************************/ 39 const char * 40 GifErrorString(int ErrorCode) 41 { 42 const char *Err; 43 44 switch (ErrorCode) { 45 case E_GIF_ERR_OPEN_FAILED: 46 Err = "Failed to open given file"; 47 break; 48 case E_GIF_ERR_WRITE_FAILED: 49 Err = "Failed to write to given file"; 50 break; 51 case E_GIF_ERR_HAS_SCRN_DSCR: 52 Err = "Screen descriptor has already been set"; 53 break; 54 case E_GIF_ERR_HAS_IMAG_DSCR: 55 Err = "Image descriptor is still active"; 56 break; 57 case E_GIF_ERR_NO_COLOR_MAP: 58 Err = "Neither global nor local color map"; 59 break; 60 case E_GIF_ERR_DATA_TOO_BIG: 61 Err = "Number of pixels bigger than width * height"; 62 break; 63 case E_GIF_ERR_NOT_ENOUGH_MEM: 64 Err = "Failed to allocate required memory"; 65 break; 66 case E_GIF_ERR_DISK_IS_FULL: 67 Err = "Write failed (disk full?)"; 68 break; 69 case E_GIF_ERR_CLOSE_FAILED: 70 Err = "Failed to close given file"; 71 break; 72 case E_GIF_ERR_NOT_WRITEABLE: 73 Err = "Given file was not opened for write"; 74 break; 75 case D_GIF_ERR_OPEN_FAILED: 76 Err = "Failed to open given file"; 77 break; 78 case D_GIF_ERR_READ_FAILED: 79 Err = "Failed to read from given file"; 80 break; 81 case D_GIF_ERR_NOT_GIF_FILE: 82 Err = "Data is not in GIF format"; 83 break; 84 case D_GIF_ERR_NO_SCRN_DSCR: 85 Err = "No screen descriptor detected"; 86 break; 87 case D_GIF_ERR_NO_IMAG_DSCR: 88 Err = "No Image Descriptor detected"; 89 break; 90 case D_GIF_ERR_NO_COLOR_MAP: 91 Err = "Neither global nor local color map"; 92 break; 93 case D_GIF_ERR_WRONG_RECORD: 94 Err = "Wrong record type detected"; 95 break; 96 case D_GIF_ERR_DATA_TOO_BIG: 97 Err = "Number of pixels bigger than width * height"; 98 break; 99 case D_GIF_ERR_NOT_ENOUGH_MEM: 100 Err = "Failed to allocate required memory"; 101 break; 102 case D_GIF_ERR_CLOSE_FAILED: 103 Err = "Failed to close given file"; 104 break; 105 case D_GIF_ERR_NOT_READABLE: 106 Err = "Given file was not opened for read"; 107 break; 108 case D_GIF_ERR_IMAGE_DEFECT: 109 Err = "Image is defective, decoding aborted"; 110 break; 111 case D_GIF_ERR_EOF_TOO_SOON: 112 Err = "Image EOF detected before image complete"; 113 break; 114 default: 115 Err = NULL; 116 break; 117 } 118 return Err; 119 } 120 121 /* end */ |