00001 /*************************************************************************** 00002 $RCSfile: error.h,v $ 00003 ------------------- 00004 cvs : $Id: error.h,v 1.3 2003/01/11 12:58:44 aquamaniac Exp $ 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 00033 #ifndef MOD_ERROR_H 00034 #define MOD_ERROR_H 00035 00051 // @{ 00052 00053 /* 00054 * Allow this to be used from C and C++ 00055 */ 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00066 CHIPCARD_API typedef const char* (*ERRORMESSAGEPTR)(int c); 00067 00068 00073 CHIPCARD_API typedef struct { 00078 ERRORMESSAGEPTR msgptr; 00086 int typ; 00087 00095 char type_name[16]; 00096 00097 } ERRORTYPEREGISTRATIONFORM; 00098 00099 00103 #define ERROR_SEVERITY_DEBUG 0 00104 00107 #define ERROR_SEVERITY_INFO 1 00108 00111 #define ERROR_SEVERITY_WARN 2 00112 00115 #define ERROR_SEVERITY_ERR 3 00116 00120 #define ERROR_TYPE_ERROR 0 00121 00122 #define ERROR_UNSPECIFIED 1 00123 #define ERROR_COULD_NOT_REGISTER 2 00124 #define ERROR_COULD_NOT_UNREGISTER 3 00125 #define ERROR_INVALID_BUFFERSIZE 4 00126 00127 00140 CHIPCARD_API typedef unsigned long ERRORCODE; 00141 00142 00150 CHIPCARD_API void Error_ModuleInit(); 00151 00155 CHIPCARD_API void Error_ModuleFini(); 00156 00158 00159 00168 00174 CHIPCARD_API int Error_RegisterType(ERRORTYPEREGISTRATIONFORM *tptr); 00175 00181 CHIPCARD_API int Error_UnregisterType(ERRORTYPEREGISTRATIONFORM *tptr); 00183 00189 00194 CHIPCARD_API int Error_FindType(const char *name); 00195 00202 CHIPCARD_API const char *Error_GetTypename(int t); 00204 00205 00225 CHIPCARD_API ERRORCODE Error_New(int iscustom, int severity, int typ, int code); 00226 00232 CHIPCARD_API int Error_IsOk(ERRORCODE c); 00233 00237 CHIPCARD_API int Error_GetSeverity(ERRORCODE c); 00238 00242 CHIPCARD_API void Error_SetSeverity(ERRORCODE *c, int v); 00243 00250 CHIPCARD_API int Error_IsCustom(ERRORCODE c); 00251 00255 CHIPCARD_API void Error_SetIsCustom(ERRORCODE *c, int iscustom); 00256 00260 CHIPCARD_API int Error_GetType(ERRORCODE c); 00261 00265 CHIPCARD_API void Error_SetType(ERRORCODE *c, int v); 00266 00270 CHIPCARD_API int Error_GetCode(ERRORCODE c); 00271 00275 CHIPCARD_API void Error_SetCode(ERRORCODE *c, int v); 00277 00278 00292 CHIPCARD_API int Error_ToString(ERRORCODE c, char *buffer, int bsize); 00294 00295 #ifdef __cplusplus 00296 } 00297 #endif 00298 00300 00301 00302 #endif // MOD_ERROR_H 00303 00304