15
18
#endif /* __cplusplus */
17
20
#ifndef CMDLINE_PARSER_PACKAGE
21
/** @brief the program name */
18
22
#define CMDLINE_PARSER_PACKAGE PACKAGE
21
25
#ifndef CMDLINE_PARSER_VERSION
26
/** @brief the program version */
22
27
#define CMDLINE_PARSER_VERSION VERSION
30
/** @brief Where the command line options are stored */
25
31
struct gengetopt_args_info
27
char * import_format_arg; /* Force the file format of the file(s) specified (default='AUTODETECT'). */
28
int msg_parser_flag; /* Output file parsing messages (default=off). */
29
int msg_debug_flag; /* Output messages meant for debuging (default=off). */
30
int msg_warning_flag; /* Output warning messages about abnormal conditions and unknown constructs (default=on). */
31
int msg_error_flag; /* Output error messages (default=on). */
32
int msg_info_flag; /* Output informational messages about the progress of the library (default=on). */
33
int msg_status_flag; /* Output status messages (default=on). */
35
int help_given ; /* Whether help was given. */
36
int version_given ; /* Whether version was given. */
37
int import_format_given ; /* Whether import-format was given. */
38
int list_import_formats_given ; /* Whether list-import-formats was given. */
39
int msg_parser_given ; /* Whether msg_parser was given. */
40
int msg_debug_given ; /* Whether msg_debug was given. */
41
int msg_warning_given ; /* Whether msg_warning was given. */
42
int msg_error_given ; /* Whether msg_error was given. */
43
int msg_info_given ; /* Whether msg_info was given. */
44
int msg_status_given ; /* Whether msg_status was given. */
46
char **inputs ; /* unamed options */
47
unsigned inputs_num ; /* unamed options number */
50
int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info);
33
const char *help_help; /**< @brief Print help and exit help description. */
34
const char *version_help; /**< @brief Print version and exit help description. */
35
char * import_format_arg; /**< @brief Force the file format of the file(s) specified (default='AUTODETECT'). */
36
char * import_format_orig; /**< @brief Force the file format of the file(s) specified original value given at command line. */
37
const char *import_format_help; /**< @brief Force the file format of the file(s) specified help description. */
38
const char *list_import_formats_help; /**< @brief List available import file formats 'import-format' command help description. */
39
int msg_parser_flag; /**< @brief Output file parsing messages (default=off). */
40
const char *msg_parser_help; /**< @brief Output file parsing messages help description. */
41
int msg_debug_flag; /**< @brief Output messages meant for debuging (default=off). */
42
const char *msg_debug_help; /**< @brief Output messages meant for debuging help description. */
43
int msg_warning_flag; /**< @brief Output warning messages about abnormal conditions and unknown constructs (default=on). */
44
const char *msg_warning_help; /**< @brief Output warning messages about abnormal conditions and unknown constructs help description. */
45
int msg_error_flag; /**< @brief Output error messages (default=on). */
46
const char *msg_error_help; /**< @brief Output error messages help description. */
47
int msg_info_flag; /**< @brief Output informational messages about the progress of the library (default=on). */
48
const char *msg_info_help; /**< @brief Output informational messages about the progress of the library help description. */
49
int msg_status_flag; /**< @brief Output status messages (default=on). */
50
const char *msg_status_help; /**< @brief Output status messages help description. */
52
int help_given ; /**< @brief Whether help was given. */
53
int version_given ; /**< @brief Whether version was given. */
54
int import_format_given ; /**< @brief Whether import-format was given. */
55
int list_import_formats_given ; /**< @brief Whether list-import-formats was given. */
56
int msg_parser_given ; /**< @brief Whether msg_parser was given. */
57
int msg_debug_given ; /**< @brief Whether msg_debug was given. */
58
int msg_warning_given ; /**< @brief Whether msg_warning was given. */
59
int msg_error_given ; /**< @brief Whether msg_error was given. */
60
int msg_info_given ; /**< @brief Whether msg_info was given. */
61
int msg_status_given ; /**< @brief Whether msg_status was given. */
63
char **inputs ; /**< @brief unamed options (options without names) */
64
unsigned inputs_num ; /**< @brief unamed options number */
67
/** @brief The additional parameters to pass to parser functions */
68
struct cmdline_parser_params
70
int override; /**< @brief whether to override possibly already present options (default 0) */
71
int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 0) */
72
int check_required; /**< @brief whether to check that all required options were provided (default 0) */
73
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
76
/** @brief the purpose string of the program */
77
extern const char *gengetopt_args_info_purpose;
78
/** @brief the usage string of the program */
79
extern const char *gengetopt_args_info_usage;
80
/** @brief all the lines making the help output */
81
extern const char *gengetopt_args_info_help[];
84
* The command line parser
85
* @param argc the number of command line options
86
* @param argv the command line options
87
* @param args_info the structure where option information will be stored
88
* @return 0 if everything went fine, NON 0 if an error took place
90
int cmdline_parser (int argc, char * const *argv,
91
struct gengetopt_args_info *args_info);
94
* The command line parser (version with additional parameters - deprecated)
95
* @param argc the number of command line options
96
* @param argv the command line options
97
* @param args_info the structure where option information will be stored
98
* @param override whether to override possibly already present options
99
* @param initialize whether to initialize the option structure my_args_info
100
* @param check_required whether to check that all required options were provided
101
* @return 0 if everything went fine, NON 0 if an error took place
102
* @deprecated use cmdline_parser_ext() instead
104
int cmdline_parser2 (int argc, char * const *argv,
105
struct gengetopt_args_info *args_info,
106
int override, int initialize, int check_required);
109
* The command line parser (version with additional parameters)
110
* @param argc the number of command line options
111
* @param argv the command line options
112
* @param args_info the structure where option information will be stored
113
* @param params additional parameters for the parser
114
* @return 0 if everything went fine, NON 0 if an error took place
116
int cmdline_parser_ext (int argc, char * const *argv,
117
struct gengetopt_args_info *args_info,
118
struct cmdline_parser_params *params);
121
* Save the contents of the option struct into a (text) file.
122
* This file can be read by the config file parser (if generated by gengetopt)
123
* @param filename the file where to save
124
* @param args_info the option struct to save
125
* @return 0 if everything went fine, NON 0 if an error took place
127
int cmdline_parser_file_save(const char *filename,
128
struct gengetopt_args_info *args_info);
52
133
void cmdline_parser_print_help(void);
53
137
void cmdline_parser_print_version(void);
140
* Allocates dynamically a cmdline_parser_params structure and initializes
141
* all its fields to 0
142
* @return the initialized cmdline_parser_params structure
144
struct cmdline_parser_params *cmdline_parser_params_init();
147
* Initializes the passed gengetopt_args_info structure's fields
148
* (also set default values for options that have a default)
149
* @param args_info the structure to initialize
151
void cmdline_parser_init (struct gengetopt_args_info *args_info);
153
* Deallocates the string fields of the gengetopt_args_info structure
154
* (but does not deallocate the structure itself)
155
* @param args_info the structure to deallocate
157
void cmdline_parser_free (struct gengetopt_args_info *args_info);
160
* Checks that all the required options were specified
161
* @param args_info the structure to check
162
* @param prog_name the name of the program that will be used to print
166
int cmdline_parser_required (struct gengetopt_args_info *args_info,
167
const char *prog_name);
55
170
#ifdef __cplusplus
57
172
#endif /* __cplusplus */