1 /*
2  * COPYRIGHT (c) International Business Machines Corp. 2001-2017
3  *
4  * This program is provided under the terms of the Common Public License,
5  * version 1.0 (CPL-1.0). Any use, reproduction or distribution for this
6  * software constitutes recipient's acceptance of CPL-1.0 terms which can be
7  * found in the file LICENSE file or at
8  * https://opensource.org/licenses/cpl1.0.php
9  */
10 
11 #ifndef _SLOTD_ERR_H
12 #define _SLOTD_ERR_H
13 
14 #ifdef DEV
15 
16 #ifndef ASSERT
17 #define ASSERT(_expr) _ASSERT((_expr),(__FILE__),(__LINE__))
18 #define _ASSERT(_expr, _fname, _line) \
19     if (!(_expr)) { \
20         ErrLog("****** ****** ***** ***** ***** ***** ***** " \
21                "***** ***** ****** ******"); \
22         ErrLog("****** ASSERTION FAILED '%s'; %s, line %d", \
23                (#_expr), (_fname), (_line)); \
24         ErrLog("****** ****** ***** ***** ***** ***** ***** " \
25                "***** ***** ****** ******"); \
26         ErrLog("Exiting."); \
27         abort(); \
28     }
29 #endif                          /* ASSERT */
30 
31 #ifndef ASSERT_FUNC
32 #define ASSERT_FUNC(_expr, _func) \
33     _ASSERT_FUNC((_expr), (_func), (__FILE__), (__LINE__))
34 #define _ASSERT_FUNC(_expr, _func, _fname, _line) \
35           if (!(_expr)) { \
36               ErrLog("****** ****** ***** ***** ***** ***** ***** " \
37                      "***** ***** ****** ******"); \
38               ErrLog("****** ASSERTION FAILED '%s'; %s, line %d", \
39                      (#_expr), (_fname), (_line)); \
40               ErrLog("Additional information from '%s':\n", (#_func)); \
41               { _func; } \
42               ErrLog("End of additional information from '%s'\n", (#_func) ); \
43               ErrLog("****** ****** ***** ***** ***** ***** ***** " \
44                      "***** ***** ****** ******"); \
45               ErrLog("Exiting."); \
46               abort(); \
47            }
48 #endif                          /* ASSERT_FUNC */
49 
50 #else
51 
52 #ifndef ASSERT
53 #define ASSERT(_expr)
54 #endif                          /* ASSERT */
55 
56 #ifndef ASSERT_FUNC
57 #define ASSERT_FUNC(_expr, _func_to_call)
58 #endif                          /* ASSERT_FUNC */
59 
60 #endif                          /* DEV */
61 
62 
63 #define SEV_EXPECTED          0x01
64 #define SEV_ALLOWED           0x02
65 #define SEV_ERROR             0x03
66 #define SEV_FATAL             0x04
67 
68 
69 
70 typedef struct _ConstInfo {
71     unsigned const int Code;
72     const char *Name;
73     /* UCHAR      Descrip[256]; */
74 } ConstInfo, *pConstInfo;
75 
76 #define CONSTINFO(_X) { (_X), (#_X) }
77 
78 
79 
80 const unsigned char *ConstName(pConstInfo pInfoArray,
81                                unsigned int InfoArraySize,
82                                unsigned int ConstValue);
83 
84 #ifdef _DAE_H
85 const unsigned char *DAEConst(unsigned int Val);
86 #endif                          /* _DAE_H */
87 
88 #ifndef _H_ERRNO
89 #define _H_ERRNO
90 #endif
91 
92 #ifdef _H_ERRNO
93 extern const unsigned char *SysConst(unsigned int Val);
94 #define SysError( _x ) SysConst((_x))
95 #endif                          /* _H_ERRNO */
96 
97 extern const unsigned char *SignalConst(unsigned int Val);
98 
99 #ifdef _H_ODMI
100 const unsigned char *ODMConst(unsigned int Val);
101 #endif                          /* _H_ODMI */
102 
103 #ifdef _PKCS11TYPES_H_
104 const unsigned char *PkcsReturn(unsigned int Val);
105 const unsigned char *PkcsFlags(unsigned int Val);
106 const unsigned char *PkcsMechanism(unsigned int Val);
107 const unsigned char *PkcsObject(unsigned int Val);
108 const unsigned char *PkcsKey(unsigned int Val);
109 const unsigned char *PkcsAttribute(unsigned int Val);
110 #endif                          /* _PKCS11TYPES_H_ */
111 
112 const unsigned char *ResponseSeverity(unsigned int Val);
113 
114 
115 #endif                          /* _SLOTD_ERR_H */
116