* Add an option instance to currently parsed group. */
| 723 | * Add an option instance to currently parsed group. |
| 724 | */ |
| 725 | static int add_opt(OptionParseContext *octx, const OptionDef *opt, |
| 726 | const char *key, const char *val) |
| 727 | { |
| 728 | int global = !(opt->flags & OPT_PERFILE); |
| 729 | OptionGroup *g = global ? &octx->global_opts : &octx->cur_group; |
| 730 | int ret; |
| 731 | |
| 732 | ret = GROW_ARRAY(g->opts, g->nb_opts); |
| 733 | if (ret < 0) |
| 734 | return ret; |
| 735 | |
| 736 | g->opts[g->nb_opts - 1].opt = opt; |
| 737 | g->opts[g->nb_opts - 1].key = key; |
| 738 | g->opts[g->nb_opts - 1].val = val; |
| 739 | |
| 740 | return 0; |
| 741 | } |
| 742 | |
| 743 | static int init_parse_context(OptionParseContext *octx, |
| 744 | const OptionGroupDef *groups, int nb_groups) |