3
* Options parsing class
5
* by Timothy Baldock <tb@entropy.me.uk>
11
Fetchopt_t::Fetchopt_t(int argc, char **argv, const char *optstring) {
20
char *Fetchopt_t::get_optarg() {
24
int Fetchopt_t::get_optind() {
28
int Fetchopt_t::next() {
30
if (optind >= ac || av[optind][0] != '-') {
33
int optchar = av[optind][pos];
34
const char *offset = strchr(optstr, optchar);
35
if (offset == NULL || optchar == ':') {
39
if (*(offset+1) == ':') {
40
// Option with argument
41
if (av[optind][pos+1] == '\0') {
42
// Use next argument for option's argument
47
optarg = av[optind+1];
51
// Use rest of current argument for option's argument
52
optarg = av[optind]+pos+1;
60
if (av[optind][pos] == '\0') {