PageRenderTime 57ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git
C Header | 195 lines | 97 code | 38 blank | 60 comment | 11 complexity | 881ce95019d40491de348981e8a926be 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. /** **********************************************************************
  4. ** Module: Error \file error.h
  5. ** Description: This module implements the ERROR abstraction.
  6. ************************************************************************/
  7. /*
  8. * This work was supported by the United States Government, and is
  9. * not subject to copyright.
  10. *
  11. * $Log: error.h,v $
  12. * Revision 1.8 1997/01/21 19:16:55 dar
  13. * made C++ compatible
  14. * ,.
  15. *
  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. #include <scl_export.h>
  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. bool 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. extern SCL_EXPRESS_EXPORT bool __ERROR_buffer_errors;
  70. extern SCL_EXPRESS_EXPORT char * current_filename;
  71. /* flag to remember whether non-warning errors have occurred */
  72. extern SCL_EXPRESS_EXPORT bool ERRORoccurred;
  73. extern SCL_EXPRESS_EXPORT Error experrc;
  74. extern SCL_EXPRESS_EXPORT Error ERROR_subordinate_failed;
  75. extern SCL_EXPRESS_EXPORT Error ERROR_syntax_expecting;
  76. /* all of these are 1 if true, 0 if false switches */
  77. /* for debugging fedex */
  78. extern SCL_EXPRESS_EXPORT int ERRORdebugging;
  79. /* for debugging malloc during resolution */
  80. extern SCL_EXPRESS_EXPORT int malloc_debug_resolve;
  81. /* for debugging yacc/lex */
  82. extern SCL_EXPRESS_EXPORT int debug;
  83. extern SCL_EXPRESS_EXPORT struct Linked_List_ * ERRORwarnings;
  84. extern SCL_EXPRESS_EXPORT struct freelist_head ERROR_OPT_fl;
  85. extern SCL_EXPRESS_EXPORT void ( *ERRORusage_function )( void );
  86. /******************************/
  87. /* macro function definitions */
  88. /******************************/
  89. #define ERROR_OPT_new() (struct Error_Warning_ *)MEM_new(&ERROR_OPT_fl)
  90. #define ERROR_OPT_destroy(x) MEM_destroy(&ERROR_OPT_fl,(Freelist *)(Generic)x)
  91. /***********************/
  92. /* function prototypes */
  93. /***********************/
  94. #if defined(__MSVC__) || defined(__BORLAND__)
  95. extern SCL_EXPRESS_EXPORT void ERROR_start_message_buffer PROTO( ( void ) );
  96. extern SCL_EXPRESS_EXPORT void ERROR_flush_message_buffer PROTO( ( void ) );
  97. #endif
  98. /********************/
  99. /* Inline functions */
  100. /********************/
  101. static_inline void ERRORdisable( Error error ) {
  102. if( error != ERROR_none ) {
  103. error->enabled = false;
  104. }
  105. }
  106. static_inline void ERRORenable( Error error ) {
  107. if( error != ERROR_none ) {
  108. error->enabled = true;
  109. }
  110. }
  111. static_inline bool ERRORis_enabled( Error error ) {
  112. return error->enabled;
  113. }
  114. static_inline void ERRORbuffer_messages( bool flag ) {
  115. #if !defined(__MSVC__) && !defined(__BORLAND__)
  116. extern void ERROR_start_message_buffer( void ),
  117. ERROR_flush_message_buffer( void );
  118. #endif
  119. __ERROR_buffer_errors = flag;
  120. if( __ERROR_buffer_errors ) {
  121. ERROR_start_message_buffer();
  122. } else {
  123. ERROR_flush_message_buffer();
  124. }
  125. }
  126. static_inline void ERRORflush_messages( void ) {
  127. #if !defined(__MSVC__) && !defined(__BORLAND__)
  128. extern void ERROR_start_message_buffer( void ),
  129. ERROR_flush_message_buffer( void );
  130. #endif
  131. if( __ERROR_buffer_errors ) {
  132. ERROR_flush_message_buffer();
  133. ERROR_start_message_buffer();
  134. }
  135. }
  136. /***********************/
  137. /* function prototypes */
  138. /***********************/
  139. extern SCL_EXPRESS_EXPORT void ERRORinitialize PROTO( ( void ) );
  140. extern SCL_EXPRESS_EXPORT void ERRORinitialize_after_LIST PROTO( ( void ) );
  141. extern SCL_EXPRESS_EXPORT void ERRORnospace PROTO( ( void ) );
  142. extern SCL_EXPRESS_EXPORT void ERRORabort PROTO( ( int ) );
  143. extern SCL_EXPRESS_EXPORT Error ERRORcreate PROTO( ( char *, Severity ) );
  144. extern SCL_EXPRESS_EXPORT void ERRORreport PROTO( ( Error, ... ) );
  145. struct Symbol_; /* mention Symbol to avoid warning on following line */
  146. extern SCL_EXPRESS_EXPORT void ERRORreport_with_symbol PROTO( ( Error, struct Symbol_ *, ... ) );
  147. extern SCL_EXPRESS_EXPORT void ERRORreport_with_line PROTO( ( Error, int, ... ) );
  148. #if !defined(__MSVC__) && !defined(__BORLAND__)
  149. extern SCL_EXPRESS_EXPORT void ERROR_start_message_buffer PROTO( ( void ) );
  150. extern SCL_EXPRESS_EXPORT void ERROR_flush_message_buffer PROTO( ( void ) );
  151. #endif
  152. extern SCL_EXPRESS_EXPORT void ERRORcreate_warning PROTO( ( char *, Error ) );
  153. extern SCL_EXPRESS_EXPORT void ERRORset_warning PROTO( ( char *, int ) );
  154. extern SCL_EXPRESS_EXPORT void ERRORset_all_warnings PROTO( ( int ) );
  155. extern SCL_EXPRESS_EXPORT void ERRORsafe PROTO( ( jmp_buf env ) );
  156. extern SCL_EXPRESS_EXPORT void ERRORunsafe PROTO( ( void ) );
  157. #endif /* ERROR_H */