From e724ea478e4efe6e2531f81908ce0f9334357d81 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Thu, 16 Mar 2017 15:41:10 +0100 Subject: [PATCH] porting fs finished. --- src/fs/gnunet-fs-profiler.c | 30 ++++++++++++------- src/fs/gnunet-fs.c | 13 +++++---- src/fs/gnunet-search.c | 58 +++++++++++++++++++++++-------------- src/fs/gnunet-unindex.c | 10 +++---- 4 files changed, 70 insertions(+), 41 deletions(-) diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c index cfbe57bbd..fb99d8f90 100644 --- a/src/fs/gnunet-fs-profiler.c +++ b/src/fs/gnunet-fs-profiler.c @@ -203,16 +203,26 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'n', "num-peers", "COUNT", - gettext_noop ("run the experiment with COUNT peers"), - 1, &GNUNET_GETOPT_set_uint, &num_peers}, - {'H', "hosts", "HOSTFILE", - gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), - 1, &GNUNET_GETOPT_set_string, &host_filename}, - {'t', "timeout", "DELAY", - gettext_noop ("automatically terminate experiment after DELAY"), - 1, &GNUNET_GETOPT_set_relative_time, &timeout}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_SET_UINT ('n', + "num-peers", + "COUNT", + gettext_noop ("run the experiment with COUNT peers"), + &num_peers), + + GNUNET_GETOPT_OPTION_STRING ('H', + "hosts", + "HOSTFILE", + gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), + &host_filename), + + GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', + "timeout", + "DELAY", + gettext_noop ("automatically terminate experiment after DELAY"), + &timeout), + GNUNET_GETOPT_OPTION_END }; if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index 7c20e025f..2b24b7124 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c @@ -43,7 +43,7 @@ static int list_indexed_files; /** * Option -v given? */ -static int verbose; +static unsigned int verbose; /** @@ -112,10 +112,13 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { - static struct GNUNET_GETOPT_CommandLineOption options[] = { - {'i', "list-indexed", NULL, - gettext_noop ("print a list of all indexed files"), 0, - &GNUNET_GETOPT_set_one, &list_indexed_files}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_SET_ONE ('i', + "list-indexed", + gettext_noop ("print a list of all indexed files"), + &list_indexed_files), + GNUNET_GETOPT_OPTION_VERBOSE (&verbose), GNUNET_GETOPT_OPTION_END }; diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index dfe6d0e75..22e790cf3 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c @@ -51,7 +51,7 @@ static unsigned int results_limit; static unsigned int results; -static int verbose; +static unsigned int verbose; static int local_only; @@ -305,26 +305,42 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'a', "anonymity", "LEVEL", - gettext_noop ("set the desired LEVEL of receiver-anonymity"), - 1, &GNUNET_GETOPT_set_uint, &anonymity}, - {'n', "no-network", NULL, - gettext_noop ("only search the local peer (no P2P network search)"), - 0, &GNUNET_GETOPT_set_one, &local_only}, - {'o', "output", "PREFIX", - gettext_noop ("write search results to file starting with PREFIX"), - 1, &GNUNET_GETOPT_set_string, &output_filename}, - {'t', "timeout", "DELAY", - gettext_noop ("automatically terminate search after DELAY"), - 1, &GNUNET_GETOPT_set_relative_time, &timeout}, - {'V', "verbose", NULL, - gettext_noop ("be verbose (print progress information)"), - 0, &GNUNET_GETOPT_set_one, &verbose}, - {'N', "results", "VALUE", - gettext_noop - ("automatically terminate search after VALUE results are found"), - 1, &GNUNET_GETOPT_set_uint, &results_limit}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_SET_UINT ('a', + "anonymity", + "LEVEL", + gettext_noop ("set the desired LEVEL of receiver-anonymity"), + &anonymity), + + + GNUNET_GETOPT_OPTION_SET_ONE ('n', + "no-network", + gettext_noop ("only search the local peer (no P2P network search)"), + &local_only), + + GNUNET_GETOPT_OPTION_STRING ('o', + "output", + "PREFIX", + gettext_noop ("write search results to file starting with PREFIX"), + &output_filename), + + GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', + "timeout", + "DELAY", + gettext_noop ("automatically terminate search after DELAY"), + &timeout), + + + GNUNET_GETOPT_OPTION_VERBOSE (&verbose), + + GNUNET_GETOPT_OPTION_SET_UINT ('N', + "results", + "VALUE", + gettext_noop ("automatically terminate search " + "after VALUE results are found"), + &results_limit), + GNUNET_GETOPT_OPTION_END }; diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 40fa13b62..c53a85fb4 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c @@ -30,7 +30,7 @@ static int ret; -static int verbose; +static unsigned int verbose; static const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -162,10 +162,10 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'V', "verbose", NULL, - gettext_noop ("be verbose (print progress information)"), - 0, &GNUNET_GETOPT_set_one, &verbose}, + struct GNUNET_GETOPT_CommandLineOption options[] = { + + GNUNET_GETOPT_OPTION_VERBOSE (&verbose), + GNUNET_GETOPT_OPTION_END }; -- 2.25.1