1: /*
   2: **  SET FLAG
   3: **
   4: **	This routine sets flags from argv.  You give arguments
   5: **	of the argv, the flag to be detected, and the default
   6: **	for that flag (if it is not supplied).  The return value
   7: **	is the flag value.   For example:
   8: **		setflag(argv, 'x', 2);
   9: **	returns zero if the "-x" flag is stated, and one if the
  10: **	"+x" flag is stated.  It returns 2 if the flag is not
  11: **	stated at all.
  12: **
  13: **	History:
  14: **		8/15/79 (eric) (6.2/7) -- changed to take -1
  15: **			or 0 as argv[argc].
  16: */
  17: 
  18: setflag(argv, flagch, def)
  19: char    **argv;
  20: char    flagch;
  21: int def;
  22: {
  23:     register char   **p;
  24:     register char   *q;
  25:     register int    rtval;
  26: 
  27:     rtval = -1;
  28:     for (p = &argv[1]; *p != 0 && *p != -1; p++)
  29:     {
  30:         q = *p;
  31:         if (q[1] != flagch)
  32:             continue;
  33:         if (*q != '-' && *q != '+')
  34:             continue;
  35:         rtval = (q[0] == '+');
  36:     }
  37:     if (rtval < 0)
  38:         rtval = def;
  39:     return (rtval);
  40: }
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1841
Valid CSS Valid XHTML 1.0 Strict