1: # include   <sccs.h>
   2: 
   3: SCCSID(@(#)setflag.c	8.1	12/31/84)
   4: 
   5: /*
   6: **  SET FLAG
   7: **
   8: **	This routine sets flags from argv.  You give arguments
   9: **	of the argv, the flag to be detected, and the default
  10: **	for that flag (if it is not supplied).  The return value
  11: **	is the flag value.   For example:
  12: **		setflag(argv, 'x', 2);
  13: **	returns zero if the "-x" flag is stated, and one if the
  14: **	"+x" flag is stated.  It returns 2 if the flag is not
  15: **	stated at all.
  16: */
  17: 
  18: # define    NULL    0
  19: 
  20: setflag(argv, flagch, def)
  21: char    **argv;
  22: char    flagch;
  23: int def;
  24: {
  25:     register char   **p;
  26:     register char   *q;
  27:     register int    rtval;
  28: 
  29:     rtval = -1;
  30:     for (p = &argv[1]; *p != NULL; p++)
  31:     {
  32:         q = *p;
  33:         if (q[1] != flagch)
  34:             continue;
  35:         if (*q != '-' && *q != '+')
  36:             continue;
  37:         rtval = (q[0] == '+');
  38:     }
  39:     if (rtval < 0)
  40:         rtval = def;
  41:     return (rtval);
  42: }

Defined functions

setflag defined in line 3; never used

Defined macros

NULL defined in line 18; used 1 times
  • in line 30
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 472
Valid CSS Valid XHTML 1.0 Strict