00001 /*************************************************************************** 00002 $RCSfile$ 00003 ------------------- 00004 cvs : $Id$ 00005 begin : Tue Oct 02 2002 00006 copyright : (C) 2002 by Martin Preuss 00007 email : martin@libchipcard.de 00008 00009 *************************************************************************** 00010 * * 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU Lesser General Public * 00013 * License as published by the Free Software Foundation; either * 00014 * version 2.1 of the License, or (at your option) any later version. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00019 * Lesser General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU Lesser General Public * 00022 * License along with this library; if not, write to the Free Software * 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00024 * MA 02111-1307 USA * 00025 * * 00026 ***************************************************************************/ 00027 00028 00029 #ifdef HAVE_CONFIG_H 00030 # include <config.h> 00031 #endif 00032 00033 /* Internationalization */ 00034 #ifdef ENABLE_NLS 00035 # include <libintl.h> 00036 # include <locale.h> 00037 # define I18N(m) dgettext("gwenhywfar", m) 00038 # define I18S(m) m 00039 #else 00040 # define I18N(m) m 00041 # define I18S(m) m 00042 #endif 00043 00044 00045 #include <stdio.h> 00046 #include <assert.h> 00047 #include <string.h> 00048 #ifdef HAVE_STRINGS_H 00049 # include <strings.h> 00050 #endif 00051 #include "error_p.h" 00052 #include "gwenhywfar/debug.h" 00053 #include "gwenhywfar/misc.h" 00054 00055 #include "gwenhywfar/inetsocket.h" 00056 #include "gwenhywfar/inetaddr.h" 00057 #include "gwenhywfar/bufferedio.h" 00058 #include "gwenhywfar/libloader.h" 00059 00060 00061 00062 int GWEN_Error_ModuleInit() { 00063 DBG_VERBOUS(GWEN_LOGDOMAIN, "Error_ModuleInit"); 00064 return 0; 00065 } 00066 00067 00068 00069 int GWEN_Error_ModuleFini() { 00070 return 0; 00071 } 00072 00073 00074 00075 int GWEN_Error_ToString(int c, char *buffer, int bsize) { 00076 const char *s; 00077 00078 assert(buffer); 00079 assert(bsize); 00080 s=GWEN_Error_SimpleToString(c); 00081 snprintf(buffer, bsize-1, "Error %d [%s]", c, s?s:"none"); 00082 /* make sure the string is NULL terminated */ 00083 buffer[bsize-1]=0; 00084 00085 /* finished */ 00086 return 1; 00087 } 00088 00089 00090 00091 const char *GWEN_Error_SimpleToString(int i){ 00092 const char *s; 00093 00094 switch(i) { 00095 case GWEN_SUCCESS: 00096 s=I18N("Ok"); break; 00097 case GWEN_ERROR_GENERIC: 00098 s=I18N("Generic error"); break; 00099 case GWEN_ERROR_ABORTED: 00100 s=I18N("Aborted"); break; 00101 case GWEN_ERROR_NOT_AVAILABLE: 00102 s=I18N("Not available"); break; 00103 case GWEN_ERROR_BAD_SOCKETTYPE: 00104 s=I18N("Bad socket type"); break; 00105 case GWEN_ERROR_NOT_OPEN: 00106 s=I18N("Not open"); break; 00107 case GWEN_ERROR_TIMEOUT: 00108 s=I18N("Timeout"); break; 00109 case GWEN_ERROR_IN_PROGRESS: 00110 s=I18N("In Progress"); break; 00111 case GWEN_ERROR_STARTUP: 00112 s=I18N("Startup error"); break; 00113 case GWEN_ERROR_INTERRUPTED: 00114 s=I18N("Interrupted system call"); break; 00115 case GWEN_ERROR_NOT_SUPPORTED: 00116 s=I18N("Not supported"); break; 00117 case GWEN_ERROR_BROKEN_PIPE: 00118 s=I18N("Broken pipe"); break; 00119 case GWEN_ERROR_MEMORY_FULL: 00120 s=I18N("Memory full"); break; 00121 case GWEN_ERROR_BAD_ADDRESS: 00122 s=I18N("Bad address"); break; 00123 case GWEN_ERROR_BUFFER_OVERFLOW: 00124 s=I18N("Buffer overflow"); break; 00125 case GWEN_ERROR_HOST_NOT_FOUND: 00126 s=I18N("Host not found"); break; 00127 case GWEN_ERROR_NO_ADDRESS: 00128 s=I18N("No address"); break; 00129 case GWEN_ERROR_NO_RECOVERY: 00130 s=I18N("No recovery"); break; 00131 case GWEN_ERROR_TRY_AGAIN: 00132 s=I18N("Try again"); break; 00133 case GWEN_ERROR_UNKNOWN_DNS_ERROR: 00134 s=I18N("Unknown DNS error"); break; 00135 case GWEN_ERROR_BAD_ADDRESS_FAMILY: 00136 s=I18N("Bad address family"); break; 00137 case GWEN_ERROR_COULD_NOT_LOAD: 00138 s=I18N("Could not load"); break; 00139 case GWEN_ERROR_COULD_NOT_RESOLVE: 00140 s=I18N("Could not resolve a symbol"); break; 00141 case GWEN_ERROR_NOT_FOUND: 00142 s=I18N("Not found"); break; 00143 case GWEN_ERROR_READ: 00144 s=I18N("Could not read"); break; 00145 case GWEN_ERROR_WRITE: 00146 s=I18N("Could not write"); break; 00147 case GWEN_ERROR_CLOSE: 00148 s=I18N("Could not close"); break; 00149 case GWEN_ERROR_NO_DATA: 00150 s=I18N("No data"); break; 00151 case GWEN_ERROR_PARTIAL: 00152 s=I18N("Partial data"); break; 00153 case GWEN_ERROR_EOF: 00154 s=I18N("EOF met"); break; 00155 case GWEN_ERROR_ALREADY_REGISTERED: 00156 s=I18N("Already registered"); break; 00157 case GWEN_ERROR_NOT_REGISTERED: 00158 s=I18N("Not registered"); break; 00159 case GWEN_ERROR_BAD_SIZE: 00160 s=I18N("Bad size"); break; 00161 case GWEN_ERROR_ENCRYPT: 00162 s=I18N("Could not encrypt"); break; 00163 case GWEN_ERROR_DECRYPT: 00164 s=I18N("Could not decrypt"); break; 00165 case GWEN_ERROR_SIGN: 00166 s=I18N("Could not sign"); break; 00167 case GWEN_ERROR_VERIFY: 00168 s=I18N("Could not verify"); break; 00169 case GWEN_ERROR_SSL: 00170 s=I18N("Generic SSL error"); break; 00171 default: 00172 s="Unknown error"; 00173 } 00174 00175 return s; 00176 } 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188