const struct GNUNET_CONTAINER_MetaData *md,
const void *data)
{
+ struct GNUNET_FS_Uri *curi;
struct BuilderEntry *e;
uint64_t fsize;
uint32_t big;
if (GNUNET_FS_uri_test_chk (uri))
fsize = GNUNET_FS_uri_chk_get_file_size (uri);
else
- fsize = GNUNET_FS_uri_chk_get_file_size (GNUNET_FS_uri_loc_get_uri (uri));
+ {
+ curi = GNUNET_FS_uri_loc_get_uri (uri);
+ fsize = GNUNET_FS_uri_chk_get_file_size (curi);
+ GNUNET_FS_uri_destroy (curi);
+ }
else
fsize = 0; /* not given */
if (fsize > MAX_INLINE_SIZE)
struct GNUNET_FS_DownloadContext *dc;
struct GNUNET_CLIENT_Connection *client;
- client = GNUNET_CLIENT_connect (h->sched,
- "fs",
- h->cfg);
- if (NULL == client)
- return NULL;
- // FIXME: add support for "loc" URIs!
GNUNET_assert (GNUNET_FS_uri_test_chk (uri));
if ( (offset + length < offset) ||
(offset + length > uri->data.chk.file_length) )
- {
+ {
GNUNET_break (0);
return NULL;
}
+ client = GNUNET_CLIENT_connect (h->sched,
+ "fs",
+ h->cfg);
+ if (NULL == client)
+ return NULL;
+ // FIXME: add support for "loc" URIs!
#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting download `%s' of %llu bytes\n",
anonymity,
priority,
expirationTime);
+ GNUNET_CONTAINER_meta_data_destroy (meta);
ret->data.dir.entries = dc.entries;
while (dc.entries != NULL)
{
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *info)
{
+ char *s;
+ char *t;
+
switch (info->status)
{
case GNUNET_FS_STATUS_DOWNLOAD_START:
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
if (verbose)
- fprintf (stdout,
- _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"),
- info->value.download.filename,
- (unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size,
- GNUNET_STRINGS_relative_time_to_string(info->value.download.eta),
- GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1)));
+ {
+ s = GNUNET_STRINGS_relative_time_to_string(info->value.download.eta);
+ t = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1));
+ fprintf (stdout,
+ _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"),
+ info->value.download.filename,
+ (unsigned long long) info->value.download.completed,
+ (unsigned long long) info->value.download.size,
+ s,
+ t);
+ GNUNET_free (s);
+ GNUNET_free (t);
+ }
break;
case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
fprintf (stderr,
GNUNET_FS_download_stop (dc, delete_incomplete);
break;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
+ s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1));
fprintf (stdout,
_("Downloading `%s' done (%s/s).\n"),
info->value.download.filename,
- GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1)));
+ s);
+ GNUNET_free (s);
if (info->value.download.dc == dc)
GNUNET_FS_download_stop (dc, delete_incomplete);
break;
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *info)
{
+ char *s;
+
switch (info->status)
{
case GNUNET_FS_STATUS_PUBLISH_START:
break;
case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
if (verbose)
- fprintf (stdout,
- _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
- info->value.publish.filename,
- (unsigned long long) info->value.publish.completed,
- (unsigned long long) info->value.publish.size,
- GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta));
+ {
+ s = GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta);
+ fprintf (stdout,
+ _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
+ info->value.publish.filename,
+ (unsigned long long) info->value.publish.completed,
+ (unsigned long long) info->value.publish.size,
+ s);
+ GNUNET_free (s);
+ }
break;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
fprintf (stderr,
pos->next = indexed_files;
indexed_files = pos;
}
+ GNUNET_free (fname);
}
if (GNUNET_OK !=
GNUNET_BIO_read_close (rh, &emsg))
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *info)
{
+ char *s;
+
switch (info->status)
{
case GNUNET_FS_STATUS_UNINDEX_START:
break;
case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
if (verbose)
- fprintf (stdout,
- _("Unindexing at %llu/%llu (%s remaining)\n"),
- (unsigned long long) info->value.unindex.completed,
- (unsigned long long) info->value.unindex.size,
- GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta));
+ {
+ s = GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta);
+ fprintf (stdout,
+ _("Unindexing at %llu/%llu (%s remaining)\n"),
+ (unsigned long long) info->value.unindex.completed,
+ (unsigned long long) info->value.unindex.size,
+ s);
+ GNUNET_free (s);
+ }
break;
case GNUNET_FS_STATUS_UNINDEX_ERROR:
fprintf (stderr,