configure: create some convenience AC_SUBST's for the global includes
[oweals/cde.git] / cde / lib / tt / mini_isam / isamerror.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: isamerror.c /main/3 1995/10/23 11:34:39 rswiston $                                                   */
28 /*
29  * Copyright (c) 1988 by Sun Microsystems, Inc.
30  */
31
32 /*
33  * isamerror.c
34  *
35  * Description: 
36  *      Error handling functions for the Access Method layer.
37  *      
38  *
39  */
40
41 #include "isam_impl.h"
42
43 #define ESENTINEL       -100                 /* Must not be a valid errno */
44
45 static struct errstattab {
46     int         iserrno;
47     char        isstat1;
48     char        isstat2;
49 } errstattab[] = {
50     { ISOK,     '0', '0'},
51     { ENOREC,   '2', '3'},
52     { ENOCURR,  '2', '1'},
53     { EENDFILE, '1', '0'},
54     { EDUPL,    '2', '2'},
55     { ENOTOPEN, '9', '0'},
56     { EBADARG,  '9', '0'},
57     { EBADKEY,  '9', '0'},
58     { ETOOMANY, '9', '0'},
59     { EBADFILE, '9', '0'},
60     { ENOTEXCL, '9', '0'},
61     { ELOCKED,  '9', '0'},
62     { EKEXISTS, '9', '0'},
63     { EPRIMKEY, '9', '0'},
64     { EFLOCKED, '9', '0'},
65     { EFNAME,   '9', '0'},
66     { EFATAL,   '9', '0'},
67
68     /* Unix errors */
69
70     { ENOENT,   '9', '0'},
71     { EACCES,   '9', '0'},
72     { EEXIST,   '9', '0'},
73     { ENOSPC,   '9', '0'},
74
75     /* search sentinel */
76     { ESENTINEL, '9', '0'}
77 };
78
79 /*
80  * _amseterrcode(errcode, is_errno, is_stat1, is_stat2, is_stat3, is_stat4)
81  *
82  * Set errcode block with ISAM error codes.
83  */
84
85 void
86 _amseterrcode(struct errcode *errcode, int is_errno)
87 {
88     struct errstattab   *p;
89     errcode->iserrno = is_errno;
90
91     /*
92      * Search errstattab to get appropriate isstat[12] values.
93      */
94
95     for (p = errstattab; p->iserrno != ESENTINEL; p++) {
96         if (p->iserrno == is_errno) {
97             errcode->isstat[0] = p->isstat1;
98             errcode->isstat[1] = p->isstat2;
99
100             break;
101         }
102     }
103
104     if (is_errno == 0 && isdupl == 1)
105         errcode->isstat[1] = '2';            /* Indicate allowed duplicates */
106 }
107