Back to index

im-sdk  12.3.91
gif_err.c
Go to the documentation of this file.
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 #include <stdio.h>
00013 #include "gif_lib.h"
00014 
00015 #define PROGRAM_NAME "GIF_LIBRARY"
00016 
00017 int _GifError = 0;
00018 
00019 #ifdef SYSV
00020 static char *VersionStr =
00021         "Gif library module,\t\tGershon Elber\n\
00022        (C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
00023 #else
00024 static char *VersionStr =
00025        PROGRAM_NAME
00026        "      IBMPC "
00027        GIF_LIB_VERSION
00028        "      Gershon Elber,       "
00029        __DATE__ ",   " __TIME__ "\n"
00030        "(C) Copyright 1989 Gershon Elber, Non commercial use only.\n";
00031 #endif /* SYSV */
00032 
00033 /*****************************************************************************
00034 * Return the last GIF error (0 if none) and reset the error.               *
00035 *****************************************************************************/
00036 int GifLastError(void)
00037 {
00038     int i = _GifError;
00039 
00040     _GifError = 0;
00041 
00042     return i;
00043 }
00044 
00045 /*****************************************************************************
00046 * Print the last GIF error to stderr.                                      *
00047 *****************************************************************************/
00048 void PrintGifError(void)
00049 {
00050     char *Err;
00051 
00052     switch(_GifError) {
00053        case E_GIF_ERR_OPEN_FAILED:
00054            Err = "Failed to open given file";
00055            break;
00056        case E_GIF_ERR_WRITE_FAILED:
00057            Err = "Failed to Write to given file";
00058            break;
00059        case E_GIF_ERR_HAS_SCRN_DSCR:
00060            Err = "Screen Descriptor already been set";
00061            break;
00062        case E_GIF_ERR_HAS_IMAG_DSCR:
00063            Err = "Image Descriptor is still active";
00064            break;
00065        case E_GIF_ERR_NO_COLOR_MAP:
00066            Err = "Neither Global Nor Local color map";
00067            break;
00068        case E_GIF_ERR_DATA_TOO_BIG:
00069            Err = "#Pixels bigger than Width * Height";
00070            break;
00071        case E_GIF_ERR_NOT_ENOUGH_MEM:
00072            Err = "Fail to allocate required memory";
00073            break;
00074        case E_GIF_ERR_DISK_IS_FULL:
00075            Err = "Write failed (disk full?)";
00076            break;
00077        case E_GIF_ERR_CLOSE_FAILED:
00078            Err = "Failed to close given file";
00079            break;
00080        case E_GIF_ERR_NOT_WRITEABLE:
00081            Err = "Given file was not opened for write";
00082            break;
00083        case D_GIF_ERR_OPEN_FAILED:
00084            Err = "Failed to open given file";
00085            break;
00086        case D_GIF_ERR_READ_FAILED:
00087            Err = "Failed to Read from given file";
00088            break;
00089        case D_GIF_ERR_NOT_GIF_FILE:
00090            Err = "Given file is NOT GIF file";
00091            break;
00092        case D_GIF_ERR_NO_SCRN_DSCR:
00093            Err = "No Screen Descriptor detected";
00094            break;
00095        case D_GIF_ERR_NO_IMAG_DSCR:
00096            Err = "No Image Descriptor detected";
00097            break;
00098        case D_GIF_ERR_NO_COLOR_MAP:
00099            Err = "Neither Global Nor Local color map";
00100            break;
00101        case D_GIF_ERR_WRONG_RECORD:
00102            Err = "Wrong record type detected";
00103            break;
00104        case D_GIF_ERR_DATA_TOO_BIG:
00105            Err = "#Pixels bigger than Width * Height";
00106            break;
00107        case D_GIF_ERR_NOT_ENOUGH_MEM:
00108            Err = "Fail to allocate required memory";
00109            break;
00110        case D_GIF_ERR_CLOSE_FAILED:
00111            Err = "Failed to close given file";
00112            break;
00113        case D_GIF_ERR_NOT_READABLE:
00114            Err = "Given file was not opened for read";
00115            break;
00116        case D_GIF_ERR_IMAGE_DEFECT:
00117            Err = "Image is defective, decoding aborted";
00118            break;
00119        case D_GIF_ERR_EOF_TOO_SOON:
00120            Err = "Image EOF detected, before image complete";
00121            break;
00122        default:
00123            Err = NULL;
00124            break;
00125     }
00126     if (Err != NULL)
00127        fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
00128     else
00129        fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
00130 }