gwenhywfar  4.3.3
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"); break;
98  case GWEN_ERROR_GENERIC:
99  s=I18N("Generic error"); break;
100  case GWEN_ERROR_ABORTED:
101  s=I18N("Aborted"); break;
103  s=I18N("Not available"); break;
105  s=I18N("Bad socket type"); break;
106  case GWEN_ERROR_NOT_OPEN:
107  s=I18N("Not open"); break;
108  case GWEN_ERROR_TIMEOUT:
109  s=I18N("Timeout"); break;
111  s=I18N("In Progress"); break;
112  case GWEN_ERROR_STARTUP:
113  s=I18N("Startup error"); break;
115  s=I18N("Interrupted system call"); break;
117  s=I18N("Not supported"); break;
119  s=I18N("Broken pipe"); break;
121  s=I18N("Memory full"); break;
123  s=I18N("Bad address"); break;
125  s=I18N("Buffer overflow"); break;
127  s=I18N("Host not found"); break;
129  s=I18N("No address"); break;
131  s=I18N("No recovery"); break;
133  s=I18N("Try again"); break;
135  s=I18N("Unknown DNS error"); break;
137  s=I18N("Bad address family"); break;
139  s=I18N("Could not load"); break;
141  s=I18N("Could not resolve a symbol"); break;
143  s=I18N("Not found"); break;
144  case GWEN_ERROR_READ:
145  s=I18N("Could not read"); break;
146  case GWEN_ERROR_WRITE:
147  s=I18N("Could not write"); break;
148  case GWEN_ERROR_CLOSE:
149  s=I18N("Could not close"); break;
150  case GWEN_ERROR_NO_DATA:
151  s=I18N("No data"); break;
152  case GWEN_ERROR_PARTIAL:
153  s=I18N("Partial data"); break;
154  case GWEN_ERROR_EOF:
155  s=I18N("EOF met"); break;
157  s=I18N("Already registered"); break;
159  s=I18N("Not registered"); break;
160  case GWEN_ERROR_BAD_SIZE:
161  s=I18N("Bad size"); break;
162  case GWEN_ERROR_ENCRYPT:
163  s=I18N("Could not encrypt"); break;
164  case GWEN_ERROR_DECRYPT:
165  s=I18N("Could not decrypt"); break;
166  case GWEN_ERROR_SIGN:
167  s=I18N("Could not sign"); break;
168  case GWEN_ERROR_VERIFY:
169  s=I18N("Could not verify"); break;
170  case GWEN_ERROR_SSL:
171  s=I18N("Generic SSL error"); break;
172  default:
173  s="Unknown error";
174  }
175 
176  return s;
177 }
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189