1 /***************************************************************************
2  $RCSfile$
3                              -------------------
4     cvs         : $Id$
5     begin       : Tue Oct 02 2002
6     copyright   : (C) 2002 by Martin Preuss
7     email       : martin@libchipcard.de
8 
9  ***************************************************************************
10  *                                                                         *
11  *   This library is free software; you can redistribute it and/or         *
12  *   modify it under the terms of the GNU Lesser General Public            *
13  *   License as published by the Free Software Foundation; either          *
14  *   version 2.1 of the License, or (at your option) any later version.    *
15  *                                                                         *
16  *   This library is distributed in the hope that it will be useful,       *
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
19  *   Lesser General Public License for more details.                       *
20  *                                                                         *
21  *   You should have received a copy of the GNU Lesser General Public      *
22  *   License along with this library; if not, write to the Free Software   *
23  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
24  *   MA  02111-1307  USA                                                   *
25  *                                                                         *
26  ***************************************************************************/
27 
28 /**
29  * @file base/error.h
30  * @short This file contains the module for error handling.
31  */
32 
33 #ifndef GWENHYWFAR_ERROR_H
34 #define GWENHYWFAR_ERROR_H
35 
36 #include <gwenhywfar/gwenhywfarapi.h>
37 #include <gwenhywfar/types.h>
38 
39 
40 /**
41  * @defgroup MOD_ERROR Error module
42  * @ingroup MOD_BASE
43  * @short This module does all error handling
44  * @author Martin Preuss<martin@libchipcard.de>
45  *
46  */
47 /*@{*/
48 
49 /*
50  * Allow this to be used from C and C++
51  */
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /** @defgroup MOD_ERROR_SIMPLE Simplified Error Codes
57  *
58  */
59 /*@{*/
60 #define GWEN_SUCCESS 0
61 /* generic errors */
62 #define GWEN_ERROR_GENERIC              (-1)
63 #define GWEN_ERROR_ABORTED              (-2)
64 #define GWEN_ERROR_NOT_AVAILABLE        (-3)
65 #define GWEN_ERROR_USER_ABORTED         (-4)
66 #define GWEN_ERROR_OPEN                 (-5)
67 #define GWEN_ERROR_INVALID              (-6)
68 /* socket errors */
69 #define GWEN_ERROR_BAD_SOCKETTYPE       (-32)
70 #define GWEN_ERROR_NOT_OPEN             (-33)
71 #define GWEN_ERROR_TIMEOUT              (-34)
72 #define GWEN_ERROR_IN_PROGRESS          (-35)
73 #define GWEN_ERROR_STARTUP              (-36)
74 #define GWEN_ERROR_INTERRUPTED          (-37)
75 #define GWEN_ERROR_BROKEN_PIPE          (-39)
76 /* inet address errors */
77 #define GWEN_ERROR_MEMORY_FULL          (-40)
78 #define GWEN_ERROR_BAD_ADDRESS          (-41)
79 #define GWEN_ERROR_BUFFER_OVERFLOW      (-42)
80 #define GWEN_ERROR_HOST_NOT_FOUND       (-43)
81 #define GWEN_ERROR_NO_ADDRESS           (-44)
82 #define GWEN_ERROR_NO_RECOVERY          (-45)
83 #define GWEN_ERROR_TRY_AGAIN            (-46)
84 #define GWEN_ERROR_UNKNOWN_DNS_ERROR    (-47)
85 #define GWEN_ERROR_BAD_ADDRESS_FAMILY   (-48)
86 /* libloader errors */
87 #define GWEN_ERROR_COULD_NOT_LOAD       (-49)
88 #define GWEN_ERROR_COULD_NOT_RESOLVE    (-50)
89 #define GWEN_ERROR_NOT_FOUND            (-51)
90 /* buffered IO errors */
91 #define GWEN_ERROR_READ                 (-52)
92 #define GWEN_ERROR_WRITE                (-53)
93 #define GWEN_ERROR_CLOSE                (-54)
94 #define GWEN_ERROR_NO_DATA              (-55)
95 #define GWEN_ERROR_PARTIAL              (-56)
96 #define GWEN_ERROR_EOF                  (-57)
97 /* crypt errors */
98 #define GWEN_ERROR_ALREADY_REGISTERED   (-58)
99 #define GWEN_ERROR_NOT_REGISTERED       (-59)
100 #define GWEN_ERROR_BAD_SIZE             (-60)
101 #define GWEN_ERROR_ENCRYPT              (-62)
102 #define GWEN_ERROR_DECRYPT              (-63)
103 #define GWEN_ERROR_SIGN                 (-64)
104 #define GWEN_ERROR_VERIFY               (-65)
105 #define GWEN_ERROR_SSL                  (-66)
106 
107 /* crypt token errors */
108 #define GWEN_ERROR_NOT_IMPLEMENTED      (-67)
109 #define GWEN_ERROR_NOT_SUPPORTED        (-68)
110 #define GWEN_ERROR_BAD_NAME             (-69)
111 #define GWEN_ERROR_BAD_PIN              (-70)
112 #define GWEN_ERROR_BAD_PIN_0_LEFT       (-71)
113 #define GWEN_ERROR_BAD_PIN_1_LEFT       (-72)
114 #define GWEN_ERROR_BAD_PIN_2_LEFT       (-73)
115 #define GWEN_ERROR_NO_KEY               (-74)
116 #define GWEN_ERROR_REMOVED              (-75)
117 #define GWEN_ERROR_DEFAULT_VALUE        (-76)
118 
119 /* new error codes in GWEN2 */
120 #define GWEN_ERROR_NOT_CONNECTED        (-100)
121 #define GWEN_ERROR_BAD_DATA             (-101)
122 #define GWEN_ERROR_FOUND                (-102)
123 #define GWEN_ERROR_IO                   (-103)
124 
125 #define GWEN_ERROR_INTERNAL             (-104)
126 #define GWEN_ERROR_PERMISSIONS          (-105)
127 #define GWEN_ERROR_CONN_REFUSED         (-106)
128 #define GWEN_ERROR_NET_UNREACHABLE      (-107)
129 #define GWEN_ERROR_SSL_SECURITY         (-108)
130 
131 #define GWEN_ERROR_LOCK                 (-109)
132 
133 #define GWEN_ERROR_SSL_PREMATURE_CLOSE  (-110)
134 
135 
136 #define GWEN_ERROR_USEROFFSET           (-1000)
137 
138 
139 
140 /*@}*/
141 
142 
143 /**
144  * @name Verbosity
145  *
146  * Composing error messages.
147  */
148 /*@{*/
149 /**
150  * Dumps the string corresponding to the given erro code.
151  * @return 1 detailed error message created, 0 otherwise
152  * @param c error code
153  * @param buffer pointer to a buffer to receive the message
154  * @param bsize size of that buffer in bytes
155  */
156 GWENHYWFAR_API int GWEN_Error_ToString(int c, char *buffer, int bsize);
157 
158 /**
159  * @brief Returns a (very) short string describing the given GWEN error code, or "Unknown error" for unknown codes
160  * @param i The error code
161  * @return A fixed static string that must not be free'd
162  */
163 GWENHYWFAR_API const char *GWEN_Error_SimpleToString(int i);
164 /*@}*/
165 
166 
167 /*@}*/
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 /*@} group mod_error */
174 
175 
176 #endif /* MOD_ERROR_H */
177 
178 
179