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

  1. /*
  2.    do_args: parse the comand line arguments and set variables related to
  3.    them.
  4.  
  5.    Copied from main:
  6.     watcher [-p] [-v] [-h histfile] [-f controlfile]
  7.  
  8.     -p : pretty print control file as a verification of parse
  9.         (default no pretty print).  This option prevents
  10.         processing of control file.
  11.     -v : be verbose.
  12.     -h : file in which to save output for future compare (default
  13.         ./watcher.history).
  14.     -f : controlfile to use (default ./DEF_CONTROL{,2}).
  15.  
  16.    Kenneth Ingham
  17.  
  18.    Copyright (C) 1987 The University of New Mexico
  19. */
  20.  
  21. #include "defs.h"
  22.  
  23. do_args(argc, argv)
  24. int argc; 
  25. char *argv[];
  26. {
  27.     extern int pflag, cflag, vflag;
  28.     extern char controlname[], histfilename[];
  29.  
  30.     register int i;
  31.  
  32.     /* defaults */
  33.     pflag = False;
  34.     cflag = False;
  35.     vflag = False;
  36.     (void) sprintf(histfilename, "%s", DEF_HISTFILE);
  37.  
  38.     for (i=1; i<argc; i++) {
  39.         if (argv[i][0] == '-') {
  40.             switch(argv[i][1]) {
  41.             case 'v':
  42.                 vflag = True;
  43.                 break;
  44.             case 'p':
  45.                 pflag = True;
  46.                 break;
  47.             case 'h':
  48.                 i = getargv(histfilename, argv, i,
  49.                     "history file name");
  50.                 break;
  51.             case 'f':
  52.                 i = getargv(controlname, argv, i,
  53.                     "controlfile name");
  54.                 cflag = True;
  55.                 break;
  56.             default:
  57.                 fprintf(stderr, "Unknown flag '%s'\n", argv[i]);
  58.                 exit(1);
  59.             }
  60.         }
  61.     }
  62. }
  63.