home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / TIMEXSRC.ZIP / ERRHAND.H < prev    next >
Text File  |  1990-02-14  |  2KB  |  80 lines

  1. /* errhand.h -- Definitions for error handling routines
  2.  
  3.     1990 MIPS Magazine / M. Mallett
  4.  
  5. */
  6.  
  7.  
  8. typedef enum {                /* Error control types */
  9.     CTHANDLER,            /* Handler */
  10.     CTINTCEPT            /* Interceptor */
  11.          } ECTYPE;
  12.  
  13. /* Default number of conditions (in definition of ERRLIST struct) */
  14. #define    ELSIZE    2            /* Allows for 1 condition + ANY */
  15.  
  16. /* Condition list flags */
  17. #define    CF_ANY    0x01            /* Will handle any condition */
  18.  
  19. /* Special condition indexes */
  20. #define    CXNONE    0            /* Normal (non-error) return. */
  21. #define    CXANY    -1            /* Returned "any" */
  22.  
  23. /* Condition codes used internally */
  24. #define    CCMEMORY    0x8001        /* Memory allocation */
  25. #define    CCHANDLER    0x8002        /* No handler */
  26. #define    CCLISTFULL    0x8003        /* Condition list full */
  27.  
  28. typedef    int    ERRCOND;        /* How codes are represented */
  29.  
  30. typedef struct {            /* Error dispatch entry */
  31.     ERRCOND    d_cond;            /* condition */
  32.     int        (*d_rtc)();        /* routine to call */
  33.   } EDISP;
  34.  
  35.  
  36. typedef                    /* Condition list structure */
  37.   struct {
  38.     int        c_condC;        /* Number of conditions */
  39.     int        c_condL;        /* Length of condition array */
  40.     int        c_flags;        /* Flags for this list */
  41.     ECTYPE    c_type;            /* Type of list */
  42.     union {
  43.       ERRCOND    ca_cond;
  44.       EDISP    ca_disp;
  45.     }        c_any;            /* The "any" condition */
  46.  
  47.     union {
  48.       ERRCOND    cl_cond[ELSIZE];
  49.       EDISP    cl_disp[ELSIZE];
  50.     }        c_list;            /* The list. */
  51.  
  52.   } ERRLIST;
  53.  
  54. /* Macro to obtain a condition from a list given its index */
  55. #define    el_cond_inx(lP, x) ( lP->c_type == CTHANDLER ? \
  56.                 lP->c_list.cl_cond[x] :\
  57.                 lP->c_list.cl_disp[x].d_cond )
  58.  
  59. /* Macro to obtain a condition from a list given its ordinal */
  60. #define    el_cond_ord(lP, o) el_cond_inx(lP, o-1)
  61.  
  62. /* Macro to obtain the "any" condition from a list */
  63. #define el_cond_any(lP) ( lP->c_type == CTHANDLER ? \
  64.                 lP->c_any.ca_cond :\
  65.                 lP->c_any.ca_disp.d_cond )
  66.  
  67. /* Macro to obtain a condition from a list given the condition value */
  68. #define    el_cond( lP, v ) ( v == CXANY ? el_cond_any(lP) :\
  69.                         el_cond_ord( lP, v ) )
  70.  
  71.  
  72. void any_condition();
  73. void add_condition();
  74. ERRLIST *condition_list();
  75. int handle_error();
  76. void note_error();
  77. void receive_error();
  78. void remove_condition();
  79. void return_error();
  80.