/src/FreeImage/Source/LibMNG/libmng_error.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 119 lines · 38 code · 15 blank · 66 comment · 15 complexity · d73284b9ea8496a53cfcae7d792fc60c MD5 · raw file

  1. /* ************************************************************************** */
  2. /* * For conditions of distribution and use, * */
  3. /* * see copyright notice in libmng.h * */
  4. /* ************************************************************************** */
  5. /* * * */
  6. /* * project : libmng * */
  7. /* * file : libmng_error.h copyright (c) 2000-2002 G.Juyn * */
  8. /* * version : 1.0.5 * */
  9. /* * * */
  10. /* * purpose : Error functions (definition) * */
  11. /* * * */
  12. /* * author : G.Juyn * */
  13. /* * * */
  14. /* * comment : Definition of the generic error-codes and functions * */
  15. /* * * */
  16. /* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
  17. /* * - added some errorcodes * */
  18. /* * 0.5.1 - 05/08/2000 - G.Juyn * */
  19. /* * - added some errorcodes * */
  20. /* * - changed strict-ANSI stuff * */
  21. /* * 0.5.1 - 05/11/2000 - G.Juyn * */
  22. /* * - added application errorcodes (used with callbacks) * */
  23. /* * - moved chunk-access errorcodes to severity 5 * */
  24. /* * * */
  25. /* * 0.5.2 - 05/20/2000 - G.Juyn * */
  26. /* * - added JNG errorcodes * */
  27. /* * 0.5.2 - 05/23/2000 - G.Juyn * */
  28. /* * - added error tell-tale definition * */
  29. /* * 0.5.2 - 05/30/2000 - G.Juyn * */
  30. /* * - added errorcodes for delta-image processing * */
  31. /* * 0.5.2 - 06/06/2000 - G.Juyn * */
  32. /* * - added errorcode for delayed buffer-processing * */
  33. /* * - moved errorcodes to "libmng.h" * */
  34. /* * * */
  35. /* * 0.9.1 - 07/15/2000 - G.Juyn * */
  36. /* * - added macro + routine to set returncode without * */
  37. /* * calling error callback * */
  38. /* * * */
  39. /* * 0.9.2 - 08/05/2000 - G.Juyn * */
  40. /* * - changed file-prefixes * */
  41. /* * * */
  42. /* * 1.0.5 - 08/19/2002 - G.Juyn * */
  43. /* * - B597134 - libmng pollutes the linker namespace * */
  44. /* * 1.0.5 - 08/20/2002 - G.Juyn * */
  45. /* * - added option for soft-handling of errors * */
  46. /* * * */
  47. /* ************************************************************************** */
  48. #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
  49. #pragma option -A /* force ANSI-C */
  50. #endif
  51. #ifndef _libmng_error_h_
  52. #define _libmng_error_h_
  53. /* ************************************************************************** */
  54. /* * * */
  55. /* * Default error routines * */
  56. /* * * */
  57. /* ************************************************************************** */
  58. mng_bool mng_store_error (mng_datap pData,
  59. mng_retcode iError,
  60. mng_retcode iExtra1,
  61. mng_retcode iExtra2);
  62. mng_bool mng_process_error (mng_datap pData,
  63. mng_retcode iError,
  64. mng_retcode iExtra1,
  65. mng_retcode iExtra2);
  66. /* ************************************************************************** */
  67. /* * * */
  68. /* * Error handling macros * */
  69. /* * * */
  70. /* ************************************************************************** */
  71. #ifdef MNG_SOFTERRORS
  72. #define MNG_ERROR(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; }
  73. #define MNG_ERRORZ(D,Z) { if (!mng_process_error (D, MNG_ZLIBERROR, Z, 0)) return MNG_ZLIBERROR; }
  74. #define MNG_ERRORJ(D,J) { if (!mng_process_error (D, MNG_JPEGERROR, J, 0)) return MNG_JPEGERROR; }
  75. #define MNG_ERRORL(D,L) { if (!mng_process_error (D, MNG_LCMSERROR, L, 0)) return MNG_LCMSERROR; }
  76. #else
  77. #define MNG_ERROR(D,C) { mng_process_error (D, C, 0, 0); return C; }
  78. #define MNG_ERRORZ(D,Z) { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; }
  79. #define MNG_ERRORJ(D,J) { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; }
  80. #define MNG_ERRORL(D,L) { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; }
  81. #endif
  82. #define MNG_RETURN(D,C) { mng_store_error (D, C, 0, 0); return C; }
  83. #define MNG_WARNING(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; }
  84. #define MNG_VALIDHANDLE(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
  85. return MNG_INVALIDHANDLE; }
  86. #define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
  87. return 0; }
  88. #define MNG_VALIDCB(D,C) { if (!((mng_datap)D)->C) \
  89. MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) }
  90. /* ************************************************************************** */
  91. /* * * */
  92. /* * Error string-table entry * */
  93. /* * * */
  94. /* ************************************************************************** */
  95. typedef struct {
  96. mng_retcode iError;
  97. mng_pchar zErrortext;
  98. } mng_error_entry;
  99. typedef mng_error_entry const * mng_error_entryp;
  100. /* ************************************************************************** */
  101. #endif /* _libmng_error_h_ */
  102. /* ************************************************************************** */
  103. /* * end of file * */
  104. /* ************************************************************************** */