|
|
1.1 ! root 1: # include <sccs.h> ! 2: ! 3: SCCSID(@(#)setflag.c 7.1 2/5/81) ! 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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.