home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / FTREE0.3.LHA / ftree / src / RCS / errs.c,v < prev    next >
Encoding:
Text File  |  1994-04-27  |  1.3 KB  |  82 lines

  1. head    1.1;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @ * @;
  6.  
  7.  
  8. 1.1
  9. date    94.03.26.11.34.21;    author peteric;    state Exp;
  10. branches;
  11. next    ;
  12.  
  13.  
  14. desc
  15. @Error handling routines extracted from main.c
  16. @
  17.  
  18.  
  19. 1.1
  20. log
  21. @Initial revision
  22. @
  23. text
  24. @/*************************************************************************
  25.  *
  26.  *     $RSCFile$
  27.  *
  28.  *    $Author$
  29.  *
  30.  *    $Date$
  31.  *
  32.  *    $Revision$
  33.  *
  34.  *    Purpose:    Error handling routines
  35.  *            
  36.  *    $Log$
  37.  *    
  38.  *
  39.  *************************************************************************/
  40.  
  41. #include <stdlib.h>
  42. #include <stdarg.h>
  43. #include <string.h>
  44.  
  45. #include "ftree.h"
  46.  
  47. int reading_file = FALSE;        /* true when reading input file */
  48. int errors = 0;                        /* # errors so far */
  49. char *current_filename = NULL;        /* current filename pointer */
  50. int lineno = 0;                        /* current linenumber */
  51.  
  52. void errmsg(const char *str, ...)
  53. {
  54.     va_list ap;
  55.  
  56.     va_start(ap, str);
  57.     if (reading_file)
  58.         fprintf(stderr, "%s: %d: ", current_filename, lineno);
  59.     fprintf(stderr, "error: ");
  60.     vfprintf(stderr, str, ap);
  61.     va_end(ap);
  62.     
  63.     if (++errors > 5)
  64.     {
  65.         fprintf(stderr, "ftree: error: too many errors; exiting.\n");
  66.         exit(1);
  67.     }
  68. }
  69.  
  70. void warnmsg(const char *str, ...)
  71. {
  72.     va_list ap;
  73.  
  74.     va_start(ap, str);
  75.     if (reading_file)
  76.         fprintf(stderr, "%s: %d: ", current_filename, lineno);
  77.     fprintf(stderr, "warning: ");
  78.     vfprintf(stderr, str, ap);
  79.     va_end(ap);
  80. }
  81. @
  82.