home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW noweb 2.7 / src / c / errors.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-30  |  1013 b   |  41 lines  |  [TEXT/MPS ]

  1. #line 16 "errors.nw"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <stdarg.h>
  6. #include "errors.h"
  7.  
  8. #line 30 "errors.nw"
  9. enum errorlevel errorlevel = Normal;
  10. #line 40 "errors.nw"
  11. void errormsg(enum errorlevel level, char *s,...) {     
  12.     va_list args;                       /* see K&R, page 174 */
  13.     va_start(args,s);
  14.     
  15. #line 63 "errors.nw"
  16. if (level > errorlevel)
  17.     errorlevel = level;
  18. vfprintf(stderr, s, args);
  19. fprintf(stderr,"\n");
  20. #line 44 "errors.nw"
  21.     va_end(args);
  22.     if (level >= Fatal)
  23.         exit(level);
  24. }
  25. #line 52 "errors.nw"
  26. void errorat(char *filename, int lineno, enum errorlevel level, char *s, ...) {     
  27.     va_list args;                       /* see K&R, page 174 */
  28.     va_start(args,s);
  29.     fprintf(stderr, "\"%s\", line %d: ", filename, lineno);
  30.     
  31. #line 63 "errors.nw"
  32. if (level > errorlevel)
  33.     errorlevel = level;
  34. vfprintf(stderr, s, args);
  35. fprintf(stderr,"\n");
  36. #line 57 "errors.nw"
  37.     va_end(args);
  38.     if (level >= Fatal)
  39.         exit(level);
  40. }
  41.