2ec1e693 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: err.h,v 1.1 2002/01/25 19:34:45 mdw Exp $ |
4 | * |
5 | * Error reporting |
6 | * |
7 | * (c) 2001 Mark Wooding |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of Jog: Programming for a jogging machine. |
13 | * |
14 | * Jog is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2 of the License, or |
17 | * (at your option) any later version. |
18 | * |
19 | * Jog is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU General Public License for more details. |
23 | * |
24 | * You should have received a copy of the GNU General Public License |
25 | * along with Jog; if not, write to the Free Software Foundation, |
26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
27 | */ |
28 | |
29 | /*----- Revision history --------------------------------------------------* |
30 | * |
31 | * $Log: err.h,v $ |
32 | * Revision 1.1 2002/01/25 19:34:45 mdw |
33 | * Initial revision |
34 | * |
35 | */ |
36 | |
37 | #ifndef ERR_H |
38 | #define ERR_H |
39 | |
40 | #ifdef __cplusplus |
41 | extern "C" { |
42 | #endif |
43 | |
44 | /*----- Header files ------------------------------------------------------*/ |
45 | |
46 | #ifdef HAVE_CONFIG_H |
47 | # include "config.h" |
48 | #endif |
49 | |
50 | #include <stdarg.h> |
51 | |
52 | /*----- Error codes -------------------------------------------------------*/ |
53 | |
54 | /* --- Abort codes --- * |
55 | * |
56 | * Only for the most serious errors, pertaining to the log file. |
57 | */ |
58 | |
59 | #define ERRABORT_LOGOPEN 1u /* Log file wouldn't open */ |
60 | #define ERRABORT_LOGWRITE 2u /* Couldn't write to log file */ |
61 | |
62 | /* --- Error contexts and reason codes --- * |
63 | * |
64 | * Most errors are reported as a group of three numeric codes. These are, in |
65 | * order: |
66 | * |
67 | * * the `context' code, which describes where whatever it was went wrong |
68 | * went wrong; |
69 | * |
70 | * * the `reason' code (specific to a particular context), which describes |
71 | * what the program was trying to do at the time; and |
72 | * |
73 | * * the `error' code (again specific to a particular context, but usually |
74 | * an @errno@ error code), which explains what the problem actually was. |
75 | */ |
76 | |
77 | #define ERR_EXC 1u /* mLib exception error code */ |
78 | /* Reason code is zero; error code is exception number */ |
79 | |
80 | #define ERR_RXGLUE 2u /* REXX interface stuff */ |
81 | # define ERRRX_SCRIPTREAD 1u /* Problem reading script file */ |
82 | # define ERRRX_INTERP 2u /* Error code from interpreter */ |
83 | # define ERRRX_INIT 3u /* Initialization error */ |
84 | |
85 | #define ERR_RXERR 3u /* REXX error */ |
86 | /* Reason code is line number; error code is REXX error number */ |
87 | |
88 | #define ERR_TXPORT 4u /* Transport switch stuff */ |
89 | # define ERRTX_BADTX 1u /* Unknown transport name */ |
90 | # define ERRTX_CREATE 2u /* Error creating transport */ |
91 | # define ERRTX_WRITE 3u /* Error writing to transport */ |
92 | # define ERRTX_READ 4u /* Read error from transport */ |
93 | # define ERRTX_CONFIG 5u /* Error in configuration */ |
94 | |
95 | /*----- Functions provided ------------------------------------------------*/ |
96 | |
97 | /* --- @err_abort@ --- * |
98 | * |
99 | * Arguments: @int reason@ = abort reason code |
100 | * @unsigned long err@ = abort error code |
101 | * @const char *msg@ = error message |
102 | * |
103 | * Returns: Doesn't. |
104 | * |
105 | * Use: Reports a fatal error. |
106 | */ |
107 | |
108 | extern void err_abortv(int /*reason*/, unsigned long /*err*/, |
109 | const char */*msg*/, va_list */*ap*/); |
110 | |
111 | extern void err_abort(int /*reason*/, unsigned long /*err*/, |
112 | const char */*msg*/, ...); |
113 | |
114 | /* --- @err_init@ --- * |
115 | * |
116 | * Arguments: --- |
117 | * |
118 | * Returns: --- |
119 | * |
120 | * Use: Attempts to initialize the logging system. It is a |
121 | * catastrophic failure if logging can't start up. |
122 | */ |
123 | |
124 | extern void err_init(void); |
125 | |
126 | /* --- @err_report@ --- * |
127 | * |
128 | * Arguments: @int ctx@ = context code |
129 | * @int reason@ = reason code |
130 | * @unsigned long err@ = system error code |
131 | * @const char *msg@ = textual message to log |
132 | * |
133 | * Returns: --- |
134 | * |
135 | * Use: Reports an error. Doesn't abort anything unless something |
136 | * really serious happens. |
137 | */ |
138 | |
139 | extern void err_reportv(int /*ctx*/, int /*reason*/, unsigned long /*err*/, |
140 | const char */*msg*/, va_list */*ap*/); |
141 | |
142 | extern void err_report(int /*ctx*/, int /*reason*/, unsigned long /*err*/, |
143 | const char */*msg*/, ...); |
144 | |
145 | /* --- @err_log@ --- * |
146 | * |
147 | * Arguments: @const char *msg@ = textual message to log |
148 | * |
149 | * Returns: --- |
150 | * |
151 | * Use: Logs a message. |
152 | */ |
153 | |
154 | extern void err_logv(const char */*msg*/, va_list */*ap*/); |
155 | |
156 | extern void err_log(const char */*msg*/, ...); |
157 | |
158 | /*----- That's all, folks -------------------------------------------------*/ |
159 | |
160 | #ifdef __cplusplus |
161 | } |
162 | #endif |
163 | |
164 | #endif |