00001 /* lib/error.h - Error functions 00002 Copyright (C) 1999, 2000 Thomas Uehlinger 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2, or (at your option) 00007 any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 00017 00025 #include <gobjconfig.h> 00026 00027 #ifndef gobj_lib_error_h 00028 #define gobj_lib_error_h 00029 00030 #include <gobj/decls.h> 00031 #include <gobj/types.h> 00032 #include <gobj/context.h> 00033 #include <gobj/id.h> 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif /* __cplusplus */ 00038 #if 0 00039 } 00040 #endif 00041 00042 00049 typedef char* Gj_ErrorConvertFunc(void*); 00050 00051 00056 #define GJ_ERRORARGTYPE_NAMELEN 20 00057 00058 00063 typedef enum Gj_Errordatatype_enum { 00064 00065 GJ_ERRDATATYPE_STRING, 00066 GJ_ERRDATATYPE_POINTER, 00067 GJ_ERRDATATYPE_INT, 00068 GJ_ERRDATATYPE_DOUBLE, 00069 GJ_ERRDATATYPE_DATA 00070 00071 } Gj_Errordatatype; 00072 00073 00078 typedef struct Gj_Errorargtype_struct { 00079 00081 char name[GJ_ERRORARGTYPE_NAMELEN]; 00082 00084 Gj_Errordatatype type; 00085 00092 int len; 00093 00101 Gj_ErrorConvertFunc* func; 00102 00103 } Gj_Errorargtype; 00104 00105 00110 #define GJ_ERRORSPEC_ARGLEN 100 00111 00112 00117 #define GJ_ERRORSPEC_MSGLEN 300 00118 00119 00124 typedef struct Gj_Errorspec_struct { 00125 00127 Gj_Id* id; 00128 00130 char args[GJ_ERRORSPEC_ARGLEN]; 00131 00133 char msg[GJ_ERRORSPEC_MSGLEN]; 00134 00135 } Gj_Errorspec; 00136 00137 00142 struct Gj_Error_struct { 00143 00145 Gj_Error* next; 00146 00148 Gj_Id id; 00149 00151 unsigned time; 00152 00154 char* sourcefile; 00155 00157 int sourceline; 00158 00159 }; 00160 00161 00172 Gj_Error* Gj_error_new(Gj_Id* id, char* module, int line, ...); 00173 00174 00181 void Gj_error_delete(Gj_Error* error); 00182 00183 00191 char* Gj_error_getSourcefile(Gj_Error* error); 00192 00193 00201 int Gj_error_getSourceline(Gj_Error* error); 00202 00203 00211 char* Gj_error_getMsg(Gj_Error* error); 00212 00213 00214 #ifdef GJ_STDIO 00215 #include <stdio.h> 00223 void Gj_error_dump(Gj_Error* error, FILE* stream); 00224 #endif 00225 00226 00227 #ifdef __cplusplus 00228 } 00229 #endif /* __cplusplus */ 00230 00231 #endif /* !gobj_lib_error_h */ 00232 00233