00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #endif
00015
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <string.h>
00019
00020 #include "getopt.h"
00021
00022 #include "cmdline.h"
00023
00024 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.";
00025
00026 const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]... [FILES]...";
00027
00028 const char *gengetopt_args_info_description = "";
00029
00030 const char *gengetopt_args_info_help[] = {
00031 " -h, --help Print help and exit",
00032 " -V, --version Print version and exit",
00033 " --fipid=STRING FI partner identifier (looks up fid, org & url from \n partner server)",
00034 " --fid=STRING FI identifier",
00035 " --org=STRING FI org tag",
00036 " --bank=STRING IBAN bank identifier",
00037 " --broker=STRING Broker identifier",
00038 " --user=STRING User name",
00039 " --pass=STRING Password",
00040 " --acct=STRING Account ID",
00041 " --type=INT Account Type 1=checking 2=invest 3=ccard",
00042 " --past=LONG How far back to look from today (in days)",
00043 " --url=STRING Url to POST the data to (otherwise goes to stdout)",
00044 " --trid=INT Transaction id",
00045 "\n Group: command",
00046 " -s, --statement-req Request for a statement",
00047 " -a, --accountinfo-req Request for a list of accounts",
00048 " -p, --payment-req Request to make a payment",
00049 " -i, --paymentinquiry-req Request to inquire about the status of a payment",
00050 " -b, --bank-list List all known banks",
00051 " -f, --bank-fipid List all fipids for a given bank",
00052 " -v, --bank-services List supported services for a given fipid",
00053 " --allsupport List all banks which support online banking",
00054 0
00055 };
00056
00057 static
00058 void clear_given (struct gengetopt_args_info *args_info);
00059 static
00060 void clear_args (struct gengetopt_args_info *args_info);
00061
00062 static int
00063 cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
00064 struct cmdline_parser_params *params, const char *additional_error);
00065
00066
00067 static char *
00068 gengetopt_strdup (const char *s);
00069
00070 static
00071 void clear_given (struct gengetopt_args_info *args_info)
00072 {
00073 args_info->help_given = 0 ;
00074 args_info->version_given = 0 ;
00075 args_info->fipid_given = 0 ;
00076 args_info->fid_given = 0 ;
00077 args_info->org_given = 0 ;
00078 args_info->bank_given = 0 ;
00079 args_info->broker_given = 0 ;
00080 args_info->user_given = 0 ;
00081 args_info->pass_given = 0 ;
00082 args_info->acct_given = 0 ;
00083 args_info->type_given = 0 ;
00084 args_info->past_given = 0 ;
00085 args_info->url_given = 0 ;
00086 args_info->trid_given = 0 ;
00087 args_info->statement_req_given = 0 ;
00088 args_info->accountinfo_req_given = 0 ;
00089 args_info->payment_req_given = 0 ;
00090 args_info->paymentinquiry_req_given = 0 ;
00091 args_info->bank_list_given = 0 ;
00092 args_info->bank_fipid_given = 0 ;
00093 args_info->bank_services_given = 0 ;
00094 args_info->allsupport_given = 0 ;
00095 args_info->command_group_counter = 0 ;
00096 }
00097
00098 static
00099 void clear_args (struct gengetopt_args_info *args_info)
00100 {
00101 args_info->fipid_arg = NULL;
00102 args_info->fipid_orig = NULL;
00103 args_info->fid_arg = NULL;
00104 args_info->fid_orig = NULL;
00105 args_info->org_arg = NULL;
00106 args_info->org_orig = NULL;
00107 args_info->bank_arg = NULL;
00108 args_info->bank_orig = NULL;
00109 args_info->broker_arg = NULL;
00110 args_info->broker_orig = NULL;
00111 args_info->user_arg = NULL;
00112 args_info->user_orig = NULL;
00113 args_info->pass_arg = NULL;
00114 args_info->pass_orig = NULL;
00115 args_info->acct_arg = NULL;
00116 args_info->acct_orig = NULL;
00117 args_info->type_orig = NULL;
00118 args_info->past_orig = NULL;
00119 args_info->url_arg = NULL;
00120 args_info->url_orig = NULL;
00121 args_info->trid_orig = NULL;
00122
00123 }
00124
00125 static
00126 void init_args_info(struct gengetopt_args_info *args_info)
00127 {
00128 args_info->help_help = gengetopt_args_info_help[0] ;
00129 args_info->version_help = gengetopt_args_info_help[1] ;
00130 args_info->fipid_help = gengetopt_args_info_help[2] ;
00131 args_info->fid_help = gengetopt_args_info_help[3] ;
00132 args_info->org_help = gengetopt_args_info_help[4] ;
00133 args_info->bank_help = gengetopt_args_info_help[5] ;
00134 args_info->broker_help = gengetopt_args_info_help[6] ;
00135 args_info->user_help = gengetopt_args_info_help[7] ;
00136 args_info->pass_help = gengetopt_args_info_help[8] ;
00137 args_info->acct_help = gengetopt_args_info_help[9] ;
00138 args_info->type_help = gengetopt_args_info_help[10] ;
00139 args_info->past_help = gengetopt_args_info_help[11] ;
00140 args_info->url_help = gengetopt_args_info_help[12] ;
00141 args_info->trid_help = gengetopt_args_info_help[13] ;
00142 args_info->statement_req_help = gengetopt_args_info_help[14] ;
00143 args_info->accountinfo_req_help = gengetopt_args_info_help[15] ;
00144 args_info->payment_req_help = gengetopt_args_info_help[16] ;
00145 args_info->paymentinquiry_req_help = gengetopt_args_info_help[17] ;
00146 args_info->bank_list_help = gengetopt_args_info_help[18] ;
00147 args_info->bank_fipid_help = gengetopt_args_info_help[19] ;
00148 args_info->bank_services_help = gengetopt_args_info_help[20] ;
00149 args_info->allsupport_help = gengetopt_args_info_help[21] ;
00150
00151 }
00152
00153 void
00154 cmdline_parser_print_version (void)
00155 {
00156 printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
00157 }
00158
00159 void
00160 cmdline_parser_print_help (void)
00161 {
00162 int i = 0;
00163 cmdline_parser_print_version ();
00164
00165 if (strlen(gengetopt_args_info_purpose) > 0)
00166 printf("\n%s\n", gengetopt_args_info_purpose);
00167
00168 printf("\n%s\n\n", gengetopt_args_info_usage);
00169
00170 if (strlen(gengetopt_args_info_description) > 0)
00171 printf("%s\n", gengetopt_args_info_description);
00172
00173 while (gengetopt_args_info_help[i])
00174 printf("%s\n", gengetopt_args_info_help[i++]);
00175 }
00176
00177 void
00178 cmdline_parser_init (struct gengetopt_args_info *args_info)
00179 {
00180 clear_given (args_info);
00181 clear_args (args_info);
00182 init_args_info (args_info);
00183
00184 args_info->inputs = NULL;
00185 args_info->inputs_num = 0;
00186 }
00187
00188 struct cmdline_parser_params *
00189 cmdline_parser_params_init()
00190 {
00191 struct cmdline_parser_params *params =
00192 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
00193
00194 if (params)
00195 {
00196 params->override = 0;
00197 params->initialize = 0;
00198 params->check_required = 0;
00199 params->check_ambiguity = 0;
00200 }
00201
00202 return params;
00203 }
00204
00205 static void
00206 cmdline_parser_release (struct gengetopt_args_info *args_info)
00207 {
00208
00209 unsigned int i;
00210 if (args_info->fipid_arg)
00211 {
00212 free (args_info->fipid_arg);
00213 args_info->fipid_arg = 0;
00214 }
00215 if (args_info->fipid_orig)
00216 {
00217 free (args_info->fipid_orig);
00218 args_info->fipid_orig = 0;
00219 }
00220 if (args_info->fid_arg)
00221 {
00222 free (args_info->fid_arg);
00223 args_info->fid_arg = 0;
00224 }
00225 if (args_info->fid_orig)
00226 {
00227 free (args_info->fid_orig);
00228 args_info->fid_orig = 0;
00229 }
00230 if (args_info->org_arg)
00231 {
00232 free (args_info->org_arg);
00233 args_info->org_arg = 0;
00234 }
00235 if (args_info->org_orig)
00236 {
00237 free (args_info->org_orig);
00238 args_info->org_orig = 0;
00239 }
00240 if (args_info->bank_arg)
00241 {
00242 free (args_info->bank_arg);
00243 args_info->bank_arg = 0;
00244 }
00245 if (args_info->bank_orig)
00246 {
00247 free (args_info->bank_orig);
00248 args_info->bank_orig = 0;
00249 }
00250 if (args_info->broker_arg)
00251 {
00252 free (args_info->broker_arg);
00253 args_info->broker_arg = 0;
00254 }
00255 if (args_info->broker_orig)
00256 {
00257 free (args_info->broker_orig);
00258 args_info->broker_orig = 0;
00259 }
00260 if (args_info->user_arg)
00261 {
00262 free (args_info->user_arg);
00263 args_info->user_arg = 0;
00264 }
00265 if (args_info->user_orig)
00266 {
00267 free (args_info->user_orig);
00268 args_info->user_orig = 0;
00269 }
00270 if (args_info->pass_arg)
00271 {
00272 free (args_info->pass_arg);
00273 args_info->pass_arg = 0;
00274 }
00275 if (args_info->pass_orig)
00276 {
00277 free (args_info->pass_orig);
00278 args_info->pass_orig = 0;
00279 }
00280 if (args_info->acct_arg)
00281 {
00282 free (args_info->acct_arg);
00283 args_info->acct_arg = 0;
00284 }
00285 if (args_info->acct_orig)
00286 {
00287 free (args_info->acct_orig);
00288 args_info->acct_orig = 0;
00289 }
00290 if (args_info->type_orig)
00291 {
00292 free (args_info->type_orig);
00293 args_info->type_orig = 0;
00294 }
00295 if (args_info->past_orig)
00296 {
00297 free (args_info->past_orig);
00298 args_info->past_orig = 0;
00299 }
00300 if (args_info->url_arg)
00301 {
00302 free (args_info->url_arg);
00303 args_info->url_arg = 0;
00304 }
00305 if (args_info->url_orig)
00306 {
00307 free (args_info->url_orig);
00308 args_info->url_orig = 0;
00309 }
00310 if (args_info->trid_orig)
00311 {
00312 free (args_info->trid_orig);
00313 args_info->trid_orig = 0;
00314 }
00315
00316 for (i = 0; i < args_info->inputs_num; ++i)
00317 free (args_info->inputs [i]);
00318
00319 if (args_info->inputs_num)
00320 free (args_info->inputs);
00321
00322 clear_given (args_info);
00323 }
00324
00325 int
00326 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
00327 {
00328 FILE *outfile;
00329 int i = 0;
00330
00331 outfile = fopen(filename, "w");
00332
00333 if (!outfile)
00334 {
00335 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
00336 return EXIT_FAILURE;
00337 }
00338
00339 if (args_info->help_given) {
00340 fprintf(outfile, "%s\n", "help");
00341 }
00342 if (args_info->version_given) {
00343 fprintf(outfile, "%s\n", "version");
00344 }
00345 if (args_info->fipid_given) {
00346 if (args_info->fipid_orig) {
00347 fprintf(outfile, "%s=\"%s\"\n", "fipid", args_info->fipid_orig);
00348 } else {
00349 fprintf(outfile, "%s\n", "fipid");
00350 }
00351 }
00352 if (args_info->fid_given) {
00353 if (args_info->fid_orig) {
00354 fprintf(outfile, "%s=\"%s\"\n", "fid", args_info->fid_orig);
00355 } else {
00356 fprintf(outfile, "%s\n", "fid");
00357 }
00358 }
00359 if (args_info->org_given) {
00360 if (args_info->org_orig) {
00361 fprintf(outfile, "%s=\"%s\"\n", "org", args_info->org_orig);
00362 } else {
00363 fprintf(outfile, "%s\n", "org");
00364 }
00365 }
00366 if (args_info->bank_given) {
00367 if (args_info->bank_orig) {
00368 fprintf(outfile, "%s=\"%s\"\n", "bank", args_info->bank_orig);
00369 } else {
00370 fprintf(outfile, "%s\n", "bank");
00371 }
00372 }
00373 if (args_info->broker_given) {
00374 if (args_info->broker_orig) {
00375 fprintf(outfile, "%s=\"%s\"\n", "broker", args_info->broker_orig);
00376 } else {
00377 fprintf(outfile, "%s\n", "broker");
00378 }
00379 }
00380 if (args_info->user_given) {
00381 if (args_info->user_orig) {
00382 fprintf(outfile, "%s=\"%s\"\n", "user", args_info->user_orig);
00383 } else {
00384 fprintf(outfile, "%s\n", "user");
00385 }
00386 }
00387 if (args_info->pass_given) {
00388 if (args_info->pass_orig) {
00389 fprintf(outfile, "%s=\"%s\"\n", "pass", args_info->pass_orig);
00390 } else {
00391 fprintf(outfile, "%s\n", "pass");
00392 }
00393 }
00394 if (args_info->acct_given) {
00395 if (args_info->acct_orig) {
00396 fprintf(outfile, "%s=\"%s\"\n", "acct", args_info->acct_orig);
00397 } else {
00398 fprintf(outfile, "%s\n", "acct");
00399 }
00400 }
00401 if (args_info->type_given) {
00402 if (args_info->type_orig) {
00403 fprintf(outfile, "%s=\"%s\"\n", "type", args_info->type_orig);
00404 } else {
00405 fprintf(outfile, "%s\n", "type");
00406 }
00407 }
00408 if (args_info->past_given) {
00409 if (args_info->past_orig) {
00410 fprintf(outfile, "%s=\"%s\"\n", "past", args_info->past_orig);
00411 } else {
00412 fprintf(outfile, "%s\n", "past");
00413 }
00414 }
00415 if (args_info->url_given) {
00416 if (args_info->url_orig) {
00417 fprintf(outfile, "%s=\"%s\"\n", "url", args_info->url_orig);
00418 } else {
00419 fprintf(outfile, "%s\n", "url");
00420 }
00421 }
00422 if (args_info->trid_given) {
00423 if (args_info->trid_orig) {
00424 fprintf(outfile, "%s=\"%s\"\n", "trid", args_info->trid_orig);
00425 } else {
00426 fprintf(outfile, "%s\n", "trid");
00427 }
00428 }
00429 if (args_info->statement_req_given) {
00430 fprintf(outfile, "%s\n", "statement-req");
00431 }
00432 if (args_info->accountinfo_req_given) {
00433 fprintf(outfile, "%s\n", "accountinfo-req");
00434 }
00435 if (args_info->payment_req_given) {
00436 fprintf(outfile, "%s\n", "payment-req");
00437 }
00438 if (args_info->paymentinquiry_req_given) {
00439 fprintf(outfile, "%s\n", "paymentinquiry-req");
00440 }
00441 if (args_info->bank_list_given) {
00442 fprintf(outfile, "%s\n", "bank-list");
00443 }
00444 if (args_info->bank_fipid_given) {
00445 fprintf(outfile, "%s\n", "bank-fipid");
00446 }
00447 if (args_info->bank_services_given) {
00448 fprintf(outfile, "%s\n", "bank-services");
00449 }
00450 if (args_info->allsupport_given) {
00451 fprintf(outfile, "%s\n", "allsupport");
00452 }
00453
00454 fclose (outfile);
00455
00456 i = EXIT_SUCCESS;
00457 return i;
00458 }
00459
00460 void
00461 cmdline_parser_free (struct gengetopt_args_info *args_info)
00462 {
00463 cmdline_parser_release (args_info);
00464 }
00465
00466
00467
00468
00469 char *
00470 gengetopt_strdup (const char *s)
00471 {
00472 char *result = NULL;
00473 if (!s)
00474 return result;
00475
00476 result = (char*)malloc(strlen(s) + 1);
00477 if (result == (char*)0)
00478 return (char*)0;
00479 strcpy(result, s);
00480 return result;
00481 }
00482
00483 static void
00484 reset_group_command(struct gengetopt_args_info *args_info);
00485
00486 static void
00487 reset_group_command(struct gengetopt_args_info *args_info)
00488 {
00489 if (! args_info->command_group_counter)
00490 return;
00491
00492 args_info->statement_req_given = 0 ;
00493 args_info->accountinfo_req_given = 0 ;
00494 args_info->payment_req_given = 0 ;
00495 args_info->paymentinquiry_req_given = 0 ;
00496 args_info->bank_list_given = 0 ;
00497 args_info->bank_fipid_given = 0 ;
00498 args_info->bank_services_given = 0 ;
00499 args_info->allsupport_given = 0 ;
00500
00501 args_info->command_group_counter = 0;
00502 }
00503
00504 int
00505 cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
00506 {
00507 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
00508 }
00509
00510 int
00511 cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
00512 struct cmdline_parser_params *params)
00513 {
00514 int result;
00515 result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
00516
00517 if (result == EXIT_FAILURE)
00518 {
00519 cmdline_parser_free (args_info);
00520 exit (EXIT_FAILURE);
00521 }
00522
00523 return result;
00524 }
00525
00526 int
00527 cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
00528 {
00529 int result;
00530 struct cmdline_parser_params params;
00531
00532 params.override = override;
00533 params.initialize = initialize;
00534 params.check_required = check_required;
00535 params.check_ambiguity = 0;
00536
00537 result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL);
00538
00539 if (result == EXIT_FAILURE)
00540 {
00541 cmdline_parser_free (args_info);
00542 exit (EXIT_FAILURE);
00543 }
00544
00545 return result;
00546 }
00547
00548 int
00549 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
00550 {
00551 return EXIT_SUCCESS;
00552 }
00553
00554 int
00555 cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
00556 struct cmdline_parser_params *params, const char *additional_error)
00557 {
00558 int c;
00559
00560 int error = 0;
00561 struct gengetopt_args_info local_args_info;
00562
00563 int override;
00564 int initialize;
00565 int check_required;
00566 int check_ambiguity;
00567
00568 override = params->override;
00569 initialize = params->initialize;
00570 check_required = params->check_required;
00571 check_ambiguity = params->check_ambiguity;
00572
00573 if (initialize)
00574 cmdline_parser_init (args_info);
00575
00576 cmdline_parser_init (&local_args_info);
00577
00578 optarg = 0;
00579 optind = 0;
00580 opterr = 1;
00581 optopt = '?';
00582
00583 while (1)
00584 {
00585 int option_index = 0;
00586 char *stop_char;
00587
00588 static struct option long_options[] = {
00589 { "help", 0, NULL, 'h' },
00590 { "version", 0, NULL, 'V' },
00591 { "fipid", 1, NULL, 0 },
00592 { "fid", 1, NULL, 0 },
00593 { "org", 1, NULL, 0 },
00594 { "bank", 1, NULL, 0 },
00595 { "broker", 1, NULL, 0 },
00596 { "user", 1, NULL, 0 },
00597 { "pass", 1, NULL, 0 },
00598 { "acct", 1, NULL, 0 },
00599 { "type", 1, NULL, 0 },
00600 { "past", 1, NULL, 0 },
00601 { "url", 1, NULL, 0 },
00602 { "trid", 1, NULL, 0 },
00603 { "statement-req", 0, NULL, 's' },
00604 { "accountinfo-req", 0, NULL, 'a' },
00605 { "payment-req", 0, NULL, 'p' },
00606 { "paymentinquiry-req", 0, NULL, 'i' },
00607 { "bank-list", 0, NULL, 'b' },
00608 { "bank-fipid", 0, NULL, 'f' },
00609 { "bank-services", 0, NULL, 'v' },
00610 { "allsupport", 0, NULL, 0 },
00611 { NULL, 0, NULL, 0 }
00612 };
00613
00614 stop_char = 0;
00615 c = getopt_long (argc, argv, "hVsapibfv", long_options, &option_index);
00616
00617 if (c == -1) break;
00618
00619 switch (c)
00620 {
00621 case 'h':
00622 cmdline_parser_print_help ();
00623 cmdline_parser_free (&local_args_info);
00624 exit (EXIT_SUCCESS);
00625
00626 case 'V':
00627 cmdline_parser_print_version ();
00628 cmdline_parser_free (&local_args_info);
00629 exit (EXIT_SUCCESS);
00630
00631 case 's':
00632 if (local_args_info.statement_req_given || (check_ambiguity && args_info->statement_req_given))
00633 {
00634 fprintf (stderr, "%s: `--statement-req' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00635 goto failure;
00636 }
00637 if (args_info->statement_req_given && ! override)
00638 continue;
00639 local_args_info.statement_req_given = 1;
00640 args_info->statement_req_given = 1;
00641 if (args_info->command_group_counter && override)
00642 reset_group_command (args_info);
00643 args_info->command_group_counter += 1;
00644 break;
00645
00646 case 'a':
00647 if (local_args_info.accountinfo_req_given || (check_ambiguity && args_info->accountinfo_req_given))
00648 {
00649 fprintf (stderr, "%s: `--accountinfo-req' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00650 goto failure;
00651 }
00652 if (args_info->accountinfo_req_given && ! override)
00653 continue;
00654 local_args_info.accountinfo_req_given = 1;
00655 args_info->accountinfo_req_given = 1;
00656 if (args_info->command_group_counter && override)
00657 reset_group_command (args_info);
00658 args_info->command_group_counter += 1;
00659 break;
00660
00661 case 'p':
00662 if (local_args_info.payment_req_given || (check_ambiguity && args_info->payment_req_given))
00663 {
00664 fprintf (stderr, "%s: `--payment-req' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00665 goto failure;
00666 }
00667 if (args_info->payment_req_given && ! override)
00668 continue;
00669 local_args_info.payment_req_given = 1;
00670 args_info->payment_req_given = 1;
00671 if (args_info->command_group_counter && override)
00672 reset_group_command (args_info);
00673 args_info->command_group_counter += 1;
00674 break;
00675
00676 case 'i':
00677 if (local_args_info.paymentinquiry_req_given || (check_ambiguity && args_info->paymentinquiry_req_given))
00678 {
00679 fprintf (stderr, "%s: `--paymentinquiry-req' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00680 goto failure;
00681 }
00682 if (args_info->paymentinquiry_req_given && ! override)
00683 continue;
00684 local_args_info.paymentinquiry_req_given = 1;
00685 args_info->paymentinquiry_req_given = 1;
00686 if (args_info->command_group_counter && override)
00687 reset_group_command (args_info);
00688 args_info->command_group_counter += 1;
00689 break;
00690
00691 case 'b':
00692 if (local_args_info.bank_list_given || (check_ambiguity && args_info->bank_list_given))
00693 {
00694 fprintf (stderr, "%s: `--bank-list' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00695 goto failure;
00696 }
00697 if (args_info->bank_list_given && ! override)
00698 continue;
00699 local_args_info.bank_list_given = 1;
00700 args_info->bank_list_given = 1;
00701 if (args_info->command_group_counter && override)
00702 reset_group_command (args_info);
00703 args_info->command_group_counter += 1;
00704 break;
00705
00706 case 'f':
00707 if (local_args_info.bank_fipid_given || (check_ambiguity && args_info->bank_fipid_given))
00708 {
00709 fprintf (stderr, "%s: `--bank-fipid' (`-f') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00710 goto failure;
00711 }
00712 if (args_info->bank_fipid_given && ! override)
00713 continue;
00714 local_args_info.bank_fipid_given = 1;
00715 args_info->bank_fipid_given = 1;
00716 if (args_info->command_group_counter && override)
00717 reset_group_command (args_info);
00718 args_info->command_group_counter += 1;
00719 break;
00720
00721 case 'v':
00722 if (local_args_info.bank_services_given || (check_ambiguity && args_info->bank_services_given))
00723 {
00724 fprintf (stderr, "%s: `--bank-services' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00725 goto failure;
00726 }
00727 if (args_info->bank_services_given && ! override)
00728 continue;
00729 local_args_info.bank_services_given = 1;
00730 args_info->bank_services_given = 1;
00731 if (args_info->command_group_counter && override)
00732 reset_group_command (args_info);
00733 args_info->command_group_counter += 1;
00734 break;
00735
00736
00737 case 0:
00738
00739 if (strcmp (long_options[option_index].name, "fipid") == 0)
00740 {
00741 if (local_args_info.fipid_given || (check_ambiguity && args_info->fipid_given))
00742 {
00743 fprintf (stderr, "%s: `--fipid' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00744 goto failure;
00745 }
00746 if (args_info->fipid_given && ! override)
00747 continue;
00748 local_args_info.fipid_given = 1;
00749 args_info->fipid_given = 1;
00750 if (args_info->fipid_arg)
00751 free (args_info->fipid_arg);
00752 args_info->fipid_arg = gengetopt_strdup (optarg);
00753 if (args_info->fipid_orig)
00754 free (args_info->fipid_orig);
00755 args_info->fipid_orig = gengetopt_strdup (optarg);
00756 }
00757
00758 else if (strcmp (long_options[option_index].name, "fid") == 0)
00759 {
00760 if (local_args_info.fid_given || (check_ambiguity && args_info->fid_given))
00761 {
00762 fprintf (stderr, "%s: `--fid' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00763 goto failure;
00764 }
00765 if (args_info->fid_given && ! override)
00766 continue;
00767 local_args_info.fid_given = 1;
00768 args_info->fid_given = 1;
00769 if (args_info->fid_arg)
00770 free (args_info->fid_arg);
00771 args_info->fid_arg = gengetopt_strdup (optarg);
00772 if (args_info->fid_orig)
00773 free (args_info->fid_orig);
00774 args_info->fid_orig = gengetopt_strdup (optarg);
00775 }
00776
00777 else if (strcmp (long_options[option_index].name, "org") == 0)
00778 {
00779 if (local_args_info.org_given || (check_ambiguity && args_info->org_given))
00780 {
00781 fprintf (stderr, "%s: `--org' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00782 goto failure;
00783 }
00784 if (args_info->org_given && ! override)
00785 continue;
00786 local_args_info.org_given = 1;
00787 args_info->org_given = 1;
00788 if (args_info->org_arg)
00789 free (args_info->org_arg);
00790 args_info->org_arg = gengetopt_strdup (optarg);
00791 if (args_info->org_orig)
00792 free (args_info->org_orig);
00793 args_info->org_orig = gengetopt_strdup (optarg);
00794 }
00795
00796 else if (strcmp (long_options[option_index].name, "bank") == 0)
00797 {
00798 if (local_args_info.bank_given || (check_ambiguity && args_info->bank_given))
00799 {
00800 fprintf (stderr, "%s: `--bank' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00801 goto failure;
00802 }
00803 if (args_info->bank_given && ! override)
00804 continue;
00805 local_args_info.bank_given = 1;
00806 args_info->bank_given = 1;
00807 if (args_info->bank_arg)
00808 free (args_info->bank_arg);
00809 args_info->bank_arg = gengetopt_strdup (optarg);
00810 if (args_info->bank_orig)
00811 free (args_info->bank_orig);
00812 args_info->bank_orig = gengetopt_strdup (optarg);
00813 }
00814
00815 else if (strcmp (long_options[option_index].name, "broker") == 0)
00816 {
00817 if (local_args_info.broker_given || (check_ambiguity && args_info->broker_given))
00818 {
00819 fprintf (stderr, "%s: `--broker' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00820 goto failure;
00821 }
00822 if (args_info->broker_given && ! override)
00823 continue;
00824 local_args_info.broker_given = 1;
00825 args_info->broker_given = 1;
00826 if (args_info->broker_arg)
00827 free (args_info->broker_arg);
00828 args_info->broker_arg = gengetopt_strdup (optarg);
00829 if (args_info->broker_orig)
00830 free (args_info->broker_orig);
00831 args_info->broker_orig = gengetopt_strdup (optarg);
00832 }
00833
00834 else if (strcmp (long_options[option_index].name, "user") == 0)
00835 {
00836 if (local_args_info.user_given || (check_ambiguity && args_info->user_given))
00837 {
00838 fprintf (stderr, "%s: `--user' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00839 goto failure;
00840 }
00841 if (args_info->user_given && ! override)
00842 continue;
00843 local_args_info.user_given = 1;
00844 args_info->user_given = 1;
00845 if (args_info->user_arg)
00846 free (args_info->user_arg);
00847 args_info->user_arg = gengetopt_strdup (optarg);
00848 if (args_info->user_orig)
00849 free (args_info->user_orig);
00850 args_info->user_orig = gengetopt_strdup (optarg);
00851 }
00852
00853 else if (strcmp (long_options[option_index].name, "pass") == 0)
00854 {
00855 if (local_args_info.pass_given || (check_ambiguity && args_info->pass_given))
00856 {
00857 fprintf (stderr, "%s: `--pass' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00858 goto failure;
00859 }
00860 if (args_info->pass_given && ! override)
00861 continue;
00862 local_args_info.pass_given = 1;
00863 args_info->pass_given = 1;
00864 if (args_info->pass_arg)
00865 free (args_info->pass_arg);
00866 args_info->pass_arg = gengetopt_strdup (optarg);
00867 if (args_info->pass_orig)
00868 free (args_info->pass_orig);
00869 args_info->pass_orig = gengetopt_strdup (optarg);
00870 }
00871
00872 else if (strcmp (long_options[option_index].name, "acct") == 0)
00873 {
00874 if (local_args_info.acct_given || (check_ambiguity && args_info->acct_given))
00875 {
00876 fprintf (stderr, "%s: `--acct' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00877 goto failure;
00878 }
00879 if (args_info->acct_given && ! override)
00880 continue;
00881 local_args_info.acct_given = 1;
00882 args_info->acct_given = 1;
00883 if (args_info->acct_arg)
00884 free (args_info->acct_arg);
00885 args_info->acct_arg = gengetopt_strdup (optarg);
00886 if (args_info->acct_orig)
00887 free (args_info->acct_orig);
00888 args_info->acct_orig = gengetopt_strdup (optarg);
00889 }
00890
00891 else if (strcmp (long_options[option_index].name, "type") == 0)
00892 {
00893 if (local_args_info.type_given || (check_ambiguity && args_info->type_given))
00894 {
00895 fprintf (stderr, "%s: `--type' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00896 goto failure;
00897 }
00898 if (args_info->type_given && ! override)
00899 continue;
00900 local_args_info.type_given = 1;
00901 args_info->type_given = 1;
00902 args_info->type_arg = strtol (optarg, &stop_char, 0);
00903 if (!(stop_char && *stop_char == '\0')) {
00904 fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
00905 goto failure;
00906 }
00907 if (args_info->type_orig)
00908 free (args_info->type_orig);
00909 args_info->type_orig = gengetopt_strdup (optarg);
00910 }
00911
00912 else if (strcmp (long_options[option_index].name, "past") == 0)
00913 {
00914 if (local_args_info.past_given || (check_ambiguity && args_info->past_given))
00915 {
00916 fprintf (stderr, "%s: `--past' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00917 goto failure;
00918 }
00919 if (args_info->past_given && ! override)
00920 continue;
00921 local_args_info.past_given = 1;
00922 args_info->past_given = 1;
00923 args_info->past_arg = strtol (optarg, &stop_char, 0);
00924 if (!(stop_char && *stop_char == '\0')) {
00925 fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
00926 goto failure;
00927 }
00928 if (args_info->past_orig)
00929 free (args_info->past_orig);
00930 args_info->past_orig = gengetopt_strdup (optarg);
00931 }
00932
00933 else if (strcmp (long_options[option_index].name, "url") == 0)
00934 {
00935 if (local_args_info.url_given || (check_ambiguity && args_info->url_given))
00936 {
00937 fprintf (stderr, "%s: `--url' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00938 goto failure;
00939 }
00940 if (args_info->url_given && ! override)
00941 continue;
00942 local_args_info.url_given = 1;
00943 args_info->url_given = 1;
00944 if (args_info->url_arg)
00945 free (args_info->url_arg);
00946 args_info->url_arg = gengetopt_strdup (optarg);
00947 if (args_info->url_orig)
00948 free (args_info->url_orig);
00949 args_info->url_orig = gengetopt_strdup (optarg);
00950 }
00951
00952 else if (strcmp (long_options[option_index].name, "trid") == 0)
00953 {
00954 if (local_args_info.trid_given || (check_ambiguity && args_info->trid_given))
00955 {
00956 fprintf (stderr, "%s: `--trid' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00957 goto failure;
00958 }
00959 if (args_info->trid_given && ! override)
00960 continue;
00961 local_args_info.trid_given = 1;
00962 args_info->trid_given = 1;
00963 args_info->trid_arg = strtol (optarg, &stop_char, 0);
00964 if (!(stop_char && *stop_char == '\0')) {
00965 fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
00966 goto failure;
00967 }
00968 if (args_info->trid_orig)
00969 free (args_info->trid_orig);
00970 args_info->trid_orig = gengetopt_strdup (optarg);
00971 }
00972
00973 else if (strcmp (long_options[option_index].name, "allsupport") == 0)
00974 {
00975 if (local_args_info.allsupport_given || (check_ambiguity && args_info->allsupport_given))
00976 {
00977 fprintf (stderr, "%s: `--allsupport' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
00978 goto failure;
00979 }
00980 if (args_info->allsupport_given && ! override)
00981 continue;
00982 local_args_info.allsupport_given = 1;
00983 args_info->allsupport_given = 1;
00984 if (args_info->command_group_counter && override)
00985 reset_group_command (args_info);
00986 args_info->command_group_counter += 1;
00987 break;
00988 }
00989
00990 break;
00991 case '?':
00992
00993 goto failure;
00994
00995 default:
00996 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
00997 abort ();
00998 }
00999 }
01000
01001 if (args_info->command_group_counter > 1)
01002 {
01003 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 : ""));
01004 error = 1;
01005 }
01006
01007
01008
01009
01010 cmdline_parser_release (&local_args_info);
01011
01012 if ( error )
01013 return (EXIT_FAILURE);
01014
01015 if (optind < argc)
01016 {
01017 int i = 0 ;
01018 int found_prog_name = 0;
01019
01020
01021
01022
01023 i = optind;
01024 while (i < argc)
01025 if (argv[i++] == argv[0]) {
01026 found_prog_name = 1;
01027 break;
01028 }
01029 i = 0;
01030
01031 args_info->inputs_num = argc - optind - found_prog_name;
01032 args_info->inputs =
01033 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
01034 while (optind < argc)
01035 if (argv[optind++] != argv[0])
01036 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
01037 }
01038
01039 return 0;
01040
01041 failure:
01042
01043 cmdline_parser_release (&local_args_info);
01044 return (EXIT_FAILURE);
01045 }