home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / watcher / part01 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-27  |  2.1 KB  |  80 lines

  1. /*
  2.    main: main routine for the watcher program.
  3.  
  4.    read from a file describing commands (pipelines) to execute, formats of
  5.        the output, max changes allowed (% or absolute), and max & min
  6.        values for various fields.
  7.    problems noticed are reported.
  8.    as a side effect, be able to pretty print the description file
  9.        (originally use to verify parsing).
  10.    
  11.    format:
  12.    (command)\tformat :
  13.    \tfield\tchange\tmax\tmin
  14.        .
  15.        .
  16.        .
  17.  
  18.    See yacc file for complete grammar description of control file.
  19.  
  20.    outline of program:
  21.     parse control file and build data structures.
  22.     run each pipeline and compare output to previous output (only
  23.         save relevant fields; save directory is either default
  24.         or command line specified; no previous file or format
  25.         changed (ie we are watching different or new fields) we
  26.         create new file and next time we do compare).
  27.         differences that are not allowable are reported.
  28.     
  29.    Usage of program:
  30.     watcher [-p] [-v] [-h histfile] [-f controlfile]
  31.  
  32.     -p : pretty print control file as a verification of parse
  33.         (default no pretty print).  This option prevents
  34.         processing of control file.
  35.     -v : be verbose when doing work; useful for debugging.
  36.     -h : file in which to save output for future compare (default
  37.         ./watcher.history).
  38.     -f : controlfile to use (default ./watcherfile or ./Watcherfile).
  39.  
  40.    Note that the basic data structures are all linear linked lists, with
  41.    many items in the list being heads of other lists.  When problems
  42.    occur, get out the pencil and paper and start drawing the lists.  
  43.  
  44.    Kenneth Ingham
  45.  
  46.    Copyright (C) 1987 The University of New Mexico
  47. */
  48.  
  49. #include "defs.h"
  50.  
  51. main(argc, argv)
  52. int argc;
  53. char *argv[];
  54. {
  55.     extern int parse_error;
  56.     extern struct cmd_st *clist;
  57.     extern int pflag;
  58.  
  59.     do_args(argc, argv);
  60.     init();
  61.  
  62.     if (yyparse() == 1 || parse_error) {
  63.         fprintf(stderr, "%s: parse error in control file.\n", NAME);
  64.         exit(1);
  65.     }
  66.  
  67.     if (clist == NULL) {
  68.         fprintf(stderr, "No command list to execute!\n");
  69.         exit(1);
  70.     }
  71.  
  72.     if (pflag)
  73.         pp(clist);
  74.     else {
  75.         read_hist();
  76.         open_hf(); /* for writing our history */
  77.         doit();
  78.     }
  79. }
  80.