PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/brlcad/branches/dmtogl/src/other/step/include/express/error.h

https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git
C Header | 216 lines | 113 code | 43 blank | 60 comment | 7 complexity | 4a254905c717a7627794ef79b61aa03d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1, Apache-2.0, AGPL-3.0, LGPL-3.0, GPL-3.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, 0BSD, BSD-3-Clause
  1. #ifndef ERROR_H
  2. #define ERROR_H
  3. /* $Id: error.h,v 1.8 1997/01/21 19:16:55 dar Exp $ */
  4. /************************************************************************
  5. ** Module: Error
  6. ** Description: This module implements the ERROR abstraction.
  7. ************************************************************************/
  8. /*
  9. * This work was supported by the United States Government, and is
  10. * not subject to copyright.
  11. *
  12. * $Log: error.h,v $
  13. * Revision 1.8 1997/01/21 19:16:55 dar
  14. * made C++ compatible
  15. * ,.
  16. *
  17. * Revision 1.7 1993/10/15 18:49:23 libes
  18. * CADDETC certified
  19. *
  20. * Revision 1.5 1993/02/22 21:44:34 libes
  21. * ANSI compat fixes
  22. *
  23. * Revision 1.4 1992/08/18 17:15:40 libes
  24. * rm'd extraneous error messages
  25. *
  26. * Revision 1.3 1992/06/08 18:07:35 libes
  27. * prettied up interface to print_objects_when_running
  28. */
  29. #include "basic.h" /* get basic definitions */
  30. #include "setjmp.h"
  31. /*************/
  32. /* constants */
  33. /*************/
  34. #define ERROR_none (Error)NULL
  35. #define ERROR_MAX 100
  36. /*****************/
  37. /* packages used */
  38. /*****************/
  39. #include "memory.h"
  40. #include "symbol.h"
  41. /************/
  42. /* typedefs */
  43. /************/
  44. typedef enum {
  45. SEVERITY_WARNING = 0,
  46. SEVERITY_ERROR = 1,
  47. SEVERITY_EXIT = 2,
  48. SEVERITY_DUMP = 3,
  49. SEVERITY_MAX = 4
  50. } Severity;
  51. /***************************/
  52. /* hidden type definitions */
  53. /***************************/
  54. typedef struct Error_ {
  55. Boolean enabled;
  56. Severity severity;
  57. char* message;
  58. } *Error;
  59. typedef struct Error_Warning_ {
  60. char * name;
  61. struct Linked_List_ *errors;
  62. } *Error_Warning;
  63. /****************/
  64. /* modules used */
  65. /****************/
  66. /********************/
  67. /* global variables */
  68. /********************/
  69. #ifdef ERROR_C
  70. #include "defstart.h"
  71. #else
  72. #include "decstart.h"
  73. #endif /* ERROR_C */
  74. GLOBAL Boolean __ERROR_buffer_errors INITIALLY(False);
  75. GLOBAL char *current_filename INITIALLY("stdin");
  76. /* flag to remember whether non-warning errors have occurred */
  77. GLOBAL Boolean ERRORoccurred INITIALLY(False);
  78. GLOBAL Error experrc INITIALLY(ERROR_none);
  79. GLOBAL Error ERROR_subordinate_failed INITIALLY(ERROR_none);
  80. GLOBAL Error ERROR_syntax_expecting INITIALLY(ERROR_none);
  81. /* all of these are 1 if true, 0 if false switches */
  82. /* for debugging fedex */
  83. GLOBAL int ERRORdebugging INITIALLY(0);
  84. /* for debugging malloc during resolution */
  85. GLOBAL int malloc_debug_resolve INITIALLY(0);
  86. /* for debugging yacc/lex */
  87. GLOBAL int debug INITIALLY(0);
  88. GLOBAL struct Linked_List_ *ERRORwarnings;
  89. GLOBAL struct freelist_head ERROR_OPT_fl;
  90. GLOBAL void (*ERRORusage_function) PROTO((void));
  91. #include "de_end.h"
  92. /******************************/
  93. /* macro function definitions */
  94. /******************************/
  95. #define ERROR_OPT_new() (struct Error_Warning_ *)MEM_new(&ERROR_OPT_fl)
  96. #define ERROR_OPT_destroy(x) MEM_destroy(&ERROR_OPT_fl,(Freelist *)(Generic)x)
  97. /********************/
  98. /* Inline functions */
  99. /********************/
  100. #if supports_inline_functions || defined(ERROR_C)
  101. static_inline
  102. void
  103. ERRORdisable(Error error)
  104. {
  105. if (error != ERROR_none)
  106. error->enabled = False;
  107. }
  108. static_inline
  109. void
  110. ERRORenable(Error error)
  111. {
  112. if (error != ERROR_none)
  113. error->enabled = True;
  114. }
  115. static_inline
  116. Boolean
  117. ERRORis_enabled(Error error)
  118. {
  119. return error->enabled;
  120. }
  121. static_inline
  122. void
  123. ERRORbuffer_messages(Boolean flag)
  124. {
  125. extern void ERROR_start_message_buffer(void),
  126. ERROR_flush_message_buffer(void);
  127. __ERROR_buffer_errors = flag;
  128. if (__ERROR_buffer_errors)
  129. ERROR_start_message_buffer();
  130. else
  131. ERROR_flush_message_buffer();
  132. }
  133. static_inline
  134. void
  135. ERRORflush_messages(void)
  136. {
  137. extern void ERROR_start_message_buffer(void),
  138. ERROR_flush_message_buffer(void);
  139. if (__ERROR_buffer_errors) {
  140. ERROR_flush_message_buffer();
  141. ERROR_start_message_buffer();
  142. }
  143. }
  144. #endif /*supports_inline_functions || defined(ERROR_C)*/
  145. /***********************/
  146. /* function prototypes */
  147. /***********************/
  148. extern void ERRORinitialize PROTO((void));
  149. extern void ERRORinitialize_after_LIST PROTO((void));
  150. extern void ERRORnospace PROTO((void));
  151. extern void ERRORabort PROTO((int));
  152. extern Error ERRORcreate PROTO((char*, Severity));
  153. extern void ERRORreport PROTO((Error, ...));
  154. /*SUPPRESS 652*/ /* 1.? */
  155. /*SUPPRESS 842*/ /* 4.0.2 */
  156. struct Symbol_; /* mention Symbol to avoid warning on following line */
  157. extern void ERRORreport_with_symbol PROTO((Error, struct Symbol_ *, ...));
  158. extern void ERRORreport_with_line PROTO((Error, int, ...));
  159. extern void ERRORbuffer_messages PROTO((Boolean));
  160. extern void ERRORflush_messages PROTO((void));
  161. extern void ERROR_start_message_buffer PROTO((void));
  162. extern void ERROR_flush_message_buffer PROTO((void));
  163. extern void ERRORcreate_warning PROTO((char *,Error));
  164. extern void ERRORset_warning PROTO((char *,int));
  165. extern void ERRORset_all_warnings PROTO((int));
  166. extern void ERRORsafe PROTO((jmp_buf env));
  167. extern void ERRORunsafe PROTO((void));
  168. #if deprecated
  169. extern void ERRORdisable PROTO((Error));
  170. extern void ERRORenable PROTO((Error));
  171. extern Boolean ERRORis_enabled PROTO((Error));
  172. #endif
  173. #endif /* ERROR_H */