1/*
2 *  herr.h
3 *
4 *  $Id: herr.h,v 1.12 2006/07/10 13:49:29 source Exp $
5 *
6 *  Error stack management functions
7 *
8 *  The iODBC driver manager.
9 *
10 *  Copyright (C) 1995 by Ke Jin <kejin@empress.com>
11 *  Copyright (C) 1996-2006 by OpenLink Software <iodbc@openlinksw.com>
12 *  All Rights Reserved.
13 *
14 *  This software is released under the terms of either of the following
15 *  licenses:
16 *
17 *      - GNU Library General Public License (see LICENSE.LGPL)
18 *      - The BSD License (see LICENSE.BSD).
19 *
20 *  Note that the only valid version of the LGPL license as far as this
21 *  project is concerned is the original GNU Library General Public License
22 *  Version 2, dated June 1991.
23 *
24 *  While not mandated by the BSD license, any patches you make to the
25 *  iODBC source code may be contributed back into the iODBC project
26 *  at your discretion. Contributions will benefit the Open Source and
27 *  Data Access community as a whole. Submissions may be made at:
28 *
29 *      http://www.iodbc.org
30 *
31 *
32 *  GNU Library Generic Public License Version 2
33 *  ============================================
34 *  This library is free software; you can redistribute it and/or
35 *  modify it under the terms of the GNU Library General Public
36 *  License as published by the Free Software Foundation; only
37 *  Version 2 of the License dated June 1991.
38 *
39 *  This library is distributed in the hope that it will be useful,
40 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
41 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42 *  Library General Public License for more details.
43 *
44 *  You should have received a copy of the GNU Library General Public
45 *  License along with this library; if not, write to the Free
46 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
47 *
48 *
49 *  The BSD License
50 *  ===============
51 *  Redistribution and use in source and binary forms, with or without
52 *  modification, are permitted provided that the following conditions
53 *  are met:
54 *
55 *  1. Redistributions of source code must retain the above copyright
56 *     notice, this list of conditions and the following disclaimer.
57 *  2. Redistributions in binary form must reproduce the above copyright
58 *     notice, this list of conditions and the following disclaimer in
59 *     the documentation and/or other materials provided with the
60 *     distribution.
61 *  3. Neither the name of OpenLink Software Inc. nor the names of its
62 *     contributors may be used to endorse or promote products derived
63 *     from this software without specific prior written permission.
64 *
65 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
66 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
67 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
68 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR
69 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
70 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
71 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
72 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
73 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
74 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76 */
77
78#ifndef	_HERR_H
79#define	_HERR_H
80
81typedef enum
82  {
83    en_00000 = 0,
84    en_01000,
85    en_01002,
86    en_01004,
87    en_01006,
88    en_01S00,
89    en_01S01,
90    en_01S02,
91    en_01S03,
92    en_01S04,
93    en_01S08,
94    en_07001,
95    en_07006,
96    en_08001,
97    en_08002,
98    en_08003,
99    en_08004,
100    en_08007,
101    en_08S01,
102    en_21S01,
103    en_21S02,
104    en_22001,
105    en_22003,
106    en_22005,
107    en_22008,
108    en_22012,
109    en_22026,
110    en_23000,
111    en_24000,
112    en_25000,
113    en_28000,
114    en_34000,
115    en_37000,
116    en_3C000,
117    en_40001,
118    en_42000,
119    en_70100,
120    en_HY001,
121    en_HY009,
122    en_HY010,
123    en_HY017,
124    en_HY024,
125    en_HY091,
126    en_HY092,
127    en_HY110,
128    en_HYC00,
129    en_IM001,
130    en_IM002,
131    en_IM003,
132    en_IM004,
133    en_IM005,
134    en_IM006,
135    en_IM007,
136    en_IM008,
137    en_IM009,
138    en_IM010,
139    en_IM011,
140    en_IM012,
141    en_IM013,
142    en_IM014,
143    en_IM015,
144    en_S0001,
145    en_S0002,
146    en_S0011,
147    en_S0012,
148    en_S0021,
149    en_S0022,
150    en_S0023,
151    en_S1000,
152    en_S1001,
153    en_S1002,
154    en_S1003,
155    en_S1004,
156    en_S1008,
157    en_S1009,
158    en_S1010,
159    en_S1011,
160    en_S1012,
161    en_S1015,
162    en_S1090,
163    en_S1091,
164    en_S1092,
165    en_S1093,
166    en_S1094,
167    en_S1095,
168    en_S1096,
169    en_S1097,
170    en_S1098,
171    en_S1099,
172    en_S1100,
173    en_S1101,
174    en_S1103,
175    en_S1104,
176    en_S1105,
177    en_S1106,
178    en_S1107,
179    en_S1108,
180    en_S1109,
181    en_S1110,
182    en_S1111,
183    en_S1C00,
184    en_S1T00,
185    en_sqlstat_total
186  }
187sqlstcode_t;
188
189typedef void *HERR;
190#define SQL_NULL_HERR	((HERR)NULL)
191
192typedef struct
193  {
194    sqlstcode_t code;
195    char *stat;
196    char *msg;
197  }
198sqlerrmsg_t;
199
200typedef struct sqlerr
201  {
202    sqlstcode_t code;
203    int idx;
204    char *msg;
205    struct sqlerr *next;
206  }
207sqlerr_t;
208
209extern void _iodbcdm_freesqlerrlist (HERR herr);
210extern HERR _iodbcdm_pushsqlerr (HERR list, sqlstcode_t code, void *sysmsg);
211
212#define	PUSHSYSERR(list, msg)	\
213	list = (HERR) _iodbcdm_pushsqlerr ((HERR)(list), en_00000, msg)
214
215#define	PUSHSQLERR(list, code)	\
216	list = (HERR) _iodbcdm_pushsqlerr ((HERR)(list), (code), NULL)
217
218#define CLEAR_ERRORS(_handle) \
219    { \
220	_iodbcdm_freesqlerrlist ((_handle)->herr); \
221	 (_handle)->herr = SQL_NULL_HERR; \
222	 (_handle)->rc = SQL_SUCCESS; \
223         (_handle)->err_rec = 0; \
224    }
225
226#endif /* _SQLERR_H */
227