4 #define EPR fprintf(stderr,
5 #define ERR(str, chr) if(opterr) { EPR "%s%c\n", str, chr); }
13 stgetopt(int argc
, char *const argv
[], const char *opts
)
22 argv
[optind
][0] != '-' || argv
[optind
][1] == '\0')
25 if (strcmp(argv
[optind
], "--") == 0)
31 optopt
= c
= argv
[optind
][sp
];
32 if (c
== ':' || (cp
= strchr(opts
, c
)) == 0)
34 ERR(": illegal option -- ", c
);
35 if (argv
[optind
][++sp
] == '\0')
44 if (argv
[optind
][sp
+ 1] != '\0')
45 optarg
= &argv
[optind
++][sp
+ 1];
49 ERR(": option requires an argument -- ", c
);
54 optarg
= argv
[optind
++];
59 if (argv
[optind
][++sp
] == '\0')