home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Ports / x11 / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-18  |  1.9 KB  |  87 lines  |  [TEXT/????]

  1. /* X11 STDWIN -- error and debugging messages */
  2.  
  3. #include "x11.h"
  4.  
  5.  
  6. /* Undocumented globals to reduce the output volume */
  7.  
  8. bool _wnoerrors;        /* Suppress errors and warnings if set */
  9. bool _wnowarnings;        /* Suppress warnings if set */
  10. int _wtracelevel;        /* Amount of trace output wanted */
  11. int _wdebuglevel;        /* Amount of debug output wanted */
  12.  
  13.  
  14. /* Fatal error message aborting the program (use for unrecoverable errors) */
  15.  
  16. /*VARARGS1*/
  17. _wfatal(str, arg1, arg2, arg3, arg4)
  18.     char *str;
  19. {
  20.     fprintf(stderr, "%s: fatal error: ", _wprogname);
  21.     fprintf(stderr, str, arg1, arg2, arg3, arg4);
  22.     fprintf(stderr, "\n");
  23.     exit(1);
  24.     /*NOTREACHED*/
  25. }
  26.  
  27.  
  28. /* Error message (use for recoverable serious errors) */
  29.  
  30. /*VARARGS1*/
  31. _werror(str, arg1, arg2, arg3, arg4)
  32.     char *str;
  33. {
  34.     if (!_wnoerrors || _wdebuglevel > 0 || _wtracelevel > 0) {
  35.         fprintf(stderr, "%s: error: ", _wprogname);
  36.         fprintf(stderr, str, arg1, arg2, arg3, arg4);
  37.         fprintf(stderr, "\n");
  38.     }
  39. }
  40.  
  41.  
  42. /* Warning message (use for informative messages) */
  43.  
  44. /*VARARGS1*/
  45. _wwarning(str, arg1, arg2, arg3, arg4)
  46.     char *str;
  47. {
  48.     if (!_wnoerrors && !_wnowarnings || 
  49.         _wdebuglevel > 0 || _wtracelevel > 0) {
  50.         fprintf(stderr, "%s: warning: ", _wprogname);
  51.         fprintf(stderr, str, arg1, arg2, arg3, arg4);
  52.         fprintf(stderr, "\n");
  53.     }
  54. }
  55.  
  56.  
  57. /* Trace message (use to trace user-level routine calls) */
  58.  
  59. /*VARARGS2*/
  60. _wtrace(level, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  61.     int level;
  62.     char *str;
  63. {
  64.     if (_wtracelevel >= level) {
  65.         fprintf(stderr, "%s: trace %d: ", _wprogname, level);
  66.         fprintf(stderr, str,
  67.             arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  68.         fprintf(stderr, "\n");
  69.     }
  70. }
  71.  
  72.  
  73. /* Debug message (use for misc. debugging output) */
  74.  
  75. /*VARARGS2*/
  76. _wdebug(level, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  77.     int level;
  78.     char *str;
  79. {
  80.     if (_wdebuglevel >= level) {
  81.         fprintf(stderr, "%s: debug %d: ", _wprogname, level);
  82.         fprintf(stderr, str,
  83.             arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  84.         fprintf(stderr, "\n");
  85.     }
  86. }
  87.