21#define FIX_UNUSED(X) (void) (X)
28const char *gengetopt_args_info_purpose =
"ofxdump prints to stdout, in human readable form, everything the library \nunderstands about a particular file or response, and sends errors to\nstderr. To know exactly what the library understands about of a particular\nofx response file, just call ofxdump on that file.";
32const char *gengetopt_args_info_versiontext =
"";
34const char *gengetopt_args_info_description =
"";
36const char *gengetopt_args_info_help[] = {
37 " -h, --help Print help and exit",
38 " -V, --version Print version and exit",
39 " -f, --import-format=STRING Force the file format of the file(s) specified\n (default=`AUTODETECT')",
40 " --list-import-formats List available import file formats\n 'import-format' command",
41 " --msg_parser Output file parsing messages (default=off)",
42 " --msg_debug Output messages meant for debugging\n (default=off)",
43 " --msg_warning Output warning messages about abnormal conditions\n and unknown constructs (default=on)",
44 " --msg_error Output error messages (default=on)",
45 " --msg_info Output informational messages about the progress\n of the library (default=on)",
46 " --msg_status Output status messages (default=on)",
53} cmdline_parser_arg_type;
66gengetopt_strdup (
const char *s);
86 FIX_UNUSED (args_info);
103 args_info->
help_help = gengetopt_args_info_help[0] ;
117cmdline_parser_print_version (
void)
123 if (strlen(gengetopt_args_info_versiontext) > 0)
124 printf(
"\n%s\n", gengetopt_args_info_versiontext);
127static void print_help_common(
void)
129 size_t len_purpose = strlen(gengetopt_args_info_purpose);
130 size_t len_usage = strlen(gengetopt_args_info_usage);
133 printf(
"%s\n", gengetopt_args_info_usage);
135 if (len_purpose > 0) {
136 printf(
"%s\n", gengetopt_args_info_purpose);
139 if (len_usage || len_purpose) {
143 if (strlen(gengetopt_args_info_description) > 0) {
144 printf(
"%s\n\n", gengetopt_args_info_description);
149cmdline_parser_print_help (
void)
153 while (gengetopt_args_info_help[i])
154 printf(
"%s\n", gengetopt_args_info_help[i++]);
160 clear_given (args_info);
161 clear_args (args_info);
162 init_args_info (args_info);
191free_string_field (
char **s)
210 free (args_info->
inputs [i]);
215 clear_given (args_info);
220write_into_file(FILE *outfile,
const char *opt,
const char *arg,
const char *values[])
224 fprintf(outfile,
"%s=\"%s\"\n", opt, arg);
226 fprintf(outfile,
"%s\n", opt);
243 write_into_file(outfile,
"help", 0, 0 );
245 write_into_file(outfile,
"version", 0, 0 );
249 write_into_file(outfile,
"list-import-formats", 0, 0 );
251 write_into_file(outfile,
"msg_parser", 0, 0 );
253 write_into_file(outfile,
"msg_debug", 0, 0 );
255 write_into_file(outfile,
"msg_warning", 0, 0 );
257 write_into_file(outfile,
"msg_error", 0, 0 );
259 write_into_file(outfile,
"msg_info", 0, 0 );
261 write_into_file(outfile,
"msg_status", 0, 0 );
274 outfile = fopen(filename,
"w");
291 cmdline_parser_release (args_info);
296gengetopt_strdup (
const char *s)
302 result = (
char*)malloc(strlen(s) + 1);
303 if (result == (
char*)0)
320 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
322 if (result == EXIT_FAILURE)
343 result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
345 if (result == EXIT_FAILURE)
357 FIX_UNUSED (args_info);
358 FIX_UNUSED (prog_name);
363static char *package_name = 0;
384int update_arg(
void *field,
char **orig_field,
385 unsigned int *field_given,
unsigned int *prev_given,
386 char *value,
const char *possible_values[],
387 const char *default_value,
388 cmdline_parser_arg_type arg_type,
390 int no_free,
int multiple_option,
391 const char *long_opt,
char short_opt,
392 const char *additional_error)
395 const char *val = value;
403 if (!multiple_option && prev_given && (*prev_given || (
check_ambiguity && *field_given)))
405 if (short_opt !=
'-')
406 fprintf (stderr,
"%s: `--%s' (`-%c') option given more than once%s\n",
407 package_name, long_opt, short_opt,
408 (additional_error ? additional_error :
""));
410 fprintf (stderr,
"%s: `--%s' option given more than once%s\n",
411 package_name, long_opt,
412 (additional_error ? additional_error :
""));
416 FIX_UNUSED (default_value);
418 if (field_given && *field_given && !
override)
425 val = possible_values[found];
429 *((
int *)field) = !*((
int *)field);
433 string_field = (
char **)field;
434 if (!no_free && *string_field)
435 free (*string_field);
436 *string_field = gengetopt_strdup (val);
443 FIX_UNUSED(stop_char);
451 if (value && orig_field) {
457 *orig_field = gengetopt_strdup (value);
467cmdline_parser_internal (
473 int error_occurred = 0;
481 package_name = argv[0];
485 FIX_UNUSED(
override);
492 FIX_UNUSED(check_ambiguity);
506 int option_index = 0;
508 static struct option long_options[] = {
509 {
"help", 0, NULL,
'h' },
510 {
"version", 0, NULL,
'V' },
511 {
"import-format", 1, NULL,
'f' },
512 {
"list-import-formats", 0, NULL, 0 },
513 {
"msg_parser", 0, NULL, 0 },
514 {
"msg_debug", 0, NULL, 0 },
515 {
"msg_warning", 0, NULL, 0 },
516 {
"msg_error", 0, NULL, 0 },
517 {
"msg_info", 0, NULL, 0 },
518 {
"msg_status", 0, NULL, 0 },
522 c = getopt_long (argc, argv,
"hVf:", long_options, &option_index);
529 cmdline_parser_print_help ();
530 cmdline_parser_free (&local_args_info);
534 cmdline_parser_print_version ();
535 cmdline_parser_free (&local_args_info);
543 &(local_args_info.import_format_given), optarg, 0,
"AUTODETECT", ARG_STRING,
544 check_ambiguity,
override, 0, 0,
545 "import-format",
'f',
553 if (strcmp (long_options[option_index].name,
"list-import-formats") == 0)
559 &(local_args_info.list_import_formats_given), optarg, 0, 0, ARG_NO,
560 check_ambiguity,
override, 0, 0,
561 "list-import-formats",
'-',
567 else if (strcmp (long_options[option_index].name,
"msg_parser") == 0)
572 &(local_args_info.msg_parser_given), optarg, 0, 0, ARG_FLAG,
573 check_ambiguity,
override, 1, 0,
"msg_parser",
'-',
579 else if (strcmp (long_options[option_index].name,
"msg_debug") == 0)
584 &(local_args_info.msg_debug_given), optarg, 0, 0, ARG_FLAG,
585 check_ambiguity,
override, 1, 0,
"msg_debug",
'-',
591 else if (strcmp (long_options[option_index].name,
"msg_warning") == 0)
596 &(local_args_info.msg_warning_given), optarg, 0, 0, ARG_FLAG,
597 check_ambiguity,
override, 1, 0,
"msg_warning",
'-',
603 else if (strcmp (long_options[option_index].name,
"msg_error") == 0)
608 &(local_args_info.msg_error_given), optarg, 0, 0, ARG_FLAG,
609 check_ambiguity,
override, 1, 0,
"msg_error",
'-',
615 else if (strcmp (long_options[option_index].name,
"msg_info") == 0)
620 &(local_args_info.msg_info_given), optarg, 0, 0, ARG_FLAG,
621 check_ambiguity,
override, 1, 0,
"msg_info",
'-',
627 else if (strcmp (long_options[option_index].name,
"msg_status") == 0)
632 &(local_args_info.msg_status_given), optarg, 0, 0, ARG_FLAG,
633 check_ambiguity,
override, 1, 0,
"msg_status",
'-',
645 fprintf (stderr,
"%s: option unknown: %c%s\n",
CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error :
""));
652 FIX_UNUSED(check_required);
654 cmdline_parser_release (&local_args_info);
656 if ( error_occurred )
657 return (EXIT_FAILURE);
662 int found_prog_name = 0;
669 if (argv[i++] == argv[0]) {
675 args_info->
inputs_num = argc - optind - found_prog_name;
677 (
char **)(malloc ((args_info->
inputs_num)*
sizeof(
char *))) ;
678 while (optind < argc)
679 if (argv[optind++] != argv[0])
680 args_info->
inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
687 cmdline_parser_release (&local_args_info);
688 return (EXIT_FAILURE);
#define CMDLINE_PARSER_VERSION
the program version
#define CMDLINE_PARSER_PACKAGE_NAME
the complete program name (used for help and version)
#define CMDLINE_PARSER_PACKAGE
the program name (used for printing errors)
The header file for the command line option parser generated by GNU Gengetopt version 2....
int cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
int cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info)
int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
int cmdline_parser2(int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
int cmdline_parser_required(struct gengetopt_args_info *args_info, const char *prog_name)
struct cmdline_parser_params * cmdline_parser_params_create(void)
int cmdline_parser_ext(int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params)
void cmdline_parser_init(struct gengetopt_args_info *args_info)
void cmdline_parser_free(struct gengetopt_args_info *args_info)
void cmdline_parser_params_init(struct cmdline_parser_params *params)
The additional parameters to pass to parser functions.
int print_errors
whether getopt_long should print an error message for a bad option (default 1)
int check_required
whether to check that all required options were provided (default 1)
int check_ambiguity
whether to check for options already specified in the option structure gengetopt_args_info (default 0...
int initialize
whether to initialize the option structure gengetopt_args_info (default 1)
int override
whether to override possibly already present options (default 0)
Where the command line options are stored.
const char * msg_error_help
Output error messages help description.
int msg_status_flag
Output status messages (default=on).
const char * msg_info_help
Output informational messages about the progress of the library help description.
unsigned int list_import_formats_given
Whether list-import-formats was given.
char * import_format_orig
Force the file format of the file(s) specified original value given at command line.
unsigned inputs_num
unnamed options number
const char * msg_parser_help
Output file parsing messages help description.
unsigned int import_format_given
Whether import-format was given.
unsigned int msg_info_given
Whether msg_info was given.
const char * msg_status_help
Output status messages help description.
int msg_parser_flag
Output file parsing messages (default=off).
const char * help_help
Print help and exit help description.
const char * import_format_help
Force the file format of the file(s) specified help description.
int msg_debug_flag
Output messages meant for debugging (default=off).
char ** inputs
unnamed options (options without names)
const char * msg_debug_help
Output messages meant for debugging help description.
int msg_info_flag
Output informational messages about the progress of the library (default=on).
int msg_warning_flag
Output warning messages about abnormal conditions and unknown constructs (default=on).
unsigned int msg_debug_given
Whether msg_debug was given.
int msg_error_flag
Output error messages (default=on).
const char * msg_warning_help
Output warning messages about abnormal conditions and unknown constructs help description.
unsigned int help_given
Whether help was given.
unsigned int msg_error_given
Whether msg_error was given.
const char * list_import_formats_help
List available import file formats 'import-format' command help description.
unsigned int version_given
Whether version was given.
const char * version_help
Print version and exit help description.
unsigned int msg_parser_given
Whether msg_parser was given.
unsigned int msg_status_given
Whether msg_status was given.
unsigned int msg_warning_given
Whether msg_warning was given.
char * import_format_arg
Force the file format of the file(s) specified (default='AUTODETECT').