1 // This may look like C code, but it is really -*- C++ -*- 2 3 // ------------------------------------------------------------------ 4 // The Goldware Library 5 // Copyright (C) 1990-1999 Odinn Sorensen 6 // ------------------------------------------------------------------ 7 // This library is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU Library General Public 9 // License as published by the Free Software Foundation; either 10 // version 2 of the License, or (at your option) any later version. 11 // 12 // This library is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 // Library General Public License for more details. 16 // 17 // You should have received a copy of the GNU Library General Public 18 // License along with this program; if not, write to the Free 19 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 // MA 02111-1307, USA 21 // ------------------------------------------------------------------ 22 // $Id: gdbgerr.h,v 1.4 2011/02/22 00:08:17 stas_degteff Exp $ 23 // ------------------------------------------------------------------ 24 // Debugging and logging. 25 // ------------------------------------------------------------------ 26 27 28 // ------------------------------------------------------------------ 29 // Only include once! 30 31 #ifndef __GDBGERR_H 32 #define __GDBGERR_H 33 34 35 // ------------------------------------------------------------------ 36 #include <gdefs.h> 37 38 39 // ------------------------------------------------------------------ 40 // Error codes 41 42 #define GOLD_NO_ERROR 0 43 44 45 // ------------------------------------------------------------------ 46 // Debug aid macros 47 48 #define GDEBUGINFO __FILE__, __LINE__ 49 #define GDEBUGDATA GDEBUGFILE, GDEBUGLINE 50 #define GDEBUGPROTO char* GDEBUGFILE, int GDEBUGLINE 51 52 53 // ------------------------------------------------------------------ 54 // Automatic inline debugging info for use with _halt_() 55 56 #define E_INFO __FILE__,__LINE__ 57 #define E_PROTO int _error_, char* _file_, int _line_ 58 #define E_DATA _error_, _file_, _line_ 59 60 61 // ------------------------------------------------------------------ 62 // Error types for use with _halt_() 63 64 const int ERR_OK = 0; 65 const int ERR_OPEN = 1; 66 const int ERR_READ = 2; 67 const int ERR_SEEK = 3; 68 const int ERR_MEMO = 4; 69 const int ERR_INDX = 5; 70 const int ERR_WRITE = 6; 71 const int ERR_TELL = 7; 72 const int ERR_CLOSE = 8; 73 const int ERR_CONF = 9; 74 const int ERR_BREAK = 10; 75 const int ERR_NOKEY = 11; 76 const int ERR_TEST = 12; 77 const int ERR_ENVR = 13; 78 const int ERR_LOCK = 14; 79 const int ERR_MPTR = 15; 80 81 #define E_OK ERR_OK , E_INFO 82 #define E_OPEN ERR_OPEN , E_INFO 83 #define E_READ ERR_READ , E_INFO 84 #define E_SEEK ERR_SEEK , E_INFO 85 #define E_MEMO ERR_MEMO , E_INFO 86 #define E_INDX ERR_INDX , E_INFO 87 #define E_WRITE ERR_WRITE, E_INFO 88 #define E_TELL ERR_TELL , E_INFO 89 #define E_CLOSE ERR_CLOSE, E_INFO 90 #define E_CONF ERR_CONF , E_INFO 91 #define E_BREAK ERR_BREAK, E_INFO 92 #define E_NOKEY ERR_NOKEY, E_INFO 93 #define E_TEST ERR_TEST , E_INFO 94 #define E_ENVR ERR_ENVR , E_INFO 95 #define E_LOCK ERR_LOCK , E_INFO 96 #define E_MPTR ERR_MPTR , E_INFO 97 98 99 // ------------------------------------------------------------------ 100 // Prototypes 101 102 extern int errorlevel; 103 extern int error_exit; 104 extern const char* etext[]; 105 void ErrorExit(int type); 106 107 108 // ------------------------------------------------------------------ 109 // Return string (static array): Smth. error exit at [__file,__line]. 110 char* gerrinfo(int __type, const char* __file, int __line); 111 // Return string (static array): __message at [__file,__line]. 112 char* gerrinfo(const char* __message, const char* __file, int __line); 113 // Return string (static array): (OS version) reports error ##: strerror. 114 char* gerrosinfo(); 115 116 117 // ------------------------------------------------------------------ 118 119 #define gerropen() gerrinfo(ERR_OPEN, __FILE__, __LINE__) 120 #define gerrread() gerrinfo(ERR_READ, __FILE__, __LINE__) 121 #define gerrseek() gerrinfo(ERR_SEEK, __FILE__, __LINE__) 122 #define gerrmemory() gerrinfo(ERR_MEMO, __FILE__, __LINE__) 123 #define gerrindex() gerrinfo(ERR_INDX, __FILE__, __LINE__) 124 #define gerrwrite() gerrinfo(ERR_WRITE, __FILE__, __LINE__) 125 #define gerrtell() gerrinfo(ERR_TELL, __FILE__, __LINE__) 126 #define gerrclose() gerrinfo(ERR_CLOSE, __FILE__, __LINE__) 127 #define gerrconfig() gerrinfo(ERR_CONF, __FILE__, __LINE__) 128 #define gerrbreak() gerrinfo(ERR_BREAK, __FILE__, __LINE__) 129 #define gerrnokey() gerrinfo(ERR_NOKEY, __FILE__, __LINE__) 130 #define gerrtest() gerrinfo(ERR_TEST, __FILE__, __LINE__) 131 #define gerrenvr() gerrinfo(ERR_ENVR, __FILE__, __LINE__) 132 #define gerrlock() gerrinfo(ERR_LOCK, __FILE__, __LINE__) 133 #define gerrpointer() gerrinfo(ERR_MPTR, __FILE__, __LINE__) 134 135 #define erropen(f,l) printf("! %s", gerrinfo(ERR_OPEN, f,l)) 136 #define errread(f,l) printf("! %s", gerrinfo(ERR_READ, f,l)) 137 #define errseek(f,l) printf("! %s", gerrinfo(ERR_SEEK, f,l)) 138 #define errmemory(f,l) printf("! %s", gerrinfo(ERR_MEMO, f,l)) 139 #define errindex(f,l) printf("! %s", gerrinfo(ERR_INDX, f,l)) 140 #define errwrite(f,l) printf("! %s", gerrinfo(ERR_WRITE, f,l)) 141 #define errtell(f,l) printf("! %s", gerrinfo(ERR_TELL, f,l)) 142 #define errclose(f,l) printf("! %s", gerrinfo(ERR_CLOSE, f,l)) 143 #define errconfig(f,l) printf("! %s", gerrinfo(ERR_CONF, f,l)) 144 #define errbreak(f,l) printf("! %s", gerrinfo(ERR_BREAK, f,l)) 145 #define errnokey(f,l) printf("! %s", gerrinfo(ERR_NOKEY, f,l)) 146 #define errtest(f,l) printf("! %s", gerrinfo(ERR_TEST, f,l)) 147 #define errenvr(f,l) printf("! %s", gerrinfo(ERR_ENVR, f,l)) 148 #define errlock(f,l) printf("! %s", gerrinfo(ERR_LOCK, f,l)) 149 #define errpointer(f,l) printf("! %s", gerrinfo(ERR_MPTR, f,l)) 150 151 #define ErrOpen() erropen(__FILE__,__LINE__) 152 #define ErrRead() errread(__FILE__,__LINE__) 153 #define ErrSeek() errseek(__FILE__,__LINE__) 154 #define ErrMemory() errmemory(__FILE__,__LINE__) 155 #define ErrIndex() errindex(__FILE__,__LINE__) 156 #define ErrWrite() errwrite(__FILE__,__LINE__) 157 #define ErrTell() errtell(__FILE__,__LINE__) 158 #define ErrClose() errclose(__FILE__,__LINE__) 159 #define ErrConfig() errconfig(__FILE__,__LINE__) 160 #define ErrBreak() errbreak(__FILE__,__LINE__) 161 #define ErrNokey() errnokey(__FILE__,__LINE__) 162 #define ErrTest() errtest(__FILE__,__LINE__) 163 #define ErrEnvr() errenvr(__FILE__,__LINE__) 164 #define ErrLock() errlock(__FILE__,__LINE__) 165 #define ErrPointer() errpointer(__FILE__,__LINE__) 166 #define ErrOSInfo() printf(": %s", gerrosinfo()) 167 168 #define OpenErrorExit() ErrorExit(ERR_OPEN) 169 #define ReadErrorExit() ErrorExit(ERR_READ) 170 #define SeekErrorExit() ErrorExit(ERR_SEEK) 171 #define MemoryErrorExit() ErrorExit(ERR_MEMO) 172 #define IndexErrorExit() ErrorExit(ERR_INDX) 173 #define WriteErrorExit() ErrorExit(ERR_WRITE) 174 #define TellErrorExit() ErrorExit(ERR_TELL) 175 #define CloseErrorExit() ErrorExit(ERR_CLOSE) 176 #define ConfigErrorExit() ErrorExit(ERR_CONF) 177 #define BreakErrorExit() ErrorExit(ERR_BREAK) 178 #define NokeyErrorExit() ErrorExit(ERR_NOKEY) 179 #define TestErrorExit() ErrorExit(ERR_TEST) 180 #define EnvrErrorExit() ErrorExit(ERR_ENVR) 181 #define LockErrorExit() ErrorExit(ERR_LOCK) 182 #define PointerErrorExit() ErrorExit(ERR_MPTR) 183 184 185 // ------------------------------------------------------------------ 186 187 #endif 188 189 // ------------------------------------------------------------------ 190