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 #include "error_p.h" 00034 00035 /* Internationalization */ 00036 #ifdef ENABLE_NLS 00037 # include <libintl.h> 00038 # include <locale.h> 00039 # define I18N(m) dgettext("gwenhywfar", m) 00040 # define I18S(m) m 00041 #else 00042 # define I18N(m) m 00043 # define I18S(m) m 00044 #endif 00045 00046 00047 #include <stdio.h> 00048 #include <assert.h> 00049 #include <string.h> 00050 #ifdef HAVE_STRINGS_H 00051 # include <strings.h> 00052 #endif 00053 00054 #include "gwenhywfar/debug.h" 00055 #include "gwenhywfar/misc.h" 00056 00057 #include "gwenhywfar/inetsocket.h" 00058 #include "gwenhywfar/inetaddr.h" 00059 #include "gwenhywfar/bufferedio.h" 00060 #include "gwenhywfar/libloader.h" 00061 00062 00063 00064 int GWEN_Error_ModuleInit() { 00065 DBG_VERBOUS(GWEN_LOGDOMAIN, "Error_ModuleInit"); 00066 return 0; 00067 } 00068 00069 00070 00071 int GWEN_Error_ModuleFini() { 00072 return 0; 00073 } 00074 00075 00076 00077 int GWEN_Error_ToString(int c, char *buffer, int bsize) { 00078 const char *s; 00079 00080 assert(buffer); 00081 assert(bsize); 00082 s=GWEN_Error_SimpleToString(c); 00083 snprintf(buffer, bsize-1, "Error %d [%s]", c, s?s:"none"); 00084 /* make sure the string is NULL terminated */ 00085 buffer[bsize-1]=0; 00086 00087 /* finished */ 00088 return 1; 00089 } 00090 00091 00092 00093 const char *GWEN_Error_SimpleToString(int i){ 00094 const char *s; 00095 00096 switch(i) { 00097 case GWEN_SUCCESS: 00098 s=I18N("Ok"); break; 00099 case GWEN_ERROR_GENERIC: 00100 s=I18N("Generic error"); break; 00101 case GWEN_ERROR_ABORTED: 00102 s=I18N("Aborted"); break; 00103 case GWEN_ERROR_NOT_AVAILABLE: 00104 s=I18N("Not available"); break; 00105 case GWEN_ERROR_BAD_SOCKETTYPE: 00106 s=I18N("Bad socket type"); break; 00107 case GWEN_ERROR_NOT_OPEN: 00108 s=I18N("Not open"); break; 00109 case GWEN_ERROR_TIMEOUT: 00110 s=I18N("Timeout"); break; 00111 case GWEN_ERROR_IN_PROGRESS: 00112 s=I18N("In Progress"); break; 00113 case GWEN_ERROR_STARTUP: 00114 s=I18N("Startup error"); break; 00115 case GWEN_ERROR_INTERRUPTED: 00116 s=I18N("Interrupted system call"); break; 00117 case GWEN_ERROR_NOT_SUPPORTED: 00118 s=I18N("Not supported"); break; 00119 case GWEN_ERROR_BROKEN_PIPE: 00120 s=I18N("Broken pipe"); break; 00121 case GWEN_ERROR_MEMORY_FULL: 00122 s=I18N("Memory full"); break; 00123 case GWEN_ERROR_BAD_ADDRESS: 00124 s=I18N("Bad address"); break; 00125 case GWEN_ERROR_BUFFER_OVERFLOW: 00126 s=I18N("Buffer overflow"); break; 00127 case GWEN_ERROR_HOST_NOT_FOUND: 00128 s=I18N("Host not found"); break; 00129 case GWEN_ERROR_NO_ADDRESS: 00130 s=I18N("No address"); break; 00131 case GWEN_ERROR_NO_RECOVERY: 00132 s=I18N("No recovery"); break; 00133 case GWEN_ERROR_TRY_AGAIN: 00134 s=I18N("Try again"); break; 00135 case GWEN_ERROR_UNKNOWN_DNS_ERROR: 00136 s=I18N("Unknown DNS error"); break; 00137 case GWEN_ERROR_BAD_ADDRESS_FAMILY: 00138 s=I18N("Bad address family"); break; 00139 case GWEN_ERROR_COULD_NOT_LOAD: 00140 s=I18N("Could not load"); break; 00141 case GWEN_ERROR_COULD_NOT_RESOLVE: 00142 s=I18N("Could not resolve a symbol"); break; 00143 case GWEN_ERROR_NOT_FOUND: 00144 s=I18N("Not found"); break; 00145 case GWEN_ERROR_READ: 00146 s=I18N("Could not read"); break; 00147 case GWEN_ERROR_WRITE: 00148 s=I18N("Could not write"); break; 00149 case GWEN_ERROR_CLOSE: 00150 s=I18N("Could not close"); break; 00151 case GWEN_ERROR_NO_DATA: 00152 s=I18N("No data"); break; 00153 case GWEN_ERROR_PARTIAL: 00154 s=I18N("Partial data"); break; 00155 case GWEN_ERROR_EOF: 00156 s=I18N("EOF met"); break; 00157 case GWEN_ERROR_ALREADY_REGISTERED: 00158 s=I18N("Already registered"); break; 00159 case GWEN_ERROR_NOT_REGISTERED: 00160 s=I18N("Not registered"); break; 00161 case GWEN_ERROR_BAD_SIZE: 00162 s=I18N("Bad size"); break; 00163 case GWEN_ERROR_ENCRYPT: 00164 s=I18N("Could not encrypt"); break; 00165 case GWEN_ERROR_DECRYPT: 00166 s=I18N("Could not decrypt"); break; 00167 case GWEN_ERROR_SIGN: 00168 s=I18N("Could not sign"); break; 00169 case GWEN_ERROR_VERIFY: 00170 s=I18N("Could not verify"); break; 00171 case GWEN_ERROR_SSL: 00172 s=I18N("Generic SSL error"); break; 00173 default: 00174 s="Unknown error"; 00175 } 00176 00177 return s; 00178 } 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190