diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-04 16:36:51 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-07-04 16:36:51 +0200 |
commit | dc921dbc58d129db304ebd3e7c877cbe8e61c7f0 (patch) | |
tree | ec6ce0702825ceeef95f1392baa9fd7a98ec752a /src/merchant-tools/taler-merchant-benchmark.c | |
parent | 664266b2fb8bd160a974da13d119828dc0a8a38d (diff) |
Args parsing.
Fix problem reported here:
https://gnunet.org/bugs/view.php?id=5378#c13134,
and closing #5378.
Diffstat (limited to 'src/merchant-tools/taler-merchant-benchmark.c')
-rw-r--r-- | src/merchant-tools/taler-merchant-benchmark.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index 6f58e95f..6f4daba6 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -564,6 +564,8 @@ main (int argc, loglev, logfile); + struct GNUNET_GETOPT_CommandLineOption *options; + struct GNUNET_GETOPT_CommandLineOption root_options[] = { GNUNET_GETOPT_option_cfgfile @@ -707,42 +709,46 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; - - if (GNUNET_SYSERR != (result = GNUNET_GETOPT_run - ("taler-merchant-benchmark", - root_options, - argc, - argv)) && (NULL == argv[result])) + + options = root_options; + if (0 == strcmp ("ordinary", argv[1])) { - if (GNUNET_YES == root_help) - fprintf (stderr, root_help_str); - - /* either --version or "root" --help at this point. */ - return 0; + ordinary = GNUNET_YES; + options = ordinary_options; + } + if (0 == strcmp ("corner", argv[1])) + { + corner = GNUNET_YES; + options = corner_options; } - if ((GNUNET_SYSERR != (result = GNUNET_GETOPT_run + if (GNUNET_SYSERR != (result = GNUNET_GETOPT_run ("taler-merchant-benchmark", - ordinary_options, + options, argc, - argv))) && (0 == strcmp ("ordinary", argv[result]))) + argv))) { - ordinary = 1; + + if (GNUNET_YES == root_help) + { + fprintf (stdout, root_help_str); + return 0; + } + + /* --help was given. */ + if (0 == result) + return 0; } - if ((GNUNET_SYSERR != (result = GNUNET_GETOPT_run - ("taler-merchant-benchmark", - corner_options, - argc, - argv))) && (0 == strcmp ("corner", argv[result]))) + if (-1 == result) { - corner = 1; + return 1; } - if ((GNUNET_YES != ordinary) && (GNUNET_YES != corner)) + if ((GNUNET_YES == corner) && (NULL == alt_instance)) { - TALER_LOG_ERROR - ("Neither 'ordinary' or 'corner' were given\n"); + fprintf (stderr, "option '-i' is mandatory" + " with sub-command 'corner'!\n"); return 1; } |