21 #define FIX_UNUSED(X) (void) (X)  
   28 const 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.";
 
   32 const char *gengetopt_args_info_versiontext = 
"";
 
   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;
 
   66 gengetopt_strdup (
const char *s);
 
   86   FIX_UNUSED (args_info);
 
  123   if (strlen(gengetopt_args_info_versiontext) > 0)
 
  124     printf(
"\n%s\n", gengetopt_args_info_versiontext);
 
  127 static void print_help_common(
void)
 
  135         if (len_purpose > 0) {
 
  139         if (len_usage || len_purpose) {
 
  160   clear_given (args_info);
 
  161   clear_args (args_info);
 
  162   init_args_info (args_info);
 
  191 free_string_field (
char **s)
 
  210     free (args_info->
inputs [i]);
 
  215   clear_given (args_info);
 
  220 write_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);
 
  296 gengetopt_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);
 
  363 static char *package_name = 0;
 
  384 int 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);
 
  467 cmdline_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);
 
  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);