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