[variadic] Use (char *)0 as last arg, not NULL
[ctxopt.git] / ctxopt.h
blobc758a0e2585c18db36a8a41b56177eed5731e394
1 /* ################################################################### */
2 /* This Source Code Form is subject to the terms of the Mozilla Public */
3 /* License, v. 2.0. If a copy of the MPL was not distributed with this */
4 /* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
5 /* ################################################################### */
7 #ifndef CTXOPT_H
8 #define CTXOPT_H
10 typedef enum
12 parameters,
13 constraints,
14 actions,
15 incompatibilities,
16 error_functions,
17 before,
18 after,
19 } settings;
21 typedef enum
23 entering,
24 exiting
25 } direction;
27 typedef enum
29 CTXOPTNOERR = 0,
30 CTXOPTMISPAR,
31 CTXOPTMISARG,
32 CTXOPTDUPOPT,
33 CTXOPTUNKPAR,
34 CTXOPTINCOPT,
35 CTXOPTCTEOPT,
36 CTXOPTCTLOPT,
37 CTXOPTCTGOPT,
38 CTXOPTCTEARG,
39 CTXOPTCTLARG,
40 CTXOPTCTGARG,
41 CTXOPTUNXARG,
42 CTXOPTERRSIZ
43 } errors;
45 typedef enum
47 continue_after,
48 exit_after
49 } usage_behaviour;
51 typedef struct state_s
53 char * prog_name; /* base name of the program name. */
54 char * ctx_name; /* current context name. */
55 char * ctx_par_name; /* parameter which led to this context. */
56 char * opt_name; /* current option name. */
57 int opts_count; /* limit of the number of occurrences of *
58 | the current option. */
59 int opt_args_count; /* limit of the number of parameters of *
60 | the current option. */
61 char * pre_opt_par_name; /* parameter before the current one. */
62 char * cur_opt_par_name; /* current parameter. */
63 char * cur_opt_params; /* All the option's parameters. */
64 } state_t;
66 void
67 ctxopt_init(char * prog_name, char * flags);
69 void
70 ctxopt_analyze(int nb_words, char ** words, int * rem_count, char *** rem_args);
72 void
73 ctxopt_evaluate(void);
75 void
76 ctxopt_new_ctx(char * name, char * opts_specs);
78 void
79 ctxopt_ctx_disp_usage(char * ctx_name, usage_behaviour action);
81 void
82 ctxopt_disp_usage(usage_behaviour action);
84 void
85 ctxopt_add_global_settings(settings s, ...);
87 void
88 ctxopt_add_ctx_settings(settings s, ...);
90 void
91 ctxopt_add_opt_settings(settings s, ...);
93 int
94 ctxopt_format_constraint(int nb_args, char ** args, char * value, char * par);
96 int
97 ctxopt_re_constraint(int nb_args, char ** args, char * value, char * par);
99 int
100 ctxopt_range_constraint(int nb_args, char ** args, char * value, char * par);
102 void
103 ctxopt_free_memory(void);
105 #endif