21 #define FIX_UNUSED(X) (void) (X)  
   28 const char *gengetopt_args_info_purpose = 
"prints to stdout the created OFX file based on the options you pass it.\ncurrently it will only create a statement request file.  you can POST this to\nan OFX server to request a statement from that financial institution for that\naccount.";
 
   30 const char *gengetopt_args_info_usage = 
"Usage: " CMDLINE_PARSER_PACKAGE 
" [OPTIONS]... [FILES]...";
 
   32 const char *gengetopt_args_info_versiontext = 
"";
 
   34 const char *gengetopt_args_info_description = 
"";
 
   36 const char *gengetopt_args_info_help[] = {
 
   37   "  -h, --help                Print help and exit",
 
   38   "  -V, --version             Print version and exit",
 
   39   "      --fipid=STRING        FI partner identifier (looks up fid, org & url from\n                              partner server)",
 
   40   "      --fid=STRING          FI identifier",
 
   41   "      --org=STRING          FI org tag",
 
   42   "      --bank=STRING         IBAN bank identifier",
 
   43   "      --broker=STRING       Broker identifier",
 
   44   "      --user=STRING         User name",
 
   45   "      --pass=STRING         Password",
 
   46   "      --acct=STRING         Account ID",
 
   47   "      --type=INT            Account Type 1=checking 2=invest 3=ccard",
 
   48   "      --past=LONG           How far back to look from today (in days)",
 
   49   "      --url=STRING          Url to POST the data to (otherwise goes to stdout)",
 
   50   "      --trid=INT            Transaction id",
 
   52   "  -s, --statement-req       Request for a statement",
 
   53   "  -a, --accountinfo-req     Request for a list of accounts",
 
   54   "  -p, --payment-req         Request to make a payment",
 
   55   "  -i, --paymentinquiry-req  Request to inquire about the status of a payment",
 
   56   "  -b, --bank-list           List all known banks",
 
   57   "  -f, --bank-fipid          List all fipids for a given bank",
 
   58   "  -v, --bank-services       List supported services for a given fipid",
 
   59   "      --allsupport          List all banks which support online banking",
 
   67 } cmdline_parser_arg_type;
 
   80 gengetopt_strdup (
const char *s);
 
  113   FIX_UNUSED (args_info);
 
  143   args_info->
help_help = gengetopt_args_info_help[0] ;
 
  145   args_info->
fipid_help = gengetopt_args_info_help[2] ;
 
  146   args_info->
fid_help = gengetopt_args_info_help[3] ;
 
  147   args_info->
org_help = gengetopt_args_info_help[4] ;
 
  148   args_info->
bank_help = gengetopt_args_info_help[5] ;
 
  149   args_info->
broker_help = gengetopt_args_info_help[6] ;
 
  150   args_info->
user_help = gengetopt_args_info_help[7] ;
 
  151   args_info->
pass_help = gengetopt_args_info_help[8] ;
 
  152   args_info->
acct_help = gengetopt_args_info_help[9] ;
 
  153   args_info->
type_help = gengetopt_args_info_help[10] ;
 
  154   args_info->
past_help = gengetopt_args_info_help[11] ;
 
  155   args_info->
url_help = gengetopt_args_info_help[12] ;
 
  156   args_info->
trid_help = gengetopt_args_info_help[13] ;
 
  169 cmdline_parser_print_version (
void)
 
  172      (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
 
  173      CMDLINE_PARSER_VERSION);
 
  175   if (strlen(gengetopt_args_info_versiontext) > 0)
 
  176     printf(
"\n%s\n", gengetopt_args_info_versiontext);
 
  179 static void print_help_common(
void) {
 
  180   cmdline_parser_print_version ();
 
  182   if (strlen(gengetopt_args_info_purpose) > 0)
 
  183     printf(
"\n%s\n", gengetopt_args_info_purpose);
 
  185   if (strlen(gengetopt_args_info_usage) > 0)
 
  186     printf(
"\n%s\n", gengetopt_args_info_usage);
 
  190   if (strlen(gengetopt_args_info_description) > 0)
 
  191     printf(
"%s\n\n", gengetopt_args_info_description);
 
  195 cmdline_parser_print_help (
void)
 
  199   while (gengetopt_args_info_help[i])
 
  200     printf(
"%s\n", gengetopt_args_info_help[i++]);
 
  206   clear_given (args_info);
 
  207   clear_args (args_info);
 
  208   init_args_info (args_info);
 
  228 cmdline_parser_params_create(
void)
 
  232   cmdline_parser_params_init(params);  
 
  237 free_string_field (
char **s)
 
  251   free_string_field (&(args_info->
fipid_arg));
 
  253   free_string_field (&(args_info->
fid_arg));
 
  254   free_string_field (&(args_info->
fid_orig));
 
  255   free_string_field (&(args_info->
org_arg));
 
  256   free_string_field (&(args_info->
org_orig));
 
  257   free_string_field (&(args_info->
bank_arg));
 
  258   free_string_field (&(args_info->
bank_orig));
 
  261   free_string_field (&(args_info->
user_arg));
 
  262   free_string_field (&(args_info->
user_orig));
 
  263   free_string_field (&(args_info->
pass_arg));
 
  264   free_string_field (&(args_info->
pass_orig));
 
  265   free_string_field (&(args_info->
acct_arg));
 
  266   free_string_field (&(args_info->
acct_orig));
 
  267   free_string_field (&(args_info->
type_orig));
 
  268   free_string_field (&(args_info->
past_orig));
 
  269   free_string_field (&(args_info->
url_arg));
 
  270   free_string_field (&(args_info->
url_orig));
 
  271   free_string_field (&(args_info->
trid_orig));
 
  275     free (args_info->
inputs [i]);
 
  280   clear_given (args_info);
 
  285 write_into_file(FILE *outfile, 
const char *opt, 
const char *arg, 
const char *values[])
 
  289     fprintf(outfile, 
"%s=\"%s\"\n", opt, arg);
 
  291     fprintf(outfile, 
"%s\n", opt);
 
  303       fprintf (stderr, 
"%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
 
  308     write_into_file(outfile, 
"help", 0, 0 );
 
  310     write_into_file(outfile, 
"version", 0, 0 );
 
  312     write_into_file(outfile, 
"fipid", args_info->
fipid_orig, 0);
 
  314     write_into_file(outfile, 
"fid", args_info->
fid_orig, 0);
 
  316     write_into_file(outfile, 
"org", args_info->
org_orig, 0);
 
  318     write_into_file(outfile, 
"bank", args_info->
bank_orig, 0);
 
  320     write_into_file(outfile, 
"broker", args_info->
broker_orig, 0);
 
  322     write_into_file(outfile, 
"user", args_info->
user_orig, 0);
 
  324     write_into_file(outfile, 
"pass", args_info->
pass_orig, 0);
 
  326     write_into_file(outfile, 
"acct", args_info->
acct_orig, 0);
 
  328     write_into_file(outfile, 
"type", args_info->
type_orig, 0);
 
  330     write_into_file(outfile, 
"past", args_info->
past_orig, 0);
 
  332     write_into_file(outfile, 
"url", args_info->
url_orig, 0);
 
  334     write_into_file(outfile, 
"trid", args_info->
trid_orig, 0);
 
  336     write_into_file(outfile, 
"statement-req", 0, 0 );
 
  338     write_into_file(outfile, 
"accountinfo-req", 0, 0 );
 
  340     write_into_file(outfile, 
"payment-req", 0, 0 );
 
  342     write_into_file(outfile, 
"paymentinquiry-req", 0, 0 );
 
  344     write_into_file(outfile, 
"bank-list", 0, 0 );
 
  346     write_into_file(outfile, 
"bank-fipid", 0, 0 );
 
  348     write_into_file(outfile, 
"bank-services", 0, 0 );
 
  350     write_into_file(outfile, 
"allsupport", 0, 0 );
 
  363   outfile = fopen(filename, 
"w");
 
  367       fprintf (stderr, 
"%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
 
  371   i = cmdline_parser_dump(outfile, args_info);
 
  380   cmdline_parser_release (args_info);
 
  385 gengetopt_strdup (
const char *s)
 
  391   result = (
char*)malloc(strlen(s) + 1);
 
  392   if (result == (
char*)0)
 
  419   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 
  427   result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
  429   if (result == EXIT_FAILURE)
 
  431       cmdline_parser_free (args_info);
 
  450   result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
 
  452   if (result == EXIT_FAILURE)
 
  454       cmdline_parser_free (args_info);
 
  464   FIX_UNUSED (args_info);
 
  465   FIX_UNUSED (prog_name);
 
  470 static char *package_name = 0;
 
  491 int update_arg(
void *field, 
char **orig_field,
 
  492                unsigned int *field_given, 
unsigned int *prev_given, 
 
  493                char *value, 
const char *possible_values[],
 
  494                const char *default_value,
 
  495                cmdline_parser_arg_type arg_type,
 
  497                int no_free, 
int multiple_option,
 
  498                const char *long_opt, 
char short_opt,
 
  499                const char *additional_error)
 
  502   const char *val = value;
 
  510   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
 
  512       if (short_opt != 
'-')
 
  513         fprintf (stderr, 
"%s: `--%s' (`-%c') option given more than once%s\n", 
 
  514                package_name, long_opt, short_opt,
 
  515                (additional_error ? additional_error : 
""));
 
  517         fprintf (stderr, 
"%s: `--%s' option given more than once%s\n", 
 
  518                package_name, long_opt,
 
  519                (additional_error ? additional_error : 
""));
 
  523   FIX_UNUSED (default_value);
 
  525   if (field_given && *field_given && ! 
override)
 
  532     val = possible_values[found];
 
  536     if (val) *((
int *)field) = strtol (val, &stop_char, 0);
 
  539     if (val) *((
long *)field) = (long)strtol (val, &stop_char, 0);
 
  543       string_field = (
char **)field;
 
  544       if (!no_free && *string_field)
 
  545         free (*string_field); 
 
  546       *string_field = gengetopt_strdup (val);
 
  557     if (val && !(stop_char && *stop_char == 
'\0')) {
 
  558       fprintf(stderr, 
"%s: invalid numeric value: %s\n", package_name, val);
 
  571     if (value && orig_field) {
 
  577         *orig_field = gengetopt_strdup (value);
 
  587 cmdline_parser_internal (
 
  593   int error_occurred = 0;
 
  601   package_name = argv[0];
 
  609     cmdline_parser_init (args_info);
 
  611   cmdline_parser_init (&local_args_info);
 
  620       int option_index = 0;
 
  622       static struct option long_options[] = {
 
  623         { 
"help",       0, NULL, 
'h' },
 
  624         { 
"version",    0, NULL, 
'V' },
 
  625         { 
"fipid",      1, NULL, 0 },
 
  626         { 
"fid",        1, NULL, 0 },
 
  627         { 
"org",        1, NULL, 0 },
 
  628         { 
"bank",       1, NULL, 0 },
 
  629         { 
"broker",     1, NULL, 0 },
 
  630         { 
"user",       1, NULL, 0 },
 
  631         { 
"pass",       1, NULL, 0 },
 
  632         { 
"acct",       1, NULL, 0 },
 
  633         { 
"type",       1, NULL, 0 },
 
  634         { 
"past",       1, NULL, 0 },
 
  635         { 
"url",        1, NULL, 0 },
 
  636         { 
"trid",       1, NULL, 0 },
 
  637         { 
"statement-req",      0, NULL, 
's' },
 
  638         { 
"accountinfo-req",    0, NULL, 
'a' },
 
  639         { 
"payment-req",        0, NULL, 
'p' },
 
  640         { 
"paymentinquiry-req", 0, NULL, 
'i' },
 
  641         { 
"bank-list",  0, NULL, 
'b' },
 
  642         { 
"bank-fipid", 0, NULL, 
'f' },
 
  643         { 
"bank-services",      0, NULL, 
'v' },
 
  644         { 
"allsupport", 0, NULL, 0 },
 
  648       c = getopt_long (argc, argv, 
"hVsapibfv", long_options, &option_index);
 
  655           cmdline_parser_print_help ();
 
  656           cmdline_parser_free (&local_args_info);
 
  660           cmdline_parser_print_version ();
 
  661           cmdline_parser_free (&local_args_info);
 
  667             reset_group_command (args_info);
 
  672               &(local_args_info.statement_req_given), optarg, 0, 0, ARG_NO,
 
  673               check_ambiguity, 
override, 0, 0,
 
  674               "statement-req", 
's',
 
  682             reset_group_command (args_info);
 
  687               &(local_args_info.accountinfo_req_given), optarg, 0, 0, ARG_NO,
 
  688               check_ambiguity, 
override, 0, 0,
 
  689               "accountinfo-req", 
'a',
 
  697             reset_group_command (args_info);
 
  702               &(local_args_info.payment_req_given), optarg, 0, 0, ARG_NO,
 
  703               check_ambiguity, 
override, 0, 0,
 
  712             reset_group_command (args_info);
 
  717               &(local_args_info.paymentinquiry_req_given), optarg, 0, 0, ARG_NO,
 
  718               check_ambiguity, 
override, 0, 0,
 
  719               "paymentinquiry-req", 
'i',
 
  727             reset_group_command (args_info);
 
  732               &(local_args_info.bank_list_given), optarg, 0, 0, ARG_NO,
 
  733               check_ambiguity, 
override, 0, 0,
 
  742             reset_group_command (args_info);
 
  747               &(local_args_info.bank_fipid_given), optarg, 0, 0, ARG_NO,
 
  748               check_ambiguity, 
override, 0, 0,
 
  757             reset_group_command (args_info);
 
  762               &(local_args_info.bank_services_given), optarg, 0, 0, ARG_NO,
 
  763               check_ambiguity, 
override, 0, 0,
 
  764               "bank-services", 
'v',
 
  772           if (strcmp (long_options[option_index].name, 
"fipid") == 0)
 
  776             if (update_arg( (
void *)&(args_info->
fipid_arg), 
 
  778                 &(local_args_info.fipid_given), optarg, 0, 0, ARG_STRING,
 
  779                 check_ambiguity, 
override, 0, 0,
 
  786           else if (strcmp (long_options[option_index].name, 
"fid") == 0)
 
  790             if (update_arg( (
void *)&(args_info->
fid_arg), 
 
  792                 &(local_args_info.fid_given), optarg, 0, 0, ARG_STRING,
 
  793                 check_ambiguity, 
override, 0, 0,
 
  800           else if (strcmp (long_options[option_index].name, 
"org") == 0)
 
  804             if (update_arg( (
void *)&(args_info->
org_arg), 
 
  806                 &(local_args_info.org_given), optarg, 0, 0, ARG_STRING,
 
  807                 check_ambiguity, 
override, 0, 0,
 
  814           else if (strcmp (long_options[option_index].name, 
"bank") == 0)
 
  818             if (update_arg( (
void *)&(args_info->
bank_arg), 
 
  820                 &(local_args_info.bank_given), optarg, 0, 0, ARG_STRING,
 
  821                 check_ambiguity, 
override, 0, 0,
 
  828           else if (strcmp (long_options[option_index].name, 
"broker") == 0)
 
  832             if (update_arg( (
void *)&(args_info->
broker_arg), 
 
  834                 &(local_args_info.broker_given), optarg, 0, 0, ARG_STRING,
 
  835                 check_ambiguity, 
override, 0, 0,
 
  842           else if (strcmp (long_options[option_index].name, 
"user") == 0)
 
  846             if (update_arg( (
void *)&(args_info->
user_arg), 
 
  848                 &(local_args_info.user_given), optarg, 0, 0, ARG_STRING,
 
  849                 check_ambiguity, 
override, 0, 0,
 
  856           else if (strcmp (long_options[option_index].name, 
"pass") == 0)
 
  860             if (update_arg( (
void *)&(args_info->
pass_arg), 
 
  862                 &(local_args_info.pass_given), optarg, 0, 0, ARG_STRING,
 
  863                 check_ambiguity, 
override, 0, 0,
 
  870           else if (strcmp (long_options[option_index].name, 
"acct") == 0)
 
  874             if (update_arg( (
void *)&(args_info->
acct_arg), 
 
  876                 &(local_args_info.acct_given), optarg, 0, 0, ARG_STRING,
 
  877                 check_ambiguity, 
override, 0, 0,
 
  884           else if (strcmp (long_options[option_index].name, 
"type") == 0)
 
  888             if (update_arg( (
void *)&(args_info->
type_arg), 
 
  890                 &(local_args_info.type_given), optarg, 0, 0, ARG_INT,
 
  891                 check_ambiguity, 
override, 0, 0,
 
  898           else if (strcmp (long_options[option_index].name, 
"past") == 0)
 
  902             if (update_arg( (
void *)&(args_info->
past_arg), 
 
  904                 &(local_args_info.past_given), optarg, 0, 0, ARG_LONG,
 
  905                 check_ambiguity, 
override, 0, 0,
 
  912           else if (strcmp (long_options[option_index].name, 
"url") == 0)
 
  916             if (update_arg( (
void *)&(args_info->
url_arg), 
 
  918                 &(local_args_info.url_given), optarg, 0, 0, ARG_STRING,
 
  919                 check_ambiguity, 
override, 0, 0,
 
  926           else if (strcmp (long_options[option_index].name, 
"trid") == 0)
 
  930             if (update_arg( (
void *)&(args_info->
trid_arg), 
 
  932                 &(local_args_info.trid_given), optarg, 0, 0, ARG_INT,
 
  933                 check_ambiguity, 
override, 0, 0,
 
  940           else if (strcmp (long_options[option_index].name, 
"allsupport") == 0)
 
  944               reset_group_command (args_info);
 
  949                 &(local_args_info.allsupport_given), optarg, 0, 0, ARG_NO,
 
  950                 check_ambiguity, 
override, 0, 0,
 
  963           fprintf (stderr, 
"%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : 
""));
 
  970       fprintf (stderr, 
"%s: %d options of group command were given. At most one is required%s.\n", argv[0], args_info->
command_group_counter, (additional_error ? additional_error : 
""));
 
  977   cmdline_parser_release (&local_args_info);
 
  979   if ( error_occurred )
 
  980     return (EXIT_FAILURE);
 
  985       int found_prog_name = 0;
 
  992         if (argv[i++] == argv[0]) {
 
  998       args_info->
inputs_num = argc - optind - found_prog_name;
 
 1000         (
char **)(malloc ((args_info->
inputs_num)*
sizeof(
char *))) ;
 
 1001       while (optind < argc)
 
 1002         if (argv[optind++] != argv[0])
 
 1003           args_info->
inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
 
 1010   cmdline_parser_release (&local_args_info);
 
 1011   return (EXIT_FAILURE);
 
unsigned int allsupport_given
Whether allsupport was given. 
const char * bank_list_help
List all known banks help description. 
int override
whether to override possibly already present options (default 0) 
const char * allsupport_help
List all banks which support online banking help description. 
char * past_orig
How far back to look from today (in days) original value given at command line. 
unsigned int org_given
Whether org was given. 
const char * accountinfo_req_help
Request for a list of accounts help description. 
int initialize
whether to initialize the option structure gengetopt_args_info (default 1) 
char * type_orig
Account Type 1=checking 2=invest 3=ccard original value given at command line. 
char * url_orig
Url to POST the data to (otherwise goes to stdout) original value given at command line...
long past_arg
How far back to look from today (in days). 
unsigned int payment_req_given
Whether payment-req was given. 
unsigned int fid_given
Whether fid was given. 
Where the command line options are stored. 
unsigned int help_given
Whether help was given. 
unsigned int type_given
Whether type was given. 
char * fid_arg
FI identifier. 
unsigned int bank_given
Whether bank was given. 
const char * type_help
Account Type 1=checking 2=invest 3=ccard help description. 
unsigned int bank_fipid_given
Whether bank-fipid was given. 
const char * pass_help
Password help description. 
const char * user_help
User name help description. 
The additional parameters to pass to parser functions. 
char * url_arg
Url to POST the data to (otherwise goes to stdout). 
const char * version_help
Print version and exit help description. 
const char * acct_help
Account ID help description. 
char * bank_orig
IBAN bank identifier original value given at command line. 
const char * bank_fipid_help
List all fipids for a given bank help description. 
unsigned int bank_services_given
Whether bank-services was given. 
char * fipid_arg
FI partner identifier (looks up fid, org & url from partner server). 
unsigned int url_given
Whether url was given. 
const char * fid_help
FI identifier help description. 
const char * url_help
Url to POST the data to (otherwise goes to stdout) help description. 
char * fipid_orig
FI partner identifier (looks up fid, org & url from partner server) original value given at command l...
char * acct_orig
Account ID original value given at command line. 
const char * bank_help
IBAN bank identifier help description. 
const char * help_help
Print help and exit help description. 
char * user_orig
User name original value given at command line. 
unsigned int fipid_given
Whether fipid was given. 
char * acct_arg
Account ID. 
const char * statement_req_help
Request for a statement help description. 
char * user_arg
User name. 
unsigned int bank_list_given
Whether bank-list was given. 
const char * payment_req_help
Request to make a payment help description. 
unsigned int pass_given
Whether pass was given. 
unsigned inputs_num
unamed options number 
int trid_arg
Transaction id. 
const char * past_help
How far back to look from today (in days) help description. 
unsigned int statement_req_given
Whether statement-req was given. 
const char * paymentinquiry_req_help
Request to inquire about the status of a payment help description. 
int print_errors
whether getopt_long should print an error message for a bad option (default 1) 
unsigned int trid_given
Whether trid was given. 
int check_ambiguity
whether to check for options already specified in the option structure gengetopt_args_info (default 0...
int check_required
whether to check that all required options were provided (default 1) 
int command_group_counter
Counter for group command. 
unsigned int past_given
Whether past was given. 
unsigned int acct_given
Whether acct was given. 
const char * bank_services_help
List supported services for a given fipid help description. 
const char * trid_help
Transaction id help description. 
char ** inputs
unamed options (options without names) 
const char * org_help
FI org tag help description. 
char * org_orig
FI org tag original value given at command line. 
char * fid_orig
FI identifier original value given at command line. 
unsigned int user_given
Whether user was given. 
unsigned int paymentinquiry_req_given
Whether paymentinquiry-req was given. 
const char * broker_help
Broker identifier help description. 
unsigned int accountinfo_req_given
Whether accountinfo-req was given. 
char * pass_orig
Password original value given at command line. 
char * trid_orig
Transaction id original value given at command line. 
char * broker_orig
Broker identifier original value given at command line. 
char * bank_arg
IBAN bank identifier. 
unsigned int broker_given
Whether broker was given. 
const char * fipid_help
FI partner identifier (looks up fid, org & url from partner server) help description. 
char * org_arg
FI org tag. 
char * broker_arg
Broker identifier. 
int type_arg
Account Type 1=checking 2=invest 3=ccard. 
unsigned int version_given
Whether version was given.