From 5d6ed5fbda01a324d8d9b800928339d4a90343c3 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 15 Mar 2017 15:28:41 +0100 Subject: [PATCH] Still porting to new getopt API. --- src/ats-tests/gnunet-solver-eval.c | 29 +++++--- src/ats-tool/gnunet-ats.c | 84 +++++++++++++++-------- src/core/gnunet-core.c | 9 +-- src/peerinfo-tool/gnunet-peerinfo.c | 67 +++++++++++------- src/rest/gnunet-rest-server.c | 14 ++-- src/testbed/generate-underlay-topology.c | 12 ++-- src/testbed/gnunet-testbed-profiler.c | 43 +++++++----- src/transport/gnunet-transport-profiler.c | 52 ++++++++------ src/transport/gnunet-transport.c | 76 +++++++++++--------- 9 files changed, 239 insertions(+), 147 deletions(-) diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c index c19afe895..1bb7fdee7 100644 --- a/src/ats-tests/gnunet-solver-eval.c +++ b/src/ats-tests/gnunet-solver-eval.c @@ -931,17 +931,24 @@ main (int argc, char *argv[]) opt_log = GNUNET_NO; opt_plot = GNUNET_NO; - static struct GNUNET_GETOPT_CommandLineOption options[] = - { - { 's', "solver", NULL, - gettext_noop ("solver to use"), - 1, &GNUNET_GETOPT_set_string, &opt_solver}, - { 'e', "experiment", NULL, - gettext_noop ("experiment to use"), - 1, &GNUNET_GETOPT_set_string, &opt_exp_file}, - { 'e', "experiment", NULL, - gettext_noop ("experiment to use"), - 1, &GNUNET_GETOPT_set_one, &opt_verbose}, + struct GNUNET_GETOPT_CommandLineOption options[] = + { + GNUNET_GETOPT_OPTION_STRING ('s', + "solver", + NULL, + gettext_noop ("solver to use"), + &opt_solver), + + GNUNET_GETOPT_OPTION_STRING ('e', + "experiment", + NULL, + gettext_noop ("experiment to use"), + &opt_exp_file), + + GNUNET_GETOPT_OPTION_SET_ONE ('e', + "experiment", + gettext_noop ("experiment to use"), + &opt_verbose), GNUNET_GETOPT_OPTION_END }; diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 5fc1d6e92..f645ba56d 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c @@ -944,34 +944,62 @@ main (int argc, stat_receive_done = GNUNET_NO; opt_type_str = NULL; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - { 'u', "used", NULL, - gettext_noop ("get list of active addresses currently used"), 0, - &GNUNET_GETOPT_set_one, &opt_list_used }, - { 'a', "all", NULL, gettext_noop ("get list of all active addresses"), 0, - &GNUNET_GETOPT_set_one, &opt_list_all }, - { 'C', "connect", "PEER", - gettext_noop ("connect to PEER"), 1, - &GNUNET_GETOPT_set_string, &cpid_str }, - { 'n', "numeric", NULL, - gettext_noop ("do not resolve IP addresses to hostnames"), 0, - &GNUNET_GETOPT_set_one, &opt_resolve_addresses_numeric }, - { 'm', "monitor", NULL, gettext_noop ("monitor mode"), 0, - &GNUNET_GETOPT_set_one, &opt_monitor }, - { 'p', "preference", NULL, gettext_noop ("set preference for the given peer"), - 0, &GNUNET_GETOPT_set_one, &opt_set_pref }, - { 'q', "quotas", NULL, gettext_noop ("print all configured quotas"), 0, - &GNUNET_GETOPT_set_one, &opt_print_quotas }, - { 'i', "id", "TYPE", gettext_noop ("peer id"), 1, &GNUNET_GETOPT_set_string, - &opt_pid_str }, - { 't', "type", "TYPE", - gettext_noop ("preference type to set: latency | bandwidth"), 1, - &GNUNET_GETOPT_set_string, &opt_type_str }, - { 'k', "value", "VALUE", gettext_noop ("preference value"), 1, - &GNUNET_GETOPT_set_uint, &opt_pref_value }, - { 'V', "verbose", NULL, - gettext_noop ("verbose output (include ATS address properties)"), 0, - &GNUNET_GETOPT_set_one, &opt_verbose }, + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_SET_ONE ('u', + "used", + gettext_noop ("get list of active addresses currently used"), + &opt_list_used), + GNUNET_GETOPT_OPTION_SET_ONE ('a', + "all", + gettext_noop ("get list of all active addresses"), + &opt_list_all), + + GNUNET_GETOPT_OPTION_STRING ('C', + "connect", + NULL, + gettext_noop ("connect to PEER"), + &cpid_str), + GNUNET_GETOPT_OPTION_SET_ONE ('n', + "numeric", + gettext_noop ("do not resolve IP addresses to hostnames"), + &opt_resolve_addresses_numeric), + + GNUNET_GETOPT_OPTION_SET_ONE ('m', + "monitor", + gettext_noop ("monitor mode"), + &opt_monitor), + + GNUNET_GETOPT_OPTION_SET_ONE ('p', + "preference", + gettext_noop ("set preference for the given peer"), + &opt_set_pref), + + GNUNET_GETOPT_OPTION_SET_ONE ('q', + "quotas", + gettext_noop ("print all configured quotas"), + &opt_print_quotas), + GNUNET_GETOPT_OPTION_STRING ('i', + "id", + "TYPE", + gettext_noop ("peer id"), + &opt_pid_str), + + GNUNET_GETOPT_OPTION_STRING ('t', + "type", + "TYPE", + gettext_noop ("preference type to set: latency | bandwidth"), + &opt_type_str), + + GNUNET_GETOPT_OPTION_SET_UINT ('k', + "value", + "VALUE", + gettext_noop ("preference value"), + &opt_pref_value), + + GNUNET_GETOPT_OPTION_SET_ONE ('V', + "verbose", + gettext_noop ("verbose output (include ATS address properties)"), + &opt_verbose), GNUNET_GETOPT_OPTION_END }; diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c index d91dc304d..ed89b1946 100644 --- a/src/core/gnunet-core.c +++ b/src/core/gnunet-core.c @@ -171,10 +171,11 @@ main (int argc, char *const *argv) { int res; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'m', "monitor", NULL, - gettext_noop ("provide information about all current connections (continuously)"), - 0, &GNUNET_GETOPT_set_one, &monitor_connections}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_SET_ONE ('m', + "monitor", + gettext_noop ("provide information about all current connections (continuously)"), + &monitor_connections), GNUNET_GETOPT_OPTION_END }; diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index a5907c63f..59ffe2efd 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -837,31 +837,48 @@ state_machine (void *cls) int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'n', "numeric", NULL, - gettext_noop ("don't resolve host names"), - 0, &GNUNET_GETOPT_set_one, &no_resolve}, - {'q', "quiet", NULL, - gettext_noop ("output only the identity strings"), - 0, &GNUNET_GETOPT_set_one, &be_quiet}, - {'f', "friends", NULL, - gettext_noop ("include friend-only information"), - 0, &GNUNET_GETOPT_set_one, &include_friend_only}, - {'s', "self", NULL, - gettext_noop ("output our own identity only"), - 0, &GNUNET_GETOPT_set_one, &get_self}, - {'i', "info", NULL, - gettext_noop ("list all known peers"), - 0, &GNUNET_GETOPT_set_one, &get_info}, - {'d', "dump-hello", NULL, - gettext_noop ("dump hello to file"), - 1, &GNUNET_GETOPT_set_string, &dump_hello}, - {'g', "get-hello", NULL, - gettext_noop ("also output HELLO uri(s)"), - 0, &GNUNET_GETOPT_set_one, &get_uri}, - {'p', "put-hello", "HELLO", - gettext_noop ("add given HELLO uri to the database"), - 1, &GNUNET_GETOPT_set_string, &put_uri}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_SET_ONE ('n', + "numeric", + gettext_noop ("don't resolve host names"), + &no_resolve), + + GNUNET_GETOPT_OPTION_SET_ONE ('q', + "quiet", + gettext_noop ("output only the identity strings"), + &be_quiet), + GNUNET_GETOPT_OPTION_SET_ONE ('f', + "friends", + gettext_noop ("include friend-only information"), + &include_friend_only), + + GNUNET_GETOPT_OPTION_SET_ONE ('s', + "self", + gettext_noop ("output our own identity only"), + &get_self), + + GNUNET_GETOPT_OPTION_SET_ONE ('i', + "info", + gettext_noop ("list all known peers"), + &get_info), + + GNUNET_GETOPT_OPTION_STRING ('d', + "dump-hello", + NULL, + gettext_noop ("dump hello to file"), + &dump_hello), + + GNUNET_GETOPT_OPTION_SET_ONE ('g', + "get-hello", + gettext_noop ("also output HELLO uri(s)"), + &get_uri), + + GNUNET_GETOPT_OPTION_STRING ('p', + "put-hello", + "HELLO", + gettext_noop ("add given HELLO uri to the database"), + &put_uri), + GNUNET_GETOPT_OPTION_END }; int ret; diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index b115deb20..0b6c18267 100644 --- a/src/rest/gnunet-rest-server.c +++ b/src/rest/gnunet-rest-server.c @@ -66,7 +66,7 @@ static struct GNUNET_SCHEDULER_Task *httpd_task; /** * The port the service is running on (default 7776) */ -static unsigned long port = GNUNET_REST_SERVICE_PORT; +static unsigned long long port = GNUNET_REST_SERVICE_PORT; /** * The listen socket of the service for IPv4 @@ -748,7 +748,7 @@ run (void *cls, return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Service listens on port %lu\n", + "Service listens on port %llu\n", port); httpd = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_NO_LISTEN_SOCKET, 0, @@ -783,10 +783,12 @@ run (void *cls, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'p', "port", NULL, - gettext_noop ("listen on specified port (default: 7776)"), 1, - &GNUNET_GETOPT_set_ulong, &port}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_SET_ULONG ('p', + "port", + "PORT", + gettext_noop ("listen on specified port (default: 7776)"), + &port), GNUNET_GETOPT_OPTION_END }; static const char* err_page = diff --git a/src/testbed/generate-underlay-topology.c b/src/testbed/generate-underlay-topology.c index 36580a2a3..ab7d81c8b 100644 --- a/src/testbed/generate-underlay-topology.c +++ b/src/testbed/generate-underlay-topology.c @@ -70,7 +70,7 @@ enum GNUNET_TESTBED_TopologyOption topology; /** * The number of peers to include in the topology */ -static int num_peers; +static unsigned int num_peers; /** * program result @@ -335,11 +335,15 @@ int main (int argc, char *const argv[]) { struct GNUNET_GETOPT_CommandLineOption option[] = { - {'p', "num-peers", "COUNT", - gettext_noop ("create COUNT number of peers"), - GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers}, + + GNUNET_GETOPT_OPTION_SET_UINT ('p', + "num-peers", + "COUNT", + gettext_noop ("create COUNT number of peers"), + &num_peers), GNUNET_GETOPT_OPTION_END }; + int ret; exit_result = GNUNET_SYSERR; diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index 9468b3c91..29f77193d 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c @@ -276,23 +276,34 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'p', "num-peers", "COUNT", - gettext_noop ("create COUNT number of peers"), - GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers}, - {'e', "num-errors", "COUNT", - gettext_noop ("tolerate COUNT number of continious timeout failures"), - GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails}, - {'n', "non-interactive", NULL, - gettext_noop ("run profiler in non-interactive mode where upon " - "testbed setup the profiler does not wait for a " - "keystroke but continues to run until a termination " - "signal is received"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &noninteractive}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_SET_UINT ('p', + "num-peers", + "COUNT", + gettext_noop ("create COUNT number of peers"), + &num_peers), + + GNUNET_GETOPT_OPTION_SET_UINT ('e', + "num-errors", + "COUNT", + gettext_noop ("tolerate COUNT number of continious timeout failures"), + &num_cont_fails), + + GNUNET_GETOPT_OPTION_SET_ONE ('n', + "non-interactive", + gettext_noop ("run profiler in non-interactive mode where upon " + "testbed setup the profiler does not wait for a " + "keystroke but continues to run until a termination " + "signal is received"), + &noninteractive), + #if !ENABLE_SUPERMUC - {'H', "hosts", "FILENAME", - gettext_noop ("name of the file with the login information for the testbed"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &hosts_file}, + GNUNET_GETOPT_OPTION_STRING ('H', + "hosts", + "FILENAME", + gettext_noop ("name of the file with the login information for the testbed"), + &hosts_file), #endif GNUNET_GETOPT_OPTION_END }; diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index dceff7e3b..bd4d3072b 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c @@ -151,7 +151,7 @@ static struct GNUNET_PeerIdentity pid; /** * Selected level of verbosity. */ -static int verbosity; +static unsigned int verbosity; /** @@ -610,26 +610,36 @@ main (int argc, char * const *argv) benchmark_iterations = DEFAULT_ITERATION_COUNT; benchmark_running = GNUNET_NO; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - - { 's', "send", NULL, - gettext_noop ("send data to peer"), - 0, &GNUNET_GETOPT_set_one, &benchmark_send}, - { 'r', "receive", NULL, gettext_noop - ("receive data from peer"), 0, - &GNUNET_GETOPT_set_one, &benchmark_receive}, - { 'i', "iterations", NULL, gettext_noop - ("iterations"), 1, - &GNUNET_GETOPT_set_uint, &benchmark_iterations}, - { 'n', "number", NULL, gettext_noop - ("number of messages to send"), 1, - &GNUNET_GETOPT_set_uint, &benchmark_count}, - { 'm', "messagesize", NULL, gettext_noop - ("message size to use"), 1, - &GNUNET_GETOPT_set_uint, &benchmark_size}, - { 'p', "peer", "PEER", - gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, - &cpid }, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_SET_ONE ('s', + "send", + gettext_noop ("send data to peer"), + &benchmark_send), + GNUNET_GETOPT_OPTION_SET_ONE ('r', + "receive", + gettext_noop ("receive data from peer"), + &benchmark_receive), + GNUNET_GETOPT_OPTION_SET_UINT ('i', + "iterations", + NULL, + gettext_noop ("iterations"), + &benchmark_iterations), + GNUNET_GETOPT_OPTION_SET_UINT ('n', + "number", + NULL, + gettext_noop ("number of messages to send"), + &benchmark_count), + GNUNET_GETOPT_OPTION_SET_UINT ('m', + "messagesize", + NULL, + gettext_noop ("message size to use"), + &benchmark_size), + GNUNET_GETOPT_OPTION_STRING ('p', + "peer", + "PEER", + gettext_noop ("peer identity"), + &cpid), GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), GNUNET_GETOPT_OPTION_END }; diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index fcfc94ac8..c0442950d 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c @@ -295,7 +295,7 @@ static struct GNUNET_SCHEDULER_Task *op_timeout; /** * Selected level of verbosity. */ -static int verbosity; +static unsigned int verbosity; /** * Resolver process handle. @@ -1439,37 +1439,49 @@ main (int argc, char * const *argv) { int res; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - { 'a', "all", NULL, - gettext_noop ("print information for all peers (instead of only connected peers)"), - 0, &GNUNET_GETOPT_set_one, &iterate_all }, - { 'b', "benchmark", NULL, - gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), - 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, - { 'D', "disconnect", - NULL, gettext_noop ("disconnect from a peer"), 0, - &GNUNET_GETOPT_set_one, &do_disconnect }, - { 'i', "information", NULL, - gettext_noop ("provide information about all current connections (once)"), - 0, &GNUNET_GETOPT_set_one, &iterate_connections }, - { 'm', "monitor", NULL, - gettext_noop ("provide information about all current connections (continuously)"), - 0, &GNUNET_GETOPT_set_one, &monitor_connections }, - { 'e', "events", NULL, - gettext_noop ("provide information about all connects and disconnect events (continuously)"), - 0, &GNUNET_GETOPT_set_one, &monitor_connects }, - { 'n', "numeric", - NULL, gettext_noop ("do not resolve hostnames"), 0, - &GNUNET_GETOPT_set_one, &numeric }, - { 'p', "peer", "PEER", - gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, - &cpid }, - { 'P', "plugins", NULL, - gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one, - &monitor_plugins }, - { 's', "send", NULL, gettext_noop - ("send data for benchmarking to the other peer (until CTRL-C)"), 0, - &GNUNET_GETOPT_set_one, &benchmark_send }, + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_SET_ONE ('a', + "all", + gettext_noop ("print information for all peers (instead of only connected peers)"), + &iterate_all), + GNUNET_GETOPT_OPTION_SET_ONE ('b', + "benchmark", + gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), + &benchmark_receive), + GNUNET_GETOPT_OPTION_SET_ONE ('D', + "disconnect", + gettext_noop ("disconnect from a peer"), + &do_disconnect), + GNUNET_GETOPT_OPTION_SET_ONE ('i', + "information", + gettext_noop ("provide information about all current connections (once)"), + &iterate_connections), + GNUNET_GETOPT_OPTION_SET_ONE ('m', + "monitor", + gettext_noop ("provide information about all current connections (continuously)"), + &monitor_connections), + GNUNET_GETOPT_OPTION_SET_ONE ('e', + "events", + gettext_noop ("provide information about all connects and disconnect events (continuously)"), + &monitor_connects), + GNUNET_GETOPT_OPTION_SET_ONE ('n', + "numeric", + gettext_noop ("do not resolve hostnames"), + &numeric), + GNUNET_GETOPT_OPTION_STRING ('p', + "peer", + "PEER", + gettext_noop ("peer identity"), + &cpid), + GNUNET_GETOPT_OPTION_SET_ONE ('P', + "plugins", + gettext_noop ("monitor plugin sessions"), + &monitor_plugins), + GNUNET_GETOPT_OPTION_SET_ONE ('s', + "send", + gettext_noop + ("send data for benchmarking to the other peer (until CTRL-C)"), + &benchmark_send), GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), GNUNET_GETOPT_OPTION_END }; -- 2.25.1