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