/* @(#)getopt.c 2.1 88/08/01 4.0 RPCSRC */
/* this is a public domain version of getopt */
#define ERR(s, c) if(opterr){\
extern int strlen(), write();\
errbuf[0] = c; errbuf[1] = '\n';\
(void) write(2, argv[0], strlen(argv[0]));\
(void) write(2, s, strlen(s));\
(void) write(2, errbuf, 2);}
argv
[optind
][0] != '-' || argv
[optind
][1] == '\0')
else if(strcmp(argv
[optind
], "--") == NULL
) {
optopt
= c
= argv
[optind
][sp
];
if(c
== ':' || (cp
=strchr(opts
, c
)) == NULL
) {
ERR(": unknown option, -", c
);
if(argv
[optind
][++sp
] == '\0') {
if(argv
[optind
][sp
+1] != '\0')
optarg
= &argv
[optind
++][sp
+1];
else if(++optind
>= argc
) {
ERR(": argument missing for -", c
);
if(argv
[optind
][++sp
] == '\0') {