home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / FED_PLUS.EXE / ERROR.H < prev    next >
C/C++ Source or Header  |  1994-07-23  |  5KB  |  213 lines

  1. #ifndef ERROR_H
  2. #define ERROR_H
  3.  
  4. /* $Id: error.h,v 1.7 1993/10/15 18:49:23 libes Exp $ */
  5.  
  6. /************************************************************************
  7. ** Module:    Error
  8. ** Description:    This module implements the ERROR abstraction.
  9. ************************************************************************/
  10.  
  11. /*
  12.  * This work was supported by the United States Government, and is
  13.  * not subject to copyright.
  14.  *
  15.  * $Log: error.h,v $
  16.  * Revision 1.7  1993/10/15  18:49:23  libes
  17.  * CADDETC certified
  18.  *
  19.  * Revision 1.5  1993/02/22  21:44:34  libes
  20.  * ANSI compat fixes
  21.  *
  22.  * Revision 1.4  1992/08/18  17:15:40  libes
  23.  * rm'd extraneous error messages
  24.  *
  25.  * Revision 1.3  1992/06/08  18:07:35  libes
  26.  * prettied up interface to print_objects_when_running
  27.  */
  28.  
  29. #include "basic.h"    /* get basic definitions */
  30. #include <setjmp.h>
  31.  
  32. /*************/
  33. /* constants */
  34. /*************/
  35.  
  36. #define ERROR_none        (Error)NULL
  37. #define ERROR_MAX        100
  38.  
  39. /*****************/
  40. /* packages used */
  41. /*****************/
  42.  
  43. #include "memory.h"
  44. #include "symbol.h"
  45.  
  46. /************/
  47. /* typedefs */
  48. /************/
  49.  
  50. typedef enum {
  51.     SEVERITY_WARNING    = 0,
  52.     SEVERITY_ERROR    = 1,
  53.     SEVERITY_EXIT    = 2,
  54.     SEVERITY_DUMP    = 3,
  55.     SEVERITY_MAX    = 4
  56. } Severity;
  57.  
  58. /***************************/
  59. /* hidden type definitions */
  60. /***************************/
  61.  
  62. typedef struct Error {
  63.     Boolean    enabled;
  64.     Severity    severity;
  65.     char*    message;
  66. } *Error;
  67.  
  68. typedef struct Error_Warning {
  69.     char *    name;
  70.     struct Linked_List *errors;
  71. } *Error_Warning;
  72.  
  73. /****************/
  74. /* modules used */
  75. /****************/
  76.  
  77. /********************/
  78. /* global variables */
  79. /********************/
  80.  
  81. #ifdef ERROR_C
  82. #include "defstart.h"
  83. #else
  84. #include "decstart.h"
  85. #endif /* ERROR_C */
  86.  
  87. GLOBAL Boolean    __ERROR_buffer_errors        INITIALLY(false);
  88. GLOBAL char *current_filename            INITIALLY("stdin");
  89.  
  90. /* flag to remember whether non-warning errors have occurred */
  91. GLOBAL Boolean    ERRORoccurred            INITIALLY(false);
  92.  
  93.  
  94. GLOBAL Error    errc                INITIALLY(ERROR_none);
  95. GLOBAL Error    ERROR_subordinate_failed    INITIALLY(ERROR_none);
  96. GLOBAL Error    ERROR_syntax_expecting        INITIALLY(ERROR_none);
  97.  
  98. /* all of these are 1 if true, 0 if false switches */
  99. /* for debugging fedex */
  100. GLOBAL int    ERRORdebugging            INITIALLY(0);
  101. /* for debugging malloc during resolution */
  102. GLOBAL int    malloc_debug_resolve        INITIALLY(0);
  103. /* for debugging yacc/lex */
  104. GLOBAL int    debug                INITIALLY(0);
  105.  
  106. GLOBAL struct Linked_List *ERRORwarnings;
  107. GLOBAL struct freelist_head ERROR_OPT_fl;
  108.  
  109. GLOBAL void (*ERRORusage_function) PROTO((void));
  110.  
  111. #include "de_end.h"
  112.  
  113. /******************************/
  114. /* macro function definitions */
  115. /******************************/
  116.  
  117. #define ERROR_OPT_new()    (struct Error_Warning *)MEM_new(&ERROR_OPT_fl)
  118. #define ERROR_OPT_destroy(x)    MEM_destroy(&ERROR_OPT_fl,(Freelist *)(Generic)x)
  119.  
  120.  
  121. /********************/
  122. /* Inline functions */
  123. /********************/
  124.  
  125. #if supports_inline_functions || defined(ERROR_C)
  126.  
  127. static_inline
  128. void
  129. ERRORdisable(Error error)
  130. {
  131.     if (error != ERROR_none)
  132.     error->enabled = false;
  133. }
  134.  
  135. static_inline
  136. void
  137. ERRORenable(Error error)
  138. {
  139.     if (error != ERROR_none)
  140.     error->enabled = true;
  141. }
  142.  
  143. static_inline
  144. Boolean
  145. ERRORis_enabled(Error error)
  146. {
  147.     return error->enabled;
  148. }
  149.  
  150. static_inline
  151. void
  152. ERRORbuffer_messages(Boolean flag)
  153. {
  154.     extern void    ERROR_start_message_buffer(void),
  155.         ERROR_flush_message_buffer(void);
  156.  
  157.     __ERROR_buffer_errors = flag;
  158.     if (__ERROR_buffer_errors)
  159.     ERROR_start_message_buffer();
  160.     else
  161.     ERROR_flush_message_buffer();
  162. }
  163.  
  164. static_inline
  165. void
  166. ERRORflush_messages(void)
  167. {
  168.     extern void    ERROR_start_message_buffer(void),
  169.         ERROR_flush_message_buffer(void);
  170.  
  171.     if (__ERROR_buffer_errors) {
  172.     ERROR_flush_message_buffer();
  173.     ERROR_start_message_buffer();
  174.     }
  175. }
  176.  
  177. #endif /*supports_inline_functions || defined(ERROR_C)*/
  178.  
  179. /***********************/
  180. /* function prototypes */
  181. /***********************/
  182.  
  183. extern void    ERRORinitialize PROTO((void));
  184. extern void    ERRORinitialize_after_LIST PROTO((void));
  185. extern void    ERRORnospace PROTO((void));
  186. extern void    ERRORabort PROTO((int));
  187. extern Error    ERRORcreate PROTO((char*, Severity));
  188. extern void    ERRORreport PROTO((Error, ...));
  189. /*SUPPRESS 652*/  /* 1.? */
  190. /*SUPPRESS 842*/  /* 4.0.2 */
  191. struct Symbol;    /* mention Symbol to avoid warning on following line */
  192. extern void    ERRORreport_with_symbol PROTO((Error, struct Symbol *, ...));
  193. extern void    ERRORreport_with_line PROTO((Error, int, ...));
  194. extern void    ERRORbuffer_messages PROTO((Boolean));
  195. extern void    ERRORflush_messages PROTO((void));
  196.  
  197. extern void    ERROR_start_message_buffer PROTO((void));
  198. extern void    ERROR_flush_message_buffer PROTO((void));
  199.  
  200. extern void    ERRORcreate_warning PROTO((char *,Error));
  201. extern void    ERRORset_warning PROTO((char *,int));
  202. extern void    ERRORset_all_warnings PROTO((int));
  203. extern void    ERRORsafe PROTO((jmp_buf env));
  204. extern void    ERRORunsafe PROTO((void));
  205.  
  206. #if deprecated
  207. extern void    ERRORdisable PROTO((Error));
  208. extern void    ERRORenable PROTO((Error));
  209. extern Boolean    ERRORis_enabled PROTO((Error));
  210. #endif
  211.  
  212. #endif /* ERROR_H */
  213.