gif_err.c 3.8 KB

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