aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-search.c')
-rw-r--r--src/fs/gnunet-search.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 60620a4..e90b761 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -42,11 +42,14 @@ static struct GNUNET_FS_DirectoryBuilder *db;
static unsigned int anonymity = 1;
-static unsigned long long timeout;
+/**
+ * Timeout for the search, 0 means to wait for CTRL-C.
+ */
+static struct GNUNET_TIME_Relative timeout;
static unsigned int results_limit;
-static unsigned int results = 0;
+static unsigned int results;
static int verbose;
@@ -220,7 +223,6 @@ run (void *cls, char *const *args, const char *cfgfile,
struct GNUNET_FS_Uri *uri;
unsigned int argc;
enum GNUNET_FS_SearchOptions options;
- struct GNUNET_TIME_Relative delay;
argc = 0;
while (NULL != args[argc])
@@ -257,16 +259,11 @@ run (void *cls, char *const *args, const char *cfgfile,
ret = 1;
return;
}
- if (timeout != 0)
- {
- delay.rel_value = timeout;
- GNUNET_SCHEDULER_add_delayed (delay, &shutdown_task, NULL);
- }
+ if (0 != timeout.rel_value)
+ GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
else
- {
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);
- }
}
@@ -290,9 +287,9 @@ main (int argc, char *const *argv)
{'o', "output", "PREFIX",
gettext_noop ("write search results to file starting with PREFIX"),
1, &GNUNET_GETOPT_set_string, &output_filename},
- {'t', "timeout", "VALUE",
- gettext_noop ("automatically terminate search after VALUE ms"),
- 1, &GNUNET_GETOPT_set_ulong, &timeout},
+ {'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},
@@ -302,11 +299,17 @@ main (int argc, char *const *argv)
1, &GNUNET_GETOPT_set_uint, &results_limit},
GNUNET_GETOPT_OPTION_END
};
- return (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD",
- gettext_noop
- ("Search GNUnet for files that were published on GNUnet"),
- options, &run, NULL)) ? ret : 1;
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD",
+ gettext_noop
+ ("Search GNUnet for files that were published on GNUnet"),
+ options, &run, NULL)) ? ret : 1;
+ GNUNET_free ((void*) argv);
+ return ret;
}
/* end of gnunet-search.c */