Lines Matching refs:options
345 static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options) in parse_short_opt() argument
348 for (; options->type != OPTION_END; options++) { in parse_short_opt()
349 if (options->short_name == *p->opt) { in parse_short_opt()
351 return get_value(p, options, OPT_SHORT); in parse_short_opt()
355 if (options->parent) { in parse_short_opt()
356 options = options->parent; in parse_short_opt()
364 const struct option *options) in parse_long_opt() argument
374 for (; options->type != OPTION_END; options++) { in parse_long_opt()
378 if (!options->long_name) in parse_long_opt()
381 rest = skip_prefix(arg, options->long_name); in parse_long_opt()
382 if (options->type == OPTION_ARGUMENT) { in parse_long_opt()
386 return opterror(options, "takes no value", flags); in parse_long_opt()
393 if (strstarts(options->long_name, "no-")) { in parse_long_opt()
400 rest = skip_prefix(arg, options->long_name + 3); in parse_long_opt()
406 if (strstarts(options->long_name + 3, arg)) { in parse_long_opt()
412 if (!strncmp(options->long_name, arg, arg_end - arg)) { in parse_long_opt()
426 abbrev_option = options; in parse_long_opt()
439 rest = skip_prefix(arg + 3, options->long_name); in parse_long_opt()
441 if (!rest && strstarts(options->long_name, arg + 3)) in parse_long_opt()
452 return get_value(p, options, flags); in parse_long_opt()
468 if (options->parent) { in parse_long_opt()
469 options = options->parent; in parse_long_opt()
476 static void check_typos(const char *arg, const struct option *options) in check_typos() argument
486 for (; options->type != OPTION_END; options++) { in check_typos()
487 if (!options->long_name) in check_typos()
489 if (strstarts(options->long_name, arg)) { in check_typos()
515 const struct option *options, in parse_options_step() argument
537 return usage_with_options_internal(usagestr, options, 0, ctx); in parse_options_step()
539 switch (parse_short_opt(ctx, options)) { in parse_options_step()
541 return parse_options_usage(usagestr, options, arg, 1); in parse_options_step()
550 check_typos(arg, options); in parse_options_step()
553 return usage_with_options_internal(usagestr, options, 0, ctx); in parse_options_step()
555 switch (parse_short_opt(ctx, options)) { in parse_options_step()
557 return parse_options_usage(usagestr, options, arg, 1); in parse_options_step()
586 return usage_with_options_internal(usagestr, options, 1, ctx); in parse_options_step()
588 return usage_with_options_internal(usagestr, options, 0, ctx); in parse_options_step()
593 switch (parse_long_opt(ctx, arg, options)) { in parse_options_step()
595 return parse_options_usage(usagestr, options, arg, 0); in parse_options_step()
614 parse_options_usage(usagestr, options, arg, excl_short_opt); in parse_options_step()
618 parse_options_usage(NULL, options, &opt, 1); in parse_options_step()
620 parse_options_usage(NULL, options, ctx->excl_opt->long_name, 0); in parse_options_step()
632 int parse_options_subcommand(int argc, const char **argv, const struct option *options, in parse_options_subcommand() argument
654 switch (parse_options_step(&ctx, options, usagestr)) { in parse_options_subcommand()
660 while (options->type != OPTION_END) { in parse_options_subcommand()
661 if (options->long_name) in parse_options_subcommand()
662 printf("--%s ", options->long_name); in parse_options_subcommand()
663 options++; in parse_options_subcommand()
680 usage_with_options(usagestr, options); in parse_options_subcommand()
686 int parse_options(int argc, const char **argv, const struct option *options, in parse_options() argument
689 return parse_options_subcommand(argc, argv, options, NULL, in parse_options()