- {
- case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
-#if VERBOSE
- printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n",
- (unsigned long long) event->value.publish.completed,
- (unsigned long long) event->value.publish.size,
- event->value.publish.specifics.progress.depth,
- (unsigned long long) event->value.publish.specifics.progress.offset);
-#endif
- break;
- case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
- printf ("Publishing complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024LL));
- fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
- start = GNUNET_TIME_absolute_get ();
- download = GNUNET_FS_download_start (fs,
- event->value.publish.specifics.completed.chk_uri,
- NULL,
- fn, NULL,
- 0,
- FILESIZE,
- 1,
- GNUNET_FS_DOWNLOAD_OPTION_NONE,
- "download",
- NULL);
- GNUNET_assert (download != NULL);
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
- printf ("Download complete, %llu kbps.\n",
- (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024LL));
- GNUNET_SCHEDULER_add_now (sched,
- &abort_download_task,
- NULL);
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
- GNUNET_assert (download == event->value.download.dc);
-#if VERBOSE
- printf ("Download is progressing (%llu/%llu at level %u off %llu)...\n",
- (unsigned long long) event->value.download.completed,
- (unsigned long long) event->value.download.size,
- event->value.download.specifics.progress.depth,
- (unsigned long long) event->value.download.specifics.progress.offset);
-#endif
- break;
- case GNUNET_FS_STATUS_PUBLISH_ERROR:
- fprintf (stderr,
- "Error publishing file: %s\n",
- event->value.publish.specifics.error.message);
- GNUNET_break (0);
- GNUNET_SCHEDULER_add_continuation (sched,
- &abort_publish_task,
- NULL,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
- fprintf (stderr,
- "Error downloading file: %s\n",
- event->value.download.specifics.error.message);
- GNUNET_SCHEDULER_add_now (sched,
- &abort_download_task,
- NULL);
- break;
- case GNUNET_FS_STATUS_PUBLISH_START:
- GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
- GNUNET_assert (NULL == event->value.publish.pctx);
- GNUNET_assert (FILESIZE == event->value.publish.size);
- GNUNET_assert (0 == event->value.publish.completed);
- GNUNET_assert (1 == event->value.publish.anonymity);
- break;
- case GNUNET_FS_STATUS_PUBLISH_STOPPED:
- GNUNET_assert (publish == event->value.publish.sc);
- GNUNET_assert (FILESIZE == event->value.publish.size);
- GNUNET_assert (1 == event->value.publish.anonymity);
- GNUNET_FS_stop (fs);
- fs = NULL;
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_START:
- GNUNET_assert (download == NULL);
- GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
- GNUNET_assert (NULL == event->value.download.pctx);
- GNUNET_assert (NULL != event->value.download.uri);
- GNUNET_assert (0 == strcmp (fn, event->value.download.filename));
- GNUNET_assert (FILESIZE == event->value.download.size);
- GNUNET_assert (0 == event->value.download.completed);
- GNUNET_assert (1 == event->value.download.anonymity);
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
- GNUNET_assert (download == event->value.download.dc);
- GNUNET_SCHEDULER_add_continuation (sched,
- &abort_publish_task,
- NULL,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- break;
- default:
- printf ("Unexpected event: %d\n",
- event->status);
- break;
- }
+ {
+ case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Publish is progressing (%llu/%llu at level %u off %llu)...\n",
+ (unsigned long long) event->value.publish.completed,
+ (unsigned long long) event->value.publish.size,
+ event->value.publish.specifics.progress.depth,
+ (unsigned long long) event->value.publish.specifics.
+ progress.offset);
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY:
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
+ fprintf (stdout,
+ "Publishing complete, %llu kb/s.\n",
+ (unsigned long long) (FILESIZE * 1000000LL /
+ (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us) / 1024LL));
+ GAUGER ("FS",
+ (GNUNET_YES == indexed)
+ ? "Publishing speed (indexing)"
+ : "Publishing speed (insertion)",
+ (unsigned long long) (FILESIZE * 1000000LL /
+ (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us) / 1024LL), "kb/s");
+ fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
+ start = GNUNET_TIME_absolute_get ();
+ download =
+ GNUNET_FS_download_start (fs,
+ event->value.publish.specifics.
+ completed.chk_uri, NULL, fn, NULL, 0,
+ FILESIZE, anonymity_level,
+ GNUNET_FS_DOWNLOAD_OPTION_NONE,
+ "download", NULL);
+ GNUNET_assert (download != NULL);
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
+ fprintf (stdout,
+ "Download complete, %llu kb/s.\n",
+ (unsigned long long) (FILESIZE * 1000000LL /
+ (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us) / 1024LL));
+ GAUGER ("FS",
+ (GNUNET_YES == indexed)
+ ? "Local download speed (indexed)"
+ : "Local download speed (inserted)",
+ (unsigned long long) (FILESIZE * 1000000LL /
+ (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start).rel_value_us) / 1024LL), "kb/s");
+ GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
+ GNUNET_assert (download == event->value.download.dc);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Download is progressing (%llu/%llu at level %u off %llu)...\n",
+ (unsigned long long) event->value.download.completed,
+ (unsigned long long) event->value.download.size,
+ event->value.download.specifics.progress.depth,
+ (unsigned long long) event->value.download.specifics.
+ progress.offset);
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_ERROR:
+ FPRINTF (stderr, "Error publishing file: %s\n",
+ event->value.publish.specifics.error.message);
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ GNUNET_SCHEDULER_shutdown ();
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
+ FPRINTF (stderr, "Error downloading file: %s\n",
+ event->value.download.specifics.error.message);
+ GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
+ GNUNET_SCHEDULER_shutdown ();
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
+ case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_START:
+ GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
+ GNUNET_assert (NULL == event->value.publish.pctx);
+ GNUNET_assert (FILESIZE == event->value.publish.size);
+ GNUNET_assert (0 == event->value.publish.completed);
+ GNUNET_assert (1 == event->value.publish.anonymity);
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_STOPPED:
+ GNUNET_assert (publish == event->value.publish.pc);
+ GNUNET_assert (FILESIZE == event->value.publish.size);
+ GNUNET_assert (1 == event->value.publish.anonymity);
+ GNUNET_SCHEDULER_add_now (&stop_fs_task, NULL);
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_START:
+ GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
+ GNUNET_assert (NULL == event->value.download.pctx);
+ GNUNET_assert (NULL != event->value.download.uri);
+ GNUNET_assert (0 == strcmp (fn, event->value.download.filename));
+ GNUNET_assert (FILESIZE == event->value.download.size);
+ GNUNET_assert (0 == event->value.download.completed);
+ GNUNET_assert (1 == event->value.download.anonymity);
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
+ GNUNET_assert (download == event->value.download.dc);
+ GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ break;
+ default:
+ printf ("Unexpected event: %d\n", event->status);
+ break;
+ }