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;
GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE))
{
- fprintf (stderr,
+ FPRINTF (stderr,
_("Failed to write directory with search results to `%s'\n"),
output_filename);
}
/* ignore */
break;
case GNUNET_FS_STATUS_SEARCH_ERROR:
- fprintf (stderr, _("Error searching: %s.\n"),
+ FPRINTF (stderr, _("Error searching: %s.\n"),
info->value.search.specifics.error.message);
GNUNET_SCHEDULER_shutdown ();
break;
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
default:
- fprintf (stderr, _("Unexpected status: %d\n"), info->status);
+ FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
break;
}
return NULL;
struct GNUNET_FS_Uri *uri;
unsigned int argc;
enum GNUNET_FS_SearchOptions options;
- struct GNUNET_TIME_Relative delay;
argc = 0;
while (NULL != args[argc])
uri = GNUNET_FS_uri_ksk_create_from_args (argc, (const char **) args);
if (NULL == uri)
{
- fprintf (stderr, _("Could not create keyword URI from arguments.\n"));
+ FPRINTF (stderr, "%s", _("Could not create keyword URI from arguments.\n"));
ret = 1;
return;
}
GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
if (NULL == ctx)
{
- fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
+ FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
GNUNET_FS_uri_destroy (uri);
ret = 1;
return;
GNUNET_FS_uri_destroy (uri);
if (NULL == sc)
{
- fprintf (stderr, _("Could not start searching.\n"));
+ FPRINTF (stderr, "%s", _("Could not start searching.\n"));
GNUNET_FS_stop (ctx);
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);
- }
}
{'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},
{'N', "results", "VALUE",
gettext_noop
("automatically terminate search after VALUE results are found"),
- 1, &GNUNET_GETOPT_set_ulong, &results_limit},
+ 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 */