From 421ad27103356b4a21636c76618bf374b2e10bc9 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Fri, 17 Mar 2017 14:24:13 +0100 Subject: Porting leftovers to new getopt API. --- src/ats/gnunet-ats-solver-eval.c | 45 +++++++++++++--------- src/ats/perf_ats_solver.c | 57 ++++++++++++++++++---------- src/cadet/test_cadet.c | 17 ++++++--- src/conversation/gnunet-conversation.c | 21 ++++++---- src/dv/gnunet-dv.c | 10 ++--- src/regex/gnunet-regex-simulation-profiler.c | 21 ++++++---- 6 files changed, 107 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index e2e68562c..597285f5e 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c @@ -3289,24 +3289,33 @@ main (int argc, char *argv[]) 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}, - { 'V', "verbose", NULL, - gettext_noop ("be verbose"), - 0, &GNUNET_GETOPT_set_one, &opt_verbose}, - { 'p', "print", NULL, - gettext_noop ("print logging"), - 0, &GNUNET_GETOPT_set_one, &opt_print}, - { 'f', "file", NULL, - gettext_noop ("save logging to disk"), - 0, &GNUNET_GETOPT_set_one, &opt_save}, - { 'd', "dn", NULL, - gettext_noop ("disable normalization"), - 0, &GNUNET_GETOPT_set_one, &opt_disable_normalization}, + GNUNET_GETOPT_OPTION_STRING ('s', + "solver", + gettext_noop ("solver to use"), + &opt_solver), + + GNUNET_GETOPT_OPTION_STRING ('e', + "experiment" + gettext_noop ("experiment to use"), + &opt_exp_file), + + GNUNET_GETOPT_OPTION_VERBOSE (&opt_verbose), + + GNUNET_GETOPT_OPTION_SET_ONE ('p', + "print", + gettext_noop ("print logging"), + &opt_print), + + GNUNET_GETOPT_OPTION_SET_ONE ('f', + "file", + gettext_noop ("save logging to disk"), + &opt_save), + + GNUNET_GETOPT_OPTION_SET_ONE ('d', + "dn", + gettext_noop ("disable normalization"), + &opt_disable_normalization), + GNUNET_GETOPT_OPTION_END }; diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index f05668e9b..855899b36 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c @@ -1404,27 +1404,42 @@ main (int argc, char *argv[]) ph.total_iterations = 1; static struct GNUNET_GETOPT_CommandLineOption options[] = { - { 'a', "addresses", NULL, - gettext_noop ("addresses to use"), - 1, &GNUNET_GETOPT_set_uint, &ph.N_address }, - { 's', "start", NULL, - gettext_noop ("start with peer"), - 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_start }, - { 'e', "end", NULL, - gettext_noop ("end with peer"), - 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end }, - { 'i', "iterations", NULL, - gettext_noop ("number of iterations used for averaging (default: 1)"), - 1, &GNUNET_GETOPT_set_uint, &ph.total_iterations }, - { 'p', "percentage", NULL, - gettext_noop ("update a fix percentage of addresses"), - 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, - { 'd', "data", NULL, - gettext_noop ("create data file"), - 0, &GNUNET_GETOPT_set_one, &ph.create_datafile}, - { 'u', "update", NULL, - gettext_noop ("measure updates"), - 0, &GNUNET_GETOPT_set_one, &ph.measure_updates}, + + GNUNET_GETOPT_OPTION_SET_UINT ('a', + "addresses", + gettext_noop ("addresses to use"), + &ph.N_address), + + GNUNET_GETOPT_OPTION_SET_UINT ('s', + "start", + gettext_noop ("start with peer"), + &ph.N_peers_start), + + GNUNET_GETOPT_OPTION_SET_UINT ('e', + "end", + gettext_noop ("end with peer"), + &ph.N_peers_end), + + GNUNET_GETOPT_OPTION_SET_UINT ('i', + "iterations", + gettext_noop ("number of iterations used for averaging (default: 1)"), + &ph.total_iterations), + + GNUNET_GETOPT_OPTION_SET_UINT ('p', + "percentage", + gettext_noop ("update a fix percentage of addresses"), + &ph.opt_update_percent), + + GNUNET_GETOPT_OPTION_SET_ONE ('d', + "data", + gettext_noop ("create data file"), + &ph.create_datafile), + + GNUNET_GETOPT_OPTION_SET_ONE ('u', + "update", + gettext_noop ("measure updates"), + &ph.measure_updates), + GNUNET_GETOPT_OPTION_END }; diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 3586b26ac..a7304c3ee 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c @@ -962,12 +962,17 @@ main (int argc, char *argv[]) char port_id[] = "test port"; static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'t', "time", "short_time", - gettext_noop ("set short timeout"), - GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &short_time}, - {'m', "messages", "NUM_MESSAGES", - gettext_noop ("set number of messages to send"), - GNUNET_YES, &GNUNET_GETOPT_set_uint, &total_packets}, + GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', + "time", + "short_time", + gettext_noop ("set short timeout"), + &short_time), + + GNUNET_GETOPT_OPTION_SET_UINT ('m', + "messages", + "NUM_MESSAGES", + gettext_noop ("set number of messages to send"), + &total_packets), GNUNET_GETOPT_OPTION_END }; diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 925db4665..c5275c0de 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c @@ -1265,13 +1265,20 @@ run (void *cls, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'e', "ego", "NAME", - gettext_noop ("sets the NAME of the ego to use for the phone (and name resolution)"), - 1, &GNUNET_GETOPT_set_string, &ego_name}, - {'p', "phone", "LINE", - gettext_noop ("sets the LINE to use for the phone"), - 1, &GNUNET_GETOPT_set_string, &line}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_STRING ('e', + "ego", + "NAME", + gettext_noop ("sets the NAME of the ego to use for the phone (and name resolution)"), + &ego_name), + + GNUNET_GETOPT_OPTION_STRING ('p', + "phone", + "LINE", + gettext_noop ("sets the LINE to use for the phone"), + &line), + GNUNET_GETOPT_OPTION_END }; int ret; diff --git a/src/dv/gnunet-dv.c b/src/dv/gnunet-dv.c index d0917d363..cb40bb6d2 100644 --- a/src/dv/gnunet-dv.c +++ b/src/dv/gnunet-dv.c @@ -34,7 +34,7 @@ static struct GNUNET_DV_ServiceHandle *sh; /** * Was verbose specified? */ -static int verbose; +static unsigned int verbose; /** @@ -161,10 +161,10 @@ main (int argc, char *const *argv) { int res; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'V', "verbose", NULL, - gettext_noop ("verbose output"), - 0, &GNUNET_GETOPT_set_one, &verbose}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_VERBOSE (&verbose), + GNUNET_GETOPT_OPTION_END }; diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index 025a70316..422e45565 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c @@ -691,13 +691,20 @@ run (void *cls, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'t', "table", "TABLENAME", - gettext_noop ("name of the table to write DFAs"), - 1, &GNUNET_GETOPT_set_string, &table_name}, - {'p', "max-path-compression", "MAX_PATH_COMPRESSION", - gettext_noop ("maximum path compression length"), - 1, &GNUNET_GETOPT_set_uint, &max_path_compression}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_STRING ('t', + "table", + "TABLENAME", + gettext_noop ("name of the table to write DFAs"), + &table_name), + + GNUNET_GETOPT_OPTION_SET_UINT ('p', + "max-path-compression", + "MAX_PATH_COMPRESSION", + gettext_noop ("maximum path compression length"), + &max_path_compression), + GNUNET_GETOPT_OPTION_END }; int ret; -- cgit v1.2.3