Home | History | Annotate | Download | only in giflib
      1 /*****************************************************************************
      2  *   "Gif-Lib" - Yet another gif library.
      3  *
      4  * Written by:  Gershon Elber            IBM PC Ver 0.1,    Jun. 1989
      5  *****************************************************************************
      6  * Handle error reporting for the GIF library.
      7  *****************************************************************************
      8  * History:
      9  * 17 Jun 89 - Version 1.0 by Gershon Elber.
     10  ****************************************************************************/
     11 
     12 #ifdef HAVE_CONFIG_H
     13 #include <config.h>
     14 #endif
     15 
     16 #include <stdio.h>
     17 #include "gif_lib.h"
     18 
     19 int _GifError = 0;
     20 
     21 /*****************************************************************************
     22  * Return the last GIF error (0 if none) and reset the error.
     23  ****************************************************************************/
     24 int
     25 GifLastError(void) {
     26     int i = _GifError;
     27 
     28     _GifError = 0;
     29 
     30     return i;
     31 }
     32 #ifndef _GBA_NO_FILEIO
     33 
     34 /*****************************************************************************
     35  * Print the last GIF error to stderr.
     36  ****************************************************************************/
     37 void
     38 PrintGifError(void) {
     39     char *Err;
     40 
     41     switch (_GifError) {
     42       case E_GIF_ERR_OPEN_FAILED:
     43         Err = "Failed to open given file";
     44         break;
     45       case E_GIF_ERR_WRITE_FAILED:
     46         Err = "Failed to Write to given file";
     47         break;
     48       case E_GIF_ERR_HAS_SCRN_DSCR:
     49         Err = "Screen Descriptor already been set";
     50         break;
     51       case E_GIF_ERR_HAS_IMAG_DSCR:
     52         Err = "Image Descriptor is still active";
     53         break;
     54       case E_GIF_ERR_NO_COLOR_MAP:
     55         Err = "Neither Global Nor Local color map";
     56         break;
     57       case E_GIF_ERR_DATA_TOO_BIG:
     58         Err = "#Pixels bigger than Width * Height";
     59         break;
     60       case E_GIF_ERR_NOT_ENOUGH_MEM:
     61         Err = "Fail to allocate required memory";
     62         break;
     63       case E_GIF_ERR_DISK_IS_FULL:
     64         Err = "Write failed (disk full?)";
     65         break;
     66       case E_GIF_ERR_CLOSE_FAILED:
     67         Err = "Failed to close given file";
     68         break;
     69       case E_GIF_ERR_NOT_WRITEABLE:
     70         Err = "Given file was not opened for write";
     71         break;
     72       case D_GIF_ERR_OPEN_FAILED:
     73         Err = "Failed to open given file";
     74         break;
     75       case D_GIF_ERR_READ_FAILED:
     76         Err = "Failed to Read from given file";
     77         break;
     78       case D_GIF_ERR_NOT_GIF_FILE:
     79         Err = "Given file is NOT GIF file";
     80         break;
     81       case D_GIF_ERR_NO_SCRN_DSCR:
     82         Err = "No Screen Descriptor detected";
     83         break;
     84       case D_GIF_ERR_NO_IMAG_DSCR:
     85         Err = "No Image Descriptor detected";
     86         break;
     87       case D_GIF_ERR_NO_COLOR_MAP:
     88         Err = "Neither Global Nor Local color map";
     89         break;
     90       case D_GIF_ERR_WRONG_RECORD:
     91         Err = "Wrong record type detected";
     92         break;
     93       case D_GIF_ERR_DATA_TOO_BIG:
     94         Err = "#Pixels bigger than Width * Height";
     95         break;
     96       case D_GIF_ERR_NOT_ENOUGH_MEM:
     97         Err = "Fail to allocate required memory";
     98         break;
     99       case D_GIF_ERR_CLOSE_FAILED:
    100         Err = "Failed to close given file";
    101         break;
    102       case D_GIF_ERR_NOT_READABLE:
    103         Err = "Given file was not opened for read";
    104         break;
    105       case D_GIF_ERR_IMAGE_DEFECT:
    106         Err = "Image is defective, decoding aborted";
    107         break;
    108       case D_GIF_ERR_EOF_TOO_SOON:
    109         Err = "Image EOF detected, before image complete";
    110         break;
    111       default:
    112         Err = NULL;
    113         break;
    114     }
    115     if (Err != NULL)
    116         fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
    117     else
    118         fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
    119 }
    120 #endif /* _GBA_NO_FILEIO */
    121