infra: Clean up project setup
[jog] / err.h
CommitLineData
2ec1e693 1/* -*-c-*-
2 *
e9060e7e 3 * $Id: err.h,v 1.2 2002/02/02 19:16:46 mdw Exp $
2ec1e693 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
2ec1e693 29#ifndef ERR_H
30#define ERR_H
31
32#ifdef __cplusplus
33 extern "C" {
34#endif
35
36/*----- Header files ------------------------------------------------------*/
37
38#ifdef HAVE_CONFIG_H
39# include "config.h"
40#endif
41
42#include <stdarg.h>
43
44/*----- Error codes -------------------------------------------------------*/
45
46/* --- Abort codes --- *
47 *
48 * Only for the most serious errors, pertaining to the log file.
49 */
50
51#define ERRABORT_LOGOPEN 1u /* Log file wouldn't open */
52#define ERRABORT_LOGWRITE 2u /* Couldn't write to log file */
53
54/* --- Error contexts and reason codes --- *
55 *
56 * Most errors are reported as a group of three numeric codes. These are, in
57 * order:
58 *
59 * * the `context' code, which describes where whatever it was went wrong
60 * went wrong;
61 *
62 * * the `reason' code (specific to a particular context), which describes
63 * what the program was trying to do at the time; and
64 *
65 * * the `error' code (again specific to a particular context, but usually
66 * an @errno@ error code), which explains what the problem actually was.
67 */
68
69#define ERR_EXC 1u /* mLib exception error code */
70 /* Reason code is zero; error code is exception number */
71
72#define ERR_RXGLUE 2u /* REXX interface stuff */
73# define ERRRX_SCRIPTREAD 1u /* Problem reading script file */
74# define ERRRX_INTERP 2u /* Error code from interpreter */
75# define ERRRX_INIT 3u /* Initialization error */
76
77#define ERR_RXERR 3u /* REXX error */
78 /* Reason code is line number; error code is REXX error number */
79
80#define ERR_TXPORT 4u /* Transport switch stuff */
81# define ERRTX_BADTX 1u /* Unknown transport name */
82# define ERRTX_CREATE 2u /* Error creating transport */
83# define ERRTX_WRITE 3u /* Error writing to transport */
84# define ERRTX_READ 4u /* Read error from transport */
85# define ERRTX_CONFIG 5u /* Error in configuration */
86
e9060e7e 87#define ERR_AUDIO 5u /* Audio subsystem */
88# define ERRAU_NOTFOUND 1u /* Requested sample wasn't found */
89# define ERRAU_OPEN 2u /* Couldn't read sample file */
90# define ERRAU_INIT 3u /* Couldn't initialize audio */
91
2ec1e693 92/*----- Functions provided ------------------------------------------------*/
93
94/* --- @err_abort@ --- *
95 *
96 * Arguments: @int reason@ = abort reason code
97 * @unsigned long err@ = abort error code
98 * @const char *msg@ = error message
99 *
100 * Returns: Doesn't.
101 *
102 * Use: Reports a fatal error.
103 */
104
105extern void err_abortv(int /*reason*/, unsigned long /*err*/,
106 const char */*msg*/, va_list */*ap*/);
107
108extern void err_abort(int /*reason*/, unsigned long /*err*/,
109 const char */*msg*/, ...);
110
111/* --- @err_init@ --- *
112 *
113 * Arguments: ---
114 *
115 * Returns: ---
116 *
117 * Use: Attempts to initialize the logging system. It is a
118 * catastrophic failure if logging can't start up.
119 */
120
121extern void err_init(void);
122
123/* --- @err_report@ --- *
124 *
125 * Arguments: @int ctx@ = context code
126 * @int reason@ = reason code
127 * @unsigned long err@ = system error code
128 * @const char *msg@ = textual message to log
129 *
130 * Returns: ---
131 *
132 * Use: Reports an error. Doesn't abort anything unless something
133 * really serious happens.
134 */
135
136extern void err_reportv(int /*ctx*/, int /*reason*/, unsigned long /*err*/,
137 const char */*msg*/, va_list */*ap*/);
138
139extern void err_report(int /*ctx*/, int /*reason*/, unsigned long /*err*/,
140 const char */*msg*/, ...);
141
142/* --- @err_log@ --- *
143 *
144 * Arguments: @const char *msg@ = textual message to log
145 *
146 * Returns: ---
147 *
148 * Use: Logs a message.
149 */
150
151extern void err_logv(const char */*msg*/, va_list */*ap*/);
152
153extern void err_log(const char */*msg*/, ...);
154
155/*----- That's all, folks -------------------------------------------------*/
156
157#ifdef __cplusplus
158 }
159#endif
160
161#endif