gwenhywfar  4.99.8beta
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  DBG_VERBOUS(GWEN_LOGDOMAIN, "Error_ModuleInit");
65  return 0;
66 }
67 
68 
69 
71  return 0;
72 }
73 
74 
75 
76 int GWEN_Error_ToString(int c, char *buffer, int bsize) {
77  const char *s;
78 
79  assert(buffer);
80  assert(bsize);
82  snprintf(buffer, bsize-1, "Error %d [%s]", c, s?s:"none");
83  /* make sure the string is NULL terminated */
84  buffer[bsize-1]=0;
85 
86  /* finished */
87  return 1;
88 }
89 
90 
91 
92 const char *GWEN_Error_SimpleToString(int i) {
93  const char *s;
94 
95  switch(i) {
96  case GWEN_SUCCESS:
97  s=I18N("Ok");
98  break;
99  case GWEN_ERROR_GENERIC:
100  s=I18N("Generic error");
101  break;
102  case GWEN_ERROR_ABORTED:
103  s=I18N("Aborted");
104  break;
106  s=I18N("Not available");
107  break;
109  s=I18N("Bad socket type");
110  break;
111  case GWEN_ERROR_NOT_OPEN:
112  s=I18N("Not open");
113  break;
114  case GWEN_ERROR_TIMEOUT:
115  s=I18N("Timeout");
116  break;
118  s=I18N("In Progress");
119  break;
120  case GWEN_ERROR_STARTUP:
121  s=I18N("Startup error");
122  break;
124  s=I18N("Interrupted system call");
125  break;
127  s=I18N("Not supported");
128  break;
130  s=I18N("Broken pipe");
131  break;
133  s=I18N("Memory full");
134  break;
136  s=I18N("Bad address");
137  break;
139  s=I18N("Buffer overflow");
140  break;
142  s=I18N("Host not found");
143  break;
145  s=I18N("No address");
146  break;
148  s=I18N("No recovery");
149  break;
151  s=I18N("Try again");
152  break;
154  s=I18N("Unknown DNS error");
155  break;
157  s=I18N("Bad address family");
158  break;
160  s=I18N("Could not load");
161  break;
163  s=I18N("Could not resolve a symbol");
164  break;
166  s=I18N("Not found");
167  break;
168  case GWEN_ERROR_READ:
169  s=I18N("Could not read");
170  break;
171  case GWEN_ERROR_WRITE:
172  s=I18N("Could not write");
173  break;
174  case GWEN_ERROR_CLOSE:
175  s=I18N("Could not close");
176  break;
177  case GWEN_ERROR_NO_DATA:
178  s=I18N("No data");
179  break;
180  case GWEN_ERROR_PARTIAL:
181  s=I18N("Partial data");
182  break;
183  case GWEN_ERROR_EOF:
184  s=I18N("EOF met");
185  break;
187  s=I18N("Already registered");
188  break;
190  s=I18N("Not registered");
191  break;
192  case GWEN_ERROR_BAD_SIZE:
193  s=I18N("Bad size");
194  break;
195  case GWEN_ERROR_ENCRYPT:
196  s=I18N("Could not encrypt");
197  break;
198  case GWEN_ERROR_DECRYPT:
199  s=I18N("Could not decrypt");
200  break;
201  case GWEN_ERROR_SIGN:
202  s=I18N("Could not sign");
203  break;
204  case GWEN_ERROR_VERIFY:
205  s=I18N("Could not verify");
206  break;
207  case GWEN_ERROR_SSL:
208  s=I18N("Generic SSL error");
209  break;
210  default:
211  s="Unknown error";
212  }
213 
214  return s;
215 }
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
#define GWEN_ERROR_SIGN
Definition: error.h:103
int GWEN_Error_ToString(int c, char *buffer, int bsize)
Definition: error.c:76
#define I18N(m)
Definition: error.c:42
#define GWEN_ERROR_BAD_ADDRESS_FAMILY
Definition: error.h:85
#define GWEN_ERROR_HOST_NOT_FOUND
Definition: error.h:80
#define GWEN_ERROR_BAD_ADDRESS
Definition: error.h:78
#define GWEN_ERROR_UNKNOWN_DNS_ERROR
Definition: error.h:84
#define GWEN_SUCCESS
Definition: error.h:60
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:200
#define GWEN_ERROR_NOT_REGISTERED
Definition: error.h:99
#define GWEN_LOGDOMAIN
Definition: logger.h:35
#define GWEN_ERROR_BROKEN_PIPE
Definition: error.h:75
#define GWEN_ERROR_BUFFER_OVERFLOW
Definition: error.h:79
#define GWEN_ERROR_PARTIAL
Definition: error.h:95
#define GWEN_ERROR_INTERRUPTED
Definition: error.h:74
#define GWEN_ERROR_DECRYPT
Definition: error.h:102
#define GWEN_ERROR_SSL
Definition: error.h:105
#define GWEN_ERROR_IN_PROGRESS
Definition: error.h:72
#define GWEN_ERROR_STARTUP
Definition: error.h:73
#define GWEN_ERROR_ABORTED
Definition: error.h:63
int GWEN_Error_ModuleInit(void)
Definition: error.c:63
#define GWEN_ERROR_TRY_AGAIN
Definition: error.h:83
#define GWEN_ERROR_GENERIC
Definition: error.h:62
int GWEN_Error_ModuleFini(void)
Definition: error.c:70
#define GWEN_ERROR_COULD_NOT_RESOLVE
Definition: error.h:88
#define GWEN_ERROR_BAD_SOCKETTYPE
Definition: error.h:69
#define GWEN_ERROR_NO_ADDRESS
Definition: error.h:81
#define GWEN_ERROR_NOT_OPEN
Definition: error.h:70
#define GWEN_ERROR_EOF
Definition: error.h:96
#define GWEN_ERROR_NOT_SUPPORTED
Definition: error.h:109
#define GWEN_ERROR_NOT_FOUND
Definition: error.h:89
#define GWEN_ERROR_WRITE
Definition: error.h:92
#define GWEN_ERROR_VERIFY
Definition: error.h:104
#define GWEN_ERROR_TIMEOUT
Definition: error.h:71
#define GWEN_ERROR_CLOSE
Definition: error.h:93
#define GWEN_ERROR_READ
Definition: error.h:91
#define GWEN_ERROR_NO_RECOVERY
Definition: error.h:82
#define GWEN_ERROR_NO_DATA
Definition: error.h:94
#define GWEN_ERROR_NOT_AVAILABLE
Definition: error.h:64
#define GWEN_ERROR_ENCRYPT
Definition: error.h:101
#define GWEN_ERROR_BAD_SIZE
Definition: error.h:100
#define GWEN_ERROR_COULD_NOT_LOAD
Definition: error.h:87
#define GWEN_ERROR_ALREADY_REGISTERED
Definition: error.h:98
#define GWEN_ERROR_MEMORY_FULL
Definition: error.h:77
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:92