PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 49#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
 50#pragma option -A                      /* force ANSI-C */
 51#endif
 52
 53#ifndef _libmng_error_h_
 54#define _libmng_error_h_
 55
 56/* ************************************************************************** */
 57/* *                                                                        * */
 58/* * Default error routines                                                 * */
 59/* *                                                                        * */
 60/* ************************************************************************** */
 61
 62mng_bool mng_store_error   (mng_datap   pData,
 63                            mng_retcode iError,
 64                            mng_retcode iExtra1,
 65                            mng_retcode iExtra2);
 66
 67mng_bool mng_process_error (mng_datap   pData,
 68                            mng_retcode iError,
 69                            mng_retcode iExtra1,
 70                            mng_retcode iExtra2);
 71
 72/* ************************************************************************** */
 73/* *                                                                        * */
 74/* * Error handling macros                                                  * */
 75/* *                                                                        * */
 76/* ************************************************************************** */
 77
 78#ifdef MNG_SOFTERRORS
 79#define MNG_ERROR(D,C)      { if (!mng_process_error (D, C, 0, 0)) return C; }
 80#define MNG_ERRORZ(D,Z)     { if (!mng_process_error (D, MNG_ZLIBERROR, Z, 0)) return MNG_ZLIBERROR; }
 81#define MNG_ERRORJ(D,J)     { if (!mng_process_error (D, MNG_JPEGERROR, J, 0)) return MNG_JPEGERROR; }
 82#define MNG_ERRORL(D,L)     { if (!mng_process_error (D, MNG_LCMSERROR, L, 0)) return MNG_LCMSERROR; }
 83#else
 84#define MNG_ERROR(D,C)      { mng_process_error (D, C, 0, 0); return C; }
 85#define MNG_ERRORZ(D,Z)     { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; }
 86#define MNG_ERRORJ(D,J)     { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; }
 87#define MNG_ERRORL(D,L)     { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; }
 88#endif
 89
 90#define MNG_RETURN(D,C)     { mng_store_error (D, C, 0, 0); return C; }
 91
 92#define MNG_WARNING(D,C)    { if (!mng_process_error (D, C, 0, 0)) return C; }
 93
 94#define MNG_VALIDHANDLE(H)  { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
 95                                return MNG_INVALIDHANDLE; }
 96#define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
 97                                return 0; }
 98#define MNG_VALIDCB(D,C)    { if (!((mng_datap)D)->C) \
 99                                MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) }
100
101/* ************************************************************************** */
102/* *                                                                        * */
103/* * Error string-table entry                                               * */
104/* *                                                                        * */
105/* ************************************************************************** */
106
107typedef struct {
108                 mng_retcode iError;
109                 mng_pchar   zErrortext;
110               } mng_error_entry;
111typedef mng_error_entry const * mng_error_entryp;
112
113/* ************************************************************************** */
114
115#endif /* _libmng_error_h_ */
116
117/* ************************************************************************** */
118/* * end of file                                                            * */
119/* ************************************************************************** */