LibOFX

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