home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
TIMEXSRC.ZIP
/
ERRHAND.H
< prev
next >
Wrap
Text File
|
1990-02-14
|
2KB
|
80 lines
/* errhand.h -- Definitions for error handling routines
1990 MIPS Magazine / M. Mallett
*/
typedef enum { /* Error control types */
CTHANDLER, /* Handler */
CTINTCEPT /* Interceptor */
} ECTYPE;
/* Default number of conditions (in definition of ERRLIST struct) */
#define ELSIZE 2 /* Allows for 1 condition + ANY */
/* Condition list flags */
#define CF_ANY 0x01 /* Will handle any condition */
/* Special condition indexes */
#define CXNONE 0 /* Normal (non-error) return. */
#define CXANY -1 /* Returned "any" */
/* Condition codes used internally */
#define CCMEMORY 0x8001 /* Memory allocation */
#define CCHANDLER 0x8002 /* No handler */
#define CCLISTFULL 0x8003 /* Condition list full */
typedef int ERRCOND; /* How codes are represented */
typedef struct { /* Error dispatch entry */
ERRCOND d_cond; /* condition */
int (*d_rtc)(); /* routine to call */
} EDISP;
typedef /* Condition list structure */
struct {
int c_condC; /* Number of conditions */
int c_condL; /* Length of condition array */
int c_flags; /* Flags for this list */
ECTYPE c_type; /* Type of list */
union {
ERRCOND ca_cond;
EDISP ca_disp;
} c_any; /* The "any" condition */
union {
ERRCOND cl_cond[ELSIZE];
EDISP cl_disp[ELSIZE];
} c_list; /* The list. */
} ERRLIST;
/* Macro to obtain a condition from a list given its index */
#define el_cond_inx(lP, x) ( lP->c_type == CTHANDLER ? \
lP->c_list.cl_cond[x] :\
lP->c_list.cl_disp[x].d_cond )
/* Macro to obtain a condition from a list given its ordinal */
#define el_cond_ord(lP, o) el_cond_inx(lP, o-1)
/* Macro to obtain the "any" condition from a list */
#define el_cond_any(lP) ( lP->c_type == CTHANDLER ? \
lP->c_any.ca_cond :\
lP->c_any.ca_disp.d_cond )
/* Macro to obtain a condition from a list given the condition value */
#define el_cond( lP, v ) ( v == CXANY ? el_cond_any(lP) :\
el_cond_ord( lP, v ) )
void any_condition();
void add_condition();
ERRLIST *condition_list();
int handle_error();
void note_error();
void receive_error();
void remove_condition();
void return_error();