Lines Matching refs:gof

130 static int gotflag(struct getoptflagstate *gof, struct opts *opt)  in gotflag()  argument
136 if (gof->noerror) return 1; in gotflag()
137 error_exit("Unknown option %s", gof->arg); in gotflag()
146 for (clr=gof->opts, i=1; clr; clr = clr->next, i<<=1) in gotflag()
153 gof->excludes |= opt->dex[2]; in gotflag()
154 if (opt->flags&2) gof->stopearly=2; in gotflag()
156 if (toys.optflags & gof->excludes) { in gotflag()
160 for (bad=gof->opts, i=1; ;bad = bad->next, i<<=1) { in gotflag()
168 if (!gof->arg) { in gotflag()
170 gof->arg = ""; in gotflag()
171 } else gof->arg++; in gotflag()
176 char *arg = gof->arg; in gotflag()
182 if (gof->nodash_now || (!arg[0] && !(opt->flags & 8))) in gotflag()
183 arg = toys.argv[++gof->argc]; in gotflag()
190 for (lo = gof->longopts; lo->opt != opt; lo = lo->next); in gotflag()
219 if (!gof->nodash_now) gof->arg = ""; in gotflag()
227 void parse_optflaglist(struct getoptflagstate *gof) in parse_optflaglist() argument
235 memset(gof, 0, sizeof(struct getoptflagstate)); in parse_optflaglist()
236 gof->maxargs = INT_MAX; in parse_optflaglist()
241 if (*options == '^') gof->stopearly++; in parse_optflaglist()
242 else if (*options == '<') gof->minargs=*(++options)-'0'; in parse_optflaglist()
243 else if (*options == '>') gof->maxargs=*(++options)-'0'; in parse_optflaglist()
244 else if (*options == '?') gof->noerror++; in parse_optflaglist()
245 else if (*options == '&') gof->nodash++; in parse_optflaglist()
252 if (!*options) gof->stopearly++; in parse_optflaglist()
262 new->next = gof->opts; in parse_optflaglist()
263 gof->opts = new; in parse_optflaglist()
279 lo->next = gof->longopts; in parse_optflaglist()
283 gof->longopts = lo; in parse_optflaglist()
326 for (new = gof->opts; new; new = new->next) { in parse_optflaglist()
331 if (new->flags & 1) gof->requires |= u; in parse_optflaglist()
356 for (i=0, opt = gof->opts; ; i++, opt = opt->next) { in parse_optflaglist()
377 struct getoptflagstate gof; in get_optflags() local
391 parse_optflaglist(&gof); in get_optflags()
394 for (gof.argc=1; toys.argv[gof.argc]; gof.argc++) { in get_optflags()
395 gof.arg = toys.argv[gof.argc]; in get_optflags()
399 if (gof.stopearly>1) goto notflag; in get_optflags()
401 gof.nodash_now = 0; in get_optflags()
404 if (*gof.arg == '-') { in get_optflags()
407 if (!gof.arg[1]) goto notflag; in get_optflags()
408 gof.arg++; in get_optflags()
409 if (*gof.arg=='-') { in get_optflags()
412 gof.arg++; in get_optflags()
414 if (!*gof.arg) { in get_optflags()
415 gof.stopearly += 2; in get_optflags()
420 for (lo = gof.longopts; lo; lo = lo->next) { in get_optflags()
421 if (!strncmp(gof.arg, lo->str, lo->len)) { in get_optflags()
422 if (!gof.arg[lo->len]) gof.arg = 0; in get_optflags()
423 else if (gof.arg[lo->len] == '=' && lo->opt->type) in get_optflags()
424 gof.arg += lo->len; in get_optflags()
433 if (!lo && gof.noerror) { in get_optflags()
434 gof.arg -= 2; in get_optflags()
439 gotflag(&gof, catch); in get_optflags()
445 if (gof.nodash && (gof.nodash>1 || gof.argc == 1)) gof.nodash_now = 1; in get_optflags()
452 while (*gof.arg) { in get_optflags()
455 for (catch = gof.opts; catch; catch = catch->next) in get_optflags()
456 if (*gof.arg == catch->c) in get_optflags()
457 if (!((catch->flags&4) && gof.arg[1])) break; in get_optflags()
460 if (gotflag(&gof, catch) ) { in get_optflags()
462 gof.arg = toys.argv[gof.argc]; in get_optflags()
470 if (gof.stopearly) gof.stopearly++; in get_optflags()
471 toys.optargs[toys.optc++] = toys.argv[gof.argc]; in get_optflags()
475 if (toys.optc<gof.minargs) in get_optflags()
476 error_exit("Need%s %d argument%s", letters[!!(gof.minargs-1)], in get_optflags()
477 gof.minargs, letters[!(gof.minargs-1)]); in get_optflags()
478 if (toys.optc>gof.maxargs) in get_optflags()
479 error_exit("Max %d argument%s", gof.maxargs, letters[!(gof.maxargs-1)]); in get_optflags()
480 if (gof.requires && !(gof.requires & toys.optflags)) { in get_optflags()
484 for (req = gof.opts; req; req = req->next) in get_optflags()
493 llist_traverse(gof.opts, free); in get_optflags()
494 llist_traverse(gof.longopts, free); in get_optflags()