10 int xoptind
= 1; /* index of which argument is next */
11 char *xoptarg
; /* pointer to argument of current option */
12 int xopterr
= 0; /* allow error message */
14 static char *letP
= NULL
; /* remember next option char's location */
15 char SW
= '-'; /* DOS switch character, either '-' or '/' */
18 Parse the command line options, System V style.
20 Standard option syntax is:
22 option ::= SW [optLetter]* [argLetter space* argument]
26 int xgetopt(int argc
, char *argv
[], char *optionS
)
37 if ((letP
= argv
[xoptind
]) == NULL
||
38 *(letP
++) != SW
) goto gopEOF
;
40 xoptind
++; goto gopEOF
;
43 if (0 == (ch
= *(letP
++))) {
44 xoptind
++; goto gopEOF
;
46 if (':' == ch
|| (optP
= strchr(optionS
, ch
)) == NULL
)
48 if (':' == *(++optP
)) {
51 if (argc
<= xoptind
) goto gopError
;
52 letP
= argv
[xoptind
++];
66 xoptarg
= letP
= NULL
;
73 perror ("get command line option");