LibOFX
ofxconnect/cmdline.c
1 /*
2  File autogenerated by gengetopt version 2.23
3  generated with the following command:
4  gengetopt --unamed-opts -i cmdline.ggo
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  " --fid=STRING FI identifier",
40  " --org=STRING FI org tag",
41  " --bank=STRING IBAN bank identifier",
42  " --broker=STRING Broker identifier",
43  " --user=STRING User name",
44  " --pass=STRING Password",
45  " --acct=STRING Account ID",
46  " --type=INT Account Type 1=checking 2=invest 3=ccard",
47  " --past=LONG How far back to look from today (in days)",
48  " --url=STRING Url to POST the data to (otherwise goes to stdout)",
49  " --trid=INT Transaction id",
50  "\n Group: command",
51  " -s, --statement-req Request for a statement",
52  " -a, --accountinfo-req Request for a list of accounts",
53  " -p, --payment-req Request to make a payment",
54  " -i, --paymentinquiry-req Request to inquire about the status of a payment",
55  0
56 };
57 
58 typedef enum {ARG_NO
59  , ARG_STRING
60  , ARG_INT
61  , ARG_LONG
62 } cmdline_parser_arg_type;
63 
64 static
65 void clear_given (struct gengetopt_args_info *args_info);
66 static
67 void clear_args (struct gengetopt_args_info *args_info);
68 
69 static int
70 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
71  struct cmdline_parser_params *params, const char *additional_error);
72 
73 
74 static char *
75 gengetopt_strdup (const char *s);
76 
77 static
78 void clear_given (struct gengetopt_args_info *args_info)
79 {
80  args_info->help_given = 0 ;
81  args_info->version_given = 0 ;
82  args_info->fid_given = 0 ;
83  args_info->org_given = 0 ;
84  args_info->bank_given = 0 ;
85  args_info->broker_given = 0 ;
86  args_info->user_given = 0 ;
87  args_info->pass_given = 0 ;
88  args_info->acct_given = 0 ;
89  args_info->type_given = 0 ;
90  args_info->past_given = 0 ;
91  args_info->url_given = 0 ;
92  args_info->trid_given = 0 ;
93  args_info->statement_req_given = 0 ;
94  args_info->accountinfo_req_given = 0 ;
95  args_info->payment_req_given = 0 ;
96  args_info->paymentinquiry_req_given = 0 ;
97  args_info->command_group_counter = 0 ;
98 }
99 
100 static
101 void clear_args (struct gengetopt_args_info *args_info)
102 {
103  FIX_UNUSED (args_info);
104  args_info->fid_arg = NULL;
105  args_info->fid_orig = NULL;
106  args_info->org_arg = NULL;
107  args_info->org_orig = NULL;
108  args_info->bank_arg = NULL;
109  args_info->bank_orig = NULL;
110  args_info->broker_arg = NULL;
111  args_info->broker_orig = NULL;
112  args_info->user_arg = NULL;
113  args_info->user_orig = NULL;
114  args_info->pass_arg = NULL;
115  args_info->pass_orig = NULL;
116  args_info->acct_arg = NULL;
117  args_info->acct_orig = NULL;
118  args_info->type_orig = NULL;
119  args_info->past_orig = NULL;
120  args_info->url_arg = NULL;
121  args_info->url_orig = NULL;
122  args_info->trid_orig = NULL;
123 
124 }
125 
126 static
127 void init_args_info(struct gengetopt_args_info *args_info)
128 {
129 
130 
131  args_info->help_help = gengetopt_args_info_help[0] ;
132  args_info->version_help = gengetopt_args_info_help[1] ;
133  args_info->fid_help = gengetopt_args_info_help[2] ;
134  args_info->org_help = gengetopt_args_info_help[3] ;
135  args_info->bank_help = gengetopt_args_info_help[4] ;
136  args_info->broker_help = gengetopt_args_info_help[5] ;
137  args_info->user_help = gengetopt_args_info_help[6] ;
138  args_info->pass_help = gengetopt_args_info_help[7] ;
139  args_info->acct_help = gengetopt_args_info_help[8] ;
140  args_info->type_help = gengetopt_args_info_help[9] ;
141  args_info->past_help = gengetopt_args_info_help[10] ;
142  args_info->url_help = gengetopt_args_info_help[11] ;
143  args_info->trid_help = gengetopt_args_info_help[12] ;
144  args_info->statement_req_help = gengetopt_args_info_help[14] ;
145  args_info->accountinfo_req_help = gengetopt_args_info_help[15] ;
146  args_info->payment_req_help = gengetopt_args_info_help[16] ;
147  args_info->paymentinquiry_req_help = gengetopt_args_info_help[17] ;
148 
149 }
150 
151 void
152 cmdline_parser_print_version (void)
153 {
154  printf ("%s %s\n",
155  (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
156  CMDLINE_PARSER_VERSION);
157 
158  if (strlen(gengetopt_args_info_versiontext) > 0)
159  printf("\n%s\n", gengetopt_args_info_versiontext);
160 }
161 
162 static void print_help_common(void)
163 {
164  size_t len_purpose = strlen(gengetopt_args_info_purpose);
165  size_t len_usage = strlen(gengetopt_args_info_usage);
166 
167  if (len_usage > 0) {
168  printf("%s\n", gengetopt_args_info_usage);
169  }
170  if (len_purpose > 0) {
171  printf("%s\n", gengetopt_args_info_purpose);
172  }
173 
174  if (len_usage || len_purpose) {
175  printf("\n");
176  }
177 
178  if (strlen(gengetopt_args_info_description) > 0) {
179  printf("%s\n\n", gengetopt_args_info_description);
180  }
181 }
182 
183 void
184 cmdline_parser_print_help (void)
185 {
186  int i = 0;
187  print_help_common();
188  while (gengetopt_args_info_help[i])
189  printf("%s\n", gengetopt_args_info_help[i++]);
190 }
191 
192 void
193 cmdline_parser_init (struct gengetopt_args_info *args_info)
194 {
195  clear_given (args_info);
196  clear_args (args_info);
197  init_args_info (args_info);
198 
199  args_info->inputs = 0;
200  args_info->inputs_num = 0;
201 }
202 
203 void
204 cmdline_parser_params_init(struct cmdline_parser_params *params)
205 {
206  if (params)
207  {
208  params->override = 0;
209  params->initialize = 1;
210  params->check_required = 1;
211  params->check_ambiguity = 0;
212  params->print_errors = 1;
213  }
214 }
215 
216 struct cmdline_parser_params *
217 cmdline_parser_params_create(void)
218 {
219  struct cmdline_parser_params *params =
220  (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
221  cmdline_parser_params_init(params);
222  return params;
223 }
224 
225 static void
226 free_string_field (char **s)
227 {
228  if (*s)
229  {
230  free (*s);
231  *s = 0;
232  }
233 }
234 
235 
236 static void
237 cmdline_parser_release (struct gengetopt_args_info *args_info)
238 {
239  unsigned int i;
240  free_string_field (&(args_info->fid_arg));
241  free_string_field (&(args_info->fid_orig));
242  free_string_field (&(args_info->org_arg));
243  free_string_field (&(args_info->org_orig));
244  free_string_field (&(args_info->bank_arg));
245  free_string_field (&(args_info->bank_orig));
246  free_string_field (&(args_info->broker_arg));
247  free_string_field (&(args_info->broker_orig));
248  free_string_field (&(args_info->user_arg));
249  free_string_field (&(args_info->user_orig));
250  free_string_field (&(args_info->pass_arg));
251  free_string_field (&(args_info->pass_orig));
252  free_string_field (&(args_info->acct_arg));
253  free_string_field (&(args_info->acct_orig));
254  free_string_field (&(args_info->type_orig));
255  free_string_field (&(args_info->past_orig));
256  free_string_field (&(args_info->url_arg));
257  free_string_field (&(args_info->url_orig));
258  free_string_field (&(args_info->trid_orig));
259 
260 
261  for (i = 0; i < args_info->inputs_num; ++i)
262  free (args_info->inputs [i]);
263 
264  if (args_info->inputs_num)
265  free (args_info->inputs);
266 
267  clear_given (args_info);
268 }
269 
270 
271 static void
272 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
273 {
274  FIX_UNUSED (values);
275  if (arg) {
276  fprintf(outfile, "%s=\"%s\"\n", opt, arg);
277  } else {
278  fprintf(outfile, "%s\n", opt);
279  }
280 }
281 
282 
283 int
284 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
285 {
286  int i = 0;
287 
288  if (!outfile)
289  {
290  fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
291  return EXIT_FAILURE;
292  }
293 
294  if (args_info->help_given)
295  write_into_file(outfile, "help", 0, 0 );
296  if (args_info->version_given)
297  write_into_file(outfile, "version", 0, 0 );
298  if (args_info->fid_given)
299  write_into_file(outfile, "fid", args_info->fid_orig, 0);
300  if (args_info->org_given)
301  write_into_file(outfile, "org", args_info->org_orig, 0);
302  if (args_info->bank_given)
303  write_into_file(outfile, "bank", args_info->bank_orig, 0);
304  if (args_info->broker_given)
305  write_into_file(outfile, "broker", args_info->broker_orig, 0);
306  if (args_info->user_given)
307  write_into_file(outfile, "user", args_info->user_orig, 0);
308  if (args_info->pass_given)
309  write_into_file(outfile, "pass", args_info->pass_orig, 0);
310  if (args_info->acct_given)
311  write_into_file(outfile, "acct", args_info->acct_orig, 0);
312  if (args_info->type_given)
313  write_into_file(outfile, "type", args_info->type_orig, 0);
314  if (args_info->past_given)
315  write_into_file(outfile, "past", args_info->past_orig, 0);
316  if (args_info->url_given)
317  write_into_file(outfile, "url", args_info->url_orig, 0);
318  if (args_info->trid_given)
319  write_into_file(outfile, "trid", args_info->trid_orig, 0);
320  if (args_info->statement_req_given)
321  write_into_file(outfile, "statement-req", 0, 0 );
322  if (args_info->accountinfo_req_given)
323  write_into_file(outfile, "accountinfo-req", 0, 0 );
324  if (args_info->payment_req_given)
325  write_into_file(outfile, "payment-req", 0, 0 );
326  if (args_info->paymentinquiry_req_given)
327  write_into_file(outfile, "paymentinquiry-req", 0, 0 );
328 
329 
330  i = EXIT_SUCCESS;
331  return i;
332 }
333 
334 int
335 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
336 {
337  FILE *outfile;
338  int i = 0;
339 
340  outfile = fopen(filename, "w");
341 
342  if (!outfile)
343  {
344  fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
345  return EXIT_FAILURE;
346  }
347 
348  i = cmdline_parser_dump(outfile, args_info);
349  fclose (outfile);
350 
351  return i;
352 }
353 
354 void
355 cmdline_parser_free (struct gengetopt_args_info *args_info)
356 {
357  cmdline_parser_release (args_info);
358 }
359 
361 char *
362 gengetopt_strdup (const char *s)
363 {
364  char *result = 0;
365  if (!s)
366  return result;
367 
368  result = (char*)malloc(strlen(s) + 1);
369  if (result == (char*)0)
370  return (char*)0;
371  strcpy(result, s);
372  return result;
373 }
374 
375 static void
376 reset_group_command(struct gengetopt_args_info *args_info)
377 {
378  if (! args_info->command_group_counter)
379  return;
380 
381  args_info->statement_req_given = 0 ;
382  args_info->accountinfo_req_given = 0 ;
383  args_info->payment_req_given = 0 ;
384  args_info->paymentinquiry_req_given = 0 ;
385 
386  args_info->command_group_counter = 0;
387 }
388 
389 int
390 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
391 {
392  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
393 }
394 
395 int
396 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
397  struct cmdline_parser_params *params)
398 {
399  int result;
400  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
401 
402  if (result == EXIT_FAILURE)
403  {
404  cmdline_parser_free (args_info);
405  exit (EXIT_FAILURE);
406  }
407 
408  return result;
409 }
410 
411 int
412 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
413 {
414  int result;
415  struct cmdline_parser_params params;
416 
417  params.override = override;
418  params.initialize = initialize;
420  params.check_ambiguity = 0;
421  params.print_errors = 1;
422 
423  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
424 
425  if (result == EXIT_FAILURE)
426  {
427  cmdline_parser_free (args_info);
428  exit (EXIT_FAILURE);
429  }
430 
431  return result;
432 }
433 
434 int
435 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
436 {
437  FIX_UNUSED (args_info);
438  FIX_UNUSED (prog_name);
439  return EXIT_SUCCESS;
440 }
441 
442 
443 static char *package_name = 0;
444 
463 static
464 int update_arg(void *field, char **orig_field,
465  unsigned int *field_given, unsigned int *prev_given,
466  char *value, const char *possible_values[],
467  const char *default_value,
468  cmdline_parser_arg_type arg_type,
469  int check_ambiguity, int override,
470  int no_free, int multiple_option,
471  const char *long_opt, char short_opt,
472  const char *additional_error)
473 {
474  char *stop_char = 0;
475  const char *val = value;
476  int found;
477  char **string_field;
478  FIX_UNUSED (field);
479 
480  stop_char = 0;
481  found = 0;
482 
483  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
484  {
485  if (short_opt != '-')
486  fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
487  package_name, long_opt, short_opt,
488  (additional_error ? additional_error : ""));
489  else
490  fprintf (stderr, "%s: `--%s' option given more than once%s\n",
491  package_name, long_opt,
492  (additional_error ? additional_error : ""));
493  return 1; /* failure */
494  }
495 
496  FIX_UNUSED (default_value);
497 
498  if (field_given && *field_given && ! override)
499  return 0;
500  if (prev_given)
501  (*prev_given)++;
502  if (field_given)
503  (*field_given)++;
504  if (possible_values)
505  val = possible_values[found];
506 
507  switch(arg_type) {
508  case ARG_INT:
509  if (val) *((int *)field) = strtol (val, &stop_char, 0);
510  break;
511  case ARG_LONG:
512  if (val) *((long *)field) = (long)strtol (val, &stop_char, 0);
513  break;
514  case ARG_STRING:
515  if (val) {
516  string_field = (char **)field;
517  if (!no_free && *string_field)
518  free (*string_field); /* free previous string */
519  *string_field = gengetopt_strdup (val);
520  }
521  break;
522  default:
523  break;
524  };
525 
526  /* check numeric conversion */
527  switch(arg_type) {
528  case ARG_INT:
529  case ARG_LONG:
530  if (val && !(stop_char && *stop_char == '\0')) {
531  fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
532  return 1; /* failure */
533  }
534  break;
535  default:
536  ;
537  };
538 
539  /* store the original value */
540  switch(arg_type) {
541  case ARG_NO:
542  break;
543  default:
544  if (value && orig_field) {
545  if (no_free) {
546  *orig_field = value;
547  } else {
548  if (*orig_field)
549  free (*orig_field); /* free previous string */
550  *orig_field = gengetopt_strdup (value);
551  }
552  }
553  };
554 
555  return 0; /* OK */
556 }
557 
558 
559 int
560 cmdline_parser_internal (
561  int argc, char **argv, struct gengetopt_args_info *args_info,
562  struct cmdline_parser_params *params, const char *additional_error)
563 {
564  int c; /* Character of the parsed option. */
565 
566  int error_occurred = 0;
567  struct gengetopt_args_info local_args_info;
568 
569  int override;
570  int initialize;
571  int check_required;
572  int check_ambiguity;
573 
574  package_name = argv[0];
575 
576  /* TODO: Why is this here? It is not used anywhere. */
577  override = params->override;
578  FIX_UNUSED(override);
579 
580  initialize = params->initialize;
581  check_required = params->check_required;
582 
583  /* TODO: Why is this here? It is not used anywhere. */
584  check_ambiguity = params->check_ambiguity;
585  FIX_UNUSED(check_ambiguity);
586 
587  if (initialize)
588  cmdline_parser_init (args_info);
589 
590  cmdline_parser_init (&local_args_info);
591 
592  optarg = 0;
593  optind = 0;
594  opterr = params->print_errors;
595  optopt = '?';
596 
597  while (1)
598  {
599  int option_index = 0;
600 
601  static struct option long_options[] = {
602  { "help", 0, NULL, 'h' },
603  { "version", 0, NULL, 'V' },
604  { "fid", 1, NULL, 0 },
605  { "org", 1, NULL, 0 },
606  { "bank", 1, NULL, 0 },
607  { "broker", 1, NULL, 0 },
608  { "user", 1, NULL, 0 },
609  { "pass", 1, NULL, 0 },
610  { "acct", 1, NULL, 0 },
611  { "type", 1, NULL, 0 },
612  { "past", 1, NULL, 0 },
613  { "url", 1, NULL, 0 },
614  { "trid", 1, NULL, 0 },
615  { "statement-req", 0, NULL, 's' },
616  { "accountinfo-req", 0, NULL, 'a' },
617  { "payment-req", 0, NULL, 'p' },
618  { "paymentinquiry-req", 0, NULL, 'i' },
619  { 0, 0, 0, 0 }
620  };
621 
622  c = getopt_long (argc, argv, "hVsapi", long_options, &option_index);
623 
624  if (c == -1) break; /* Exit from `while (1)' loop. */
625 
626  switch (c)
627  {
628  case 'h': /* Print help and exit. */
629  cmdline_parser_print_help ();
630  cmdline_parser_free (&local_args_info);
631  exit (EXIT_SUCCESS);
632 
633  case 'V': /* Print version and exit. */
634  cmdline_parser_print_version ();
635  cmdline_parser_free (&local_args_info);
636  exit (EXIT_SUCCESS);
637 
638  case 's': /* Request for a statement. */
639 
640  if (args_info->command_group_counter && override)
641  reset_group_command (args_info);
642  args_info->command_group_counter += 1;
643 
644  if (update_arg( 0 ,
645  0 , &(args_info->statement_req_given),
646  &(local_args_info.statement_req_given), optarg, 0, 0, ARG_NO,
647  check_ambiguity, override, 0, 0,
648  "statement-req", 's',
649  additional_error))
650  goto failure;
651 
652  break;
653  case 'a': /* Request for a list of accounts. */
654 
655  if (args_info->command_group_counter && override)
656  reset_group_command (args_info);
657  args_info->command_group_counter += 1;
658 
659  if (update_arg( 0 ,
660  0 , &(args_info->accountinfo_req_given),
661  &(local_args_info.accountinfo_req_given), optarg, 0, 0, ARG_NO,
662  check_ambiguity, override, 0, 0,
663  "accountinfo-req", 'a',
664  additional_error))
665  goto failure;
666 
667  break;
668  case 'p': /* Request to make a payment. */
669 
670  if (args_info->command_group_counter && override)
671  reset_group_command (args_info);
672  args_info->command_group_counter += 1;
673 
674  if (update_arg( 0 ,
675  0 , &(args_info->payment_req_given),
676  &(local_args_info.payment_req_given), optarg, 0, 0, ARG_NO,
677  check_ambiguity, override, 0, 0,
678  "payment-req", 'p',
679  additional_error))
680  goto failure;
681 
682  break;
683  case 'i': /* Request to inquire about the status of a payment. */
684 
685  if (args_info->command_group_counter && override)
686  reset_group_command (args_info);
687  args_info->command_group_counter += 1;
688 
689  if (update_arg( 0 ,
690  0 , &(args_info->paymentinquiry_req_given),
691  &(local_args_info.paymentinquiry_req_given), optarg, 0, 0, ARG_NO,
692  check_ambiguity, override, 0, 0,
693  "paymentinquiry-req", 'i',
694  additional_error))
695  goto failure;
696 
697  break;
698 
699  case 0: /* Long option with no short option */
700  /* FI identifier. */
701  if (strcmp (long_options[option_index].name, "fid") == 0)
702  {
703 
704 
705  if (update_arg( (void *)&(args_info->fid_arg),
706  &(args_info->fid_orig), &(args_info->fid_given),
707  &(local_args_info.fid_given), optarg, 0, 0, ARG_STRING,
708  check_ambiguity, override, 0, 0,
709  "fid", '-',
710  additional_error))
711  goto failure;
712 
713  }
714  /* FI org tag. */
715  else if (strcmp (long_options[option_index].name, "org") == 0)
716  {
717 
718 
719  if (update_arg( (void *)&(args_info->org_arg),
720  &(args_info->org_orig), &(args_info->org_given),
721  &(local_args_info.org_given), optarg, 0, 0, ARG_STRING,
722  check_ambiguity, override, 0, 0,
723  "org", '-',
724  additional_error))
725  goto failure;
726 
727  }
728  /* IBAN bank identifier. */
729  else if (strcmp (long_options[option_index].name, "bank") == 0)
730  {
731 
732 
733  if (update_arg( (void *)&(args_info->bank_arg),
734  &(args_info->bank_orig), &(args_info->bank_given),
735  &(local_args_info.bank_given), optarg, 0, 0, ARG_STRING,
736  check_ambiguity, override, 0, 0,
737  "bank", '-',
738  additional_error))
739  goto failure;
740 
741  }
742  /* Broker identifier. */
743  else if (strcmp (long_options[option_index].name, "broker") == 0)
744  {
745 
746 
747  if (update_arg( (void *)&(args_info->broker_arg),
748  &(args_info->broker_orig), &(args_info->broker_given),
749  &(local_args_info.broker_given), optarg, 0, 0, ARG_STRING,
750  check_ambiguity, override, 0, 0,
751  "broker", '-',
752  additional_error))
753  goto failure;
754 
755  }
756  /* User name. */
757  else if (strcmp (long_options[option_index].name, "user") == 0)
758  {
759 
760 
761  if (update_arg( (void *)&(args_info->user_arg),
762  &(args_info->user_orig), &(args_info->user_given),
763  &(local_args_info.user_given), optarg, 0, 0, ARG_STRING,
764  check_ambiguity, override, 0, 0,
765  "user", '-',
766  additional_error))
767  goto failure;
768 
769  }
770  /* Password. */
771  else if (strcmp (long_options[option_index].name, "pass") == 0)
772  {
773 
774 
775  if (update_arg( (void *)&(args_info->pass_arg),
776  &(args_info->pass_orig), &(args_info->pass_given),
777  &(local_args_info.pass_given), optarg, 0, 0, ARG_STRING,
778  check_ambiguity, override, 0, 0,
779  "pass", '-',
780  additional_error))
781  goto failure;
782 
783  }
784  /* Account ID. */
785  else if (strcmp (long_options[option_index].name, "acct") == 0)
786  {
787 
788 
789  if (update_arg( (void *)&(args_info->acct_arg),
790  &(args_info->acct_orig), &(args_info->acct_given),
791  &(local_args_info.acct_given), optarg, 0, 0, ARG_STRING,
792  check_ambiguity, override, 0, 0,
793  "acct", '-',
794  additional_error))
795  goto failure;
796 
797  }
798  /* Account Type 1=checking 2=invest 3=ccard. */
799  else if (strcmp (long_options[option_index].name, "type") == 0)
800  {
801 
802 
803  if (update_arg( (void *)&(args_info->type_arg),
804  &(args_info->type_orig), &(args_info->type_given),
805  &(local_args_info.type_given), optarg, 0, 0, ARG_INT,
806  check_ambiguity, override, 0, 0,
807  "type", '-',
808  additional_error))
809  goto failure;
810 
811  }
812  /* How far back to look from today (in days). */
813  else if (strcmp (long_options[option_index].name, "past") == 0)
814  {
815 
816 
817  if (update_arg( (void *)&(args_info->past_arg),
818  &(args_info->past_orig), &(args_info->past_given),
819  &(local_args_info.past_given), optarg, 0, 0, ARG_LONG,
820  check_ambiguity, override, 0, 0,
821  "past", '-',
822  additional_error))
823  goto failure;
824 
825  }
826  /* Url to POST the data to (otherwise goes to stdout). */
827  else if (strcmp (long_options[option_index].name, "url") == 0)
828  {
829 
830 
831  if (update_arg( (void *)&(args_info->url_arg),
832  &(args_info->url_orig), &(args_info->url_given),
833  &(local_args_info.url_given), optarg, 0, 0, ARG_STRING,
834  check_ambiguity, override, 0, 0,
835  "url", '-',
836  additional_error))
837  goto failure;
838 
839  }
840  /* Transaction id. */
841  else if (strcmp (long_options[option_index].name, "trid") == 0)
842  {
843 
844 
845  if (update_arg( (void *)&(args_info->trid_arg),
846  &(args_info->trid_orig), &(args_info->trid_given),
847  &(local_args_info.trid_given), optarg, 0, 0, ARG_INT,
848  check_ambiguity, override, 0, 0,
849  "trid", '-',
850  additional_error))
851  goto failure;
852 
853  }
854 
855  break;
856  case '?': /* Invalid option. */
857  /* `getopt_long' already printed an error message. */
858  goto failure;
859 
860  default: /* bug: option not considered. */
861  fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
862  abort ();
863  } /* switch */
864  } /* while */
865 
866  if (args_info->command_group_counter > 1)
867  {
868  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 : ""));
869  error_occurred = 1;
870  }
871 
872 
873 
874  FIX_UNUSED(check_required);
875 
876  cmdline_parser_release (&local_args_info);
877 
878  if ( error_occurred )
879  return (EXIT_FAILURE);
880 
881  if (optind < argc)
882  {
883  int i = 0 ;
884  int found_prog_name = 0;
885  /* whether program name, i.e., argv[0], is in the remaining args
886  (this may happen with some implementations of getopt,
887  but surely not with the one included by gengetopt) */
888 
889  i = optind;
890  while (i < argc)
891  if (argv[i++] == argv[0]) {
892  found_prog_name = 1;
893  break;
894  }
895  i = 0;
896 
897  args_info->inputs_num = argc - optind - found_prog_name;
898  args_info->inputs =
899  (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
900  while (optind < argc)
901  if (argv[optind++] != argv[0])
902  args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
903  }
904 
905  return 0;
906 
907 failure:
908 
909  cmdline_parser_release (&local_args_info);
910  return (EXIT_FAILURE);
911 }
912 /* vim: set ft=c noet ts=8 sts=8 sw=8 tw=80 nojs spell : */
int override
whether to override possibly already present options (default 0)
char * past_orig
How far back to look from today (in days) original value given at command line.
unsigned int org_given
Whether org was given.
const char * accountinfo_req_help
Request for a list of accounts help description.
int initialize
whether to initialize the option structure gengetopt_args_info (default 1)
char * type_orig
Account Type 1=checking 2=invest 3=ccard original value given at command line.
char * url_orig
Url to POST the data to (otherwise goes to stdout) original value given at command line...
long past_arg
How far back to look from today (in days).
unsigned int payment_req_given
Whether payment-req was given.
unsigned int fid_given
Whether fid was given.
Where the command line options are stored.
unsigned int help_given
Whether help was given.
unsigned int type_given
Whether type was given.
char * fid_arg
FI identifier.
unsigned int bank_given
Whether bank was given.
const char * type_help
Account Type 1=checking 2=invest 3=ccard help description.
const char * pass_help
Password help description.
const char * user_help
User name help description.
The additional parameters to pass to parser functions.
char * url_arg
Url to POST the data to (otherwise goes to stdout).
const char * version_help
Print version and exit help description.
const char * acct_help
Account ID help description.
Definition: getopt.h:94
char * bank_orig
IBAN bank identifier original value given at command line.
unsigned int url_given
Whether url was given.
const char * fid_help
FI identifier help description.
const char * url_help
Url to POST the data to (otherwise goes to stdout) help description.
char * acct_orig
Account ID original value given at command line.
const char * bank_help
IBAN bank identifier help description.
const char * help_help
Print help and exit help description.
char * user_orig
User name original value given at command line.
char * acct_arg
Account ID.
const char * statement_req_help
Request for a statement help description.
char * user_arg
User name.
const char * payment_req_help
Request to make a payment help description.
unsigned int pass_given
Whether pass was given.
unsigned inputs_num
unnamed options number
int trid_arg
Transaction id.
const char * past_help
How far back to look from today (in days) help description.
unsigned int statement_req_given
Whether statement-req was given.
const char * paymentinquiry_req_help
Request to inquire about the status of a payment help description.
int print_errors
whether getopt_long should print an error message for a bad option (default 1)
unsigned int trid_given
Whether trid was given.
int check_ambiguity
whether to check for options already specified in the option structure gengetopt_args_info (default 0...
int check_required
whether to check that all required options were provided (default 1)
int command_group_counter
Counter for group command.
unsigned int past_given
Whether past was given.
unsigned int acct_given
Whether acct was given.
const char * trid_help
Transaction id help description.
char ** inputs
unnamed options (options without names)
const char * org_help
FI org tag help description.
char * org_orig
FI org tag original value given at command line.
char * fid_orig
FI identifier original value given at command line.
unsigned int user_given
Whether user was given.
unsigned int paymentinquiry_req_given
Whether paymentinquiry-req was given.
const char * broker_help
Broker identifier help description.
unsigned int accountinfo_req_given
Whether accountinfo-req was given.
char * pass_orig
Password original value given at command line.
char * trid_orig
Transaction id original value given at command line.
char * broker_orig
Broker identifier original value given at command line.
char * bank_arg
IBAN bank identifier.
unsigned int broker_given
Whether broker was given.
char * org_arg
FI org tag.
char * broker_arg
Broker identifier.
int type_arg
Account Type 1=checking 2=invest 3=ccard.
char * pass_arg
Password.
unsigned int version_given
Whether version was given.