summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libmng/libmng_error.h
blob: 9ea9316c7cfb2174bedf15a174f5a60bf3158aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* ************************************************************************** */
/* *             For conditions of distribution and use,                    * */
/* *                see copyright notice in libmng.h                        * */
/* ************************************************************************** */
/* *                                                                        * */
/* * project   : libmng                                                     * */
/* * file      : libmng_error.h            copyright (c) 2000 G.Juyn        * */
/* * version   : 1.0.0                                                      * */
/* *                                                                        * */
/* * purpose   : Error functions (definition)                               * */
/* *                                                                        * */
/* * author    : G.Juyn                                                     * */
/* * web       : http://www.3-t.com                                         * */
/* * email     : mailto:[email protected]                                        * */
/* *                                                                        * */
/* * comment   : Definition of the generic error-codes and functions        * */
/* *                                                                        * */
/* * changes   : 0.5.1 - 05/06/2000 - G.Juyn                                * */
/* *             - added some errorcodes                                    * */
/* *             0.5.1 - 05/08/2000 - G.Juyn                                * */
/* *             - added some errorcodes                                    * */
/* *             - changed strict-ANSI stuff                                * */
/* *             0.5.1 - 05/11/2000 - G.Juyn                                * */
/* *             - added application errorcodes (used with callbacks)       * */
/* *             - moved chunk-access errorcodes to severity 5              * */
/* *                                                                        * */
/* *             0.5.2 - 05/20/2000 - G.Juyn                                * */
/* *             - added JNG errorcodes                                     * */
/* *             0.5.2 - 05/23/2000 - G.Juyn                                * */
/* *             - added error tell-tale definition                         * */
/* *             0.5.2 - 05/30/2000 - G.Juyn                                * */
/* *             - added errorcodes for delta-image processing              * */
/* *             0.5.2 - 06/06/2000 - G.Juyn                                * */
/* *             - added errorcode for delayed buffer-processing            * */
/* *             - moved errorcodes to "libmng.h"                           * */
/* *                                                                        * */
/* *             0.9.1 - 07/15/2000 - G.Juyn                                * */
/* *             - added macro + routine to set returncode without          * */
/* *               calling error callback                                   * */
/* *                                                                        * */
/* *             0.9.2 - 08/05/2000 - G.Juyn                                * */
/* *             - changed file-prefixes                                    * */
/* *                                                                        * */
/* ************************************************************************** */

#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
#pragma option -A                      /* force ANSI-C */
#endif

#ifndef _libmng_error_h_
#define _libmng_error_h_

/* ************************************************************************** */
/* *                                                                        * */
/* * Default error routines                                                 * */
/* *                                                                        * */
/* ************************************************************************** */

mng_bool mng_store_error   (mng_datap   pData,
                            mng_retcode iError,
                            mng_retcode iExtra1,
                            mng_retcode iExtra2);

mng_bool mng_process_error (mng_datap   pData,
                            mng_retcode iError,
                            mng_retcode iExtra1,
                            mng_retcode iExtra2);

/* ************************************************************************** */
/* *                                                                        * */
/* * Error handling macros                                                  * */
/* *                                                                        * */
/* ************************************************************************** */

#define MNG_ERROR(D,C)      { mng_process_error (D, C, 0, 0); return C; }
#define MNG_ERRORZ(D,Z)     { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; }
#define MNG_ERRORJ(D,J)     { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; }
#define MNG_ERRORL(D,L)     { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; }

#define MNG_RETURN(D,C)     { mng_store_error (D, C, 0, 0); return C; }

#define MNG_WARNING(D,C)    { if (!mng_process_error (D, C, 0, 0)) return C; }

#define MNG_VALIDHANDLE(H)  { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
                                return MNG_INVALIDHANDLE; }
#define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \
                                return 0; }
#define MNG_VALIDCB(D,C)    { if (!((mng_datap)D)->C) \
                                MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) }

/* ************************************************************************** */
/* *                                                                        * */
/* * Error string-table entry                                               * */
/* *                                                                        * */
/* ************************************************************************** */

typedef struct {
           mng_retcode iError;
           mng_pchar   zErrortext;
        } mng_error_entry;
typedef mng_error_entry * mng_error_entryp;

/* ************************************************************************** */

#endif /* _libmng_error_h_ */

/* ************************************************************************** */
/* * end of file                                                            * */
/* ************************************************************************** */