1 /* ################################################################### */
2 /* Copyright 2020, Pierre Gentile (p.gen.progs@gmail.com) */
4 /* This Source Code Form is subject to the terms of the Mozilla Public */
5 /* License, v. 2.0. If a copy of the MPL was not distributed with this */
6 /* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 /* ################################################################### */
56 typedef struct state_s
58 char *prog_name
; /* base name of the program name. */
59 char *ctx_name
; /* current context name. */
60 char *ctx_par_name
; /* parameter which led to this context. */
61 char *opt_name
; /* current option name. */
62 int opts_count
; /* limit of the number of occurrences of *
63 | the current option. */
64 int opt_args_count
; /* limit of the number of parameters of *
65 | the current option. */
66 char *pre_opt_par_name
; /* parameter before the current one. */
67 char *cur_opt_par_name
; /* current parameter. */
68 char *cur_opt_params
; /* All the option's parameters. */
69 char *req_opt_par_needed
; /* Option's params in the missing *
70 | required group of optrions. */
71 char *req_opt_par
; /* Option's params of the option which *
72 | required one of the parameter in *
73 | req_opt_par_needed to also be present *
74 | in the current context. */
78 ctxopt_init(char *prog_name
, char *flags
);
81 ctxopt_analyze(int nb_words
, char **words
, int *rem_count
, char ***rem_args
);
84 ctxopt_evaluate(void);
87 ctxopt_new_ctx(char *name
, char *opts_specs
);
90 ctxopt_ctx_disp_usage(char *ctx_name
, usage_behaviour action
);
93 ctxopt_disp_usage(usage_behaviour action
);
96 ctxopt_add_global_settings(settings s
, ...);
99 ctxopt_add_ctx_settings(settings s
, ...);
102 ctxopt_add_opt_settings(settings s
, ...);
105 ctxopt_format_constraint(int nb_args
, char **args
, char *value
, char *par
);
108 ctxopt_re_constraint(int nb_args
, char **args
, char *value
, char *par
);
111 ctxopt_range_constraint(int nb_args
, char **args
, char *value
, char *par
);
114 ctxopt_free_memory(void);