]> Creatis software - clitk.git/blob - utilities/gengetopt/cmdline.h
Debug RTStruct conversion with empty struc
[clitk.git] / utilities / gengetopt / cmdline.h
1 /** @file cmdline.h
2  *  @brief The header file for the command line option parser
3  *  generated by GNU Gengetopt version 2.22.4
4  *  http://www.gnu.org/software/gengetopt.
5  *  DO NOT modify this file, since it can be overwritten
6  *  @author GNU Gengetopt by Lorenzo Bettini */
7
8 #ifndef CMDLINE_H
9 #define CMDLINE_H
10
11 /* If we use autoconf.  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <stdio.h> /* for FILE */
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 #ifndef CMDLINE_PARSER_PACKAGE
23 /** @brief the program name (used for printing errors) */
24 #define CMDLINE_PARSER_PACKAGE PACKAGE
25 #endif
26
27 #ifndef CMDLINE_PARSER_PACKAGE_NAME
28 /** @brief the complete program name (used for help and version) */
29 #ifdef PACKAGE_NAME
30 #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE_NAME
31 #else
32 #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE
33 #endif
34 #endif
35
36 #ifndef CMDLINE_PARSER_VERSION
37 /** @brief the program version */
38 #define CMDLINE_PARSER_VERSION VERSION
39 #endif
40
41 /** @brief Where the command line options are stored */
42 struct gengetopt_args_info
43 {
44   const char *help_help; /**< @brief Print help and exit help description.  */
45   const char *detailed_help_help; /**< @brief Print help, including all details and hidden options, and exit help description.  */
46   const char *version_help; /**< @brief Print version and exit help description.  */
47   char * input_arg;     /**< @brief input file (default std input).  */
48   char * input_orig;    /**< @brief input file (default std input) original value given at command line.  */
49   const char *input_help; /**< @brief input file (default std input) help description.  */
50   char * func_name_arg; /**< @brief name of generated function (default='cmdline_parser').  */
51   char * func_name_orig;        /**< @brief name of generated function original value given at command line.  */
52   const char *func_name_help; /**< @brief name of generated function help description.  */
53   char * arg_struct_name_arg;   /**< @brief name of generated args info struct (default='gengetopt_args_info').  */
54   char * arg_struct_name_orig;  /**< @brief name of generated args info struct original value given at command line.  */
55   const char *arg_struct_name_help; /**< @brief name of generated args info struct help description.  */
56   char * file_name_arg; /**< @brief name of generated file (default='cmdline').  */
57   char * file_name_orig;        /**< @brief name of generated file original value given at command line.  */
58   const char *file_name_help; /**< @brief name of generated file help description.  */
59   char * output_dir_arg;        /**< @brief output directory.  */
60   char * output_dir_orig;       /**< @brief output directory original value given at command line.  */
61   const char *output_dir_help; /**< @brief output directory help description.  */
62   char * header_output_dir_arg; /**< @brief header output directory.  */
63   char * header_output_dir_orig;        /**< @brief header output directory original value given at command line.  */
64   const char *header_output_dir_help; /**< @brief header output directory help description.  */
65   char * src_output_dir_arg;    /**< @brief source output directory.  */
66   char * src_output_dir_orig;   /**< @brief source output directory original value given at command line.  */
67   const char *src_output_dir_help; /**< @brief source output directory help description.  */
68   char * c_extension_arg;       /**< @brief extension of c file (default='c').  */
69   char * c_extension_orig;      /**< @brief extension of c file original value given at command line.  */
70   const char *c_extension_help; /**< @brief extension of c file help description.  */
71   char * header_extension_arg;  /**< @brief extension of header file (default='h').  */
72   char * header_extension_orig; /**< @brief extension of header file original value given at command line.  */
73   const char *header_extension_help; /**< @brief extension of header file help description.  */
74   const char *long_help_help; /**< @brief long usage line in help help description.  */
75   const char *default_optional_help; /**< @brief by default, an option is considered optional if not specified otherwise help description.  */
76   char * unamed_opts_arg;       /**< @brief accept options without names (e.g., file names) (default='FILES').  */
77   char * unamed_opts_orig;      /**< @brief accept options without names (e.g., file names) original value given at command line.  */
78   const char *unamed_opts_help; /**< @brief accept options without names (e.g., file names) help description.  */
79   const char *conf_parser_help; /**< @brief generate a config file parser help description.  */
80   const char *string_parser_help; /**< @brief generate a string parser (the string contains the command line) help description.  */
81   const char *include_getopt_help; /**< @brief adds the code for getopt_long in the generated C file help description.  */
82   const char *no_handle_help_help; /**< @brief do not handle --help|-h automatically help description.  */
83   const char *no_help_help; /**< @brief do not add --help|-h automatically help description.  */
84   const char *no_handle_version_help; /**< @brief do not handle --version|-V automatically help description.  */
85   const char *no_version_help; /**< @brief do not add --version|-V automatically help description.  */
86   const char *no_handle_error_help; /**< @brief do not exit on errors help description.  */
87   char * show_required_arg;     /**< @brief in the output of help will specify which options are mandatory, by using the optional passed string (default='(mandatory)').  */
88   char * show_required_orig;    /**< @brief in the output of help will specify which options are mandatory, by using the optional passed string original value given at command line.  */
89   const char *show_required_help; /**< @brief in the output of help will specify which options are mandatory, by using the optional passed string help description.  */
90   int gen_version_flag; /**< @brief put gengetopt version in the generated file (default=on).  */
91   const char *gen_version_help; /**< @brief put gengetopt version in the generated file help description.  */
92   char * set_package_arg;       /**< @brief set the package name (override package defined in the .ggo file).  */
93   char * set_package_orig;      /**< @brief set the package name (override package defined in the .ggo file) original value given at command line.  */
94   const char *set_package_help; /**< @brief set the package name (override package defined in the .ggo file) help description.  */
95   char * set_version_arg;       /**< @brief set the version number (override version defined in the .ggo file).  */
96   char * set_version_orig;      /**< @brief set the version number (override version defined in the .ggo file) original value given at command line.  */
97   const char *set_version_help; /**< @brief set the version number (override version defined in the .ggo file) help description.  */
98   const char *show_help_help; /**< @brief show the output of --help instead of generating code help description.  */
99   const char *show_full_help_help; /**< @brief show the output of --full-help (i.e., including hidden options) instead of generating code help description.  */
100   const char *show_detailed_help_help; /**< @brief show the output of --detailed-help (i.e., including details and hidden options) instead of generating code help description.  */
101   const char *show_version_help; /**< @brief show the output of --version instead of generating code help description.  */
102   
103   unsigned int help_given ;     /**< @brief Whether help was given.  */
104   unsigned int detailed_help_given ;    /**< @brief Whether detailed-help was given.  */
105   unsigned int version_given ;  /**< @brief Whether version was given.  */
106   unsigned int input_given ;    /**< @brief Whether input was given.  */
107   unsigned int func_name_given ;        /**< @brief Whether func-name was given.  */
108   unsigned int arg_struct_name_given ;  /**< @brief Whether arg-struct-name was given.  */
109   unsigned int file_name_given ;        /**< @brief Whether file-name was given.  */
110   unsigned int output_dir_given ;       /**< @brief Whether output-dir was given.  */
111   unsigned int header_output_dir_given ;        /**< @brief Whether header-output-dir was given.  */
112   unsigned int src_output_dir_given ;   /**< @brief Whether src-output-dir was given.  */
113   unsigned int c_extension_given ;      /**< @brief Whether c-extension was given.  */
114   unsigned int header_extension_given ; /**< @brief Whether header-extension was given.  */
115   unsigned int long_help_given ;        /**< @brief Whether long-help was given.  */
116   unsigned int default_optional_given ; /**< @brief Whether default-optional was given.  */
117   unsigned int unamed_opts_given ;      /**< @brief Whether unamed-opts was given.  */
118   unsigned int conf_parser_given ;      /**< @brief Whether conf-parser was given.  */
119   unsigned int string_parser_given ;    /**< @brief Whether string-parser was given.  */
120   unsigned int include_getopt_given ;   /**< @brief Whether include-getopt was given.  */
121   unsigned int no_handle_help_given ;   /**< @brief Whether no-handle-help was given.  */
122   unsigned int no_help_given ;  /**< @brief Whether no-help was given.  */
123   unsigned int no_handle_version_given ;        /**< @brief Whether no-handle-version was given.  */
124   unsigned int no_version_given ;       /**< @brief Whether no-version was given.  */
125   unsigned int no_handle_error_given ;  /**< @brief Whether no-handle-error was given.  */
126   unsigned int show_required_given ;    /**< @brief Whether show-required was given.  */
127   unsigned int gen_version_given ;      /**< @brief Whether gen-version was given.  */
128   unsigned int set_package_given ;      /**< @brief Whether set-package was given.  */
129   unsigned int set_version_given ;      /**< @brief Whether set-version was given.  */
130   unsigned int show_help_given ;        /**< @brief Whether show-help was given.  */
131   unsigned int show_full_help_given ;   /**< @brief Whether show-full-help was given.  */
132   unsigned int show_detailed_help_given ;       /**< @brief Whether show-detailed-help was given.  */
133   unsigned int show_version_given ;     /**< @brief Whether show-version was given.  */
134
135 } ;
136
137 /** @brief The additional parameters to pass to parser functions */
138 struct cmdline_parser_params
139 {
140   int override; /**< @brief whether to override possibly already present options (default 0) */
141   int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
142   int check_required; /**< @brief whether to check that all required options were provided (default 1) */
143   int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
144   int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
145 } ;
146
147 /** @brief the purpose string of the program */
148 extern const char *gengetopt_args_info_purpose;
149 /** @brief the usage string of the program */
150 extern const char *gengetopt_args_info_usage;
151 /** @brief all the lines making the help output */
152 extern const char *gengetopt_args_info_help[];
153 /** @brief all the lines making the detailed help output (including hidden options and details) */
154 extern const char *gengetopt_args_info_detailed_help[];
155
156 /**
157  * The command line parser
158  * @param argc the number of command line options
159  * @param argv the command line options
160  * @param args_info the structure where option information will be stored
161  * @return 0 if everything went fine, NON 0 if an error took place
162  */
163 int cmdline_parser (int argc, char **argv,
164   struct gengetopt_args_info *args_info);
165
166 /**
167  * The command line parser (version with additional parameters - deprecated)
168  * @param argc the number of command line options
169  * @param argv the command line options
170  * @param args_info the structure where option information will be stored
171  * @param override whether to override possibly already present options
172  * @param initialize whether to initialize the option structure my_args_info
173  * @param check_required whether to check that all required options were provided
174  * @return 0 if everything went fine, NON 0 if an error took place
175  * @deprecated use cmdline_parser_ext() instead
176  */
177 int cmdline_parser2 (int argc, char **argv,
178   struct gengetopt_args_info *args_info,
179   int override, int initialize, int check_required);
180
181 /**
182  * The command line parser (version with additional parameters)
183  * @param argc the number of command line options
184  * @param argv the command line options
185  * @param args_info the structure where option information will be stored
186  * @param params additional parameters for the parser
187  * @return 0 if everything went fine, NON 0 if an error took place
188  */
189 int cmdline_parser_ext (int argc, char **argv,
190   struct gengetopt_args_info *args_info,
191   struct cmdline_parser_params *params);
192
193 /**
194  * Save the contents of the option struct into an already open FILE stream.
195  * @param outfile the stream where to dump options
196  * @param args_info the option struct to dump
197  * @return 0 if everything went fine, NON 0 if an error took place
198  */
199 int cmdline_parser_dump(FILE *outfile,
200   struct gengetopt_args_info *args_info);
201
202 /**
203  * Save the contents of the option struct into a (text) file.
204  * This file can be read by the config file parser (if generated by gengetopt)
205  * @param filename the file where to save
206  * @param args_info the option struct to save
207  * @return 0 if everything went fine, NON 0 if an error took place
208  */
209 int cmdline_parser_file_save(const char *filename,
210   struct gengetopt_args_info *args_info);
211
212 /**
213  * Print the help
214  */
215 void cmdline_parser_print_help(void);
216 /**
217  * Print the detailed help (including hidden options and details)
218  */
219 void cmdline_parser_print_detailed_help(void);
220 /**
221  * Print the version
222  */
223 void cmdline_parser_print_version(void);
224
225 /**
226  * Initializes all the fields a cmdline_parser_params structure 
227  * to their default values
228  * @param params the structure to initialize
229  */
230 void cmdline_parser_params_init(struct cmdline_parser_params *params);
231
232 /**
233  * Allocates dynamically a cmdline_parser_params structure and initializes
234  * all its fields to their default values
235  * @return the created and initialized cmdline_parser_params structure
236  */
237 struct cmdline_parser_params *cmdline_parser_params_create(void);
238
239 /**
240  * Initializes the passed gengetopt_args_info structure's fields
241  * (also set default values for options that have a default)
242  * @param args_info the structure to initialize
243  */
244 void cmdline_parser_init (struct gengetopt_args_info *args_info);
245 /**
246  * Deallocates the string fields of the gengetopt_args_info structure
247  * (but does not deallocate the structure itself)
248  * @param args_info the structure to deallocate
249  */
250 void cmdline_parser_free (struct gengetopt_args_info *args_info);
251
252 /**
253  * The string parser (interprets the passed string as a command line)
254  * @param cmdline the command line stirng
255  * @param args_info the structure where option information will be stored
256  * @param prog_name the name of the program that will be used to print
257  *   possible errors
258  * @return 0 if everything went fine, NON 0 if an error took place
259  */
260 int cmdline_parser_string (const char *cmdline, struct gengetopt_args_info *args_info,
261   const char *prog_name);
262 /**
263  * The string parser (version with additional parameters - deprecated)
264  * @param cmdline the command line stirng
265  * @param args_info the structure where option information will be stored
266  * @param prog_name the name of the program that will be used to print
267  *   possible errors
268  * @param override whether to override possibly already present options
269  * @param initialize whether to initialize the option structure my_args_info
270  * @param check_required whether to check that all required options were provided
271  * @return 0 if everything went fine, NON 0 if an error took place
272  * @deprecated use cmdline_parser_string_ext() instead
273  */
274 int cmdline_parser_string2 (const char *cmdline, struct gengetopt_args_info *args_info,
275   const char *prog_name,
276   int override, int initialize, int check_required);
277 /**
278  * The string parser (version with additional parameters)
279  * @param cmdline the command line stirng
280  * @param args_info the structure where option information will be stored
281  * @param prog_name the name of the program that will be used to print
282  *   possible errors
283  * @param params additional parameters for the parser
284  * @return 0 if everything went fine, NON 0 if an error took place
285  */
286 int cmdline_parser_string_ext (const char *cmdline, struct gengetopt_args_info *args_info,
287   const char *prog_name,
288   struct cmdline_parser_params *params);
289
290 /**
291  * Checks that all the required options were specified
292  * @param args_info the structure to check
293  * @param prog_name the name of the program that will be used to print
294  *   possible errors
295  * @return
296  */
297 int cmdline_parser_required (struct gengetopt_args_info *args_info,
298   const char *prog_name);
299
300
301 #ifdef __cplusplus
302 }
303 #endif /* __cplusplus */
304 #endif /* CMDLINE_H */