diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-05 21:16:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-05 21:16:40 +0000 |
commit | 0488211f40f1db8df5df25f3c2cf9c82eacdd631 (patch) | |
tree | 426e93692c36b82345631db7a52726a86a4c4126 /src/fs/gnunet-search.c | |
parent | 917aafaa99163e731d76b471e9975a8947a35a60 (diff) | |
download | gnunet-0488211f40f1db8df5df25f3c2cf9c82eacdd631.tar.gz gnunet-0488211f40f1db8df5df25f3c2cf9c82eacdd631.zip |
LRN: 0007-Add-N-NUM-argument-to-quit-the-search-after-NUM-hits.patch
Diffstat (limited to 'src/fs/gnunet-search.c')
-rw-r--r-- | src/fs/gnunet-search.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index f2414322d..cb48cda88 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -44,6 +44,10 @@ static unsigned int anonymity = 1; | |||
44 | 44 | ||
45 | static unsigned long long timeout; | 45 | static unsigned long long timeout; |
46 | 46 | ||
47 | static unsigned int results_limit; | ||
48 | |||
49 | static unsigned int results = 0; | ||
50 | |||
47 | static int verbose; | 51 | static int verbose; |
48 | 52 | ||
49 | static int local_only; | 53 | static int local_only; |
@@ -177,6 +181,9 @@ progress_cb (void *cls, | |||
177 | fflush(stdout); | 181 | fflush(stdout); |
178 | GNUNET_free_non_null (filename); | 182 | GNUNET_free_non_null (filename); |
179 | GNUNET_free (uri); | 183 | GNUNET_free (uri); |
184 | results += 1; | ||
185 | if (results_limit > 0 && results >= results_limit) | ||
186 | GNUNET_SCHEDULER_shutdown (); | ||
180 | break; | 187 | break; |
181 | case GNUNET_FS_STATUS_SEARCH_UPDATE: | 188 | case GNUNET_FS_STATUS_SEARCH_UPDATE: |
182 | break; | 189 | break; |
@@ -320,12 +327,16 @@ main (int argc, char *const *argv) | |||
320 | ("write search results to file starting with PREFIX"), | 327 | ("write search results to file starting with PREFIX"), |
321 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | 328 | 1, &GNUNET_GETOPT_set_string, &output_filename}, |
322 | {'t', "timeout", "VALUE", | 329 | {'t', "timeout", "VALUE", |
323 | gettext_noop | 330 | gettext_noop |
324 | ("automatically terminate search after VALUE ms"), | 331 | ("automatically terminate search after VALUE ms"), |
325 | 1, &GNUNET_GETOPT_set_ulong, &timeout}, | 332 | 1, &GNUNET_GETOPT_set_ulong, &timeout}, |
326 | {'V', "verbose", NULL, | 333 | {'V', "verbose", NULL, |
327 | gettext_noop ("be verbose (print progress information)"), | 334 | gettext_noop ("be verbose (print progress information)"), |
328 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 335 | 0, &GNUNET_GETOPT_set_one, &verbose}, |
336 | {'N', "results", "VALUE", | ||
337 | gettext_noop | ||
338 | ("automatically terminate search after VALUE results are found"), | ||
339 | 1, &GNUNET_GETOPT_set_ulong, &results_limit}, | ||
329 | GNUNET_GETOPT_OPTION_END | 340 | GNUNET_GETOPT_OPTION_END |
330 | }; | 341 | }; |
331 | return (GNUNET_OK == | 342 | return (GNUNET_OK == |