aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-09 18:36:01 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-09 18:36:01 +0000
commit15af56ceb3ae31463a79c95b34841fbdec920ba5 (patch)
tree1e1de33b94a3cd493179a80bcfeaa332b7e3fc10 /src/fs
parent85869129442a971414710ebd8bef97433570083b (diff)
downloadgnunet-15af56ceb3ae31463a79c95b34841fbdec920ba5.tar.gz
gnunet-15af56ceb3ae31463a79c95b34841fbdec920ba5.zip
new getopt helper function to parse relative time command line argument
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-search.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 88507f608..200dc77ab 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -42,11 +42,14 @@ static struct GNUNET_FS_DirectoryBuilder *db;
42 42
43static unsigned int anonymity = 1; 43static unsigned int anonymity = 1;
44 44
45static unsigned long long timeout; 45/**
46 * Timeout for the search, 0 means to wait for CTRL-C.
47 */
48static struct GNUNET_TIME_Relative timeout;
46 49
47static unsigned int results_limit; 50static unsigned int results_limit;
48 51
49static unsigned int results = 0; 52static unsigned int results;
50 53
51static int verbose; 54static int verbose;
52 55
@@ -220,7 +223,6 @@ run (void *cls, char *const *args, const char *cfgfile,
220 struct GNUNET_FS_Uri *uri; 223 struct GNUNET_FS_Uri *uri;
221 unsigned int argc; 224 unsigned int argc;
222 enum GNUNET_FS_SearchOptions options; 225 enum GNUNET_FS_SearchOptions options;
223 struct GNUNET_TIME_Relative delay;
224 226
225 argc = 0; 227 argc = 0;
226 while (NULL != args[argc]) 228 while (NULL != args[argc])
@@ -257,16 +259,11 @@ run (void *cls, char *const *args, const char *cfgfile,
257 ret = 1; 259 ret = 1;
258 return; 260 return;
259 } 261 }
260 if (timeout != 0) 262 if (0 != timeout.rel_value)
261 { 263 GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
262 delay.rel_value = timeout;
263 GNUNET_SCHEDULER_add_delayed (delay, &shutdown_task, NULL);
264 }
265 else 264 else
266 {
267 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 265 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
268 NULL); 266 NULL);
269 }
270} 267}
271 268
272 269
@@ -290,9 +287,9 @@ main (int argc, char *const *argv)
290 {'o', "output", "PREFIX", 287 {'o', "output", "PREFIX",
291 gettext_noop ("write search results to file starting with PREFIX"), 288 gettext_noop ("write search results to file starting with PREFIX"),
292 1, &GNUNET_GETOPT_set_string, &output_filename}, 289 1, &GNUNET_GETOPT_set_string, &output_filename},
293 {'t', "timeout", "VALUE", 290 {'t', "timeout", "DELAY",
294 gettext_noop ("automatically terminate search after VALUE ms"), 291 gettext_noop ("automatically terminate search after DELAY"),
295 1, &GNUNET_GETOPT_set_ulong, &timeout}, 292 1, &GNUNET_GETOPT_set_relative_time, &timeout},
296 {'V', "verbose", NULL, 293 {'V', "verbose", NULL,
297 gettext_noop ("be verbose (print progress information)"), 294 gettext_noop ("be verbose (print progress information)"),
298 0, &GNUNET_GETOPT_set_one, &verbose}, 295 0, &GNUNET_GETOPT_set_one, &verbose},