LibOFX

ofxconnect/cmdline.c
1 /*
2 File autogenerated by gengetopt version 2.22.6
3 generated with the following command:
4 gengetopt --unamed-opts
5
6 The developers of gengetopt consider the fixed text that goes in all
7 gengetopt output files to be in the public domain:
8 we make no copyright claims on it.
9 */
10
11 /* If we use autoconf. */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 #ifndef FIX_UNUSED
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22 #endif
23
24 #include <getopt.h>
25
26 #include "cmdline.h"
27
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.";
29
30 const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]... [FILES]...";
31
32 const char *gengetopt_args_info_versiontext = "";
33
34 const char *gengetopt_args_info_description = "";
35
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",
51 "\n Group: command",
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",
60 0
61 };
62
63 typedef enum {ARG_NO
64 , ARG_STRING
65 , ARG_INT
66 , ARG_LONG
67 } cmdline_parser_arg_type;
68
69 static
70 void clear_given (struct gengetopt_args_info *args_info);
71 static
72 void clear_args (struct gengetopt_args_info *args_info);
73
74 static int
75 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
76 struct cmdline_parser_params *params, const char *additional_error);
77
78
79 static char *
80 gengetopt_strdup (const char *s);
81
82 static
83 void clear_given (struct gengetopt_args_info *args_info)
84 {
85 args_info->help_given = 0 ;
86 args_info->version_given = 0 ;
87 args_info->fipid_given = 0 ;
88 args_info->fid_given = 0 ;
89 args_info->org_given = 0 ;
90 args_info->bank_given = 0 ;
91 args_info->broker_given = 0 ;
92 args_info->user_given = 0 ;
93 args_info->pass_given = 0 ;
94 args_info->acct_given = 0 ;
95 args_info->type_given = 0 ;
96 args_info->past_given = 0 ;
97 args_info->url_given = 0 ;
98 args_info->trid_given = 0 ;
99 args_info->statement_req_given = 0 ;
100 args_info->accountinfo_req_given = 0 ;
101 args_info->payment_req_given = 0 ;
102 args_info->paymentinquiry_req_given = 0 ;
103 args_info->bank_list_given = 0 ;
104 args_info->bank_fipid_given = 0 ;
105 args_info->bank_services_given = 0 ;
106 args_info->allsupport_given = 0 ;
107 args_info->command_group_counter = 0 ;
108 }
109
110 static
111 void clear_args (struct gengetopt_args_info *args_info)
112 {
113 FIX_UNUSED (args_info);
114 args_info->fipid_arg = NULL;
115 args_info->fipid_orig = NULL;
116 args_info->fid_arg = NULL;
117 args_info->fid_orig = NULL;
118 args_info->org_arg = NULL;
119 args_info->org_orig = NULL;
120 args_info->bank_arg = NULL;
121 args_info->bank_orig = NULL;
122 args_info->broker_arg = NULL;
123 args_info->broker_orig = NULL;
124 args_info->user_arg = NULL;
125 args_info->user_orig = NULL;
126 args_info->pass_arg = NULL;
127 args_info->pass_orig = NULL;
128 args_info->acct_arg = NULL;
129 args_info->acct_orig = NULL;
130 args_info->type_orig = NULL;
131 args_info->past_orig = NULL;
132 args_info->url_arg = NULL;
133 args_info->url_orig = NULL;
134 args_info->trid_orig = NULL;
135
136 }
137
138 static
139 void init_args_info(struct gengetopt_args_info *args_info)
140 {
141
142
143 args_info->help_help = gengetopt_args_info_help[0] ;
144 args_info->version_help = gengetopt_args_info_help[1] ;
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] ;
157 args_info->statement_req_help = gengetopt_args_info_help[15] ;
158 args_info->accountinfo_req_help = gengetopt_args_info_help[16] ;
159 args_info->payment_req_help = gengetopt_args_info_help[17] ;
160 args_info->paymentinquiry_req_help = gengetopt_args_info_help[18] ;
161 args_info->bank_list_help = gengetopt_args_info_help[19] ;
162 args_info->bank_fipid_help = gengetopt_args_info_help[20] ;
163 args_info->bank_services_help = gengetopt_args_info_help[21] ;
164 args_info->allsupport_help = gengetopt_args_info_help[22] ;
165
166 }
167
168 void
169 cmdline_parser_print_version (void)
170 {
171 printf ("%s %s\n",
172 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
173 CMDLINE_PARSER_VERSION);
174
175 if (strlen(gengetopt_args_info_versiontext) > 0)
176 printf("\n%s\n", gengetopt_args_info_versiontext);
177 }
178
179 static void print_help_common(void) {
180 cmdline_parser_print_version ();
181
182 if (strlen(gengetopt_args_info_purpose) > 0)
183 printf("\n%s\n", gengetopt_args_info_purpose);
184
185 if (strlen(gengetopt_args_info_usage) > 0)
186 printf("\n%s\n", gengetopt_args_info_usage);
187
188 printf("\n");
189
190 if (strlen(gengetopt_args_info_description) > 0)
191 printf("%s\n\n", gengetopt_args_info_description);
192 }
193
194 void
195 cmdline_parser_print_help (void)
196 {
197 int i = 0;
198 print_help_common();
199 while (gengetopt_args_info_help[i])
200 printf("%s\n", gengetopt_args_info_help[i++]);
201 }
202
203 void
204 cmdline_parser_init (struct gengetopt_args_info *args_info)
205 {
206 clear_given (args_info);
207 clear_args (args_info);
208 init_args_info (args_info);
209
210 args_info->inputs = 0;
211 args_info->inputs_num = 0;
212 }
213
214 void
215 cmdline_parser_params_init(struct cmdline_parser_params *params)
216 {
217 if (params)
218 {
219 params->override = 0;
220 params->initialize = 1;
221 params->check_required = 1;
222 params->check_ambiguity = 0;
223 params->print_errors = 1;
224 }
225 }
226
227 struct cmdline_parser_params *
228 cmdline_parser_params_create(void)
229 {
230 struct cmdline_parser_params *params =
231 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
232 cmdline_parser_params_init(params);
233 return params;
234 }
235
236 static void
237 free_string_field (char **s)
238 {
239 if (*s)
240 {
241 free (*s);
242 *s = 0;
243 }
244 }
245
246
247 static void
248 cmdline_parser_release (struct gengetopt_args_info *args_info)
249 {
250 unsigned int i;
251 free_string_field (&(args_info->fipid_arg));
252 free_string_field (&(args_info->fipid_orig));
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));
259 free_string_field (&(args_info->broker_arg));
260 free_string_field (&(args_info->broker_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));
272
273
274 for (i = 0; i < args_info->inputs_num; ++i)
275 free (args_info->inputs [i]);
276
277 if (args_info->inputs_num)
278 free (args_info->inputs);
279
280 clear_given (args_info);
281 }
282
283
284 static void
285 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
286 {
287 FIX_UNUSED (values);
288 if (arg) {
289 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
290 } else {
291 fprintf(outfile, "%s\n", opt);
292 }
293 }
294
295
296 int
297 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
298 {
299 int i = 0;
300
301 if (!outfile)
302 {
303 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
304 return EXIT_FAILURE;
305 }
306
307 if (args_info->help_given)
308 write_into_file(outfile, "help", 0, 0 );
309 if (args_info->version_given)
310 write_into_file(outfile, "version", 0, 0 );
311 if (args_info->fipid_given)
312 write_into_file(outfile, "fipid", args_info->fipid_orig, 0);
313 if (args_info->fid_given)
314 write_into_file(outfile, "fid", args_info->fid_orig, 0);
315 if (args_info->org_given)
316 write_into_file(outfile, "org", args_info->org_orig, 0);
317 if (args_info->bank_given)
318 write_into_file(outfile, "bank", args_info->bank_orig, 0);
319 if (args_info->broker_given)
320 write_into_file(outfile, "broker", args_info->broker_orig, 0);
321 if (args_info->user_given)
322 write_into_file(outfile, "user", args_info->user_orig, 0);
323 if (args_info->pass_given)
324 write_into_file(outfile, "pass", args_info->pass_orig, 0);
325 if (args_info->acct_given)
326 write_into_file(outfile, "acct", args_info->acct_orig, 0);
327 if (args_info->type_given)
328 write_into_file(outfile, "type", args_info->type_orig, 0);
329 if (args_info->past_given)
330 write_into_file(outfile, "past", args_info->past_orig, 0);
331 if (args_info->url_given)
332 write_into_file(outfile, "url", args_info->url_orig, 0);
333 if (args_info->trid_given)
334 write_into_file(outfile, "trid", args_info->trid_orig, 0);
335 if (args_info->statement_req_given)
336 write_into_file(outfile, "statement-req", 0, 0 );
337 if (args_info->accountinfo_req_given)
338 write_into_file(outfile, "accountinfo-req", 0, 0 );
339 if (args_info->payment_req_given)
340 write_into_file(outfile, "payment-req", 0, 0 );
341 if (args_info->paymentinquiry_req_given)
342 write_into_file(outfile, "paymentinquiry-req", 0, 0 );
343 if (args_info->bank_list_given)
344 write_into_file(outfile, "bank-list", 0, 0 );
345 if (args_info->bank_fipid_given)
346 write_into_file(outfile, "bank-fipid", 0, 0 );
347 if (args_info->bank_services_given)
348 write_into_file(outfile, "bank-services", 0, 0 );
349 if (args_info->allsupport_given)
350 write_into_file(outfile, "allsupport", 0, 0 );
351
352
353 i = EXIT_SUCCESS;
354 return i;
355 }
356
357 int
358 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
359 {
360 FILE *outfile;
361 int i = 0;
362
363 outfile = fopen(filename, "w");
364
365 if (!outfile)
366 {
367 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
368 return EXIT_FAILURE;
369 }
370
371 i = cmdline_parser_dump(outfile, args_info);
372 fclose (outfile);
373
374 return i;
375 }
376
377 void
378 cmdline_parser_free (struct gengetopt_args_info *args_info)
379 {
380 cmdline_parser_release (args_info);
381 }
382
384 char *
385 gengetopt_strdup (const char *s)
386 {
387 char *result = 0;
388 if (!s)
389 return result;
390
391 result = (char*)malloc(strlen(s) + 1);
392 if (result == (char*)0)
393 return (char*)0;
394 strcpy(result, s);
395 return result;
396 }
397
398 static void
399 reset_group_command(struct gengetopt_args_info *args_info)
400 {
401 if (! args_info->command_group_counter)
402 return;
403
404 args_info->statement_req_given = 0 ;
405 args_info->accountinfo_req_given = 0 ;
406 args_info->payment_req_given = 0 ;
407 args_info->paymentinquiry_req_given = 0 ;
408 args_info->bank_list_given = 0 ;
409 args_info->bank_fipid_given = 0 ;
410 args_info->bank_services_given = 0 ;
411 args_info->allsupport_given = 0 ;
412
413 args_info->command_group_counter = 0;
414 }
415
416 int
417 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
418 {
419 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
420 }
421
422 int
423 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
424 struct cmdline_parser_params *params)
425 {
426 int result;
427 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
428
429 if (result == EXIT_FAILURE)
430 {
431 cmdline_parser_free (args_info);
432 exit (EXIT_FAILURE);
433 }
434
435 return result;
436 }
437
438 int
439 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
440 {
441 int result;
442 struct cmdline_parser_params params;
443
444 params.override = override;
445 params.initialize = initialize;
446 params.check_required = check_required;
447 params.check_ambiguity = 0;
448 params.print_errors = 1;
449
450 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
451
452 if (result == EXIT_FAILURE)
453 {
454 cmdline_parser_free (args_info);
455 exit (EXIT_FAILURE);
456 }
457
458 return result;
459 }
460
461 int
462 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
463 {
464 FIX_UNUSED (args_info);
465 FIX_UNUSED (prog_name);
466 return EXIT_SUCCESS;
467 }
468
469
470 static char *package_name = 0;
471
490 static
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,
496 int check_ambiguity, int override,
497 int no_free, int multiple_option,
498 const char *long_opt, char short_opt,
499 const char *additional_error)
500 {
501 char *stop_char = 0;
502 const char *val = value;
503 int found;
504 char **string_field;
505 FIX_UNUSED (field);
506
507 stop_char = 0;
508 found = 0;
509
510 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
511 {
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 : ""));
516 else
517 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
518 package_name, long_opt,
519 (additional_error ? additional_error : ""));
520 return 1; /* failure */
521 }
522
523 FIX_UNUSED (default_value);
524
525 if (field_given && *field_given && ! override)
526 return 0;
527 if (prev_given)
528 (*prev_given)++;
529 if (field_given)
530 (*field_given)++;
531 if (possible_values)
532 val = possible_values[found];
533
534 switch(arg_type) {
535 case ARG_INT:
536 if (val) *((int *)field) = strtol (val, &stop_char, 0);
537 break;
538 case ARG_LONG:
539 if (val) *((long *)field) = (long)strtol (val, &stop_char, 0);
540 break;
541 case ARG_STRING:
542 if (val) {
543 string_field = (char **)field;
544 if (!no_free && *string_field)
545 free (*string_field); /* free previous string */
546 *string_field = gengetopt_strdup (val);
547 }
548 break;
549 default:
550 break;
551 };
552
553 /* check numeric conversion */
554 switch(arg_type) {
555 case ARG_INT:
556 case ARG_LONG:
557 if (val && !(stop_char && *stop_char == '\0')) {
558 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
559 return 1; /* failure */
560 }
561 break;
562 default:
563 ;
564 };
565
566 /* store the original value */
567 switch(arg_type) {
568 case ARG_NO:
569 break;
570 default:
571 if (value && orig_field) {
572 if (no_free) {
573 *orig_field = value;
574 } else {
575 if (*orig_field)
576 free (*orig_field); /* free previous string */
577 *orig_field = gengetopt_strdup (value);
578 }
579 }
580 };
581
582 return 0; /* OK */
583 }
584
585
586 int
587 cmdline_parser_internal (
588 int argc, char **argv, struct gengetopt_args_info *args_info,
589 struct cmdline_parser_params *params, const char *additional_error)
590 {
591 int c; /* Character of the parsed option. */
592
593 int error_occurred = 0;
594 struct gengetopt_args_info local_args_info;
595
596 int override;
597 int initialize;
598 int check_required;
599 int check_ambiguity;
600
601 package_name = argv[0];
602
603 override = params->override;
604 initialize = params->initialize;
605 check_required = params->check_required;
606 check_ambiguity = params->check_ambiguity;
607
608 if (initialize)
609 cmdline_parser_init (args_info);
610
611 cmdline_parser_init (&local_args_info);
612
613 optarg = 0;
614 optind = 0;
615 opterr = params->print_errors;
616 optopt = '?';
617
618 while (1)
619 {
620 int option_index = 0;
621
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 },
645 { 0, 0, 0, 0 }
646 };
647
648 c = getopt_long (argc, argv, "hVsapibfv", long_options, &option_index);
649
650 if (c == -1) break; /* Exit from `while (1)' loop. */
651
652 switch (c)
653 {
654 case 'h': /* Print help and exit. */
655 cmdline_parser_print_help ();
656 cmdline_parser_free (&local_args_info);
657 exit (EXIT_SUCCESS);
658
659 case 'V': /* Print version and exit. */
660 cmdline_parser_print_version ();
661 cmdline_parser_free (&local_args_info);
662 exit (EXIT_SUCCESS);
663
664 case 's': /* Request for a statement. */
665
666 if (args_info->command_group_counter && override)
667 reset_group_command (args_info);
668 args_info->command_group_counter += 1;
669
670 if (update_arg( 0 ,
671 0 , &(args_info->statement_req_given),
672 &(local_args_info.statement_req_given), optarg, 0, 0, ARG_NO,
673 check_ambiguity, override, 0, 0,
674 "statement-req", 's',
675 additional_error))
676 goto failure;
677
678 break;
679 case 'a': /* Request for a list of accounts. */
680
681 if (args_info->command_group_counter && override)
682 reset_group_command (args_info);
683 args_info->command_group_counter += 1;
684
685 if (update_arg( 0 ,
686 0 , &(args_info->accountinfo_req_given),
687 &(local_args_info.accountinfo_req_given), optarg, 0, 0, ARG_NO,
688 check_ambiguity, override, 0, 0,
689 "accountinfo-req", 'a',
690 additional_error))
691 goto failure;
692
693 break;
694 case 'p': /* Request to make a payment. */
695
696 if (args_info->command_group_counter && override)
697 reset_group_command (args_info);
698 args_info->command_group_counter += 1;
699
700 if (update_arg( 0 ,
701 0 , &(args_info->payment_req_given),
702 &(local_args_info.payment_req_given), optarg, 0, 0, ARG_NO,
703 check_ambiguity, override, 0, 0,
704 "payment-req", 'p',
705 additional_error))
706 goto failure;
707
708 break;
709 case 'i': /* Request to inquire about the status of a payment. */
710
711 if (args_info->command_group_counter && override)
712 reset_group_command (args_info);
713 args_info->command_group_counter += 1;
714
715 if (update_arg( 0 ,
716 0 , &(args_info->paymentinquiry_req_given),
717 &(local_args_info.paymentinquiry_req_given), optarg, 0, 0, ARG_NO,
718 check_ambiguity, override, 0, 0,
719 "paymentinquiry-req", 'i',
720 additional_error))
721 goto failure;
722
723 break;
724 case 'b': /* List all known banks. */
725
726 if (args_info->command_group_counter && override)
727 reset_group_command (args_info);
728 args_info->command_group_counter += 1;
729
730 if (update_arg( 0 ,
731 0 , &(args_info->bank_list_given),
732 &(local_args_info.bank_list_given), optarg, 0, 0, ARG_NO,
733 check_ambiguity, override, 0, 0,
734 "bank-list", 'b',
735 additional_error))
736 goto failure;
737
738 break;
739 case 'f': /* List all fipids for a given bank. */
740
741 if (args_info->command_group_counter && override)
742 reset_group_command (args_info);
743 args_info->command_group_counter += 1;
744
745 if (update_arg( 0 ,
746 0 , &(args_info->bank_fipid_given),
747 &(local_args_info.bank_fipid_given), optarg, 0, 0, ARG_NO,
748 check_ambiguity, override, 0, 0,
749 "bank-fipid", 'f',
750 additional_error))
751 goto failure;
752
753 break;
754 case 'v': /* List supported services for a given fipid. */
755
756 if (args_info->command_group_counter && override)
757 reset_group_command (args_info);
758 args_info->command_group_counter += 1;
759
760 if (update_arg( 0 ,
761 0 , &(args_info->bank_services_given),
762 &(local_args_info.bank_services_given), optarg, 0, 0, ARG_NO,
763 check_ambiguity, override, 0, 0,
764 "bank-services", 'v',
765 additional_error))
766 goto failure;
767
768 break;
769
770 case 0: /* Long option with no short option */
771 /* FI partner identifier (looks up fid, org & url from partner server). */
772 if (strcmp (long_options[option_index].name, "fipid") == 0)
773 {
774
775
776 if (update_arg( (void *)&(args_info->fipid_arg),
777 &(args_info->fipid_orig), &(args_info->fipid_given),
778 &(local_args_info.fipid_given), optarg, 0, 0, ARG_STRING,
779 check_ambiguity, override, 0, 0,
780 "fipid", '-',
781 additional_error))
782 goto failure;
783
784 }
785 /* FI identifier. */
786 else if (strcmp (long_options[option_index].name, "fid") == 0)
787 {
788
789
790 if (update_arg( (void *)&(args_info->fid_arg),
791 &(args_info->fid_orig), &(args_info->fid_given),
792 &(local_args_info.fid_given), optarg, 0, 0, ARG_STRING,
793 check_ambiguity, override, 0, 0,
794 "fid", '-',
795 additional_error))
796 goto failure;
797
798 }
799 /* FI org tag. */
800 else if (strcmp (long_options[option_index].name, "org") == 0)
801 {
802
803
804 if (update_arg( (void *)&(args_info->org_arg),
805 &(args_info->org_orig), &(args_info->org_given),
806 &(local_args_info.org_given), optarg, 0, 0, ARG_STRING,
807 check_ambiguity, override, 0, 0,
808 "org", '-',
809 additional_error))
810 goto failure;
811
812 }
813 /* IBAN bank identifier. */
814 else if (strcmp (long_options[option_index].name, "bank") == 0)
815 {
816
817
818 if (update_arg( (void *)&(args_info->bank_arg),
819 &(args_info->bank_orig), &(args_info->bank_given),
820 &(local_args_info.bank_given), optarg, 0, 0, ARG_STRING,
821 check_ambiguity, override, 0, 0,
822 "bank", '-',
823 additional_error))
824 goto failure;
825
826 }
827 /* Broker identifier. */
828 else if (strcmp (long_options[option_index].name, "broker") == 0)
829 {
830
831
832 if (update_arg( (void *)&(args_info->broker_arg),
833 &(args_info->broker_orig), &(args_info->broker_given),
834 &(local_args_info.broker_given), optarg, 0, 0, ARG_STRING,
835 check_ambiguity, override, 0, 0,
836 "broker", '-',
837 additional_error))
838 goto failure;
839
840 }
841 /* User name. */
842 else if (strcmp (long_options[option_index].name, "user") == 0)
843 {
844
845
846 if (update_arg( (void *)&(args_info->user_arg),
847 &(args_info->user_orig), &(args_info->user_given),
848 &(local_args_info.user_given), optarg, 0, 0, ARG_STRING,
849 check_ambiguity, override, 0, 0,
850 "user", '-',
851 additional_error))
852 goto failure;
853
854 }
855 /* Password. */
856 else if (strcmp (long_options[option_index].name, "pass") == 0)
857 {
858
859
860 if (update_arg( (void *)&(args_info->pass_arg),
861 &(args_info->pass_orig), &(args_info->pass_given),
862 &(local_args_info.pass_given), optarg, 0, 0, ARG_STRING,
863 check_ambiguity, override, 0, 0,
864 "pass", '-',
865 additional_error))
866 goto failure;
867
868 }
869 /* Account ID. */
870 else if (strcmp (long_options[option_index].name, "acct") == 0)
871 {
872
873
874 if (update_arg( (void *)&(args_info->acct_arg),
875 &(args_info->acct_orig), &(args_info->acct_given),
876 &(local_args_info.acct_given), optarg, 0, 0, ARG_STRING,
877 check_ambiguity, override, 0, 0,
878 "acct", '-',
879 additional_error))
880 goto failure;
881
882 }
883 /* Account Type 1=checking 2=invest 3=ccard. */
884 else if (strcmp (long_options[option_index].name, "type") == 0)
885 {
886
887
888 if (update_arg( (void *)&(args_info->type_arg),
889 &(args_info->type_orig), &(args_info->type_given),
890 &(local_args_info.type_given), optarg, 0, 0, ARG_INT,
891 check_ambiguity, override, 0, 0,
892 "type", '-',
893 additional_error))
894 goto failure;
895
896 }
897 /* How far back to look from today (in days). */
898 else if (strcmp (long_options[option_index].name, "past") == 0)
899 {
900
901
902 if (update_arg( (void *)&(args_info->past_arg),
903 &(args_info->past_orig), &(args_info->past_given),
904 &(local_args_info.past_given), optarg, 0, 0, ARG_LONG,
905 check_ambiguity, override, 0, 0,
906 "past", '-',
907 additional_error))
908 goto failure;
909
910 }
911 /* Url to POST the data to (otherwise goes to stdout). */
912 else if (strcmp (long_options[option_index].name, "url") == 0)
913 {
914
915
916 if (update_arg( (void *)&(args_info->url_arg),
917 &(args_info->url_orig), &(args_info->url_given),
918 &(local_args_info.url_given), optarg, 0, 0, ARG_STRING,
919 check_ambiguity, override, 0, 0,
920 "url", '-',
921 additional_error))
922 goto failure;
923
924 }
925 /* Transaction id. */
926 else if (strcmp (long_options[option_index].name, "trid") == 0)
927 {
928
929
930 if (update_arg( (void *)&(args_info->trid_arg),
931 &(args_info->trid_orig), &(args_info->trid_given),
932 &(local_args_info.trid_given), optarg, 0, 0, ARG_INT,
933 check_ambiguity, override, 0, 0,
934 "trid", '-',
935 additional_error))
936 goto failure;
937
938 }
939 /* List all banks which support online banking. */
940 else if (strcmp (long_options[option_index].name, "allsupport") == 0)
941 {
942
943 if (args_info->command_group_counter && override)
944 reset_group_command (args_info);
945 args_info->command_group_counter += 1;
946
947 if (update_arg( 0 ,
948 0 , &(args_info->allsupport_given),
949 &(local_args_info.allsupport_given), optarg, 0, 0, ARG_NO,
950 check_ambiguity, override, 0, 0,
951 "allsupport", '-',
952 additional_error))
953 goto failure;
954
955 }
956
957 break;
958 case '?': /* Invalid option. */
959 /* `getopt_long' already printed an error message. */
960 goto failure;
961
962 default: /* bug: option not considered. */
963 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
964 abort ();
965 } /* switch */
966 } /* while */
967
968 if (args_info->command_group_counter > 1)
969 {
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 : ""));
971 error_occurred = 1;
972 }
973
974
975
976
977 cmdline_parser_release (&local_args_info);
978
979 if ( error_occurred )
980 return (EXIT_FAILURE);
981
982 if (optind < argc)
983 {
984 int i = 0 ;
985 int found_prog_name = 0;
986 /* whether program name, i.e., argv[0], is in the remaining args
987 (this may happen with some implementations of getopt,
988 but surely not with the one included by gengetopt) */
989
990 i = optind;
991 while (i < argc)
992 if (argv[i++] == argv[0]) {
993 found_prog_name = 1;
994 break;
995 }
996 i = 0;
997
998 args_info->inputs_num = argc - optind - found_prog_name;
999 args_info->inputs =
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]) ;
1004 }
1005
1006 return 0;
1007
1008 failure:
1009
1010 cmdline_parser_release (&local_args_info);
1011 return (EXIT_FAILURE);
1012 }
gengetopt_args_info::allsupport_given
unsigned int allsupport_given
Whether allsupport was given.
Definition: ofxconnect/cmdline.h:112
gengetopt_args_info::bank_list_help
const char * bank_list_help
List all known banks help description.
Definition: ofxconnect/cmdline.h:86
cmdline_parser_params::override
int override
whether to override possibly already present options (default 0)
Definition: ofxconnect/cmdline.h:122
gengetopt_args_info::allsupport_help
const char * allsupport_help
List all banks which support online banking help description.
Definition: ofxconnect/cmdline.h:89
gengetopt_args_info::past_orig
char * past_orig
How far back to look from today (in days) original value given at command line.
Definition: ofxconnect/cmdline.h:74
gengetopt_args_info::org_given
unsigned int org_given
Whether org was given.
Definition: ofxconnect/cmdline.h:95
gengetopt_args_info::accountinfo_req_help
const char * accountinfo_req_help
Request for a list of accounts help description.
Definition: ofxconnect/cmdline.h:83
cmdline_parser_params::initialize
int initialize
whether to initialize the option structure gengetopt_args_info (default 1)
Definition: ofxconnect/cmdline.h:123
gengetopt_args_info::type_orig
char * type_orig
Account Type 1=checking 2=invest 3=ccard original value given at command line.
Definition: ofxconnect/cmdline.h:71
gengetopt_args_info::url_orig
char * url_orig
Url to POST the data to (otherwise goes to stdout) original value given at command line...
Definition: ofxconnect/cmdline.h:77
gengetopt_args_info::past_arg
long past_arg
How far back to look from today (in days).
Definition: ofxconnect/cmdline.h:73
gengetopt_args_info::payment_req_given
unsigned int payment_req_given
Whether payment-req was given.
Definition: ofxconnect/cmdline.h:107
gengetopt_args_info::fid_given
unsigned int fid_given
Whether fid was given.
Definition: ofxconnect/cmdline.h:94
gengetopt_args_info
Where the command line options are stored.
Definition: ofxconnect/cmdline.h:42
gengetopt_args_info::help_given
unsigned int help_given
Whether help was given.
Definition: ofxconnect/cmdline.h:91
gengetopt_args_info::type_given
unsigned int type_given
Whether type was given.
Definition: ofxconnect/cmdline.h:101
gengetopt_args_info::fid_arg
char * fid_arg
FI identifier.
Definition: ofxconnect/cmdline.h:49
gengetopt_args_info::bank_given
unsigned int bank_given
Whether bank was given.
Definition: ofxconnect/cmdline.h:96
gengetopt_args_info::type_help
const char * type_help
Account Type 1=checking 2=invest 3=ccard help description.
Definition: ofxconnect/cmdline.h:72
gengetopt_args_info::bank_fipid_given
unsigned int bank_fipid_given
Whether bank-fipid was given.
Definition: ofxconnect/cmdline.h:110
gengetopt_args_info::pass_help
const char * pass_help
Password help description.
Definition: ofxconnect/cmdline.h:66
gengetopt_args_info::user_help
const char * user_help
User name help description.
Definition: ofxconnect/cmdline.h:63
cmdline_parser_params
The additional parameters to pass to parser functions.
Definition: ofxconnect/cmdline.h:120
gengetopt_args_info::url_arg
char * url_arg
Url to POST the data to (otherwise goes to stdout).
Definition: ofxconnect/cmdline.h:76
gengetopt_args_info::version_help
const char * version_help
Print version and exit help description.
Definition: ofxconnect/cmdline.h:45
gengetopt_args_info::acct_help
const char * acct_help
Account ID help description.
Definition: ofxconnect/cmdline.h:69
option
Definition: build/libofx-0.10.0/lib/gnugetopt.h:94
gengetopt_args_info::bank_orig
char * bank_orig
IBAN bank identifier original value given at command line.
Definition: ofxconnect/cmdline.h:56
gengetopt_args_info::bank_fipid_help
const char * bank_fipid_help
List all fipids for a given bank help description.
Definition: ofxconnect/cmdline.h:87
gengetopt_args_info::bank_services_given
unsigned int bank_services_given
Whether bank-services was given.
Definition: ofxconnect/cmdline.h:111
gengetopt_args_info::fipid_arg
char * fipid_arg
FI partner identifier (looks up fid, org & url from partner server).
Definition: ofxconnect/cmdline.h:46
gengetopt_args_info::url_given
unsigned int url_given
Whether url was given.
Definition: ofxconnect/cmdline.h:103
gengetopt_args_info::fid_help
const char * fid_help
FI identifier help description.
Definition: ofxconnect/cmdline.h:51
gengetopt_args_info::url_help
const char * url_help
Url to POST the data to (otherwise goes to stdout) help description.
Definition: ofxconnect/cmdline.h:78
gengetopt_args_info::fipid_orig
char * fipid_orig
FI partner identifier (looks up fid, org & url from partner server) original value given at command l...
Definition: ofxconnect/cmdline.h:47
gengetopt_args_info::acct_orig
char * acct_orig
Account ID original value given at command line.
Definition: ofxconnect/cmdline.h:68
gengetopt_args_info::bank_help
const char * bank_help
IBAN bank identifier help description.
Definition: ofxconnect/cmdline.h:57
gengetopt_args_info::help_help
const char * help_help
Print help and exit help description.
Definition: ofxconnect/cmdline.h:44
gengetopt_args_info::user_orig
char * user_orig
User name original value given at command line.
Definition: ofxconnect/cmdline.h:62
gengetopt_args_info::fipid_given
unsigned int fipid_given
Whether fipid was given.
Definition: ofxconnect/cmdline.h:93
gengetopt_args_info::acct_arg
char * acct_arg
Account ID.
Definition: ofxconnect/cmdline.h:67
gengetopt_args_info::statement_req_help
const char * statement_req_help
Request for a statement help description.
Definition: ofxconnect/cmdline.h:82
gengetopt_args_info::user_arg
char * user_arg
User name.
Definition: ofxconnect/cmdline.h:61
gengetopt_args_info::bank_list_given
unsigned int bank_list_given
Whether bank-list was given.
Definition: ofxconnect/cmdline.h:109
gengetopt_args_info::payment_req_help
const char * payment_req_help
Request to make a payment help description.
Definition: ofxconnect/cmdline.h:84
gengetopt_args_info::pass_given
unsigned int pass_given
Whether pass was given.
Definition: ofxconnect/cmdline.h:99
gengetopt_args_info::inputs_num
unsigned inputs_num
unamed options number
Definition: ofxconnect/cmdline.h:115
gengetopt_args_info::trid_arg
int trid_arg
Transaction id.
Definition: ofxconnect/cmdline.h:79
gengetopt_args_info::past_help
const char * past_help
How far back to look from today (in days) help description.
Definition: ofxconnect/cmdline.h:75
gengetopt_args_info::statement_req_given
unsigned int statement_req_given
Whether statement-req was given.
Definition: ofxconnect/cmdline.h:105
gengetopt_args_info::paymentinquiry_req_help
const char * paymentinquiry_req_help
Request to inquire about the status of a payment help description.
Definition: ofxconnect/cmdline.h:85
cmdline_parser_params::print_errors
int print_errors
whether getopt_long should print an error message for a bad option (default 1)
Definition: ofxconnect/cmdline.h:126
gengetopt_args_info::trid_given
unsigned int trid_given
Whether trid was given.
Definition: ofxconnect/cmdline.h:104
cmdline_parser_params::check_ambiguity
int check_ambiguity
whether to check for options already specified in the option structure gengetopt_args_info (default 0...
Definition: ofxconnect/cmdline.h:125
cmdline_parser_params::check_required
int check_required
whether to check that all required options were provided (default 1)
Definition: ofxconnect/cmdline.h:124
gengetopt_args_info::command_group_counter
int command_group_counter
Counter for group command.
Definition: ofxconnect/cmdline.h:116
gengetopt_args_info::past_given
unsigned int past_given
Whether past was given.
Definition: ofxconnect/cmdline.h:102
gengetopt_args_info::acct_given
unsigned int acct_given
Whether acct was given.
Definition: ofxconnect/cmdline.h:100
gengetopt_args_info::bank_services_help
const char * bank_services_help
List supported services for a given fipid help description.
Definition: ofxconnect/cmdline.h:88
gengetopt_args_info::trid_help
const char * trid_help
Transaction id help description.
Definition: ofxconnect/cmdline.h:81
gengetopt_args_info::inputs
char ** inputs
unamed options (options without names)
Definition: ofxconnect/cmdline.h:114
gengetopt_args_info::org_help
const char * org_help
FI org tag help description.
Definition: ofxconnect/cmdline.h:54
gengetopt_args_info::org_orig
char * org_orig
FI org tag original value given at command line.
Definition: ofxconnect/cmdline.h:53
gengetopt_args_info::fid_orig
char * fid_orig
FI identifier original value given at command line.
Definition: ofxconnect/cmdline.h:50
gengetopt_args_info::user_given
unsigned int user_given
Whether user was given.
Definition: ofxconnect/cmdline.h:98
gengetopt_args_info::paymentinquiry_req_given
unsigned int paymentinquiry_req_given
Whether paymentinquiry-req was given.
Definition: ofxconnect/cmdline.h:108
gengetopt_args_info::broker_help
const char * broker_help
Broker identifier help description.
Definition: ofxconnect/cmdline.h:60
gengetopt_args_info::accountinfo_req_given
unsigned int accountinfo_req_given
Whether accountinfo-req was given.
Definition: ofxconnect/cmdline.h:106
gengetopt_args_info::pass_orig
char * pass_orig
Password original value given at command line.
Definition: ofxconnect/cmdline.h:65
gengetopt_args_info::trid_orig
char * trid_orig
Transaction id original value given at command line.
Definition: ofxconnect/cmdline.h:80
gengetopt_args_info::broker_orig
char * broker_orig
Broker identifier original value given at command line.
Definition: ofxconnect/cmdline.h:59
gengetopt_args_info::bank_arg
char * bank_arg
IBAN bank identifier.
Definition: ofxconnect/cmdline.h:55
gengetopt_args_info::broker_given
unsigned int broker_given
Whether broker was given.
Definition: ofxconnect/cmdline.h:97
gengetopt_args_info::fipid_help
const char * fipid_help
FI partner identifier (looks up fid, org & url from partner server) help description.
Definition: ofxconnect/cmdline.h:48
gengetopt_args_info::org_arg
char * org_arg
FI org tag.
Definition: ofxconnect/cmdline.h:52
gengetopt_args_info::broker_arg
char * broker_arg
Broker identifier.
Definition: ofxconnect/cmdline.h:58
gengetopt_args_info::type_arg
int type_arg
Account Type 1=checking 2=invest 3=ccard.
Definition: ofxconnect/cmdline.h:70
gengetopt_args_info::pass_arg
char * pass_arg
Password.
Definition: ofxconnect/cmdline.h:64
gengetopt_args_info::version_given
unsigned int version_given
Whether version was given.
Definition: ofxconnect/cmdline.h:92