gwenhywfar 5.10.1
error.c
Go to the documentation of this file.
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#ifdef HAVE_CONFIG_H
30# include <config.h>
31#endif
32
33#include "error_p.h"
34
35/* Internationalization */
36#ifdef ENABLE_NLS
37# include <libintl.h>
38# include <locale.h>
39# define I18N(m) dgettext("gwenhywfar", m)
40# define I18S(m) m
41#else
42# define I18N(m) m
43# define I18S(m) m
44#endif
45
46
47#include <stdio.h>
48#include <assert.h>
49#include <string.h>
50#ifdef HAVE_STRINGS_H
51# include <strings.h>
52#endif
53
54#include "gwenhywfar/debug.h"
55#include "gwenhywfar/misc.h"
56
57#include "gwenhywfar/inetsocket.h"
58#include "gwenhywfar/inetaddr.h"
59#include "gwenhywfar/libloader.h"
60
61
62
64{
65 DBG_VERBOUS(GWEN_LOGDOMAIN, "Error_ModuleInit");
66 return 0;
67}
68
69
70
72{
73 return 0;
74}
75
76
77
78int GWEN_Error_ToString(int c, char *buffer, int bsize)
79{
80 const char *s;
81
82 assert(buffer);
83 assert(bsize);
85 snprintf(buffer, bsize-1, "Error %d [%s]", c, s?s:"none");
86 /* make sure the string is NULL terminated */
87 buffer[bsize-1]=0;
88
89 /* finished */
90 return 1;
91}
92
93
94
95const char *GWEN_Error_SimpleToString(int i)
96{
97 const char *s;
98
99 switch (i) {
100 case GWEN_SUCCESS:
101 s=I18N("Ok");
102 break;
104 s=I18N("Generic error");
105 break;
107 s=I18N("Aborted");
108 break;
110 s=I18N("Not available");
111 break;
113 s=I18N("Bad socket type");
114 break;
116 s=I18N("Not open");
117 break;
119 s=I18N("Timeout");
120 break;
122 s=I18N("In Progress");
123 break;
125 s=I18N("Startup error");
126 break;
128 s=I18N("Interrupted system call");
129 break;
131 s=I18N("Not supported");
132 break;
134 s=I18N("Broken pipe");
135 break;
137 s=I18N("Memory full");
138 break;
140 s=I18N("Bad address");
141 break;
143 s=I18N("Buffer overflow");
144 break;
146 s=I18N("Host not found");
147 break;
149 s=I18N("No address");
150 break;
152 s=I18N("No recovery");
153 break;
155 s=I18N("Try again");
156 break;
158 s=I18N("Unknown DNS error");
159 break;
161 s=I18N("Bad address family");
162 break;
164 s=I18N("Could not load");
165 break;
167 s=I18N("Could not resolve a symbol");
168 break;
170 s=I18N("Not found");
171 break;
172 case GWEN_ERROR_READ:
173 s=I18N("Could not read");
174 break;
175 case GWEN_ERROR_WRITE:
176 s=I18N("Could not write");
177 break;
178 case GWEN_ERROR_CLOSE:
179 s=I18N("Could not close");
180 break;
182 s=I18N("No data");
183 break;
185 s=I18N("Partial data");
186 break;
187 case GWEN_ERROR_EOF:
188 s=I18N("EOF met");
189 break;
191 s=I18N("Already registered");
192 break;
194 s=I18N("Not registered");
195 break;
197 s=I18N("Bad size");
198 break;
200 s=I18N("Could not encrypt");
201 break;
203 s=I18N("Could not decrypt");
204 break;
205 case GWEN_ERROR_SIGN:
206 s=I18N("Could not sign");
207 break;
209 s=I18N("Could not verify");
210 break;
211 case GWEN_ERROR_SSL:
212 s=I18N("Generic SSL error");
213 break;
214 default:
215 s="Unknown error";
216 }
217
218 return s;
219}
220
221
222
223
224
225
226
227
228
229
230
231
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:224
int GWEN_Error_ToString(int c, char *buffer, int bsize)
Definition: error.c:78
int GWEN_Error_ModuleInit(void)
Definition: error.c:63
#define I18N(m)
Definition: error.c:42
const char * GWEN_Error_SimpleToString(int i)
Returns a (very) short string describing the given GWEN error code, or "Unknown error" for unknown co...
Definition: error.c:95
int GWEN_Error_ModuleFini(void)
Definition: error.c:71
#define GWEN_ERROR_SSL
Definition: error.h:105
#define GWEN_ERROR_BAD_SOCKETTYPE
Definition: error.h:69
#define GWEN_ERROR_CLOSE
Definition: error.h:93
#define GWEN_ERROR_BAD_ADDRESS_FAMILY
Definition: error.h:85
#define GWEN_ERROR_ENCRYPT
Definition: error.h:101
#define GWEN_ERROR_NOT_OPEN
Definition: error.h:70
#define GWEN_ERROR_TRY_AGAIN
Definition: error.h:83
#define GWEN_ERROR_SIGN
Definition: error.h:103
#define GWEN_ERROR_STARTUP
Definition: error.h:73
#define GWEN_ERROR_BAD_ADDRESS
Definition: error.h:78
#define GWEN_ERROR_MEMORY_FULL
Definition: error.h:77
#define GWEN_ERROR_VERIFY
Definition: error.h:104
#define GWEN_ERROR_TIMEOUT
Definition: error.h:71
#define GWEN_ERROR_COULD_NOT_RESOLVE
Definition: error.h:88
#define GWEN_ERROR_HOST_NOT_FOUND
Definition: error.h:80
#define GWEN_ERROR_NO_ADDRESS
Definition: error.h:81
#define GWEN_ERROR_DECRYPT
Definition: error.h:102
#define GWEN_ERROR_BROKEN_PIPE
Definition: error.h:75
#define GWEN_ERROR_BUFFER_OVERFLOW
Definition: error.h:79
#define GWEN_ERROR_READ
Definition: error.h:91
#define GWEN_ERROR_GENERIC
Definition: error.h:62
#define GWEN_ERROR_UNKNOWN_DNS_ERROR
Definition: error.h:84
#define GWEN_SUCCESS
Definition: error.h:60
#define GWEN_ERROR_BAD_SIZE
Definition: error.h:100
#define GWEN_ERROR_NOT_FOUND
Definition: error.h:89
#define GWEN_ERROR_PARTIAL
Definition: error.h:95
#define GWEN_ERROR_NO_RECOVERY
Definition: error.h:82
#define GWEN_ERROR_IN_PROGRESS
Definition: error.h:72
#define GWEN_ERROR_WRITE
Definition: error.h:92
#define GWEN_ERROR_COULD_NOT_LOAD
Definition: error.h:87
#define GWEN_ERROR_INTERRUPTED
Definition: error.h:74
#define GWEN_ERROR_NOT_SUPPORTED
Definition: error.h:109
#define GWEN_ERROR_ABORTED
Definition: error.h:63
#define GWEN_ERROR_NOT_REGISTERED
Definition: error.h:99
#define GWEN_ERROR_NO_DATA
Definition: error.h:94
#define GWEN_ERROR_NOT_AVAILABLE
Definition: error.h:64
#define GWEN_ERROR_ALREADY_REGISTERED
Definition: error.h:98
#define GWEN_ERROR_EOF
Definition: error.h:96
#define GWEN_LOGDOMAIN
Definition: logger.h:35