aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/fs
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.c521
-rw-r--r--src/fs/fs_directory.c53
-rw-r--r--src/fs/fs_download.c370
-rw-r--r--src/fs/fs_file_information.c108
-rw-r--r--src/fs/fs_getopt.c15
-rw-r--r--src/fs/fs_list_indexed.c21
-rw-r--r--src/fs/fs_misc.c49
-rw-r--r--src/fs/fs_namespace.c163
-rw-r--r--src/fs/fs_publish.c297
-rw-r--r--src/fs/fs_search.c154
-rw-r--r--src/fs/fs_test_lib.c139
-rw-r--r--src/fs/fs_tree.c46
-rw-r--r--src/fs/fs_unindex.c57
-rw-r--r--src/fs/fs_uri.c111
-rw-r--r--src/fs/gnunet-directory.c46
-rw-r--r--src/fs/gnunet-download.c52
-rw-r--r--src/fs/gnunet-pseudonym.c38
-rw-r--r--src/fs/gnunet-publish.c121
-rw-r--r--src/fs/gnunet-search.c46
-rw-r--r--src/fs/gnunet-service-fs.c61
-rw-r--r--src/fs/gnunet-service-fs_cp.c220
-rw-r--r--src/fs/gnunet-service-fs_indexing.c129
-rw-r--r--src/fs/gnunet-service-fs_lc.c54
-rw-r--r--src/fs/gnunet-service-fs_pe.c75
-rw-r--r--src/fs/gnunet-service-fs_pr.c419
-rw-r--r--src/fs/gnunet-service-fs_push.c50
-rw-r--r--src/fs/gnunet-service-fs_put.c58
-rw-r--r--src/fs/gnunet-unindex.c29
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c84
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_trust.c102
-rw-r--r--src/fs/test_fs.c25
-rw-r--r--src/fs/test_fs_directory.c30
-rw-r--r--src/fs/test_fs_download.c94
-rw-r--r--src/fs/test_fs_download_indexed.c100
-rw-r--r--src/fs/test_fs_download_persistence.c86
-rw-r--r--src/fs/test_fs_download_recursive.c38
-rw-r--r--src/fs/test_fs_file_information.c65
-rw-r--r--src/fs/test_fs_list_indexed.c103
-rw-r--r--src/fs/test_fs_namespace.c48
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c45
-rw-r--r--src/fs/test_fs_publish.c90
-rw-r--r--src/fs/test_fs_publish_persistence.c96
-rw-r--r--src/fs/test_fs_search.c70
-rw-r--r--src/fs/test_fs_search_persistence.c74
-rw-r--r--src/fs/test_fs_search_ranking.c25
-rw-r--r--src/fs/test_fs_start_stop.c28
-rw-r--r--src/fs/test_fs_test_lib.c37
-rw-r--r--src/fs/test_fs_unindex.c77
-rw-r--r--src/fs/test_fs_unindex_persistence.c81
-rw-r--r--src/fs/test_fs_uri.c10
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c38
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c39
52 files changed, 2113 insertions, 2874 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c
index 318b7088e..e26a01996 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -52,8 +52,7 @@ start_job (struct GNUNET_FS_QueueEntry *qe)
52 qe->h->active_blocks += qe->blocks; 52 qe->h->active_blocks += qe->blocks;
53 qe->start_time = GNUNET_TIME_absolute_get (); 53 qe->start_time = GNUNET_TIME_absolute_get ();
54 GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe); 54 GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe);
55 GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, 55 GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, qe->h->running_tail,
56 qe->h->running_tail,
57 qe->h->running_tail, qe); 56 qe->h->running_tail, qe);
58} 57}
59 58
@@ -71,12 +70,12 @@ stop_job (struct GNUNET_FS_QueueEntry *qe)
71 qe->stop (qe->cls); 70 qe->stop (qe->cls);
72 qe->h->active_downloads--; 71 qe->h->active_downloads--;
73 qe->h->active_blocks -= qe->blocks; 72 qe->h->active_blocks -= qe->blocks;
74 qe->run_time = GNUNET_TIME_relative_add (qe->run_time, 73 qe->run_time =
75 GNUNET_TIME_absolute_get_duration 74 GNUNET_TIME_relative_add (qe->run_time,
76 (qe->start_time)); 75 GNUNET_TIME_absolute_get_duration (qe->
76 start_time));
77 GNUNET_CONTAINER_DLL_remove (qe->h->running_head, qe->h->running_tail, qe); 77 GNUNET_CONTAINER_DLL_remove (qe->h->running_head, qe->h->running_tail, qe);
78 GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head, 78 GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head, qe->h->pending_tail,
79 qe->h->pending_tail,
80 qe->h->pending_tail, qe); 79 qe->h->pending_tail, qe);
81} 80}
82 81
@@ -123,8 +122,9 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
123 while (NULL != (qe = next)) 122 while (NULL != (qe = next))
124 { 123 {
125 next = qe->next; 124 next = qe->next;
126 run_time = GNUNET_TIME_relative_multiply (h->avg_block_latency, 125 run_time =
127 qe->blocks * qe->start_times); 126 GNUNET_TIME_relative_multiply (h->avg_block_latency,
127 qe->blocks * qe->start_times);
128 end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); 128 end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time);
129 rst = GNUNET_TIME_absolute_get_remaining (end_time); 129 rst = GNUNET_TIME_absolute_get_remaining (end_time);
130 restart_at = GNUNET_TIME_relative_min (rst, restart_at); 130 restart_at = GNUNET_TIME_relative_min (rst, restart_at);
@@ -132,8 +132,8 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
132 continue; 132 continue;
133 stop_job (qe); 133 stop_job (qe);
134 } 134 }
135 h->queue_job = GNUNET_SCHEDULER_add_delayed (restart_at, 135 h->queue_job =
136 &process_job_queue, h); 136 GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h);
137} 137}
138 138
139 139
@@ -148,8 +148,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
148 * @return queue handle 148 * @return queue handle
149 */ 149 */
150struct GNUNET_FS_QueueEntry * 150struct GNUNET_FS_QueueEntry *
151GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, 151GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start,
152 GNUNET_FS_QueueStart start,
153 GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks) 152 GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks)
154{ 153{
155 struct GNUNET_FS_QueueEntry *qe; 154 struct GNUNET_FS_QueueEntry *qe;
@@ -161,8 +160,8 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
161 qe->cls = cls; 160 qe->cls = cls;
162 qe->queue_time = GNUNET_TIME_absolute_get (); 161 qe->queue_time = GNUNET_TIME_absolute_get ();
163 qe->blocks = blocks; 162 qe->blocks = blocks;
164 GNUNET_CONTAINER_DLL_insert_after (h->pending_head, 163 GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail,
165 h->pending_tail, h->pending_tail, qe); 164 h->pending_tail, qe);
166 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) 165 if (h->queue_job != GNUNET_SCHEDULER_NO_TASK)
167 GNUNET_SCHEDULER_cancel (h->queue_job); 166 GNUNET_SCHEDULER_cancel (h->queue_job);
168 h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); 167 h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h);
@@ -199,8 +198,8 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh)
199 * @return fresh top-level activity handle 198 * @return fresh top-level activity handle
200 */ 199 */
201struct TopLevelActivity * 200struct TopLevelActivity *
202GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, 201GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf,
203 SuspendSignalFunction ssf, void *ssf_cls) 202 void *ssf_cls)
204{ 203{
205 struct TopLevelActivity *ret; 204 struct TopLevelActivity *ret;
206 205
@@ -261,9 +260,8 @@ struct FileInfo
261 * @return number of bytes written, usually "max", 0 on error 260 * @return number of bytes written, usually "max", 0 on error
262 */ 261 */
263size_t 262size_t
264GNUNET_FS_data_reader_file_ (void *cls, 263GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf,
265 uint64_t offset, 264 char **emsg)
266 size_t max, void *buf, char **emsg)
267{ 265{
268 struct FileInfo *fi = cls; 266 struct FileInfo *fi = cls;
269 ssize_t ret; 267 ssize_t ret;
@@ -278,14 +276,13 @@ GNUNET_FS_data_reader_file_ (void *cls,
278 } 276 }
279 if (fi->fd == NULL) 277 if (fi->fd == NULL)
280 { 278 {
281 fi->fd = GNUNET_DISK_file_open (fi->filename, 279 fi->fd =
282 GNUNET_DISK_OPEN_READ, 280 GNUNET_DISK_file_open (fi->filename, GNUNET_DISK_OPEN_READ,
283 GNUNET_DISK_PERM_NONE); 281 GNUNET_DISK_PERM_NONE);
284 if (fi->fd == NULL) 282 if (fi->fd == NULL)
285 { 283 {
286 GNUNET_asprintf (emsg, 284 GNUNET_asprintf (emsg, _("Could not open file `%s': %s"), fi->filename,
287 _("Could not open file `%s': %s"), 285 STRERROR (errno));
288 fi->filename, STRERROR (errno));
289 return 0; 286 return 0;
290 } 287 }
291 } 288 }
@@ -293,15 +290,14 @@ GNUNET_FS_data_reader_file_ (void *cls,
293 ret = GNUNET_DISK_file_read (fi->fd, buf, max); 290 ret = GNUNET_DISK_file_read (fi->fd, buf, max);
294 if (ret == -1) 291 if (ret == -1)
295 { 292 {
296 GNUNET_asprintf (emsg, 293 GNUNET_asprintf (emsg, _("Could not read file `%s': %s"), fi->filename,
297 _("Could not read file `%s': %s"), 294 STRERROR (errno));
298 fi->filename, STRERROR (errno));
299 return 0; 295 return 0;
300 } 296 }
301 if (ret != max) 297 if (ret != max)
302 { 298 {
303 GNUNET_asprintf (emsg, 299 GNUNET_asprintf (emsg, _("Short read reading from file `%s'!"),
304 _("Short read reading from file `%s'!"), fi->filename); 300 fi->filename);
305 return 0; 301 return 0;
306 } 302 }
307 return max; 303 return max;
@@ -347,9 +343,8 @@ GNUNET_FS_make_file_reader_context_ (const char *filename)
347 * @return number of bytes written, usually "max", 0 on error 343 * @return number of bytes written, usually "max", 0 on error
348 */ 344 */
349size_t 345size_t
350GNUNET_FS_data_reader_copy_ (void *cls, 346GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf,
351 uint64_t offset, 347 char **emsg)
352 size_t max, void *buf, char **emsg)
353{ 348{
354 char *data = cls; 349 char *data = cls;
355 350
@@ -373,8 +368,8 @@ GNUNET_FS_data_reader_copy_ (void *cls,
373 * @return NULL on error 368 * @return NULL on error
374 */ 369 */
375static char * 370static char *
376get_serialization_file_name (struct GNUNET_FS_Handle *h, 371get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext,
377 const char *ext, const char *ent) 372 const char *ent)
378{ 373{
379 char *basename; 374 char *basename;
380 char *ret; 375 char *ret;
@@ -382,15 +377,12 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h,
382 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 377 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
383 return NULL; /* persistence not requested */ 378 return NULL; /* persistence not requested */
384 if (GNUNET_OK != 379 if (GNUNET_OK !=
385 GNUNET_CONFIGURATION_get_value_filename (h->cfg, 380 GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR",
386 "fs", "STATE_DIR", &basename)) 381 &basename))
387 return NULL; 382 return NULL;
388 GNUNET_asprintf (&ret, 383 GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s", basename, DIR_SEPARATOR_STR,
389 "%s%s%s%s%s%s%s", 384 h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR,
390 basename, 385 ent);
391 DIR_SEPARATOR_STR,
392 h->client_name,
393 DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR, ent);
394 GNUNET_free (basename); 386 GNUNET_free (basename);
395 return ret; 387 return ret;
396} 388}
@@ -408,8 +400,7 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h,
408 * @return NULL on error 400 * @return NULL on error
409 */ 401 */
410static char * 402static char *
411get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, 403get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
412 const char *ext,
413 const char *uni, const char *ent) 404 const char *uni, const char *ent)
414{ 405{
415 char *basename; 406 char *basename;
@@ -418,16 +409,12 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
418 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 409 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
419 return NULL; /* persistence not requested */ 410 return NULL; /* persistence not requested */
420 if (GNUNET_OK != 411 if (GNUNET_OK !=
421 GNUNET_CONFIGURATION_get_value_filename (h->cfg, 412 GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR",
422 "fs", "STATE_DIR", &basename)) 413 &basename))
423 return NULL; 414 return NULL;
424 GNUNET_asprintf (&ret, 415 GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s.dir%s%s", basename, DIR_SEPARATOR_STR,
425 "%s%s%s%s%s%s%s.dir%s%s", 416 h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR,
426 basename, 417 uni, DIR_SEPARATOR_STR, ent);
427 DIR_SEPARATOR_STR,
428 h->client_name,
429 DIR_SEPARATOR_STR,
430 ext, DIR_SEPARATOR_STR, uni, DIR_SEPARATOR_STR, ent);
431 GNUNET_free (basename); 418 GNUNET_free (basename);
432 return ret; 419 return ret;
433} 420}
@@ -493,8 +480,8 @@ get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
493 * @return NULL on error 480 * @return NULL on error
494 */ 481 */
495static struct GNUNET_BIO_WriteHandle * 482static struct GNUNET_BIO_WriteHandle *
496get_write_handle_in_dir (struct GNUNET_FS_Handle *h, 483get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
497 const char *ext, const char *uni, const char *ent) 484 const char *uni, const char *ent)
498{ 485{
499 char *fn; 486 char *fn;
500 struct GNUNET_BIO_WriteHandle *ret; 487 struct GNUNET_BIO_WriteHandle *ret;
@@ -516,8 +503,8 @@ get_write_handle_in_dir (struct GNUNET_FS_Handle *h,
516 * @param ent entity identifier 503 * @param ent entity identifier
517 */ 504 */
518void 505void
519GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, 506GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
520 const char *ext, const char *ent) 507 const char *ent)
521{ 508{
522 char *filename; 509 char *filename;
523 510
@@ -545,8 +532,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
545 * @param ent entity identifier 532 * @param ent entity identifier
546 */ 533 */
547static void 534static void
548remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, 535remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
549 const char *ext, const char *uni, const char *ent) 536 const char *uni, const char *ent)
550{ 537{
551 char *filename; 538 char *filename;
552 539
@@ -573,8 +560,8 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h,
573 * @param uni unique name of parent 560 * @param uni unique name of parent
574 */ 561 */
575void 562void
576GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, 563GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext,
577 const char *ext, const char *uni) 564 const char *uni)
578{ 565{
579 char *dn; 566 char *dn;
580 567
@@ -670,8 +657,8 @@ static struct GNUNET_FS_FileInformation *deserialize_file_information (struct
670 * @return NULL on error 657 * @return NULL on error
671 */ 658 */
672static struct GNUNET_FS_FileInformation * 659static struct GNUNET_FS_FileInformation *
673deserialize_fi_node (struct GNUNET_FS_Handle *h, 660deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn,
674 const char *fn, struct GNUNET_BIO_ReadHandle *rh) 661 struct GNUNET_BIO_ReadHandle *rh)
675{ 662{
676 struct GNUNET_FS_FileInformation *ret; 663 struct GNUNET_FS_FileInformation *ret;
677 struct GNUNET_FS_FileInformation *nxt; 664 struct GNUNET_FS_FileInformation *nxt;
@@ -691,34 +678,23 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
691 ksks = NULL; 678 ksks = NULL;
692 chks = NULL; 679 chks = NULL;
693 filename = NULL; 680 filename = NULL;
694 if ((GNUNET_OK != 681 if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) ||
695 GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || 682 (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) ||
696 (GNUNET_OK !=
697 GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) ||
698 ((ksks != NULL) && 683 ((ksks != NULL) &&
699 (NULL == 684 (NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL)))) ||
700 (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL)))) || 685 (GNUNET_YES != GNUNET_FS_uri_test_ksk (ret->keywords)) ||
701 (GNUNET_YES != 686 (GNUNET_OK != GNUNET_BIO_read_string (rh, "chk-uri", &chks, 1024)) ||
702 GNUNET_FS_uri_test_ksk (ret->keywords)) ||
703 (GNUNET_OK !=
704 GNUNET_BIO_read_string (rh, "chk-uri", &chks, 1024)) ||
705 ((chks != NULL) && 687 ((chks != NULL) &&
706 ((NULL == 688 ((NULL == (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) ||
707 (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) || 689 (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri)))) ||
708 (GNUNET_YES != 690 (GNUNET_OK != read_start_time (rh, &ret->start_time)) ||
709 GNUNET_FS_uri_test_chk (ret->chk_uri)))) || 691 (GNUNET_OK != GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024))
710 (GNUNET_OK != 692 || (GNUNET_OK !=
711 read_start_time (rh, &ret->start_time)) || 693 GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) ||
712 (GNUNET_OK !=
713 GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024)) ||
714 (GNUNET_OK !=
715 GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) ||
716 (GNUNET_OK != 694 (GNUNET_OK !=
717 GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value)) || 695 GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value)) ||
718 (GNUNET_OK != 696 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) ||
719 GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) || 697 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) ||
720 (GNUNET_OK !=
721 GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) ||
722 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level))) 698 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level)))
723 { 699 {
724 GNUNET_break (0); 700 GNUNET_break (0);
@@ -786,8 +762,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
786 GNUNET_break (0); 762 GNUNET_break (0);
787 goto cleanup; 763 goto cleanup;
788 } 764 }
789 if ((GNUNET_OK != 765 if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
790 GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
791 (GNUNET_OK != 766 (GNUNET_OK !=
792 GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id, 767 GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id,
793 sizeof (GNUNET_HashCode)))) 768 sizeof (GNUNET_HashCode))))
@@ -809,8 +784,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
809 GNUNET_break (0); 784 GNUNET_break (0);
810 goto cleanup; 785 goto cleanup;
811 } 786 }
812 if ((GNUNET_OK != 787 if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
813 GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) ||
814 (GNUNET_OK != 788 (GNUNET_OK !=
815 GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id, 789 GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id,
816 sizeof (GNUNET_HashCode)))) 790 sizeof (GNUNET_HashCode))))
@@ -828,8 +802,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
828 break; 802 break;
829 case 4: /* directory */ 803 case 4: /* directory */
830 ret->is_directory = GNUNET_YES; 804 ret->is_directory = GNUNET_YES;
831 if ((GNUNET_OK != 805 if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dsize)) ||
832 GNUNET_BIO_read_int32 (rh, &dsize)) ||
833 (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) || 806 (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) ||
834 (GNUNET_OK != 807 (GNUNET_OK !=
835 GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) || 808 GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) ||
@@ -1046,8 +1019,8 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh,
1046 while (off < fi->data.file.file_size) 1019 while (off < fi->data.file.file_size)
1047 { 1020 {
1048 left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off); 1021 left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off);
1049 ret = fi->data.file.reader (fi->data.file.reader_cls, 1022 ret =
1050 off, left, buf, &emsg); 1023 fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg);
1051 if (ret == 0) 1024 if (ret == 0)
1052 { 1025 {
1053 GNUNET_free (emsg); 1026 GNUNET_free (emsg);
@@ -1107,26 +1080,17 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
1107 chks = GNUNET_FS_uri_to_string (fi->chk_uri); 1080 chks = GNUNET_FS_uri_to_string (fi->chk_uri);
1108 else 1081 else
1109 chks = NULL; 1082 chks = NULL;
1110 if ((GNUNET_OK != 1083 if ((GNUNET_OK != GNUNET_BIO_write (wh, &b, sizeof (b))) ||
1111 GNUNET_BIO_write (wh, &b, sizeof (b))) || 1084 (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, fi->meta)) ||
1112 (GNUNET_OK != 1085 (GNUNET_OK != GNUNET_BIO_write_string (wh, ksks)) ||
1113 GNUNET_BIO_write_meta_data (wh, fi->meta)) || 1086 (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) ||
1114 (GNUNET_OK != 1087 (GNUNET_OK != write_start_time (wh, fi->start_time)) ||
1115 GNUNET_BIO_write_string (wh, ksks)) || 1088 (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) ||
1116 (GNUNET_OK != 1089 (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) ||
1117 GNUNET_BIO_write_string (wh, chks)) ||
1118 (GNUNET_OK !=
1119 write_start_time (wh, fi->start_time)) ||
1120 (GNUNET_OK !=
1121 GNUNET_BIO_write_string (wh, fi->emsg)) ||
1122 (GNUNET_OK !=
1123 GNUNET_BIO_write_string (wh, fi->filename)) ||
1124 (GNUNET_OK != 1090 (GNUNET_OK !=
1125 GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value)) || 1091 GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value)) ||
1126 (GNUNET_OK != 1092 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) ||
1127 GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) || 1093 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) ||
1128 (GNUNET_OK !=
1129 GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) ||
1130 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.replication_level))) 1094 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.replication_level)))
1131 { 1095 {
1132 GNUNET_break (0); 1096 GNUNET_break (0);
@@ -1171,8 +1135,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
1171 GNUNET_break (0); 1135 GNUNET_break (0);
1172 goto cleanup; 1136 goto cleanup;
1173 } 1137 }
1174 if ((GNUNET_OK != 1138 if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) ||
1175 GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) ||
1176 (GNUNET_OK != 1139 (GNUNET_OK !=
1177 GNUNET_BIO_write (wh, &fi->data.file.file_id, 1140 GNUNET_BIO_write (wh, &fi->data.file.file_id,
1178 sizeof (GNUNET_HashCode)))) 1141 sizeof (GNUNET_HashCode))))
@@ -1182,16 +1145,15 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
1182 } 1145 }
1183 break; 1146 break;
1184 case 4: /* directory */ 1147 case 4: /* directory */
1185 if ((GNUNET_OK != 1148 if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) ||
1186 GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) ||
1187 (GNUNET_OK != 1149 (GNUNET_OK !=
1188 GNUNET_BIO_write (wh, fi->data.dir.dir_data, 1150 GNUNET_BIO_write (wh, fi->data.dir.dir_data,
1189 (uint32_t) fi->data.dir.dir_size)) || 1151 (uint32_t) fi->data.dir.dir_size)) ||
1190 (GNUNET_OK != 1152 (GNUNET_OK !=
1191 GNUNET_BIO_write_string (wh, 1153 GNUNET_BIO_write_string (wh,
1192 (fi->data.dir.entries == 1154 (fi->data.dir.entries ==
1193 NULL) ? NULL : fi->data.dir. 1155 NULL) ? NULL : fi->data.dir.entries->
1194 entries->serialization))) 1156 serialization)))
1195 { 1157 {
1196 GNUNET_break (0); 1158 GNUNET_break (0);
1197 goto cleanup; 1159 goto cleanup;
@@ -1279,13 +1241,11 @@ find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch)
1279 * @return GNUNET_OK to continue (always) 1241 * @return GNUNET_OK to continue (always)
1280 */ 1242 */
1281static int 1243static int
1282fip_signal_resume (void *cls, 1244fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi,
1283 struct GNUNET_FS_FileInformation *fi, 1245 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1284 uint64_t length,
1285 struct GNUNET_CONTAINER_MetaData *meta,
1286 struct GNUNET_FS_Uri **uri, 1246 struct GNUNET_FS_Uri **uri,
1287 struct GNUNET_FS_BlockOptions *bo, 1247 struct GNUNET_FS_BlockOptions *bo, int *do_index,
1288 int *do_index, void **client_info) 1248 void **client_info)
1289{ 1249{
1290 struct GNUNET_FS_PublishContext *sc = cls; 1250 struct GNUNET_FS_PublishContext *sc = cls;
1291 struct GNUNET_FS_ProgressInfo pi; 1251 struct GNUNET_FS_ProgressInfo pi;
@@ -1331,19 +1291,15 @@ deserialize_publish_file (void *cls, const char *filename)
1331 GNUNET_break (0); 1291 GNUNET_break (0);
1332 goto cleanup; 1292 goto cleanup;
1333 } 1293 }
1334 if ((GNUNET_OK != 1294 if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024))
1335 GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) || 1295 || (GNUNET_OK !=
1336 (GNUNET_OK != 1296 GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) ||
1337 GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) || 1297 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) ||
1338 (GNUNET_OK != 1298 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &all_done)) ||
1339 GNUNET_BIO_read_int32 (rh, &options)) ||
1340 (GNUNET_OK !=
1341 GNUNET_BIO_read_int32 (rh, &all_done)) ||
1342 (GNUNET_OK != 1299 (GNUNET_OK !=
1343 GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) || 1300 GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) ||
1344 (GNUNET_OK != 1301 (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128))
1345 GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) || 1302 || (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024)))
1346 (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024)))
1347 { 1303 {
1348 GNUNET_break (0); 1304 GNUNET_break (0);
1349 goto cleanup; 1305 goto cleanup;
@@ -1402,8 +1358,7 @@ deserialize_publish_file (void *cls, const char *filename)
1402 if (pc->all_done != GNUNET_YES) 1358 if (pc->all_done != GNUNET_YES)
1403 { 1359 {
1404 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 1360 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
1405 pc->upload_task 1361 pc->upload_task =
1406 =
1407 GNUNET_SCHEDULER_add_with_priority 1362 GNUNET_SCHEDULER_add_with_priority
1408 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); 1363 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc);
1409 } 1364 }
@@ -1426,8 +1381,8 @@ cleanup:
1426 if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) 1381 if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)))
1427 { 1382 {
1428 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1383 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1429 _("Failed to resume publishing operation `%s': %s\n"), 1384 _("Failed to resume publishing operation `%s': %s\n"), filename,
1430 filename, emsg); 1385 emsg);
1431 GNUNET_free (emsg); 1386 GNUNET_free (emsg);
1432 } 1387 }
1433 if (pc->fi != NULL) 1388 if (pc->fi != NULL)
@@ -1454,8 +1409,9 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
1454 struct GNUNET_BIO_WriteHandle *wh; 1409 struct GNUNET_BIO_WriteHandle *wh;
1455 1410
1456 if (NULL == pc->serialization) 1411 if (NULL == pc->serialization)
1457 pc->serialization = make_serialization_file_name (pc->h, 1412 pc->serialization =
1458 GNUNET_FS_SYNC_PATH_MASTER_PUBLISH); 1413 make_serialization_file_name (pc->h,
1414 GNUNET_FS_SYNC_PATH_MASTER_PUBLISH);
1459 if (NULL == pc->serialization) 1415 if (NULL == pc->serialization)
1460 return; 1416 return;
1461 if (NULL == pc->fi) 1417 if (NULL == pc->fi)
@@ -1472,16 +1428,11 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
1472 GNUNET_break (0); 1428 GNUNET_break (0);
1473 goto cleanup; 1429 goto cleanup;
1474 } 1430 }
1475 if ((GNUNET_OK != 1431 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nid)) ||
1476 GNUNET_BIO_write_string (wh, pc->nid)) || 1432 (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nuid)) ||
1477 (GNUNET_OK != 1433 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->options)) ||
1478 GNUNET_BIO_write_string (wh, pc->nuid)) || 1434 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->all_done)) ||
1479 (GNUNET_OK != 1435 (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) ||
1480 GNUNET_BIO_write_int32 (wh, pc->options)) ||
1481 (GNUNET_OK !=
1482 GNUNET_BIO_write_int32 (wh, pc->all_done)) ||
1483 (GNUNET_OK !=
1484 GNUNET_BIO_write_string (wh, pc->fi->serialization)) ||
1485 (GNUNET_OK != 1436 (GNUNET_OK !=
1486 GNUNET_BIO_write_string (wh, 1437 GNUNET_BIO_write_string (wh,
1487 (pc->fi_pos == 1438 (pc->fi_pos ==
@@ -1525,8 +1476,9 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
1525 struct GNUNET_BIO_WriteHandle *wh; 1476 struct GNUNET_BIO_WriteHandle *wh;
1526 1477
1527 if (NULL == uc->serialization) 1478 if (NULL == uc->serialization)
1528 uc->serialization = make_serialization_file_name (uc->h, 1479 uc->serialization =
1529 GNUNET_FS_SYNC_PATH_MASTER_UNINDEX); 1480 make_serialization_file_name (uc->h,
1481 GNUNET_FS_SYNC_PATH_MASTER_UNINDEX);
1530 if (NULL == uc->serialization) 1482 if (NULL == uc->serialization)
1531 return; 1483 return;
1532 wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 1484 wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
@@ -1536,14 +1488,10 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
1536 GNUNET_break (0); 1488 GNUNET_break (0);
1537 goto cleanup; 1489 goto cleanup;
1538 } 1490 }
1539 if ((GNUNET_OK != 1491 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uc->filename)) ||
1540 GNUNET_BIO_write_string (wh, uc->filename)) || 1492 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, uc->file_size)) ||
1541 (GNUNET_OK != 1493 (GNUNET_OK != write_start_time (wh, uc->start_time)) ||
1542 GNUNET_BIO_write_int64 (wh, uc->file_size)) || 1494 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) ||
1543 (GNUNET_OK !=
1544 write_start_time (wh, uc->start_time)) ||
1545 (GNUNET_OK !=
1546 GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) ||
1547 ((uc->state == UNINDEX_STATE_FS_NOTIFY) && 1495 ((uc->state == UNINDEX_STATE_FS_NOTIFY) &&
1548 (GNUNET_OK != 1496 (GNUNET_OK !=
1549 GNUNET_BIO_write (wh, &uc->file_id, sizeof (GNUNET_HashCode)))) || 1497 GNUNET_BIO_write (wh, &uc->file_id, sizeof (GNUNET_HashCode)))) ||
@@ -1583,12 +1531,9 @@ write_download_request (struct GNUNET_BIO_WriteHandle *wh,
1583{ 1531{
1584 unsigned int i; 1532 unsigned int i;
1585 1533
1586 if ((GNUNET_OK != 1534 if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->state)) ||
1587 GNUNET_BIO_write_int32 (wh, dr->state)) || 1535 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dr->offset)) ||
1588 (GNUNET_OK != 1536 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->num_children)) ||
1589 GNUNET_BIO_write_int64 (wh, dr->offset)) ||
1590 (GNUNET_OK !=
1591 GNUNET_BIO_write_int32 (wh, dr->num_children)) ||
1592 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth))) 1537 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth)))
1593 return GNUNET_NO; 1538 return GNUNET_NO;
1594 if ((dr->state == BRS_CHK_SET) && 1539 if ((dr->state == BRS_CHK_SET) &&
@@ -1616,16 +1561,14 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh)
1616 1561
1617 dr = GNUNET_malloc (sizeof (struct DownloadRequest)); 1562 dr = GNUNET_malloc (sizeof (struct DownloadRequest));
1618 1563
1619 if ((GNUNET_OK != 1564 if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) ||
1620 GNUNET_BIO_read_int32 (rh, &dr->state)) || 1565 (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) ||
1621 (GNUNET_OK != 1566 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) ||
1622 GNUNET_BIO_read_int64 (rh, &dr->offset)) ||
1623 (GNUNET_OK !=
1624 GNUNET_BIO_read_int32 (rh, &dr->num_children)) ||
1625 (dr->num_children > CHK_PER_INODE) || 1567 (dr->num_children > CHK_PER_INODE) ||
1626 (GNUNET_OK != 1568 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((dr->depth == 0)
1627 GNUNET_BIO_read_int32 (rh, &dr->depth)) || 1569 && (dr->
1628 ((dr->depth == 0) && (dr->num_children > 0)) || 1570 num_children
1571 > 0)) ||
1629 ((dr->depth > 0) && (dr->num_children == 0))) 1572 ((dr->depth > 0) && (dr->num_children == 0)))
1630 { 1573 {
1631 GNUNET_break (0); 1574 GNUNET_break (0);
@@ -1633,8 +1576,8 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh)
1633 goto cleanup; 1576 goto cleanup;
1634 } 1577 }
1635 if (dr->num_children > 0) 1578 if (dr->num_children > 0)
1636 dr->children = GNUNET_malloc (dr->num_children * 1579 dr->children =
1637 sizeof (struct ContentHashKey)); 1580 GNUNET_malloc (dr->num_children * sizeof (struct ContentHashKey));
1638 switch (dr->state) 1581 switch (dr->state)
1639 { 1582 {
1640 case BRS_INIT: 1583 case BRS_INIT:
@@ -1686,7 +1629,8 @@ get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc,
1686 1629
1687 if (dc->parent == NULL) 1630 if (dc->parent == NULL)
1688 return get_serialization_file_name (dc->h, 1631 return get_serialization_file_name (dc->h,
1689 (dc->search != NULL) ? 1632 (dc->search !=
1633 NULL) ?
1690 GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : 1634 GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
1691 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 1635 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
1692 uni); 1636 uni);
@@ -1755,30 +1699,18 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
1755 GNUNET_assert ((GNUNET_YES == GNUNET_FS_uri_test_chk (dc->uri)) || 1699 GNUNET_assert ((GNUNET_YES == GNUNET_FS_uri_test_chk (dc->uri)) ||
1756 (GNUNET_YES == GNUNET_FS_uri_test_loc (dc->uri))); 1700 (GNUNET_YES == GNUNET_FS_uri_test_loc (dc->uri)));
1757 uris = GNUNET_FS_uri_to_string (dc->uri); 1701 uris = GNUNET_FS_uri_to_string (dc->uri);
1758 if ((GNUNET_OK != 1702 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
1759 GNUNET_BIO_write_string (wh, uris)) || 1703 (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, dc->meta)) ||
1760 (GNUNET_OK != 1704 (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->emsg)) ||
1761 GNUNET_BIO_write_meta_data (wh, dc->meta)) || 1705 (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->filename)) ||
1762 (GNUNET_OK != 1706 (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->temp_filename)) ||
1763 GNUNET_BIO_write_string (wh, dc->emsg)) || 1707 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->old_file_size)) ||
1764 (GNUNET_OK != 1708 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->offset)) ||
1765 GNUNET_BIO_write_string (wh, dc->filename)) || 1709 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->length)) ||
1766 (GNUNET_OK != 1710 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->completed)) ||
1767 GNUNET_BIO_write_string (wh, dc->temp_filename)) || 1711 (GNUNET_OK != write_start_time (wh, dc->start_time)) ||
1768 (GNUNET_OK != 1712 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dc->anonymity)) ||
1769 GNUNET_BIO_write_int64 (wh, dc->old_file_size)) || 1713 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) ||
1770 (GNUNET_OK !=
1771 GNUNET_BIO_write_int64 (wh, dc->offset)) ||
1772 (GNUNET_OK !=
1773 GNUNET_BIO_write_int64 (wh, dc->length)) ||
1774 (GNUNET_OK !=
1775 GNUNET_BIO_write_int64 (wh, dc->completed)) ||
1776 (GNUNET_OK !=
1777 write_start_time (wh, dc->start_time)) ||
1778 (GNUNET_OK !=
1779 GNUNET_BIO_write_int32 (wh, dc->anonymity)) ||
1780 (GNUNET_OK !=
1781 GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) ||
1782 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->has_finished))) 1714 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->has_finished)))
1783 { 1715 {
1784 GNUNET_break (0); 1716 GNUNET_break (0);
@@ -1831,22 +1763,19 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
1831 1763
1832 uris = NULL; 1764 uris = NULL;
1833 if (NULL == sr->serialization) 1765 if (NULL == sr->serialization)
1834 sr->serialization = make_serialization_file_name_in_dir (sr->sc->h, 1766 sr->serialization =
1835 (sr-> 1767 make_serialization_file_name_in_dir (sr->sc->h,
1836 sc->psearch_result 1768 (sr->sc->psearch_result ==
1837 == 1769 NULL) ?
1838 NULL) ? 1770 GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
1839 GNUNET_FS_SYNC_PATH_MASTER_SEARCH 1771 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
1840 : 1772 sr->sc->serialization);
1841 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
1842 sr->
1843 sc->serialization);
1844 if (NULL == sr->serialization) 1773 if (NULL == sr->serialization)
1845 return; 1774 return;
1846 wh = get_write_handle_in_dir (sr->sc->h, 1775 wh = get_write_handle_in_dir (sr->sc->h,
1847 (sr->sc->psearch_result == NULL) 1776 (sr->sc->psearch_result ==
1848 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 1777 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
1849 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 1778 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
1850 sr->sc->serialization, sr->serialization); 1779 sr->sc->serialization, sr->serialization);
1851 if (wh == NULL) 1780 if (wh == NULL)
1852 { 1781 {
@@ -1854,8 +1783,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
1854 goto cleanup; 1783 goto cleanup;
1855 } 1784 }
1856 uris = GNUNET_FS_uri_to_string (sr->uri); 1785 uris = GNUNET_FS_uri_to_string (sr->uri);
1857 if ((GNUNET_OK != 1786 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
1858 GNUNET_BIO_write_string (wh, uris)) ||
1859 (GNUNET_OK != 1787 (GNUNET_OK !=
1860 GNUNET_BIO_write_string (wh, 1788 GNUNET_BIO_write_string (wh,
1861 sr->download != 1789 sr->download !=
@@ -1887,9 +1815,9 @@ cleanup:
1887 if (wh != NULL) 1815 if (wh != NULL)
1888 (void) GNUNET_BIO_write_close (wh); 1816 (void) GNUNET_BIO_write_close (wh);
1889 remove_sync_file_in_dir (sr->sc->h, 1817 remove_sync_file_in_dir (sr->sc->h,
1890 (sr->sc->psearch_result == NULL) 1818 (sr->sc->psearch_result ==
1891 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 1819 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
1892 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 1820 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
1893 sr->sc->serialization, sr->serialization); 1821 sr->sc->serialization, sr->serialization);
1894 GNUNET_free (sr->serialization); 1822 GNUNET_free (sr->serialization);
1895 sr->serialization = NULL; 1823 sr->serialization = NULL;
@@ -1912,8 +1840,10 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc)
1912 char in_pause; 1840 char in_pause;
1913 const char *category; 1841 const char *category;
1914 1842
1915 category = (sc->psearch_result == NULL) 1843 category =
1916 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : GNUNET_FS_SYNC_PATH_CHILD_SEARCH; 1844 (sc->psearch_result ==
1845 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
1846 GNUNET_FS_SYNC_PATH_CHILD_SEARCH;
1917 if (NULL == sc->serialization) 1847 if (NULL == sc->serialization)
1918 sc->serialization = make_serialization_file_name (sc->h, category); 1848 sc->serialization = make_serialization_file_name (sc->h, category);
1919 if (NULL == sc->serialization) 1849 if (NULL == sc->serialization)
@@ -1929,16 +1859,11 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc)
1929 (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri))); 1859 (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri)));
1930 uris = GNUNET_FS_uri_to_string (sc->uri); 1860 uris = GNUNET_FS_uri_to_string (sc->uri);
1931 in_pause = (sc->task != GNUNET_SCHEDULER_NO_TASK) ? 'r' : '\0'; 1861 in_pause = (sc->task != GNUNET_SCHEDULER_NO_TASK) ? 'r' : '\0';
1932 if ((GNUNET_OK != 1862 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
1933 GNUNET_BIO_write_string (wh, uris)) || 1863 (GNUNET_OK != write_start_time (wh, sc->start_time)) ||
1934 (GNUNET_OK != 1864 (GNUNET_OK != GNUNET_BIO_write_string (wh, sc->emsg)) ||
1935 write_start_time (wh, sc->start_time)) || 1865 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) ||
1936 (GNUNET_OK != 1866 (GNUNET_OK != GNUNET_BIO_write (wh, &in_pause, sizeof (in_pause))) ||
1937 GNUNET_BIO_write_string (wh, sc->emsg)) ||
1938 (GNUNET_OK !=
1939 GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) ||
1940 (GNUNET_OK !=
1941 GNUNET_BIO_write (wh, &in_pause, sizeof (in_pause))) ||
1942 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sc->anonymity))) 1867 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sc->anonymity)))
1943 { 1868 {
1944 GNUNET_break (0); 1869 GNUNET_break (0);
@@ -1992,10 +1917,8 @@ deserialize_unindex_file (void *cls, const char *filename)
1992 } 1917 }
1993 if ((GNUNET_OK != 1918 if ((GNUNET_OK !=
1994 GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10 * 1024)) || 1919 GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10 * 1024)) ||
1995 (GNUNET_OK != 1920 (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &uc->file_size)) ||
1996 GNUNET_BIO_read_int64 (rh, &uc->file_size)) || 1921 (GNUNET_OK != read_start_time (rh, &uc->start_time)) ||
1997 (GNUNET_OK !=
1998 read_start_time (rh, &uc->start_time)) ||
1999 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &state))) 1922 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &state)))
2000 { 1923 {
2001 GNUNET_break (0); 1924 GNUNET_break (0);
@@ -2034,17 +1957,16 @@ deserialize_unindex_file (void *cls, const char *filename)
2034 uc->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, uc); 1957 uc->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, uc);
2035 pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME; 1958 pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME;
2036 pi.value.unindex.specifics.resume.message = uc->emsg; 1959 pi.value.unindex.specifics.resume.message = uc->emsg;
2037 GNUNET_FS_unindex_make_status_ (&pi, 1960 GNUNET_FS_unindex_make_status_ (&pi, uc,
2038 uc, 1961 (uc->state ==
2039 (uc->state == UNINDEX_STATE_COMPLETE) 1962 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
2040 ? uc->file_size : 0);
2041 switch (uc->state) 1963 switch (uc->state)
2042 { 1964 {
2043 case UNINDEX_STATE_HASHING: 1965 case UNINDEX_STATE_HASHING:
2044 uc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, 1966 uc->fhc =
2045 uc->filename, 1967 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, uc->filename,
2046 HASHING_BLOCKSIZE, 1968 HASHING_BLOCKSIZE,
2047 &GNUNET_FS_unindex_process_hash_, uc); 1969 &GNUNET_FS_unindex_process_hash_, uc);
2048 break; 1970 break;
2049 case UNINDEX_STATE_FS_NOTIFY: 1971 case UNINDEX_STATE_FS_NOTIFY:
2050 uc->state = UNINDEX_STATE_HASHING; 1972 uc->state = UNINDEX_STATE_HASHING;
@@ -2073,8 +1995,8 @@ cleanup:
2073 if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) 1995 if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)))
2074 { 1996 {
2075 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1997 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2076 _("Failed to resume unindexing operation `%s': %s\n"), 1998 _("Failed to resume unindexing operation `%s': %s\n"), filename,
2077 filename, emsg); 1999 emsg);
2078 GNUNET_free (emsg); 2000 GNUNET_free (emsg);
2079 } 2001 }
2080 if (uc->serialization != NULL) 2002 if (uc->serialization != NULL)
@@ -2095,12 +2017,11 @@ cleanup:
2095 * @param search associated search 2017 * @param search associated search
2096 * @param serialization name under which the search was serialized 2018 * @param serialization name under which the search was serialized
2097 */ 2019 */
2098static void 2020static void deserialize_download (struct GNUNET_FS_Handle *h,
2099deserialize_download (struct GNUNET_FS_Handle *h, 2021 struct GNUNET_BIO_ReadHandle *rh,
2100 struct GNUNET_BIO_ReadHandle *rh, 2022 struct GNUNET_FS_DownloadContext *parent,
2101 struct GNUNET_FS_DownloadContext *parent, 2023 struct GNUNET_FS_SearchResult *search,
2102 struct GNUNET_FS_SearchResult *search, 2024 const char *serialization);
2103 const char *serialization);
2104 2025
2105 2026
2106/** 2027/**
@@ -2151,9 +2072,9 @@ deserialize_search_result (void *cls, const char *filename)
2151 if (ser != NULL) 2072 if (ser != NULL)
2152 { 2073 {
2153 remove_sync_file_in_dir (sc->h, 2074 remove_sync_file_in_dir (sc->h,
2154 (sc->psearch_result == NULL) 2075 (sc->psearch_result ==
2155 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 2076 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
2156 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 2077 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2157 sc->serialization, ser); 2078 sc->serialization, ser);
2158 GNUNET_free (ser); 2079 GNUNET_free (ser);
2159 } 2080 }
@@ -2165,15 +2086,12 @@ deserialize_search_result (void *cls, const char *filename)
2165 update_srch = NULL; 2086 update_srch = NULL;
2166 sr = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchResult)); 2087 sr = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchResult));
2167 sr->serialization = ser; 2088 sr->serialization = ser;
2168 if ((GNUNET_OK != 2089 if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024))
2169 GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024)) || 2090 || (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
2170 (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) || 2091 (GNUNET_OK != GNUNET_BIO_read_string (rh, "download-lnk", &download, 16))
2171 (GNUNET_OK != 2092 || (GNUNET_OK !=
2172 GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || 2093 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
2173 (GNUNET_OK != 2094 (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) ||
2174 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
2175 (GNUNET_OK !=
2176 GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) ||
2177 (GNUNET_OK != 2095 (GNUNET_OK !=
2178 GNUNET_BIO_read (rh, "result-key", &sr->key, sizeof (GNUNET_HashCode))) 2096 GNUNET_BIO_read (rh, "result-key", &sr->key, sizeof (GNUNET_HashCode)))
2179 || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) || 2097 || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) ||
@@ -2194,8 +2112,8 @@ deserialize_search_result (void *cls, const char *filename)
2194 if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) 2112 if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg))
2195 { 2113 {
2196 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2114 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2197 _("Failed to resume sub-download `%s': %s\n"), 2115 _("Failed to resume sub-download `%s': %s\n"), download,
2198 download, emsg); 2116 emsg);
2199 GNUNET_free (emsg); 2117 GNUNET_free (emsg);
2200 } 2118 }
2201 } 2119 }
@@ -2203,24 +2121,22 @@ deserialize_search_result (void *cls, const char *filename)
2203 } 2121 }
2204 if (update_srch != NULL) 2122 if (update_srch != NULL)
2205 { 2123 {
2206 drh = get_read_handle (sc->h, 2124 drh =
2207 GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch); 2125 get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch);
2208 if (drh != NULL) 2126 if (drh != NULL)
2209 { 2127 {
2210 deserialize_search (sc->h, drh, sr, update_srch); 2128 deserialize_search (sc->h, drh, sr, update_srch);
2211 if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) 2129 if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg))
2212 { 2130 {
2213 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2131 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2214 _("Failed to resume sub-search `%s': %s\n"), 2132 _("Failed to resume sub-search `%s': %s\n"), update_srch,
2215 update_srch, emsg); 2133 emsg);
2216 GNUNET_free (emsg); 2134 GNUNET_free (emsg);
2217 } 2135 }
2218 } 2136 }
2219 GNUNET_free (update_srch); 2137 GNUNET_free (update_srch);
2220 } 2138 }
2221 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, 2139 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &sr->key, sr,
2222 &sr->key,
2223 sr,
2224 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2140 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2225 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) 2141 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
2226 { 2142 {
@@ -2378,14 +2294,14 @@ free_search_context (struct GNUNET_FS_SearchContext *sc)
2378 if (sc->serialization != NULL) 2294 if (sc->serialization != NULL)
2379 { 2295 {
2380 GNUNET_FS_remove_sync_file_ (sc->h, 2296 GNUNET_FS_remove_sync_file_ (sc->h,
2381 (sc->psearch_result == NULL) 2297 (sc->psearch_result ==
2382 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 2298 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
2383 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 2299 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2384 sc->serialization); 2300 sc->serialization);
2385 GNUNET_FS_remove_sync_dir_ (sc->h, 2301 GNUNET_FS_remove_sync_dir_ (sc->h,
2386 (sc->psearch_result == NULL) 2302 (sc->psearch_result ==
2387 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 2303 NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
2388 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 2304 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2389 sc->serialization); 2305 sc->serialization);
2390 } 2306 }
2391 GNUNET_free_non_null (sc->serialization); 2307 GNUNET_free_non_null (sc->serialization);
@@ -2394,8 +2310,8 @@ free_search_context (struct GNUNET_FS_SearchContext *sc)
2394 GNUNET_FS_uri_destroy (sc->uri); 2310 GNUNET_FS_uri_destroy (sc->uri);
2395 if (sc->master_result_map != NULL) 2311 if (sc->master_result_map != NULL)
2396 { 2312 {
2397 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, 2313 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, &free_result,
2398 &free_result, sc); 2314 sc);
2399 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); 2315 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
2400 } 2316 }
2401 GNUNET_free (sc); 2317 GNUNET_free (sc);
@@ -2507,10 +2423,9 @@ deserialize_download (struct GNUNET_FS_Handle *h,
2507 (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || 2423 (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
2508 ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) && 2424 ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) &&
2509 (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) || 2425 (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) ||
2510 (GNUNET_OK != 2426 (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta))
2511 GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta)) || 2427 || (GNUNET_OK !=
2512 (GNUNET_OK != 2428 GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) ||
2513 GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) ||
2514 (GNUNET_OK != 2429 (GNUNET_OK !=
2515 GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) || 2430 GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) ||
2516 (GNUNET_OK != 2431 (GNUNET_OK !=
@@ -2565,8 +2480,8 @@ deserialize_download (struct GNUNET_FS_Handle *h,
2565 } 2480 }
2566 if ((parent == NULL) && (search == NULL)) 2481 if ((parent == NULL) && (search == NULL))
2567 { 2482 {
2568 dc->top = GNUNET_FS_make_top (dc->h, 2483 dc->top =
2569 &GNUNET_FS_download_signal_suspend_, dc); 2484 GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
2570 signal_download_resume (dc); 2485 signal_download_resume (dc);
2571 } 2486 }
2572 GNUNET_free (uris); 2487 GNUNET_free (uris);
@@ -2637,17 +2552,14 @@ deserialize_search (struct GNUNET_FS_Handle *h,
2637 } 2552 }
2638 sc->h = h; 2553 sc->h = h;
2639 sc->serialization = GNUNET_strdup (serialization); 2554 sc->serialization = GNUNET_strdup (serialization);
2640 if ((GNUNET_OK != 2555 if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "search-uri", &uris, 10 * 1024))
2641 GNUNET_BIO_read_string (rh, "search-uri", &uris, 10 * 1024)) || 2556 || (NULL == (sc->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
2642 (NULL == (sc->uri = GNUNET_FS_uri_parse (uris, &emsg))) ||
2643 ((GNUNET_YES != GNUNET_FS_uri_test_ksk (sc->uri)) && 2557 ((GNUNET_YES != GNUNET_FS_uri_test_ksk (sc->uri)) &&
2644 (GNUNET_YES != GNUNET_FS_uri_test_sks (sc->uri))) || 2558 (GNUNET_YES != GNUNET_FS_uri_test_sks (sc->uri))) ||
2645 (GNUNET_OK != 2559 (GNUNET_OK != read_start_time (rh, &sc->start_time)) ||
2646 read_start_time (rh, &sc->start_time)) ||
2647 (GNUNET_OK != 2560 (GNUNET_OK !=
2648 GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10 * 1024)) || 2561 GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10 * 1024)) ||
2649 (GNUNET_OK != 2562 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) ||
2650 GNUNET_BIO_read_int32 (rh, &options)) ||
2651 (GNUNET_OK != 2563 (GNUNET_OK !=
2652 GNUNET_BIO_read (rh, "search-pause", &in_pause, sizeof (in_pause))) || 2564 GNUNET_BIO_read (rh, "search-pause", &in_pause, sizeof (in_pause))) ||
2653 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sc->anonymity))) 2565 (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sc->anonymity)))
@@ -2658,9 +2570,10 @@ deserialize_search (struct GNUNET_FS_Handle *h,
2658 sc->options = (enum GNUNET_FS_SearchOptions) options; 2570 sc->options = (enum GNUNET_FS_SearchOptions) options;
2659 sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16); 2571 sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16);
2660 dn = get_serialization_file_name_in_dir (h, 2572 dn = get_serialization_file_name_in_dir (h,
2661 (sc->psearch_result == NULL) 2573 (sc->psearch_result ==
2662 ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH 2574 NULL) ?
2663 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 2575 GNUNET_FS_SYNC_PATH_MASTER_SEARCH :
2576 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2664 sc->serialization, ""); 2577 sc->serialization, "");
2665 if (dn != NULL) 2578 if (dn != NULL)
2666 { 2579 {
@@ -2775,8 +2688,7 @@ deserialize_download_file (void *cls, const char *filename)
2775 * @param h the 'struct GNUNET_FS_Handle*' 2688 * @param h the 'struct GNUNET_FS_Handle*'
2776 */ 2689 */
2777static void 2690static void
2778deserialization_master (const char *master_path, 2691deserialization_master (const char *master_path, GNUNET_FileNameCallback proc,
2779 GNUNET_FileNameCallback proc,
2780 struct GNUNET_FS_Handle *h) 2692 struct GNUNET_FS_Handle *h)
2781{ 2693{
2782 char *dn; 2694 char *dn;
@@ -2803,8 +2715,7 @@ deserialization_master (const char *master_path,
2803 */ 2715 */
2804struct GNUNET_FS_Handle * 2716struct GNUNET_FS_Handle *
2805GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 2717GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
2806 const char *client_name, 2718 const char *client_name, GNUNET_FS_ProgressCallback upcb,
2807 GNUNET_FS_ProgressCallback upcb,
2808 void *upcb_cls, enum GNUNET_FS_Flags flags, ...) 2719 void *upcb_cls, enum GNUNET_FS_Flags flags, ...)
2809{ 2720{
2810 struct GNUNET_FS_Handle *ret; 2721 struct GNUNET_FS_Handle *ret;
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c
index f22480d5f..61ed1586f 100644
--- a/src/fs/fs_directory.c
+++ b/src/fs/fs_directory.c
@@ -88,11 +88,9 @@ GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md)
88 GNUNET_free (mime); 88 GNUNET_free (mime);
89 return; 89 return;
90 } 90 }
91 GNUNET_CONTAINER_meta_data_insert (md, 91 GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>",
92 "<gnunet>",
93 EXTRACTOR_METATYPE_MIMETYPE, 92 EXTRACTOR_METATYPE_MIMETYPE,
94 EXTRACTOR_METAFORMAT_UTF8, 93 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
95 "text/plain",
96 GNUNET_FS_DIRECTORY_MIME, 94 GNUNET_FS_DIRECTORY_MIME,
97 strlen (GNUNET_FS_DIRECTORY_MIME) + 1); 95 strlen (GNUNET_FS_DIRECTORY_MIME) + 1);
98} 96}
@@ -134,10 +132,8 @@ struct GetFullDataClosure
134 * @return 0 to continue extracting, 1 to abort 132 * @return 0 to continue extracting, 1 to abort
135 */ 133 */
136static int 134static int
137find_full_data (void *cls, 135find_full_data (void *cls, const char *plugin_name,
138 const char *plugin_name, 136 enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
139 enum EXTRACTOR_MetaType type,
140 enum EXTRACTOR_MetaFormat format,
141 const char *data_mime_type, const char *data, size_t data_len) 137 const char *data_mime_type, const char *data, size_t data_len)
142{ 138{
143 struct GetFullDataClosure *gfdc = cls; 139 struct GetFullDataClosure *gfdc = cls;
@@ -182,8 +178,7 @@ find_full_data (void *cls,
182 * GNUNET_SYSERR if 'data' does not represent a directory 178 * GNUNET_SYSERR if 'data' does not represent a directory
183 */ 179 */
184int 180int
185GNUNET_FS_directory_list_contents (size_t size, 181GNUNET_FS_directory_list_contents (size_t size, const void *data,
186 const void *data,
187 uint64_t offset, 182 uint64_t offset,
188 GNUNET_FS_DirectoryEntryProcessor dep, 183 GNUNET_FS_DirectoryEntryProcessor dep,
189 void *dep_cls) 184 void *dep_cls)
@@ -219,8 +214,7 @@ GNUNET_FS_directory_list_contents (size_t size,
219 _("MAGIC mismatch. This is not a GNUnet directory.\n")); 214 _("MAGIC mismatch. This is not a GNUnet directory.\n"));
220 return GNUNET_SYSERR; 215 return GNUNET_SYSERR;
221 } 216 }
222 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + 217 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof (uint32_t)],
223 sizeof (uint32_t)],
224 mdSize); 218 mdSize);
225 if (md == NULL) 219 if (md == NULL)
226 { 220 {
@@ -289,8 +283,9 @@ GNUNET_FS_directory_list_contents (size_t size,
289 return GNUNET_NO; /* malformed ! */ 283 return GNUNET_NO; /* malformed ! */
290 } 284 }
291 pos += mdSize; 285 pos += mdSize;
292 filename = GNUNET_CONTAINER_meta_data_get_by_type (md, 286 filename =
293 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 287 GNUNET_CONTAINER_meta_data_get_by_type (md,
288 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
294 full_data.size = 0; 289 full_data.size = 0;
295 full_data.data = NULL; 290 full_data.data = NULL;
296 GNUNET_CONTAINER_meta_data_iterate (md, &find_full_data, &full_data); 291 GNUNET_CONTAINER_meta_data_iterate (md, &find_full_data, &full_data);
@@ -425,11 +420,10 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
425 if (fsize > 0) 420 if (fsize > 0)
426 { 421 {
427 meta = GNUNET_CONTAINER_meta_data_duplicate (md); 422 meta = GNUNET_CONTAINER_meta_data_duplicate (md);
428 GNUNET_CONTAINER_meta_data_insert (meta, 423 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
429 "<gnunet>",
430 EXTRACTOR_METATYPE_GNUNET_FULL_DATA, 424 EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
431 EXTRACTOR_METAFORMAT_BINARY, 425 EXTRACTOR_METAFORMAT_BINARY, NULL, data,
432 NULL, data, fsize); 426 fsize);
433 mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 427 mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
434 if ((slen + sizeof (uint32_t) + mdxs - 1) / DBLOCK_SIZE == 428 if ((slen + sizeof (uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
435 (slen + sizeof (uint32_t) + mds - 1) / DBLOCK_SIZE) 429 (slen + sizeof (uint32_t) + mds - 1) / DBLOCK_SIZE)
@@ -443,16 +437,15 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
443 437
444 if (mds > GNUNET_MAX_MALLOC_CHECKED / 2) 438 if (mds > GNUNET_MAX_MALLOC_CHECKED / 2)
445 mds = GNUNET_MAX_MALLOC_CHECKED / 2; 439 mds = GNUNET_MAX_MALLOC_CHECKED / 2;
446 e = GNUNET_malloc (sizeof (struct BuilderEntry) + 440 e = GNUNET_malloc (sizeof (struct BuilderEntry) + slen + mds +
447 slen + mds + sizeof (uint32_t)); 441 sizeof (uint32_t));
448 ser = (char *) &e[1]; 442 ser = (char *) &e[1];
449 memcpy (ser, uris, slen); 443 memcpy (ser, uris, slen);
450 GNUNET_free (uris); 444 GNUNET_free (uris);
451 sptr = &ser[slen + sizeof (uint32_t)]; 445 sptr = &ser[slen + sizeof (uint32_t)];
452 ret = GNUNET_CONTAINER_meta_data_serialize (meta_use, 446 ret =
453 &sptr, 447 GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds,
454 mds, 448 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
455 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
456 if (NULL != meta) 449 if (NULL != meta)
457 GNUNET_CONTAINER_meta_data_destroy (meta); 450 GNUNET_CONTAINER_meta_data_destroy (meta);
458 if (ret == -1) 451 if (ret == -1)
@@ -495,8 +488,8 @@ do_align (size_t start_position, size_t end_position)
495 * @param perm the permutation of the blocks (updated) 488 * @param perm the permutation of the blocks (updated)
496 */ 489 */
497static void 490static void
498block_align (size_t start, 491block_align (size_t start, unsigned int count, const size_t * sizes,
499 unsigned int count, const size_t * sizes, unsigned int *perm) 492 unsigned int *perm)
500{ 493{
501 unsigned int i; 494 unsigned int i;
502 unsigned int j; 495 unsigned int j;
@@ -625,10 +618,10 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
625 off = strlen (GNUNET_DIRECTORY_MAGIC); 618 off = strlen (GNUNET_DIRECTORY_MAGIC);
626 619
627 sptr = &data[off + sizeof (uint32_t)]; 620 sptr = &data[off + sizeof (uint32_t)];
628 ret = GNUNET_CONTAINER_meta_data_serialize (bld->meta, 621 ret =
629 &sptr, 622 GNUNET_CONTAINER_meta_data_serialize (bld->meta, &sptr,
630 size - off - sizeof (uint32_t), 623 size - off - sizeof (uint32_t),
631 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 624 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
632 GNUNET_assert (ret != -1); 625 GNUNET_assert (ret != -1);
633 big = htonl (ret); 626 big = htonl (ret);
634 memcpy (&data[off], &big, sizeof (uint32_t)); 627 memcpy (&data[off], &big, sizeof (uint32_t));
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 6b72b4e56..a3c5b9b62 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -111,19 +111,19 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
111{ 111{
112 pi->value.download.dc = dc; 112 pi->value.download.dc = dc;
113 pi->value.download.cctx = dc->client_info; 113 pi->value.download.cctx = dc->client_info;
114 pi->value.download.pctx 114 pi->value.download.pctx =
115 = (dc->parent == NULL) ? NULL : dc->parent->client_info; 115 (dc->parent == NULL) ? NULL : dc->parent->client_info;
116 pi->value.download.sctx 116 pi->value.download.sctx =
117 = (dc->search == NULL) ? NULL : dc->search->client_info; 117 (dc->search == NULL) ? NULL : dc->search->client_info;
118 pi->value.download.uri = dc->uri; 118 pi->value.download.uri = dc->uri;
119 pi->value.download.filename = dc->filename; 119 pi->value.download.filename = dc->filename;
120 pi->value.download.size = dc->length; 120 pi->value.download.size = dc->length;
121 pi->value.download.duration 121 pi->value.download.duration =
122 = GNUNET_TIME_absolute_get_duration (dc->start_time); 122 GNUNET_TIME_absolute_get_duration (dc->start_time);
123 pi->value.download.completed = dc->completed; 123 pi->value.download.completed = dc->completed;
124 pi->value.download.anonymity = dc->anonymity; 124 pi->value.download.anonymity = dc->anonymity;
125 pi->value.download.eta 125 pi->value.download.eta =
126 = GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length); 126 GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length);
127 pi->value.download.is_active = (dc->client == NULL) ? GNUNET_NO : GNUNET_YES; 127 pi->value.download.is_active = (dc->client == NULL) ? GNUNET_NO : GNUNET_YES;
128 if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE)) 128 if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
129 dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi); 129 dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi);
@@ -194,9 +194,8 @@ struct ProcessResultClosure
194 * @param value value in the hash map (a 'struct DownloadRequest') 194 * @param value value in the hash map (a 'struct DownloadRequest')
195 * @return GNUNET_YES (we should continue to iterate); unless serious error 195 * @return GNUNET_YES (we should continue to iterate); unless serious error
196 */ 196 */
197static int 197static int process_result_with_request (void *cls, const GNUNET_HashCode * key,
198process_result_with_request (void *cls, 198 void *value);
199 const GNUNET_HashCode * key, void *value);
200 199
201 200
202/** 201/**
@@ -215,8 +214,8 @@ process_result_with_request (void *cls,
215static int 214static int
216encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc, 215encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
217 const struct ContentHashKey *chk, 216 const struct ContentHashKey *chk,
218 struct DownloadRequest *dr, 217 struct DownloadRequest *dr, const char *block,
219 const char *block, size_t len, int do_store) 218 size_t len, int do_store)
220{ 219{
221 struct ProcessResultClosure prc; 220 struct ProcessResultClosure prc;
222 char enc[len]; 221 char enc[len];
@@ -245,8 +244,9 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
245 prc.dc = dc; 244 prc.dc = dc;
246 prc.data = enc; 245 prc.data = enc;
247 prc.size = len; 246 prc.size = len;
248 prc.type = (0 == dr->depth) 247 prc.type =
249 ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; 248 (0 ==
249 dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK;
250 prc.query = chk->query; 250 prc.query = chk->query;
251 prc.do_store = do_store; 251 prc.do_store = do_store;
252 process_result_with_request (&prc, &chk->key, dr); 252 process_result_with_request (&prc, &chk->key, dr);
@@ -275,12 +275,10 @@ static void try_reconnect (struct GNUNET_FS_DownloadContext *dc);
275 * @param length number of bytes in data 275 * @param length number of bytes in data
276 * @param data contents of the file (or NULL if they were not inlined) 276 * @param data contents of the file (or NULL if they were not inlined)
277 */ 277 */
278static void 278static void trigger_recursive_download (void *cls, const char *filename,
279trigger_recursive_download (void *cls, 279 const struct GNUNET_FS_Uri *uri,
280 const char *filename, 280 const struct GNUNET_CONTAINER_MetaData
281 const struct GNUNET_FS_Uri *uri, 281 *meta, size_t length, const void *data);
282 const struct GNUNET_CONTAINER_MetaData *meta,
283 size_t length, const void *data);
284 282
285 283
286/** 284/**
@@ -309,14 +307,14 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
309 } 307 }
310 if (dc->filename != NULL) 308 if (dc->filename != NULL)
311 { 309 {
312 h = GNUNET_DISK_file_open (dc->filename, 310 h = GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ,
313 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 311 GNUNET_DISK_PERM_NONE);
314 } 312 }
315 else 313 else
316 { 314 {
317 GNUNET_assert (dc->temp_filename != NULL); 315 GNUNET_assert (dc->temp_filename != NULL);
318 h = GNUNET_DISK_file_open (dc->temp_filename, 316 h = GNUNET_DISK_file_open (dc->temp_filename, GNUNET_DISK_OPEN_READ,
319 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 317 GNUNET_DISK_PERM_NONE);
320 } 318 }
321 if (h == NULL) 319 if (h == NULL)
322 return; /* oops */ 320 return; /* oops */
@@ -328,17 +326,16 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
328 } 326 }
329 else 327 else
330 { 328 {
331 GNUNET_FS_directory_list_contents (size, 329 GNUNET_FS_directory_list_contents (size, data, 0,
332 data, 330 &trigger_recursive_download, dc);
333 0, &trigger_recursive_download, dc);
334 GNUNET_DISK_file_unmap (m); 331 GNUNET_DISK_file_unmap (m);
335 } 332 }
336 GNUNET_DISK_file_close (h); 333 GNUNET_DISK_file_close (h);
337 if (dc->filename == NULL) 334 if (dc->filename == NULL)
338 { 335 {
339 if (0 != UNLINK (dc->temp_filename)) 336 if (0 != UNLINK (dc->temp_filename))
340 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 337 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
341 "unlink", dc->temp_filename); 338 dc->temp_filename);
342 GNUNET_free (dc->temp_filename); 339 GNUNET_free (dc->temp_filename);
343 dc->temp_filename = NULL; 340 dc->temp_filename = NULL;
344 } 341 }
@@ -483,8 +480,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
483 if (fh == NULL) 480 if (fh == NULL)
484 { 481 {
485 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn); 482 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
486 GNUNET_asprintf (&dc->emsg, 483 GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
487 _("Failed to open file `%s' for writing"), fn); 484 fn);
488 GNUNET_DISK_file_close (fh); 485 GNUNET_DISK_file_close (fh);
489 dr->state = BRS_ERROR; 486 dr->state = BRS_ERROR;
490 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; 487 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
@@ -495,8 +492,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
495 if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len)) 492 if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len))
496 { 493 {
497 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn); 494 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
498 GNUNET_asprintf (&dc->emsg, 495 GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
499 _("Failed to open file `%s' for writing"), fn); 496 fn);
500 GNUNET_DISK_file_close (fh); 497 GNUNET_DISK_file_close (fh);
501 dr->state = BRS_ERROR; 498 dr->state = BRS_ERROR;
502 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; 499 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
@@ -516,10 +513,11 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
516 pi.value.download.specifics.progress.depth = 0; 513 pi.value.download.specifics.progress.depth = 0;
517 GNUNET_FS_download_make_status_ (&pi, dc); 514 GNUNET_FS_download_make_status_ (&pi, dc);
518 if ((NULL != dc->filename) && 515 if ((NULL != dc->filename) &&
519 (0 != truncate (dc->filename, 516 (0 !=
520 GNUNET_ntohll (dc->uri->data.chk.file_length)))) 517 truncate (dc->filename,
521 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 518 GNUNET_ntohll (dc->uri->data.chk.file_length))))
522 "truncate", dc->filename); 519 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
520 dc->filename);
523 check_completed (dc); 521 check_completed (dc);
524 break; 522 break;
525 default: 523 default:
@@ -549,10 +547,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
549 * @return 0 to continue extracting, 1 to abort 547 * @return 0 to continue extracting, 1 to abort
550 */ 548 */
551static int 549static int
552match_full_data (void *cls, 550match_full_data (void *cls, const char *plugin_name,
553 const char *plugin_name, 551 enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
554 enum EXTRACTOR_MetaType type,
555 enum EXTRACTOR_MetaFormat format,
556 const char *data_mime_type, const char *data, size_t data_len) 552 const char *data_mime_type, const char *data, size_t data_len)
557{ 553{
558 struct GNUNET_FS_DownloadContext *dc = cls; 554 struct GNUNET_FS_DownloadContext *dc = cls;
@@ -560,8 +556,8 @@ match_full_data (void *cls,
560 if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA) 556 if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
561 return 0; 557 return 0;
562#if DEBUG_DOWNLOAD 558#if DEBUG_DOWNLOAD
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u bytes of FD!\n",
564 "Found %u bytes of FD!\n", (unsigned int) data_len); 560 (unsigned int) data_len);
565#endif 561#endif
566 if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len) 562 if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len)
567 { 563 {
@@ -729,28 +725,26 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
729#if DEBUG_DOWNLOAD 725#if DEBUG_DOWNLOAD
730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Scheduling download at offset %llu and depth %u for `%s'\n", 727 "Scheduling download at offset %llu and depth %u for `%s'\n",
732 (unsigned long long) dr->offset, 728 (unsigned long long) dr->offset, dr->depth,
733 dr->depth, GNUNET_h2s (&dr->chk.query)); 729 GNUNET_h2s (&dr->chk.query));
734#endif 730#endif
735 if (GNUNET_NO != 731 if (GNUNET_NO !=
736 GNUNET_CONTAINER_multihashmap_contains_value (dc->active, 732 GNUNET_CONTAINER_multihashmap_contains_value (dc->active, &dr->chk.query,
737 &dr->chk.query, dr)) 733 dr))
738 return; /* already active */ 734 return; /* already active */
739 GNUNET_CONTAINER_multihashmap_put (dc->active, 735 GNUNET_CONTAINER_multihashmap_put (dc->active, &dr->chk.query, dr,
740 &dr->chk.query,
741 dr,
742 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 736 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
743 if (dc->client == NULL) 737 if (dc->client == NULL)
744 return; /* download not active */ 738 return; /* download not active */
745 GNUNET_CONTAINER_DLL_insert (dc->pending_head, dc->pending_tail, dr); 739 GNUNET_CONTAINER_DLL_insert (dc->pending_head, dc->pending_tail, dr);
746 dr->is_pending = GNUNET_YES; 740 dr->is_pending = GNUNET_YES;
747 if (NULL == dc->th) 741 if (NULL == dc->th)
748 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 742 dc->th =
749 sizeof (struct SearchMessage), 743 GNUNET_CLIENT_notify_transmit_ready (dc->client,
750 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 744 sizeof (struct SearchMessage),
751 GNUNET_NO, 745 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
752 &transmit_download_request, 746 GNUNET_NO,
753 dc); 747 &transmit_download_request, dc);
754} 748}
755 749
756 750
@@ -768,8 +762,7 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
768 * @param data contents of the file (or NULL if they were not inlined) 762 * @param data contents of the file (or NULL if they were not inlined)
769 */ 763 */
770static void 764static void
771trigger_recursive_download (void *cls, 765trigger_recursive_download (void *cls, const char *filename,
772 const char *filename,
773 const struct GNUNET_FS_Uri *uri, 766 const struct GNUNET_FS_Uri *uri,
774 const struct GNUNET_CONTAINER_MetaData *meta, 767 const struct GNUNET_CONTAINER_MetaData *meta,
775 size_t length, const void *data) 768 size_t length, const void *data)
@@ -790,8 +783,7 @@ trigger_recursive_download (void *cls,
790 cpos = dc->child_head; 783 cpos = dc->child_head;
791 while (cpos != NULL) 784 while (cpos != NULL)
792 { 785 {
793 if ((GNUNET_FS_uri_test_equal (uri, 786 if ((GNUNET_FS_uri_test_equal (uri, cpos->uri)) ||
794 cpos->uri)) ||
795 ((filename != NULL) && (0 == strcmp (cpos->filename, filename)))) 787 ((filename != NULL) && (0 == strcmp (cpos->filename, filename))))
796 break; 788 break;
797 cpos = cpos->next; 789 cpos = cpos->next;
@@ -812,8 +804,8 @@ trigger_recursive_download (void *cls,
812 { 804 {
813 ext = fn; 805 ext = fn;
814 us = GNUNET_FS_uri_to_string (uri); 806 us = GNUNET_FS_uri_to_string (uri);
815 GNUNET_asprintf (&fn, 807 GNUNET_asprintf (&fn, "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)],
816 "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)], ext); 808 ext);
817 GNUNET_free (ext); 809 GNUNET_free (ext);
818 GNUNET_free (us); 810 GNUNET_free (us);
819 } 811 }
@@ -858,9 +850,8 @@ trigger_recursive_download (void *cls,
858 strstr (filename + strlen (filename) - 850 strstr (filename + strlen (filename) -
859 strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT)))) 851 strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT))))
860 { 852 {
861 GNUNET_asprintf (&full_name, 853 GNUNET_asprintf (&full_name, "%s%s%s%s", dn, DIR_SEPARATOR_STR, sfn,
862 "%s%s%s%s", 854 GNUNET_FS_DIRECTORY_EXT);
863 dn, DIR_SEPARATOR_STR, sfn, GNUNET_FS_DIRECTORY_EXT);
864 } 855 }
865 else 856 else
866 { 857 {
@@ -889,11 +880,7 @@ trigger_recursive_download (void *cls,
889 (unsigned int) 880 (unsigned int)
890 GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); 881 GNUNET_CONTAINER_meta_data_get_serialized_size (meta));
891#endif 882#endif
892 GNUNET_FS_download_start (dc->h, 883 GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0,
893 uri,
894 meta,
895 full_name, temp_name,
896 0,
897 GNUNET_FS_uri_chk_get_file_size (uri), 884 GNUNET_FS_uri_chk_get_file_size (uri),
898 dc->anonymity, dc->options, NULL, dc); 885 dc->anonymity, dc->options, NULL, dc);
899 GNUNET_free_non_null (full_name); 886 GNUNET_free_non_null (full_name);
@@ -931,8 +918,8 @@ GNUNET_FS_free_download_request_ (struct DownloadRequest *dr)
931 * @return GNUNET_YES (we should continue to iterate); unless serious error 918 * @return GNUNET_YES (we should continue to iterate); unless serious error
932 */ 919 */
933static int 920static int
934process_result_with_request (void *cls, 921process_result_with_request (void *cls, const GNUNET_HashCode * key,
935 const GNUNET_HashCode * key, void *value) 922 void *value)
936{ 923{
937 struct ProcessResultClosure *prc = cls; 924 struct ProcessResultClosure *prc = cls;
938 struct DownloadRequest *dr = value; 925 struct DownloadRequest *dr = value;
@@ -952,11 +939,9 @@ process_result_with_request (void *cls,
952#if DEBUG_DOWNLOAD 939#if DEBUG_DOWNLOAD
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 940 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
954 "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n", 941 "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n",
955 GNUNET_h2s (key), 942 GNUNET_h2s (key), dr->depth, (unsigned long long) dr->offset,
956 dr->depth, 943 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
957 (unsigned long long) dr->offset, 944 file_length));
958 (unsigned long long) GNUNET_ntohll (dc->uri->data.
959 chk.file_length));
960 945
961#endif 946#endif
962 bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll 947 bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll
@@ -968,8 +953,8 @@ process_result_with_request (void *cls,
968 _ 953 _
969 ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)\n"), 954 ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)\n"),
970 bs, dr->depth, (unsigned long long) dr->offset, 955 bs, dr->depth, (unsigned long long) dr->offset,
971 (unsigned long long) GNUNET_ntohll (dc->uri->data. 956 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
972 chk.file_length), 957 file_length),
973 prc->size); 958 prc->size);
974 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s", dc->emsg); 959 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s", dc->emsg);
975 while (dr->parent != NULL) 960 while (dr->parent != NULL)
@@ -996,18 +981,17 @@ process_result_with_request (void *cls,
996 dc->emsg = GNUNET_strdup (_("internal error decrypting content")); 981 dc->emsg = GNUNET_strdup (_("internal error decrypting content"));
997 goto signal_error; 982 goto signal_error;
998 } 983 }
999 off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length), 984 off =
1000 dr->offset, dr->depth); 985 compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length),
986 dr->offset, dr->depth);
1001 /* save to disk */ 987 /* save to disk */
1002 if ((GNUNET_YES == prc->do_store) && 988 if ((GNUNET_YES == prc->do_store) &&
1003 ((dc->filename != NULL) || 989 ((dc->filename != NULL) || (is_recursive_download (dc))) &&
1004 (is_recursive_download (dc))) &&
1005 ((dr->depth == dc->treedepth) || 990 ((dr->depth == dc->treedepth) ||
1006 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES)))) 991 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES))))
1007 { 992 {
1008 fh = GNUNET_DISK_file_open (dc->filename != NULL 993 fh = GNUNET_DISK_file_open (dc->filename !=
1009 ? dc->filename 994 NULL ? dc->filename : dc->temp_filename,
1010 : dc->temp_filename,
1011 GNUNET_DISK_OPEN_READWRITE | 995 GNUNET_DISK_OPEN_READWRITE |
1012 GNUNET_DISK_OPEN_CREATE, 996 GNUNET_DISK_OPEN_CREATE,
1013 GNUNET_DISK_PERM_USER_READ | 997 GNUNET_DISK_PERM_USER_READ |
@@ -1030,8 +1014,8 @@ process_result_with_request (void *cls,
1030 { 1014 {
1031 GNUNET_asprintf (&dc->emsg, 1015 GNUNET_asprintf (&dc->emsg,
1032 _("Failed to seek to offset %llu in file `%s': %s\n"), 1016 _("Failed to seek to offset %llu in file `%s': %s\n"),
1033 (unsigned long long) off, 1017 (unsigned long long) off, dc->filename,
1034 dc->filename, STRERROR (errno)); 1018 STRERROR (errno));
1035 goto signal_error; 1019 goto signal_error;
1036 } 1020 }
1037 if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size)) 1021 if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size))
@@ -1072,9 +1056,8 @@ process_result_with_request (void *cls,
1072 * says it is a directory or if no meta data is given AND filename 1056 * says it is a directory or if no meta data is given AND filename
1073 * ends in '.gnd' (top-level case) */ 1057 * ends in '.gnd' (top-level case) */
1074 if (is_recursive_download (dc)) 1058 if (is_recursive_download (dc))
1075 GNUNET_FS_directory_list_contents (prc->size, 1059 GNUNET_FS_directory_list_contents (prc->size, pt, off,
1076 pt, 1060 &trigger_recursive_download, dc);
1077 off, &trigger_recursive_download, dc);
1078 1061
1079 } 1062 }
1080 dr->state = BRS_DOWNLOAD_DOWN; 1063 dr->state = BRS_DOWNLOAD_DOWN;
@@ -1094,16 +1077,17 @@ process_result_with_request (void *cls,
1094#if DEBUG_DOWNLOAD 1077#if DEBUG_DOWNLOAD
1095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1096 "Download completed, truncating file to desired length %llu\n", 1079 "Download completed, truncating file to desired length %llu\n",
1097 (unsigned long long) GNUNET_ntohll (dc->uri->data. 1080 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
1098 chk.file_length)); 1081 file_length));
1099#endif 1082#endif
1100 /* truncate file to size (since we store IBlocks at the end) */ 1083 /* truncate file to size (since we store IBlocks at the end) */
1101 if (dc->filename != NULL) 1084 if (dc->filename != NULL)
1102 { 1085 {
1103 if (0 != truncate (dc->filename, 1086 if (0 !=
1104 GNUNET_ntohll (dc->uri->data.chk.file_length))) 1087 truncate (dc->filename,
1105 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1088 GNUNET_ntohll (dc->uri->data.chk.file_length)))
1106 "truncate", dc->filename); 1089 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
1090 dc->filename);
1107 } 1091 }
1108 GNUNET_assert (dr->depth == 0); 1092 GNUNET_assert (dr->depth == 0);
1109 check_completed (dc); 1093 check_completed (dc);
@@ -1212,8 +1196,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc,
1212 "Received result for query `%s' from `%s'-service\n", 1196 "Received result for query `%s' from `%s'-service\n",
1213 GNUNET_h2s (&prc.query), "FS"); 1197 GNUNET_h2s (&prc.query), "FS");
1214#endif 1198#endif
1215 GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, 1199 GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, &prc.query,
1216 &prc.query,
1217 &process_result_with_request, 1200 &process_result_with_request,
1218 &prc); 1201 &prc);
1219} 1202}
@@ -1233,8 +1216,7 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
1233 const struct PutMessage *cm; 1216 const struct PutMessage *cm;
1234 uint16_t msize; 1217 uint16_t msize;
1235 1218
1236 if ((NULL == msg) || 1219 if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
1237 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
1238 (sizeof (struct PutMessage) > ntohs (msg->size))) 1220 (sizeof (struct PutMessage) > ntohs (msg->size)))
1239 { 1221 {
1240 GNUNET_break (msg == NULL); 1222 GNUNET_break (msg == NULL);
@@ -1243,13 +1225,13 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
1243 } 1225 }
1244 msize = ntohs (msg->size); 1226 msize = ntohs (msg->size);
1245 cm = (const struct PutMessage *) msg; 1227 cm = (const struct PutMessage *) msg;
1246 process_result (dc, 1228 process_result (dc, ntohl (cm->type), &cm[1],
1247 ntohl (cm->type), &cm[1], msize - sizeof (struct PutMessage)); 1229 msize - sizeof (struct PutMessage));
1248 if (dc->client == NULL) 1230 if (dc->client == NULL)
1249 return; /* fatal error */ 1231 return; /* fatal error */
1250 /* continue receiving */ 1232 /* continue receiving */
1251 GNUNET_CLIENT_receive (dc->client, 1233 GNUNET_CLIENT_receive (dc->client, &receive_results, dc,
1252 &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); 1234 GNUNET_TIME_UNIT_FOREVER_REL);
1253} 1235}
1254 1236
1255 1237
@@ -1315,19 +1297,19 @@ transmit_download_request (void *cls, size_t size, void *buf)
1315 } 1297 }
1316 if (dc->pending_head != NULL) 1298 if (dc->pending_head != NULL)
1317 { 1299 {
1318 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 1300 dc->th =
1319 sizeof (struct SearchMessage), 1301 GNUNET_CLIENT_notify_transmit_ready (dc->client,
1320 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1302 sizeof (struct SearchMessage),
1321 GNUNET_NO, 1303 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1322 &transmit_download_request, 1304 GNUNET_NO,
1323 dc); 1305 &transmit_download_request, dc);
1324 GNUNET_assert (dc->th != NULL); 1306 GNUNET_assert (dc->th != NULL);
1325 } 1307 }
1326 if (GNUNET_NO == dc->in_receive) 1308 if (GNUNET_NO == dc->in_receive)
1327 { 1309 {
1328 dc->in_receive = GNUNET_YES; 1310 dc->in_receive = GNUNET_YES;
1329 GNUNET_CLIENT_receive (dc->client, 1311 GNUNET_CLIENT_receive (dc->client, &receive_results, dc,
1330 &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); 1312 GNUNET_TIME_UNIT_FOREVER_REL);
1331 } 1313 }
1332 return msize; 1314 return msize;
1333} 1315}
@@ -1357,12 +1339,12 @@ do_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1357 dc->client = client; 1339 dc->client = client;
1358 if (dc->pending_head != NULL) 1340 if (dc->pending_head != NULL)
1359 { 1341 {
1360 dc->th = GNUNET_CLIENT_notify_transmit_ready (client, 1342 dc->th =
1361 sizeof (struct SearchMessage), 1343 GNUNET_CLIENT_notify_transmit_ready (client,
1362 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1344 sizeof (struct SearchMessage),
1363 GNUNET_NO, 1345 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1364 &transmit_download_request, 1346 GNUNET_NO,
1365 dc); 1347 &transmit_download_request, dc);
1366 GNUNET_assert (dc->th != NULL); 1348 GNUNET_assert (dc->th != NULL);
1367 } 1349 }
1368} 1350}
@@ -1423,9 +1405,9 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
1423#if DEBUG_DOWNLOAD 1405#if DEBUG_DOWNLOAD
1424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n"); 1406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n");
1425#endif 1407#endif
1426 dc->task 1408 dc->task =
1427 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 1409 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
1428 &do_reconnect, dc); 1410 dc);
1429} 1411}
1430 1412
1431 1413
@@ -1459,12 +1441,12 @@ activate_fs_download (void *cls, struct GNUNET_CLIENT_Connection *client)
1459#endif 1441#endif
1460 if (dc->pending_head != NULL) 1442 if (dc->pending_head != NULL)
1461 { 1443 {
1462 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 1444 dc->th =
1463 sizeof (struct SearchMessage), 1445 GNUNET_CLIENT_notify_transmit_ready (dc->client,
1464 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1446 sizeof (struct SearchMessage),
1465 GNUNET_NO, 1447 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1466 &transmit_download_request, 1448 GNUNET_NO,
1467 dc); 1449 &transmit_download_request, dc);
1468 GNUNET_assert (dc->th != NULL); 1450 GNUNET_assert (dc->th != NULL);
1469 } 1451 }
1470} 1452}
@@ -1521,10 +1503,9 @@ deactivate_fs_download (void *cls)
1521 * the specified depth 1503 * the specified depth
1522 */ 1504 */
1523static struct DownloadRequest * 1505static struct DownloadRequest *
1524create_download_request (struct DownloadRequest *parent, 1506create_download_request (struct DownloadRequest *parent, unsigned int depth,
1525 unsigned int depth, 1507 uint64_t dr_offset, uint64_t file_start_offset,
1526 uint64_t dr_offset, 1508 uint64_t desired_length)
1527 uint64_t file_start_offset, uint64_t desired_length)
1528{ 1509{
1529 struct DownloadRequest *dr; 1510 struct DownloadRequest *dr;
1530 unsigned int i; 1511 unsigned int i;
@@ -1561,15 +1542,13 @@ create_download_request (struct DownloadRequest *parent,
1561 /* why else would we have gotten here to begin with? (that'd be a bad logic error) */ 1542 /* why else would we have gotten here to begin with? (that'd be a bad logic error) */
1562 GNUNET_assert (dr->num_children > 0); 1543 GNUNET_assert (dr->num_children > 0);
1563 1544
1564 dr->children = GNUNET_malloc (dr->num_children * 1545 dr->children =
1565 sizeof (struct DownloadRequest *)); 1546 GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *));
1566 for (i = 0; i < dr->num_children; i++) 1547 for (i = 0; i < dr->num_children; i++)
1567 dr->children[i] = create_download_request (dr, 1548 dr->children[i] =
1568 depth - 1, 1549 create_download_request (dr, depth - 1,
1569 dr_offset + 1550 dr_offset + i * child_block_size,
1570 i * child_block_size, 1551 file_start_offset, desired_length);
1571 file_start_offset,
1572 desired_length);
1573 } 1552 }
1574 return dr; 1553 return dr;
1575} 1554}
@@ -1643,11 +1622,8 @@ get_next_block (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1643 * @param block_size size of block (in bytes) 1622 * @param block_size size of block (in bytes)
1644 */ 1623 */
1645static void 1624static void
1646reconstruct_cb (void *cls, 1625reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
1647 const struct ContentHashKey *chk, 1626 unsigned int depth, enum GNUNET_BLOCK_Type type,
1648 uint64_t offset,
1649 unsigned int depth,
1650 enum GNUNET_BLOCK_Type type,
1651 const void *block, uint16_t block_size) 1627 const void *block, uint16_t block_size)
1652{ 1628{
1653 struct GNUNET_FS_DownloadContext *dc = cls; 1629 struct GNUNET_FS_DownloadContext *dc = cls;
@@ -1781,7 +1757,8 @@ GNUNET_FS_download_start_task_ (void *cls,
1781 GNUNET_DISK_OPEN_READWRITE | 1757 GNUNET_DISK_OPEN_READWRITE |
1782 GNUNET_DISK_OPEN_CREATE | 1758 GNUNET_DISK_OPEN_CREATE |
1783 ((0 == 1759 ((0 ==
1784 GNUNET_FS_uri_chk_get_file_size (dc->uri)) ? 1760 GNUNET_FS_uri_chk_get_file_size (dc->
1761 uri)) ?
1785 GNUNET_DISK_OPEN_TRUNCATE : 0), 1762 GNUNET_DISK_OPEN_TRUNCATE : 0),
1786 GNUNET_DISK_PERM_USER_READ | 1763 GNUNET_DISK_PERM_USER_READ |
1787 GNUNET_DISK_PERM_USER_WRITE | 1764 GNUNET_DISK_PERM_USER_WRITE |
@@ -1797,11 +1774,13 @@ GNUNET_FS_download_start_task_ (void *cls,
1797 return; 1774 return;
1798 if (dc->top_request == NULL) 1775 if (dc->top_request == NULL)
1799 { 1776 {
1800 dc->top_request = create_download_request (NULL, dc->treedepth - 1, 0, 1777 dc->top_request =
1801 dc->offset, dc->length); 1778 create_download_request (NULL, dc->treedepth - 1, 0, dc->offset,
1779 dc->length);
1802 dc->top_request->state = BRS_CHK_SET; 1780 dc->top_request->state = BRS_CHK_SET;
1803 dc->top_request->chk = (dc->uri->type == chk) 1781 dc->top_request->chk =
1804 ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk; 1782 (dc->uri->type ==
1783 chk) ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk;
1805 /* signal start */ 1784 /* signal start */
1806 GNUNET_FS_download_sync_ (dc); 1785 GNUNET_FS_download_sync_ (dc);
1807 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; 1786 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START;
@@ -1811,9 +1790,9 @@ GNUNET_FS_download_start_task_ (void *cls,
1811 GNUNET_FS_download_start_downloading_ (dc); 1790 GNUNET_FS_download_start_downloading_ (dc);
1812 /* attempt reconstruction from disk */ 1791 /* attempt reconstruction from disk */
1813 if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename)) 1792 if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename))
1814 dc->rfh = GNUNET_DISK_file_open (dc->filename, 1793 dc->rfh =
1815 GNUNET_DISK_OPEN_READ, 1794 GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ,
1816 GNUNET_DISK_PERM_NONE); 1795 GNUNET_DISK_PERM_NONE);
1817 if (dc->top_request->state == BRS_CHK_SET) 1796 if (dc->top_request->state == BRS_CHK_SET)
1818 { 1797 {
1819 if (dc->rfh != NULL) 1798 if (dc->rfh != NULL)
@@ -1884,12 +1863,10 @@ GNUNET_FS_download_start_task_ (void *cls,
1884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1885 "Trying bottom-up reconstruction of file `%s'\n", dc->filename); 1864 "Trying bottom-up reconstruction of file `%s'\n", dc->filename);
1886#endif 1865#endif
1887 dc->te = GNUNET_FS_tree_encoder_create (dc->h, 1866 dc->te =
1888 dc->old_file_size, 1867 GNUNET_FS_tree_encoder_create (dc->h, dc->old_file_size, dc, &fh_reader,
1889 dc, 1868 &reconstruct_cb, NULL,
1890 &fh_reader, 1869 &reconstruct_cont);
1891 &reconstruct_cb,
1892 NULL, &reconstruct_cont);
1893 dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc); 1870 dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
1894 } 1871 }
1895 else 1872 else
@@ -1929,8 +1906,8 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
1929 dc->job_queue = NULL; 1906 dc->job_queue = NULL;
1930 } 1907 }
1931 if (dc->parent != NULL) 1908 if (dc->parent != NULL)
1932 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, 1909 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail,
1933 dc->parent->child_tail, dc); 1910 dc);
1934 if (dc->task != GNUNET_SCHEDULER_NO_TASK) 1911 if (dc->task != GNUNET_SCHEDULER_NO_TASK)
1935 { 1912 {
1936 GNUNET_SCHEDULER_cancel (dc->task); 1913 GNUNET_SCHEDULER_cancel (dc->task);
@@ -1997,13 +1974,10 @@ struct GNUNET_FS_DownloadContext *
1997GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 1974GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
1998 const struct GNUNET_FS_Uri *uri, 1975 const struct GNUNET_FS_Uri *uri,
1999 const struct GNUNET_CONTAINER_MetaData *meta, 1976 const struct GNUNET_CONTAINER_MetaData *meta,
2000 const char *filename, 1977 const char *filename, const char *tempname,
2001 const char *tempname, 1978 uint64_t offset, uint64_t length, uint32_t anonymity,
2002 uint64_t offset, 1979 enum GNUNET_FS_DownloadOptions options, void *cctx,
2003 uint64_t length, 1980 struct GNUNET_FS_DownloadContext *parent)
2004 uint32_t anonymity,
2005 enum GNUNET_FS_DownloadOptions options,
2006 void *cctx, struct GNUNET_FS_DownloadContext *parent)
2007{ 1981{
2008 struct GNUNET_FS_DownloadContext *dc; 1982 struct GNUNET_FS_DownloadContext *dc;
2009 1983
@@ -2016,8 +1990,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2016 return NULL; 1990 return NULL;
2017 } 1991 }
2018#if DEBUG_DOWNLOAD 1992#if DEBUG_DOWNLOAD
2019 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
2020 "Starting download `%s' of %llu bytes\n",
2021 filename, (unsigned long long) length); 1994 filename, (unsigned long long) length);
2022#endif 1995#endif
2023 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); 1996 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
@@ -2057,13 +2030,13 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2057 } 2030 }
2058 2031
2059#if DEBUG_DOWNLOAD 2032#if DEBUG_DOWNLOAD
2060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
2061 "Download tree has depth %u\n", dc->treedepth); 2034 dc->treedepth);
2062#endif 2035#endif
2063 if (parent == NULL) 2036 if (parent == NULL)
2064 { 2037 {
2065 dc->top = GNUNET_FS_make_top (dc->h, 2038 dc->top =
2066 &GNUNET_FS_download_signal_suspend_, dc); 2039 GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
2067 } 2040 }
2068 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); 2041 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
2069 return dc; 2042 return dc;
@@ -2108,10 +2081,8 @@ struct GNUNET_FS_DownloadContext *
2108GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, 2081GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2109 struct GNUNET_FS_SearchResult *sr, 2082 struct GNUNET_FS_SearchResult *sr,
2110 const char *filename, 2083 const char *filename,
2111 const char *tempname, 2084 const char *tempname, uint64_t offset,
2112 uint64_t offset, 2085 uint64_t length, uint32_t anonymity,
2113 uint64_t length,
2114 uint32_t anonymity,
2115 enum GNUNET_FS_DownloadOptions options, 2086 enum GNUNET_FS_DownloadOptions options,
2116 void *cctx) 2087 void *cctx)
2117{ 2088{
@@ -2131,8 +2102,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2131 return NULL; 2102 return NULL;
2132 } 2103 }
2133#if DEBUG_DOWNLOAD 2104#if DEBUG_DOWNLOAD
2134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
2135 "Starting download `%s' of %llu bytes\n",
2136 filename, (unsigned long long) length); 2106 filename, (unsigned long long) length);
2137#endif 2107#endif
2138 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); 2108 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
@@ -2174,8 +2144,8 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2174 } 2144 }
2175 2145
2176#if DEBUG_DOWNLOAD 2146#if DEBUG_DOWNLOAD
2177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
2178 "Download tree has depth %u\n", dc->treedepth); 2148 dc->treedepth);
2179#endif 2149#endif
2180 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); 2150 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
2181 return dc; 2151 return dc;
@@ -2193,12 +2163,9 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
2193 if (dc->completed == dc->length) 2163 if (dc->completed == dc->length)
2194 return; 2164 return;
2195 GNUNET_assert (dc->job_queue == NULL); 2165 GNUNET_assert (dc->job_queue == NULL);
2196 dc->job_queue = GNUNET_FS_queue_ (dc->h, 2166 dc->job_queue =
2197 &activate_fs_download, 2167 GNUNET_FS_queue_ (dc->h, &activate_fs_download, &deactivate_fs_download,
2198 &deactivate_fs_download, 2168 dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE);
2199 dc,
2200 (dc->length + DBLOCK_SIZE -
2201 1) / DBLOCK_SIZE);
2202} 2169}
2203 2170
2204 2171
@@ -2242,19 +2209,20 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2242 while (NULL != dc->child_head) 2209 while (NULL != dc->child_head)
2243 GNUNET_FS_download_stop (dc->child_head, do_delete); 2210 GNUNET_FS_download_stop (dc->child_head, do_delete);
2244 if (dc->parent != NULL) 2211 if (dc->parent != NULL)
2245 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, 2212 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail,
2246 dc->parent->child_tail, dc); 2213 dc);
2247 if (dc->serialization != NULL) 2214 if (dc->serialization != NULL)
2248 GNUNET_FS_remove_sync_file_ (dc->h, 2215 GNUNET_FS_remove_sync_file_ (dc->h,
2249 ((dc->parent != NULL) || (dc->search != NULL)) 2216 ((dc->parent != NULL) ||
2250 ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD 2217 (dc->search !=
2251 : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 2218 NULL)) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
2219 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
2252 dc->serialization); 2220 dc->serialization);
2253 if ((GNUNET_YES == have_children) && (dc->parent == NULL)) 2221 if ((GNUNET_YES == have_children) && (dc->parent == NULL))
2254 GNUNET_FS_remove_sync_dir_ (dc->h, 2222 GNUNET_FS_remove_sync_dir_ (dc->h,
2255 (dc->search != NULL) 2223 (dc->search !=
2256 ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD 2224 NULL) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
2257 : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 2225 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
2258 dc->serialization); 2226 dc->serialization);
2259 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; 2227 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
2260 GNUNET_FS_download_make_status_ (&pi, dc); 2228 GNUNET_FS_download_make_status_ (&pi, dc);
@@ -2270,8 +2238,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2270 if ((dc->completed != dc->length) && (GNUNET_YES == do_delete)) 2238 if ((dc->completed != dc->length) && (GNUNET_YES == do_delete))
2271 { 2239 {
2272 if (0 != UNLINK (dc->filename)) 2240 if (0 != UNLINK (dc->filename))
2273 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 2241 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
2274 "unlink", dc->filename); 2242 dc->filename);
2275 } 2243 }
2276 GNUNET_free (dc->filename); 2244 GNUNET_free (dc->filename);
2277 } 2245 }
@@ -2280,8 +2248,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2280 if (NULL != dc->temp_filename) 2248 if (NULL != dc->temp_filename)
2281 { 2249 {
2282 if (0 != UNLINK (dc->temp_filename)) 2250 if (0 != UNLINK (dc->temp_filename))
2283 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 2251 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink",
2284 "unlink", dc->temp_filename); 2252 dc->temp_filename);
2285 GNUNET_free (dc->temp_filename); 2253 GNUNET_free (dc->temp_filename);
2286 } 2254 }
2287 GNUNET_free_non_null (dc->serialization); 2255 GNUNET_free_non_null (dc->serialization);
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index bb323bbbc..6809e3055 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -52,18 +52,13 @@
52 * @return always 0 to continue extracting 52 * @return always 0 to continue extracting
53 */ 53 */
54static int 54static int
55add_to_md (void *cls, 55add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
56 const char *plugin_name, 56 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
57 enum EXTRACTOR_MetaType type, 57 const char *data, size_t data_len)
58 enum EXTRACTOR_MetaFormat format,
59 const char *data_mime_type, const char *data, size_t data_len)
60{ 58{
61 struct GNUNET_CONTAINER_MetaData *md = cls; 59 struct GNUNET_CONTAINER_MetaData *md = cls;
62 60
63 (void) GNUNET_CONTAINER_meta_data_insert (md, 61 (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format,
64 plugin_name,
65 type,
66 format,
67 data_mime_type, data, data_len); 62 data_mime_type, data, data_len);
68 return 0; 63 return 0;
69} 64}
@@ -76,8 +71,8 @@ add_to_md (void *cls,
76 * of meta-data items obtained 71 * of meta-data items obtained
77 */ 72 */
78int 73int
79GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData 74GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData *md,
80 *md, const char *filename, 75 const char *filename,
81 struct EXTRACTOR_PluginList *extractors) 76 struct EXTRACTOR_PluginList *extractors)
82{ 77{
83 int old; 78 int old;
@@ -160,13 +155,12 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
160 GNUNET_break (0); 155 GNUNET_break (0);
161 return NULL; 156 return NULL;
162 } 157 }
163 ret = GNUNET_FS_file_information_create_from_reader (h, 158 ret =
164 client_info, 159 GNUNET_FS_file_information_create_from_reader (h, client_info,
165 sbuf.st_size, 160 sbuf.st_size,
166 &GNUNET_FS_data_reader_file_, 161 &GNUNET_FS_data_reader_file_,
167 fi, 162 fi, keywords, meta,
168 keywords, 163 do_index, bo);
169 meta, do_index, bo);
170 if (ret == NULL) 164 if (ret == NULL)
171 return NULL; 165 return NULL;
172 ret->h = h; 166 ret->h = h;
@@ -179,8 +173,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
179#endif 173#endif
180 while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) 174 while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
181 fn = ss + 1; 175 fn = ss + 1;
182 GNUNET_CONTAINER_meta_data_insert (ret->meta, 176 GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
183 "<gnunet>",
184 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 177 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
185 EXTRACTOR_METAFORMAT_C_STRING, 178 EXTRACTOR_METAFORMAT_C_STRING,
186 "text/plain", fn, strlen (fn) + 1); 179 "text/plain", fn, strlen (fn) + 1);
@@ -206,8 +199,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
206 */ 199 */
207struct GNUNET_FS_FileInformation * 200struct GNUNET_FS_FileInformation *
208GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, 201GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
209 void *client_info, 202 void *client_info, uint64_t length,
210 uint64_t length,
211 void *data, 203 void *data,
212 const struct GNUNET_FS_Uri 204 const struct GNUNET_FS_Uri
213 *keywords, 205 *keywords,
@@ -222,13 +214,10 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
222 GNUNET_break (0); 214 GNUNET_break (0);
223 return NULL; 215 return NULL;
224 } 216 }
225 return GNUNET_FS_file_information_create_from_reader (h, 217 return GNUNET_FS_file_information_create_from_reader (h, client_info, length,
226 client_info,
227 length,
228 &GNUNET_FS_data_reader_copy_, 218 &GNUNET_FS_data_reader_copy_,
229 data, 219 data, keywords, meta,
230 keywords, 220 do_index, bo);
231 meta, do_index, bo);
232} 221}
233 222
234 223
@@ -357,15 +346,13 @@ dir_scan_cb (void *cls, const char *filename)
357 346
358 if (0 != STAT (filename, &sbuf)) 347 if (0 != STAT (filename, &sbuf))
359 { 348 {
360 GNUNET_asprintf (&dsc->emsg, 349 GNUNET_asprintf (&dsc->emsg, _("`%s' failed on file `%s': %s"), "stat",
361 _("`%s' failed on file `%s': %s"), 350 filename, STRERROR (errno));
362 "stat", filename, STRERROR (errno));
363 return GNUNET_SYSERR; 351 return GNUNET_SYSERR;
364 } 352 }
365 if (S_ISDIR (sbuf.st_mode)) 353 if (S_ISDIR (sbuf.st_mode))
366 { 354 {
367 fi = GNUNET_FS_file_information_create_from_directory (dsc->h, 355 fi = GNUNET_FS_file_information_create_from_directory (dsc->h, NULL,
368 NULL,
369 filename, 356 filename,
370 dsc->scanner, 357 dsc->scanner,
371 dsc->scanner_cls, 358 dsc->scanner_cls,
@@ -383,11 +370,8 @@ dir_scan_cb (void *cls, const char *filename)
383 GNUNET_FS_meta_data_extract_from_file (meta, filename, dsc->extractors); 370 GNUNET_FS_meta_data_extract_from_file (meta, filename, dsc->extractors);
384 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); 371 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
385 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); 372 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords);
386 fi = GNUNET_FS_file_information_create_from_file (dsc->h, 373 fi = GNUNET_FS_file_information_create_from_file (dsc->h, NULL, filename,
387 NULL, 374 ksk_uri, meta,
388 filename,
389 ksk_uri,
390 meta,
391 dsc->do_index, dsc->bo); 375 dsc->do_index, dsc->bo);
392 GNUNET_CONTAINER_meta_data_destroy (meta); 376 GNUNET_CONTAINER_meta_data_destroy (meta);
393 GNUNET_FS_uri_destroy (keywords); 377 GNUNET_FS_uri_destroy (keywords);
@@ -420,10 +404,8 @@ dir_scan_cb (void *cls, const char *filename)
420 * @return GNUNET_OK on success 404 * @return GNUNET_OK on success
421 */ 405 */
422int 406int
423GNUNET_FS_directory_scanner_default (void *cls, 407GNUNET_FS_directory_scanner_default (void *cls, struct GNUNET_FS_Handle *h,
424 struct GNUNET_FS_Handle *h, 408 const char *dirname, int do_index,
425 const char *dirname,
426 int do_index,
427 const struct GNUNET_FS_BlockOptions *bo, 409 const struct GNUNET_FS_BlockOptions *bo,
428 GNUNET_FS_FileProcessor proc, 410 GNUNET_FS_FileProcessor proc,
429 void *proc_cls, char **emsg) 411 void *proc_cls, char **emsg)
@@ -527,9 +509,9 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
527 scanner (scanner_cls, h, filename, do_index, bo, &dirproc, &dc, emsg); 509 scanner (scanner_cls, h, filename, do_index, bo, &dirproc, &dc, emsg);
528 ksk = NULL; // FIXME... 510 ksk = NULL; // FIXME...
529 // FIXME: create meta! 511 // FIXME: create meta!
530 ret = GNUNET_FS_file_information_create_empty_directory (h, 512 ret =
531 client_info, 513 GNUNET_FS_file_information_create_empty_directory (h, client_info, ksk,
532 ksk, meta, bo); 514 meta, bo);
533 GNUNET_CONTAINER_meta_data_destroy (meta); 515 GNUNET_CONTAINER_meta_data_destroy (meta);
534 ret->data.dir.entries = dc.entries; 516 ret->data.dir.entries = dc.entries;
535 while (dc.entries != NULL) 517 while (dc.entries != NULL)
@@ -541,8 +523,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
541 while ((NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) && (strlen (ss) > 1)) 523 while ((NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) && (strlen (ss) > 1))
542 fn = ss + 1; 524 fn = ss + 1;
543 GNUNET_asprintf (&dn, "%s/", fn); 525 GNUNET_asprintf (&dn, "%s/", fn);
544 GNUNET_CONTAINER_meta_data_insert (ret->meta, 526 GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
545 "<gnunet>",
546 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 527 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
547 EXTRACTOR_METAFORMAT_C_STRING, 528 EXTRACTOR_METAFORMAT_C_STRING,
548 "text/plain", dn, strlen (dn) + 1); 529 "text/plain", dn, strlen (dn) + 1);
@@ -656,10 +637,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
656 637
657 no = GNUNET_NO; 638 no = GNUNET_NO;
658 if (GNUNET_OK != 639 if (GNUNET_OK !=
659 proc (proc_cls, 640 proc (proc_cls, dir,
660 dir, 641 (dir->is_directory) ? dir->data.dir.dir_size : dir->data.file.
661 (dir->is_directory) ? dir->data.dir.dir_size : dir->data. 642 file_size, dir->meta, &dir->keywords, &dir->bo,
662 file.file_size, dir->meta, &dir->keywords, &dir->bo,
663 (dir->is_directory) ? &no : &dir->data.file.do_index, 643 (dir->is_directory) ? &no : &dir->data.file.do_index,
664 &dir->client_info)) 644 &dir->client_info))
665 return; 645 return;
@@ -670,10 +650,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
670 { 650 {
671 no = GNUNET_NO; 651 no = GNUNET_NO;
672 if (GNUNET_OK != 652 if (GNUNET_OK !=
673 proc (proc_cls, 653 proc (proc_cls, pos,
674 pos, 654 (pos->is_directory) ? pos->data.dir.dir_size : pos->data.file.
675 (pos->is_directory) ? pos->data.dir.dir_size : pos->data. 655 file_size, pos->meta, &pos->keywords, &pos->bo,
676 file.file_size, pos->meta, &pos->keywords, &pos->bo,
677 (dir->is_directory) ? &no : &dir->data.file.do_index, 656 (dir->is_directory) ? &no : &dir->data.file.do_index,
678 &pos->client_info)) 657 &pos->client_info))
679 break; 658 break;
@@ -711,10 +690,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
711 } 690 }
712 /* clean up client-info */ 691 /* clean up client-info */
713 if (NULL != cleaner) 692 if (NULL != cleaner)
714 cleaner (cleaner_cls, 693 cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords,
715 fi, 694 &fi->bo, &no, &fi->client_info);
716 fi->data.dir.dir_size,
717 fi->meta, &fi->keywords, &fi->bo, &no, &fi->client_info);
718 GNUNET_free_non_null (fi->data.dir.dir_data); 695 GNUNET_free_non_null (fi->data.dir.dir_data);
719 } 696 }
720 else 697 else
@@ -724,20 +701,17 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
724 fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL); 701 fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
725 /* clean up client-info */ 702 /* clean up client-info */
726 if (NULL != cleaner) 703 if (NULL != cleaner)
727 cleaner (cleaner_cls, 704 cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
728 fi, 705 &fi->keywords, &fi->bo, &fi->data.file.do_index,
729 fi->data.file.file_size, 706 &fi->client_info);
730 fi->meta,
731 &fi->keywords,
732 &fi->bo, &fi->data.file.do_index, &fi->client_info);
733 } 707 }
734 GNUNET_free_non_null (fi->filename); 708 GNUNET_free_non_null (fi->filename);
735 GNUNET_free_non_null (fi->emsg); 709 GNUNET_free_non_null (fi->emsg);
736 GNUNET_free_non_null (fi->chk_uri); 710 GNUNET_free_non_null (fi->chk_uri);
737 /* clean up serialization */ 711 /* clean up serialization */
738 if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization))) 712 if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization)))
739 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 713 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
740 "unlink", fi->serialization); 714 fi->serialization);
741 if (NULL != fi->keywords) 715 if (NULL != fi->keywords)
742 GNUNET_FS_uri_destroy (fi->keywords); 716 GNUNET_FS_uri_destroy (fi->keywords);
743 if (NULL != fi->meta) 717 if (NULL != fi->meta)
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index 6c54fd69b..b50d0624b 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -154,9 +154,7 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext
154 (tmp[strlen (typename)] == ':') && 154 (tmp[strlen (typename)] == ':') &&
155 (0 == strncmp (typename, tmp, strlen (typename)))) 155 (0 == strncmp (typename, tmp, strlen (typename))))
156 { 156 {
157 GNUNET_CONTAINER_meta_data_insert (meta, 157 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type,
158 "<gnunet>",
159 type,
160 EXTRACTOR_METAFORMAT_UTF8, 158 EXTRACTOR_METAFORMAT_UTF8,
161 "text/plain", 159 "text/plain",
162 &tmp[strlen (typename) + 1], 160 &tmp[strlen (typename) + 1],
@@ -170,9 +168,7 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext
170 (tmp[strlen (typename_i18n)] == ':') && 168 (tmp[strlen (typename_i18n)] == ':') &&
171 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n)))) 169 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n))))
172 { 170 {
173 GNUNET_CONTAINER_meta_data_insert (meta, 171 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type,
174 "<gnunet>",
175 type,
176 EXTRACTOR_METAFORMAT_UTF8, 172 EXTRACTOR_METAFORMAT_UTF8,
177 "text/plain", 173 "text/plain",
178 &tmp[strlen (typename_i18n) + 1], 174 &tmp[strlen (typename_i18n) + 1],
@@ -186,11 +182,10 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext
186 } 182 }
187 if (tmp != NULL) 183 if (tmp != NULL)
188 { 184 {
189 GNUNET_CONTAINER_meta_data_insert (meta, 185 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
190 "<gnunet>",
191 EXTRACTOR_METATYPE_UNKNOWN, 186 EXTRACTOR_METATYPE_UNKNOWN,
192 EXTRACTOR_METAFORMAT_UTF8, 187 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
193 "text/plain", tmp, strlen (tmp) + 1); 188 tmp, strlen (tmp) + 1);
194 GNUNET_free (tmp); 189 GNUNET_free (tmp);
195 printf (_ 190 printf (_
196 ("Unknown metadata type in metadata option `%s'. Using metadata type `unknown' instead.\n"), 191 ("Unknown metadata type in metadata option `%s'. Using metadata type `unknown' instead.\n"),
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index 1eb290f11..85e12db32 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -98,8 +98,7 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg)
98 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END) 98 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END)
99 { 99 {
100 /* normal end-of-list */ 100 /* normal end-of-list */
101 GNUNET_SCHEDULER_add_continuation (gic->cont, 101 GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls,
102 gic->cont_cls,
103 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 102 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
104 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 103 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
105 GNUNET_free (gic); 104 GNUNET_free (gic);
@@ -125,17 +124,15 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg)
125 } 124 }
126 if (GNUNET_OK != gic->iterator (gic->iterator_cls, filename, &iim->file_id)) 125 if (GNUNET_OK != gic->iterator (gic->iterator_cls, filename, &iim->file_id))
127 { 126 {
128 GNUNET_SCHEDULER_add_continuation (gic->cont, 127 GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls,
129 gic->cont_cls,
130 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 128 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
131 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); 129 GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO);
132 GNUNET_free (gic); 130 GNUNET_free (gic);
133 return; 131 return;
134 } 132 }
135 /* get more */ 133 /* get more */
136 GNUNET_CLIENT_receive (gic->client, 134 GNUNET_CLIENT_receive (gic->client, &handle_index_info, gic,
137 &handle_index_info, 135 GNUNET_CONSTANTS_SERVICE_TIMEOUT);
138 gic, GNUNET_CONSTANTS_SERVICE_TIMEOUT);
139} 136}
140 137
141 138
@@ -153,8 +150,8 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg)
153void 150void
154GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, 151GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
155 GNUNET_FS_IndexedFileProcessor iterator, 152 GNUNET_FS_IndexedFileProcessor iterator,
156 void *iterator_cls, 153 void *iterator_cls, GNUNET_SCHEDULER_Task cont,
157 GNUNET_SCHEDULER_Task cont, void *cont_cls) 154 void *cont_cls)
158{ 155{
159 struct GNUNET_CLIENT_Connection *client; 156 struct GNUNET_CLIENT_Connection *client;
160 struct GetIndexedContext *gic; 157 struct GetIndexedContext *gic;
@@ -165,8 +162,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
165 { 162 {
166 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 163 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
167 _("Failed to not connect to `%s' service.\n"), "fs"); 164 _("Failed to not connect to `%s' service.\n"), "fs");
168 GNUNET_SCHEDULER_add_continuation (cont, 165 GNUNET_SCHEDULER_add_continuation (cont, cont_cls,
169 cont_cls,
170 GNUNET_SCHEDULER_REASON_TIMEOUT); 166 GNUNET_SCHEDULER_REASON_TIMEOUT);
171 return; 167 return;
172 } 168 }
@@ -181,8 +177,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
181 msg.size = htons (sizeof (struct GNUNET_MessageHeader)); 177 msg.size = htons (sizeof (struct GNUNET_MessageHeader));
182 msg.type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET); 178 msg.type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET);
183 GNUNET_assert (GNUNET_OK == 179 GNUNET_assert (GNUNET_OK ==
184 GNUNET_CLIENT_transmit_and_get_response (client, 180 GNUNET_CLIENT_transmit_and_get_response (client, &msg,
185 &msg,
186 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 181 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
187 GNUNET_YES, 182 GNUNET_YES,
188 &handle_index_info, 183 &handle_index_info,
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index 9fa86a5c4..3a8260d05 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -108,44 +108,45 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
108 char *base; 108 char *base;
109 const char *ext; 109 const char *ext;
110 110
111 ret = GNUNET_CONTAINER_meta_data_get_by_type (md, 111 ret =
112 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 112 GNUNET_CONTAINER_meta_data_get_by_type (md,
113 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
113 if (ret != NULL) 114 if (ret != NULL)
114 return ret; 115 return ret;
115 ext = NULL; 116 ext = NULL;
116 mime = GNUNET_CONTAINER_meta_data_get_by_type (md, 117 mime =
117 EXTRACTOR_METATYPE_MIMETYPE); 118 GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
118 if (mime != NULL) 119 if (mime != NULL)
119 { 120 {
120 i = 0; 121 i = 0;
121 while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0]))) 122 while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0])))
122 i++; 123 i++;
123 if (mimeMap[i][1] == NULL) 124 if (mimeMap[i][1] == NULL)
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | 125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
125 GNUNET_ERROR_TYPE_BULK,
126 _("Did not find mime type `%s' in extension list.\n"), mime); 126 _("Did not find mime type `%s' in extension list.\n"), mime);
127 else 127 else
128 ext = mimeMap[i][1]; 128 ext = mimeMap[i][1];
129 GNUNET_free (mime); 129 GNUNET_free (mime);
130 } 130 }
131 base = GNUNET_CONTAINER_meta_data_get_first_by_types (md, 131 base =
132 EXTRACTOR_METATYPE_TITLE, 132 GNUNET_CONTAINER_meta_data_get_first_by_types (md,
133 EXTRACTOR_METATYPE_BOOK_TITLE, 133 EXTRACTOR_METATYPE_TITLE,
134 EXTRACTOR_METATYPE_ORIGINAL_TITLE, 134 EXTRACTOR_METATYPE_BOOK_TITLE,
135 EXTRACTOR_METATYPE_PACKAGE_NAME, 135 EXTRACTOR_METATYPE_ORIGINAL_TITLE,
136 EXTRACTOR_METATYPE_URL, 136 EXTRACTOR_METATYPE_PACKAGE_NAME,
137 EXTRACTOR_METATYPE_URI, 137 EXTRACTOR_METATYPE_URL,
138 EXTRACTOR_METATYPE_DESCRIPTION, 138 EXTRACTOR_METATYPE_URI,
139 EXTRACTOR_METATYPE_ISRC, 139 EXTRACTOR_METATYPE_DESCRIPTION,
140 EXTRACTOR_METATYPE_JOURNAL_NAME, 140 EXTRACTOR_METATYPE_ISRC,
141 EXTRACTOR_METATYPE_AUTHOR_NAME, 141 EXTRACTOR_METATYPE_JOURNAL_NAME,
142 EXTRACTOR_METATYPE_SUBJECT, 142 EXTRACTOR_METATYPE_AUTHOR_NAME,
143 EXTRACTOR_METATYPE_ALBUM, 143 EXTRACTOR_METATYPE_SUBJECT,
144 EXTRACTOR_METATYPE_ARTIST, 144 EXTRACTOR_METATYPE_ALBUM,
145 EXTRACTOR_METATYPE_KEYWORDS, 145 EXTRACTOR_METATYPE_ARTIST,
146 EXTRACTOR_METATYPE_COMMENT, 146 EXTRACTOR_METATYPE_KEYWORDS,
147 EXTRACTOR_METATYPE_UNKNOWN, 147 EXTRACTOR_METATYPE_COMMENT,
148 -1); 148 EXTRACTOR_METATYPE_UNKNOWN,
149 -1);
149 if ((base == NULL) && (ext == NULL)) 150 if ((base == NULL) && (ext == NULL))
150 return NULL; 151 return NULL;
151 if (base == NULL) 152 if (base == NULL)
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index e8dd56ef4..236e8d59b 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -45,8 +45,8 @@ get_namespace_directory (struct GNUNET_FS_Handle *h)
45 char *dn; 45 char *dn;
46 46
47 if (GNUNET_OK != 47 if (GNUNET_OK !=
48 GNUNET_CONFIGURATION_get_value_filename (h->cfg, 48 GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "IDENTITY_DIR",
49 "FS", "IDENTITY_DIR", &dn)) 49 &dn))
50 { 50 {
51 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 51 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
52 _("Configuration fails to specify `%s' in section `%s'\n"), 52 _("Configuration fails to specify `%s' in section `%s'\n"),
@@ -71,8 +71,8 @@ get_update_information_directory (struct GNUNET_FS_Namespace *ns)
71 char *ret; 71 char *ret;
72 72
73 if (GNUNET_OK != 73 if (GNUNET_OK !=
74 GNUNET_CONFIGURATION_get_value_filename (ns->h->cfg, 74 GNUNET_CONFIGURATION_get_value_filename (ns->h->cfg, "FS", "UPDATE_DIR",
75 "FS", "UPDATE_DIR", &dn)) 75 &dn))
76 { 76 {
77 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 77 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
78 _("Configuration fails to specify `%s' in section `%s'\n"), 78 _("Configuration fails to specify `%s' in section `%s'\n"),
@@ -114,12 +114,9 @@ write_update_information_graph (struct GNUNET_FS_Namespace *ns)
114 { 114 {
115 n = ns->update_nodes[i]; 115 n = ns->update_nodes[i];
116 uris = GNUNET_FS_uri_to_string (n->uri); 116 uris = GNUNET_FS_uri_to_string (n->uri);
117 if ((GNUNET_OK != 117 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) ||
118 GNUNET_BIO_write_string (wh, n->id)) || 118 (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) ||
119 (GNUNET_OK != 119 (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) ||
120 GNUNET_BIO_write_meta_data (wh, n->md)) ||
121 (GNUNET_OK !=
122 GNUNET_BIO_write_string (wh, n->update)) ||
123 (GNUNET_OK != GNUNET_BIO_write_string (wh, uris))) 120 (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)))
124 { 121 {
125 GNUNET_free (uris); 122 GNUNET_free (uris);
@@ -129,8 +126,8 @@ write_update_information_graph (struct GNUNET_FS_Namespace *ns)
129 } 126 }
130END: 127END:
131 if (GNUNET_OK != GNUNET_BIO_write_close (wh)) 128 if (GNUNET_OK != GNUNET_BIO_write_close (wh))
132 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to write `%s': %s\n"),
133 _("Failed to write `%s': %s\n"), STRERROR (errno)); 130 STRERROR (errno));
134 GNUNET_free (fn); 131 GNUNET_free (fn);
135} 132}
136 133
@@ -185,10 +182,8 @@ read_update_information_graph (struct GNUNET_FS_Namespace *ns)
185 for (i = 0; i < count; i++) 182 for (i = 0; i < count; i++)
186 { 183 {
187 n = GNUNET_malloc (sizeof (struct NamespaceUpdateNode)); 184 n = GNUNET_malloc (sizeof (struct NamespaceUpdateNode));
188 if ((GNUNET_OK != 185 if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024))
189 GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) || 186 || (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
190 (GNUNET_OK !=
191 GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
192 (GNUNET_OK != 187 (GNUNET_OK !=
193 GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) || 188 GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) ||
194 (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2))) 189 (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2)))
@@ -320,8 +315,7 @@ advertisement_cont (void *cls, int success, const char *msg)
320 if (GNUNET_OK != success) 315 if (GNUNET_OK != success)
321 { 316 {
322 /* error! */ 317 /* error! */
323 GNUNET_SCHEDULER_add_continuation (&do_disconnect, 318 GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh,
324 ac->dsh,
325 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 319 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
326 if (msg == NULL) 320 if (msg == NULL)
327 { 321 {
@@ -340,8 +334,7 @@ advertisement_cont (void *cls, int success, const char *msg)
340 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) 334 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
341 { 335 {
342 /* done! */ 336 /* done! */
343 GNUNET_SCHEDULER_add_continuation (&do_disconnect, 337 GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh,
344 ac->dsh,
345 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 338 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
346 if (ac->cont != NULL) 339 if (ac->cont != NULL)
347 ac->cont (ac->cont_cls, ac->ksk_uri, NULL); 340 ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
@@ -359,8 +352,7 @@ advertisement_cont (void *cls, int success, const char *msg)
359 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); 352 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
360 GNUNET_CRYPTO_aes_encrypt (ac->pt, ac->pt_size, &skey, &iv, &ac->nb[1]); 353 GNUNET_CRYPTO_aes_encrypt (ac->pt, ac->pt_size, &skey, &iv, &ac->nb[1]);
361 GNUNET_break (GNUNET_OK == 354 GNUNET_break (GNUNET_OK ==
362 GNUNET_CRYPTO_rsa_sign (ac->ns->key, 355 GNUNET_CRYPTO_rsa_sign (ac->ns->key, &ac->nb->ns_purpose,
363 &ac->nb->ns_purpose,
364 &ac->nb->ns_signature)); 356 &ac->nb->ns_signature));
365 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); 357 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
366 GNUNET_assert (pk != NULL); 358 GNUNET_assert (pk != NULL);
@@ -369,22 +361,16 @@ advertisement_cont (void *cls, int success, const char *msg)
369 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 361 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
370 &query); 362 &query);
371 GNUNET_break (GNUNET_OK == 363 GNUNET_break (GNUNET_OK ==
372 GNUNET_CRYPTO_rsa_sign (pk, 364 GNUNET_CRYPTO_rsa_sign (pk, &ac->nb->ksk_purpose,
373 &ac->nb->ksk_purpose,
374 &ac->nb->ksk_signature)); 365 &ac->nb->ksk_signature));
375 GNUNET_CRYPTO_rsa_key_free (pk); 366 GNUNET_CRYPTO_rsa_key_free (pk);
376 GNUNET_DATASTORE_put (ac->dsh, 0 /* no reservation */ , 367 GNUNET_DATASTORE_put (ac->dsh, 0 /* no reservation */ ,
377 &query, 368 &query, ac->pt_size + sizeof (struct NBlock), ac->nb,
378 ac->pt_size + sizeof (struct NBlock), 369 GNUNET_BLOCK_TYPE_FS_NBLOCK, ac->bo.content_priority,
379 ac->nb, 370 ac->bo.anonymity_level, ac->bo.replication_level,
380 GNUNET_BLOCK_TYPE_FS_NBLOCK, 371 ac->bo.expiration_time, -2, 1,
381 ac->bo.content_priority, 372 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &advertisement_cont,
382 ac->bo.anonymity_level, 373 ac);
383 ac->bo.replication_level,
384 ac->bo.expiration_time,
385 -2, 1,
386 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
387 &advertisement_cont, ac);
388} 374}
389 375
390 376
@@ -437,10 +423,9 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
437 pt = GNUNET_malloc (mdsize + reslen); 423 pt = GNUNET_malloc (mdsize + reslen);
438 memcpy (pt, rootEntry, reslen); 424 memcpy (pt, rootEntry, reslen);
439 mdst = &pt[reslen]; 425 mdst = &pt[reslen];
440 mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, 426 mdsize =
441 &mdst, 427 GNUNET_CONTAINER_meta_data_serialize (meta, &mdst, mdsize,
442 mdsize, 428 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
443 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
444 if (mdsize == -1) 429 if (mdsize == -1)
445 { 430 {
446 GNUNET_break (0); 431 GNUNET_break (0);
@@ -451,11 +436,10 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
451 size = mdsize + sizeof (struct NBlock) + reslen; 436 size = mdsize + sizeof (struct NBlock) + reslen;
452 nb = GNUNET_malloc (size); 437 nb = GNUNET_malloc (size);
453 GNUNET_CRYPTO_rsa_key_get_public (namespace->key, &nb->subspace); 438 GNUNET_CRYPTO_rsa_key_get_public (namespace->key, &nb->subspace);
454 nb->ns_purpose.size = htonl (mdsize + reslen + 439 nb->ns_purpose.size =
455 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) 440 htonl (mdsize + reslen +
456 + 441 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
457 sizeof (struct 442 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
458 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
459 nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); 443 nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK);
460 nb->ksk_purpose.size = 444 nb->ksk_purpose.size =
461 htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); 445 htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature));
@@ -541,8 +525,8 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace, int freeze)
541 if (freeze) 525 if (freeze)
542 { 526 {
543 if (0 != UNLINK (namespace->filename)) 527 if (0 != UNLINK (namespace->filename))
544 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 528 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink",
545 "unlink", namespace->filename); 529 namespace->filename);
546 } 530 }
547 if (0 == namespace->rc) 531 if (0 == namespace->rc)
548 { 532 {
@@ -558,8 +542,8 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace, int freeze)
558 GNUNET_free (nsn->update); 542 GNUNET_free (nsn->update);
559 GNUNET_free (nsn); 543 GNUNET_free (nsn);
560 } 544 }
561 GNUNET_array_grow (namespace->update_nodes, 545 GNUNET_array_grow (namespace->update_nodes, namespace->update_node_count,
562 namespace->update_node_count, 0); 546 0);
563 if (namespace->update_map != NULL) 547 if (namespace->update_map != NULL)
564 GNUNET_CONTAINER_multihashmap_destroy (namespace->update_map); 548 GNUNET_CONTAINER_multihashmap_destroy (namespace->update_map);
565 GNUNET_free (namespace); 549 GNUNET_free (namespace);
@@ -733,8 +717,7 @@ sb_put_cont (void *cls, int success, const char *msg)
733 if (psc->namespace->update_map != NULL) 717 if (psc->namespace->update_map != NULL)
734 { 718 {
735 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc); 719 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc);
736 GNUNET_CONTAINER_multihashmap_put (psc->namespace->update_map, 720 GNUNET_CONTAINER_multihashmap_put (psc->namespace->update_map, &hc,
737 &hc,
738 psc->nsn, 721 psc->nsn,
739 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 722 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
740 } 723 }
@@ -775,8 +758,7 @@ sb_put_cont (void *cls, int success, const char *msg)
775void 758void
776GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, 759GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
777 struct GNUNET_FS_Namespace *namespace, 760 struct GNUNET_FS_Namespace *namespace,
778 const char *identifier, 761 const char *identifier, const char *update,
779 const char *update,
780 const struct GNUNET_CONTAINER_MetaData *meta, 762 const struct GNUNET_CONTAINER_MetaData *meta,
781 const struct GNUNET_FS_Uri *uri, 763 const struct GNUNET_FS_Uri *uri,
782 const struct GNUNET_FS_BlockOptions *bo, 764 const struct GNUNET_FS_BlockOptions *bo,
@@ -829,10 +811,9 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
829 memcpy (dest, uris, slen); 811 memcpy (dest, uris, slen);
830 GNUNET_free (uris); 812 GNUNET_free (uris);
831 dest += slen; 813 dest += slen;
832 mdsize = GNUNET_CONTAINER_meta_data_serialize (mmeta, 814 mdsize =
833 &dest, 815 GNUNET_CONTAINER_meta_data_serialize (mmeta, &dest, mdsize,
834 mdsize, 816 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
835 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
836 GNUNET_CONTAINER_meta_data_destroy (mmeta); 817 GNUNET_CONTAINER_meta_data_destroy (mmeta);
837 if (mdsize == -1) 818 if (mdsize == -1)
838 { 819 {
@@ -852,19 +833,18 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
852 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 833 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
853 &sks_uri->data.sks.namespace); 834 &sks_uri->data.sks.namespace);
854 sks_uri->data.sks.identifier = GNUNET_strdup (identifier); 835 sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
855 GNUNET_CRYPTO_hash_xor (&id, 836 GNUNET_CRYPTO_hash_xor (&id, &sks_uri->data.sks.namespace,
856 &sks_uri->data.sks.namespace, &sb_enc->identifier); 837 &sb_enc->identifier);
857 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); 838 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv);
858 GNUNET_CRYPTO_aes_encrypt (&sb[1], 839 GNUNET_CRYPTO_aes_encrypt (&sb[1], size - sizeof (struct SBlock), &sk, &iv,
859 size - sizeof (struct SBlock), 840 &sb_enc[1]);
860 &sk, &iv, &sb_enc[1]);
861 sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK); 841 sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK);
862 sb_enc->purpose.size = htonl (slen + mdsize + nidlen 842 sb_enc->purpose.size =
863 + sizeof (struct SBlock) 843 htonl (slen + mdsize + nidlen + sizeof (struct SBlock) -
864 - sizeof (struct GNUNET_CRYPTO_RsaSignature)); 844 sizeof (struct GNUNET_CRYPTO_RsaSignature));
865 GNUNET_assert (GNUNET_OK == 845 GNUNET_assert (GNUNET_OK ==
866 GNUNET_CRYPTO_rsa_sign (namespace->key, 846 GNUNET_CRYPTO_rsa_sign (namespace->key, &sb_enc->purpose,
867 &sb_enc->purpose, &sb_enc->signature)); 847 &sb_enc->signature));
868 psc = GNUNET_malloc (sizeof (struct PublishSksContext)); 848 psc = GNUNET_malloc (sizeof (struct PublishSksContext));
869 psc->uri = sks_uri; 849 psc->uri = sks_uri;
870 psc->cont = cont; 850 psc->cont = cont;
@@ -895,17 +875,10 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
895 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta); 875 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta);
896 psc->nsn->uri = GNUNET_FS_uri_dup (uri); 876 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
897 } 877 }
898 GNUNET_DATASTORE_put (psc->dsh, 878 GNUNET_DATASTORE_put (psc->dsh, 0, &sb_enc->identifier, size, sb_enc,
899 0, 879 GNUNET_BLOCK_TYPE_FS_SBLOCK, bo->content_priority,
900 &sb_enc->identifier, 880 bo->anonymity_level, bo->replication_level,
901 size, 881 bo->expiration_time, -2, 1,
902 sb_enc,
903 GNUNET_BLOCK_TYPE_FS_SBLOCK,
904 bo->content_priority,
905 bo->anonymity_level,
906 bo->replication_level,
907 bo->expiration_time,
908 -2, 1,
909 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, psc); 882 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, psc);
910 GNUNET_free (sb); 883 GNUNET_free (sb);
911 GNUNET_free (sb_enc); 884 GNUNET_free (sb_enc);
@@ -1030,8 +1003,8 @@ find_trees (void *cls, const GNUNET_HashCode * key, void *value)
1030 nsn->tree_id = UINT_MAX; /* mark as undef */ 1003 nsn->tree_id = UINT_MAX; /* mark as undef */
1031 /* trace */ 1004 /* trace */
1032 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc); 1005 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
1033 GNUNET_CONTAINER_multihashmap_get_multiple (fc->namespace->update_map, 1006 GNUNET_CONTAINER_multihashmap_get_multiple (fc->namespace->update_map, &hc,
1034 &hc, &find_trees, fc); 1007 &find_trees, fc);
1035 } 1008 }
1036 return GNUNET_YES; 1009 return GNUNET_YES;
1037} 1010}
@@ -1093,9 +1066,7 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1093 { 1066 {
1094 nsn = namespace->update_nodes[i]; 1067 nsn = namespace->update_nodes[i];
1095 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); 1068 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
1096 GNUNET_CONTAINER_multihashmap_put (namespace->update_map, 1069 GNUNET_CONTAINER_multihashmap_put (namespace->update_map, &hc, nsn,
1097 &hc,
1098 nsn,
1099 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1070 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1100 } 1071 }
1101 } 1072 }
@@ -1104,8 +1075,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1104 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc); 1075 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
1105 pc.ip = ip; 1076 pc.ip = ip;
1106 pc.ip_cls = ip_cls; 1077 pc.ip_cls = ip_cls;
1107 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, 1078 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc,
1108 &hc, &process_update_node, &pc); 1079 &process_update_node, &pc);
1109 return; 1080 return;
1110 } 1081 }
1111#if DEBUG_NAMESPACE 1082#if DEBUG_NAMESPACE
@@ -1123,8 +1094,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1123 if (nsn->nug == nug) 1094 if (nsn->nug == nug)
1124 { 1095 {
1125#if DEBUG_NAMESPACE 1096#if DEBUG_NAMESPACE
1126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id,
1127 "TREE of node `%s' is %u\n", nsn->id, nsn->nug); 1098 nsn->nug);
1128#endif 1099#endif
1129 continue; /* already placed in TREE */ 1100 continue; /* already placed in TREE */
1130 } 1101 }
@@ -1133,8 +1104,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1133 fc.id = UINT_MAX; 1104 fc.id = UINT_MAX;
1134 fc.nug = nug; 1105 fc.nug = nug;
1135 fc.namespace = namespace; 1106 fc.namespace = namespace;
1136 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, 1107 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc,
1137 &hc, &find_trees, &fc); 1108 &find_trees, &fc);
1138 if (fc.id == UINT_MAX) 1109 if (fc.id == UINT_MAX)
1139 { 1110 {
1140 /* start new TREE */ 1111 /* start new TREE */
@@ -1154,16 +1125,16 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1154 } 1125 }
1155#if DEBUG_NAMESPACE 1126#if DEBUG_NAMESPACE
1156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1157 "Starting new TREE %u with node `%s'\n", 1128 "Starting new TREE %u with node `%s'\n", nsn->tree_id,
1158 nsn->tree_id, nsn->id); 1129 nsn->id);
1159#endif 1130#endif
1160 /* put all nodes with same identifier into this TREE */ 1131 /* put all nodes with same identifier into this TREE */
1161 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); 1132 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
1162 fc.id = nsn->tree_id; 1133 fc.id = nsn->tree_id;
1163 fc.nug = nug; 1134 fc.nug = nug;
1164 fc.namespace = namespace; 1135 fc.namespace = namespace;
1165 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, 1136 GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc,
1166 &hc, &find_trees, &fc); 1137 &find_trees, &fc);
1167 } 1138 }
1168 else 1139 else
1169 { 1140 {
@@ -1172,8 +1143,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1172 nsn->tree_id = fc.id; 1143 nsn->tree_id = fc.id;
1173 } 1144 }
1174#if DEBUG_NAMESPACE 1145#if DEBUG_NAMESPACE
1175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id,
1176 "TREE of node `%s' is %u\n", nsn->id, fc.id); 1147 fc.id);
1177#endif 1148#endif
1178 } 1149 }
1179 for (i = 0; i < fc.tree_array_size; i++) 1150 for (i = 0; i < fc.tree_array_size; i++)
@@ -1182,8 +1153,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1182 if (NULL != nsn) 1153 if (NULL != nsn)
1183 { 1154 {
1184#if DEBUG_NAMESPACE 1155#if DEBUG_NAMESPACE
1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Root of TREE %u is node `%s'\n", i,
1186 "Root of TREE %u is node `%s'\n", i, nsn->id); 1157 nsn->id);
1187#endif 1158#endif
1188 1159
1189 ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update); 1160 ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 87161501b..746f4f099 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -58,11 +58,10 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
58 pi->value.publish.cctx = p->client_info; 58 pi->value.publish.cctx = p->client_info;
59 pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; 59 pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info;
60 pi->value.publish.filename = p->filename; 60 pi->value.publish.filename = p->filename;
61 pi->value.publish.size 61 pi->value.publish.size =
62 = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; 62 (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
63 pi->value.publish.eta 63 pi->value.publish.eta =
64 = GNUNET_TIME_calculate_eta (p->start_time, 64 GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size);
65 offset, pi->value.publish.size);
66 pi->value.publish.completed = offset; 65 pi->value.publish.completed = offset;
67 pi->value.publish.duration = 66 pi->value.publish.duration =
68 GNUNET_TIME_absolute_get_duration (p->start_time); 67 GNUNET_TIME_absolute_get_duration (p->start_time);
@@ -132,8 +131,8 @@ ds_put_cont (void *cls, int success, const char *msg)
132 if (GNUNET_SYSERR == pc->in_network_wait) 131 if (GNUNET_SYSERR == pc->in_network_wait)
133 { 132 {
134 /* we were aborted in the meantime, finish shutdown! */ 133 /* we were aborted in the meantime, finish shutdown! */
135 GNUNET_SCHEDULER_add_continuation (&publish_cleanup, 134 GNUNET_SCHEDULER_add_continuation (&publish_cleanup, pc,
136 pc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 135 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
137 return; 136 return;
138 } 137 }
139 GNUNET_assert (GNUNET_YES == pc->in_network_wait); 138 GNUNET_assert (GNUNET_YES == pc->in_network_wait);
@@ -155,8 +154,7 @@ ds_put_cont (void *cls, int success, const char *msg)
155 } 154 }
156 } 155 }
157 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 156 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
158 pc->upload_task 157 pc->upload_task =
159 =
160 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 158 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
161 &GNUNET_FS_publish_main_, pc); 159 &GNUNET_FS_publish_main_, pc);
162} 160}
@@ -179,10 +177,10 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p,
179 pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; 177 pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED;
180 pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; 178 pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
181 pi.value.publish.specifics.completed.chk_uri = p->chk_uri; 179 pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
182 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 180 p->client_info =
183 GNUNET_ntohll (p-> 181 GNUNET_FS_publish_make_status_ (&pi, pc, p,
184 chk_uri->data. 182 GNUNET_ntohll (p->chk_uri->data.chk.
185 chk.file_length)); 183 file_length));
186} 184}
187 185
188 186
@@ -206,8 +204,8 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p,
206 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 204 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
207 pi.value.publish.specifics.error.message = emsg; 205 pi.value.publish.specifics.error.message = emsg;
208 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); 206 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
209 if ((p->is_directory == GNUNET_NO) && 207 if ((p->is_directory == GNUNET_NO) && (p->filename != NULL) &&
210 (p->filename != NULL) && (p->data.file.do_index == GNUNET_YES)) 208 (p->data.file.do_index == GNUNET_YES))
211 { 209 {
212 /* run unindex to clean up */ 210 /* run unindex to clean up */
213 GNUNET_FS_unindex_start (pc->h, p->filename, NULL); 211 GNUNET_FS_unindex_start (pc->h, p->filename, NULL);
@@ -247,8 +245,8 @@ finish_release_reserve (void *cls, int success, const char *msg)
247 * @param emsg NULL on success, otherwise error message 245 * @param emsg NULL on success, otherwise error message
248 */ 246 */
249static void 247static void
250publish_sblocks_cont (void *cls, 248publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri,
251 const struct GNUNET_FS_Uri *uri, const char *emsg) 249 const char *emsg)
252{ 250{
253 struct GNUNET_FS_PublishContext *pc = cls; 251 struct GNUNET_FS_PublishContext *pc = cls;
254 252
@@ -261,12 +259,10 @@ publish_sblocks_cont (void *cls,
261 GNUNET_assert (pc->qre == NULL); 259 GNUNET_assert (pc->qre == NULL);
262 if ((pc->dsh != NULL) && (pc->rid != 0)) 260 if ((pc->dsh != NULL) && (pc->rid != 0))
263 { 261 {
264 pc->qre = GNUNET_DATASTORE_release_reserve (pc->dsh, 262 pc->qre =
265 pc->rid, 263 GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX,
266 UINT_MAX, 264 GNUNET_TIME_UNIT_FOREVER_REL,
267 UINT_MAX, 265 &finish_release_reserve, pc);
268 GNUNET_TIME_UNIT_FOREVER_REL,
269 &finish_release_reserve, pc);
270 } 266 }
271 else 267 else
272 { 268 {
@@ -285,13 +281,9 @@ static void
285publish_sblock (struct GNUNET_FS_PublishContext *pc) 281publish_sblock (struct GNUNET_FS_PublishContext *pc)
286{ 282{
287 if (NULL != pc->namespace) 283 if (NULL != pc->namespace)
288 GNUNET_FS_publish_sks (pc->h, 284 GNUNET_FS_publish_sks (pc->h, pc->namespace, pc->nid, pc->nuid,
289 pc->namespace, 285 pc->fi->meta, pc->fi->chk_uri, &pc->fi->bo,
290 pc->nid, 286 pc->options, &publish_sblocks_cont, pc);
291 pc->nuid,
292 pc->fi->meta,
293 pc->fi->chk_uri,
294 &pc->fi->bo, pc->options, &publish_sblocks_cont, pc);
295 else 287 else
296 publish_sblocks_cont (pc, NULL, NULL); 288 publish_sblocks_cont (pc, NULL, NULL);
297} 289}
@@ -307,8 +299,8 @@ publish_sblock (struct GNUNET_FS_PublishContext *pc)
307 * @param emsg NULL on success, otherwise error message 299 * @param emsg NULL on success, otherwise error message
308 */ 300 */
309static void 301static void
310publish_kblocks_cont (void *cls, 302publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri,
311 const struct GNUNET_FS_Uri *uri, const char *emsg) 303 const char *emsg)
312{ 304{
313 struct GNUNET_FS_PublishContext *pc = cls; 305 struct GNUNET_FS_PublishContext *pc = cls;
314 struct GNUNET_FS_FileInformation *p = pc->fi_pos; 306 struct GNUNET_FS_FileInformation *p = pc->fi_pos;
@@ -316,15 +308,14 @@ publish_kblocks_cont (void *cls,
316 if (NULL != emsg) 308 if (NULL != emsg)
317 { 309 {
318#if DEBUG_PUBLISH 310#if DEBUG_PUBLISH
319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading KSK blocks: %s\n",
320 "Error uploading KSK blocks: %s\n", emsg); 312 emsg);
321#endif 313#endif
322 signal_publish_error (p, pc, emsg); 314 signal_publish_error (p, pc, emsg);
323 GNUNET_FS_file_information_sync_ (p); 315 GNUNET_FS_file_information_sync_ (p);
324 GNUNET_FS_publish_sync_ (pc); 316 GNUNET_FS_publish_sync_ (pc);
325 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 317 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
326 pc->upload_task 318 pc->upload_task =
327 =
328 GNUNET_SCHEDULER_add_with_priority 319 GNUNET_SCHEDULER_add_with_priority
329 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); 320 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc);
330 return; 321 return;
@@ -342,8 +333,7 @@ publish_kblocks_cont (void *cls,
342 pc->fi_pos = p->dir; 333 pc->fi_pos = p->dir;
343 GNUNET_FS_publish_sync_ (pc); 334 GNUNET_FS_publish_sync_ (pc);
344 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 335 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
345 pc->upload_task 336 pc->upload_task =
346 =
347 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 337 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
348 &GNUNET_FS_publish_main_, pc); 338 &GNUNET_FS_publish_main_, pc);
349} 339}
@@ -384,8 +374,8 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
384 return 0; /* calling reader with pt_size==0 374 return 0; /* calling reader with pt_size==0
385 * might free buf, so don't! */ 375 * might free buf, so don't! */
386 if (pt_size != 376 if (pt_size !=
387 p->data.file.reader (p->data.file.reader_cls, 377 p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf,
388 offset, pt_size, buf, emsg)) 378 emsg))
389 return 0; 379 return 0;
390 } 380 }
391 return pt_size; 381 return pt_size;
@@ -438,8 +428,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
438 428
439 /* continue with main */ 429 /* continue with main */
440 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 430 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
441 pc->upload_task 431 pc->upload_task =
442 =
443 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 432 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
444 &GNUNET_FS_publish_main_, pc); 433 &GNUNET_FS_publish_main_, pc);
445} 434}
@@ -460,11 +449,9 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
460 * @param block_size size of block (in bytes) 449 * @param block_size size of block (in bytes)
461 */ 450 */
462static void 451static void
463block_proc (void *cls, 452block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset,
464 const struct ContentHashKey *chk, 453 unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block,
465 uint64_t offset, 454 uint16_t block_size)
466 unsigned int depth,
467 enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
468{ 455{
469 struct GNUNET_FS_PublishContext *pc = cls; 456 struct GNUNET_FS_PublishContext *pc = cls;
470 struct GNUNET_FS_FileInformation *p; 457 struct GNUNET_FS_FileInformation *p;
@@ -477,8 +464,7 @@ block_proc (void *cls,
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for datastore connection\n"); 464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for datastore connection\n");
478#endif 465#endif
479 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 466 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
480 pc->upload_task 467 pc->upload_task =
481 =
482 GNUNET_SCHEDULER_add_with_priority 468 GNUNET_SCHEDULER_add_with_priority
483 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); 469 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc);
484 return; 470 return;
@@ -486,54 +472,42 @@ block_proc (void *cls,
486 472
487 GNUNET_assert (GNUNET_NO == pc->in_network_wait); 473 GNUNET_assert (GNUNET_NO == pc->in_network_wait);
488 pc->in_network_wait = GNUNET_YES; 474 pc->in_network_wait = GNUNET_YES;
489 if ((!p->is_directory) && 475 if ((!p->is_directory) && (GNUNET_YES == p->data.file.do_index) &&
490 (GNUNET_YES == p->data.file.do_index) &&
491 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK)) 476 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK))
492 { 477 {
493#if DEBUG_PUBLISH 478#if DEBUG_PUBLISH
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
495 "Indexing block `%s' for offset %llu with index size %u\n", 480 "Indexing block `%s' for offset %llu with index size %u\n",
496 GNUNET_h2s (&chk->query), 481 GNUNET_h2s (&chk->query), (unsigned long long) offset,
497 (unsigned long long) offset, sizeof (struct OnDemandBlock)); 482 sizeof (struct OnDemandBlock));
498#endif 483#endif
499 odb.offset = GNUNET_htonll (offset); 484 odb.offset = GNUNET_htonll (offset);
500 odb.file_id = p->data.file.file_id; 485 odb.file_id = p->data.file.file_id;
501 GNUNET_assert (pc->qre == NULL); 486 GNUNET_assert (pc->qre == NULL);
502 pc->qre = GNUNET_DATASTORE_put (pc->dsh, 487 pc->qre =
503 (p->is_directory) ? 0 : pc->rid, 488 GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid,
504 &chk->query, 489 &chk->query, sizeof (struct OnDemandBlock), &odb,
505 sizeof (struct OnDemandBlock), 490 GNUNET_BLOCK_TYPE_FS_ONDEMAND,
506 &odb, 491 p->bo.content_priority, p->bo.anonymity_level,
507 GNUNET_BLOCK_TYPE_FS_ONDEMAND, 492 p->bo.replication_level, p->bo.expiration_time,
508 p->bo.content_priority, 493 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
509 p->bo.anonymity_level, 494 &ds_put_cont, pc);
510 p->bo.replication_level,
511 p->bo.expiration_time,
512 -2, 1,
513 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
514 &ds_put_cont, pc);
515 return; 495 return;
516 } 496 }
517#if DEBUG_PUBLISH 497#if DEBUG_PUBLISH
518 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
519 "Publishing block `%s' for offset %llu with size %u\n", 499 "Publishing block `%s' for offset %llu with size %u\n",
520 GNUNET_h2s (&chk->query), 500 GNUNET_h2s (&chk->query), (unsigned long long) offset,
521 (unsigned long long) offset, (unsigned int) block_size); 501 (unsigned int) block_size);
522#endif 502#endif
523 GNUNET_assert (pc->qre == NULL); 503 GNUNET_assert (pc->qre == NULL);
524 pc->qre = GNUNET_DATASTORE_put (pc->dsh, 504 pc->qre =
525 (p->is_directory) ? 0 : pc->rid, 505 GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid,
526 &chk->query, 506 &chk->query, block_size, block, type,
527 block_size, 507 p->bo.content_priority, p->bo.anonymity_level,
528 block, 508 p->bo.replication_level, p->bo.expiration_time, -2,
529 type, 509 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont,
530 p->bo.content_priority, 510 pc);
531 p->bo.anonymity_level,
532 p->bo.replication_level,
533 p->bo.expiration_time,
534 -2, 1,
535 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
536 &ds_put_cont, pc);
537} 511}
538 512
539 513
@@ -548,9 +522,8 @@ block_proc (void *cls,
548 * @param depth depth of the block in the tree, 0 for DBLOCK 522 * @param depth depth of the block in the tree, 0 for DBLOCK
549 */ 523 */
550static void 524static void
551progress_proc (void *cls, 525progress_proc (void *cls, uint64_t offset, const void *pt_block, size_t pt_size,
552 uint64_t offset, 526 unsigned int depth)
553 const void *pt_block, size_t pt_size, unsigned int depth)
554{ 527{
555 struct GNUNET_FS_PublishContext *pc = cls; 528 struct GNUNET_FS_PublishContext *pc = cls;
556 struct GNUNET_FS_FileInformation *p; 529 struct GNUNET_FS_FileInformation *p;
@@ -610,10 +583,9 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
610 raw_data = GNUNET_malloc (dirpos->data.file.file_size); 583 raw_data = GNUNET_malloc (dirpos->data.file.file_size);
611 emsg = NULL; 584 emsg = NULL;
612 if (dirpos->data.file.file_size != 585 if (dirpos->data.file.file_size !=
613 dirpos->data.file.reader (dirpos->data.file.reader_cls, 586 dirpos->data.file.reader (dirpos->data.file.reader_cls, 0,
614 0, 587 dirpos->data.file.file_size, raw_data,
615 dirpos->data.file.file_size, 588 &emsg))
616 raw_data, &emsg))
617 { 589 {
618 GNUNET_free_non_null (emsg); 590 GNUNET_free_non_null (emsg);
619 GNUNET_free (raw_data); 591 GNUNET_free (raw_data);
@@ -621,17 +593,15 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
621 } 593 }
622 } 594 }
623 } 595 }
624 GNUNET_FS_directory_builder_add (db, 596 GNUNET_FS_directory_builder_add (db, dirpos->chk_uri, dirpos->meta,
625 dirpos->chk_uri, 597 raw_data);
626 dirpos->meta, raw_data);
627 GNUNET_free_non_null (raw_data); 598 GNUNET_free_non_null (raw_data);
628 dirpos = dirpos->next; 599 dirpos = dirpos->next;
629 } 600 }
630 GNUNET_free_non_null (p->data.dir.dir_data); 601 GNUNET_free_non_null (p->data.dir.dir_data);
631 p->data.dir.dir_data = NULL; 602 p->data.dir.dir_data = NULL;
632 p->data.dir.dir_size = 0; 603 p->data.dir.dir_size = 0;
633 GNUNET_FS_directory_builder_finish (db, 604 GNUNET_FS_directory_builder_finish (db, &p->data.dir.dir_size,
634 &p->data.dir.dir_size,
635 &p->data.dir.dir_data); 605 &p->data.dir.dir_data);
636 GNUNET_FS_file_information_sync_ (p); 606 GNUNET_FS_file_information_sync_ (p);
637 } 607 }
@@ -639,12 +609,10 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
639#if DEBUG_PUBLISH 609#if DEBUG_PUBLISH
640 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n"); 610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n");
641#endif 611#endif
642 p->te = GNUNET_FS_tree_encoder_create (pc->h, 612 p->te =
643 size, 613 GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader,
644 pc, 614 &block_proc, &progress_proc,
645 &block_reader, 615 &encode_cont);
646 &block_proc,
647 &progress_proc, &encode_cont);
648 616
649 } 617 }
650#if DEBUG_PUBLISH 618#if DEBUG_PUBLISH
@@ -761,8 +729,7 @@ hash_for_index_cb (void *cls, const GNUNET_HashCode * res)
761 return; 729 return;
762 } 730 }
763#if DEBUG_PUBLISH 731#if DEBUG_PUBLISH
764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hash of indexed file `%s' is `%s'\n",
765 "Hash of indexed file `%s' is `%s'\n",
766 p->filename, GNUNET_h2s (res)); 733 p->filename, GNUNET_h2s (res));
767#endif 734#endif
768 if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 735 if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
@@ -813,8 +780,7 @@ hash_for_index_cb (void *cls, const GNUNET_HashCode * res)
813 GNUNET_free (fn); 780 GNUNET_free (fn);
814 pc->client = client; 781 pc->client = client;
815 GNUNET_break (GNUNET_YES == 782 GNUNET_break (GNUNET_YES ==
816 GNUNET_CLIENT_transmit_and_get_response (client, 783 GNUNET_CLIENT_transmit_and_get_response (client, &ism->header,
817 &ism->header,
818 GNUNET_TIME_UNIT_FOREVER_REL, 784 GNUNET_TIME_UNIT_FOREVER_REL,
819 GNUNET_YES, 785 GNUNET_YES,
820 &process_index_start_response, 786 &process_index_start_response,
@@ -854,9 +820,8 @@ GNUNET_FS_publish_main_ (void *cls,
854 return; 820 return;
855 } 821 }
856 /* find starting position */ 822 /* find starting position */
857 while ((p->is_directory) && 823 while ((p->is_directory) && (NULL != p->data.dir.entries) && (NULL == p->emsg)
858 (NULL != p->data.dir.entries) && 824 && (NULL == p->data.dir.entries->chk_uri))
859 (NULL == p->emsg) && (NULL == p->data.dir.entries->chk_uri))
860 { 825 {
861 p = p->data.dir.entries; 826 p = p->data.dir.entries;
862 pc->fi_pos = p; 827 pc->fi_pos = p;
@@ -877,8 +842,8 @@ GNUNET_FS_publish_main_ (void *cls,
877 p = p->dir; 842 p = p->dir;
878 if (fn != NULL) 843 if (fn != NULL)
879 { 844 {
880 GNUNET_asprintf (&p->emsg, 845 GNUNET_asprintf (&p->emsg, _("Recursive upload failed at `%s': %s"), fn,
881 _("Recursive upload failed at `%s': %s"), fn, p->emsg); 846 p->emsg);
882 GNUNET_free (fn); 847 GNUNET_free (fn);
883 } 848 }
884 else 849 else
@@ -904,8 +869,9 @@ GNUNET_FS_publish_main_ (void *cls,
904 if (0 == p->bo.anonymity_level) 869 if (0 == p->bo.anonymity_level)
905 { 870 {
906 /* zero anonymity, box CHK URI in LOC URI */ 871 /* zero anonymity, box CHK URI in LOC URI */
907 loc = GNUNET_FS_uri_loc_create (p->chk_uri, 872 loc =
908 pc->h->cfg, p->bo.expiration_time); 873 GNUNET_FS_uri_loc_create (p->chk_uri, pc->h->cfg,
874 p->bo.expiration_time);
909 GNUNET_FS_uri_destroy (p->chk_uri); 875 GNUNET_FS_uri_destroy (p->chk_uri);
910 p->chk_uri = loc; 876 p->chk_uri = loc;
911 } 877 }
@@ -913,11 +879,8 @@ GNUNET_FS_publish_main_ (void *cls,
913 /* upload of "p" complete, publish KBlocks! */ 879 /* upload of "p" complete, publish KBlocks! */
914 if (p->keywords != NULL) 880 if (p->keywords != NULL)
915 { 881 {
916 GNUNET_FS_publish_ksk (pc->h, 882 GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo,
917 p->keywords, 883 pc->options, &publish_kblocks_cont, pc);
918 p->meta,
919 p->chk_uri,
920 &p->bo, pc->options, &publish_kblocks_cont, pc);
921 } 884 }
922 else 885 else
923 { 886 {
@@ -945,10 +908,9 @@ GNUNET_FS_publish_main_ (void *cls,
945 else 908 else
946 { 909 {
947 p->start_time = GNUNET_TIME_absolute_get (); 910 p->start_time = GNUNET_TIME_absolute_get ();
948 pc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, 911 pc->fhc =
949 p->filename, 912 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename,
950 HASHING_BLOCKSIZE, 913 HASHING_BLOCKSIZE, &hash_for_index_cb, pc);
951 &hash_for_index_cb, pc);
952 } 914 }
953 return; 915 return;
954 } 916 }
@@ -971,12 +933,9 @@ GNUNET_FS_publish_main_ (void *cls,
971 * @return GNUNET_OK to continue (always) 933 * @return GNUNET_OK to continue (always)
972 */ 934 */
973static int 935static int
974fip_signal_start (void *cls, 936fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi,
975 struct GNUNET_FS_FileInformation *fi, 937 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
976 uint64_t length, 938 struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo,
977 struct GNUNET_CONTAINER_MetaData *meta,
978 struct GNUNET_FS_Uri **uri,
979 struct GNUNET_FS_BlockOptions *bo,
980 int *do_index, void **client_info) 939 int *do_index, void **client_info)
981{ 940{
982 struct GNUNET_FS_PublishContext *pc = cls; 941 struct GNUNET_FS_PublishContext *pc = cls;
@@ -1040,13 +999,11 @@ fip_signal_start (void *cls,
1040 * @return GNUNET_OK to continue (always) 999 * @return GNUNET_OK to continue (always)
1041 */ 1000 */
1042static int 1001static int
1043fip_signal_suspend (void *cls, 1002fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
1044 struct GNUNET_FS_FileInformation *fi, 1003 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1045 uint64_t length,
1046 struct GNUNET_CONTAINER_MetaData *meta,
1047 struct GNUNET_FS_Uri **uri, 1004 struct GNUNET_FS_Uri **uri,
1048 struct GNUNET_FS_BlockOptions *bo, 1005 struct GNUNET_FS_BlockOptions *bo, int *do_index,
1049 int *do_index, void **client_info) 1006 void **client_info)
1050{ 1007{
1051 struct GNUNET_FS_PublishContext *pc = cls; 1008 struct GNUNET_FS_PublishContext *pc = cls;
1052 struct GNUNET_FS_ProgressInfo pi; 1009 struct GNUNET_FS_ProgressInfo pi;
@@ -1118,15 +1075,14 @@ finish_reserve (void *cls, int success, const char *msg)
1118#endif 1075#endif
1119 if ((msg != NULL) || (success <= 0)) 1076 if ((msg != NULL) || (success <= 0))
1120 { 1077 {
1121 GNUNET_asprintf (&pc->fi->emsg, 1078 GNUNET_asprintf (&pc->fi->emsg, _("Insufficient space for publishing: %s"),
1122 _("Insufficient space for publishing: %s"), msg); 1079 msg);
1123 signal_publish_error (pc->fi, pc, pc->fi->emsg); 1080 signal_publish_error (pc->fi, pc, pc->fi->emsg);
1124 return; 1081 return;
1125 } 1082 }
1126 pc->rid = success; 1083 pc->rid = success;
1127 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 1084 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
1128 pc->upload_task 1085 pc->upload_task =
1129 =
1130 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 1086 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1131 &GNUNET_FS_publish_main_, pc); 1087 &GNUNET_FS_publish_main_, pc);
1132} 1088}
@@ -1148,8 +1104,7 @@ finish_reserve (void *cls, int success, const char *msg)
1148struct GNUNET_FS_PublishContext * 1104struct GNUNET_FS_PublishContext *
1149GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, 1105GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1150 struct GNUNET_FS_FileInformation *fi, 1106 struct GNUNET_FS_FileInformation *fi,
1151 struct GNUNET_FS_Namespace *namespace, 1107 struct GNUNET_FS_Namespace *namespace, const char *nid,
1152 const char *nid,
1153 const char *nuid, 1108 const char *nuid,
1154 enum GNUNET_FS_PublishOptions options) 1109 enum GNUNET_FS_PublishOptions options)
1155{ 1110{
@@ -1203,8 +1158,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1203 else 1158 else
1204 { 1159 {
1205 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ret->upload_task); 1160 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ret->upload_task);
1206 ret->upload_task 1161 ret->upload_task =
1207 =
1208 GNUNET_SCHEDULER_add_with_priority 1162 GNUNET_SCHEDULER_add_with_priority
1209 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret); 1163 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret);
1210 } 1164 }
@@ -1227,12 +1181,9 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1227 * @return GNUNET_OK to continue (always) 1181 * @return GNUNET_OK to continue (always)
1228 */ 1182 */
1229static int 1183static int
1230fip_signal_stop (void *cls, 1184fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi,
1231 struct GNUNET_FS_FileInformation *fi, 1185 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1232 uint64_t length, 1186 struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo,
1233 struct GNUNET_CONTAINER_MetaData *meta,
1234 struct GNUNET_FS_Uri **uri,
1235 struct GNUNET_FS_BlockOptions *bo,
1236 int *do_index, void **client_info) 1187 int *do_index, void **client_info)
1237{ 1188{
1238 struct GNUNET_FS_PublishContext *pc = cls; 1189 struct GNUNET_FS_PublishContext *pc = cls;
@@ -1241,8 +1192,7 @@ fip_signal_stop (void *cls,
1241 1192
1242 if (fi->serialization != NULL) 1193 if (fi->serialization != NULL)
1243 { 1194 {
1244 GNUNET_FS_remove_sync_file_ (pc->h, 1195 GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO,
1245 GNUNET_FS_SYNC_PATH_FILE_INFO,
1246 fi->serialization); 1196 fi->serialization);
1247 GNUNET_free (fi->serialization); 1197 GNUNET_free (fi->serialization);
1248 fi->serialization = NULL; 1198 fi->serialization = NULL;
@@ -1383,8 +1333,8 @@ struct PublishKskContext
1383 * @param cls closure of type "struct PublishKskContext*" 1333 * @param cls closure of type "struct PublishKskContext*"
1384 * @param tc unused 1334 * @param tc unused
1385 */ 1335 */
1386static void 1336static void publish_ksk_cont (void *cls,
1387publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 1337 const struct GNUNET_SCHEDULER_TaskContext *tc);
1388 1338
1389 1339
1390/** 1340/**
@@ -1418,8 +1368,8 @@ kb_put_cont (void *cls, int success, const char *msg)
1418 GNUNET_free (pkc); 1368 GNUNET_free (pkc);
1419 return; 1369 return;
1420 } 1370 }
1421 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, 1371 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc,
1422 pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1372 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1423} 1373}
1424 1374
1425 1375
@@ -1461,15 +1411,15 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1461 } 1411 }
1462 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++]; 1412 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
1463#if DEBUG_PUBLISH 1413#if DEBUG_PUBLISH
1464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n",
1465 "Publishing under keyword `%s'\n", keyword); 1415 keyword);
1466#endif 1416#endif
1467 /* first character of keyword indicates if it is 1417 /* first character of keyword indicates if it is
1468 * mandatory or not -- ignore for hashing */ 1418 * mandatory or not -- ignore for hashing */
1469 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key); 1419 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
1470 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); 1420 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
1471 GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], 1421 GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], pkc->slen + pkc->mdsize, &skey, &iv,
1472 pkc->slen + pkc->mdsize, &skey, &iv, &pkc->cpy[1]); 1422 &pkc->cpy[1]);
1473 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); 1423 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
1474 GNUNET_assert (NULL != pk); 1424 GNUNET_assert (NULL != pk);
1475 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace); 1425 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace);
@@ -1477,25 +1427,17 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1477 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1427 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1478 &query); 1428 &query);
1479 GNUNET_assert (GNUNET_OK == 1429 GNUNET_assert (GNUNET_OK ==
1480 GNUNET_CRYPTO_rsa_sign (pk, 1430 GNUNET_CRYPTO_rsa_sign (pk, &pkc->cpy->purpose,
1481 &pkc->cpy->purpose,
1482 &pkc->cpy->signature)); 1431 &pkc->cpy->signature));
1483 GNUNET_CRYPTO_rsa_key_free (pk); 1432 GNUNET_CRYPTO_rsa_key_free (pk);
1484 pkc->qre = GNUNET_DATASTORE_put (pkc->dsh, 1433 pkc->qre =
1485 0, 1434 GNUNET_DATASTORE_put (pkc->dsh, 0, &query,
1486 &query, 1435 pkc->mdsize + sizeof (struct KBlock) + pkc->slen,
1487 pkc->mdsize + 1436 pkc->cpy, GNUNET_BLOCK_TYPE_FS_KBLOCK,
1488 sizeof (struct KBlock) + 1437 pkc->bo.content_priority, pkc->bo.anonymity_level,
1489 pkc->slen, 1438 pkc->bo.replication_level, pkc->bo.expiration_time,
1490 pkc->cpy, 1439 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1491 GNUNET_BLOCK_TYPE_FS_KBLOCK, 1440 &kb_put_cont, pkc);
1492 pkc->bo.content_priority,
1493 pkc->bo.anonymity_level,
1494 pkc->bo.replication_level,
1495 pkc->bo.expiration_time,
1496 -2, 1,
1497 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1498 &kb_put_cont, pkc);
1499} 1441}
1500 1442
1501 1443
@@ -1561,10 +1503,9 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1561 GNUNET_free (uris); 1503 GNUNET_free (uris);
1562 sptr = &kbe[pkc->slen]; 1504 sptr = &kbe[pkc->slen];
1563 if (meta != NULL) 1505 if (meta != NULL)
1564 pkc->mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, 1506 pkc->mdsize =
1565 &sptr, 1507 GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, pkc->mdsize,
1566 pkc->mdsize, 1508 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
1567 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
1568 if (pkc->mdsize == -1) 1509 if (pkc->mdsize == -1)
1569 { 1510 {
1570 GNUNET_break (0); 1511 GNUNET_break (0);
@@ -1587,8 +1528,8 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1587 pkc->mdsize + pkc->slen); 1528 pkc->mdsize + pkc->slen);
1588 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK); 1529 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
1589 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 1530 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
1590 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, 1531 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc,
1591 pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1532 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1592} 1533}
1593 1534
1594 1535
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 60b7a1cc8..89a8c5582 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -48,8 +48,8 @@ GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
48 48
49 pi->value.search.sc = sc; 49 pi->value.search.sc = sc;
50 pi->value.search.cctx = sc->client_info; 50 pi->value.search.cctx = sc->client_info;
51 pi->value.search.pctx 51 pi->value.search.pctx =
52 = (sc->psearch_result == NULL) ? NULL : sc->psearch_result->client_info; 52 (sc->psearch_result == NULL) ? NULL : sc->psearch_result->client_info;
53 pi->value.search.query = sc->uri; 53 pi->value.search.query = sc->uri;
54 pi->value.search.duration = 54 pi->value.search.duration =
55 GNUNET_TIME_absolute_get_duration (sc->start_time); 55 GNUNET_TIME_absolute_get_duration (sc->start_time);
@@ -121,10 +121,10 @@ notify_client_chk_update (struct GNUNET_FS_SearchContext *sc,
121 pi.value.search.specifics.update.cctx = sr->client_info; 121 pi.value.search.specifics.update.cctx = sr->client_info;
122 pi.value.search.specifics.update.meta = sr->meta; 122 pi.value.search.specifics.update.meta = sr->meta;
123 pi.value.search.specifics.update.uri = sr->uri; 123 pi.value.search.specifics.update.uri = sr->uri;
124 pi.value.search.specifics.update.availability_rank 124 pi.value.search.specifics.update.availability_rank =
125 = 2 * sr->availability_success - sr->availability_trials; 125 2 * sr->availability_success - sr->availability_trials;
126 pi.value.search.specifics.update.availability_certainty 126 pi.value.search.specifics.update.availability_certainty =
127 = sr->availability_trials; 127 sr->availability_trials;
128 pi.value.search.specifics.update.applicability_rank = sr->optional_support; 128 pi.value.search.specifics.update.applicability_rank = sr->optional_support;
129 sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc); 129 sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
130} 130}
@@ -386,16 +386,15 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
386 /* check if new */ 386 /* check if new */
387 GNUNET_FS_uri_to_key (uri, &key); 387 GNUNET_FS_uri_to_key (uri, &key);
388 if (GNUNET_SYSERR == 388 if (GNUNET_SYSERR ==
389 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, 389 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, &key,
390 &key,
391 &test_result_present, 390 &test_result_present,
392 (void *) uri)) 391 (void *) uri))
393 return; /* duplicate result */ 392 return; /* duplicate result */
394 /* try to find search result in master map */ 393 /* try to find search result in master map */
395 grc.sr = NULL; 394 grc.sr = NULL;
396 grc.uri = uri; 395 grc.uri = uri;
397 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, 396 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key,
398 &key, &get_result_present, &grc); 397 &get_result_present, &grc);
399 sr = grc.sr; 398 sr = grc.sr;
400 is_new = (NULL == sr) || (sr->mandatory_missing > 0); 399 is_new = (NULL == sr) || (sr->mandatory_missing > 0);
401 if (NULL == sr) 400 if (NULL == sr)
@@ -406,9 +405,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
406 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 405 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
407 sr->mandatory_missing = sc->mandatory_count; 406 sr->mandatory_missing = sc->mandatory_count;
408 sr->key = key; 407 sr->key = key;
409 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, 408 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr,
410 &key,
411 sr,
412 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 409 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
413 } 410 }
414 else 411 else
@@ -464,8 +461,7 @@ static struct GNUNET_FS_SearchContext *search_start (struct GNUNET_FS_Handle *h,
464 * @param meta metadata associated with the URI 461 * @param meta metadata associated with the URI
465 */ 462 */
466static void 463static void
467process_sks_result (struct GNUNET_FS_SearchContext *sc, 464process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update,
468 const char *id_update,
469 const struct GNUNET_FS_Uri *uri, 465 const struct GNUNET_FS_Uri *uri,
470 const struct GNUNET_CONTAINER_MetaData *meta) 466 const struct GNUNET_CONTAINER_MetaData *meta)
471{ 467{
@@ -475,11 +471,10 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
475 471
476 /* check if new */ 472 /* check if new */
477 GNUNET_FS_uri_to_key (uri, &key); 473 GNUNET_FS_uri_to_key (uri, &key);
478 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, 474 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, &uri->data.chk.chk.query,
479 &uri->data.chk.chk.query, &key); 475 &key);
480 if (GNUNET_SYSERR == 476 if (GNUNET_SYSERR ==
481 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, 477 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key,
482 &key,
483 &test_result_present, 478 &test_result_present,
484 (void *) uri)) 479 (void *) uri))
485 return; /* duplicate result */ 480 return; /* duplicate result */
@@ -488,9 +483,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
488 sr->uri = GNUNET_FS_uri_dup (uri); 483 sr->uri = GNUNET_FS_uri_dup (uri);
489 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 484 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
490 sr->key = key; 485 sr->key = key;
491 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, 486 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr,
492 &key,
493 sr,
494 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 487 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
495 GNUNET_FS_search_result_sync_ (sr); 488 GNUNET_FS_search_result_sync_ (sr);
496 GNUNET_FS_search_start_probe_ (sr); 489 GNUNET_FS_search_start_probe_ (sr);
@@ -515,8 +508,8 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
515 * @param size size of kb 508 * @param size size of kb
516 */ 509 */
517static void 510static void
518process_kblock (struct GNUNET_FS_SearchContext *sc, 511process_kblock (struct GNUNET_FS_SearchContext *sc, const struct KBlock *kb,
519 const struct KBlock *kb, size_t size) 512 size_t size)
520{ 513{
521 unsigned int i; 514 unsigned int i;
522 size_t j; 515 size_t j;
@@ -544,9 +537,9 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
544 } 537 }
545 /* decrypt */ 538 /* decrypt */
546 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); 539 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
547 if (-1 == GNUNET_CRYPTO_aes_decrypt (&kb[1], 540 if (-1 ==
548 size - sizeof (struct KBlock), 541 GNUNET_CRYPTO_aes_decrypt (&kb[1], size - sizeof (struct KBlock), &skey,
549 &skey, &iv, pt)) 542 &iv, pt))
550 { 543 {
551 GNUNET_break (0); 544 GNUNET_break (0);
552 return; 545 return;
@@ -593,8 +586,8 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
593 * @param size size of nb 586 * @param size size of nb
594 */ 587 */
595static void 588static void
596process_nblock (struct GNUNET_FS_SearchContext *sc, 589process_nblock (struct GNUNET_FS_SearchContext *sc, const struct NBlock *nb,
597 const struct NBlock *nb, size_t size) 590 size_t size)
598{ 591{
599 unsigned int i; 592 unsigned int i;
600 size_t j; 593 size_t j;
@@ -622,9 +615,9 @@ process_nblock (struct GNUNET_FS_SearchContext *sc,
622 } 615 }
623 /* decrypt */ 616 /* decrypt */
624 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); 617 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
625 if (-1 == GNUNET_CRYPTO_aes_decrypt (&nb[1], 618 if (-1 ==
626 size - sizeof (struct NBlock), 619 GNUNET_CRYPTO_aes_decrypt (&nb[1], size - sizeof (struct NBlock), &skey,
627 &skey, &iv, pt)) 620 &iv, pt))
628 { 621 {
629 GNUNET_break (0); 622 GNUNET_break (0);
630 return; 623 return;
@@ -654,11 +647,9 @@ process_nblock (struct GNUNET_FS_SearchContext *sc,
654 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 647 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
655 &uri->data.sks.namespace); 648 &uri->data.sks.namespace);
656 uris = GNUNET_FS_uri_to_string (uri); 649 uris = GNUNET_FS_uri_to_string (uri);
657 GNUNET_CONTAINER_meta_data_insert (meta, 650 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", EXTRACTOR_METATYPE_URI,
658 "<gnunet>", 651 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
659 EXTRACTOR_METATYPE_URI, 652 uris, strlen (uris) + 1);
660 EXTRACTOR_METAFORMAT_UTF8,
661 "text/plain", uris, strlen (uris) + 1);
662 GNUNET_free (uris); 653 GNUNET_free (uris);
663 GNUNET_PSEUDONYM_add (sc->h->cfg, &uri->data.sks.namespace, meta); 654 GNUNET_PSEUDONYM_add (sc->h->cfg, &uri->data.sks.namespace, meta);
664 /* process */ 655 /* process */
@@ -678,8 +669,8 @@ process_nblock (struct GNUNET_FS_SearchContext *sc,
678 * @param size size of sb 669 * @param size size of sb
679 */ 670 */
680static void 671static void
681process_sblock (struct GNUNET_FS_SearchContext *sc, 672process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb,
682 const struct SBlock *sb, size_t size) 673 size_t size)
683{ 674{
684 size_t len = size - sizeof (struct SBlock); 675 size_t len = size - sizeof (struct SBlock);
685 char pt[len]; 676 char pt[len];
@@ -719,8 +710,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
719 uri = GNUNET_FS_uri_parse (uris, &emsg); 710 uri = GNUNET_FS_uri_parse (uris, &emsg);
720 if (uri == NULL) 711 if (uri == NULL)
721 { 712 {
722 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 713 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse URI `%s': %s\n", uris,
723 "Failed to parse URI `%s': %s\n", uris, emsg); 714 emsg);
724 GNUNET_break_op (0); /* sblock malformed */ 715 GNUNET_break_op (0); /* sblock malformed */
725 GNUNET_free_non_null (emsg); 716 GNUNET_free_non_null (emsg);
726 GNUNET_CONTAINER_meta_data_destroy (meta); 717 GNUNET_CONTAINER_meta_data_destroy (meta);
@@ -744,10 +735,9 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
744 * @param size size of data 735 * @param size size of data
745 */ 736 */
746static void 737static void
747process_result (struct GNUNET_FS_SearchContext *sc, 738process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type,
748 enum GNUNET_BLOCK_Type type, 739 struct GNUNET_TIME_Absolute expiration, const void *data,
749 struct GNUNET_TIME_Absolute expiration, 740 size_t size)
750 const void *data, size_t size)
751{ 741{
752 if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0) 742 if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0)
753 { 743 {
@@ -840,8 +830,7 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
840 const struct PutMessage *cm; 830 const struct PutMessage *cm;
841 uint16_t msize; 831 uint16_t msize;
842 832
843 if ((NULL == msg) || 833 if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
844 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
845 (ntohs (msg->size) <= sizeof (struct PutMessage))) 834 (ntohs (msg->size) <= sizeof (struct PutMessage)))
846 { 835 {
847 try_reconnect (sc); 836 try_reconnect (sc);
@@ -851,13 +840,12 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 840 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
852 "Receiving %u bytes of result from fs service\n", msize); 841 "Receiving %u bytes of result from fs service\n", msize);
853 cm = (const struct PutMessage *) msg; 842 cm = (const struct PutMessage *) msg;
854 process_result (sc, 843 process_result (sc, ntohl (cm->type),
855 ntohl (cm->type), 844 GNUNET_TIME_absolute_ntoh (cm->expiration), &cm[1],
856 GNUNET_TIME_absolute_ntoh (cm->expiration), 845 msize - sizeof (struct PutMessage));
857 &cm[1], msize - sizeof (struct PutMessage));
858 /* continue receiving */ 846 /* continue receiving */
859 GNUNET_CLIENT_receive (sc->client, 847 GNUNET_CLIENT_receive (sc->client, &receive_results, sc,
860 &receive_results, sc, GNUNET_TIME_UNIT_FOREVER_REL); 848 GNUNET_TIME_UNIT_FOREVER_REL);
861} 849}
862 850
863 851
@@ -867,8 +855,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
867 * 855 *
868 * @param sc context for the search 856 * @param sc context for the search
869 */ 857 */
870static void 858static void schedule_transmit_search_request (struct GNUNET_FS_SearchContext
871schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc); 859 *sc);
872 860
873 861
874/** 862/**
@@ -1064,8 +1052,8 @@ transmit_search_request (void *cls, size_t size, void *buf)
1064 return msize; 1052 return msize;
1065 } 1053 }
1066 } 1054 }
1067 GNUNET_CLIENT_receive (sc->client, 1055 GNUNET_CLIENT_receive (sc->client, &receive_results, sc,
1068 &receive_results, sc, GNUNET_TIME_UNIT_FOREVER_REL); 1056 GNUNET_TIME_UNIT_FOREVER_REL);
1069 return msize; 1057 return msize;
1070} 1058}
1071 1059
@@ -1090,8 +1078,7 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc)
1090 fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - size) / sizeof (GNUNET_HashCode); 1078 fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - size) / sizeof (GNUNET_HashCode);
1091 fit = GNUNET_MIN (fit, sqms); 1079 fit = GNUNET_MIN (fit, sqms);
1092 size += sizeof (GNUNET_HashCode) * fit; 1080 size += sizeof (GNUNET_HashCode) * fit;
1093 GNUNET_CLIENT_notify_transmit_ready (sc->client, 1081 GNUNET_CLIENT_notify_transmit_ready (sc->client, size,
1094 size,
1095 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1082 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1096 GNUNET_NO, &transmit_search_request, sc); 1083 GNUNET_NO, &transmit_search_request, sc);
1097 1084
@@ -1140,9 +1127,9 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1140 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); 1127 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
1141 sc->client = NULL; 1128 sc->client = NULL;
1142 } 1129 }
1143 sc->task 1130 sc->task =
1144 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 1131 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
1145 &do_reconnect, sc); 1132 sc);
1146} 1133}
1147 1134
1148 1135
@@ -1159,10 +1146,8 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1159 * @return context that can be used to control the search 1146 * @return context that can be used to control the search
1160 */ 1147 */
1161static struct GNUNET_FS_SearchContext * 1148static struct GNUNET_FS_SearchContext *
1162search_start (struct GNUNET_FS_Handle *h, 1149search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri,
1163 const struct GNUNET_FS_Uri *uri, 1150 uint32_t anonymity, enum GNUNET_FS_SearchOptions options,
1164 uint32_t anonymity,
1165 enum GNUNET_FS_SearchOptions options,
1166 void *cctx, struct GNUNET_FS_SearchResult *psearch) 1151 void *cctx, struct GNUNET_FS_SearchResult *psearch)
1167{ 1152{
1168 struct GNUNET_FS_SearchContext *sc; 1153 struct GNUNET_FS_SearchContext *sc;
@@ -1215,8 +1200,9 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1215 if (GNUNET_FS_uri_test_ksk (sc->uri)) 1200 if (GNUNET_FS_uri_test_ksk (sc->uri))
1216 { 1201 {
1217 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); 1202 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1218 sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) * 1203 sc->requests =
1219 sc->uri->data.ksk.keywordCount); 1204 GNUNET_malloc (sizeof (struct SearchRequestEntry) *
1205 sc->uri->data.ksk.keywordCount);
1220 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) 1206 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1221 { 1207 {
1222 keyword = &sc->uri->data.ksk.keywords[i][1]; 1208 keyword = &sc->uri->data.ksk.keywords[i][1];
@@ -1253,8 +1239,8 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1253 * @return GNUNET_OK 1239 * @return GNUNET_OK
1254 */ 1240 */
1255static int 1241static int
1256search_result_freeze_probes (void *cls, 1242search_result_freeze_probes (void *cls, const GNUNET_HashCode * key,
1257 const GNUNET_HashCode * key, void *value) 1243 void *value)
1258{ 1244{
1259 struct GNUNET_FS_SearchResult *sr = value; 1245 struct GNUNET_FS_SearchResult *sr = value;
1260 1246
@@ -1283,8 +1269,8 @@ search_result_freeze_probes (void *cls,
1283 * @return GNUNET_OK 1269 * @return GNUNET_OK
1284 */ 1270 */
1285static int 1271static int
1286search_result_resume_probes (void *cls, 1272search_result_resume_probes (void *cls, const GNUNET_HashCode * key,
1287 const GNUNET_HashCode * key, void *value) 1273 void *value)
1288{ 1274{
1289 struct GNUNET_FS_SearchResult *sr = value; 1275 struct GNUNET_FS_SearchResult *sr = value;
1290 1276
@@ -1383,8 +1369,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls)
1383 */ 1369 */
1384struct GNUNET_FS_SearchContext * 1370struct GNUNET_FS_SearchContext *
1385GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, 1371GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1386 const struct GNUNET_FS_Uri *uri, 1372 const struct GNUNET_FS_Uri *uri, uint32_t anonymity,
1387 uint32_t anonymity,
1388 enum GNUNET_FS_SearchOptions options, void *cctx) 1373 enum GNUNET_FS_SearchOptions options, void *cctx)
1389{ 1374{
1390 struct GNUNET_FS_SearchContext *ret; 1375 struct GNUNET_FS_SearchContext *ret;
@@ -1460,13 +1445,12 @@ search_result_free (void *cls, const GNUNET_HashCode * key, void *value)
1460 if (NULL != sr->download) 1445 if (NULL != sr->download)
1461 { 1446 {
1462 sr->download->search = NULL; 1447 sr->download->search = NULL;
1463 sr->download->top = GNUNET_FS_make_top (sr->download->h, 1448 sr->download->top =
1464 &GNUNET_FS_download_signal_suspend_, 1449 GNUNET_FS_make_top (sr->download->h,
1465 sr->download); 1450 &GNUNET_FS_download_signal_suspend_, sr->download);
1466 if (NULL != sr->download->serialization) 1451 if (NULL != sr->download->serialization)
1467 { 1452 {
1468 GNUNET_FS_remove_sync_file_ (sc->h, 1453 GNUNET_FS_remove_sync_file_ (sc->h, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
1469 GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
1470 sr->download->serialization); 1454 sr->download->serialization);
1471 GNUNET_free (sr->download->serialization); 1455 GNUNET_free (sr->download->serialization);
1472 sr->download->serialization = NULL; 1456 sr->download->serialization = NULL;
@@ -1519,14 +1503,14 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
1519 if (sc->serialization != NULL) 1503 if (sc->serialization != NULL)
1520 { 1504 {
1521 GNUNET_FS_remove_sync_file_ (sc->h, 1505 GNUNET_FS_remove_sync_file_ (sc->h,
1522 (sc->psearch_result != NULL) 1506 (sc->psearch_result !=
1523 ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH 1507 NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH :
1524 : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, 1508 GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
1525 sc->serialization); 1509 sc->serialization);
1526 GNUNET_FS_remove_sync_dir_ (sc->h, 1510 GNUNET_FS_remove_sync_dir_ (sc->h,
1527 (sc->psearch_result != NULL) 1511 (sc->psearch_result !=
1528 ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH 1512 NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH :
1529 : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, 1513 GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
1530 sc->serialization); 1514 sc->serialization);
1531 GNUNET_free (sc->serialization); 1515 GNUNET_free (sc->serialization);
1532 } 1516 }
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index 334432232..17291d1bd 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -151,8 +151,8 @@ shutdown_callback (void *cls, const char *emsg)
151 151
152 if (emsg != NULL) 152 if (emsg != NULL)
153 { 153 {
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown of peers failed: %s\n",
155 "Shutdown of peers failed: %s\n", emsg); 155 emsg);
156 } 156 }
157 else 157 else
158 { 158 {
@@ -213,23 +213,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
213 break; 213 break;
214 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 214 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
215 if (daemon->verbose) 215 if (daemon->verbose)
216 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 216 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Publishing at %llu/%llu bytes\n",
217 "Publishing at %llu/%llu bytes\n",
218 (unsigned long long) info->value.publish.completed, 217 (unsigned long long) info->value.publish.completed,
219 (unsigned long long) info->value.publish.size); 218 (unsigned long long) info->value.publish.size);
220 break; 219 break;
221 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 220 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
222 if (daemon->verbose) 221 if (daemon->verbose)
223 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 222 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n",
224 "Download at %llu/%llu bytes\n",
225 (unsigned long long) info->value.download.completed, 223 (unsigned long long) info->value.download.completed,
226 (unsigned long long) info->value.download.size); 224 (unsigned long long) info->value.download.size);
227 break; 225 break;
228 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 226 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
229 GNUNET_SCHEDULER_cancel (daemon->download_timeout_task); 227 GNUNET_SCHEDULER_cancel (daemon->download_timeout_task);
230 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; 228 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
231 GNUNET_SCHEDULER_add_continuation (&report_success, 229 GNUNET_SCHEDULER_add_continuation (&report_success, daemon,
232 daemon,
233 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 230 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
234 break; 231 break;
235 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 232 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
@@ -260,8 +257,7 @@ struct StartContext
260 257
261 258
262static void 259static void
263notify_running (void *cls, 260notify_running (void *cls, const struct GNUNET_PeerIdentity *id,
264 const struct GNUNET_PeerIdentity *id,
265 const struct GNUNET_CONFIGURATION_Handle *cfg, 261 const struct GNUNET_CONFIGURATION_Handle *cfg,
266 struct GNUNET_TESTING_Daemon *d, const char *emsg) 262 struct GNUNET_TESTING_Daemon *d, const char *emsg)
267{ 263{
@@ -270,8 +266,8 @@ notify_running (void *cls,
270 266
271 if (emsg != NULL) 267 if (emsg != NULL)
272 { 268 {
273 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start daemon: %s\n"),
274 _("Failed to start daemon: %s\n"), emsg); 270 emsg);
275 return; 271 return;
276 } 272 }
277 i = 0; 273 i = 0;
@@ -291,19 +287,16 @@ notify_running (void *cls,
291 sctx->have++; 287 sctx->have++;
292 if (sctx->have == sctx->total) 288 if (sctx->have == sctx->total)
293 { 289 {
294 GNUNET_SCHEDULER_add_continuation (sctx->cont, 290 GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls,
295 sctx->cont_cls,
296 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 291 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
297 sctx->daemons[0]->gcfg = sctx->cfg; 292 sctx->daemons[0]->gcfg = sctx->cfg;
298 GNUNET_SCHEDULER_cancel (sctx->timeout_task); 293 GNUNET_SCHEDULER_cancel (sctx->timeout_task);
299 for (i = 0; i < sctx->total; i++) 294 for (i = 0; i < sctx->total; i++)
300 { 295 {
301 sctx->daemons[i]->fs = GNUNET_FS_start (sctx->daemons[i]->cfg, 296 sctx->daemons[i]->fs =
302 "<tester>", 297 GNUNET_FS_start (sctx->daemons[i]->cfg, "<tester>", &progress_cb,
303 &progress_cb, 298 sctx->daemons[i], GNUNET_FS_FLAGS_NONE,
304 sctx->daemons[i], 299 GNUNET_FS_OPTIONS_END);
305 GNUNET_FS_FLAGS_NONE,
306 GNUNET_FS_OPTIONS_END);
307 } 300 }
308 GNUNET_free (sctx); 301 GNUNET_free (sctx);
309 } 302 }
@@ -330,8 +323,7 @@ start_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
330 sctx->daemons[i] = NULL; 323 sctx->daemons[i] = NULL;
331 } 324 }
332 GNUNET_CONFIGURATION_destroy (sctx->cfg); 325 GNUNET_CONFIGURATION_destroy (sctx->cfg);
333 GNUNET_SCHEDULER_add_continuation (sctx->cont, 326 GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls,
334 sctx->cont_cls,
335 GNUNET_SCHEDULER_REASON_TIMEOUT); 327 GNUNET_SCHEDULER_REASON_TIMEOUT);
336 GNUNET_free (sctx); 328 GNUNET_free (sctx);
337} 329}
@@ -371,8 +363,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
371 GNUNET_break (0); 363 GNUNET_break (0);
372 GNUNET_CONFIGURATION_destroy (sctx->cfg); 364 GNUNET_CONFIGURATION_destroy (sctx->cfg);
373 GNUNET_free (sctx); 365 GNUNET_free (sctx);
374 GNUNET_SCHEDULER_add_continuation (cont, 366 GNUNET_SCHEDULER_add_continuation (cont, cont_cls,
375 cont_cls,
376 GNUNET_SCHEDULER_REASON_TIMEOUT); 367 GNUNET_SCHEDULER_REASON_TIMEOUT);
377 return; 368 return;
378 } 369 }
@@ -380,13 +371,11 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
380 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); 371 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
381 sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */ 372 sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */
382 total, /* Outstanding ssh connections */ 373 total, /* Outstanding ssh connections */
383 timeout, 374 timeout, NULL, NULL,
384 NULL, 375 &notify_running, sctx, NULL, NULL,
385 NULL, 376 NULL);
386 &notify_running, 377 sctx->timeout_task =
387 sctx, NULL, NULL, NULL); 378 GNUNET_SCHEDULER_add_delayed (timeout, &start_timeout, sctx);
388 sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
389 &start_timeout, sctx);
390} 379}
391 380
392 381
@@ -412,10 +401,8 @@ struct ConnectContext
412 * @param emsg error message (NULL on success) 401 * @param emsg error message (NULL on success)
413 */ 402 */
414static void 403static void
415notify_connection (void *cls, 404notify_connection (void *cls, const struct GNUNET_PeerIdentity *first,
416 const struct GNUNET_PeerIdentity *first, 405 const struct GNUNET_PeerIdentity *second, uint32_t distance,
417 const struct GNUNET_PeerIdentity *second,
418 uint32_t distance,
419 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 406 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
420 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 407 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
421 struct GNUNET_TESTING_Daemon *first_daemon, 408 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -425,13 +412,12 @@ notify_connection (void *cls,
425 struct ConnectContext *cc = cls; 412 struct ConnectContext *cc = cls;
426 413
427 if (emsg != NULL) 414 if (emsg != NULL)
428 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 415 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n",
429 "Failed to connect peers: %s\n", emsg); 416 emsg);
430 GNUNET_SCHEDULER_add_continuation (cc->cont, 417 GNUNET_SCHEDULER_add_continuation (cc->cont, cc->cont_cls,
431 cc->cont_cls, 418 (emsg !=
432 (emsg != NULL) 419 NULL) ? GNUNET_SCHEDULER_REASON_TIMEOUT :
433 ? GNUNET_SCHEDULER_REASON_TIMEOUT 420 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
434 : GNUNET_SCHEDULER_REASON_PREREQ_DONE);
435 GNUNET_free (cc); 421 GNUNET_free (cc);
436} 422}
437 423
@@ -457,11 +443,9 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
457 ncc = GNUNET_malloc (sizeof (struct ConnectContext)); 443 ncc = GNUNET_malloc (sizeof (struct ConnectContext));
458 ncc->cont = cont; 444 ncc->cont = cont;
459 ncc->cont_cls = cont_cls; 445 ncc->cont_cls = cont_cls;
460 GNUNET_TESTING_daemons_connect (daemon1->daemon, 446 GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout,
461 daemon2->daemon, 447 CONNECT_ATTEMPTS, GNUNET_YES,
462 timeout, 448 &notify_connection, ncc);
463 CONNECT_ATTEMPTS,
464 GNUNET_YES, &notify_connection, ncc);
465} 449}
466 450
467 451
@@ -610,11 +594,8 @@ file_generator (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
610 */ 594 */
611void 595void
612GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, 596GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
613 struct GNUNET_TIME_Relative timeout, 597 struct GNUNET_TIME_Relative timeout, uint32_t anonymity,
614 uint32_t anonymity, 598 int do_index, uint64_t size, uint32_t seed,
615 int do_index,
616 uint64_t size,
617 uint32_t seed,
618 unsigned int verbose, 599 unsigned int verbose,
619 GNUNET_FS_TEST_UriContinuation cont, void *cont_cls) 600 GNUNET_FS_TEST_UriContinuation cont, void *cont_cls)
620{ 601{
@@ -657,29 +638,23 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
657 off += bsize; 638 off += bsize;
658 } 639 }
659 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); 640 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
660 fi = GNUNET_FS_file_information_create_from_file (daemon->fs, 641 fi = GNUNET_FS_file_information_create_from_file (daemon->fs, daemon,
661 daemon,
662 daemon->publish_tmp_file, 642 daemon->publish_tmp_file,
663 NULL, NULL, 643 NULL, NULL, do_index,
664 do_index, &bo); 644 &bo);
665 } 645 }
666 else 646 else
667 { 647 {
668 fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, 648 fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, daemon,
669 daemon, 649 size, &file_generator,
670 size, 650 daemon, NULL, NULL,
671 &file_generator, 651 do_index, &bo);
672 daemon,
673 NULL,
674 NULL, do_index, &bo);
675 } 652 }
676 daemon->publish_context = GNUNET_FS_publish_start (daemon->fs, 653 daemon->publish_context =
677 fi, 654 GNUNET_FS_publish_start (daemon->fs, fi, NULL, NULL, NULL,
678 NULL, NULL, NULL, 655 GNUNET_FS_PUBLISH_OPTION_NONE);
679 GNUNET_FS_PUBLISH_OPTION_NONE); 656 daemon->publish_timeout_task =
680 daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, 657 GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, daemon);
681 &publish_timeout,
682 daemon);
683} 658}
684 659
685 660
@@ -716,10 +691,8 @@ download_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
716void 691void
717GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, 692GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
718 struct GNUNET_TIME_Relative timeout, 693 struct GNUNET_TIME_Relative timeout,
719 uint32_t anonymity, 694 uint32_t anonymity, uint32_t seed,
720 uint32_t seed, 695 const struct GNUNET_FS_Uri *uri, unsigned int verbose,
721 const struct GNUNET_FS_Uri *uri,
722 unsigned int verbose,
723 GNUNET_SCHEDULER_Task cont, void *cont_cls) 696 GNUNET_SCHEDULER_Task cont, void *cont_cls)
724{ 697{
725 uint64_t size; 698 uint64_t size;
@@ -730,18 +703,12 @@ GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
730 daemon->download_cont = cont; 703 daemon->download_cont = cont;
731 daemon->download_cont_cls = cont_cls; 704 daemon->download_cont_cls = cont_cls;
732 daemon->download_seed = seed; 705 daemon->download_seed = seed;
733 daemon->download_context = GNUNET_FS_download_start (daemon->fs, 706 daemon->download_context =
734 uri, 707 GNUNET_FS_download_start (daemon->fs, uri, NULL, NULL, NULL, 0, size,
735 NULL, NULL, 708 anonymity, GNUNET_FS_DOWNLOAD_OPTION_NONE, NULL,
736 NULL, 709 NULL);
737 0, 710 daemon->download_timeout_task =
738 size, 711 GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, daemon);
739 anonymity,
740 GNUNET_FS_DOWNLOAD_OPTION_NONE,
741 NULL, NULL);
742 daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
743 &download_timeout,
744 daemon);
745} 712}
746 713
747/* end of test_fs_lib.c */ 714/* end of test_fs_lib.c */
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c
index 5584ad868..0a0db7a10 100644
--- a/src/fs/fs_tree.c
+++ b/src/fs/fs_tree.c
@@ -221,8 +221,8 @@ GNUNET_FS_tree_compute_iblock_size (unsigned int depth, uint64_t end_offset)
221 * @return number of bytes stored in this node 221 * @return number of bytes stored in this node
222 */ 222 */
223size_t 223size_t
224GNUNET_FS_tree_calculate_block_size (uint64_t fsize, 224GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
225 uint64_t offset, unsigned int depth) 225 unsigned int depth)
226{ 226{
227 size_t ret; 227 size_t ret;
228 uint64_t rsize; 228 uint64_t rsize;
@@ -268,10 +268,8 @@ GNUNET_FS_tree_calculate_block_size (uint64_t fsize,
268 * @param cont function to call when done 268 * @param cont function to call when done
269 */ 269 */
270struct GNUNET_FS_TreeEncoder * 270struct GNUNET_FS_TreeEncoder *
271GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, 271GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size,
272 uint64_t size, 272 void *cls, GNUNET_FS_DataReader reader,
273 void *cls,
274 GNUNET_FS_DataReader reader,
275 GNUNET_FS_TreeBlockProcessor proc, 273 GNUNET_FS_TreeBlockProcessor proc,
276 GNUNET_FS_TreeProgressCallback progress, 274 GNUNET_FS_TreeProgressCallback progress,
277 GNUNET_SCHEDULER_Task cont) 275 GNUNET_SCHEDULER_Task cont)
@@ -287,8 +285,9 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h,
287 te->progress = progress; 285 te->progress = progress;
288 te->cont = cont; 286 te->cont = cont;
289 te->chk_tree_depth = GNUNET_FS_compute_depth (size); 287 te->chk_tree_depth = GNUNET_FS_compute_depth (size);
290 te->chk_tree = GNUNET_malloc (te->chk_tree_depth * 288 te->chk_tree =
291 CHK_PER_INODE * sizeof (struct ContentHashKey)); 289 GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE *
290 sizeof (struct ContentHashKey));
292 return te; 291 return te;
293} 292}
294 293
@@ -343,8 +342,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
343 { 342 {
344 off = CHK_PER_INODE * (te->chk_tree_depth - 1); 343 off = CHK_PER_INODE * (te->chk_tree_depth - 1);
345#if DEBUG_TREE 344#if DEBUG_TREE
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE done, reading CHK `%s' from %u\n",
347 "TE done, reading CHK `%s' from %u\n",
348 GNUNET_h2s (&te->chk_tree[off].query), off); 346 GNUNET_h2s (&te->chk_tree[off].query), off);
349#endif 347#endif
350 te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 348 te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
@@ -362,8 +360,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
362 if (pt_size != 360 if (pt_size !=
363 te->reader (te->cls, te->publish_offset, pt_size, iob, &te->emsg)) 361 te->reader (te->cls, te->publish_offset, pt_size, iob, &te->emsg))
364 { 362 {
365 GNUNET_SCHEDULER_add_continuation (te->cont, 363 GNUNET_SCHEDULER_add_continuation (te->cont, te->cls,
366 te->cls,
367 GNUNET_SCHEDULER_REASON_TIMEOUT); 364 GNUNET_SCHEDULER_REASON_TIMEOUT);
368 te->in_next = GNUNET_NO; 365 te->in_next = GNUNET_NO;
369 return; 366 return;
@@ -372,16 +369,17 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
372 } 369 }
373 else 370 else
374 { 371 {
375 pt_size = GNUNET_FS_tree_compute_iblock_size (te->current_depth, 372 pt_size =
376 te->publish_offset); 373 GNUNET_FS_tree_compute_iblock_size (te->current_depth,
374 te->publish_offset);
377 pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE]; 375 pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE];
378 } 376 }
379 off = compute_chk_offset (te->current_depth, te->publish_offset); 377 off = compute_chk_offset (te->current_depth, te->publish_offset);
380#if DEBUG_TREE 378#if DEBUG_TREE
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n", 380 "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n",
383 (unsigned long long) te->publish_offset, 381 (unsigned long long) te->publish_offset, te->current_depth,
384 te->current_depth, (unsigned int) pt_size, (unsigned int) off); 382 (unsigned int) pt_size, (unsigned int) off);
385#endif 383#endif
386 mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off]; 384 mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off];
387 GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key); 385 GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key);
@@ -395,16 +393,14 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
395 te->current_depth * CHK_PER_INODE + off); 393 te->current_depth * CHK_PER_INODE + off);
396#endif 394#endif
397 if (NULL != te->proc) 395 if (NULL != te->proc)
398 te->proc (te->cls, 396 te->proc (te->cls, mychk, te->publish_offset, te->current_depth,
399 mychk, 397 (0 ==
400 te->publish_offset, 398 te->
401 te->current_depth, 399 current_depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK :
402 (0 == te->current_depth) 400 GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size);
403 ? GNUNET_BLOCK_TYPE_FS_DBLOCK
404 : GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size);
405 if (NULL != te->progress) 401 if (NULL != te->progress)
406 te->progress (te->cls, 402 te->progress (te->cls, te->publish_offset, pt_block, pt_size,
407 te->publish_offset, pt_block, pt_size, te->current_depth); 403 te->current_depth);
408 if (0 == te->current_depth) 404 if (0 == te->current_depth)
409 { 405 {
410 te->publish_offset += pt_size; 406 te->publish_offset += pt_size;
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 130b2eae2..a992c5ff6 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -84,8 +84,8 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
84 pi->value.unindex.cctx = uc->client_info; 84 pi->value.unindex.cctx = uc->client_info;
85 pi->value.unindex.filename = uc->filename; 85 pi->value.unindex.filename = uc->filename;
86 pi->value.unindex.size = uc->file_size; 86 pi->value.unindex.size = uc->file_size;
87 pi->value.unindex.eta 87 pi->value.unindex.eta =
88 = GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size); 88 GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size);
89 pi->value.unindex.duration = 89 pi->value.unindex.duration =
90 GNUNET_TIME_absolute_get_duration (uc->start_time); 90 GNUNET_TIME_absolute_get_duration (uc->start_time);
91 pi->value.unindex.completed = offset; 91 pi->value.unindex.completed = offset;
@@ -105,9 +105,8 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
105 * @param depth depth of the block in the tree, 0 for DBLOCK 105 * @param depth depth of the block in the tree, 0 for DBLOCK
106 */ 106 */
107static void 107static void
108unindex_progress (void *cls, 108unindex_progress (void *cls, uint64_t offset, const void *pt_block,
109 uint64_t offset, 109 size_t pt_size, unsigned int depth)
110 const void *pt_block, size_t pt_size, unsigned int depth)
111{ 110{
112 struct GNUNET_FS_UnindexContext *uc = cls; 111 struct GNUNET_FS_UnindexContext *uc = cls;
113 struct GNUNET_FS_ProgressInfo pi; 112 struct GNUNET_FS_ProgressInfo pi;
@@ -181,11 +180,8 @@ process_cont (void *cls, int success, const char *msg)
181 * @param block_size size of block (in bytes) 180 * @param block_size size of block (in bytes)
182 */ 181 */
183static void 182static void
184unindex_process (void *cls, 183unindex_process (void *cls, const struct ContentHashKey *chk, uint64_t offset,
185 const struct ContentHashKey *chk, 184 unsigned int depth, enum GNUNET_BLOCK_Type type,
186 uint64_t offset,
187 unsigned int depth,
188 enum GNUNET_BLOCK_Type type,
189 const void *block, uint16_t block_size) 185 const void *block, uint16_t block_size)
190{ 186{
191 struct GNUNET_FS_UnindexContext *uc = cls; 187 struct GNUNET_FS_UnindexContext *uc = cls;
@@ -209,11 +205,7 @@ unindex_process (void *cls,
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
210 "Sending REMOVE request to DATASTORE service\n"); 206 "Sending REMOVE request to DATASTORE service\n");
211#endif 207#endif
212 GNUNET_DATASTORE_remove (uc->dsh, 208 GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
213 &chk->query,
214 size,
215 data,
216 -2, 1,
217 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc); 209 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc);
218} 210}
219 211
@@ -341,8 +333,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
341 signal_unindex_error (uc); 333 signal_unindex_error (uc);
342 return; 334 return;
343 } 335 }
344 uc->fh = GNUNET_DISK_file_open (uc->filename, 336 uc->fh =
345 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 337 GNUNET_DISK_file_open (uc->filename, GNUNET_DISK_OPEN_READ,
338 GNUNET_DISK_PERM_NONE);
346 if (NULL == uc->fh) 339 if (NULL == uc->fh)
347 { 340 {
348 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); 341 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
@@ -353,12 +346,10 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
353 signal_unindex_error (uc); 346 signal_unindex_error (uc);
354 return; 347 return;
355 } 348 }
356 uc->tc = GNUNET_FS_tree_encoder_create (uc->h, 349 uc->tc =
357 uc->file_size, 350 GNUNET_FS_tree_encoder_create (uc->h, uc->file_size, uc, &unindex_reader,
358 uc, 351 &unindex_process, &unindex_progress,
359 &unindex_reader, 352 &unindex_finish);
360 &unindex_process,
361 &unindex_progress, &unindex_finish);
362 GNUNET_FS_tree_encoder_next (uc->tc); 353 GNUNET_FS_tree_encoder_next (uc->tc);
363} 354}
364 355
@@ -436,8 +427,8 @@ GNUNET_FS_unindex_signal_suspend_ (void *cls)
436 GNUNET_FS_end_top (uc->h, uc->top); 427 GNUNET_FS_end_top (uc->h, uc->top);
437 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND; 428 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
438 GNUNET_FS_unindex_make_status_ (&pi, uc, 429 GNUNET_FS_unindex_make_status_ (&pi, uc,
439 (uc->state == UNINDEX_STATE_COMPLETE) 430 (uc->state ==
440 ? uc->file_size : 0); 431 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
441 GNUNET_break (NULL == uc->client_info); 432 GNUNET_break (NULL == uc->client_info);
442 GNUNET_free (uc->filename); 433 GNUNET_free (uc->filename);
443 GNUNET_free_non_null (uc->serialization); 434 GNUNET_free_non_null (uc->serialization);
@@ -455,8 +446,8 @@ GNUNET_FS_unindex_signal_suspend_ (void *cls)
455 * @return NULL on error, otherwise handle 446 * @return NULL on error, otherwise handle
456 */ 447 */
457struct GNUNET_FS_UnindexContext * 448struct GNUNET_FS_UnindexContext *
458GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, 449GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename,
459 const char *filename, void *cctx) 450 void *cctx)
460{ 451{
461 struct GNUNET_FS_UnindexContext *ret; 452 struct GNUNET_FS_UnindexContext *ret;
462 struct GNUNET_FS_ProgressInfo pi; 453 struct GNUNET_FS_ProgressInfo pi;
@@ -474,10 +465,10 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
474 pi.status = GNUNET_FS_STATUS_UNINDEX_START; 465 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
475 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 466 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
476 GNUNET_FS_unindex_make_status_ (&pi, ret, 0); 467 GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
477 ret->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, 468 ret->fhc =
478 filename, 469 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, filename,
479 HASHING_BLOCKSIZE, 470 HASHING_BLOCKSIZE,
480 &GNUNET_FS_unindex_process_hash_, ret); 471 &GNUNET_FS_unindex_process_hash_, ret);
481 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, ret); 472 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, ret);
482 return ret; 473 return ret;
483} 474}
@@ -529,8 +520,8 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
529 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED; 520 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED;
530 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; 521 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
531 GNUNET_FS_unindex_make_status_ (&pi, uc, 522 GNUNET_FS_unindex_make_status_ (&pi, uc,
532 (uc->state == UNINDEX_STATE_COMPLETE) 523 (uc->state ==
533 ? uc->file_size : 0); 524 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
534 GNUNET_break (NULL == uc->client_info); 525 GNUNET_break (NULL == uc->client_info);
535 GNUNET_free (uc->filename); 526 GNUNET_free (uc->filename);
536 GNUNET_free (uc); 527 GNUNET_free (uc);
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 5d5d24ca8..22dab4955 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -419,15 +419,12 @@ uri_chk_parse (const char *s, char **emsg)
419 } 419 }
420 memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 420 memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
421 h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; 421 h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
422 memcpy (h2, 422 memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
423 &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
424 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 423 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
425 h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; 424 h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
426 425
427 if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, 426 if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &fi.chk.key)) ||
428 &fi.chk.key)) || 427 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &fi.chk.query)) ||
429 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2,
430 &fi.chk.query)) ||
431 (1 != 428 (1 !=
432 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], 429 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
433 "%llu", &flen))) 430 "%llu", &flen)))
@@ -567,15 +564,12 @@ uri_loc_parse (const char *s, char **emsg)
567 } 564 }
568 memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 565 memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
569 h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; 566 h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
570 memcpy (h2, 567 memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
571 &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)],
572 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 568 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
573 h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; 569 h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
574 570
575 if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, 571 if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &ass.fi.chk.key)) ||
576 &ass.fi.chk.key)) || 572 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &ass.fi.chk.query)) ||
577 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2,
578 &ass.fi.chk.query)) ||
579 (1 != 573 (1 !=
580 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], 574 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
581 "%llu", &flen))) 575 "%llu", &flen)))
@@ -594,9 +588,9 @@ uri_loc_parse (const char *s, char **emsg)
594 goto ERR; 588 goto ERR;
595 } 589 }
596 npos++; 590 npos++;
597 ret = enc2bin (&s[npos], 591 ret =
598 &ass.peer, 592 enc2bin (&s[npos], &ass.peer,
599 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 593 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
600 if (ret == -1) 594 if (ret == -1)
601 { 595 {
602 *emsg = 596 *emsg =
@@ -769,8 +763,8 @@ GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri,
769 * @param is_mandatory is this keyword mandatory? 763 * @param is_mandatory is this keyword mandatory?
770 */ 764 */
771void 765void
772GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, 766GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keyword,
773 const char *keyword, int is_mandatory) 767 int is_mandatory)
774{ 768{
775 unsigned int i; 769 unsigned int i;
776 const char *old; 770 const char *old;
@@ -896,8 +890,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
896 if (baseUri->type != chk) 890 if (baseUri->type != chk)
897 return NULL; 891 return NULL;
898 if (GNUNET_OK != 892 if (GNUNET_OK !=
899 GNUNET_CONFIGURATION_get_value_filename (cfg, 893 GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY",
900 "GNUNETD", "HOSTKEY", &keyfile)) 894 &keyfile))
901 { 895 {
902 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 896 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
903 _("Lacking key configuration settings.\n")); 897 _("Lacking key configuration settings.\n"));
@@ -924,8 +918,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
924 uri->data.loc.expirationTime = expiration_time; 918 uri->data.loc.expirationTime = expiration_time;
925 uri->data.loc.peer = my_public_key; 919 uri->data.loc.peer = my_public_key;
926 GNUNET_assert (GNUNET_OK == 920 GNUNET_assert (GNUNET_OK ==
927 GNUNET_CRYPTO_rsa_sign (my_private_key, 921 GNUNET_CRYPTO_rsa_sign (my_private_key, &ass.purpose,
928 &ass.purpose,
929 &uri->data.loc.contentSignature)); 922 &uri->data.loc.contentSignature));
930 GNUNET_CRYPTO_rsa_key_free (my_private_key); 923 GNUNET_CRYPTO_rsa_key_free (my_private_key);
931 return uri; 924 return uri;
@@ -941,8 +934,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
941 * @return an FS URI for the given namespace and identifier 934 * @return an FS URI for the given namespace and identifier
942 */ 935 */
943struct GNUNET_FS_Uri * 936struct GNUNET_FS_Uri *
944GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, 937GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id,
945 const char *id, char **emsg) 938 char **emsg)
946{ 939{
947 struct GNUNET_FS_Uri *ns_uri; 940 struct GNUNET_FS_Uri *ns_uri;
948 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; 941 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk;
@@ -1166,8 +1159,8 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
1166 } 1159 }
1167 if (ret->data.ksk.keywordCount > 0) 1160 if (ret->data.ksk.keywordCount > 0)
1168 { 1161 {
1169 ret->data.ksk.keywords 1162 ret->data.ksk.keywords =
1170 = GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); 1163 GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *));
1171 for (i = 0; i < ret->data.ksk.keywordCount; i++) 1164 for (i = 0; i < ret->data.ksk.keywordCount; i++)
1172 ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]); 1165 ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]);
1173 } 1166 }
@@ -1315,8 +1308,7 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv)
1315 /* allow URI to be given as one and only keyword and 1308 /* allow URI to be given as one and only keyword and
1316 * handle accordingly */ 1309 * handle accordingly */
1317 emsg = NULL; 1310 emsg = NULL;
1318 if ((argc == 1) && 1311 if ((argc == 1) && (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) &&
1319 (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) &&
1320 (0 == 1312 (0 ==
1321 strncmp (argv[0], GNUNET_FS_URI_PREFIX, strlen (GNUNET_FS_URI_PREFIX))) 1313 strncmp (argv[0], GNUNET_FS_URI_PREFIX, strlen (GNUNET_FS_URI_PREFIX)))
1322 && (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg)))) 1314 && (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg))))
@@ -1371,14 +1363,14 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
1371 switch (u1->type) 1363 switch (u1->type)
1372 { 1364 {
1373 case chk: 1365 case chk:
1374 if (0 == memcmp (&u1->data.chk, 1366 if (0 ==
1375 &u2->data.chk, sizeof (struct FileIdentifier))) 1367 memcmp (&u1->data.chk, &u2->data.chk, sizeof (struct FileIdentifier)))
1376 return GNUNET_YES; 1368 return GNUNET_YES;
1377 return GNUNET_NO; 1369 return GNUNET_NO;
1378 case sks: 1370 case sks:
1379 if ((0 == memcmp (&u1->data.sks.namespace, 1371 if ((0 ==
1380 &u2->data.sks.namespace, 1372 memcmp (&u1->data.sks.namespace, &u2->data.sks.namespace,
1381 sizeof (GNUNET_HashCode))) && 1373 sizeof (GNUNET_HashCode))) &&
1382 (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier))) 1374 (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier)))
1383 1375
1384 return GNUNET_YES; 1376 return GNUNET_YES;
@@ -1402,12 +1394,12 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
1402 } 1394 }
1403 return GNUNET_YES; 1395 return GNUNET_YES;
1404 case loc: 1396 case loc:
1405 if (memcmp (&u1->data.loc, 1397 if (memcmp
1406 &u2->data.loc, 1398 (&u1->data.loc, &u2->data.loc,
1407 sizeof (struct FileIdentifier) + 1399 sizeof (struct FileIdentifier) +
1408 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + 1400 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
1409 sizeof (struct GNUNET_TIME_Absolute) + 1401 sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) +
1410 sizeof (unsigned short) + sizeof (unsigned short)) != 0) 1402 sizeof (unsigned short)) != 0)
1411 return GNUNET_NO; 1403 return GNUNET_NO;
1412 return GNUNET_YES; 1404 return GNUNET_YES;
1413 default: 1405 default:
@@ -1584,10 +1576,8 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri)
1584 * @return 0 (always) 1576 * @return 0 (always)
1585 */ 1577 */
1586static int 1578static int
1587gather_uri_data (void *cls, 1579gather_uri_data (void *cls, const char *plugin_name,
1588 const char *plugin_name, 1580 enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
1589 enum EXTRACTOR_MetaType type,
1590 enum EXTRACTOR_MetaFormat format,
1591 const char *data_mime_type, const char *data, size_t data_len) 1581 const char *data_mime_type, const char *data, size_t data_len)
1592{ 1582{
1593 struct GNUNET_FS_Uri *uri = cls; 1583 struct GNUNET_FS_Uri *uri = cls;
@@ -1643,8 +1633,9 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
1643static int 1633static int
1644needs_percent (char c) 1634needs_percent (char c)
1645{ 1635{
1646 return (!((isalnum ((unsigned char) c)) || 1636 return (!
1647 (c == '-') || (c == '_') || (c == '.') || (c == '~'))); 1637 ((isalnum ((unsigned char) c)) || (c == '-') || (c == '_') ||
1638 (c == '.') || (c == '~')));
1648} 1639}
1649 1640
1650 1641
@@ -1737,9 +1728,7 @@ uri_sks_to_string (const struct GNUNET_FS_Uri *uri)
1737 namespace = &uri->data.sks.namespace; 1728 namespace = &uri->data.sks.namespace;
1738 identifier = uri->data.sks.identifier; 1729 identifier = uri->data.sks.identifier;
1739 GNUNET_CRYPTO_hash_to_enc (namespace, &ns); 1730 GNUNET_CRYPTO_hash_to_enc (namespace, &ns);
1740 GNUNET_asprintf (&ret, 1731 GNUNET_asprintf (&ret, "%s%s%s/%s", GNUNET_FS_URI_PREFIX,
1741 "%s%s%s/%s",
1742 GNUNET_FS_URI_PREFIX,
1743 GNUNET_FS_URI_SKS_INFIX, (const char *) &ns, identifier); 1732 GNUNET_FS_URI_SKS_INFIX, (const char *) &ns, identifier);
1744 return ret; 1733 return ret;
1745} 1734}
@@ -1765,11 +1754,8 @@ uri_chk_to_string (const struct GNUNET_FS_Uri *uri)
1765 GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash); 1754 GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash);
1766 GNUNET_CRYPTO_hash_to_enc (&fi->chk.query, &queryhash); 1755 GNUNET_CRYPTO_hash_to_enc (&fi->chk.query, &queryhash);
1767 1756
1768 GNUNET_asprintf (&ret, 1757 GNUNET_asprintf (&ret, "%s%s%s.%s.%llu", GNUNET_FS_URI_PREFIX,
1769 "%s%s%s.%s.%llu", 1758 GNUNET_FS_URI_CHK_INFIX, (const char *) &keyhash,
1770 GNUNET_FS_URI_PREFIX,
1771 GNUNET_FS_URI_CHK_INFIX,
1772 (const char *) &keyhash,
1773 (const char *) &queryhash, GNUNET_ntohll (fi->file_length)); 1759 (const char *) &queryhash, GNUNET_ntohll (fi->file_length));
1774 return ret; 1760 return ret;
1775} 1761}
@@ -1839,18 +1825,17 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
1839 1825
1840 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.key, &keyhash); 1826 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.key, &keyhash);
1841 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); 1827 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash);
1842 peerId = bin2enc (&uri->data.loc.peer, 1828 peerId =
1843 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 1829 bin2enc (&uri->data.loc.peer,
1844 peerSig = bin2enc (&uri->data.loc.contentSignature, 1830 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
1845 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 1831 peerSig =
1846 GNUNET_asprintf (&ret, 1832 bin2enc (&uri->data.loc.contentSignature,
1847 "%s%s%s.%s.%llu.%s.%s.%llu", 1833 sizeof (struct GNUNET_CRYPTO_RsaSignature));
1848 GNUNET_FS_URI_PREFIX, 1834 GNUNET_asprintf (&ret, "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX,
1849 GNUNET_FS_URI_LOC_INFIX, 1835 GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash,
1850 (const char *) &keyhash,
1851 (const char *) &queryhash, 1836 (const char *) &queryhash,
1852 (unsigned long long) GNUNET_ntohll (uri->data.loc. 1837 (unsigned long long) GNUNET_ntohll (uri->data.loc.fi.
1853 fi.file_length), peerId, 1838 file_length), peerId,
1854 peerSig, 1839 peerSig,
1855 (unsigned long long) uri->data.loc.expirationTime.abs_value); 1840 (unsigned long long) uri->data.loc.expirationTime.abs_value);
1856 GNUNET_free (peerSig); 1841 GNUNET_free (peerSig);
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index a6fa42664..f2b99f48d 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -40,11 +40,9 @@ static int ret;
40 * @return always 0 (to continue iterating) 40 * @return always 0 (to continue iterating)
41 */ 41 */
42static int 42static int
43item_printer (void *cls, 43item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
44 const char *plugin_name, 44 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
45 enum EXTRACTOR_MetaType type, 45 const char *data, size_t data_size)
46 enum EXTRACTOR_MetaFormat format,
47 const char *data_mime_type, const char *data, size_t data_size)
48{ 46{
49 if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA) 47 if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
50 { 48 {
@@ -81,17 +79,16 @@ item_printer (void *cls,
81 * @param data data available for the file (length bytes) 79 * @param data data available for the file (length bytes)
82 */ 80 */
83static void 81static void
84print_entry (void *cls, 82print_entry (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
85 const char *filename, 83 const struct GNUNET_CONTAINER_MetaData *meta, size_t length,
86 const struct GNUNET_FS_Uri *uri, 84 const void *data)
87 const struct GNUNET_CONTAINER_MetaData *meta,
88 size_t length, const void *data)
89{ 85{
90 char *string; 86 char *string;
91 char *name; 87 char *name;
92 88
93 name = GNUNET_CONTAINER_meta_data_get_by_type (meta, 89 name =
94 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 90 GNUNET_CONTAINER_meta_data_get_by_type (meta,
91 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
95 if (uri == NULL) 92 if (uri == NULL)
96 { 93 {
97 printf (_("Directory `%s' meta data:\n"), name); 94 printf (_("Directory `%s' meta data:\n"), name);
@@ -119,9 +116,8 @@ print_entry (void *cls,
119 * @param cfg configuration 116 * @param cfg configuration
120 */ 117 */
121static void 118static void
122run (void *cls, 119run (void *cls, char *const *args, const char *cfgfile,
123 char *const *args, 120 const struct GNUNET_CONFIGURATION_Handle *cfg)
124 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
125{ 121{
126 struct GNUNET_DISK_MapHandle *map; 122 struct GNUNET_DISK_MapHandle *map;
127 struct GNUNET_DISK_FileHandle *h; 123 struct GNUNET_DISK_FileHandle *h;
@@ -140,16 +136,14 @@ run (void *cls,
140 i = 0; 136 i = 0;
141 while (NULL != (filename = args[i++])) 137 while (NULL != (filename = args[i++]))
142 { 138 {
143 if ((GNUNET_OK != 139 if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) ||
144 GNUNET_DISK_file_size (filename, 140 (NULL ==
145 &size, 141 (h =
146 GNUNET_YES)) || 142 GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
147 (NULL == (h = GNUNET_DISK_file_open (filename, 143 GNUNET_DISK_PERM_NONE))))
148 GNUNET_DISK_OPEN_READ,
149 GNUNET_DISK_PERM_NONE))))
150 { 144 {
151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read directory `%s'\n"),
152 _("Failed to read directory `%s'\n"), filename); 146 filename);
153 ret = 1; 147 ret = 1;
154 continue; 148 continue;
155 } 149 }
@@ -177,9 +171,7 @@ main (int argc, char *const *argv)
177 GNUNET_GETOPT_OPTION_END 171 GNUNET_GETOPT_OPTION_END
178 }; 172 };
179 return (GNUNET_OK == 173 return (GNUNET_OK ==
180 GNUNET_PROGRAM_run (argc, 174 GNUNET_PROGRAM_run (argc, argv, "gnunet-directory [OPTIONS] FILENAME",
181 argv,
182 "gnunet-directory [OPTIONS] FILENAME",
183 gettext_noop 175 gettext_noop
184 ("Display contents of a GNUnet directory"), 176 ("Display contents of a GNUnet directory"),
185 options, &run, NULL)) ? ret : 1; 177 options, &run, NULL)) ? ret : 1;
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index fc0b768d9..9f18cb99c 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -97,8 +97,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
97 { 97 {
98 case GNUNET_FS_STATUS_DOWNLOAD_START: 98 case GNUNET_FS_STATUS_DOWNLOAD_START:
99 if (verbose > 1) 99 if (verbose > 1)
100 fprintf (stderr, 100 fprintf (stderr, _("Starting download `%s'.\n"),
101 _("Starting download `%s'.\n"), info->value.download.filename); 101 info->value.download.filename);
102 break; 102 break;
103 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 103 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
104 if (verbose) 104 if (verbose)
@@ -106,8 +106,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
106 s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta); 106 s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta);
107 t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 107 t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
108 1000LL / 108 1000LL /
109 (info->value.download. 109 (info->value.download.duration.
110 duration.rel_value + 1)); 110 rel_value + 1));
111 fprintf (stdout, 111 fprintf (stdout,
112 _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"), 112 _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"),
113 info->value.download.filename, 113 info->value.download.filename,
@@ -118,15 +118,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
118 } 118 }
119 break; 119 break;
120 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 120 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
121 fprintf (stderr, 121 fprintf (stderr, _("Error downloading: %s.\n"),
122 _("Error downloading: %s.\n"),
123 info->value.download.specifics.error.message); 122 info->value.download.specifics.error.message);
124 GNUNET_SCHEDULER_shutdown (); 123 GNUNET_SCHEDULER_shutdown ();
125 break; 124 break;
126 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 125 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
127 s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 / 126 s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 /
128 (info->value.download. 127 (info->value.download.duration.
129 duration.rel_value + 1)); 128 rel_value + 1));
130 fprintf (stdout, _("Downloading `%s' done (%s/s).\n"), 129 fprintf (stdout, _("Downloading `%s' done (%s/s).\n"),
131 info->value.download.filename, s); 130 info->value.download.filename, s);
132 GNUNET_free (s); 131 GNUNET_free (s);
@@ -135,8 +134,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
135 break; 134 break;
136 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 135 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
137 if (info->value.download.dc == dc) 136 if (info->value.download.dc == dc)
138 GNUNET_SCHEDULER_add_continuation (&cleanup_task, 137 GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL,
139 NULL,
140 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 138 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
141 break; 139 break;
142 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: 140 case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
@@ -159,9 +157,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
159 * @param c configuration 157 * @param c configuration
160 */ 158 */
161static void 159static void
162run (void *cls, 160run (void *cls, char *const *args, const char *cfgfile,
163 char *const *args, 161 const struct GNUNET_CONFIGURATION_Handle *c)
164 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
165{ 162{
166 struct GNUNET_FS_Uri *uri; 163 struct GNUNET_FS_Uri *uri;
167 char *emsg; 164 char *emsg;
@@ -195,15 +192,12 @@ run (void *cls,
195 return; 192 return;
196 } 193 }
197 cfg = c; 194 cfg = c;
198 ctx = GNUNET_FS_start (cfg, 195 ctx =
199 "gnunet-download", 196 GNUNET_FS_start (cfg, "gnunet-download", &progress_cb, NULL,
200 &progress_cb, 197 GNUNET_FS_FLAGS_NONE,
201 NULL, 198 GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, parallelism,
202 GNUNET_FS_FLAGS_NONE, 199 GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
203 GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, 200 request_parallelism, GNUNET_FS_OPTIONS_END);
204 parallelism,
205 GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
206 request_parallelism, GNUNET_FS_OPTIONS_END);
207 if (NULL == ctx) 201 if (NULL == ctx)
208 { 202 {
209 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); 203 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
@@ -216,11 +210,7 @@ run (void *cls,
216 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; 210 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
217 if (local_only) 211 if (local_only)
218 options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY; 212 options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
219 dc = GNUNET_FS_download_start (ctx, 213 dc = GNUNET_FS_download_start (ctx, uri, NULL, filename, NULL, 0,
220 uri,
221 NULL,
222 filename, NULL,
223 0,
224 GNUNET_FS_uri_chk_get_file_size (uri), 214 GNUNET_FS_uri_chk_get_file_size (uri),
225 anonymity, options, NULL, NULL); 215 anonymity, options, NULL, NULL);
226 GNUNET_FS_uri_destroy (uri); 216 GNUNET_FS_uri_destroy (uri);
@@ -230,8 +220,8 @@ run (void *cls,
230 ctx = NULL; 220 ctx = NULL;
231 return; 221 return;
232 } 222 }
233 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 223 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
234 &shutdown_task, NULL); 224 NULL);
235} 225}
236 226
237 227
@@ -275,9 +265,7 @@ main (int argc, char *const *argv)
275 GNUNET_GETOPT_OPTION_END 265 GNUNET_GETOPT_OPTION_END
276 }; 266 };
277 return (GNUNET_OK == 267 return (GNUNET_OK ==
278 GNUNET_PROGRAM_run (argc, 268 GNUNET_PROGRAM_run (argc, argv, "gnunet-download [OPTIONS] URI",
279 argv,
280 "gnunet-download [OPTIONS] URI",
281 gettext_noop 269 gettext_noop
282 ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"), 270 ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"),
283 options, &run, NULL)) ? ret : 1; 271 options, &run, NULL)) ? ret : 1;
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
index 742111c4e..ce0d24506 100644
--- a/src/fs/gnunet-pseudonym.c
+++ b/src/fs/gnunet-pseudonym.c
@@ -105,9 +105,7 @@ ns_printer (void *cls, const char *name, const GNUNET_HashCode * id)
105 105
106 106
107static int 107static int
108pseudo_printer (void *cls, 108pseudo_printer (void *cls, const GNUNET_HashCode * pseudonym,
109 const GNUNET_HashCode *
110 pseudonym,
111 const struct GNUNET_CONTAINER_MetaData *md, int rating) 109 const struct GNUNET_CONTAINER_MetaData *md, int rating)
112{ 110{
113 char *id; 111 char *id;
@@ -150,8 +148,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
150 set++; 148 set++;
151 if (*set != ':') 149 if (*set != ':')
152 { 150 {
153 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid argument `%s'\n"),
154 _("Invalid argument `%s'\n"), rating_change); 152 rating_change);
155 } 153 }
156 else 154 else
157 { 155 {
@@ -164,8 +162,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
164 } 162 }
165 else 163 else
166 { 164 {
167 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namespace `%s' unknown.\n"),
168 _("Namespace `%s' unknown.\n"), rating_change); 166 rating_change);
169 } 167 }
170 } 168 }
171 GNUNET_free (rating_change); 169 GNUNET_free (rating_change);
@@ -192,17 +190,14 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
192 * @param c configuration 190 * @param c configuration
193 */ 191 */
194static void 192static void
195run (void *cls, 193run (void *cls, char *const *args, const char *cfgfile,
196 char *const *args, 194 const struct GNUNET_CONFIGURATION_Handle *c)
197 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
198{ 195{
199 char *emsg; 196 char *emsg;
200 197
201 cfg = c; 198 cfg = c;
202 h = GNUNET_FS_start (cfg, 199 h = GNUNET_FS_start (cfg, "gnunet-pseudonym", &progress_cb, NULL,
203 "gnunet-pseudonym", 200 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
204 &progress_cb,
205 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
206 if (NULL != delete_ns) 201 if (NULL != delete_ns)
207 { 202 {
208 ns = GNUNET_FS_namespace_create (h, delete_ns); 203 ns = GNUNET_FS_namespace_create (h, delete_ns);
@@ -234,13 +229,9 @@ run (void *cls,
234 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); 229 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg);
235 GNUNET_assert (NULL == emsg); 230 GNUNET_assert (NULL == emsg);
236 } 231 }
237 GNUNET_FS_namespace_advertise (h, 232 GNUNET_FS_namespace_advertise (h, ksk_uri, ns, adv_metadata, &bo,
238 ksk_uri, 233 root_identifier, &post_advertising,
239 ns, 234 NULL);
240 adv_metadata,
241 &bo,
242 root_identifier,
243 &post_advertising, NULL);
244 return; 235 return;
245 } 236 }
246 else 237 else
@@ -284,9 +275,8 @@ main (int argc, char *const *argv)
284 gettext_noop ("delete namespace NAME "), 275 gettext_noop ("delete namespace NAME "),
285 1, &GNUNET_GETOPT_set_string, &delete_ns}, 276 1, &GNUNET_GETOPT_set_string, &delete_ns},
286 {'k', "keyword", "VALUE", 277 {'k', "keyword", "VALUE",
287 gettext_noop 278 gettext_noop ("add an additional keyword for the advertisment"
288 ("add an additional keyword for the advertisment" 279 " (this option can be specified multiple times)"),
289 " (this option can be specified multiple times)"),
290 1, &GNUNET_FS_getopt_set_keywords, &ksk_uri}, 280 1, &GNUNET_FS_getopt_set_keywords, &ksk_uri},
291 {'m', "meta", "TYPE:VALUE", 281 {'m', "meta", "TYPE:VALUE",
292 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), 282 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 326fed3c6..a67886f7d 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -112,8 +112,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
112 if (verbose) 112 if (verbose)
113 { 113 {
114 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta); 114 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta);
115 fprintf (stdout, 115 fprintf (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
116 _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
117 info->value.publish.filename, 116 info->value.publish.filename,
118 (unsigned long long) info->value.publish.completed, 117 (unsigned long long) info->value.publish.completed,
119 (unsigned long long) info->value.publish.size, s); 118 (unsigned long long) info->value.publish.size, s);
@@ -121,23 +120,21 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
121 } 120 }
122 break; 121 break;
123 case GNUNET_FS_STATUS_PUBLISH_ERROR: 122 case GNUNET_FS_STATUS_PUBLISH_ERROR:
124 fprintf (stderr, 123 fprintf (stderr, _("Error publishing: %s.\n"),
125 _("Error publishing: %s.\n"),
126 info->value.publish.specifics.error.message); 124 info->value.publish.specifics.error.message);
127 if (kill_task != GNUNET_SCHEDULER_NO_TASK) 125 if (kill_task != GNUNET_SCHEDULER_NO_TASK)
128 { 126 {
129 GNUNET_SCHEDULER_cancel (kill_task); 127 GNUNET_SCHEDULER_cancel (kill_task);
130 kill_task = GNUNET_SCHEDULER_NO_TASK; 128 kill_task = GNUNET_SCHEDULER_NO_TASK;
131 } 129 }
132 GNUNET_SCHEDULER_add_continuation (&do_stop_task, 130 GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL,
133 NULL,
134 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 131 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
135 break; 132 break;
136 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 133 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
137 fprintf (stdout, 134 fprintf (stdout, _("Publishing `%s' done.\n"),
138 _("Publishing `%s' done.\n"), info->value.publish.filename); 135 info->value.publish.filename);
139 s = GNUNET_FS_uri_to_string (info->value.publish.specifics. 136 s = GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.
140 completed.chk_uri); 137 chk_uri);
141 fprintf (stdout, _("URI is `%s'.\n"), s); 138 fprintf (stdout, _("URI is `%s'.\n"), s);
142 GNUNET_free (s); 139 GNUNET_free (s);
143 if (info->value.publish.pctx == NULL) 140 if (info->value.publish.pctx == NULL)
@@ -147,8 +144,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
147 GNUNET_SCHEDULER_cancel (kill_task); 144 GNUNET_SCHEDULER_cancel (kill_task);
148 kill_task = GNUNET_SCHEDULER_NO_TASK; 145 kill_task = GNUNET_SCHEDULER_NO_TASK;
149 } 146 }
150 GNUNET_SCHEDULER_add_continuation (&do_stop_task, 147 GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL,
151 NULL,
152 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 148 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
153 } 149 }
154 break; 150 break;
@@ -177,11 +173,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
177 * @return always 0 173 * @return always 0
178 */ 174 */
179static int 175static int
180meta_printer (void *cls, 176meta_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
181 const char *plugin_name, 177 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
182 enum EXTRACTOR_MetaType type, 178 const char *data, size_t data_size)
183 enum EXTRACTOR_MetaFormat format,
184 const char *data_mime_type, const char *data, size_t data_size)
185{ 179{
186 if ((format != EXTRACTOR_METAFORMAT_UTF8) && 180 if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
187 (format != EXTRACTOR_METAFORMAT_C_STRING)) 181 (format != EXTRACTOR_METAFORMAT_C_STRING))
@@ -228,13 +222,11 @@ keyword_printer (void *cls, const char *keyword, int is_mandatory)
228 * to abort the iteration 222 * to abort the iteration
229 */ 223 */
230static int 224static int
231publish_inspector (void *cls, 225publish_inspector (void *cls, struct GNUNET_FS_FileInformation *fi,
232 struct GNUNET_FS_FileInformation *fi, 226 uint64_t length, struct GNUNET_CONTAINER_MetaData *m,
233 uint64_t length,
234 struct GNUNET_CONTAINER_MetaData *m,
235 struct GNUNET_FS_Uri **uri, 227 struct GNUNET_FS_Uri **uri,
236 struct GNUNET_FS_BlockOptions *bo, 228 struct GNUNET_FS_BlockOptions *bo, int *do_index,
237 int *do_index, void **client_info) 229 void **client_info)
238{ 230{
239 char *fn; 231 char *fn;
240 char *fs; 232 char *fs;
@@ -286,8 +278,8 @@ publish_inspector (void *cls,
286 278
287 279
288static void 280static void
289uri_sks_continuation (void *cls, 281uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
290 const struct GNUNET_FS_Uri *ksk_uri, const char *emsg) 282 const char *emsg)
291{ 283{
292 if (emsg != NULL) 284 if (emsg != NULL)
293 { 285 {
@@ -302,8 +294,8 @@ uri_sks_continuation (void *cls,
302 294
303 295
304static void 296static void
305uri_ksk_continuation (void *cls, 297uri_ksk_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
306 const struct GNUNET_FS_Uri *ksk_uri, const char *emsg) 298 const char *emsg)
307{ 299{
308 struct GNUNET_FS_Namespace *ns; 300 struct GNUNET_FS_Namespace *ns;
309 301
@@ -322,13 +314,7 @@ uri_ksk_continuation (void *cls,
322 } 314 }
323 else 315 else
324 { 316 {
325 GNUNET_FS_publish_sks (ctx, 317 GNUNET_FS_publish_sks (ctx, ns, this_id, next_id, meta, uri, &bo,
326 ns,
327 this_id,
328 next_id,
329 meta,
330 uri,
331 &bo,
332 GNUNET_FS_PUBLISH_OPTION_NONE, 318 GNUNET_FS_PUBLISH_OPTION_NONE,
333 uri_sks_continuation, NULL); 319 uri_sks_continuation, NULL);
334 GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_NO)); 320 GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_NO));
@@ -351,9 +337,8 @@ uri_ksk_continuation (void *cls,
351 * @param c configuration 337 * @param c configuration
352 */ 338 */
353static void 339static void
354run (void *cls, 340run (void *cls, char *const *args, const char *cfgfile,
355 char *const *args, 341 const struct GNUNET_CONFIGURATION_Handle *c)
356 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
357{ 342{
358 struct GNUNET_FS_FileInformation *fi; 343 struct GNUNET_FS_FileInformation *fi;
359 struct GNUNET_FS_Namespace *namespace; 344 struct GNUNET_FS_Namespace *namespace;
@@ -370,8 +355,8 @@ run (void *cls,
370 ret = -1; 355 ret = -1;
371 return; 356 return;
372 } 357 }
373 if (((uri_string == NULL) || (extract_only)) 358 if (((uri_string == NULL) || (extract_only)) &&
374 && ((args[0] == NULL) || (args[1] != NULL))) 359 ((args[0] == NULL) || (args[1] != NULL)))
375 { 360 {
376 printf (_("You must specify one and only one filename for insertion.\n")); 361 printf (_("You must specify one and only one filename for insertion.\n"));
377 ret = -1; 362 ret = -1;
@@ -387,8 +372,7 @@ run (void *cls,
387 { 372 {
388 if (NULL == this_id) 373 if (NULL == this_id)
389 { 374 {
390 fprintf (stderr, 375 fprintf (stderr, _("Option `%s' is required when using option `%s'.\n"),
391 _("Option `%s' is required when using option `%s'.\n"),
392 "-t", "-P"); 376 "-t", "-P");
393 ret = -1; 377 ret = -1;
394 return; 378 return;
@@ -398,26 +382,23 @@ run (void *cls,
398 { /* ordinary insertion checks */ 382 { /* ordinary insertion checks */
399 if (NULL != next_id) 383 if (NULL != next_id)
400 { 384 {
401 fprintf (stderr, 385 fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
402 _("Option `%s' makes no sense without option `%s'.\n"),
403 "-N", "-P"); 386 "-N", "-P");
404 ret = -1; 387 ret = -1;
405 return; 388 return;
406 } 389 }
407 if (NULL != this_id) 390 if (NULL != this_id)
408 { 391 {
409 fprintf (stderr, 392 fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
410 _("Option `%s' makes no sense without option `%s'.\n"),
411 "-t", "-P"); 393 "-t", "-P");
412 ret = -1; 394 ret = -1;
413 return; 395 return;
414 } 396 }
415 } 397 }
416 cfg = c; 398 cfg = c;
417 ctx = GNUNET_FS_start (cfg, 399 ctx =
418 "gnunet-publish", 400 GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL,
419 &progress_cb, 401 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
420 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
421 if (NULL == ctx) 402 if (NULL == ctx)
422 { 403 {
423 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); 404 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
@@ -450,13 +431,9 @@ run (void *cls,
450 ret = 1; 431 ret = 1;
451 return; 432 return;
452 } 433 }
453 GNUNET_FS_publish_ksk (ctx, 434 GNUNET_FS_publish_ksk (ctx, topKeywords, meta, uri, &bo,
454 topKeywords, 435 GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation,
455 meta, 436 NULL);
456 uri,
457 &bo,
458 GNUNET_FS_PUBLISH_OPTION_NONE,
459 &uri_ksk_continuation, NULL);
460 if (namespace != NULL) 437 if (namespace != NULL)
461 GNUNET_FS_namespace_delete (namespace, GNUNET_NO); 438 GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
462 return; 439 return;
@@ -484,12 +461,9 @@ run (void *cls,
484 } 461 }
485 else if (S_ISDIR (sbuf.st_mode)) 462 else if (S_ISDIR (sbuf.st_mode))
486 { 463 {
487 fi = GNUNET_FS_file_information_create_from_directory (ctx, 464 fi = GNUNET_FS_file_information_create_from_directory (ctx, NULL, args[0],
488 NULL,
489 args[0],
490 &GNUNET_FS_directory_scanner_default, 465 &GNUNET_FS_directory_scanner_default,
491 plugins, 466 plugins, !do_insert,
492 !do_insert,
493 &bo, &emsg); 467 &bo, &emsg);
494 } 468 }
495 else 469 else
@@ -498,11 +472,9 @@ run (void *cls,
498 meta = GNUNET_CONTAINER_meta_data_create (); 472 meta = GNUNET_CONTAINER_meta_data_create ();
499 GNUNET_FS_meta_data_extract_from_file (meta, args[0], plugins); 473 GNUNET_FS_meta_data_extract_from_file (meta, args[0], plugins);
500 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); 474 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
501 fi = GNUNET_FS_file_information_create_from_file (ctx, 475 fi = GNUNET_FS_file_information_create_from_file (ctx, NULL, args[0],
502 NULL, 476 keywords, NULL,
503 args[0], 477 !do_insert, &bo);
504 keywords,
505 NULL, !do_insert, &bo);
506 GNUNET_break (fi != NULL); 478 GNUNET_break (fi != NULL);
507 GNUNET_FS_uri_destroy (keywords); 479 GNUNET_FS_uri_destroy (keywords);
508 } 480 }
@@ -526,14 +498,10 @@ run (void *cls,
526 GNUNET_FS_stop (ctx); 498 GNUNET_FS_stop (ctx);
527 return; 499 return;
528 } 500 }
529 pc = GNUNET_FS_publish_start (ctx, 501 pc = GNUNET_FS_publish_start (ctx, fi, namespace, this_id, next_id,
530 fi, 502 (do_simulate) ?
531 namespace, 503 GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY :
532 this_id, 504 GNUNET_FS_PUBLISH_OPTION_NONE);
533 next_id,
534 (do_simulate)
535 ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
536 : GNUNET_FS_PUBLISH_OPTION_NONE);
537 if (NULL == pc) 505 if (NULL == pc)
538 { 506 {
539 fprintf (stderr, _("Could not start publishing.\n")); 507 fprintf (stderr, _("Could not start publishing.\n"));
@@ -541,8 +509,9 @@ run (void *cls,
541 ret = 1; 509 ret = 1;
542 return; 510 return;
543 } 511 }
544 kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 512 kill_task =
545 &do_stop_task, NULL); 513 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task,
514 NULL);
546} 515}
547 516
548 517
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 8a3e2ed6a..c82a0794c 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -70,11 +70,9 @@ static int local_only;
70 * @return 0 to continue extracting, 1 to abort 70 * @return 0 to continue extracting, 1 to abort
71 */ 71 */
72static int 72static int
73item_printer (void *cls, 73item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
74 const char *plugin_name, 74 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
75 enum EXTRACTOR_MetaType type, 75 const char *data, size_t data_size)
76 enum EXTRACTOR_MetaFormat format,
77 const char *data_mime_type, const char *data, size_t data_size)
78{ 76{
79 if ((format != EXTRACTOR_METAFORMAT_UTF8) && 77 if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
80 (format != EXTRACTOR_METAFORMAT_C_STRING)) 78 (format != EXTRACTOR_METAFORMAT_C_STRING))
@@ -105,9 +103,7 @@ clean_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105 return; 103 return;
106 } 104 }
107 if (dsize != 105 if (dsize !=
108 GNUNET_DISK_fn_write (output_filename, 106 GNUNET_DISK_fn_write (output_filename, ddata, dsize,
109 ddata,
110 dsize,
111 GNUNET_DISK_PERM_USER_READ | 107 GNUNET_DISK_PERM_USER_READ |
112 GNUNET_DISK_PERM_USER_WRITE)) 108 GNUNET_DISK_PERM_USER_WRITE))
113 { 109 {
@@ -154,8 +150,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
154 uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri); 150 uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri);
155 printf ("#%u:\n", cnt++); 151 printf ("#%u:\n", cnt++);
156 filename = 152 filename =
157 GNUNET_CONTAINER_meta_data_get_by_type (info->value.search. 153 GNUNET_CONTAINER_meta_data_get_by_type (info->value.search.specifics.
158 specifics.result.meta, 154 result.meta,
159 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 155 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
160 if (filename != NULL) 156 if (filename != NULL)
161 { 157 {
@@ -166,8 +162,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
166 else 162 else
167 printf ("gnunet-download %s\n", uri); 163 printf ("gnunet-download %s\n", uri);
168 if (verbose) 164 if (verbose)
169 GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics. 165 GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics.result.
170 result.meta, &item_printer, NULL); 166 meta, &item_printer, NULL);
171 printf ("\n"); 167 printf ("\n");
172 fflush (stdout); 168 fflush (stdout);
173 GNUNET_free_non_null (filename); 169 GNUNET_free_non_null (filename);
@@ -182,14 +178,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
182 /* ignore */ 178 /* ignore */
183 break; 179 break;
184 case GNUNET_FS_STATUS_SEARCH_ERROR: 180 case GNUNET_FS_STATUS_SEARCH_ERROR:
185 fprintf (stderr, 181 fprintf (stderr, _("Error searching: %s.\n"),
186 _("Error searching: %s.\n"),
187 info->value.search.specifics.error.message); 182 info->value.search.specifics.error.message);
188 GNUNET_SCHEDULER_shutdown (); 183 GNUNET_SCHEDULER_shutdown ();
189 break; 184 break;
190 case GNUNET_FS_STATUS_SEARCH_STOPPED: 185 case GNUNET_FS_STATUS_SEARCH_STOPPED:
191 GNUNET_SCHEDULER_add_continuation (&clean_task, 186 GNUNET_SCHEDULER_add_continuation (&clean_task, NULL,
192 NULL,
193 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 187 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
194 break; 188 break;
195 default: 189 default:
@@ -220,9 +214,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
220 * @param c configuration 214 * @param c configuration
221 */ 215 */
222static void 216static void
223run (void *cls, 217run (void *cls, char *const *args, const char *cfgfile,
224 char *const *args, 218 const struct GNUNET_CONFIGURATION_Handle *c)
225 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
226{ 219{
227 struct GNUNET_FS_Uri *uri; 220 struct GNUNET_FS_Uri *uri;
228 unsigned int argc; 221 unsigned int argc;
@@ -240,10 +233,9 @@ run (void *cls,
240 return; 233 return;
241 } 234 }
242 cfg = c; 235 cfg = c;
243 ctx = GNUNET_FS_start (cfg, 236 ctx =
244 "gnunet-search", 237 GNUNET_FS_start (cfg, "gnunet-search", &progress_cb, NULL,
245 &progress_cb, 238 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
246 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
247 if (NULL == ctx) 239 if (NULL == ctx)
248 { 240 {
249 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); 241 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
@@ -272,8 +264,8 @@ run (void *cls,
272 } 264 }
273 else 265 else
274 { 266 {
275 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 267 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
276 &shutdown_task, NULL); 268 NULL);
277 } 269 }
278} 270}
279 271
@@ -311,9 +303,7 @@ main (int argc, char *const *argv)
311 GNUNET_GETOPT_OPTION_END 303 GNUNET_GETOPT_OPTION_END
312 }; 304 };
313 return (GNUNET_OK == 305 return (GNUNET_OK ==
314 GNUNET_PROGRAM_run (argc, 306 GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD",
315 argv,
316 "gnunet-search [OPTIONS] KEYWORD",
317 gettext_noop 307 gettext_noop
318 ("Search GNUnet for files that were published on GNUnet"), 308 ("Search GNUnet for files that were published on GNUnet"),
319 options, &run, NULL)) ? ret : 1; 309 options, &run, NULL)) ? ret : 1;
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 4d12b8bfd..0457607d5 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -166,8 +166,9 @@ age_cover_counters (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
166{ 166{
167 GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; 167 GSF_cover_content_count = (GSF_cover_content_count * 15) / 16;
168 GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; 168 GSF_cover_query_count = (GSF_cover_query_count * 15) / 16;
169 cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, 169 cover_age_task =
170 &age_cover_counters, NULL); 170 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters,
171 NULL);
171} 172}
172 173
173 174
@@ -223,8 +224,7 @@ GSF_test_get_load_too_high_ (uint32_t priority)
223 * GNUNET_SYSERR to close it (signal serious error) 224 * GNUNET_SYSERR to close it (signal serious error)
224 */ 225 */
225static int 226static int
226handle_p2p_put (void *cls, 227handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other,
227 const struct GNUNET_PeerIdentity *other,
228 const struct GNUNET_MessageHeader *message, 228 const struct GNUNET_MessageHeader *message,
229 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 229 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
230{ 230{
@@ -273,8 +273,7 @@ consider_request_for_forwarding (void *cls,
273 * @param result final datastore lookup result 273 * @param result final datastore lookup result
274 */ 274 */
275static void 275static void
276consider_forwarding (void *cls, 276consider_forwarding (void *cls, struct GSF_PendingRequest *pr,
277 struct GSF_PendingRequest *pr,
278 enum GNUNET_BLOCK_EvaluationResult result) 277 enum GNUNET_BLOCK_EvaluationResult result)
279{ 278{
280 if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) 279 if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
@@ -295,8 +294,7 @@ consider_forwarding (void *cls,
295 * GNUNET_SYSERR to close it (signal serious error) 294 * GNUNET_SYSERR to close it (signal serious error)
296 */ 295 */
297static int 296static int
298handle_p2p_get (void *cls, 297handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other,
299 const struct GNUNET_PeerIdentity *other,
300 const struct GNUNET_MessageHeader *message, 298 const struct GNUNET_MessageHeader *message,
301 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 299 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
302{ 300{
@@ -321,8 +319,7 @@ handle_p2p_get (void *cls,
321 * @param result final datastore lookup result 319 * @param result final datastore lookup result
322 */ 320 */
323static void 321static void
324start_p2p_processing (void *cls, 322start_p2p_processing (void *cls, struct GSF_PendingRequest *pr,
325 struct GSF_PendingRequest *pr,
326 enum GNUNET_BLOCK_EvaluationResult result) 323 enum GNUNET_BLOCK_EvaluationResult result)
327{ 324{
328 struct GNUNET_SERVER_Client *client = cls; 325 struct GNUNET_SERVER_Client *client = cls;
@@ -355,8 +352,7 @@ start_p2p_processing (void *cls,
355 * @param message the actual message 352 * @param message the actual message
356 */ 353 */
357static void 354static void
358handle_start_search (void *cls, 355handle_start_search (void *cls, struct GNUNET_SERVER_Client *client,
359 struct GNUNET_SERVER_Client *client,
360 const struct GNUNET_MessageHeader *message) 356 const struct GNUNET_MessageHeader *message)
361{ 357{
362 struct GSF_PendingRequest *pr; 358 struct GSF_PendingRequest *pr;
@@ -424,8 +420,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
424 * @return GNUNET_YES to continue to iterate 420 * @return GNUNET_YES to continue to iterate
425 */ 421 */
426static int 422static int
427consider_peer_for_forwarding (void *cls, 423consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
428 const GNUNET_HashCode * key,
429 struct GSF_PendingRequest *pr) 424 struct GSF_PendingRequest *pr)
430{ 425{
431 struct GSF_ConnectedPeer *cp = cls; 426 struct GSF_ConnectedPeer *cp = cls;
@@ -443,8 +438,7 @@ consider_peer_for_forwarding (void *cls,
443 * @param atsi performance information 438 * @param atsi performance information
444 */ 439 */
445static void 440static void
446peer_connect_handler (void *cls, 441peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
447 const struct GNUNET_PeerIdentity *peer,
448 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 442 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
449{ 443{
450 struct GSF_ConnectedPeer *cp; 444 struct GSF_ConnectedPeer *cp;
@@ -471,11 +465,10 @@ peer_connect_handler (void *cls,
471 * @param publicKey public key of this peer, NULL if we failed 465 * @param publicKey public key of this peer, NULL if we failed
472 */ 466 */
473static void 467static void
474peer_init_handler (void *cls, 468peer_init_handler (void *cls, struct GNUNET_CORE_Handle *server,
475 struct GNUNET_CORE_Handle *server,
476 const struct GNUNET_PeerIdentity *my_identity, 469 const struct GNUNET_PeerIdentity *my_identity,
477 const struct 470 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
478 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 471 *publicKey)
479{ 472{
480 my_id = *my_identity; 473 my_id = *my_identity;
481} 474}
@@ -515,12 +508,10 @@ main_init (struct GNUNET_SERVER_Handle *server,
515 }; 508 };
516 509
517 GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */ 510 GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */
518 NULL, 511 NULL, &peer_init_handler,
519 &peer_init_handler,
520 &peer_connect_handler, 512 &peer_connect_handler,
521 &GSF_peer_disconnect_handler_, 513 &GSF_peer_disconnect_handler_,
522 &GSF_peer_status_handler_, 514 &GSF_peer_status_handler_, NULL, GNUNET_NO,
523 NULL, GNUNET_NO,
524 NULL, GNUNET_NO, p2p_handlers); 515 NULL, GNUNET_NO, p2p_handlers);
525 if (NULL == GSF_core) 516 if (NULL == GSF_core)
526 { 517 {
@@ -528,14 +519,15 @@ main_init (struct GNUNET_SERVER_Handle *server,
528 _("Failed to connect to `%s' service.\n"), "core"); 519 _("Failed to connect to `%s' service.\n"), "core");
529 return GNUNET_SYSERR; 520 return GNUNET_SYSERR;
530 } 521 }
531 GNUNET_SERVER_disconnect_notify (server, 522 GNUNET_SERVER_disconnect_notify (server, &GSF_client_disconnect_handler_,
532 &GSF_client_disconnect_handler_, NULL); 523 NULL);
533 GNUNET_SERVER_add_handlers (server, handlers); 524 GNUNET_SERVER_add_handlers (server, handlers);
534 cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, 525 cover_age_task =
535 &age_cover_counters, NULL); 526 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters,
527 NULL);
536 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); 528 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
537 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 529 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
538 &shutdown_task, NULL); 530 NULL);
539 return GNUNET_OK; 531 return GNUNET_OK;
540} 532}
541 533
@@ -548,8 +540,7 @@ main_init (struct GNUNET_SERVER_Handle *server,
548 * @param cfg configuration to use 540 * @param cfg configuration to use
549 */ 541 */
550static void 542static void
551run (void *cls, 543run (void *cls, struct GNUNET_SERVER_Handle *server,
552 struct GNUNET_SERVER_Handle *server,
553 const struct GNUNET_CONFIGURATION_Handle *cfg) 544 const struct GNUNET_CONFIGURATION_Handle *cfg)
554{ 545{
555 GSF_cfg = cfg; 546 GSF_cfg = cfg;
@@ -594,10 +585,8 @@ int
594main (int argc, char *const *argv) 585main (int argc, char *const *argv)
595{ 586{
596 return (GNUNET_OK == 587 return (GNUNET_OK ==
597 GNUNET_SERVICE_run (argc, 588 GNUNET_SERVICE_run (argc, argv, "fs", GNUNET_SERVICE_OPTION_NONE,
598 argv, 589 &run, NULL)) ? 0 : 1;
599 "fs",
600 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
601} 590}
602 591
603/* end of gnunet-service-fs.c */ 592/* end of gnunet-service-fs.c */
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 4e57455b2..1e93a475e 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -400,13 +400,12 @@ static size_t peer_transmit_ready_cb (void *cls, size_t size, void *buf);
400 * long should the client wait until re-trying? 400 * long should the client wait until re-trying?
401 * @param preference current traffic preference for the given peer 401 * @param preference current traffic preference for the given peer
402 */ 402 */
403static void 403static void core_reserve_callback (void *cls,
404core_reserve_callback (void *cls, 404 const struct GNUNET_PeerIdentity *peer,
405 const struct GNUNET_PeerIdentity *peer, 405 struct GNUNET_BANDWIDTH_Value32NBO
406 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 406 bandwidth_out, int32_t amount,
407 int32_t amount, 407 struct GNUNET_TIME_Relative res_delay,
408 struct GNUNET_TIME_Relative res_delay, 408 uint64_t preference);
409 uint64_t preference);
410 409
411 410
412/** 411/**
@@ -437,23 +436,20 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
437 pth->was_reserved = GNUNET_YES; 436 pth->was_reserved = GNUNET_YES;
438 ip = cp->inc_preference; 437 ip = cp->inc_preference;
439 cp->inc_preference = 0; 438 cp->inc_preference = 0;
440 cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, 439 cp->irc =
441 &target, 440 GNUNET_CORE_peer_change_preference (GSF_core, &target,
442 GNUNET_TIME_UNIT_FOREVER_REL, 441 GNUNET_TIME_UNIT_FOREVER_REL,
443 GNUNET_BANDWIDTH_VALUE_MAX, 442 GNUNET_BANDWIDTH_VALUE_MAX,
444 DBLOCK_SIZE, 443 DBLOCK_SIZE, ip,
445 ip, 444 &core_reserve_callback, cp);
446 &core_reserve_callback, cp);
447 } 445 }
448 GNUNET_assert (pth->cth == NULL); 446 GNUNET_assert (pth->cth == NULL);
449 pth->cth_in_progress++; 447 pth->cth_in_progress++;
450 pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, 448 pth->cth =
451 GNUNET_YES, 449 GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority,
452 pth->priority, 450 GNUNET_TIME_absolute_get_remaining
453 GNUNET_TIME_absolute_get_remaining 451 (pth->timeout), &target, pth->size,
454 (pth->timeout), &target, 452 &peer_transmit_ready_cb, pth);
455 pth->size,
456 &peer_transmit_ready_cb, pth);
457 GNUNET_assert (0 < pth->cth_in_progress--); 453 GNUNET_assert (0 < pth->cth_in_progress--);
458} 454}
459 455
@@ -495,8 +491,9 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf)
495 GNUNET_assert (0 < cp->ppd.pending_replies--); 491 GNUNET_assert (0 < cp->ppd.pending_replies--);
496 } 492 }
497 GNUNET_LOAD_update (cp->ppd.transmission_delay, 493 GNUNET_LOAD_update (cp->ppd.transmission_delay,
498 GNUNET_TIME_absolute_get_duration 494 GNUNET_TIME_absolute_get_duration (pth->
499 (pth->transmission_request_start_time).rel_value); 495 transmission_request_start_time).
496 rel_value);
500 ret = pth->gmc (pth->gmc_cls, size, buf); 497 ret = pth->gmc (pth->gmc_cls, size, buf);
501 GNUNET_assert (NULL == pth->cth); 498 GNUNET_assert (NULL == pth->cth);
502 for (pos = cp->pth_head; pos != NULL; pos = pos->next) 499 for (pos = cp->pth_head; pos != NULL; pos = pos->next)
@@ -528,12 +525,12 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
528 cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK; 525 cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK;
529 ip = cp->inc_preference; 526 ip = cp->inc_preference;
530 cp->inc_preference = 0; 527 cp->inc_preference = 0;
531 cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, 528 cp->irc =
532 &target, 529 GNUNET_CORE_peer_change_preference (GSF_core, &target,
533 GNUNET_TIME_UNIT_FOREVER_REL, 530 GNUNET_TIME_UNIT_FOREVER_REL,
534 GNUNET_BANDWIDTH_VALUE_MAX, 531 GNUNET_BANDWIDTH_VALUE_MAX,
535 DBLOCK_SIZE, 532 DBLOCK_SIZE, ip,
536 ip, &core_reserve_callback, cp); 533 &core_reserve_callback, cp);
537} 534}
538 535
539 536
@@ -550,11 +547,9 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
550 * @param preference current traffic preference for the given peer 547 * @param preference current traffic preference for the given peer
551 */ 548 */
552static void 549static void
553core_reserve_callback (void *cls, 550core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
554 const struct GNUNET_PeerIdentity *peer,
555 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 551 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
556 int32_t amount, 552 int32_t amount, struct GNUNET_TIME_Relative res_delay,
557 struct GNUNET_TIME_Relative res_delay,
558 uint64_t preference) 553 uint64_t preference)
559{ 554{
560 struct GSF_ConnectedPeer *cp = cls; 555 struct GSF_ConnectedPeer *cp = cls;
@@ -563,8 +558,8 @@ core_reserve_callback (void *cls,
563 cp->irc = NULL; 558 cp->irc = NULL;
564 if (0 == amount) 559 if (0 == amount)
565 { 560 {
566 cp->irc_delay_task = GNUNET_SCHEDULER_add_delayed (res_delay, 561 cp->irc_delay_task =
567 &retry_reservation, cp); 562 GNUNET_SCHEDULER_add_delayed (res_delay, &retry_reservation, cp);
568 return; 563 return;
569 } 564 }
570 cp->did_reserve = GNUNET_YES; 565 cp->did_reserve = GNUNET_YES;
@@ -573,13 +568,11 @@ core_reserve_callback (void *cls,
573 { 568 {
574 /* reservation success, try transmission now! */ 569 /* reservation success, try transmission now! */
575 pth->cth_in_progress++; 570 pth->cth_in_progress++;
576 pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, 571 pth->cth =
577 GNUNET_YES, 572 GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority,
578 pth->priority, 573 GNUNET_TIME_absolute_get_remaining
579 GNUNET_TIME_absolute_get_remaining 574 (pth->timeout), peer, pth->size,
580 (pth->timeout), peer, 575 &peer_transmit_ready_cb, pth);
581 pth->size,
582 &peer_transmit_ready_cb, pth);
583 GNUNET_assert (0 < pth->cth_in_progress--); 576 GNUNET_assert (0 < pth->cth_in_progress--);
584 } 577 }
585} 578}
@@ -604,12 +597,12 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
604 cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); 597 cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer));
605 cp->ppd.pid = GNUNET_PEER_intern (peer); 598 cp->ppd.pid = GNUNET_PEER_intern (peer);
606 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); 599 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
607 cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, 600 cp->irc =
608 peer, 601 GNUNET_CORE_peer_change_preference (GSF_core, peer,
609 GNUNET_TIME_UNIT_FOREVER_REL, 602 GNUNET_TIME_UNIT_FOREVER_REL,
610 GNUNET_BANDWIDTH_VALUE_MAX, 603 GNUNET_BANDWIDTH_VALUE_MAX,
611 DBLOCK_SIZE, 604 DBLOCK_SIZE, 0,
612 0, &core_reserve_callback, cp); 605 &core_reserve_callback, cp);
613 fn = get_trust_filename (peer); 606 fn = get_trust_filename (peer);
614 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && 607 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) &&
615 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) 608 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust))))
@@ -617,8 +610,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
617 GNUNET_free (fn); 610 GNUNET_free (fn);
618 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128); 611 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128);
619 GNUNET_break (GNUNET_OK == 612 GNUNET_break (GNUNET_OK ==
620 GNUNET_CONTAINER_multihashmap_put (cp_map, 613 GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey,
621 &peer->hashPubKey,
622 cp, 614 cp,
623 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 615 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
624 update_atsi (cp, atsi); 616 update_atsi (cp, atsi);
@@ -645,8 +637,8 @@ revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
645 if (0 != bt.rel_value) 637 if (0 != bt.rel_value)
646 { 638 {
647 /* still time left... */ 639 /* still time left... */
648 cp->mig_revive_task 640 cp->mig_revive_task =
649 = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); 641 GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp);
650 return; 642 return;
651 } 643 }
652 GSF_push_start_ (cp); 644 GSF_push_start_ (cp);
@@ -705,8 +697,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
705 if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) 697 if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK)
706 { 698 {
707 GSF_push_stop_ (cp); 699 GSF_push_stop_ (cp);
708 cp->mig_revive_task 700 cp->mig_revive_task =
709 = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); 701 GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp);
710 } 702 }
711 update_atsi (cp, atsi); 703 update_atsi (cp, atsi);
712 return GNUNET_OK; 704 return GNUNET_OK;
@@ -740,8 +732,8 @@ copy_reply (void *cls, size_t buf_size, void *buf)
740 else 732 else
741 { 733 {
742 size = 0; 734 size = 0;
743 GNUNET_STATISTICS_update (GSF_stats, 735 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# replies dropped"), 1,
744 gettext_noop ("# replies dropped"), 1, GNUNET_NO); 736 GNUNET_NO);
745 } 737 }
746 GNUNET_free (pm); 738 GNUNET_free (pm);
747 return size; 739 return size;
@@ -769,8 +761,7 @@ cancel_pending_request (void *cls, const GNUNET_HashCode * query, void *value)
769 GNUNET_SCHEDULER_cancel (peerreq->kill_task); 761 GNUNET_SCHEDULER_cancel (peerreq->kill_task);
770 peerreq->kill_task = GNUNET_SCHEDULER_NO_TASK; 762 peerreq->kill_task = GNUNET_SCHEDULER_NO_TASK;
771 } 763 }
772 GNUNET_STATISTICS_update (GSF_stats, 764 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"),
773 gettext_noop ("# P2P searches active"),
774 -1, GNUNET_NO); 765 -1, GNUNET_NO);
775 prd = GSF_pending_request_get_data_ (pr); 766 prd = GSF_pending_request_get_data_ (pr);
776 GNUNET_break (GNUNET_YES == 767 GNUNET_break (GNUNET_YES ==
@@ -820,9 +811,8 @@ transmit_delayed_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
820 GNUNET_free (dh); 811 GNUNET_free (dh);
821 return; 812 return;
822 } 813 }
823 (void) GSF_peer_transmit_ (cp, GNUNET_NO, 814 (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT,
824 UINT32_MAX, 815 dh->msize, &copy_reply, dh->pm);
825 REPLY_TIMEOUT, dh->msize, &copy_reply, dh->pm);
826 GNUNET_free (dh); 816 GNUNET_free (dh);
827} 817}
828 818
@@ -838,9 +828,10 @@ get_randomized_delay ()
838 struct GNUNET_TIME_Relative ret; 828 struct GNUNET_TIME_Relative ret;
839 829
840 /* FIXME: replace 5000 with something relating to current observed P2P message latency */ 830 /* FIXME: replace 5000 with something relating to current observed P2P message latency */
841 ret = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 831 ret =
842 GNUNET_CRYPTO_random_u32 832 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
843 (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); 833 GNUNET_CRYPTO_random_u32
834 (GNUNET_CRYPTO_QUALITY_WEAK, 5000));
844 GNUNET_STATISTICS_update (GSF_stats, 835 GNUNET_STATISTICS_update (GSF_stats,
845 gettext_noop 836 gettext_noop
846 ("# artificial delays introduced (ms)"), 837 ("# artificial delays introduced (ms)"),
@@ -868,13 +859,11 @@ get_randomized_delay ()
868 * @param data_len number of bytes in data 859 * @param data_len number of bytes in data
869 */ 860 */
870static void 861static void
871handle_p2p_reply (void *cls, 862handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
872 enum GNUNET_BLOCK_EvaluationResult eval, 863 struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level,
873 struct GSF_PendingRequest *pr,
874 uint32_t reply_anonymity_level,
875 struct GNUNET_TIME_Absolute expiration, 864 struct GNUNET_TIME_Absolute expiration,
876 enum GNUNET_BLOCK_Type type, 865 enum GNUNET_BLOCK_Type type, const void *data,
877 const void *data, size_t data_len) 866 size_t data_len)
878{ 867{
879 struct PeerRequest *peerreq = cls; 868 struct PeerRequest *peerreq = cls;
880 struct GSF_ConnectedPeer *cp = peerreq->cp; 869 struct GSF_ConnectedPeer *cp = peerreq->cp;
@@ -888,8 +877,7 @@ handle_p2p_reply (void *cls,
888 prd = GSF_pending_request_get_data_ (pr); 877 prd = GSF_pending_request_get_data_ (pr);
889 if (NULL == data) 878 if (NULL == data)
890 { 879 {
891 GNUNET_STATISTICS_update (GSF_stats, 880 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"),
892 gettext_noop ("# P2P searches active"),
893 -1, GNUNET_NO); 881 -1, GNUNET_NO);
894 GNUNET_break (GNUNET_YES == 882 GNUNET_break (GNUNET_YES ==
895 GNUNET_CONTAINER_multihashmap_remove (cp->request_map, 883 GNUNET_CONTAINER_multihashmap_remove (cp->request_map,
@@ -936,8 +924,7 @@ handle_p2p_reply (void *cls,
936 pm->type = htonl (type); 924 pm->type = htonl (type);
937 pm->expiration = GNUNET_TIME_absolute_hton (expiration); 925 pm->expiration = GNUNET_TIME_absolute_hton (expiration);
938 memcpy (&pm[1], data, data_len); 926 memcpy (&pm[1], data, data_len);
939 if ((reply_anonymity_level != UINT32_MAX) && 927 if ((reply_anonymity_level != UINT32_MAX) && (reply_anonymity_level != 0) &&
940 (reply_anonymity_level != 0) &&
941 (GSF_enable_randomized_delays == GNUNET_YES)) 928 (GSF_enable_randomized_delays == GNUNET_YES))
942 { 929 {
943 struct GSF_DelayedHandle *dh; 930 struct GSF_DelayedHandle *dh;
@@ -947,14 +934,14 @@ handle_p2p_reply (void *cls,
947 dh->pm = pm; 934 dh->pm = pm;
948 dh->msize = msize; 935 dh->msize = msize;
949 GNUNET_CONTAINER_DLL_insert (cp->delayed_head, cp->delayed_tail, dh); 936 GNUNET_CONTAINER_DLL_insert (cp->delayed_head, cp->delayed_tail, dh);
950 dh->delay_task = GNUNET_SCHEDULER_add_delayed (get_randomized_delay (), 937 dh->delay_task =
951 &transmit_delayed_now, dh); 938 GNUNET_SCHEDULER_add_delayed (get_randomized_delay (),
939 &transmit_delayed_now, dh);
952 } 940 }
953 else 941 else
954 { 942 {
955 (void) GSF_peer_transmit_ (cp, GNUNET_NO, 943 (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT, msize,
956 UINT32_MAX, 944 &copy_reply, pm);
957 REPLY_TIMEOUT, msize, &copy_reply, pm);
958 } 945 }
959 if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST) 946 if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
960 return; 947 return;
@@ -1220,8 +1207,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1220#if DEBUG_FS 1207#if DEBUG_FS
1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1222 "Received request for `%s' of type %u from peer `%4s' with flags %u\n", 1209 "Received request for `%s' of type %u from peer `%4s' with flags %u\n",
1223 GNUNET_h2s (&gm->query), 1210 GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other),
1224 (unsigned int) type, GNUNET_i2s (other), (unsigned int) bm); 1211 (unsigned int) bm);
1225#endif 1212#endif
1226 namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; 1213 namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL;
1227 if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL)) 1214 if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL))
@@ -1254,8 +1241,9 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1254 } 1241 }
1255 ttl = bound_ttl (ntohl (gm->ttl), priority); 1242 ttl = bound_ttl (ntohl (gm->ttl), priority);
1256 /* decrement ttl (always) */ 1243 /* decrement ttl (always) */
1257 ttl_decrement = 2 * TTL_DECREMENT + 1244 ttl_decrement =
1258 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TTL_DECREMENT); 1245 2 * TTL_DECREMENT + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1246 TTL_DECREMENT);
1259 if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0)) 1247 if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0))
1260 { 1248 {
1261#if DEBUG_FS 1249#if DEBUG_FS
@@ -1299,8 +1287,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1299 } 1287 }
1300 /* existing request has lower TTL, drop old one! */ 1288 /* existing request has lower TTL, drop old one! */
1301 GNUNET_STATISTICS_update (GSF_stats, 1289 GNUNET_STATISTICS_update (GSF_stats,
1302 gettext_noop ("# P2P searches active"), 1290 gettext_noop ("# P2P searches active"), -1,
1303 -1, GNUNET_NO); 1291 GNUNET_NO);
1304 priority += prd->priority; 1292 priority += prd->priority;
1305 GSF_pending_request_cancel_ (pr, GNUNET_YES); 1293 GSF_pending_request_cancel_ (pr, GNUNET_YES);
1306 GNUNET_assert (GNUNET_YES == 1294 GNUNET_assert (GNUNET_YES ==
@@ -1318,10 +1306,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1318 1306
1319 peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); 1307 peerreq = GNUNET_malloc (sizeof (struct PeerRequest));
1320 peerreq->cp = cp; 1308 peerreq->cp = cp;
1321 pr = GSF_pending_request_create_ (options, 1309 pr = GSF_pending_request_create_ (options, type, &gm->query, namespace,
1322 type,
1323 &gm->query,
1324 namespace,
1325 target, 1310 target,
1326 (bfsize > 1311 (bfsize >
1327 0) ? (const char *) &opt[bits] : NULL, 1312 0) ? (const char *) &opt[bits] : NULL,
@@ -1332,8 +1317,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1332 GNUNET_assert (NULL != pr); 1317 GNUNET_assert (NULL != pr);
1333 peerreq->pr = pr; 1318 peerreq->pr = pr;
1334 GNUNET_break (GNUNET_OK == 1319 GNUNET_break (GNUNET_OK ==
1335 GNUNET_CONTAINER_multihashmap_put (cp->request_map, 1320 GNUNET_CONTAINER_multihashmap_put (cp->request_map, &gm->query,
1336 &gm->query,
1337 peerreq, 1321 peerreq,
1338 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 1322 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
1339 GNUNET_STATISTICS_update (GSF_stats, 1323 GNUNET_STATISTICS_update (GSF_stats,
@@ -1397,10 +1381,8 @@ peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1397 * @return handle to cancel request 1381 * @return handle to cancel request
1398 */ 1382 */
1399struct GSF_PeerTransmitHandle * 1383struct GSF_PeerTransmitHandle *
1400GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, 1384GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query,
1401 int is_query, 1385 uint32_t priority, struct GNUNET_TIME_Relative timeout,
1402 uint32_t priority,
1403 struct GNUNET_TIME_Relative timeout,
1404 size_t size, GSF_GetMessageCallback gmc, void *gmc_cls) 1386 size_t size, GSF_GetMessageCallback gmc, void *gmc_cls)
1405{ 1387{
1406 struct GSF_PeerTransmitHandle *pth; 1388 struct GSF_PeerTransmitHandle *pth;
@@ -1432,9 +1414,8 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
1432 cp->ppd.pending_queries++; 1414 cp->ppd.pending_queries++;
1433 else if (GNUNET_NO == is_query) 1415 else if (GNUNET_NO == is_query)
1434 cp->ppd.pending_replies++; 1416 cp->ppd.pending_replies++;
1435 pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, 1417 pth->timeout_task =
1436 &peer_transmit_timeout, 1418 GNUNET_SCHEDULER_add_delayed (timeout, &peer_transmit_timeout, pth);
1437 pth);
1438 schedule_transmission (pth); 1419 schedule_transmission (pth);
1439 return pth; 1420 return pth;
1440} 1421}
@@ -1544,8 +1525,7 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
1544 * @param atsi status information 1525 * @param atsi status information
1545 */ 1526 */
1546void 1527void
1547GSF_peer_status_handler_ (void *cls, 1528GSF_peer_status_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer,
1548 const struct GNUNET_PeerIdentity *peer,
1549 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 1529 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1550 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 1530 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
1551 struct GNUNET_TIME_Absolute timeout, 1531 struct GNUNET_TIME_Absolute timeout,
@@ -1752,27 +1732,24 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
1752#if DEBUG_FS && 0 1732#if DEBUG_FS && 0
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1754 "Migration already blocked for another %llu ms\n", 1734 "Migration already blocked for another %llu ms\n",
1755 (unsigned long long) 1735 (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp->
1756 GNUNET_TIME_absolute_get_remaining 1736 last_migration_block).
1757 (cp->last_migration_block).rel_value); 1737 rel_value);
1758#endif 1738#endif
1759 return; /* already blocked */ 1739 return; /* already blocked */
1760 } 1740 }
1761#if DEBUG_FS && 0 1741#if DEBUG_FS && 0
1762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n",
1763 "Asking to stop migration for %llu ms\n",
1764 (unsigned long long) block_time.rel_value); 1743 (unsigned long long) block_time.rel_value);
1765#endif 1744#endif
1766 cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); 1745 cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time);
1767 if (cp->migration_pth != NULL) 1746 if (cp->migration_pth != NULL)
1768 GSF_peer_transmit_cancel_ (cp->migration_pth); 1747 GSF_peer_transmit_cancel_ (cp->migration_pth);
1769 cp->migration_pth 1748 cp->migration_pth =
1770 = GSF_peer_transmit_ (cp, 1749 GSF_peer_transmit_ (cp, GNUNET_SYSERR, UINT32_MAX,
1771 GNUNET_SYSERR, 1750 GNUNET_TIME_UNIT_FOREVER_REL,
1772 UINT32_MAX, 1751 sizeof (struct MigrationStopMessage),
1773 GNUNET_TIME_UNIT_FOREVER_REL, 1752 &create_migration_stop_message, cp);
1774 sizeof (struct MigrationStopMessage),
1775 &create_migration_stop_message, cp);
1776} 1753}
1777 1754
1778 1755
@@ -1806,12 +1783,12 @@ flush_trust (void *cls, const GNUNET_HashCode * key, void *value)
1806 else 1783 else
1807 { 1784 {
1808 trust = htonl (cp->ppd.trust); 1785 trust = htonl (cp->ppd.trust);
1809 if (sizeof (uint32_t) == GNUNET_DISK_fn_write (fn, &trust, 1786 if (sizeof (uint32_t) ==
1810 sizeof (uint32_t), 1787 GNUNET_DISK_fn_write (fn, &trust, sizeof (uint32_t),
1811 GNUNET_DISK_PERM_USER_READ | 1788 GNUNET_DISK_PERM_USER_READ |
1812 GNUNET_DISK_PERM_USER_WRITE | 1789 GNUNET_DISK_PERM_USER_WRITE |
1813 GNUNET_DISK_PERM_GROUP_READ | 1790 GNUNET_DISK_PERM_GROUP_READ |
1814 GNUNET_DISK_PERM_OTHER_READ)) 1791 GNUNET_DISK_PERM_OTHER_READ))
1815 cp->disk_trust = cp->ppd.trust; 1792 cp->disk_trust = cp->ppd.trust;
1816 } 1793 }
1817 GNUNET_free (fn); 1794 GNUNET_free (fn);
@@ -1865,8 +1842,7 @@ GSF_connected_peer_init_ ()
1865{ 1842{
1866 cp_map = GNUNET_CONTAINER_multihashmap_create (128); 1843 cp_map = GNUNET_CONTAINER_multihashmap_create (128);
1867 GNUNET_assert (GNUNET_OK == 1844 GNUNET_assert (GNUNET_OK ==
1868 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, 1845 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",
1869 "fs",
1870 "TRUST", 1846 "TRUST",
1871 &trustDirectory)); 1847 &trustDirectory));
1872 GNUNET_DISK_directory_create (trustDirectory); 1848 GNUNET_DISK_directory_create (trustDirectory);
@@ -1939,8 +1915,8 @@ GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc)
1939{ 1915{
1940 if (NULL == cp_map) 1916 if (NULL == cp_map)
1941 return; /* already cleaned up */ 1917 return; /* already cleaned up */
1942 GNUNET_CONTAINER_multihashmap_iterate (cp_map, 1918 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_local_client,
1943 &clean_local_client, (void *) lc); 1919 (void *) lc);
1944} 1920}
1945 1921
1946 1922
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index 4bf02adb0..c7bff3a9d 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -126,9 +126,7 @@ write_index_list ()
126 while (pos != NULL) 126 while (pos != NULL)
127 { 127 {
128 if ((GNUNET_OK != 128 if ((GNUNET_OK !=
129 GNUNET_BIO_write (wh, 129 GNUNET_BIO_write (wh, &pos->file_id, sizeof (GNUNET_HashCode))) ||
130 &pos->file_id,
131 sizeof (GNUNET_HashCode))) ||
132 (GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename))) 130 (GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename)))
133 break; 131 break;
134 pos = pos->next; 132 pos = pos->next;
@@ -181,14 +179,11 @@ read_index_list ()
181 return; 179 return;
182 } 180 }
183 while ((GNUNET_OK == 181 while ((GNUNET_OK ==
184 GNUNET_BIO_read (rh, 182 GNUNET_BIO_read (rh, "Hash of indexed file", &hc,
185 "Hash of indexed file",
186 &hc,
187 sizeof (GNUNET_HashCode))) && 183 sizeof (GNUNET_HashCode))) &&
188 (GNUNET_OK == 184 (GNUNET_OK ==
189 GNUNET_BIO_read_string (rh, 185 GNUNET_BIO_read_string (rh, "Name of indexed file", &fname,
190 "Name of indexed file", 186 1024 * 16)) && (fname != NULL))
191 &fname, 1024 * 16)) && (fname != NULL))
192 { 187 {
193 slen = strlen (fname) + 1; 188 slen = strlen (fname) + 1;
194 pos = GNUNET_malloc (sizeof (struct IndexInfo) + slen); 189 pos = GNUNET_malloc (sizeof (struct IndexInfo) + slen);
@@ -196,9 +191,7 @@ read_index_list ()
196 pos->filename = (const char *) &pos[1]; 191 pos->filename = (const char *) &pos[1];
197 memcpy (&pos[1], fname, slen); 192 memcpy (&pos[1], fname, slen);
198 if (GNUNET_SYSERR == 193 if (GNUNET_SYSERR ==
199 GNUNET_CONTAINER_multihashmap_put (ifm, 194 GNUNET_CONTAINER_multihashmap_put (ifm, &hc, (void *) pos->filename,
200 &hc,
201 (void *) pos->filename,
202 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 195 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
203 { 196 {
204 GNUNET_free (pos); 197 GNUNET_free (pos);
@@ -226,8 +219,7 @@ static void
226signal_index_ok (struct IndexInfo *ii) 219signal_index_ok (struct IndexInfo *ii)
227{ 220{
228 if (GNUNET_SYSERR == 221 if (GNUNET_SYSERR ==
229 GNUNET_CONTAINER_multihashmap_put (ifm, 222 GNUNET_CONTAINER_multihashmap_put (ifm, &ii->file_id,
230 &ii->file_id,
231 (void *) ii->filename, 223 (void *) ii->filename,
232 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 224 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
233 { 225 {
@@ -236,7 +228,8 @@ signal_index_ok (struct IndexInfo *ii)
236 ("Index request received for file `%s' is already indexed as `%s'. Permitting anyway.\n"), 228 ("Index request received for file `%s' is already indexed as `%s'. Permitting anyway.\n"),
237 ii->filename, 229 ii->filename,
238 (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, 230 (const char *) GNUNET_CONTAINER_multihashmap_get (ifm,
239 &ii->file_id)); 231 &ii->
232 file_id));
240 GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0, 233 GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
241 GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); 234 GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK);
242 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); 235 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
@@ -246,8 +239,7 @@ signal_index_ok (struct IndexInfo *ii)
246 ii->next = indexed_files; 239 ii->next = indexed_files;
247 indexed_files = ii; 240 indexed_files = ii;
248 write_index_list (); 241 write_index_list ();
249 GNUNET_SERVER_transmit_context_append_data (ii->tc, 242 GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
250 NULL, 0,
251 GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); 243 GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK);
252 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); 244 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
253 ii->tc = NULL; 245 ii->tc = NULL;
@@ -275,11 +267,10 @@ hash_for_index_val (void *cls, const GNUNET_HashCode * res)
275 ("Hash mismatch trying to index file `%s' which has hash `%s'\n"), 267 ("Hash mismatch trying to index file `%s' which has hash `%s'\n"),
276 ii->filename, GNUNET_h2s (res)); 268 ii->filename, GNUNET_h2s (res));
277#if DEBUG_FS 269#if DEBUG_FS
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wanted `%s'\n",
279 "Wanted `%s'\n", GNUNET_h2s (&ii->file_id)); 271 GNUNET_h2s (&ii->file_id));
280#endif 272#endif
281 GNUNET_SERVER_transmit_context_append_data (ii->tc, 273 GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0,
282 NULL, 0,
283 GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED); 274 GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED);
284 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); 275 GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES);
285 GNUNET_free (ii); 276 GNUNET_free (ii);
@@ -297,8 +288,7 @@ hash_for_index_val (void *cls, const GNUNET_HashCode * res)
297 * @param message the actual message 288 * @param message the actual message
298 */ 289 */
299void 290void
300GNUNET_FS_handle_index_start (void *cls, 291GNUNET_FS_handle_index_start (void *cls, struct GNUNET_SERVER_Client *client,
301 struct GNUNET_SERVER_Client *client,
302 const struct GNUNET_MessageHeader *message) 292 const struct GNUNET_MessageHeader *message)
303{ 293{
304 const struct IndexStartMessage *ism; 294 const struct IndexStartMessage *ism;
@@ -341,19 +331,15 @@ GNUNET_FS_handle_index_start (void *cls,
341 memcpy (&ii[1], fn, slen); 331 memcpy (&ii[1], fn, slen);
342 ii->file_id = ism->file_id; 332 ii->file_id = ism->file_id;
343#if DEBUG_FS 333#if DEBUG_FS
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for file `%s'\n",
345 "Received `%s' message for file `%s'\n",
346 "START_INDEX", ii->filename); 335 "START_INDEX", ii->filename);
347#endif 336#endif
348 337
349 ii->tc = GNUNET_SERVER_transmit_context_create (client); 338 ii->tc = GNUNET_SERVER_transmit_context_create (client);
350 mydev = 0; 339 mydev = 0;
351 myino = 0; 340 myino = 0;
352 if (((dev != 0) || 341 if (((dev != 0) || (ino != 0)) &&
353 (ino != 0)) && 342 (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn, &mydev, &myino)) &&
354 (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn,
355 &mydev,
356 &myino)) &&
357 ((dev == mydev) && (ino == myino))) 343 ((dev == mydev) && (ino == myino)))
358 { 344 {
359 /* fast validation OK! */ 345 /* fast validation OK! */
@@ -364,15 +350,13 @@ GNUNET_FS_handle_index_start (void *cls,
364#if DEBUG_FS 350#if DEBUG_FS
365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
366 "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n", 352 "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
367 (unsigned long long) ino, 353 (unsigned long long) ino, (unsigned long long) myino,
368 (unsigned long long) myino,
369 (unsigned int) dev, (unsigned int) mydev); 354 (unsigned int) dev, (unsigned int) mydev);
370#endif 355#endif
371 /* slow validation, need to hash full file (again) */ 356 /* slow validation, need to hash full file (again) */
372 ii->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, 357 ii->fhc =
373 fn, 358 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, fn,
374 HASHING_BLOCKSIZE, 359 HASHING_BLOCKSIZE, &hash_for_index_val, ii);
375 &hash_for_index_val, ii);
376 if (ii->fhc == NULL) 360 if (ii->fhc == NULL)
377 hash_for_index_val (ii, NULL); 361 hash_for_index_val (ii, NULL);
378 GNUNET_free (fn); 362 GNUNET_free (fn);
@@ -387,8 +371,7 @@ GNUNET_FS_handle_index_start (void *cls,
387 * @param message the actual message 371 * @param message the actual message
388 */ 372 */
389void 373void
390GNUNET_FS_handle_index_list_get (void *cls, 374GNUNET_FS_handle_index_list_get (void *cls, struct GNUNET_SERVER_Client *client,
391 struct GNUNET_SERVER_Client *client,
392 const struct GNUNET_MessageHeader *message) 375 const struct GNUNET_MessageHeader *message)
393{ 376{
394 struct GNUNET_SERVER_TransmitContext *tc; 377 struct GNUNET_SERVER_TransmitContext *tc;
@@ -419,8 +402,7 @@ GNUNET_FS_handle_index_list_get (void *cls,
419 GNUNET_SERVER_transmit_context_append_message (tc, &iim->header); 402 GNUNET_SERVER_transmit_context_append_message (tc, &iim->header);
420 pos = pos->next; 403 pos = pos->next;
421 } 404 }
422 GNUNET_SERVER_transmit_context_append_data (tc, 405 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
423 NULL, 0,
424 GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END); 406 GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END);
425 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES); 407 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES);
426} 408}
@@ -434,8 +416,7 @@ GNUNET_FS_handle_index_list_get (void *cls,
434 * @param message the actual message 416 * @param message the actual message
435 */ 417 */
436void 418void
437GNUNET_FS_handle_unindex (void *cls, 419GNUNET_FS_handle_unindex (void *cls, struct GNUNET_SERVER_Client *client,
438 struct GNUNET_SERVER_Client *client,
439 const struct GNUNET_MessageHeader *message) 420 const struct GNUNET_MessageHeader *message)
440{ 421{
441 const struct UnindexMessage *um; 422 const struct UnindexMessage *um;
@@ -465,10 +446,9 @@ GNUNET_FS_handle_unindex (void *cls,
465 else 446 else
466 prev->next = next; 447 prev->next = next;
467 GNUNET_break (GNUNET_OK == 448 GNUNET_break (GNUNET_OK ==
468 GNUNET_CONTAINER_multihashmap_remove (ifm, 449 GNUNET_CONTAINER_multihashmap_remove (ifm, &pos->file_id,
469 &pos->file_id, 450 (void *) pos->
470 (void *) 451 filename));
471 pos->filename));
472 GNUNET_free (pos); 452 GNUNET_free (pos);
473 found = GNUNET_YES; 453 found = GNUNET_YES;
474 } 454 }
@@ -486,8 +466,7 @@ GNUNET_FS_handle_unindex (void *cls,
486 if (GNUNET_YES == found) 466 if (GNUNET_YES == found)
487 write_index_list (); 467 write_index_list ();
488 tc = GNUNET_SERVER_transmit_context_create (client); 468 tc = GNUNET_SERVER_transmit_context_create (client);
489 GNUNET_SERVER_transmit_context_append_data (tc, 469 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
490 NULL, 0,
491 GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK); 470 GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK);
492 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES); 471 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES);
493} 472}
@@ -530,14 +509,11 @@ remove_cont (void *cls, int success, const char *msg)
530 * @return GNUNET_OK on success 509 * @return GNUNET_OK on success
531 */ 510 */
532int 511int
533GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, 512GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, uint32_t size,
534 uint32_t size, 513 const void *data, enum GNUNET_BLOCK_Type type,
535 const void *data, 514 uint32_t priority, uint32_t anonymity,
536 enum GNUNET_BLOCK_Type type, 515 struct GNUNET_TIME_Absolute expiration,
537 uint32_t priority, 516 uint64_t uid,
538 uint32_t anonymity,
539 struct GNUNET_TIME_Absolute
540 expiration, uint64_t uid,
541 GNUNET_DATASTORE_DatumProcessor cont, 517 GNUNET_DATASTORE_DatumProcessor cont,
542 void *cont_cls) 518 void *cont_cls)
543{ 519{
@@ -556,11 +532,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
556 if (size != sizeof (struct OnDemandBlock)) 532 if (size != sizeof (struct OnDemandBlock))
557 { 533 {
558 GNUNET_break (0); 534 GNUNET_break (0);
559 GNUNET_DATASTORE_remove (dsh, 535 GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
560 key,
561 size,
562 data,
563 -1, -1,
564 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); 536 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
565 return GNUNET_SYSERR; 537 return GNUNET_SYSERR;
566 } 538 }
@@ -569,13 +541,11 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
569 fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id); 541 fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id);
570 fh = NULL; 542 fh = NULL;
571 if ((NULL == fn) || 543 if ((NULL == fn) ||
572 (NULL == (fh = GNUNET_DISK_file_open (fn, 544 (NULL ==
573 GNUNET_DISK_OPEN_READ, 545 (fh =
574 GNUNET_DISK_PERM_NONE))) || 546 GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ,
575 (off != 547 GNUNET_DISK_PERM_NONE))) ||
576 GNUNET_DISK_file_seek (fh, 548 (off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)) ||
577 off,
578 GNUNET_DISK_SEEK_SET)) ||
579 (-1 == (nsize = GNUNET_DISK_file_read (fh, ndata, sizeof (ndata))))) 549 (-1 == (nsize = GNUNET_DISK_file_read (fh, ndata, sizeof (ndata)))))
580 { 550 {
581 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 551 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -585,11 +555,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
585 (fn == NULL) ? _("not indexed") : STRERROR (errno)); 555 (fn == NULL) ? _("not indexed") : STRERROR (errno));
586 if (fh != NULL) 556 if (fh != NULL)
587 GNUNET_DISK_file_close (fh); 557 GNUNET_DISK_file_close (fh);
588 GNUNET_DATASTORE_remove (dsh, 558 GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
589 key,
590 size,
591 data,
592 -1, -1,
593 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); 559 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
594 return GNUNET_SYSERR; 560 return GNUNET_SYSERR;
595 } 561 }
@@ -601,13 +567,9 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
601 if (0 != memcmp (&query, key, sizeof (GNUNET_HashCode))) 567 if (0 != memcmp (&query, key, sizeof (GNUNET_HashCode)))
602 { 568 {
603 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 569 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
604 _("Indexed file `%s' changed at offset %llu\n"), 570 _("Indexed file `%s' changed at offset %llu\n"), fn,
605 fn, (unsigned long long) off); 571 (unsigned long long) off);
606 GNUNET_DATASTORE_remove (dsh, 572 GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
607 key,
608 size,
609 data,
610 -1, -1,
611 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); 573 GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
612 return GNUNET_SYSERR; 574 return GNUNET_SYSERR;
613 } 575 }
@@ -615,11 +577,8 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
616 "On-demand encoded block for query `%s'\n", GNUNET_h2s (key)); 578 "On-demand encoded block for query `%s'\n", GNUNET_h2s (key));
617#endif 579#endif
618 cont (cont_cls, 580 cont (cont_cls, key, nsize, edata, GNUNET_BLOCK_TYPE_FS_DBLOCK, priority,
619 key, 581 anonymity, expiration, uid);
620 nsize,
621 edata,
622 GNUNET_BLOCK_TYPE_FS_DBLOCK, priority, anonymity, expiration, uid);
623 return GNUNET_OK; 582 return GNUNET_OK;
624} 583}
625 584
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index aa6569387..6460d4f13 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -199,8 +199,8 @@ client_request_destroy (void *cls,
199 GNUNET_CONTAINER_DLL_remove (lc->cr_head, lc->cr_tail, cr); 199 GNUNET_CONTAINER_DLL_remove (lc->cr_head, lc->cr_tail, cr);
200 GSF_pending_request_cancel_ (cr->pr, GNUNET_NO); 200 GSF_pending_request_cancel_ (cr->pr, GNUNET_NO);
201 GNUNET_STATISTICS_update (GSF_stats, 201 GNUNET_STATISTICS_update (GSF_stats,
202 gettext_noop ("# client searches active"), 202 gettext_noop ("# client searches active"), -1,
203 -1, GNUNET_NO); 203 GNUNET_NO);
204 GNUNET_free (cr); 204 GNUNET_free (cr);
205} 205}
206 206
@@ -223,13 +223,12 @@ client_request_destroy (void *cls,
223 * @param data_len number of bytes in data 223 * @param data_len number of bytes in data
224 */ 224 */
225static void 225static void
226client_response_handler (void *cls, 226client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
227 enum GNUNET_BLOCK_EvaluationResult eval,
228 struct GSF_PendingRequest *pr, 227 struct GSF_PendingRequest *pr,
229 uint32_t reply_anonymity_level, 228 uint32_t reply_anonymity_level,
230 struct GNUNET_TIME_Absolute expiration, 229 struct GNUNET_TIME_Absolute expiration,
231 enum GNUNET_BLOCK_Type type, 230 enum GNUNET_BLOCK_Type type, const void *data,
232 const void *data, size_t data_len) 231 size_t data_len)
233{ 232{
234 struct ClientRequest *cr = cls; 233 struct ClientRequest *cr = cls;
235 struct GSF_LocalClient *lc; 234 struct GSF_LocalClient *lc;
@@ -310,8 +309,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
310 return NULL; 309 return NULL;
311 } 310 }
312 GNUNET_STATISTICS_update (GSF_stats, 311 GNUNET_STATISTICS_update (GSF_stats,
313 gettext_noop ("# client searches received"), 312 gettext_noop ("# client searches received"), 1,
314 1, GNUNET_NO); 313 GNUNET_NO);
315 sc = (msize - sizeof (struct SearchMessage)) / sizeof (GNUNET_HashCode); 314 sc = (msize - sizeof (struct SearchMessage)) / sizeof (GNUNET_HashCode);
316 sm = (const struct SearchMessage *) message; 315 sm = (const struct SearchMessage *) message;
317 type = ntohl (sm->type); 316 type = ntohl (sm->type);
@@ -334,9 +333,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
334 while (cr != NULL) 333 while (cr != NULL)
335 { 334 {
336 prd = GSF_pending_request_get_data_ (cr->pr); 335 prd = GSF_pending_request_get_data_ (cr->pr);
337 if ((0 != memcmp (&prd->query, 336 if ((0 != memcmp (&prd->query, &sm->query, sizeof (GNUNET_HashCode))) &&
338 &sm->query, 337 (prd->type == type))
339 sizeof (GNUNET_HashCode))) && (prd->type == type))
340 break; 338 break;
341 cr = cr->next; 339 cr = cr->next;
342 } 340 }
@@ -346,8 +344,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
347 "Have existing request, merging content-seen lists.\n"); 345 "Have existing request, merging content-seen lists.\n");
348#endif 346#endif
349 GSF_pending_request_update_ (cr->pr, 347 GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1],
350 (const GNUNET_HashCode *) &sm[1], sc); 348 sc);
351 GNUNET_STATISTICS_update (GSF_stats, 349 GNUNET_STATISTICS_update (GSF_stats,
352 gettext_noop 350 gettext_noop
353 ("# client searches updated (merged content seen list)"), 351 ("# client searches updated (merged content seen list)"),
@@ -358,8 +356,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
358 } 356 }
359 357
360 GNUNET_STATISTICS_update (GSF_stats, 358 GNUNET_STATISTICS_update (GSF_stats,
361 gettext_noop ("# client searches active"), 359 gettext_noop ("# client searches active"), 1,
362 1, GNUNET_NO); 360 GNUNET_NO);
363 cr = GNUNET_malloc (sizeof (struct ClientRequest)); 361 cr = GNUNET_malloc (sizeof (struct ClientRequest));
364 cr->lc = lc; 362 cr->lc = lc;
365 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr); 363 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
@@ -368,9 +366,9 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
368 options |= GSF_PRO_LOCAL_ONLY; 366 options |= GSF_PRO_LOCAL_ONLY;
369 cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */ 367 cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
370 : NULL, 368 : NULL,
371 (0 != memcmp (&sm->target, 369 (0 !=
372 &all_zeros, 370 memcmp (&sm->target, &all_zeros,
373 sizeof (GNUNET_HashCode))) 371 sizeof (GNUNET_HashCode)))
374 ? (const struct GNUNET_PeerIdentity *) 372 ? (const struct GNUNET_PeerIdentity *)
375 &sm->target : NULL, NULL, 0, 373 &sm->target : NULL, NULL, 0,
376 0 /* bf */ , 374 0 /* bf */ ,
@@ -418,10 +416,10 @@ transmit_to_client (void *cls, size_t size, void *buf)
418 GNUNET_free (res); 416 GNUNET_free (res);
419 } 417 }
420 if (NULL != res) 418 if (NULL != res)
421 lc->th = GNUNET_SERVER_notify_transmit_ready (lc->client, 419 lc->th =
422 res->msize, 420 GNUNET_SERVER_notify_transmit_ready (lc->client, res->msize,
423 GNUNET_TIME_UNIT_FOREVER_REL, 421 GNUNET_TIME_UNIT_FOREVER_REL,
424 &transmit_to_client, lc); 422 &transmit_to_client, lc);
425 return msize; 423 return msize;
426} 424}
427 425
@@ -448,10 +446,10 @@ GSF_local_client_transmit_ (struct GSF_LocalClient *lc,
448 memcpy (&res[1], msg, msize); 446 memcpy (&res[1], msg, msize);
449 GNUNET_CONTAINER_DLL_insert_tail (lc->res_head, lc->res_tail, res); 447 GNUNET_CONTAINER_DLL_insert_tail (lc->res_head, lc->res_tail, res);
450 if (NULL == lc->th) 448 if (NULL == lc->th)
451 lc->th = GNUNET_SERVER_notify_transmit_ready (lc->client, 449 lc->th =
452 msize, 450 GNUNET_SERVER_notify_transmit_ready (lc->client, msize,
453 GNUNET_TIME_UNIT_FOREVER_REL, 451 GNUNET_TIME_UNIT_FOREVER_REL,
454 &transmit_to_client, lc); 452 &transmit_to_client, lc);
455} 453}
456 454
457 455
@@ -479,8 +477,8 @@ GSF_client_disconnect_handler_ (void *cls, struct GNUNET_SERVER_Client *client)
479 GNUNET_CONTAINER_DLL_remove (pos->cr_head, pos->cr_tail, cr); 477 GNUNET_CONTAINER_DLL_remove (pos->cr_head, pos->cr_tail, cr);
480 GSF_pending_request_cancel_ (cr->pr, GNUNET_NO); 478 GSF_pending_request_cancel_ (cr->pr, GNUNET_NO);
481 GNUNET_STATISTICS_update (GSF_stats, 479 GNUNET_STATISTICS_update (GSF_stats,
482 gettext_noop ("# client searches active"), 480 gettext_noop ("# client searches active"), -1,
483 -1, GNUNET_NO); 481 GNUNET_NO);
484 if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task) 482 if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task)
485 GNUNET_SCHEDULER_cancel (cr->kill_task); 483 GNUNET_SCHEDULER_cancel (cr->kill_task);
486 GNUNET_free (cr); 484 GNUNET_free (cr);
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c
index d3ab5026b..58fb11cee 100644
--- a/src/fs/gnunet-service-fs_pe.c
+++ b/src/fs/gnunet-service-fs_pe.c
@@ -207,9 +207,9 @@ static unsigned long long plan_count;
207 * @param cls the 'struct GSF_ConnectedPeer' for transmission 207 * @param cls the 'struct GSF_ConnectedPeer' for transmission
208 * @param tc scheduler context 208 * @param tc scheduler context
209 */ 209 */
210static void 210static void schedule_peer_transmission (void *cls,
211schedule_peer_transmission (void *cls, 211 const struct
212 const struct GNUNET_SCHEDULER_TaskContext *tc); 212 GNUNET_SCHEDULER_TaskContext *tc);
213 213
214 214
215/** 215/**
@@ -230,8 +230,9 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
230 prd = GSF_pending_request_get_data_ (rp->prl_head->pr); 230 prd = GSF_pending_request_get_data_ (rp->prl_head->pr);
231 // FIXME: calculate 'rp->priority'! 231 // FIXME: calculate 'rp->priority'!
232 if (rp->transmission_counter < 32) 232 if (rp->transmission_counter < 32)
233 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 233 delay =
234 1LL << rp->transmission_counter); 234 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
235 1LL << rp->transmission_counter);
235 else 236 else
236 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX); 237 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX);
237 rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); 238 rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
@@ -242,13 +243,13 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
242#endif 243#endif
243 244
244 GNUNET_assert (rp->hn == NULL); 245 GNUNET_assert (rp->hn == NULL);
245 if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value 246 if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).
246 == 0) 247 rel_value == 0)
247 rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); 248 rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority);
248 else 249 else
249 rp->hn = GNUNET_CONTAINER_heap_insert (pp->delay_heap, 250 rp->hn =
250 rp, 251 GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp,
251 rp->earliest_transmission.abs_value); 252 rp->earliest_transmission.abs_value);
252 if (GNUNET_SCHEDULER_NO_TASK != pp->task) 253 if (GNUNET_SCHEDULER_NO_TASK != pp->task)
253 GNUNET_SCHEDULER_cancel (pp->task); 254 GNUNET_SCHEDULER_cancel (pp->task);
254 pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); 255 pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
@@ -358,8 +359,8 @@ schedule_peer_transmission (void *cls,
358 } 359 }
359 /* move ready requests to priority queue */ 360 /* move ready requests to priority queue */
360 while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && 361 while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) &&
361 (GNUNET_TIME_absolute_get_remaining 362 (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).
362 (rp->earliest_transmission).rel_value == 0)) 363 rel_value == 0))
363 { 364 {
364 GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); 365 GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap));
365 rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); 366 rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority);
@@ -371,17 +372,17 @@ schedule_peer_transmission (void *cls,
371 if (NULL == rp) 372 if (NULL == rp)
372 { 373 {
373#if DEBUG_FS 374#if DEBUG_FS
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No active requests for plan %p.\n",
375 "No active requests for plan %p.\n", pp); 376 pp);
376#endif 377#endif
377 return; /* both queues empty */ 378 return; /* both queues empty */
378 } 379 }
379#if DEBUG_FS 380#if DEBUG_FS
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
381 "Sleeping for %llu ms before retrying requests on plan %p.\n", 382 "Sleeping for %llu ms before retrying requests on plan %p.\n",
382 (unsigned long long) 383 (unsigned long long) GNUNET_TIME_absolute_get_remaining (rp->
383 GNUNET_TIME_absolute_get_remaining 384 earliest_transmission).
384 (rp->earliest_transmission).rel_value, pp); 385 rel_value, pp);
385#endif 386#endif
386 pp->task = 387 pp->task =
387 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 388 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
@@ -396,11 +397,10 @@ schedule_peer_transmission (void *cls,
396#endif 397#endif
397 GNUNET_assert (NULL != rp); 398 GNUNET_assert (NULL != rp);
398 msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL); 399 msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL);
399 pp->pth = GSF_peer_transmit_ (pp->cp, 400 pp->pth =
400 GNUNET_YES, 401 GSF_peer_transmit_ (pp->cp, GNUNET_YES, rp->priority,
401 rp->priority, 402 GNUNET_TIME_UNIT_FOREVER_REL, msize,
402 GNUNET_TIME_UNIT_FOREVER_REL, 403 &transmit_message_callback, pp);
403 msize, &transmit_message_callback, pp);
404 GNUNET_assert (NULL != pp->pth); 404 GNUNET_assert (NULL != pp->pth);
405} 405}
406 406
@@ -430,9 +430,8 @@ struct MergeContext
430 * GNUNET_NO if not (merge success) 430 * GNUNET_NO if not (merge success)
431 */ 431 */
432static int 432static int
433merge_pr (void *cls, 433merge_pr (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element,
434 struct GNUNET_CONTAINER_HeapNode *node, 434 GNUNET_CONTAINER_HeapCostType cost)
435 void *element, GNUNET_CONTAINER_HeapCostType cost)
436{ 435{
437 struct MergeContext *mpr = cls; 436 struct MergeContext *mpr = cls;
438 struct GSF_RequestPlan *rp = element; 437 struct GSF_RequestPlan *rp = element;
@@ -455,14 +454,13 @@ merge_pr (void *cls,
455 GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); 454 GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr);
456 GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); 455 GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl);
457 mpr->merged = GNUNET_YES; 456 mpr->merged = GNUNET_YES;
458 GNUNET_STATISTICS_update (GSF_stats, 457 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1,
459 gettext_noop ("# requests merged"), 1, GNUNET_NO); 458 GNUNET_NO);
460 latest = get_latest (rp); 459 latest = get_latest (rp);
461 if (GSF_pending_request_get_data_ (latest)->ttl.abs_value < 460 if (GSF_pending_request_get_data_ (latest)->ttl.abs_value <
462 prd->ttl.abs_value) 461 prd->ttl.abs_value)
463 { 462 {
464 GNUNET_STATISTICS_update (GSF_stats, 463 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"),
465 gettext_noop ("# requests refreshed"),
466 1, GNUNET_NO); 464 1, GNUNET_NO);
467 rp->transmission_counter = 0; /* reset */ 465 rp->transmission_counter = 0; /* reset */
468 } 466 }
@@ -498,9 +496,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
498 pp->delay_heap = 496 pp->delay_heap =
499 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 497 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
500 pp->cp = cp; 498 pp->cp = cp;
501 GNUNET_CONTAINER_multihashmap_put (plans, 499 GNUNET_CONTAINER_multihashmap_put (plans, &id.hashPubKey, pp,
502 &id.hashPubKey,
503 pp,
504 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 500 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
505 } 501 }
506 mpc.merged = GNUNET_NO; 502 mpc.merged = GNUNET_NO;
@@ -512,9 +508,8 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
512 if (mpc.merged != GNUNET_NO) 508 if (mpc.merged != GNUNET_NO)
513 return; 509 return;
514 plan_count++; 510 plan_count++;
515 GNUNET_STATISTICS_update (GSF_stats, 511 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1,
516 gettext_noop ("# query plan entries"), 512 GNUNET_NO);
517 1, GNUNET_NO);
518 prd = GSF_pending_request_get_data_ (pr); 513 prd = GSF_pending_request_get_data_ (pr);
519#if DEBUG_FS 514#if DEBUG_FS
520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -554,8 +549,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
554 if (NULL == pp) 549 if (NULL == pp)
555 return; /* nothing was ever planned for this peer */ 550 return; /* nothing was ever planned for this peer */
556 GNUNET_assert (GNUNET_YES == 551 GNUNET_assert (GNUNET_YES ==
557 GNUNET_CONTAINER_multihashmap_remove (plans, 552 GNUNET_CONTAINER_multihashmap_remove (plans, &id.hashPubKey,
558 &id.hashPubKey, pp)); 553 pp));
559 if (NULL != pp->pth) 554 if (NULL != pp->pth)
560 GSF_peer_transmit_cancel_ (pp->pth); 555 GSF_peer_transmit_cancel_ (pp->pth);
561 if (GNUNET_SCHEDULER_NO_TASK != pp->task) 556 if (GNUNET_SCHEDULER_NO_TASK != pp->task)
@@ -588,8 +583,7 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
588 } 583 }
589 GNUNET_free (rp); 584 GNUNET_free (rp);
590 } 585 }
591 GNUNET_STATISTICS_set (GSF_stats, 586 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"),
592 gettext_noop ("# query plan entries"),
593 plan_count, GNUNET_NO); 587 plan_count, GNUNET_NO);
594 588
595 GNUNET_CONTAINER_heap_destroy (pp->delay_heap); 589 GNUNET_CONTAINER_heap_destroy (pp->delay_heap);
@@ -625,8 +619,7 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr)
625 GNUNET_free (rp); 619 GNUNET_free (rp);
626 } 620 }
627 } 621 }
628 GNUNET_STATISTICS_set (GSF_stats, 622 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"),
629 gettext_noop ("# query plan entries"),
630 plan_count, GNUNET_NO); 623 plan_count, GNUNET_NO);
631} 624}
632 625
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index e637be664..7b6290bbb 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -241,8 +241,8 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
241 return GNUNET_NO; /* size not changed */ 241 return GNUNET_NO; /* size not changed */
242 if (pr->bf != NULL) 242 if (pr->bf != NULL)
243 GNUNET_CONTAINER_bloomfilter_free (pr->bf); 243 GNUNET_CONTAINER_bloomfilter_free (pr->bf);
244 pr->mingle = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 244 pr->mingle =
245 UINT32_MAX); 245 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
246 pr->bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize, BLOOMFILTER_K); 246 pr->bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize, BLOOMFILTER_K);
247 for (i = 0; i < pr->replies_seen_count; i++) 247 for (i = 0; i < pr->replies_seen_count; i++)
248 { 248 {
@@ -280,12 +280,9 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
280 const GNUNET_HashCode * query, 280 const GNUNET_HashCode * query,
281 const GNUNET_HashCode * namespace, 281 const GNUNET_HashCode * namespace,
282 const struct GNUNET_PeerIdentity *target, 282 const struct GNUNET_PeerIdentity *target,
283 const char *bf_data, 283 const char *bf_data, size_t bf_size,
284 size_t bf_size, 284 uint32_t mingle, uint32_t anonymity_level,
285 uint32_t mingle, 285 uint32_t priority, int32_t ttl,
286 uint32_t anonymity_level,
287 uint32_t priority,
288 int32_t ttl,
289 GNUNET_PEER_Id sender_pid, 286 GNUNET_PEER_Id sender_pid,
290 const GNUNET_HashCode * replies_seen, 287 const GNUNET_HashCode * replies_seen,
291 unsigned int replies_seen_count, 288 unsigned int replies_seen_count,
@@ -300,8 +297,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
300 GNUNET_h2s (query), type); 297 GNUNET_h2s (query), type);
301#endif 298#endif
302 GNUNET_STATISTICS_update (GSF_stats, 299 GNUNET_STATISTICS_update (GSF_stats,
303 gettext_noop ("# Pending requests created"), 300 gettext_noop ("# Pending requests created"), 1,
304 1, GNUNET_NO); 301 GNUNET_NO);
305 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest)); 302 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest));
306 pr->local_result_offset = 303 pr->local_result_offset =
307 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 304 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -348,8 +345,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
348 } 345 }
349 if (NULL != bf_data) 346 if (NULL != bf_data)
350 { 347 {
351 pr->bf = GNUNET_CONTAINER_bloomfilter_init (bf_data, 348 pr->bf =
352 bf_size, BLOOMFILTER_K); 349 GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, BLOOMFILTER_K);
353 pr->mingle = mingle; 350 pr->mingle = mingle;
354 } 351 }
355 else if ((replies_seen_count > 0) && 352 else if ((replies_seen_count > 0) &&
@@ -357,15 +354,13 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
357 { 354 {
358 GNUNET_assert (GNUNET_YES == refresh_bloomfilter (pr)); 355 GNUNET_assert (GNUNET_YES == refresh_bloomfilter (pr));
359 } 356 }
360 GNUNET_CONTAINER_multihashmap_put (pr_map, 357 GNUNET_CONTAINER_multihashmap_put (pr_map, query, pr,
361 query,
362 pr,
363 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 358 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
364 if (0 != (options & GSF_PRO_REQUEST_EXPIRES)) 359 if (0 != (options & GSF_PRO_REQUEST_EXPIRES))
365 { 360 {
366 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, 361 pr->hnode =
367 pr, 362 GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr,
368 pr->public_data.ttl.abs_value); 363 pr->public_data.ttl.abs_value);
369 /* make sure we don't track too many requests */ 364 /* make sure we don't track too many requests */
370 while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) > 365 while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) >
371 max_pending_requests) 366 max_pending_requests)
@@ -374,17 +369,15 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
374 GNUNET_assert (dpr != NULL); 369 GNUNET_assert (dpr != NULL);
375 if (pr == dpr) 370 if (pr == dpr)
376 break; /* let the request live briefly... */ 371 break; /* let the request live briefly... */
377 dpr->rh (dpr->rh_cls, 372 dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr,
378 GNUNET_BLOCK_EVALUATION_REQUEST_VALID, 373 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY,
379 dpr, 374 NULL, 0);
380 UINT32_MAX,
381 GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY, NULL, 0);
382 GSF_pending_request_cancel_ (dpr, GNUNET_YES); 375 GSF_pending_request_cancel_ (dpr, GNUNET_YES);
383 } 376 }
384 } 377 }
385 GNUNET_STATISTICS_update (GSF_stats, 378 GNUNET_STATISTICS_update (GSF_stats,
386 gettext_noop ("# Pending requests active"), 379 gettext_noop ("# Pending requests active"), 1,
387 1, GNUNET_NO); 380 GNUNET_NO);
388 return pr; 381 return pr;
389} 382}
390 383
@@ -416,12 +409,13 @@ GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra,
416 struct GSF_PendingRequest *prb) 409 struct GSF_PendingRequest *prb)
417{ 410{
418 if ((pra->public_data.type != prb->public_data.type) || 411 if ((pra->public_data.type != prb->public_data.type) ||
419 (0 != memcmp (&pra->public_data.query, 412 (0 !=
420 &prb->public_data.query, 413 memcmp (&pra->public_data.query, &prb->public_data.query,
421 sizeof (GNUNET_HashCode))) || 414 sizeof (GNUNET_HashCode))) ||
422 ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && 415 ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) &&
423 (0 != memcmp (&pra->public_data.namespace, 416 (0 !=
424 &prb->public_data.namespace, sizeof (GNUNET_HashCode))))) 417 memcmp (&pra->public_data.namespace, &prb->public_data.namespace,
418 sizeof (GNUNET_HashCode)))))
425 return GNUNET_NO; 419 return GNUNET_NO;
426 return GNUNET_OK; 420 return GNUNET_OK;
427} 421}
@@ -450,11 +444,10 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
450 { 444 {
451 /* we're responsible for the BF, full refresh */ 445 /* we're responsible for the BF, full refresh */
452 if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size) 446 if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size)
453 GNUNET_array_grow (pr->replies_seen, 447 GNUNET_array_grow (pr->replies_seen, pr->replies_seen_size,
454 pr->replies_seen_size,
455 replies_seen_count + pr->replies_seen_count); 448 replies_seen_count + pr->replies_seen_count);
456 memcpy (&pr->replies_seen[pr->replies_seen_count], 449 memcpy (&pr->replies_seen[pr->replies_seen_count], replies_seen,
457 replies_seen, sizeof (GNUNET_HashCode) * replies_seen_count); 450 sizeof (GNUNET_HashCode) * replies_seen_count);
458 pr->replies_seen_count += replies_seen_count; 451 pr->replies_seen_count += replies_seen_count;
459 if (GNUNET_NO == refresh_bloomfilter (pr)) 452 if (GNUNET_NO == refresh_bloomfilter (pr))
460 { 453 {
@@ -472,12 +465,13 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
472 { 465 {
473 /* we're not the initiator, but the initiator did not give us 466 /* we're not the initiator, but the initiator did not give us
474 * any bloom-filter, so we need to create one on-the-fly */ 467 * any bloom-filter, so we need to create one on-the-fly */
475 pr->mingle = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 468 pr->mingle =
476 UINT32_MAX); 469 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
477 pr->bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 470 pr->bf =
478 compute_bloomfilter_size 471 GNUNET_CONTAINER_bloomfilter_init (NULL,
479 (replies_seen_count), 472 compute_bloomfilter_size
480 BLOOMFILTER_K); 473 (replies_seen_count),
474 BLOOMFILTER_K);
481 } 475 }
482 for (i = 0; i < pr->replies_seen_count; i++) 476 for (i = 0; i < pr->replies_seen_count; i++)
483 { 477 {
@@ -552,8 +546,9 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
552 gm->header.size = htons (msize); 546 gm->header.size = htons (msize);
553 gm->type = htonl (pr->public_data.type); 547 gm->type = htonl (pr->public_data.type);
554 if (do_route) 548 if (do_route)
555 prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 549 prio =
556 pr->public_data.priority + 1); 550 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
551 pr->public_data.priority + 1);
557 else 552 else
558 prio = 0; 553 prio = 0;
559 pr->public_data.priority -= prio; 554 pr->public_data.priority -= prio;
@@ -640,8 +635,8 @@ clean_request (void *cls, const GNUNET_HashCode * key, void *value)
640 &pr->public_data.query, 635 &pr->public_data.query,
641 pr)); 636 pr));
642 GNUNET_STATISTICS_update (GSF_stats, 637 GNUNET_STATISTICS_update (GSF_stats,
643 gettext_noop ("# Pending requests active"), 638 gettext_noop ("# Pending requests active"), -1,
644 -1, GNUNET_NO); 639 GNUNET_NO);
645 GNUNET_free (pr); 640 GNUNET_free (pr);
646 return GNUNET_YES; 641 return GNUNET_YES;
647} 642}
@@ -776,8 +771,8 @@ update_request_performance_data (struct ProcessReplyClosure *prq,
776{ 771{
777 if (prq->sender == NULL) 772 if (prq->sender == NULL)
778 return; 773 return;
779 GSF_peer_update_performance_ (prq->sender, 774 GSF_peer_update_performance_ (prq->sender, pr->public_data.start_time,
780 pr->public_data.start_time, prq->priority); 775 prq->priority);
781} 776}
782 777
783 778
@@ -804,18 +799,15 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
804 (unsigned int) prq->type, GNUNET_h2s (key)); 799 (unsigned int) prq->type, GNUNET_h2s (key));
805#endif 800#endif
806 GNUNET_STATISTICS_update (GSF_stats, 801 GNUNET_STATISTICS_update (GSF_stats,
807 gettext_noop ("# replies received and matched"), 802 gettext_noop ("# replies received and matched"), 1,
808 1, GNUNET_NO); 803 GNUNET_NO);
809 prq->eval = GNUNET_BLOCK_evaluate (GSF_block_ctx, 804 prq->eval =
810 prq->type, 805 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle,
811 key, 806 &pr->public_data.namespace,
812 &pr->bf, 807 (prq->type ==
813 pr->mingle, 808 GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
814 &pr->public_data.namespace, 809 sizeof (GNUNET_HashCode) : 0, prq->data,
815 (prq->type == 810 prq->size);
816 GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
817 sizeof (GNUNET_HashCode) : 0, prq->data,
818 prq->size);
819 switch (prq->eval) 811 switch (prq->eval)
820 { 812 {
821 case GNUNET_BLOCK_EVALUATION_OK_MORE: 813 case GNUNET_BLOCK_EVALUATION_OK_MORE:
@@ -825,14 +817,12 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
825 /* short cut: stop processing early, no BF-update, etc. */ 817 /* short cut: stop processing early, no BF-update, etc. */
826 update_request_performance_data (prq, pr); 818 update_request_performance_data (prq, pr);
827 GNUNET_LOAD_update (GSF_rt_entry_lifetime, 819 GNUNET_LOAD_update (GSF_rt_entry_lifetime,
828 GNUNET_TIME_absolute_get_duration (pr-> 820 GNUNET_TIME_absolute_get_duration (pr->public_data.
829 public_data.start_time).rel_value); 821 start_time).
822 rel_value);
830 /* pass on to other peers / local clients */ 823 /* pass on to other peers / local clients */
831 pr->rh (pr->rh_cls, 824 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
832 prq->eval, 825 prq->type, prq->data, prq->size);
833 pr,
834 prq->anonymity_level,
835 prq->expiration, prq->type, prq->data, prq->size);
836 return GNUNET_YES; 826 return GNUNET_YES;
837 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: 827 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
838 GNUNET_STATISTICS_update (GSF_stats, 828 GNUNET_STATISTICS_update (GSF_stats,
@@ -853,8 +843,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
853 GNUNET_break (0); 843 GNUNET_break (0);
854 return GNUNET_YES; 844 return GNUNET_YES;
855 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: 845 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
856 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 846 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unsupported block type %u\n"),
857 _("Unsupported block type %u\n"), prq->type); 847 prq->type);
858 return GNUNET_NO; 848 return GNUNET_NO;
859 } 849 }
860 /* update bloomfilter */ 850 /* update bloomfilter */
@@ -868,8 +858,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
868 GNUNET_h2s (key)); 858 GNUNET_h2s (key));
869#endif 859#endif
870 GNUNET_STATISTICS_update (GSF_stats, 860 GNUNET_STATISTICS_update (GSF_stats,
871 gettext_noop ("# results found locally"), 861 gettext_noop ("# results found locally"), 1,
872 1, GNUNET_NO); 862 GNUNET_NO);
873 } 863 }
874 else 864 else
875 { 865 {
@@ -881,11 +871,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
881 pr->public_data.results_found++; 871 pr->public_data.results_found++;
882 prq->request_found = GNUNET_YES; 872 prq->request_found = GNUNET_YES;
883 /* finally, pass on to other peer / local client */ 873 /* finally, pass on to other peer / local client */
884 pr->rh (pr->rh_cls, 874 pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration,
885 prq->eval, 875 prq->type, prq->data, prq->size);
886 pr,
887 prq->anonymity_level,
888 prq->expiration, prq->type, prq->data, prq->size);
889 return GNUNET_YES; 876 return GNUNET_YES;
890} 877}
891 878
@@ -940,12 +927,11 @@ put_migration_continuation (void *cls, int success, const char *msg)
940 { 927 {
941 ppd = GSF_get_peer_performance_data_ (cp); 928 ppd = GSF_get_peer_performance_data_ (cp);
942 ppd->migration_duplication++; 929 ppd->migration_duplication++;
943 block_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 930 block_time =
944 5 * 931 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
945 ppd->migration_duplication + 932 5 * ppd->migration_duplication +
946 GNUNET_CRYPTO_random_u32 933 GNUNET_CRYPTO_random_u32
947 (GNUNET_CRYPTO_QUALITY_WEAK, 934 (GNUNET_CRYPTO_QUALITY_WEAK, 5));
948 5));
949 GSF_block_peer_migration_ (cp, block_time); 935 GSF_block_peer_migration_ (cp, block_time);
950 } 936 }
951 } 937 }
@@ -964,8 +950,8 @@ put_migration_continuation (void *cls, int success, const char *msg)
964 if (GNUNET_OK == success) 950 if (GNUNET_OK == success)
965 return; 951 return;
966 GNUNET_STATISTICS_update (GSF_stats, 952 GNUNET_STATISTICS_update (GSF_stats,
967 gettext_noop ("# Datastore `PUT' failures"), 953 gettext_noop ("# Datastore `PUT' failures"), 1,
968 1, GNUNET_NO); 954 GNUNET_NO);
969} 955}
970 956
971 957
@@ -1013,8 +999,7 @@ test_put_load_too_high (uint32_t priority)
1013 * @param data pointer to the result data 999 * @param data pointer to the result data
1014 */ 1000 */
1015static void 1001static void
1016handle_dht_reply (void *cls, 1002handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
1017 struct GNUNET_TIME_Absolute exp,
1018 const GNUNET_HashCode * key, 1003 const GNUNET_HashCode * key,
1019 const struct GNUNET_PeerIdentity *const *get_path, 1004 const struct GNUNET_PeerIdentity *const *get_path,
1020 const struct GNUNET_PeerIdentity *const *put_path, 1005 const struct GNUNET_PeerIdentity *const *put_path,
@@ -1025,8 +1010,8 @@ handle_dht_reply (void *cls,
1025 struct PutMigrationContext *pmc; 1010 struct PutMigrationContext *pmc;
1026 1011
1027 GNUNET_STATISTICS_update (GSF_stats, 1012 GNUNET_STATISTICS_update (GSF_stats,
1028 gettext_noop ("# Replies received from DHT"), 1013 gettext_noop ("# Replies received from DHT"), 1,
1029 1, GNUNET_NO); 1014 GNUNET_NO);
1030 memset (&prq, 0, sizeof (prq)); 1015 memset (&prq, 0, sizeof (prq));
1031 prq.data = data; 1016 prq.data = data;
1032 prq.expiration = exp; 1017 prq.expiration = exp;
@@ -1045,12 +1030,10 @@ handle_dht_reply (void *cls,
1045 pmc->start = GNUNET_TIME_absolute_get (); 1030 pmc->start = GNUNET_TIME_absolute_get ();
1046 pmc->requested = GNUNET_YES; 1031 pmc->requested = GNUNET_YES;
1047 if (NULL == 1032 if (NULL ==
1048 GNUNET_DATASTORE_put (GSF_dsh, 1033 GNUNET_DATASTORE_put (GSF_dsh, 0, key, size, data, type, prq.priority,
1049 0, key, size, data, 1034 1 /* anonymity */ ,
1050 type, prq.priority, 1 /* anonymity */ ,
1051 0 /* replication */ , 1035 0 /* replication */ ,
1052 exp, 1036 exp, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1053 1 + prq.priority, MAX_DATASTORE_QUEUE,
1054 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1037 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1055 &put_migration_continuation, pmc)) 1038 &put_migration_continuation, pmc))
1056 { 1039 {
@@ -1095,15 +1078,13 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1095 memcpy (&buf[xquery_size], &pi, sizeof (struct GNUNET_PeerIdentity)); 1078 memcpy (&buf[xquery_size], &pi, sizeof (struct GNUNET_PeerIdentity));
1096 xquery_size += sizeof (struct GNUNET_PeerIdentity); 1079 xquery_size += sizeof (struct GNUNET_PeerIdentity);
1097 } 1080 }
1098 pr->gh = GNUNET_DHT_get_start (GSF_dht, 1081 pr->gh =
1099 GNUNET_TIME_UNIT_FOREVER_REL, 1082 GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL,
1100 pr->public_data.type, 1083 pr->public_data.type, &pr->public_data.query,
1101 &pr->public_data.query, 1084 DEFAULT_GET_REPLICATION,
1102 DEFAULT_GET_REPLICATION, 1085 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, pr->bf,
1103 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 1086 pr->mingle, xquery, xquery_size, &handle_dht_reply,
1104 pr->bf, 1087 pr);
1105 pr->mingle,
1106 xquery, xquery_size, &handle_dht_reply, pr);
1107} 1088}
1108 1089
1109 1090
@@ -1120,8 +1101,9 @@ warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1120 1101
1121 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1102 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1122 _("Datastore lookup already took %llu ms!\n"), 1103 _("Datastore lookup already took %llu ms!\n"),
1123 (unsigned long long) 1104 (unsigned long long) GNUNET_TIME_absolute_get_duration (pr->
1124 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value); 1105 qe_start).
1106 rel_value);
1125 pr->warn_task = 1107 pr->warn_task =
1126 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, 1108 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1127 pr); 1109 pr);
@@ -1141,8 +1123,9 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1141 1123
1142 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1124 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1143 _("On-demand lookup already took %llu ms!\n"), 1125 _("On-demand lookup already took %llu ms!\n"),
1144 (unsigned long long) 1126 (unsigned long long) GNUNET_TIME_absolute_get_duration (pr->
1145 GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value); 1127 qe_start).
1128 rel_value);
1146 pr->warn_task = 1129 pr->warn_task =
1147 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1130 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1148 &odc_warn_delay_task, pr); 1131 &odc_warn_delay_task, pr);
@@ -1167,13 +1150,9 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1167 * maybe 0 if no unique identifier is available 1150 * maybe 0 if no unique identifier is available
1168 */ 1151 */
1169static void 1152static void
1170process_local_reply (void *cls, 1153process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1171 const GNUNET_HashCode * key, 1154 const void *data, enum GNUNET_BLOCK_Type type,
1172 size_t size, 1155 uint32_t priority, uint32_t anonymity,
1173 const void *data,
1174 enum GNUNET_BLOCK_Type type,
1175 uint32_t priority,
1176 uint32_t anonymity,
1177 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 1156 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
1178{ 1157{
1179 struct GSF_PendingRequest *pr = cls; 1158 struct GSF_PendingRequest *pr = cls;
@@ -1250,8 +1229,9 @@ process_local_reply (void *cls,
1250 ("# on-demand blocks matched requests"), 1, 1229 ("# on-demand blocks matched requests"), 1,
1251 GNUNET_NO); 1230 GNUNET_NO);
1252 pr->qe_start = GNUNET_TIME_absolute_get (); 1231 pr->qe_start = GNUNET_TIME_absolute_get ();
1253 pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1232 pr->warn_task =
1254 &odc_warn_delay_task, pr); 1233 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1234 &odc_warn_delay_task, pr);
1255 if (GNUNET_OK == 1235 if (GNUNET_OK ==
1256 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, 1236 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority,
1257 anonymity, expiration, uid, 1237 anonymity, expiration, uid,
@@ -1264,30 +1244,28 @@ process_local_reply (void *cls,
1264 return; /* we're done */ 1244 return; /* we're done */
1265 } 1245 }
1266 GNUNET_STATISTICS_update (GSF_stats, 1246 GNUNET_STATISTICS_update (GSF_stats,
1267 gettext_noop ("# on-demand lookups failed"), 1247 gettext_noop ("# on-demand lookups failed"), 1,
1268 1, GNUNET_NO); 1248 GNUNET_NO);
1269 GNUNET_SCHEDULER_cancel (pr->warn_task); 1249 GNUNET_SCHEDULER_cancel (pr->warn_task);
1270 pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1250 pr->warn_task =
1271 &warn_delay_task, pr); 1251 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1272 pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, 1252 &warn_delay_task, pr);
1273 pr->local_result_offset - 1, 1253 pr->qe =
1274 &pr->public_data.query, 1254 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1275 pr->public_data.type == 1255 &pr->public_data.query,
1276 GNUNET_BLOCK_TYPE_FS_DBLOCK ? 1256 pr->public_data.type ==
1277 GNUNET_BLOCK_TYPE_ANY : pr-> 1257 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1278 public_data.type, 1258 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1279 (0 != 1259 (0 !=
1280 (GSF_PRO_PRIORITY_UNLIMITED & 1260 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1281 pr->public_data. 1261 public_data.options)) ? UINT_MAX : 1
1282 options)) ? UINT_MAX : 1 1262 /* queue priority */ ,
1283 /* queue priority */ , 1263 (0 !=
1284 (0 != 1264 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1285 (GSF_PRO_PRIORITY_UNLIMITED & 1265 public_data.options)) ? UINT_MAX : 1
1286 pr->public_data.options)) ? UINT_MAX : 1266 /* max queue size */ ,
1287 1 1267 GNUNET_TIME_UNIT_FOREVER_REL,
1288 /* max queue size */ , 1268 &process_local_reply, pr);
1289 GNUNET_TIME_UNIT_FOREVER_REL,
1290 &process_local_reply, pr);
1291 if (NULL != pr->qe) 1269 if (NULL != pr->qe)
1292 { 1270 {
1293 GNUNET_STATISTICS_update (GSF_stats, 1271 GNUNET_STATISTICS_update (GSF_stats,
@@ -1307,32 +1285,28 @@ process_local_reply (void *cls,
1307 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query)) 1285 GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query))
1308 { 1286 {
1309 GNUNET_break (0); 1287 GNUNET_break (0);
1310 GNUNET_DATASTORE_remove (GSF_dsh, 1288 GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1,
1311 key, 1289 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
1312 size, data,
1313 -1, -1, GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
1314 pr->qe_start = GNUNET_TIME_absolute_get (); 1290 pr->qe_start = GNUNET_TIME_absolute_get ();
1315 pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1291 pr->warn_task =
1316 &warn_delay_task, pr); 1292 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1317 pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, 1293 &warn_delay_task, pr);
1318 pr->local_result_offset - 1, 1294 pr->qe =
1319 &pr->public_data.query, 1295 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1,
1320 pr->public_data.type == 1296 &pr->public_data.query,
1321 GNUNET_BLOCK_TYPE_FS_DBLOCK ? 1297 pr->public_data.type ==
1322 GNUNET_BLOCK_TYPE_ANY : pr-> 1298 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1323 public_data.type, 1299 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1324 (0 != 1300 (0 !=
1325 (GSF_PRO_PRIORITY_UNLIMITED & 1301 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1326 pr->public_data. 1302 public_data.options)) ? UINT_MAX : 1
1327 options)) ? UINT_MAX : 1 1303 /* queue priority */ ,
1328 /* queue priority */ , 1304 (0 !=
1329 (0 != 1305 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1330 (GSF_PRO_PRIORITY_UNLIMITED & 1306 public_data.options)) ? UINT_MAX : 1
1331 pr->public_data.options)) ? UINT_MAX : 1307 /* max queue size */ ,
1332 1 1308 GNUNET_TIME_UNIT_FOREVER_REL,
1333 /* max queue size */ , 1309 &process_local_reply, pr);
1334 GNUNET_TIME_UNIT_FOREVER_REL,
1335 &process_local_reply, pr);
1336 if (pr->qe == NULL) 1310 if (pr->qe == NULL)
1337 { 1311 {
1338 GNUNET_STATISTICS_update (GSF_stats, 1312 GNUNET_STATISTICS_update (GSF_stats,
@@ -1373,25 +1347,25 @@ process_local_reply (void *cls,
1373 goto check_error_and_continue; 1347 goto check_error_and_continue;
1374 } 1348 }
1375 pr->qe_start = GNUNET_TIME_absolute_get (); 1349 pr->qe_start = GNUNET_TIME_absolute_get ();
1376 pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1350 pr->warn_task =
1377 &warn_delay_task, pr); 1351 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1378 pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, 1352 pr);
1379 pr->local_result_offset++, 1353 pr->qe =
1380 &pr->public_data.query, 1354 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1381 pr->public_data.type == 1355 &pr->public_data.query,
1382 GNUNET_BLOCK_TYPE_FS_DBLOCK ? 1356 pr->public_data.type ==
1383 GNUNET_BLOCK_TYPE_ANY : pr-> 1357 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1384 public_data.type, 1358 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1385 (0 != 1359 (0 !=
1386 (GSF_PRO_PRIORITY_UNLIMITED & 1360 (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.
1387 pr->public_data.options)) ? UINT_MAX : 1 1361 options)) ? UINT_MAX : 1
1388 /* queue priority */ , 1362 /* queue priority */ ,
1389 (0 != 1363 (0 !=
1390 (GSF_PRO_PRIORITY_UNLIMITED & 1364 (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.
1391 pr->public_data.options)) ? UINT_MAX : 1 1365 options)) ? UINT_MAX : 1
1392 /* max queue size */ , 1366 /* max queue size */ ,
1393 GNUNET_TIME_UNIT_FOREVER_REL, 1367 GNUNET_TIME_UNIT_FOREVER_REL,
1394 &process_local_reply, pr); 1368 &process_local_reply, pr);
1395 /* check if we successfully queued another datastore request; 1369 /* check if we successfully queued another datastore request;
1396 * if so, return, otherwise call our continuation (if we have 1370 * if so, return, otherwise call our continuation (if we have
1397 * any) */ 1371 * any) */
@@ -1426,28 +1400,28 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1426 pr->llc_cont = cont; 1400 pr->llc_cont = cont;
1427 pr->llc_cont_cls = cont_cls; 1401 pr->llc_cont_cls = cont_cls;
1428 pr->qe_start = GNUNET_TIME_absolute_get (); 1402 pr->qe_start = GNUNET_TIME_absolute_get ();
1429 pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 1403 pr->warn_task =
1430 &warn_delay_task, pr); 1404 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task,
1405 pr);
1431 GNUNET_STATISTICS_update (GSF_stats, 1406 GNUNET_STATISTICS_update (GSF_stats,
1432 gettext_noop ("# Datastore lookups initiated"), 1407 gettext_noop ("# Datastore lookups initiated"), 1,
1433 1, GNUNET_NO); 1408 GNUNET_NO);
1434 pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, 1409 pr->qe =
1435 pr->local_result_offset++, 1410 GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++,
1436 &pr->public_data.query, 1411 &pr->public_data.query,
1437 pr->public_data.type == 1412 pr->public_data.type ==
1438 GNUNET_BLOCK_TYPE_FS_DBLOCK ? 1413 GNUNET_BLOCK_TYPE_FS_DBLOCK ?
1439 GNUNET_BLOCK_TYPE_ANY : pr-> 1414 GNUNET_BLOCK_TYPE_ANY : pr->public_data.type,
1440 public_data.type, 1415 (0 !=
1441 (0 != 1416 (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.
1442 (GSF_PRO_PRIORITY_UNLIMITED & 1417 options)) ? UINT_MAX : 1
1443 pr->public_data.options)) ? UINT_MAX : 1 1418 /* queue priority */ ,
1444 /* queue priority */ , 1419 (0 !=
1445 (0 != 1420 (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.
1446 (GSF_PRO_PRIORITY_UNLIMITED & 1421 options)) ? UINT_MAX : 1
1447 pr->public_data.options)) ? UINT_MAX : 1 1422 /* max queue size */ ,
1448 /* max queue size */ , 1423 GNUNET_TIME_UNIT_FOREVER_REL,
1449 GNUNET_TIME_UNIT_FOREVER_REL, 1424 &process_local_reply, pr);
1450 &process_local_reply, pr);
1451 if (NULL != pr->qe) 1425 if (NULL != pr->qe)
1452 { 1426 {
1453 GNUNET_STATISTICS_update (GSF_stats, 1427 GNUNET_STATISTICS_update (GSF_stats,
@@ -1513,8 +1487,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1513 return GNUNET_SYSERR; 1487 return GNUNET_SYSERR;
1514 } 1488 }
1515 GNUNET_STATISTICS_update (GSF_stats, 1489 GNUNET_STATISTICS_update (GSF_stats,
1516 gettext_noop ("# GAP PUT messages received"), 1490 gettext_noop ("# GAP PUT messages received"), 1,
1517 1, GNUNET_NO); 1491 GNUNET_NO);
1518 /* now, lookup 'query' */ 1492 /* now, lookup 'query' */
1519 prq.data = (const void *) &put[1]; 1493 prq.data = (const void *) &put[1];
1520 if (NULL != cp) 1494 if (NULL != cp)
@@ -1527,8 +1501,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1527 prq.priority = 0; 1501 prq.priority = 0;
1528 prq.anonymity_level = UINT32_MAX; 1502 prq.anonymity_level = UINT32_MAX;
1529 prq.request_found = GNUNET_NO; 1503 prq.request_found = GNUNET_NO;
1530 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, 1504 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply,
1531 &query, &process_reply, &prq); 1505 &prq);
1532 if (NULL != cp) 1506 if (NULL != cp)
1533 { 1507 {
1534 GSF_connected_peer_change_preference_ (cp, 1508 GSF_connected_peer_change_preference_ (cp,
@@ -1551,12 +1525,10 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1551 GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid, 1525 GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid,
1552 &pmc->origin); 1526 &pmc->origin);
1553 if (NULL == 1527 if (NULL ==
1554 GNUNET_DATASTORE_put (GSF_dsh, 1528 GNUNET_DATASTORE_put (GSF_dsh, 0, &query, dsize, &put[1], type,
1555 0, &query, dsize, &put[1], 1529 prq.priority, 1 /* anonymity */ ,
1556 type, prq.priority, 1 /* anonymity */ ,
1557 0 /* replication */ , 1530 0 /* replication */ ,
1558 expiration, 1531 expiration, 1 + prq.priority, MAX_DATASTORE_QUEUE,
1559 1 + prq.priority, MAX_DATASTORE_QUEUE,
1560 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1532 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1561 &put_migration_continuation, pmc)) 1533 &put_migration_continuation, pmc))
1562 { 1534 {
@@ -1568,24 +1540,23 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1568#if DEBUG_FS 1540#if DEBUG_FS
1569 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1570 "Choosing not to keep content `%s' (%d/%d)\n", 1542 "Choosing not to keep content `%s' (%d/%d)\n",
1571 GNUNET_h2s (&query), 1543 GNUNET_h2s (&query), active_to_migration,
1572 active_to_migration, test_put_load_too_high (prq.priority)); 1544 test_put_load_too_high (prq.priority));
1573#endif 1545#endif
1574 } 1546 }
1575 putl = GNUNET_LOAD_get_load (datastore_put_load); 1547 putl = GNUNET_LOAD_get_load (datastore_put_load);
1576 if ((NULL != (cp = prq.sender)) && 1548 if ((NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) &&
1577 (GNUNET_NO == prq.request_found) &&
1578 ((GNUNET_YES != active_to_migration) || 1549 ((GNUNET_YES != active_to_migration) ||
1579 (putl > 2.5 * (1 + prq.priority)))) 1550 (putl > 2.5 * (1 + prq.priority))))
1580 { 1551 {
1581 if (GNUNET_YES != active_to_migration) 1552 if (GNUNET_YES != active_to_migration)
1582 putl = 1.0 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5); 1553 putl = 1.0 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5);
1583 block_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1554 block_time =
1584 5000 + 1555 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1585 GNUNET_CRYPTO_random_u32 1556 5000 +
1586 (GNUNET_CRYPTO_QUALITY_WEAK, 1557 GNUNET_CRYPTO_random_u32
1587 (unsigned int) (60000 * putl * 1558 (GNUNET_CRYPTO_QUALITY_WEAK,
1588 putl))); 1559 (unsigned int) (60000 * putl * putl)));
1589 GSF_block_peer_migration_ (cp, block_time); 1560 GSF_block_peer_migration_ (cp, block_time);
1590 } 1561 }
1591 return GNUNET_OK; 1562 return GNUNET_OK;
@@ -1599,8 +1570,7 @@ void
1599GSF_pending_request_init_ () 1570GSF_pending_request_init_ ()
1600{ 1571{
1601 if (GNUNET_OK != 1572 if (GNUNET_OK !=
1602 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, 1573 GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "fs",
1603 "fs",
1604 "MAX_PENDING_REQUESTS", 1574 "MAX_PENDING_REQUESTS",
1605 &max_pending_requests)) 1575 &max_pending_requests))
1606 { 1576 {
@@ -1609,9 +1579,8 @@ GSF_pending_request_init_ ()
1609 ("Configuration fails to specify `%s', assuming default value."), 1579 ("Configuration fails to specify `%s', assuming default value."),
1610 "MAX_PENDING_REQUESTS"); 1580 "MAX_PENDING_REQUESTS");
1611 } 1581 }
1612 active_to_migration = GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, 1582 active_to_migration =
1613 "FS", 1583 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
1614 "CONTENT_CACHING");
1615 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); 1584 datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
1616 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); 1585 pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024);
1617 requests_by_expiration_heap = 1586 requests_by_expiration_heap =
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c
index 108fce5fc..6d8c05999 100644
--- a/src/fs/gnunet-service-fs_push.c
+++ b/src/fs/gnunet-service-fs_push.c
@@ -227,8 +227,8 @@ transmit_message (void *cls, size_t buf_size, void *buf)
227 memcpy (buf, msg, msize); 227 memcpy (buf, msg, msize);
228 GNUNET_free (msg); 228 GNUNET_free (msg);
229#if DEBUG_FS_MIGRATION 229#if DEBUG_FS_MIGRATION
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pushing %u bytes to another peer\n",
231 "Pushing %u bytes to another peer\n", msize); 231 msize);
232#endif 232#endif
233 find_content (peer); 233 find_content (peer);
234 return msize; 234 return msize;
@@ -285,8 +285,8 @@ transmit_content (struct MigrationReadyPeer *peer,
285 "Asking for transmission of %u bytes for migration\n", msize); 285 "Asking for transmission of %u bytes for migration\n", msize);
286#endif 286#endif
287 peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ , 287 peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ ,
288 GNUNET_TIME_UNIT_FOREVER_REL, 288 GNUNET_TIME_UNIT_FOREVER_REL, msize,
289 msize, &transmit_message, peer); 289 &transmit_message, peer);
290 return ret; 290 return ret;
291} 291}
292 292
@@ -421,9 +421,9 @@ find_content (struct MigrationReadyPeer *mrp)
421 * @param cls unused 421 * @param cls unused
422 * @param tc scheduler context (also unused) 422 * @param tc scheduler context (also unused)
423 */ 423 */
424static void 424static void gather_migration_blocks (void *cls,
425gather_migration_blocks (void *cls, 425 const struct GNUNET_SCHEDULER_TaskContext
426 const struct GNUNET_SCHEDULER_TaskContext *tc); 426 *tc);
427 427
428 428
429/** 429/**
@@ -450,8 +450,8 @@ consider_gathering ()
450 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 450 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
451 "Scheduling gathering task (queue size: %u)\n", mig_size); 451 "Scheduling gathering task (queue size: %u)\n", mig_size);
452#endif 452#endif
453 mig_task = GNUNET_SCHEDULER_add_delayed (delay, 453 mig_task =
454 &gather_migration_blocks, NULL); 454 GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL);
455} 455}
456 456
457 457
@@ -470,13 +470,9 @@ consider_gathering ()
470 * maybe 0 if no unique identifier is available 470 * maybe 0 if no unique identifier is available
471 */ 471 */
472static void 472static void
473process_migration_content (void *cls, 473process_migration_content (void *cls, const GNUNET_HashCode * key, size_t size,
474 const GNUNET_HashCode * key, 474 const void *data, enum GNUNET_BLOCK_Type type,
475 size_t size, 475 uint32_t priority, uint32_t anonymity,
476 const void *data,
477 enum GNUNET_BLOCK_Type type,
478 uint32_t priority,
479 uint32_t anonymity,
480 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 476 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
481{ 477{
482 struct MigrationReadyBlock *mb; 478 struct MigrationReadyBlock *mb;
@@ -501,9 +497,8 @@ process_migration_content (void *cls,
501 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND) 497 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
502 { 498 {
503 if (GNUNET_OK != 499 if (GNUNET_OK !=
504 GNUNET_FS_handle_on_demand_block (key, size, data, 500 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority,
505 type, priority, anonymity, 501 anonymity, expiration, uid,
506 expiration, uid,
507 &process_migration_content, NULL)) 502 &process_migration_content, NULL))
508 consider_gathering (); 503 consider_gathering ();
509 return; 504 return;
@@ -560,11 +555,10 @@ gather_migration_blocks (void *cls,
560 "Asking datastore for content for replication (queue size: %u)\n", 555 "Asking datastore for content for replication (queue size: %u)\n",
561 mig_size); 556 mig_size);
562#endif 557#endif
563 mig_qe = GNUNET_DATASTORE_get_for_replication (GSF_dsh, 558 mig_qe =
564 0, UINT_MAX, 559 GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX,
565 GNUNET_TIME_UNIT_FOREVER_REL, 560 GNUNET_TIME_UNIT_FOREVER_REL,
566 &process_migration_content, 561 &process_migration_content, NULL);
567 NULL);
568 if (NULL == mig_qe) 562 if (NULL == mig_qe)
569 consider_gathering (); 563 consider_gathering ();
570 } 564 }
@@ -632,15 +626,13 @@ GSF_push_stop_ (struct GSF_ConnectedPeer *peer)
632void 626void
633GSF_push_init_ () 627GSF_push_init_ ()
634{ 628{
635 enabled = GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, 629 enabled =
636 "FS", "CONTENT_PUSHING"); 630 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_PUSHING");
637 if (GNUNET_YES != enabled) 631 if (GNUNET_YES != enabled)
638 return; 632 return;
639 633
640 if (GNUNET_OK != 634 if (GNUNET_OK !=
641 GNUNET_CONFIGURATION_get_value_time (GSF_cfg, 635 GNUNET_CONFIGURATION_get_value_time (GSF_cfg, "fs", "MIN_MIGRATION_DELAY",
642 "fs",
643 "MIN_MIGRATION_DELAY",
644 &min_migration_delay)) 636 &min_migration_delay))
645 { 637 {
646 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 638 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c
index e67bf0c04..ec2344b37 100644
--- a/src/fs/gnunet-service-fs_put.c
+++ b/src/fs/gnunet-service-fs_put.c
@@ -86,9 +86,9 @@ static struct PutOperator operators[] = {
86 * @param cls type of blocks to gather 86 * @param cls type of blocks to gather
87 * @param tc scheduler context (unused) 87 * @param tc scheduler context (unused)
88 */ 88 */
89static void 89static void gather_dht_put_blocks (void *cls,
90gather_dht_put_blocks (void *cls, 90 const struct GNUNET_SCHEDULER_TaskContext
91 const struct GNUNET_SCHEDULER_TaskContext *tc); 91 *tc);
92 92
93 93
94/** 94/**
@@ -108,8 +108,9 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108 return; 108 return;
109 if (po->zero_anonymity_count_estimate > 0) 109 if (po->zero_anonymity_count_estimate > 0)
110 { 110 {
111 delay = GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, 111 delay =
112 po->zero_anonymity_count_estimate); 112 GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY,
113 po->zero_anonymity_count_estimate);
113 delay = GNUNET_TIME_relative_min (delay, MAX_DHT_PUT_FREQ); 114 delay = GNUNET_TIME_relative_min (delay, MAX_DHT_PUT_FREQ);
114 } 115 }
115 else 116 else
@@ -118,8 +119,8 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
118 * (hopefully) appear */ 119 * (hopefully) appear */
119 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); 120 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5);
120 } 121 }
121 po->dht_task = GNUNET_SCHEDULER_add_delayed (delay, 122 po->dht_task =
122 &gather_dht_put_blocks, po); 123 GNUNET_SCHEDULER_add_delayed (delay, &gather_dht_put_blocks, po);
123} 124}
124 125
125 126
@@ -138,13 +139,9 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
138 * maybe 0 if no unique identifier is available 139 * maybe 0 if no unique identifier is available
139 */ 140 */
140static void 141static void
141process_dht_put_content (void *cls, 142process_dht_put_content (void *cls, const GNUNET_HashCode * key, size_t size,
142 const GNUNET_HashCode * key, 143 const void *data, enum GNUNET_BLOCK_Type type,
143 size_t size, 144 uint32_t priority, uint32_t anonymity,
144 const void *data,
145 enum GNUNET_BLOCK_Type type,
146 uint32_t priority,
147 uint32_t anonymity,
148 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 145 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
149{ 146{
150 struct PutOperator *po = cls; 147 struct PutOperator *po = cls;
@@ -157,22 +154,16 @@ process_dht_put_content (void *cls,
157 po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po); 154 po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po);
158 return; 155 return;
159 } 156 }
160 po->zero_anonymity_count_estimate = GNUNET_MAX (po->current_offset, 157 po->zero_anonymity_count_estimate =
161 po->zero_anonymity_count_estimate); 158 GNUNET_MAX (po->current_offset, po->zero_anonymity_count_estimate);
162#if DEBUG_FS 159#if DEBUG_FS
163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
164 "Retrieved block `%s' of type %u for DHT PUT\n", 161 "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key),
165 GNUNET_h2s (key), type); 162 type);
166#endif 163#endif
167 GNUNET_DHT_put (GSF_dht, 164 GNUNET_DHT_put (GSF_dht, key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE,
168 key, 165 type, size, data, expiration, GNUNET_TIME_UNIT_FOREVER_REL,
169 DEFAULT_PUT_REPLICATION, 166 &delay_dht_put_blocks, po);
170 GNUNET_DHT_RO_NONE,
171 type,
172 size,
173 data,
174 expiration,
175 GNUNET_TIME_UNIT_FOREVER_REL, &delay_dht_put_blocks, po);
176} 167}
177 168
178 169
@@ -190,13 +181,12 @@ gather_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
190 po->dht_task = GNUNET_SCHEDULER_NO_TASK; 181 po->dht_task = GNUNET_SCHEDULER_NO_TASK;
191 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 182 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
192 return; 183 return;
193 po->dht_qe = GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, 184 po->dht_qe =
194 po->current_offset++, 185 GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0,
195 0, UINT_MAX, 186 UINT_MAX,
196 GNUNET_TIME_UNIT_FOREVER_REL, 187 GNUNET_TIME_UNIT_FOREVER_REL,
197 po->dht_put_type, 188 po->dht_put_type,
198 &process_dht_put_content, 189 &process_dht_put_content, po);
199 po);
200 if (NULL == po->dht_qe) 190 if (NULL == po->dht_qe)
201 po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po); 191 po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po);
202} 192}
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index a4aad4568..d52956a75 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -86,16 +86,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
86 if (verbose) 86 if (verbose)
87 { 87 {
88 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta); 88 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta);
89 fprintf (stdout, 89 fprintf (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"),
90 _("Unindexing at %llu/%llu (%s remaining)\n"),
91 (unsigned long long) info->value.unindex.completed, 90 (unsigned long long) info->value.unindex.completed,
92 (unsigned long long) info->value.unindex.size, s); 91 (unsigned long long) info->value.unindex.size, s);
93 GNUNET_free (s); 92 GNUNET_free (s);
94 } 93 }
95 break; 94 break;
96 case GNUNET_FS_STATUS_UNINDEX_ERROR: 95 case GNUNET_FS_STATUS_UNINDEX_ERROR:
97 fprintf (stderr, 96 fprintf (stderr, _("Error unindexing: %s.\n"),
98 _("Error unindexing: %s.\n"),
99 info->value.unindex.specifics.error.message); 97 info->value.unindex.specifics.error.message);
100 GNUNET_SCHEDULER_shutdown (); 98 GNUNET_SCHEDULER_shutdown ();
101 break; 99 break;
@@ -104,8 +102,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
104 GNUNET_SCHEDULER_shutdown (); 102 GNUNET_SCHEDULER_shutdown ();
105 break; 103 break;
106 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 104 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
107 GNUNET_SCHEDULER_add_continuation (&cleanup_task, 105 GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL,
108 NULL,
109 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 106 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
110 break; 107 break;
111 default: 108 default:
@@ -125,9 +122,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
125 * @param c configuration 122 * @param c configuration
126 */ 123 */
127static void 124static void
128run (void *cls, 125run (void *cls, char *const *args, const char *cfgfile,
129 char *const *args, 126 const struct GNUNET_CONFIGURATION_Handle *c)
130 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
131{ 127{
132 /* check arguments */ 128 /* check arguments */
133 if ((args[0] == NULL) || (args[1] != NULL)) 129 if ((args[0] == NULL) || (args[1] != NULL))
@@ -137,10 +133,9 @@ run (void *cls,
137 return; 133 return;
138 } 134 }
139 cfg = c; 135 cfg = c;
140 ctx = GNUNET_FS_start (cfg, 136 ctx =
141 "gnunet-unindex", 137 GNUNET_FS_start (cfg, "gnunet-unindex", &progress_cb, NULL,
142 &progress_cb, 138 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
143 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
144 if (NULL == ctx) 139 if (NULL == ctx)
145 { 140 {
146 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); 141 fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
@@ -154,8 +149,8 @@ run (void *cls,
154 GNUNET_FS_stop (ctx); 149 GNUNET_FS_stop (ctx);
155 return; 150 return;
156 } 151 }
157 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 152 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
158 &shutdown_task, NULL); 153 NULL);
159} 154}
160 155
161 156
@@ -176,9 +171,7 @@ main (int argc, char *const *argv)
176 GNUNET_GETOPT_OPTION_END 171 GNUNET_GETOPT_OPTION_END
177 }; 172 };
178 return (GNUNET_OK == 173 return (GNUNET_OK ==
179 GNUNET_PROGRAM_run (argc, 174 GNUNET_PROGRAM_run (argc, argv, "gnunet-unindex [OPTIONS] FILENAME",
180 argv,
181 "gnunet-unindex [OPTIONS] FILENAME",
182 gettext_noop 175 gettext_noop
183 ("Unindex a file that was previously indexed with gnunet-publish."), 176 ("Unindex a file that was previously indexed with gnunet-publish."),
184 options, &run, NULL)) ? ret : 1; 177 options, &run, NULL)) ? ret : 1;
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c
index 92441e901..0737ea949 100644
--- a/src/fs/perf_gnunet_service_fs_p2p.c
+++ b/src/fs/perf_gnunet_service_fs_p2p.c
@@ -115,15 +115,13 @@ static struct StatValues stats[] = {
115 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 115 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
116 */ 116 */
117static int 117static int
118print_stat (void *cls, 118print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
119 const char *subsystem, 119 int is_persistent)
120 const char *name, uint64_t value, int is_persistent)
121{ 120{
122 struct StatMaster *sm = cls; 121 struct StatMaster *sm = cls;
123 122
124 fprintf (stderr, 123 fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
125 "Peer %2u: %12s/%50s = %12llu\n", 124 name, (unsigned long long) value);
126 sm->daemon, subsystem, name, (unsigned long long) value);
127 return GNUNET_OK; 125 return GNUNET_OK;
128} 126}
129 127
@@ -164,8 +162,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
164#else 162#else
165 stats[sm->value].subsystem, stats[sm->value].name, 163 stats[sm->value].subsystem, stats[sm->value].name,
166#endif 164#endif
167 GNUNET_TIME_UNIT_FOREVER_REL, 165 GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat,
168 &get_done, &print_stat, sm); 166 sm);
169 return; 167 return;
170 } 168 }
171 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); 169 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO);
@@ -177,9 +175,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
177 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 175 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
178 return; 176 return;
179 } 177 }
180 sm->stat = GNUNET_STATISTICS_create ("<driver>", 178 sm->stat =
181 GNUNET_FS_TEST_get_configuration 179 GNUNET_STATISTICS_create ("<driver>",
182 (daemons, sm->daemon)); 180 GNUNET_FS_TEST_get_configuration (daemons,
181 sm->daemon));
183 GNUNET_SCHEDULER_add_now (&stat_run, sm); 182 GNUNET_SCHEDULER_add_now (&stat_run, sm);
184} 183}
185 184
@@ -201,13 +200,14 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
201 1000LL / del.rel_value); 200 1000LL / del.rel_value);
202 fprintf (stdout, "Download speed was %s/s\n", fancy); 201 fprintf (stdout, "Download speed was %s/s\n", fancy);
203 GNUNET_free (fancy); 202 GNUNET_free (fancy);
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
205 "Finished download, shutting down\n",
206 (unsigned long long) FILESIZE); 204 (unsigned long long) FILESIZE);
207 sm = GNUNET_malloc (sizeof (struct StatMaster)); 205 sm = GNUNET_malloc (sizeof (struct StatMaster));
208 sm->stat = GNUNET_STATISTICS_create ("<driver>", 206 sm->stat =
209 GNUNET_FS_TEST_get_configuration 207 GNUNET_STATISTICS_create ("<driver>",
210 (daemons, sm->daemon)); 208 GNUNET_FS_TEST_get_configuration (daemons,
209 sm->
210 daemon));
211 GNUNET_SCHEDULER_add_now (&stat_run, sm); 211 GNUNET_SCHEDULER_add_now (&stat_run, sm);
212 } 212 }
213 else 213 else
@@ -233,16 +233,15 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
233 ok = 1; 233 ok = 1;
234 return; 234 return;
235 } 235 }
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
237 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 237 (unsigned long long) FILESIZE);
238 start_time = GNUNET_TIME_absolute_get (); 238 start_time = GNUNET_TIME_absolute_get ();
239 if (NULL != strstr (progname, "dht")) 239 if (NULL != strstr (progname, "dht"))
240 anonymity = 0; 240 anonymity = 0;
241 else 241 else
242 anonymity = 1; 242 anonymity = 1;
243 GNUNET_FS_TEST_download (daemons[0], 243 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE,
244 TIMEOUT, 244 &do_report, NULL);
245 anonymity, SEED, uri, VERBOSE, &do_report, NULL);
246} 245}
247 246
248 247
@@ -259,8 +258,8 @@ do_publish (void *cls, const char *emsg)
259 ok = 1; 258 ok = 1;
260 return; 259 return;
261 } 260 }
262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
263 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 262 (unsigned long long) FILESIZE);
264 if (NULL != strstr (progname, "index")) 263 if (NULL != strstr (progname, "index"))
265 do_index = GNUNET_YES; 264 do_index = GNUNET_YES;
266 else 265 else
@@ -270,11 +269,9 @@ do_publish (void *cls, const char *emsg)
270 else 269 else
271 anonymity = 1; 270 anonymity = 1;
272 271
273 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], 272 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity,
274 TIMEOUT, 273 do_index, FILESIZE, SEED, VERBOSE, &do_download,
275 anonymity, 274 NULL);
276 do_index, FILESIZE, SEED,
277 VERBOSE, &do_download, NULL);
278} 275}
279 276
280 277
@@ -287,27 +284,22 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
288 "Daemons started, will now try to connect them\n"); 285 "Daemons started, will now try to connect them\n");
289 pg = GNUNET_FS_TEST_get_group (daemons); 286 pg = GNUNET_FS_TEST_get_group (daemons);
290 GNUNET_break ((NUM_DAEMONS - 1) * 2 287 GNUNET_break ((NUM_DAEMONS - 1) * 2 ==
291 == (GNUNET_TESTING_create_topology (pg, 288 (GNUNET_TESTING_create_topology
292 GNUNET_TESTING_TOPOLOGY_LINE, 289 (pg, GNUNET_TESTING_TOPOLOGY_LINE,
293 GNUNET_TESTING_TOPOLOGY_NONE, 290 GNUNET_TESTING_TOPOLOGY_NONE, NULL)));
294 NULL))); 291 GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE,
295 GNUNET_TESTING_connect_topology (pg, 292 GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0,
296 GNUNET_TESTING_TOPOLOGY_LINE,
297 GNUNET_TESTING_TOPOLOGY_OPTION_NONE,
298 0.0,
299 TIMEOUT, NUM_DAEMONS, &do_publish, NULL); 293 TIMEOUT, NUM_DAEMONS, &do_publish, NULL);
300} 294}
301 295
302 296
303static void 297static void
304run (void *cls, 298run (void *cls, char *const *args, const char *cfgfile,
305 char *const *args, 299 const struct GNUNET_CONFIGURATION_Handle *cfg)
306 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
307{ 300{
308 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 301 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS,
309 TIMEOUT, 302 daemons, &do_connect, NULL);
310 NUM_DAEMONS, daemons, &do_connect, NULL);
311} 303}
312 304
313 305
@@ -335,9 +327,9 @@ main (int argc, char *argv[])
335 "WARNING", 327 "WARNING",
336#endif 328#endif
337 NULL); 329 NULL);
338 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 330 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
339 argvx, "perf-gnunet-service-fs-p2p-index", 331 "perf-gnunet-service-fs-p2p-index", "nohelp", options,
340 "nohelp", options, &run, NULL); 332 &run, NULL);
341 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 333 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
342 return ok; 334 return ok;
343} 335}
diff --git a/src/fs/perf_gnunet_service_fs_p2p_trust.c b/src/fs/perf_gnunet_service_fs_p2p_trust.c
index a78ff0571..5a8d4242a 100644
--- a/src/fs/perf_gnunet_service_fs_p2p_trust.c
+++ b/src/fs/perf_gnunet_service_fs_p2p_trust.c
@@ -148,15 +148,13 @@ static struct StatValues stats[] = {
148 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 148 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
149 */ 149 */
150static int 150static int
151print_stat (void *cls, 151print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
152 const char *subsystem, 152 int is_persistent)
153 const char *name, uint64_t value, int is_persistent)
154{ 153{
155 struct StatMaster *sm = cls; 154 struct StatMaster *sm = cls;
156 155
157 fprintf (stderr, 156 fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
158 "Peer %2u: %12s/%50s = %12llu\n", 157 name, (unsigned long long) value);
159 sm->daemon, subsystem, name, (unsigned long long) value);
160 return GNUNET_OK; 158 return GNUNET_OK;
161} 159}
162 160
@@ -197,8 +195,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
197#else 195#else
198 stats[sm->value].subsystem, stats[sm->value].name, 196 stats[sm->value].subsystem, stats[sm->value].name,
199#endif 197#endif
200 GNUNET_TIME_UNIT_FOREVER_REL, 198 GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat,
201 &get_done, &print_stat, sm); 199 sm);
202 return; 200 return;
203 } 201 }
204 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); 202 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO);
@@ -210,9 +208,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
210 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 208 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
211 return; 209 return;
212 } 210 }
213 sm->stat = GNUNET_STATISTICS_create ("<driver>", 211 sm->stat =
214 GNUNET_FS_TEST_get_configuration 212 GNUNET_STATISTICS_create ("<driver>",
215 (daemons, sm->daemon)); 213 GNUNET_FS_TEST_get_configuration (daemons,
214 sm->daemon));
216 GNUNET_SCHEDULER_add_now (&stat_run, sm); 215 GNUNET_SCHEDULER_add_now (&stat_run, sm);
217} 216}
218 217
@@ -242,9 +241,11 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
242 "Finished all downloads, shutting down\n", 241 "Finished all downloads, shutting down\n",
243 (unsigned long long) FILESIZE); 242 (unsigned long long) FILESIZE);
244 sm = GNUNET_malloc (sizeof (struct StatMaster)); 243 sm = GNUNET_malloc (sizeof (struct StatMaster));
245 sm->stat = GNUNET_STATISTICS_create ("<driver>", 244 sm->stat =
246 GNUNET_FS_TEST_get_configuration 245 GNUNET_STATISTICS_create ("<driver>",
247 (daemons, sm->daemon)); 246 GNUNET_FS_TEST_get_configuration (daemons,
247 sm->
248 daemon));
248 GNUNET_SCHEDULER_add_now (&stat_run, sm); 249 GNUNET_SCHEDULER_add_now (&stat_run, sm);
249 } 250 }
250 else 251 else
@@ -273,8 +274,8 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
273 return; 274 return;
274 } 275 }
275 uri2 = GNUNET_FS_uri_dup (u2); 276 uri2 = GNUNET_FS_uri_dup (u2);
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
277 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 278 (unsigned long long) FILESIZE);
278 start_time = GNUNET_TIME_absolute_get (); 279 start_time = GNUNET_TIME_absolute_get ();
279 if (NULL != strstr (progname, "dht")) 280 if (NULL != strstr (progname, "dht"))
280 anonymity = 0; 281 anonymity = 0;
@@ -284,21 +285,15 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
284 * these peers do participate in sharing, they just 285 * these peers do participate in sharing, they just
285 * don't have to offer anything *initially*. */ 286 * don't have to offer anything *initially*. */
286 for (i = 0; i < NUM_DAEMONS - 2; i++) 287 for (i = 0; i < NUM_DAEMONS - 2; i++)
287 GNUNET_FS_TEST_download (daemons[i], 288 GNUNET_FS_TEST_download (daemons[i], TIMEOUT, anonymity,
288 TIMEOUT,
289 anonymity,
290 0 == (i % 2) ? SEED1 : SEED2, 289 0 == (i % 2) ? SEED1 : SEED2,
291 0 == (i % 2) ? uri1 : uri2, 290 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report,
292 VERBOSE, &do_report, "leach"); 291 "leach");
293 /* mutual downloads of (primary) sharing peers */ 292 /* mutual downloads of (primary) sharing peers */
294 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], 293 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1,
295 TIMEOUT, 294 uri1, VERBOSE, &do_report, "seeder 2");
296 anonymity, SEED1, uri1, 295 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2,
297 VERBOSE, &do_report, "seeder 2"); 296 uri2, VERBOSE, &do_report, "seeder 1");
298 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1],
299 TIMEOUT,
300 anonymity, SEED2, uri2,
301 VERBOSE, &do_report, "seeder 1");
302} 297}
303 298
304 299
@@ -317,8 +312,8 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1)
317 return; 312 return;
318 } 313 }
319 uri1 = GNUNET_FS_uri_dup (u1); 314 uri1 = GNUNET_FS_uri_dup (u1);
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
321 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 316 (unsigned long long) FILESIZE);
322 if (NULL != strstr (progname, "index")) 317 if (NULL != strstr (progname, "index"))
323 do_index = GNUNET_YES; 318 do_index = GNUNET_YES;
324 else 319 else
@@ -328,11 +323,9 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1)
328 else 323 else
329 anonymity = 1; 324 anonymity = 1;
330 325
331 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], 326 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity,
332 TIMEOUT, 327 do_index, FILESIZE, SEED2, VERBOSE, &do_downloads,
333 anonymity, 328 NULL);
334 do_index, FILESIZE, SEED2,
335 VERBOSE, &do_downloads, NULL);
336} 329}
337 330
338static void 331static void
@@ -348,8 +341,8 @@ do_publish1 (void *cls, const char *emsg)
348 ok = 1; 341 ok = 1;
349 return; 342 return;
350 } 343 }
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
352 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 345 (unsigned long long) FILESIZE);
353 if (NULL != strstr (progname, "index")) 346 if (NULL != strstr (progname, "index"))
354 do_index = GNUNET_YES; 347 do_index = GNUNET_YES;
355 else 348 else
@@ -359,11 +352,9 @@ do_publish1 (void *cls, const char *emsg)
359 else 352 else
360 anonymity = 1; 353 anonymity = 1;
361 354
362 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], 355 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity,
363 TIMEOUT, 356 do_index, FILESIZE, SEED1, VERBOSE, &do_publish2,
364 anonymity, 357 NULL);
365 do_index, FILESIZE, SEED1,
366 VERBOSE, &do_publish2, NULL);
367} 358}
368 359
369 360
@@ -376,25 +367,20 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
377 "Daemons started, will now try to connect them\n"); 368 "Daemons started, will now try to connect them\n");
378 pg = GNUNET_FS_TEST_get_group (daemons); 369 pg = GNUNET_FS_TEST_get_group (daemons);
379 GNUNET_TESTING_create_topology (pg, 370 GNUNET_TESTING_create_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE,
380 GNUNET_TESTING_TOPOLOGY_CLIQUE,
381 GNUNET_TESTING_TOPOLOGY_NONE, NULL); 371 GNUNET_TESTING_TOPOLOGY_NONE, NULL);
382 GNUNET_TESTING_connect_topology (pg, 372 GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE,
383 GNUNET_TESTING_TOPOLOGY_CLIQUE, 373 GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0,
384 GNUNET_TESTING_TOPOLOGY_OPTION_NONE,
385 0.0,
386 TIMEOUT, NUM_DAEMONS, &do_publish1, NULL); 374 TIMEOUT, NUM_DAEMONS, &do_publish1, NULL);
387} 375}
388 376
389 377
390static void 378static void
391run (void *cls, 379run (void *cls, char *const *args, const char *cfgfile,
392 char *const *args, 380 const struct GNUNET_CONFIGURATION_Handle *cfg)
393 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
394{ 381{
395 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 382 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS,
396 TIMEOUT, 383 daemons, &do_connect, NULL);
397 NUM_DAEMONS, daemons, &do_connect, NULL);
398} 384}
399 385
400 386
@@ -422,9 +408,9 @@ main (int argc, char *argv[])
422 "WARNING", 408 "WARNING",
423#endif 409#endif
424 NULL); 410 NULL);
425 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 411 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
426 argvx, "perf-gnunet-service-fs-p2p-trust", 412 "perf-gnunet-service-fs-p2p-trust", "nohelp", options,
427 "nohelp", options, &run, NULL); 413 &run, NULL);
428 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 414 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
429 return ok; 415 return ok;
430} 416}
diff --git a/src/fs/test_fs.c b/src/fs/test_fs.c
index b936c3199..9aee89e85 100644
--- a/src/fs/test_fs.c
+++ b/src/fs/test_fs.c
@@ -40,8 +40,8 @@ makeName (unsigned int i)
40 fn = GNUNET_malloc (strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + 40 fn = GNUNET_malloc (strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") +
41 14); 41 14);
42 GNUNET_snprintf (fn, 42 GNUNET_snprintf (fn,
43 strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + 43 strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + 14,
44 14, "/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST%u", i); 44 "/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST%u", i);
45 GNUNET_disk_directory_create_for_file (NULL, fn); 45 GNUNET_disk_directory_create_for_file (NULL, fn);
46 return fn; 46 return fn;
47} 47}
@@ -143,9 +143,8 @@ main (int argc, char *argv[])
143 &eventCallback, NULL); 143 &eventCallback, NULL);
144 CHECK (ctx != NULL); 144 CHECK (ctx != NULL);
145 filename = makeName (42); 145 filename = makeName (42);
146 GNUNET_disk_file_write (NULL, 146 GNUNET_disk_file_write (NULL, filename, "foo bar test!",
147 filename, 147 strlen ("foo bar test!"), "600");
148 "foo bar test!", strlen ("foo bar test!"), "600");
149 meta = GNUNET_meta_data_create (); 148 meta = GNUNET_meta_data_create ();
150 kuri = 149 kuri =
151 GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, 150 GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2,
@@ -153,11 +152,9 @@ main (int argc, char *argv[])
153 /* upload */ 152 /* upload */
154 upload = GNUNET_FSUI_upload_start (ctx, filename, (GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, /* anonymity */ 153 upload = GNUNET_FSUI_upload_start (ctx, filename, (GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, /* anonymity */
155 0, /* priority */ 154 0, /* priority */
156 GNUNET_YES, 155 GNUNET_YES, GNUNET_NO, GNUNET_NO,
157 GNUNET_NO, 156 GNUNET_get_time () + 5 * GNUNET_CRON_HOURS,
158 GNUNET_NO, 157 meta, kuri, kuri);
159 GNUNET_get_time () +
160 5 * GNUNET_CRON_HOURS, meta, kuri, kuri);
161 CHECK (upload != NULL); 158 CHECK (upload != NULL);
162 GNUNET_ECRS_uri_destroy (kuri); 159 GNUNET_ECRS_uri_destroy (kuri);
163 GNUNET_meta_data_destroy (meta); 160 GNUNET_meta_data_destroy (meta);
@@ -190,11 +187,9 @@ main (int argc, char *argv[])
190 187
191 /* download */ 188 /* download */
192 fn = makeName (43); 189 fn = makeName (43);
193 download = GNUNET_FSUI_download_start (ctx, 190 download =
194 0, 191 GNUNET_FSUI_download_start (ctx, 0, GNUNET_NO, search_uri, search_meta,
195 GNUNET_NO, 192 fn, NULL, NULL);
196 search_uri,
197 search_meta, fn, NULL, NULL);
198 GNUNET_free (fn); 193 GNUNET_free (fn);
199 prog = 0; 194 prog = 0;
200 while (lastEvent != GNUNET_FSUI_download_completed) 195 while (lastEvent != GNUNET_FSUI_download_completed)
diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c
index d8a9c63b6..ac581bd6f 100644
--- a/src/fs/test_fs_directory.c
+++ b/src/fs/test_fs_directory.c
@@ -41,11 +41,9 @@ struct PCLS
41}; 41};
42 42
43static void 43static void
44processor (void *cls, 44processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
45 const char *filename, 45 const struct GNUNET_CONTAINER_MetaData *md, size_t length,
46 const struct GNUNET_FS_Uri *uri, 46 const void *data)
47 const struct GNUNET_CONTAINER_MetaData *md,
48 size_t length, const void *data)
49{ 47{
50 struct PCLS *p = cls; 48 struct PCLS *p = cls;
51 int i; 49 int i;
@@ -54,8 +52,7 @@ processor (void *cls,
54 return; /* ignore directory's meta data */ 52 return; /* ignore directory's meta data */
55 for (i = 0; i < p->max; i++) 53 for (i = 0; i < p->max; i++)
56 { 54 {
57 if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], 55 if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], md) &&
58 md) &&
59 GNUNET_FS_uri_test_equal (p->uri[i], uri)) 56 GNUNET_FS_uri_test_equal (p->uri[i], uri))
60 { 57 {
61 p->pos++; 58 p->pos++;
@@ -88,17 +85,12 @@ testDirectory (unsigned int i)
88 uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i); 85 uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i);
89 mds = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_MetaData *) * i); 86 mds = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_MetaData *) * i);
90 meta = GNUNET_CONTAINER_meta_data_create (); 87 meta = GNUNET_CONTAINER_meta_data_create ();
91 GNUNET_CONTAINER_meta_data_insert (meta, 88 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
92 "<test>", 89 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
93 EXTRACTOR_METATYPE_TITLE,
94 EXTRACTOR_METAFORMAT_UTF8,
95 "text/plain",
96 "A title", strlen ("A title") + 1); 90 "A title", strlen ("A title") + 1);
97 GNUNET_CONTAINER_meta_data_insert (meta, 91 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
98 "<test>",
99 EXTRACTOR_METATYPE_AUTHOR_NAME, 92 EXTRACTOR_METATYPE_AUTHOR_NAME,
100 EXTRACTOR_METAFORMAT_UTF8, 93 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
101 "text/plain",
102 "An author", strlen ("An author") + 1); 94 "An author", strlen ("An author") + 1);
103 for (p = 0; p < i; p++) 95 for (p = 0; p < i; p++)
104 { 96 {
@@ -106,14 +98,12 @@ testDirectory (unsigned int i)
106 for (q = 0; q <= p; q++) 98 for (q = 0; q <= p; q++)
107 { 99 {
108 GNUNET_snprintf (txt, sizeof (txt), "%u -- %u\n", p, q); 100 GNUNET_snprintf (txt, sizeof (txt), "%u -- %u\n", p, q);
109 GNUNET_CONTAINER_meta_data_insert (mds[p], 101 GNUNET_CONTAINER_meta_data_insert (mds[p], "<test>",
110 "<test>",
111 q % EXTRACTOR_metatype_get_max (), 102 q % EXTRACTOR_metatype_get_max (),
112 EXTRACTOR_METAFORMAT_UTF8, 103 EXTRACTOR_METAFORMAT_UTF8,
113 "text/plain", txt, strlen (txt) + 1); 104 "text/plain", txt, strlen (txt) + 1);
114 } 105 }
115 GNUNET_snprintf (uri, 106 GNUNET_snprintf (uri, sizeof (uri),
116 sizeof (uri),
117 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u", 107 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
118 p); 108 p);
119 emsg = NULL; 109 emsg = NULL;
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index d37b94c03..34625ff2e 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -140,42 +140,42 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
140 (unsigned long long) event->value.publish.completed, 140 (unsigned long long) event->value.publish.completed,
141 (unsigned long long) event->value.publish.size, 141 (unsigned long long) event->value.publish.size,
142 event->value.publish.specifics.progress.depth, 142 event->value.publish.specifics.progress.depth,
143 (unsigned long long) event->value.publish.specifics. 143 (unsigned long long) event->value.publish.specifics.progress.
144 progress.offset); 144 offset);
145#endif 145#endif
146 break; 146 break;
147 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 147 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
148 printf ("Publishing complete, %llu kb/s.\n", 148 printf ("Publishing complete, %llu kb/s.\n",
149 (unsigned long long) (FILESIZE * 1000LL / 149 (unsigned long long) (FILESIZE * 1000LL /
150 (1 + 150 (1 +
151 GNUNET_TIME_absolute_get_duration 151 GNUNET_TIME_absolute_get_duration (start).
152 (start).rel_value) / 1024LL)); 152 rel_value) / 1024LL));
153 GAUGER ("FS", "Publishing speed (insertion)", 153 GAUGER ("FS", "Publishing speed (insertion)",
154 (unsigned long long) (FILESIZE * 1000LL / 154 (unsigned long long) (FILESIZE * 1000LL /
155 (1 + 155 (1 +
156 GNUNET_TIME_absolute_get_duration 156 GNUNET_TIME_absolute_get_duration (start).
157 (start).rel_value) / 1024LL), "kb/s"); 157 rel_value) / 1024LL), "kb/s");
158 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); 158 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
159 start = GNUNET_TIME_absolute_get (); 159 start = GNUNET_TIME_absolute_get ();
160 download = GNUNET_FS_download_start (fs, 160 download =
161 event->value.publish. 161 GNUNET_FS_download_start (fs,
162 specifics.completed.chk_uri, NULL, fn, 162 event->value.publish.specifics.completed.
163 NULL, 0, FILESIZE, 1, 163 chk_uri, NULL, fn, NULL, 0, FILESIZE, 1,
164 GNUNET_FS_DOWNLOAD_OPTION_NONE, 164 GNUNET_FS_DOWNLOAD_OPTION_NONE, "download",
165 "download", NULL); 165 NULL);
166 GNUNET_assert (download != NULL); 166 GNUNET_assert (download != NULL);
167 break; 167 break;
168 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 168 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
169 printf ("Download complete, %llu kb/s.\n", 169 printf ("Download complete, %llu kb/s.\n",
170 (unsigned long long) (FILESIZE * 1000LL / 170 (unsigned long long) (FILESIZE * 1000LL /
171 (1 + 171 (1 +
172 GNUNET_TIME_absolute_get_duration 172 GNUNET_TIME_absolute_get_duration (start).
173 (start).rel_value) / 1024LL)); 173 rel_value) / 1024LL));
174 GAUGER ("FS", "Local download speed (inserted)", 174 GAUGER ("FS", "Local download speed (inserted)",
175 (unsigned long long) (FILESIZE * 1000LL / 175 (unsigned long long) (FILESIZE * 1000LL /
176 (1 + 176 (1 +
177 GNUNET_TIME_absolute_get_duration 177 GNUNET_TIME_absolute_get_duration (start).
178 (start).rel_value) / 1024LL), "kb/s"); 178 rel_value) / 1024LL), "kb/s");
179 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 179 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
180 break; 180 break;
181 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 181 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -185,22 +185,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
185 (unsigned long long) event->value.download.completed, 185 (unsigned long long) event->value.download.completed,
186 (unsigned long long) event->value.download.size, 186 (unsigned long long) event->value.download.size,
187 event->value.download.specifics.progress.depth, 187 event->value.download.specifics.progress.depth,
188 (unsigned long long) event->value.download.specifics. 188 (unsigned long long) event->value.download.specifics.progress.
189 progress.offset); 189 offset);
190#endif 190#endif
191 break; 191 break;
192 case GNUNET_FS_STATUS_PUBLISH_ERROR: 192 case GNUNET_FS_STATUS_PUBLISH_ERROR:
193 fprintf (stderr, 193 fprintf (stderr, "Error publishing file: %s\n",
194 "Error publishing file: %s\n",
195 event->value.publish.specifics.error.message); 194 event->value.publish.specifics.error.message);
196 GNUNET_break (0); 195 GNUNET_break (0);
197 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 196 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
198 NULL,
199 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 197 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
200 break; 198 break;
201 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 199 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
202 fprintf (stderr, 200 fprintf (stderr, "Error downloading file: %s\n",
203 "Error downloading file: %s\n",
204 event->value.download.specifics.error.message); 201 event->value.download.specifics.error.message);
205 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 202 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
206 break; 203 break;
@@ -231,8 +228,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
231 break; 228 break;
232 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 229 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
233 GNUNET_assert (download == event->value.download.dc); 230 GNUNET_assert (download == event->value.download.dc);
234 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 231 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
235 NULL,
236 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 232 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
237 break; 233 break;
238 default: 234 default:
@@ -248,12 +244,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
248{ 244{
249 p->cfg = GNUNET_CONFIGURATION_create (); 245 p->cfg = GNUNET_CONFIGURATION_create ();
250#if START_ARM 246#if START_ARM
251 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 247 p->arm_proc =
252 "gnunet-service-arm", 248 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
249 "gnunet-service-arm",
253#if VERBOSE 250#if VERBOSE
254 "-L", "DEBUG", 251 "-L", "DEBUG",
255#endif 252#endif
256 "-c", cfgname, NULL); 253 "-c", cfgname, NULL);
257#endif 254#endif
258 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 255 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
259} 256}
@@ -269,8 +266,7 @@ stop_arm (struct PeerContext *p)
269 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 266 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
270 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 267 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
271 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 268 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
273 "ARM process %u stopped\n",
274 GNUNET_OS_process_get_pid (p->arm_proc)); 270 GNUNET_OS_process_get_pid (p->arm_proc));
275 GNUNET_OS_process_close (p->arm_proc); 271 GNUNET_OS_process_close (p->arm_proc);
276 p->arm_proc = NULL; 272 p->arm_proc = NULL;
@@ -281,9 +277,8 @@ stop_arm (struct PeerContext *p)
281 277
282 278
283static void 279static void
284run (void *cls, 280run (void *cls, char *const *args, const char *cfgfile,
285 char *const *args, 281 const struct GNUNET_CONFIGURATION_Handle *cfg)
286 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
287{ 282{
288 const char *keywords[] = { 283 const char *keywords[] = {
289 "down_foo", 284 "down_foo",
@@ -297,10 +292,8 @@ run (void *cls,
297 struct GNUNET_FS_BlockOptions bo; 292 struct GNUNET_FS_BlockOptions bo;
298 293
299 setup_peer (&p1, "test_fs_download_data.conf"); 294 setup_peer (&p1, "test_fs_download_data.conf");
300 fs = GNUNET_FS_start (cfg, 295 fs = GNUNET_FS_start (cfg, "test-fs-download", &progress_cb, NULL,
301 "test-fs-download", 296 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
302 &progress_cb,
303 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
304 GNUNET_assert (NULL != fs); 297 GNUNET_assert (NULL != fs);
305 buf = GNUNET_malloc (FILESIZE); 298 buf = GNUNET_malloc (FILESIZE);
306 for (i = 0; i < FILESIZE; i++) 299 for (i = 0; i < FILESIZE; i++)
@@ -311,21 +304,18 @@ run (void *cls,
311 bo.anonymity_level = 1; 304 bo.anonymity_level = 1;
312 bo.replication_level = 0; 305 bo.replication_level = 0;
313 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 306 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
314 fi = GNUNET_FS_file_information_create_from_data (fs, 307 fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context",
315 "publish-context", 308 FILESIZE, buf, kuri, meta,
316 FILESIZE, 309 GNUNET_NO, &bo);
317 buf,
318 kuri, meta, GNUNET_NO, &bo);
319 GNUNET_FS_uri_destroy (kuri); 310 GNUNET_FS_uri_destroy (kuri);
320 GNUNET_CONTAINER_meta_data_destroy (meta); 311 GNUNET_CONTAINER_meta_data_destroy (meta);
321 GNUNET_assert (NULL != fi); 312 GNUNET_assert (NULL != fi);
322 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 313 timeout_kill =
323 &timeout_kill_task, NULL); 314 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL);
324 start = GNUNET_TIME_absolute_get (); 315 start = GNUNET_TIME_absolute_get ();
325 publish = GNUNET_FS_publish_start (fs, 316 publish =
326 fi, 317 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
327 NULL, NULL, NULL, 318 GNUNET_FS_PUBLISH_OPTION_NONE);
328 GNUNET_FS_PUBLISH_OPTION_NONE);
329 GNUNET_assert (publish != NULL); 319 GNUNET_assert (publish != NULL);
330} 320}
331 321
@@ -353,8 +343,8 @@ main (int argc, char *argv[])
353 "WARNING", 343 "WARNING",
354#endif 344#endif
355 NULL); 345 NULL);
356 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 346 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
357 argvx, "test-fs-download", "nohelp", options, &run, NULL); 347 "test-fs-download", "nohelp", options, &run, NULL);
358 stop_arm (&p1); 348 stop_arm (&p1);
359 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); 349 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
360 return err; 350 return err;
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c
index 86933352a..5b1752e63 100644
--- a/src/fs/test_fs_download_indexed.c
+++ b/src/fs/test_fs_download_indexed.c
@@ -141,42 +141,42 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
141 (unsigned long long) event->value.publish.completed, 141 (unsigned long long) event->value.publish.completed,
142 (unsigned long long) event->value.publish.size, 142 (unsigned long long) event->value.publish.size,
143 event->value.publish.specifics.progress.depth, 143 event->value.publish.specifics.progress.depth,
144 (unsigned long long) event->value.publish.specifics. 144 (unsigned long long) event->value.publish.specifics.progress.
145 progress.offset); 145 offset);
146#endif 146#endif
147 break; 147 break;
148 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 148 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
149 printf ("Publishing complete, %llu kbps.\n", 149 printf ("Publishing complete, %llu kbps.\n",
150 (unsigned long long) (FILESIZE * 1000LL / 150 (unsigned long long) (FILESIZE * 1000LL /
151 (1 + 151 (1 +
152 GNUNET_TIME_absolute_get_duration 152 GNUNET_TIME_absolute_get_duration (start).
153 (start).rel_value) / 1024LL)); 153 rel_value) / 1024LL));
154 GAUGER ("FS", "Publishing speed (indexing)", 154 GAUGER ("FS", "Publishing speed (indexing)",
155 (unsigned long long) (FILESIZE * 1000LL / 155 (unsigned long long) (FILESIZE * 1000LL /
156 (1 + 156 (1 +
157 GNUNET_TIME_absolute_get_duration 157 GNUNET_TIME_absolute_get_duration (start).
158 (start).rel_value) / 1024LL), "kb/s"); 158 rel_value) / 1024LL), "kb/s");
159 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); 159 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
160 start = GNUNET_TIME_absolute_get (); 160 start = GNUNET_TIME_absolute_get ();
161 download = GNUNET_FS_download_start (fs, 161 download =
162 event->value.publish. 162 GNUNET_FS_download_start (fs,
163 specifics.completed.chk_uri, NULL, fn, 163 event->value.publish.specifics.completed.
164 NULL, 0, FILESIZE, 1, 164 chk_uri, NULL, fn, NULL, 0, FILESIZE, 1,
165 GNUNET_FS_DOWNLOAD_OPTION_NONE, 165 GNUNET_FS_DOWNLOAD_OPTION_NONE, "download",
166 "download", NULL); 166 NULL);
167 GNUNET_assert (download != NULL); 167 GNUNET_assert (download != NULL);
168 break; 168 break;
169 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 169 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
170 printf ("Download complete, %llu kbps.\n", 170 printf ("Download complete, %llu kbps.\n",
171 (unsigned long long) (FILESIZE * 1000LL / 171 (unsigned long long) (FILESIZE * 1000LL /
172 (1 + 172 (1 +
173 GNUNET_TIME_absolute_get_duration 173 GNUNET_TIME_absolute_get_duration (start).
174 (start).rel_value) / 1024LL)); 174 rel_value) / 1024LL));
175 GAUGER ("FS", "Local download speed (indexed)", 175 GAUGER ("FS", "Local download speed (indexed)",
176 (unsigned long long) (FILESIZE * 1000LL / 176 (unsigned long long) (FILESIZE * 1000LL /
177 (1 + 177 (1 +
178 GNUNET_TIME_absolute_get_duration 178 GNUNET_TIME_absolute_get_duration (start).
179 (start).rel_value) / 1024LL), "kb/s"); 179 rel_value) / 1024LL), "kb/s");
180 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 180 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
181 break; 181 break;
182 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 182 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -186,22 +186,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
186 (unsigned long long) event->value.download.completed, 186 (unsigned long long) event->value.download.completed,
187 (unsigned long long) event->value.download.size, 187 (unsigned long long) event->value.download.size,
188 event->value.download.specifics.progress.depth, 188 event->value.download.specifics.progress.depth,
189 (unsigned long long) event->value.download.specifics. 189 (unsigned long long) event->value.download.specifics.progress.
190 progress.offset); 190 offset);
191#endif 191#endif
192 break; 192 break;
193 case GNUNET_FS_STATUS_PUBLISH_ERROR: 193 case GNUNET_FS_STATUS_PUBLISH_ERROR:
194 fprintf (stderr, 194 fprintf (stderr, "Error publishing file: %s\n",
195 "Error publishing file: %s\n",
196 event->value.publish.specifics.error.message); 195 event->value.publish.specifics.error.message);
197 GNUNET_break (0); 196 GNUNET_break (0);
198 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 197 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
199 NULL,
200 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 198 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
201 break; 199 break;
202 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 200 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
203 fprintf (stderr, 201 fprintf (stderr, "Error downloading file: %s\n",
204 "Error downloading file: %s\n",
205 event->value.download.specifics.error.message); 202 event->value.download.specifics.error.message);
206 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 203 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
207 break; 204 break;
@@ -232,8 +229,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
232 break; 229 break;
233 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 230 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
234 GNUNET_assert (download == event->value.download.dc); 231 GNUNET_assert (download == event->value.download.dc);
235 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 232 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
236 NULL,
237 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 233 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
238 break; 234 break;
239 default: 235 default:
@@ -249,12 +245,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
249{ 245{
250 p->cfg = GNUNET_CONFIGURATION_create (); 246 p->cfg = GNUNET_CONFIGURATION_create ();
251#if START_ARM 247#if START_ARM
252 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 248 p->arm_proc =
253 "gnunet-service-arm", 249 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
250 "gnunet-service-arm",
254#if VERBOSE 251#if VERBOSE
255 "-L", "DEBUG", 252 "-L", "DEBUG",
256#endif 253#endif
257 "-c", cfgname, NULL); 254 "-c", cfgname, NULL);
258#endif 255#endif
259 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 256 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
260} 257}
@@ -270,8 +267,7 @@ stop_arm (struct PeerContext *p)
270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 267 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
271 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 268 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 269 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
274 "ARM process %u stopped\n",
275 GNUNET_OS_process_get_pid (p->arm_proc)); 271 GNUNET_OS_process_get_pid (p->arm_proc));
276 GNUNET_OS_process_close (p->arm_proc); 272 GNUNET_OS_process_close (p->arm_proc);
277 p->arm_proc = NULL; 273 p->arm_proc = NULL;
@@ -282,9 +278,8 @@ stop_arm (struct PeerContext *p)
282 278
283 279
284static void 280static void
285run (void *cls, 281run (void *cls, char *const *args, const char *cfgfile,
286 char *const *args, 282 const struct GNUNET_CONFIGURATION_Handle *cfg)
287 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
288{ 283{
289 const char *keywords[] = { 284 const char *keywords[] = {
290 "down_foo", 285 "down_foo",
@@ -298,10 +293,8 @@ run (void *cls,
298 size_t i; 293 size_t i;
299 294
300 setup_peer (&p1, "test_fs_download_data.conf"); 295 setup_peer (&p1, "test_fs_download_data.conf");
301 fs = GNUNET_FS_start (cfg, 296 fs = GNUNET_FS_start (cfg, "test-fs-download-indexed", &progress_cb, NULL,
302 "test-fs-download-indexed", 297 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
303 &progress_cb,
304 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
305 GNUNET_assert (NULL != fs); 298 GNUNET_assert (NULL != fs);
306 299
307 fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test"); 300 fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test");
@@ -309,9 +302,7 @@ run (void *cls,
309 for (i = 0; i < FILESIZE; i++) 302 for (i = 0; i < FILESIZE; i++)
310 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 303 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
311 GNUNET_assert (FILESIZE == 304 GNUNET_assert (FILESIZE ==
312 GNUNET_DISK_fn_write (fn1, 305 GNUNET_DISK_fn_write (fn1, buf, FILESIZE,
313 buf,
314 FILESIZE,
315 GNUNET_DISK_PERM_USER_READ | 306 GNUNET_DISK_PERM_USER_READ |
316 GNUNET_DISK_PERM_USER_WRITE)); 307 GNUNET_DISK_PERM_USER_WRITE));
317 GNUNET_free (buf); 308 GNUNET_free (buf);
@@ -321,21 +312,18 @@ run (void *cls,
321 bo.anonymity_level = 1; 312 bo.anonymity_level = 1;
322 bo.replication_level = 0; 313 bo.replication_level = 0;
323 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 314 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
324 fi = GNUNET_FS_file_information_create_from_file (fs, 315 fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn1,
325 "publish-context", 316 kuri, meta, GNUNET_YES,
326 fn1, 317 &bo);
327 kuri,
328 meta, GNUNET_YES, &bo);
329 GNUNET_FS_uri_destroy (kuri); 318 GNUNET_FS_uri_destroy (kuri);
330 GNUNET_CONTAINER_meta_data_destroy (meta); 319 GNUNET_CONTAINER_meta_data_destroy (meta);
331 GNUNET_assert (NULL != fi); 320 GNUNET_assert (NULL != fi);
332 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 321 timeout_kill =
333 &timeout_kill_task, NULL); 322 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL);
334 start = GNUNET_TIME_absolute_get (); 323 start = GNUNET_TIME_absolute_get ();
335 publish = GNUNET_FS_publish_start (fs, 324 publish =
336 fi, 325 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
337 NULL, NULL, NULL, 326 GNUNET_FS_PUBLISH_OPTION_NONE);
338 GNUNET_FS_PUBLISH_OPTION_NONE);
339 GNUNET_assert (publish != NULL); 327 GNUNET_assert (publish != NULL);
340} 328}
341 329
@@ -363,9 +351,9 @@ main (int argc, char *argv[])
363 "WARNING", 351 "WARNING",
364#endif 352#endif
365 NULL); 353 NULL);
366 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 354 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
367 argvx, "test-fs-download-indexed", 355 "test-fs-download-indexed", "nohelp", options, &run,
368 "nohelp", options, &run, NULL); 356 NULL);
369 stop_arm (&p1); 357 stop_arm (&p1);
370 if (fn1 != NULL) 358 if (fn1 != NULL)
371 { 359 {
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index d484f9587..5b2a53f80 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -132,10 +132,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
132{ 132{
133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting FS.\n"); 133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting FS.\n");
134 GNUNET_FS_stop (fs); 134 GNUNET_FS_stop (fs);
135 fs = GNUNET_FS_start (cfg, 135 fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL,
136 "test-fs-download-persistence",
137 &progress_cb,
138 NULL,
139 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 136 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
140} 137}
141 138
@@ -174,26 +171,22 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
174 (unsigned long long) event->value.publish.completed, 171 (unsigned long long) event->value.publish.completed,
175 (unsigned long long) event->value.publish.size, 172 (unsigned long long) event->value.publish.size,
176 event->value.publish.specifics.progress.depth, 173 event->value.publish.specifics.progress.depth,
177 (unsigned long long) event->value.publish.specifics. 174 (unsigned long long) event->value.publish.specifics.progress.
178 progress.offset); 175 offset);
179#endif 176#endif
180 break; 177 break;
181 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 178 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
182 printf ("Publishing complete, %llu kbps.\n", 179 printf ("Publishing complete, %llu kbps.\n",
183 (unsigned long long) (FILESIZE * 1000LL / 180 (unsigned long long) (FILESIZE * 1000LL /
184 (1 + 181 (1 +
185 GNUNET_TIME_absolute_get_duration 182 GNUNET_TIME_absolute_get_duration (start).
186 (start).rel_value) / 1024LL)); 183 rel_value) / 1024LL));
187 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); 184 fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
188 start = GNUNET_TIME_absolute_get (); 185 start = GNUNET_TIME_absolute_get ();
189 GNUNET_assert (download == NULL); 186 GNUNET_assert (download == NULL);
190 GNUNET_FS_download_start (fs, 187 GNUNET_FS_download_start (fs,
191 event->value.publish.specifics.completed.chk_uri, 188 event->value.publish.specifics.completed.chk_uri,
192 NULL, 189 NULL, fn, NULL, 0, FILESIZE, 1,
193 fn, NULL,
194 0,
195 FILESIZE,
196 1,
197 GNUNET_FS_DOWNLOAD_OPTION_NONE, "download", NULL); 190 GNUNET_FS_DOWNLOAD_OPTION_NONE, "download", NULL);
198 break; 191 break;
199 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 192 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
@@ -201,8 +194,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
201 printf ("Download complete, %llu kbps.\n", 194 printf ("Download complete, %llu kbps.\n",
202 (unsigned long long) (FILESIZE * 1000LL / 195 (unsigned long long) (FILESIZE * 1000LL /
203 (1 + 196 (1 +
204 GNUNET_TIME_absolute_get_duration 197 GNUNET_TIME_absolute_get_duration (start).
205 (start).rel_value) / 1024LL)); 198 rel_value) / 1024LL));
206 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 199 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
207 break; 200 break;
208 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 201 case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
@@ -213,22 +206,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
213 (unsigned long long) event->value.download.completed, 206 (unsigned long long) event->value.download.completed,
214 (unsigned long long) event->value.download.size, 207 (unsigned long long) event->value.download.size,
215 event->value.download.specifics.progress.depth, 208 event->value.download.specifics.progress.depth,
216 (unsigned long long) event->value.download.specifics. 209 (unsigned long long) event->value.download.specifics.progress.
217 progress.offset); 210 offset);
218#endif 211#endif
219 break; 212 break;
220 case GNUNET_FS_STATUS_PUBLISH_ERROR: 213 case GNUNET_FS_STATUS_PUBLISH_ERROR:
221 fprintf (stderr, 214 fprintf (stderr, "Error publishing file: %s\n",
222 "Error publishing file: %s\n",
223 event->value.publish.specifics.error.message); 215 event->value.publish.specifics.error.message);
224 GNUNET_break (0); 216 GNUNET_break (0);
225 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 217 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
226 NULL,
227 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 218 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
228 break; 219 break;
229 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 220 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
230 fprintf (stderr, 221 fprintf (stderr, "Error downloading file: %s\n",
231 "Error downloading file: %s\n",
232 event->value.download.specifics.error.message); 222 event->value.download.specifics.error.message);
233 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); 223 GNUNET_SCHEDULER_add_now (&abort_download_task, NULL);
234 break; 224 break;
@@ -287,8 +277,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
287 break; 277 break;
288 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 278 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
289 GNUNET_assert (download == event->value.download.dc); 279 GNUNET_assert (download == event->value.download.dc);
290 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 280 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
291 NULL,
292 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 281 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
293 download = NULL; 282 download = NULL;
294 break; 283 break;
@@ -305,12 +294,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
305{ 294{
306 p->cfg = GNUNET_CONFIGURATION_create (); 295 p->cfg = GNUNET_CONFIGURATION_create ();
307#if START_ARM 296#if START_ARM
308 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 297 p->arm_proc =
309 "gnunet-service-arm", 298 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
299 "gnunet-service-arm",
310#if VERBOSE 300#if VERBOSE
311 "-L", "DEBUG", 301 "-L", "DEBUG",
312#endif 302#endif
313 "-c", cfgname, NULL); 303 "-c", cfgname, NULL);
314#endif 304#endif
315 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 305 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
316} 306}
@@ -326,8 +316,7 @@ stop_arm (struct PeerContext *p)
326 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 316 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
327 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 317 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
328 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 318 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
330 "ARM process %u stopped\n",
331 GNUNET_OS_process_get_pid (p->arm_proc)); 320 GNUNET_OS_process_get_pid (p->arm_proc));
332 GNUNET_OS_process_close (p->arm_proc); 321 GNUNET_OS_process_close (p->arm_proc);
333 p->arm_proc = NULL; 322 p->arm_proc = NULL;
@@ -338,9 +327,8 @@ stop_arm (struct PeerContext *p)
338 327
339 328
340static void 329static void
341run (void *cls, 330run (void *cls, char *const *args, const char *cfgfile,
342 char *const *args, 331 const struct GNUNET_CONFIGURATION_Handle *c)
343 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
344{ 332{
345 const char *keywords[] = { 333 const char *keywords[] = {
346 "down_foo", 334 "down_foo",
@@ -355,10 +343,7 @@ run (void *cls,
355 343
356 cfg = c; 344 cfg = c;
357 setup_peer (&p1, "test_fs_download_data.conf"); 345 setup_peer (&p1, "test_fs_download_data.conf");
358 fs = GNUNET_FS_start (cfg, 346 fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL,
359 "test-fs-download-persistence",
360 &progress_cb,
361 NULL,
362 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 347 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
363 GNUNET_assert (NULL != fs); 348 GNUNET_assert (NULL != fs);
364 buf = GNUNET_malloc (FILESIZE); 349 buf = GNUNET_malloc (FILESIZE);
@@ -370,21 +355,18 @@ run (void *cls,
370 bo.anonymity_level = 1; 355 bo.anonymity_level = 1;
371 bo.replication_level = 0; 356 bo.replication_level = 0;
372 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 357 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
373 fi = GNUNET_FS_file_information_create_from_data (fs, 358 fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context",
374 "publish-context", 359 FILESIZE, buf, kuri, meta,
375 FILESIZE, 360 GNUNET_NO, &bo);
376 buf,
377 kuri, meta, GNUNET_NO, &bo);
378 GNUNET_FS_uri_destroy (kuri); 361 GNUNET_FS_uri_destroy (kuri);
379 GNUNET_CONTAINER_meta_data_destroy (meta); 362 GNUNET_CONTAINER_meta_data_destroy (meta);
380 GNUNET_assert (NULL != fi); 363 GNUNET_assert (NULL != fi);
381 timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 364 timeout_kill =
382 &timeout_kill_task, NULL); 365 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL);
383 start = GNUNET_TIME_absolute_get (); 366 start = GNUNET_TIME_absolute_get ();
384 publish = GNUNET_FS_publish_start (fs, 367 publish =
385 fi, 368 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
386 NULL, NULL, NULL, 369 GNUNET_FS_PUBLISH_OPTION_NONE);
387 GNUNET_FS_PUBLISH_OPTION_NONE);
388 GNUNET_assert (publish != NULL); 370 GNUNET_assert (publish != NULL);
389} 371}
390 372
@@ -412,9 +394,9 @@ main (int argc, char *argv[])
412#endif 394#endif
413 NULL); 395 NULL);
414 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); 396 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
415 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 397 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
416 argvx, "test-fs-download-persistence", 398 "test-fs-download-persistence", "nohelp", options, &run,
417 "nohelp", options, &run, NULL); 399 NULL);
418 stop_arm (&p1); 400 stop_arm (&p1);
419 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); 401 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
420 return err; 402 return err;
diff --git a/src/fs/test_fs_download_recursive.c b/src/fs/test_fs_download_recursive.c
index c3e0ea440..d350dcae8 100644
--- a/src/fs/test_fs_download_recursive.c
+++ b/src/fs/test_fs_download_recursive.c
@@ -50,9 +50,9 @@ makeName (unsigned int i)
50 ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") + 50 ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") +
51 15); 51 15);
52 GNUNET_snprintf (fn, 52 GNUNET_snprintf (fn,
53 strlen 53 strlen ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST")
54 ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") + 15, 54 + 15, "/tmp/gnunet-fsui-recursive_download_test/FSUITEST%u/",
55 "/tmp/gnunet-fsui-recursive_download_test/FSUITEST%u/", i); 55 i);
56 return fn; 56 return fn;
57} 57}
58 58
@@ -142,8 +142,9 @@ checkHierarchy (unsigned int i, const char *tree)
142 GNUNET_free (fn); 142 GNUNET_free (fn);
143 return GNUNET_SYSERR; 143 return GNUNET_SYSERR;
144 } 144 }
145 res = ((makeHierarchyHelper (fn, tree, 0, 1) == -1) ? 145 res =
146 GNUNET_SYSERR : GNUNET_OK); 146 ((makeHierarchyHelper (fn, tree, 0, 1) ==
147 -1) ? GNUNET_SYSERR : GNUNET_OK);
147 GNUNET_free (fn); 148 GNUNET_free (fn);
148 return res; 149 return res;
149} 150}
@@ -287,9 +288,9 @@ main (int argc, char *argv[])
287 GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */ 288 GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */
288 /* ACTUAL TEST CODE */ 289 /* ACTUAL TEST CODE */
289#endif 290#endif
290 ctx = GNUNET_FSUI_start (NULL, 291 ctx =
291 cfg, "fsuirecursive_download_test", 32, GNUNET_YES, 292 GNUNET_FSUI_start (NULL, cfg, "fsuirecursive_download_test", 32,
292 &eventCallback, NULL); 293 GNUNET_YES, &eventCallback, NULL);
293 CHECK (ctx != NULL); 294 CHECK (ctx != NULL);
294 fn = makeHierarchy (42, DIRECTORY_TREE_SPEC); 295 fn = makeHierarchy (42, DIRECTORY_TREE_SPEC);
295 meta = GNUNET_meta_data_create (); 296 meta = GNUNET_meta_data_create ();
@@ -298,13 +299,13 @@ main (int argc, char *argv[])
298 (const char **) keywords); 299 (const char **) keywords);
299 fprintf (stderr, "Uploading...\n"); 300 fprintf (stderr, "Uploading...\n");
300 waitForEvent = GNUNET_FSUI_upload_completed; 301 waitForEvent = GNUNET_FSUI_upload_completed;
301 upload = GNUNET_FSUI_upload_start (ctx, 302 upload =
302 fn, 303 GNUNET_FSUI_upload_start (ctx, fn,
303 (GNUNET_FSUI_DirectoryScanCallback) & 304 (GNUNET_FSUI_DirectoryScanCallback) &
304 GNUNET_disk_directory_scan, NULL, 0, 0, 305 GNUNET_disk_directory_scan, NULL, 0, 0,
305 GNUNET_YES, GNUNET_NO, GNUNET_NO, 306 GNUNET_YES, GNUNET_NO, GNUNET_NO,
306 GNUNET_get_time () + 307 GNUNET_get_time () + 5 * GNUNET_CRON_HOURS,
307 5 * GNUNET_CRON_HOURS, meta, kuri, kuri); 308 meta, kuri, kuri);
308 CHECK (upload != NULL); 309 CHECK (upload != NULL);
309 GNUNET_ECRS_uri_destroy (kuri); 310 GNUNET_ECRS_uri_destroy (kuri);
310 kuri = NULL; 311 kuri = NULL;
@@ -324,10 +325,9 @@ main (int argc, char *argv[])
324 fprintf (stderr, "Downloading...\n"); 325 fprintf (stderr, "Downloading...\n");
325 waitForEvent = GNUNET_FSUI_download_completed; 326 waitForEvent = GNUNET_FSUI_download_completed;
326 fn43 = makeName (43); 327 fn43 = makeName (43);
327 download = GNUNET_FSUI_download_start (ctx, 328 download =
328 0, 329 GNUNET_FSUI_download_start (ctx, 0, GNUNET_YES, upURI, meta, fn43, NULL,
329 GNUNET_YES, 330 NULL);
330 upURI, meta, fn43, NULL, NULL);
331 CHECK (download != NULL); 331 CHECK (download != NULL);
332 GNUNET_free (fn43); 332 GNUNET_free (fn43);
333 fn43 = NULL; 333 fn43 = NULL;
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c
index 97a63062e..db5a8448a 100644
--- a/src/fs/test_fs_file_information.c
+++ b/src/fs/test_fs_file_information.c
@@ -50,11 +50,8 @@
50 50
51 51
52static int 52static int
53mycleaner (void *cls, 53mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length,
54 struct GNUNET_FS_FileInformation *fi, 54 struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri,
55 uint64_t length,
56 struct GNUNET_CONTAINER_MetaData *meta,
57 struct GNUNET_FS_Uri **uri,
58 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) 55 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
59{ 56{
60 return GNUNET_OK; 57 return GNUNET_OK;
@@ -62,9 +59,8 @@ mycleaner (void *cls,
62 59
63 60
64static void 61static void
65run (void *cls, 62run (void *cls, char *const *args, const char *cfgfile,
66 char *const *args, 63 const struct GNUNET_CONFIGURATION_Handle *cfg)
67 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
68{ 64{
69 const char *keywords[] = { 65 const char *keywords[] = {
70 "down_foo", 66 "down_foo",
@@ -89,9 +85,7 @@ run (void *cls,
89 for (i = 0; i < FILESIZE; i++) 85 for (i = 0; i < FILESIZE; i++)
90 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 86 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
91 GNUNET_assert (FILESIZE == 87 GNUNET_assert (FILESIZE ==
92 GNUNET_DISK_fn_write (fn1, 88 GNUNET_DISK_fn_write (fn1, buf, FILESIZE,
93 buf,
94 FILESIZE,
95 GNUNET_DISK_PERM_USER_READ | 89 GNUNET_DISK_PERM_USER_READ |
96 GNUNET_DISK_PERM_USER_WRITE)); 90 GNUNET_DISK_PERM_USER_WRITE));
97 GNUNET_free (buf); 91 GNUNET_free (buf);
@@ -101,9 +95,7 @@ run (void *cls,
101 for (i = 0; i < FILESIZE; i++) 95 for (i = 0; i < FILESIZE; i++)
102 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 96 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
103 GNUNET_assert (FILESIZE == 97 GNUNET_assert (FILESIZE ==
104 GNUNET_DISK_fn_write (fn2, 98 GNUNET_DISK_fn_write (fn2, buf, FILESIZE,
105 buf,
106 FILESIZE,
107 GNUNET_DISK_PERM_USER_READ | 99 GNUNET_DISK_PERM_USER_READ |
108 GNUNET_DISK_PERM_USER_WRITE)); 100 GNUNET_DISK_PERM_USER_WRITE));
109 GNUNET_free (buf); 101 GNUNET_free (buf);
@@ -114,21 +106,22 @@ run (void *cls,
114 bo.anonymity_level = 1; 106 bo.anonymity_level = 1;
115 bo.replication_level = 0; 107 bo.replication_level = 0;
116 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 108 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
117 fi1 = GNUNET_FS_file_information_create_from_file (fs, 109 fi1 =
118 "file_information-context1", 110 GNUNET_FS_file_information_create_from_file (fs,
119 fn1, 111 "file_information-context1",
120 kuri, 112 fn1, kuri, meta, GNUNET_YES,
121 meta, GNUNET_YES, &bo); 113 &bo);
122 GNUNET_assert (fi1 != NULL); 114 GNUNET_assert (fi1 != NULL);
123 fi2 = GNUNET_FS_file_information_create_from_file (fs, 115 fi2 =
124 "file_information-context2", 116 GNUNET_FS_file_information_create_from_file (fs,
125 fn2, 117 "file_information-context2",
126 kuri, 118 fn2, kuri, meta, GNUNET_YES,
127 meta, GNUNET_YES, &bo); 119 &bo);
128 GNUNET_assert (fi2 != NULL); 120 GNUNET_assert (fi2 != NULL);
129 fidir = GNUNET_FS_file_information_create_empty_directory (fs, 121 fidir =
130 "file_information-context-dir", 122 GNUNET_FS_file_information_create_empty_directory (fs,
131 kuri, meta, &bo); 123 "file_information-context-dir",
124 kuri, meta, &bo);
132 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 125 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
133 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 126 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
134 GNUNET_FS_uri_destroy (kuri); 127 GNUNET_FS_uri_destroy (kuri);
@@ -165,9 +158,10 @@ testThumbnail ()
165 ex = EXTRACTOR_plugin_add_config (ex, "mime", 158 ex = EXTRACTOR_plugin_add_config (ex, "mime",
166 EXTRACTOR_OPTION_DEFAULT_POLICY); 159 EXTRACTOR_OPTION_DEFAULT_POLICY);
167 m = GNUNET_CONTAINER_meta_data_create (); 160 m = GNUNET_CONTAINER_meta_data_create ();
168 if (3 != GNUNET_FS_meta_data_extract_from_file (m, 161 if (3 !=
169 "test_fs_file_information_meta_data_image.jpg", 162 GNUNET_FS_meta_data_extract_from_file (m,
170 ex)) 163 "test_fs_file_information_meta_data_image.jpg",
164 ex))
171 { 165 {
172 GNUNET_break (0); 166 GNUNET_break (0);
173 EXTRACTOR_plugin_remove_all (ex); 167 EXTRACTOR_plugin_remove_all (ex);
@@ -187,8 +181,9 @@ testThumbnail ()
187 } 181 }
188 GNUNET_free (thumb); 182 GNUNET_free (thumb);
189 GNUNET_CONTAINER_meta_data_add_publication_date (d); 183 GNUNET_CONTAINER_meta_data_add_publication_date (d);
190 date = GNUNET_CONTAINER_meta_data_get_by_type (d, 184 date =
191 EXTRACTOR_METATYPE_PUBLICATION_DATE); 185 GNUNET_CONTAINER_meta_data_get_by_type (d,
186 EXTRACTOR_METATYPE_PUBLICATION_DATE);
192 if (date == NULL) 187 if (date == NULL)
193 { 188 {
194 GNUNET_break (0); 189 GNUNET_break (0);
@@ -227,9 +222,9 @@ main (int argc, char *argv[])
227 NULL); 222 NULL);
228 if (0 != testThumbnail ()) 223 if (0 != testThumbnail ())
229 return 1; 224 return 1;
230 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 225 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
231 argvx, "test-fs-file_information", 226 "test-fs-file_information", "nohelp", options, &run,
232 "nohelp", options, &run, NULL); 227 NULL);
233 return 0; 228 return 0;
234} 229}
235 230
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index e3330f3ba..87afa12e1 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -92,8 +92,8 @@ static void
92list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 92list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
93{ 93{
94 94
95 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 95 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
96 NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 96 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
97} 97}
98 98
99 99
@@ -110,11 +110,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
110 printf ("Publish complete, %llu kbps.\n", 110 printf ("Publish complete, %llu kbps.\n",
111 (unsigned long long) (FILESIZE * 1000 / 111 (unsigned long long) (FILESIZE * 1000 /
112 (1 + 112 (1 +
113 GNUNET_TIME_absolute_get_duration 113 GNUNET_TIME_absolute_get_duration (start).
114 (start).rel_value) / 1024)); 114 rel_value) / 1024));
115 if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) 115 if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
116 GNUNET_SCHEDULER_add_continuation (&list_indexed_task, 116 GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL,
117 NULL,
118 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 117 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
119 118
120 break; 119 break;
@@ -126,41 +125,41 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
126 (unsigned long long) event->value.publish.completed, 125 (unsigned long long) event->value.publish.completed,
127 (unsigned long long) event->value.publish.size, 126 (unsigned long long) event->value.publish.size,
128 event->value.publish.specifics.progress.depth, 127 event->value.publish.specifics.progress.depth,
129 (unsigned long long) event->value.publish.specifics. 128 (unsigned long long) event->value.publish.specifics.progress.
130 progress.offset); 129 offset);
131#endif 130#endif
132 break; 131 break;
133 case GNUNET_FS_STATUS_PUBLISH_ERROR: 132 case GNUNET_FS_STATUS_PUBLISH_ERROR:
134 ret = event->value.publish.cctx; 133 ret = event->value.publish.cctx;
135 fprintf (stderr, 134 fprintf (stderr, "Error publishing file: %s\n",
136 "Error publishing file: %s\n",
137 event->value.publish.specifics.error.message); 135 event->value.publish.specifics.error.message);
138 err = 1; 136 err = 1;
139 if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) 137 if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
140 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 138 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
141 NULL,
142 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 139 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
143 break; 140 break;
144 case GNUNET_FS_STATUS_PUBLISH_START: 141 case GNUNET_FS_STATUS_PUBLISH_START:
145 ret = event->value.publish.cctx; 142 ret = event->value.publish.cctx;
146 if (0 == strcmp ("list_indexed-context1", event->value.publish.cctx)) 143 if (0 == strcmp ("list_indexed-context1", event->value.publish.cctx))
147 { 144 {
148 GNUNET_assert (0 == strcmp ("list_indexed-context-dir", 145 GNUNET_assert (0 ==
149 event->value.publish.pctx)); 146 strcmp ("list_indexed-context-dir",
147 event->value.publish.pctx));
150 GNUNET_assert (FILESIZE == event->value.publish.size); 148 GNUNET_assert (FILESIZE == event->value.publish.size);
151 GNUNET_assert (0 == event->value.publish.completed); 149 GNUNET_assert (0 == event->value.publish.completed);
152 GNUNET_assert (1 == event->value.publish.anonymity); 150 GNUNET_assert (1 == event->value.publish.anonymity);
153 } 151 }
154 else if (0 == strcmp ("list_indexed-context2", event->value.publish.cctx)) 152 else if (0 == strcmp ("list_indexed-context2", event->value.publish.cctx))
155 { 153 {
156 GNUNET_assert (0 == strcmp ("list_indexed-context-dir", 154 GNUNET_assert (0 ==
157 event->value.publish.pctx)); 155 strcmp ("list_indexed-context-dir",
156 event->value.publish.pctx));
158 GNUNET_assert (FILESIZE == event->value.publish.size); 157 GNUNET_assert (FILESIZE == event->value.publish.size);
159 GNUNET_assert (0 == event->value.publish.completed); 158 GNUNET_assert (0 == event->value.publish.completed);
160 GNUNET_assert (2 == event->value.publish.anonymity); 159 GNUNET_assert (2 == event->value.publish.anonymity);
161 } 160 }
162 else if (0 == strcmp ("list_indexed-context-dir", 161 else if (0 ==
163 event->value.publish.cctx)) 162 strcmp ("list_indexed-context-dir", event->value.publish.cctx))
164 { 163 {
165 GNUNET_assert (0 == event->value.publish.completed); 164 GNUNET_assert (0 == event->value.publish.completed);
166 GNUNET_assert (3 == event->value.publish.anonymity); 165 GNUNET_assert (3 == event->value.publish.anonymity);
@@ -188,12 +187,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
188{ 187{
189 p->cfg = GNUNET_CONFIGURATION_create (); 188 p->cfg = GNUNET_CONFIGURATION_create ();
190#if START_ARM 189#if START_ARM
191 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 190 p->arm_proc =
192 "gnunet-service-arm", 191 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
192 "gnunet-service-arm",
193#if VERBOSE 193#if VERBOSE
194 "-L", "DEBUG", 194 "-L", "DEBUG",
195#endif 195#endif
196 "-c", cfgname, NULL); 196 "-c", cfgname, NULL);
197#endif 197#endif
198 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 198 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
199} 199}
@@ -209,8 +209,7 @@ stop_arm (struct PeerContext *p)
209 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 209 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
210 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 210 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
211 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 211 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
213 "ARM process %u stopped\n",
214 GNUNET_OS_process_get_pid (p->arm_proc)); 213 GNUNET_OS_process_get_pid (p->arm_proc));
215 GNUNET_OS_process_close (p->arm_proc); 214 GNUNET_OS_process_close (p->arm_proc);
216 p->arm_proc = NULL; 215 p->arm_proc = NULL;
@@ -221,9 +220,8 @@ stop_arm (struct PeerContext *p)
221 220
222 221
223static void 222static void
224run (void *cls, 223run (void *cls, char *const *args, const char *cfgfile,
225 char *const *args, 224 const struct GNUNET_CONFIGURATION_Handle *cfg)
226 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
227{ 225{
228 const char *keywords[] = { 226 const char *keywords[] = {
229 "down_foo", 227 "down_foo",
@@ -239,19 +237,15 @@ run (void *cls,
239 struct GNUNET_FS_BlockOptions bo; 237 struct GNUNET_FS_BlockOptions bo;
240 238
241 setup_peer (&p1, "test_fs_list_indexed_data.conf"); 239 setup_peer (&p1, "test_fs_list_indexed_data.conf");
242 fs = GNUNET_FS_start (cfg, 240 fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL,
243 "test-fs-list_indexed", 241 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
244 &progress_cb,
245 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
246 GNUNET_assert (NULL != fs); 242 GNUNET_assert (NULL != fs);
247 fn1 = GNUNET_DISK_mktemp ("gnunet-list_indexed-test-dst"); 243 fn1 = GNUNET_DISK_mktemp ("gnunet-list_indexed-test-dst");
248 buf = GNUNET_malloc (FILESIZE); 244 buf = GNUNET_malloc (FILESIZE);
249 for (i = 0; i < FILESIZE; i++) 245 for (i = 0; i < FILESIZE; i++)
250 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 246 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
251 GNUNET_assert (FILESIZE == 247 GNUNET_assert (FILESIZE ==
252 GNUNET_DISK_fn_write (fn1, 248 GNUNET_DISK_fn_write (fn1, buf, FILESIZE,
253 buf,
254 FILESIZE,
255 GNUNET_DISK_PERM_USER_READ | 249 GNUNET_DISK_PERM_USER_READ |
256 GNUNET_DISK_PERM_USER_WRITE)); 250 GNUNET_DISK_PERM_USER_WRITE));
257 GNUNET_free (buf); 251 GNUNET_free (buf);
@@ -261,9 +255,7 @@ run (void *cls,
261 for (i = 0; i < FILESIZE; i++) 255 for (i = 0; i < FILESIZE; i++)
262 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 256 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
263 GNUNET_assert (FILESIZE == 257 GNUNET_assert (FILESIZE ==
264 GNUNET_DISK_fn_write (fn2, 258 GNUNET_DISK_fn_write (fn2, buf, FILESIZE,
265 buf,
266 FILESIZE,
267 GNUNET_DISK_PERM_USER_READ | 259 GNUNET_DISK_PERM_USER_READ |
268 GNUNET_DISK_PERM_USER_WRITE)); 260 GNUNET_DISK_PERM_USER_WRITE));
269 GNUNET_free (buf); 261 GNUNET_free (buf);
@@ -274,33 +266,31 @@ run (void *cls,
274 bo.anonymity_level = 1; 266 bo.anonymity_level = 1;
275 bo.replication_level = 0; 267 bo.replication_level = 0;
276 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 268 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
277 fi1 = GNUNET_FS_file_information_create_from_file (fs, 269 fi1 =
278 "list_indexed-context1", 270 GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context1",
279 fn1, 271 fn1, kuri, meta, GNUNET_YES,
280 kuri, 272 &bo);
281 meta, GNUNET_YES, &bo);
282 GNUNET_assert (NULL != fi1); 273 GNUNET_assert (NULL != fi1);
283 bo.anonymity_level = 2; 274 bo.anonymity_level = 2;
284 fi2 = GNUNET_FS_file_information_create_from_file (fs, 275 fi2 =
285 "list_indexed-context2", 276 GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context2",
286 fn2, 277 fn2, kuri, meta, GNUNET_YES,
287 kuri, 278 &bo);
288 meta, GNUNET_YES, &bo);
289 GNUNET_assert (NULL != fi2); 279 GNUNET_assert (NULL != fi2);
290 bo.anonymity_level = 3; 280 bo.anonymity_level = 3;
291 fidir = GNUNET_FS_file_information_create_empty_directory (fs, 281 fidir =
292 "list_indexed-context-dir", 282 GNUNET_FS_file_information_create_empty_directory (fs,
293 kuri, meta, &bo); 283 "list_indexed-context-dir",
284 kuri, meta, &bo);
294 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 285 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
295 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 286 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
296 GNUNET_FS_uri_destroy (kuri); 287 GNUNET_FS_uri_destroy (kuri);
297 GNUNET_CONTAINER_meta_data_destroy (meta); 288 GNUNET_CONTAINER_meta_data_destroy (meta);
298 GNUNET_assert (NULL != fidir); 289 GNUNET_assert (NULL != fidir);
299 start = GNUNET_TIME_absolute_get (); 290 start = GNUNET_TIME_absolute_get ();
300 publish = GNUNET_FS_publish_start (fs, 291 publish =
301 fidir, 292 GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL,
302 NULL, NULL, NULL, 293 GNUNET_FS_PUBLISH_OPTION_NONE);
303 GNUNET_FS_PUBLISH_OPTION_NONE);
304 GNUNET_assert (publish != NULL); 294 GNUNET_assert (publish != NULL);
305} 295}
306 296
@@ -328,9 +318,8 @@ main (int argc, char *argv[])
328 "WARNING", 318 "WARNING",
329#endif 319#endif
330 NULL); 320 NULL);
331 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 321 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
332 argvx, "test-fs-list_indexed", 322 "test-fs-list_indexed", "nohelp", options, &run, NULL);
333 "nohelp", options, &run, NULL);
334 stop_arm (&p1); 323 stop_arm (&p1);
335 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/"); 324 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/");
336 if (fn1 != NULL) 325 if (fn1 != NULL)
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index 96caa8dfa..ae2f77806 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -66,12 +66,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
66{ 66{
67 p->cfg = GNUNET_CONFIGURATION_create (); 67 p->cfg = GNUNET_CONFIGURATION_create ();
68#if START_ARM 68#if START_ARM
69 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 69 p->arm_proc =
70 "gnunet-service-arm", 70 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
71 "gnunet-service-arm",
71#if VERBOSE 72#if VERBOSE
72 "-L", "DEBUG", 73 "-L", "DEBUG",
73#endif 74#endif
74 "-c", cfgname, NULL); 75 "-c", cfgname, NULL);
75#endif 76#endif
76 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 77 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
77} 78}
@@ -87,8 +88,7 @@ stop_arm (struct PeerContext *p)
87 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 88 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
88 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 89 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
89 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 90 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
90 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
91 "ARM process %u stopped\n",
92 GNUNET_OS_process_get_pid (p->arm_proc)); 92 GNUNET_OS_process_get_pid (p->arm_proc));
93 GNUNET_OS_process_close (p->arm_proc); 93 GNUNET_OS_process_close (p->arm_proc);
94 p->arm_proc = NULL; 94 p->arm_proc = NULL;
@@ -155,8 +155,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
155 case GNUNET_FS_STATUS_SEARCH_RESULT: 155 case GNUNET_FS_STATUS_SEARCH_RESULT:
156 if (sks_search == event->value.search.sc) 156 if (sks_search == event->value.search.sc)
157 { 157 {
158 if (!GNUNET_FS_uri_test_equal (sks_expect_uri, 158 if (!GNUNET_FS_uri_test_equal
159 event->value.search.specifics.result.uri)) 159 (sks_expect_uri, event->value.search.specifics.result.uri))
160 { 160 {
161 fprintf (stderr, "Wrong result for sks search!\n"); 161 fprintf (stderr, "Wrong result for sks search!\n");
162 err = 1; 162 err = 1;
@@ -167,14 +167,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
167 } 167 }
168 else if (ksk_search == event->value.search.sc) 168 else if (ksk_search == event->value.search.sc)
169 { 169 {
170 if (!GNUNET_FS_uri_test_equal (ksk_expect_uri, 170 if (!GNUNET_FS_uri_test_equal
171 event->value.search.specifics.result.uri)) 171 (ksk_expect_uri, event->value.search.specifics.result.uri))
172 { 172 {
173 fprintf (stderr, "Wrong result for ksk search!\n"); 173 fprintf (stderr, "Wrong result for ksk search!\n");
174 err = 1; 174 err = 1;
175 } 175 }
176 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, 176 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
177 NULL,
178 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 177 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
179 } 178 }
180 else 179 else
@@ -184,16 +183,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
184 } 183 }
185 break; 184 break;
186 case GNUNET_FS_STATUS_SEARCH_ERROR: 185 case GNUNET_FS_STATUS_SEARCH_ERROR:
187 fprintf (stderr, 186 fprintf (stderr, "Error searching file: %s\n",
188 "Error searching file: %s\n",
189 event->value.search.specifics.error.message); 187 event->value.search.specifics.error.message);
190 if (sks_search == event->value.search.sc) 188 if (sks_search == event->value.search.sc)
191 GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, 189 GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL,
192 NULL,
193 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 190 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
194 else if (ksk_search == event->value.search.sc) 191 else if (ksk_search == event->value.search.sc)
195 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, 192 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
196 NULL,
197 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 193 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
198 else 194 else
199 GNUNET_break (0); 195 GNUNET_break (0);
@@ -365,15 +361,12 @@ testNamespace ()
365 361
366 362
367static void 363static void
368run (void *cls, 364run (void *cls, char *const *args, const char *cfgfile,
369 char *const *args, 365 const struct GNUNET_CONFIGURATION_Handle *cfg)
370 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
371{ 366{
372 setup_peer (&p1, "test_fs_namespace_data.conf"); 367 setup_peer (&p1, "test_fs_namespace_data.conf");
373 fs = GNUNET_FS_start (cfg, 368 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
374 "test-fs-namespace", 369 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
375 &progress_cb,
376 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
377 testNamespace (); 370 testNamespace ();
378} 371}
379 372
@@ -401,9 +394,8 @@ main (int argc, char *argv[])
401 "WARNING", 394 "WARNING",
402#endif 395#endif
403 NULL); 396 NULL);
404 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 397 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
405 argvx, "test-fs-namespace", 398 "test-fs-namespace", "nohelp", options, &run, NULL);
406 "nohelp", options, &run, NULL);
407 stop_arm (&p1); 399 stop_arm (&p1);
408 if (GNUNET_YES != update_started) 400 if (GNUNET_YES != update_started)
409 { 401 {
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index dc8673e21..1ad2fb5ac 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -70,12 +70,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
70{ 70{
71 p->cfg = GNUNET_CONFIGURATION_create (); 71 p->cfg = GNUNET_CONFIGURATION_create ();
72#if START_ARM 72#if START_ARM
73 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 73 p->arm_proc =
74 "gnunet-service-arm", 74 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
75 "gnunet-service-arm",
75#if VERBOSE 76#if VERBOSE
76 "-L", "DEBUG", 77 "-L", "DEBUG",
77#endif 78#endif
78 "-c", cfgname, NULL); 79 "-c", cfgname, NULL);
79#endif 80#endif
80 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 81 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
81} 82}
@@ -91,8 +92,7 @@ stop_arm (struct PeerContext *p)
91 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 92 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
92 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 93 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
93 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 94 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
95 "ARM process %u stopped\n",
96 GNUNET_OS_process_get_pid (p->arm_proc)); 96 GNUNET_OS_process_get_pid (p->arm_proc));
97 GNUNET_OS_process_close (p->arm_proc); 97 GNUNET_OS_process_close (p->arm_proc);
98 p->arm_proc = NULL; 98 p->arm_proc = NULL;
@@ -112,8 +112,7 @@ stop_arm (struct PeerContext *p)
112 112
113 113
114static void 114static void
115check_next (void *cls, 115check_next (void *cls, const char *last_id,
116 const char *last_id,
117 const struct GNUNET_FS_Uri *last_uri, 116 const struct GNUNET_FS_Uri *last_uri,
118 const struct GNUNET_CONTAINER_MetaData *last_meta, 117 const struct GNUNET_CONTAINER_MetaData *last_meta,
119 const char *next_id) 118 const char *next_id)
@@ -125,8 +124,7 @@ check_next (void *cls,
125 124
126 125
127static void 126static void
128check_this_next (void *cls, 127check_this_next (void *cls, const char *last_id,
129 const char *last_id,
130 const struct GNUNET_FS_Uri *last_uri, 128 const struct GNUNET_FS_Uri *last_uri,
131 const struct GNUNET_CONTAINER_MetaData *last_meta, 129 const struct GNUNET_CONTAINER_MetaData *last_meta,
132 const char *next_id) 130 const char *next_id)
@@ -150,8 +148,7 @@ sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
150 148
151 149
152static void 150static void
153check_this (void *cls, 151check_this (void *cls, const char *last_id,
154 const char *last_id,
155 const struct GNUNET_FS_Uri *last_uri, 152 const struct GNUNET_FS_Uri *last_uri,
156 const struct GNUNET_CONTAINER_MetaData *last_meta, 153 const struct GNUNET_CONTAINER_MetaData *last_meta,
157 const char *next_id) 154 const char *next_id)
@@ -169,13 +166,7 @@ sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
169 GNUNET_assert (NULL == emsg); 166 GNUNET_assert (NULL == emsg);
170 err = 1; 167 err = 1;
171 GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL); 168 GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL);
172 GNUNET_FS_publish_sks (fs, 169 GNUNET_FS_publish_sks (fs, ns, "next", "future", meta, uri_next, &bo,
173 ns,
174 "next",
175 "future",
176 meta,
177 uri_next,
178 &bo,
179 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL); 170 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL);
180 171
181} 172}
@@ -209,15 +200,12 @@ testNamespace ()
209 200
210 201
211static void 202static void
212run (void *cls, 203run (void *cls, char *const *args, const char *cfgfile,
213 char *const *args, 204 const struct GNUNET_CONFIGURATION_Handle *cfg)
214 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
215{ 205{
216 setup_peer (&p1, "test_fs_namespace_data.conf"); 206 setup_peer (&p1, "test_fs_namespace_data.conf");
217 fs = GNUNET_FS_start (cfg, 207 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
218 "test-fs-namespace", 208 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
219 &progress_cb,
220 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
221 testNamespace (); 209 testNamespace ();
222} 210}
223 211
@@ -245,9 +233,8 @@ main (int argc, char *argv[])
245 "WARNING", 233 "WARNING",
246#endif 234#endif
247 NULL); 235 NULL);
248 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 236 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
249 argvx, "test-fs-namespace", 237 "test-fs-namespace", "nohelp", options, &run, NULL);
250 "nohelp", options, &run, NULL);
251 stop_arm (&p1); 238 stop_arm (&p1);
252 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); 239 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/");
253 return err; 240 return err;
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index d53b5b0ae..797c4c9a8 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -98,11 +98,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
98 printf ("Publish complete, %llu kbps.\n", 98 printf ("Publish complete, %llu kbps.\n",
99 (unsigned long long) (FILESIZE * 1000 / 99 (unsigned long long) (FILESIZE * 1000 /
100 (1 + 100 (1 +
101 GNUNET_TIME_absolute_get_duration 101 GNUNET_TIME_absolute_get_duration (start).
102 (start).rel_value) / 1024)); 102 rel_value) / 1024));
103 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) 103 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
104 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 104 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
105 NULL,
106 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 105 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
107 break; 106 break;
108 case GNUNET_FS_STATUS_PUBLISH_PROGRESS: 107 case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
@@ -113,22 +112,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
113 (unsigned long long) event->value.publish.completed, 112 (unsigned long long) event->value.publish.completed,
114 (unsigned long long) event->value.publish.size, 113 (unsigned long long) event->value.publish.size,
115 event->value.publish.specifics.progress.depth, 114 event->value.publish.specifics.progress.depth,
116 (unsigned long long) event->value.publish.specifics. 115 (unsigned long long) event->value.publish.specifics.progress.
117 progress.offset); 116 offset);
118#endif 117#endif
119 break; 118 break;
120 case GNUNET_FS_STATUS_PUBLISH_ERROR: 119 case GNUNET_FS_STATUS_PUBLISH_ERROR:
121 ret = event->value.publish.cctx; 120 ret = event->value.publish.cctx;
122 fprintf (stderr, 121 fprintf (stderr, "Error publishing file: %s\n",
123 "Error publishing file: %s\n",
124 event->value.publish.specifics.error.message); 122 event->value.publish.specifics.error.message);
125 err = 1; 123 err = 1;
126 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) 124 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
127 { 125 {
128 fprintf (stderr, "Scheduling abort task for error on `%s'\n", 126 fprintf (stderr, "Scheduling abort task for error on `%s'\n",
129 (const char *) event->value.publish.cctx); 127 (const char *) event->value.publish.cctx);
130 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 128 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
131 NULL,
132 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 129 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
133 } 130 }
134 break; 131 break;
@@ -136,16 +133,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
136 ret = event->value.publish.cctx; 133 ret = event->value.publish.cctx;
137 if (0 == strcmp ("publish-context1", event->value.publish.cctx)) 134 if (0 == strcmp ("publish-context1", event->value.publish.cctx))
138 { 135 {
139 GNUNET_assert (0 == strcmp ("publish-context-dir", 136 GNUNET_assert (0 ==
140 event->value.publish.pctx)); 137 strcmp ("publish-context-dir", event->value.publish.pctx));
141 GNUNET_assert (FILESIZE == event->value.publish.size); 138 GNUNET_assert (FILESIZE == event->value.publish.size);
142 GNUNET_assert (0 == event->value.publish.completed); 139 GNUNET_assert (0 == event->value.publish.completed);
143 GNUNET_assert (1 == event->value.publish.anonymity); 140 GNUNET_assert (1 == event->value.publish.anonymity);
144 } 141 }
145 else if (0 == strcmp ("publish-context2", event->value.publish.cctx)) 142 else if (0 == strcmp ("publish-context2", event->value.publish.cctx))
146 { 143 {
147 GNUNET_assert (0 == strcmp ("publish-context-dir", 144 GNUNET_assert (0 ==
148 event->value.publish.pctx)); 145 strcmp ("publish-context-dir", event->value.publish.pctx));
149 GNUNET_assert (FILESIZE == event->value.publish.size); 146 GNUNET_assert (FILESIZE == event->value.publish.size);
150 GNUNET_assert (0 == event->value.publish.completed); 147 GNUNET_assert (0 == event->value.publish.completed);
151 GNUNET_assert (2 == event->value.publish.anonymity); 148 GNUNET_assert (2 == event->value.publish.anonymity);
@@ -175,12 +172,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
175{ 172{
176 p->cfg = GNUNET_CONFIGURATION_create (); 173 p->cfg = GNUNET_CONFIGURATION_create ();
177#if START_ARM 174#if START_ARM
178 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 175 p->arm_proc =
179 "gnunet-service-arm", 176 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
177 "gnunet-service-arm",
180#if VERBOSE 178#if VERBOSE
181 "-L", "DEBUG", 179 "-L", "DEBUG",
182#endif 180#endif
183 "-c", cfgname, NULL); 181 "-c", cfgname, NULL);
184#endif 182#endif
185 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 183 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
186} 184}
@@ -196,8 +194,7 @@ stop_arm (struct PeerContext *p)
196 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 194 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
197 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 195 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
198 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 196 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
200 "ARM process %u stopped\n",
201 GNUNET_OS_process_get_pid (p->arm_proc)); 198 GNUNET_OS_process_get_pid (p->arm_proc));
202 GNUNET_OS_process_close (p->arm_proc); 199 GNUNET_OS_process_close (p->arm_proc);
203 p->arm_proc = NULL; 200 p->arm_proc = NULL;
@@ -208,9 +205,8 @@ stop_arm (struct PeerContext *p)
208 205
209 206
210static void 207static void
211run (void *cls, 208run (void *cls, char *const *args, const char *cfgfile,
212 char *const *args, 209 const struct GNUNET_CONFIGURATION_Handle *cfg)
213 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
214{ 210{
215 const char *keywords[] = { 211 const char *keywords[] = {
216 "down_foo", 212 "down_foo",
@@ -226,19 +222,15 @@ run (void *cls,
226 struct GNUNET_FS_BlockOptions bo; 222 struct GNUNET_FS_BlockOptions bo;
227 223
228 setup_peer (&p1, "test_fs_publish_data.conf"); 224 setup_peer (&p1, "test_fs_publish_data.conf");
229 fs = GNUNET_FS_start (cfg, 225 fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL,
230 "test-fs-publish", 226 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
231 &progress_cb,
232 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
233 GNUNET_assert (NULL != fs); 227 GNUNET_assert (NULL != fs);
234 fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst"); 228 fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst");
235 buf = GNUNET_malloc (FILESIZE); 229 buf = GNUNET_malloc (FILESIZE);
236 for (i = 0; i < FILESIZE; i++) 230 for (i = 0; i < FILESIZE; i++)
237 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 231 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
238 GNUNET_assert (FILESIZE == 232 GNUNET_assert (FILESIZE ==
239 GNUNET_DISK_fn_write (fn1, 233 GNUNET_DISK_fn_write (fn1, buf, FILESIZE,
240 buf,
241 FILESIZE,
242 GNUNET_DISK_PERM_USER_READ | 234 GNUNET_DISK_PERM_USER_READ |
243 GNUNET_DISK_PERM_USER_WRITE)); 235 GNUNET_DISK_PERM_USER_WRITE));
244 GNUNET_free (buf); 236 GNUNET_free (buf);
@@ -248,9 +240,7 @@ run (void *cls,
248 for (i = 0; i < FILESIZE; i++) 240 for (i = 0; i < FILESIZE; i++)
249 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 241 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
250 GNUNET_assert (FILESIZE == 242 GNUNET_assert (FILESIZE ==
251 GNUNET_DISK_fn_write (fn2, 243 GNUNET_DISK_fn_write (fn2, buf, FILESIZE,
252 buf,
253 FILESIZE,
254 GNUNET_DISK_PERM_USER_READ | 244 GNUNET_DISK_PERM_USER_READ |
255 GNUNET_DISK_PERM_USER_WRITE)); 245 GNUNET_DISK_PERM_USER_WRITE));
256 GNUNET_free (buf); 246 GNUNET_free (buf);
@@ -262,34 +252,30 @@ run (void *cls,
262 bo.replication_level = 0; 252 bo.replication_level = 0;
263 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 253 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
264 254
265 fi1 = GNUNET_FS_file_information_create_from_file (fs, 255 fi1 =
266 "publish-context1", 256 GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1,
267 fn1, 257 kuri, meta, GNUNET_YES, &bo);
268 kuri,
269 meta, GNUNET_YES, &bo);
270 258
271 GNUNET_assert (NULL != fi1); 259 GNUNET_assert (NULL != fi1);
272 bo.anonymity_level = 2; 260 bo.anonymity_level = 2;
273 fi2 = GNUNET_FS_file_information_create_from_file (fs, 261 fi2 =
274 "publish-context2", 262 GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2,
275 fn2, 263 kuri, meta, GNUNET_YES, &bo);
276 kuri,
277 meta, GNUNET_YES, &bo);
278 GNUNET_assert (NULL != fi2); 264 GNUNET_assert (NULL != fi2);
279 bo.anonymity_level = 3; 265 bo.anonymity_level = 3;
280 fidir = GNUNET_FS_file_information_create_empty_directory (fs, 266 fidir =
281 "publish-context-dir", 267 GNUNET_FS_file_information_create_empty_directory (fs,
282 kuri, meta, &bo); 268 "publish-context-dir",
269 kuri, meta, &bo);
283 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 270 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
284 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 271 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
285 GNUNET_FS_uri_destroy (kuri); 272 GNUNET_FS_uri_destroy (kuri);
286 GNUNET_CONTAINER_meta_data_destroy (meta); 273 GNUNET_CONTAINER_meta_data_destroy (meta);
287 GNUNET_assert (NULL != fidir); 274 GNUNET_assert (NULL != fidir);
288 start = GNUNET_TIME_absolute_get (); 275 start = GNUNET_TIME_absolute_get ();
289 publish = GNUNET_FS_publish_start (fs, 276 publish =
290 fidir, 277 GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL,
291 NULL, NULL, NULL, 278 GNUNET_FS_PUBLISH_OPTION_NONE);
292 GNUNET_FS_PUBLISH_OPTION_NONE);
293 GNUNET_assert (publish != NULL); 279 GNUNET_assert (publish != NULL);
294} 280}
295 281
@@ -317,8 +303,8 @@ main (int argc, char *argv[])
317 "WARNING", 303 "WARNING",
318#endif 304#endif
319 NULL); 305 NULL);
320 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 306 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
321 argvx, "test-fs-publish", "nohelp", options, &run, NULL); 307 "test-fs-publish", "nohelp", options, &run, NULL);
322 stop_arm (&p1); 308 stop_arm (&p1);
323 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/"); 309 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
324 if (fn1 != NULL) 310 if (fn1 != NULL)
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index 4dcf10965..f69ac5d9a 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -106,10 +106,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
106{ 106{
107 rtask = GNUNET_SCHEDULER_NO_TASK; 107 rtask = GNUNET_SCHEDULER_NO_TASK;
108 GNUNET_FS_stop (fs); 108 GNUNET_FS_stop (fs);
109 fs = GNUNET_FS_start (cfg, 109 fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL,
110 "test-fs-publish-persistence",
111 &progress_cb,
112 NULL,
113 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 110 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
114} 111}
115 112
@@ -132,8 +129,9 @@ consider_restart (int ev)
132 if (prev[i] == ev) 129 if (prev[i] == ev)
133 return; 130 return;
134 prev[off++] = ev; 131 prev[off++] = ev;
135 rtask = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, 132 rtask =
136 &restart_fs_task, NULL); 133 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT,
134 &restart_fs_task, NULL);
137} 135}
138 136
139 137
@@ -151,8 +149,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
151 printf ("Publish complete, %llu kbps.\n", 149 printf ("Publish complete, %llu kbps.\n",
152 (unsigned long long) (FILESIZE * 1000LL / 150 (unsigned long long) (FILESIZE * 1000LL /
153 (1 + 151 (1 +
154 GNUNET_TIME_absolute_get_duration 152 GNUNET_TIME_absolute_get_duration (start).
155 (start).rel_value) / 1024)); 153 rel_value) / 1024));
156 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) 154 if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
157 GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); 155 GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
158 break; 156 break;
@@ -165,8 +163,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
165 (unsigned long long) event->value.publish.completed, 163 (unsigned long long) event->value.publish.completed,
166 (unsigned long long) event->value.publish.size, 164 (unsigned long long) event->value.publish.size,
167 event->value.publish.specifics.progress.depth, 165 event->value.publish.specifics.progress.depth,
168 (unsigned long long) event->value.publish.specifics. 166 (unsigned long long) event->value.publish.specifics.progress.
169 progress.offset); 167 offset);
170#endif 168#endif
171 break; 169 break;
172 case GNUNET_FS_STATUS_PUBLISH_SUSPEND: 170 case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
@@ -177,17 +175,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
177 if (NULL == publish) 175 if (NULL == publish)
178 { 176 {
179 GNUNET_assert (GNUNET_YES == 177 GNUNET_assert (GNUNET_YES ==
180 GNUNET_FS_file_information_is_directory (event-> 178 GNUNET_FS_file_information_is_directory (event->value.
181 value.publish. 179 publish.fi));
182 fi));
183 publish = event->value.publish.pc; 180 publish = event->value.publish.pc;
184 return "publish-context-dir"; 181 return "publish-context-dir";
185 } 182 }
186 break; 183 break;
187 case GNUNET_FS_STATUS_PUBLISH_ERROR: 184 case GNUNET_FS_STATUS_PUBLISH_ERROR:
188 ret = event->value.publish.cctx; 185 ret = event->value.publish.cctx;
189 fprintf (stderr, 186 fprintf (stderr, "Error publishing file: %s\n",
190 "Error publishing file: %s\n",
191 event->value.publish.specifics.error.message); 187 event->value.publish.specifics.error.message);
192 err = 1; 188 err = 1;
193 GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); 189 GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
@@ -198,16 +194,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
198 ret = event->value.publish.cctx; 194 ret = event->value.publish.cctx;
199 if (0 == strcmp ("publish-context1", event->value.publish.cctx)) 195 if (0 == strcmp ("publish-context1", event->value.publish.cctx))
200 { 196 {
201 GNUNET_assert (0 == strcmp ("publish-context-dir", 197 GNUNET_assert (0 ==
202 event->value.publish.pctx)); 198 strcmp ("publish-context-dir", event->value.publish.pctx));
203 GNUNET_assert (FILESIZE == event->value.publish.size); 199 GNUNET_assert (FILESIZE == event->value.publish.size);
204 GNUNET_assert (0 == event->value.publish.completed); 200 GNUNET_assert (0 == event->value.publish.completed);
205 GNUNET_assert (1 == event->value.publish.anonymity); 201 GNUNET_assert (1 == event->value.publish.anonymity);
206 } 202 }
207 else if (0 == strcmp ("publish-context2", event->value.publish.cctx)) 203 else if (0 == strcmp ("publish-context2", event->value.publish.cctx))
208 { 204 {
209 GNUNET_assert (0 == strcmp ("publish-context-dir", 205 GNUNET_assert (0 ==
210 event->value.publish.pctx)); 206 strcmp ("publish-context-dir", event->value.publish.pctx));
211 GNUNET_assert (FILESIZE == event->value.publish.size); 207 GNUNET_assert (FILESIZE == event->value.publish.size);
212 GNUNET_assert (0 == event->value.publish.completed); 208 GNUNET_assert (0 == event->value.publish.completed);
213 GNUNET_assert (2 == event->value.publish.anonymity); 209 GNUNET_assert (2 == event->value.publish.anonymity);
@@ -238,12 +234,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
238{ 234{
239 p->cfg = GNUNET_CONFIGURATION_create (); 235 p->cfg = GNUNET_CONFIGURATION_create ();
240#if START_ARM 236#if START_ARM
241 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 237 p->arm_proc =
242 "gnunet-service-arm", 238 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
239 "gnunet-service-arm",
243#if VERBOSE 240#if VERBOSE
244 "-L", "DEBUG", 241 "-L", "DEBUG",
245#endif 242#endif
246 "-c", cfgname, NULL); 243 "-c", cfgname, NULL);
247#endif 244#endif
248 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 245 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
249} 246}
@@ -259,8 +256,7 @@ stop_arm (struct PeerContext *p)
259 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 256 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
260 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 257 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
261 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 258 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
263 "ARM process %u stopped\n",
264 GNUNET_OS_process_get_pid (p->arm_proc)); 260 GNUNET_OS_process_get_pid (p->arm_proc));
265 GNUNET_OS_process_close (p->arm_proc); 261 GNUNET_OS_process_close (p->arm_proc);
266 p->arm_proc = NULL; 262 p->arm_proc = NULL;
@@ -271,9 +267,8 @@ stop_arm (struct PeerContext *p)
271 267
272 268
273static void 269static void
274run (void *cls, 270run (void *cls, char *const *args, const char *cfgfile,
275 char *const *args, 271 const struct GNUNET_CONFIGURATION_Handle *c)
276 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
277{ 272{
278 const char *keywords[] = { 273 const char *keywords[] = {
279 "down_foo", 274 "down_foo",
@@ -290,10 +285,7 @@ run (void *cls,
290 285
291 cfg = c; 286 cfg = c;
292 setup_peer (&p1, "test_fs_publish_data.conf"); 287 setup_peer (&p1, "test_fs_publish_data.conf");
293 fs = GNUNET_FS_start (cfg, 288 fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL,
294 "test-fs-publish-persistence",
295 &progress_cb,
296 NULL,
297 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 289 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
298 GNUNET_assert (NULL != fs); 290 GNUNET_assert (NULL != fs);
299 fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst"); 291 fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst");
@@ -301,9 +293,7 @@ run (void *cls,
301 for (i = 0; i < FILESIZE; i++) 293 for (i = 0; i < FILESIZE; i++)
302 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 294 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
303 GNUNET_assert (FILESIZE == 295 GNUNET_assert (FILESIZE ==
304 GNUNET_DISK_fn_write (fn1, 296 GNUNET_DISK_fn_write (fn1, buf, FILESIZE,
305 buf,
306 FILESIZE,
307 GNUNET_DISK_PERM_USER_READ | 297 GNUNET_DISK_PERM_USER_READ |
308 GNUNET_DISK_PERM_USER_WRITE)); 298 GNUNET_DISK_PERM_USER_WRITE));
309 GNUNET_free (buf); 299 GNUNET_free (buf);
@@ -313,9 +303,7 @@ run (void *cls,
313 for (i = 0; i < FILESIZE; i++) 303 for (i = 0; i < FILESIZE; i++)
314 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 304 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
315 GNUNET_assert (FILESIZE == 305 GNUNET_assert (FILESIZE ==
316 GNUNET_DISK_fn_write (fn2, 306 GNUNET_DISK_fn_write (fn2, buf, FILESIZE,
317 buf,
318 FILESIZE,
319 GNUNET_DISK_PERM_USER_READ | 307 GNUNET_DISK_PERM_USER_READ |
320 GNUNET_DISK_PERM_USER_WRITE)); 308 GNUNET_DISK_PERM_USER_WRITE));
321 GNUNET_free (buf); 309 GNUNET_free (buf);
@@ -326,32 +314,28 @@ run (void *cls,
326 bo.anonymity_level = 1; 314 bo.anonymity_level = 1;
327 bo.replication_level = 0; 315 bo.replication_level = 0;
328 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 316 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
329 fi1 = GNUNET_FS_file_information_create_from_file (fs, 317 fi1 =
330 "publish-context1", 318 GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1,
331 fn1, 319 kuri, meta, GNUNET_YES, &bo);
332 kuri,
333 meta, GNUNET_YES, &bo);
334 GNUNET_assert (NULL != fi1); 320 GNUNET_assert (NULL != fi1);
335 bo.anonymity_level = 2; 321 bo.anonymity_level = 2;
336 fi2 = GNUNET_FS_file_information_create_from_file (fs, 322 fi2 =
337 "publish-context2", 323 GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2,
338 fn2, 324 kuri, meta, GNUNET_YES, &bo);
339 kuri,
340 meta, GNUNET_YES, &bo);
341 GNUNET_assert (NULL != fi2); 325 GNUNET_assert (NULL != fi2);
342 bo.anonymity_level = 3; 326 bo.anonymity_level = 3;
343 fidir = GNUNET_FS_file_information_create_empty_directory (fs, 327 fidir =
344 "publish-context-dir", 328 GNUNET_FS_file_information_create_empty_directory (fs,
345 kuri, meta, &bo); 329 "publish-context-dir",
330 kuri, meta, &bo);
346 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 331 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
347 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 332 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
348 GNUNET_FS_uri_destroy (kuri); 333 GNUNET_FS_uri_destroy (kuri);
349 GNUNET_CONTAINER_meta_data_destroy (meta); 334 GNUNET_CONTAINER_meta_data_destroy (meta);
350 GNUNET_assert (NULL != fidir); 335 GNUNET_assert (NULL != fidir);
351 start = GNUNET_TIME_absolute_get (); 336 start = GNUNET_TIME_absolute_get ();
352 GNUNET_FS_publish_start (fs, 337 GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL,
353 fidir, 338 GNUNET_FS_PUBLISH_OPTION_NONE);
354 NULL, NULL, NULL, GNUNET_FS_PUBLISH_OPTION_NONE);
355 GNUNET_assert (publish != NULL); 339 GNUNET_assert (publish != NULL);
356} 340}
357 341
@@ -379,8 +363,8 @@ main (int argc, char *argv[])
379 "WARNING", 363 "WARNING",
380#endif 364#endif
381 NULL); 365 NULL);
382 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 366 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
383 argvx, "test-fs-publish", "nohelp", options, &run, NULL); 367 "test-fs-publish", "nohelp", options, &run, NULL);
384 stop_arm (&p1); 368 stop_arm (&p1);
385 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/"); 369 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/");
386 if (fn1 != NULL) 370 if (fn1 != NULL)
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 878624c73..3961017cf 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -101,16 +101,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
101 (unsigned long long) event->value.publish.completed, 101 (unsigned long long) event->value.publish.completed,
102 (unsigned long long) event->value.publish.size, 102 (unsigned long long) event->value.publish.size,
103 event->value.publish.specifics.progress.depth, 103 event->value.publish.specifics.progress.depth,
104 (unsigned long long) event->value.publish.specifics. 104 (unsigned long long) event->value.publish.specifics.progress.
105 progress.offset); 105 offset);
106#endif 106#endif
107 break; 107 break;
108 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 108 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
109 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); 109 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
110 start = GNUNET_TIME_absolute_get (); 110 start = GNUNET_TIME_absolute_get ();
111 search = GNUNET_FS_search_start (fs, 111 search =
112 kuri, 112 GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE,
113 1, GNUNET_FS_SEARCH_OPTION_NONE, "search"); 113 "search");
114 GNUNET_FS_uri_destroy (kuri); 114 GNUNET_FS_uri_destroy (kuri);
115 GNUNET_assert (search != NULL); 115 GNUNET_assert (search != NULL);
116 break; 116 break;
@@ -118,25 +118,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
118#if VERBOSE 118#if VERBOSE
119 printf ("Search complete.\n"); 119 printf ("Search complete.\n");
120#endif 120#endif
121 GNUNET_SCHEDULER_add_continuation (&abort_search_task, 121 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
122 NULL,
123 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 122 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
124 break; 123 break;
125 case GNUNET_FS_STATUS_PUBLISH_ERROR: 124 case GNUNET_FS_STATUS_PUBLISH_ERROR:
126 fprintf (stderr, 125 fprintf (stderr, "Error publishing file: %s\n",
127 "Error publishing file: %s\n",
128 event->value.publish.specifics.error.message); 126 event->value.publish.specifics.error.message);
129 GNUNET_break (0); 127 GNUNET_break (0);
130 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 128 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
131 NULL,
132 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 129 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
133 break; 130 break;
134 case GNUNET_FS_STATUS_SEARCH_ERROR: 131 case GNUNET_FS_STATUS_SEARCH_ERROR:
135 fprintf (stderr, 132 fprintf (stderr, "Error searching file: %s\n",
136 "Error searching file: %s\n",
137 event->value.search.specifics.error.message); 133 event->value.search.specifics.error.message);
138 GNUNET_SCHEDULER_add_continuation (&abort_search_task, 134 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
139 NULL,
140 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 135 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
141 break; 136 break;
142 case GNUNET_FS_STATUS_PUBLISH_START: 137 case GNUNET_FS_STATUS_PUBLISH_START:
@@ -162,8 +157,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
162 break; 157 break;
163 case GNUNET_FS_STATUS_SEARCH_STOPPED: 158 case GNUNET_FS_STATUS_SEARCH_STOPPED:
164 GNUNET_assert (search == event->value.search.sc); 159 GNUNET_assert (search == event->value.search.sc);
165 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 160 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
166 NULL,
167 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 161 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
168 break; 162 break;
169 default: 163 default:
@@ -179,12 +173,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
179{ 173{
180 p->cfg = GNUNET_CONFIGURATION_create (); 174 p->cfg = GNUNET_CONFIGURATION_create ();
181#if START_ARM 175#if START_ARM
182 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 176 p->arm_proc =
183 "gnunet-service-arm", 177 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
178 "gnunet-service-arm",
184#if VERBOSE 179#if VERBOSE
185 "-L", "DEBUG", 180 "-L", "DEBUG",
186#endif 181#endif
187 "-c", cfgname, NULL); 182 "-c", cfgname, NULL);
188#endif 183#endif
189 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 184 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
190} 185}
@@ -200,8 +195,7 @@ stop_arm (struct PeerContext *p)
200 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 195 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
201 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 196 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
202 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 197 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
204 "ARM process %u stopped\n",
205 GNUNET_OS_process_get_pid (p->arm_proc)); 199 GNUNET_OS_process_get_pid (p->arm_proc));
206 GNUNET_OS_process_close (p->arm_proc); 200 GNUNET_OS_process_close (p->arm_proc);
207 p->arm_proc = NULL; 201 p->arm_proc = NULL;
@@ -212,9 +206,8 @@ stop_arm (struct PeerContext *p)
212 206
213 207
214static void 208static void
215run (void *cls, 209run (void *cls, char *const *args, const char *cfgfile,
216 char *const *args, 210 const struct GNUNET_CONFIGURATION_Handle *cfg)
217 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
218{ 211{
219 const char *keywords[] = { 212 const char *keywords[] = {
220 "down_foo", 213 "down_foo",
@@ -228,10 +221,8 @@ run (void *cls,
228 size_t i; 221 size_t i;
229 222
230 setup_peer (&p1, "test_fs_search_data.conf"); 223 setup_peer (&p1, "test_fs_search_data.conf");
231 fs = GNUNET_FS_start (cfg, 224 fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
232 "test-fs-search", 225 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
233 &progress_cb,
234 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
235 GNUNET_assert (NULL != fs); 226 GNUNET_assert (NULL != fs);
236 buf = GNUNET_malloc (FILESIZE); 227 buf = GNUNET_malloc (FILESIZE);
237 for (i = 0; i < FILESIZE; i++) 228 for (i = 0; i < FILESIZE; i++)
@@ -242,19 +233,16 @@ run (void *cls,
242 bo.anonymity_level = 1; 233 bo.anonymity_level = 1;
243 bo.replication_level = 0; 234 bo.replication_level = 0;
244 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 235 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
245 fi = GNUNET_FS_file_information_create_from_data (fs, 236 fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context",
246 "publish-context", 237 FILESIZE, buf, kuri, meta,
247 FILESIZE, 238 GNUNET_NO, &bo);
248 buf,
249 kuri, meta, GNUNET_NO, &bo);
250 GNUNET_FS_uri_destroy (kuri); 239 GNUNET_FS_uri_destroy (kuri);
251 GNUNET_CONTAINER_meta_data_destroy (meta); 240 GNUNET_CONTAINER_meta_data_destroy (meta);
252 GNUNET_assert (NULL != fi); 241 GNUNET_assert (NULL != fi);
253 start = GNUNET_TIME_absolute_get (); 242 start = GNUNET_TIME_absolute_get ();
254 publish = GNUNET_FS_publish_start (fs, 243 publish =
255 fi, 244 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
256 NULL, NULL, NULL, 245 GNUNET_FS_PUBLISH_OPTION_NONE);
257 GNUNET_FS_PUBLISH_OPTION_NONE);
258 GNUNET_assert (publish != NULL); 246 GNUNET_assert (publish != NULL);
259} 247}
260 248
@@ -282,8 +270,8 @@ main (int argc, char *argv[])
282 "WARNING", 270 "WARNING",
283#endif 271#endif
284 NULL); 272 NULL);
285 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 273 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
286 argvx, "test-fs-search", "nohelp", options, &run, NULL); 274 "test-fs-search", "nohelp", options, &run, NULL);
287 stop_arm (&p1); 275 stop_arm (&p1);
288 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); 276 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
289 return 0; 277 return 0;
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index eceb4d1d5..5c5a6f140 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -94,10 +94,7 @@ static void
94restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 94restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
95{ 95{
96 GNUNET_FS_stop (fs); 96 GNUNET_FS_stop (fs);
97 fs = GNUNET_FS_start (cfg, 97 fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL,
98 "test-fs-search-persistence",
99 &progress_cb,
100 NULL,
101 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 98 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
102} 99}
103 100
@@ -143,15 +140,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
143 (unsigned long long) event->value.publish.completed, 140 (unsigned long long) event->value.publish.completed,
144 (unsigned long long) event->value.publish.size, 141 (unsigned long long) event->value.publish.size,
145 event->value.publish.specifics.progress.depth, 142 event->value.publish.specifics.progress.depth,
146 (unsigned long long) event->value.publish.specifics. 143 (unsigned long long) event->value.publish.specifics.progress.
147 progress.offset); 144 offset);
148#endif 145#endif
149 break; 146 break;
150 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 147 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
151 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); 148 kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords);
152 start = GNUNET_TIME_absolute_get (); 149 start = GNUNET_TIME_absolute_get ();
153 GNUNET_FS_search_start (fs, 150 GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE,
154 kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, "search"); 151 "search");
155 GNUNET_FS_uri_destroy (kuri); 152 GNUNET_FS_uri_destroy (kuri);
156 GNUNET_assert (search != NULL); 153 GNUNET_assert (search != NULL);
157 break; 154 break;
@@ -169,25 +166,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
169#if VERBOSE 166#if VERBOSE
170 printf ("Search complete.\n"); 167 printf ("Search complete.\n");
171#endif 168#endif
172 GNUNET_SCHEDULER_add_continuation (&abort_search_task, 169 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
173 NULL,
174 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 170 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
175 break; 171 break;
176 case GNUNET_FS_STATUS_PUBLISH_ERROR: 172 case GNUNET_FS_STATUS_PUBLISH_ERROR:
177 fprintf (stderr, 173 fprintf (stderr, "Error publishing file: %s\n",
178 "Error publishing file: %s\n",
179 event->value.publish.specifics.error.message); 174 event->value.publish.specifics.error.message);
180 GNUNET_break (0); 175 GNUNET_break (0);
181 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 176 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
182 NULL,
183 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 177 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
184 break; 178 break;
185 case GNUNET_FS_STATUS_SEARCH_ERROR: 179 case GNUNET_FS_STATUS_SEARCH_ERROR:
186 fprintf (stderr, 180 fprintf (stderr, "Error searching file: %s\n",
187 "Error searching file: %s\n",
188 event->value.search.specifics.error.message); 181 event->value.search.specifics.error.message);
189 GNUNET_SCHEDULER_add_continuation (&abort_search_task, 182 GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
190 NULL,
191 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 183 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
192 break; 184 break;
193 case GNUNET_FS_STATUS_SEARCH_SUSPEND: 185 case GNUNET_FS_STATUS_SEARCH_SUSPEND:
@@ -226,8 +218,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
226 break; 218 break;
227 case GNUNET_FS_STATUS_SEARCH_STOPPED: 219 case GNUNET_FS_STATUS_SEARCH_STOPPED:
228 GNUNET_assert (search == event->value.search.sc); 220 GNUNET_assert (search == event->value.search.sc);
229 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 221 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
230 NULL,
231 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 222 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
232 search = NULL; 223 search = NULL;
233 break; 224 break;
@@ -244,12 +235,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
244{ 235{
245 p->cfg = GNUNET_CONFIGURATION_create (); 236 p->cfg = GNUNET_CONFIGURATION_create ();
246#if START_ARM 237#if START_ARM
247 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 238 p->arm_proc =
248 "gnunet-service-arm", 239 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
240 "gnunet-service-arm",
249#if VERBOSE 241#if VERBOSE
250 "-L", "DEBUG", 242 "-L", "DEBUG",
251#endif 243#endif
252 "-c", cfgname, NULL); 244 "-c", cfgname, NULL);
253#endif 245#endif
254 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 246 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
255} 247}
@@ -265,8 +257,7 @@ stop_arm (struct PeerContext *p)
265 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 257 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
266 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 258 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
267 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 259 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
269 "ARM process %u stopped\n",
270 GNUNET_OS_process_get_pid (p->arm_proc)); 261 GNUNET_OS_process_get_pid (p->arm_proc));
271 GNUNET_OS_process_close (p->arm_proc); 262 GNUNET_OS_process_close (p->arm_proc);
272 p->arm_proc = NULL; 263 p->arm_proc = NULL;
@@ -277,9 +268,8 @@ stop_arm (struct PeerContext *p)
277 268
278 269
279static void 270static void
280run (void *cls, 271run (void *cls, char *const *args, const char *cfgfile,
281 char *const *args, 272 const struct GNUNET_CONFIGURATION_Handle *c)
282 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
283{ 273{
284 const char *keywords[] = { 274 const char *keywords[] = {
285 "down_foo", 275 "down_foo",
@@ -294,10 +284,7 @@ run (void *cls,
294 284
295 cfg = c; 285 cfg = c;
296 setup_peer (&p1, "test_fs_search_data.conf"); 286 setup_peer (&p1, "test_fs_search_data.conf");
297 fs = GNUNET_FS_start (cfg, 287 fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL,
298 "test-fs-search-persistence",
299 &progress_cb,
300 NULL,
301 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 288 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
302 GNUNET_assert (NULL != fs); 289 GNUNET_assert (NULL != fs);
303 buf = GNUNET_malloc (FILESIZE); 290 buf = GNUNET_malloc (FILESIZE);
@@ -309,19 +296,16 @@ run (void *cls,
309 bo.anonymity_level = 1; 296 bo.anonymity_level = 1;
310 bo.replication_level = 0; 297 bo.replication_level = 0;
311 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 298 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
312 fi = GNUNET_FS_file_information_create_from_data (fs, 299 fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context",
313 "publish-context", 300 FILESIZE, buf, kuri, meta,
314 FILESIZE, 301 GNUNET_NO, &bo);
315 buf,
316 kuri, meta, GNUNET_NO, &bo);
317 GNUNET_FS_uri_destroy (kuri); 302 GNUNET_FS_uri_destroy (kuri);
318 GNUNET_CONTAINER_meta_data_destroy (meta); 303 GNUNET_CONTAINER_meta_data_destroy (meta);
319 GNUNET_assert (NULL != fi); 304 GNUNET_assert (NULL != fi);
320 start = GNUNET_TIME_absolute_get (); 305 start = GNUNET_TIME_absolute_get ();
321 publish = GNUNET_FS_publish_start (fs, 306 publish =
322 fi, 307 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
323 NULL, NULL, NULL, 308 GNUNET_FS_PUBLISH_OPTION_NONE);
324 GNUNET_FS_PUBLISH_OPTION_NONE);
325 GNUNET_assert (publish != NULL); 309 GNUNET_assert (publish != NULL);
326} 310}
327 311
@@ -350,9 +334,9 @@ main (int argc, char *argv[])
350 "WARNING", 334 "WARNING",
351#endif 335#endif
352 NULL); 336 NULL);
353 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 337 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
354 argvx, "test-fs-search-persistence", 338 "test-fs-search-persistence", "nohelp", options, &run,
355 "nohelp", options, &run, NULL); 339 NULL);
356 stop_arm (&p1); 340 stop_arm (&p1);
357 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); 341 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/");
358 return 0; 342 return 0;
diff --git a/src/fs/test_fs_search_ranking.c b/src/fs/test_fs_search_ranking.c
index b19ff97bf..53522c6fe 100644
--- a/src/fs/test_fs_search_ranking.c
+++ b/src/fs/test_fs_search_ranking.c
@@ -38,8 +38,7 @@ makeName (unsigned int i)
38 char *fn; 38 char *fn;
39 39
40 fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14); 40 fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14);
41 GNUNET_snprintf (fn, 41 GNUNET_snprintf (fn, strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14,
42 strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14,
43 "/tmp/gnunet-fsui-searchranktest/FSUITEST%u", i); 42 "/tmp/gnunet-fsui-searchranktest/FSUITEST%u", i);
44 GNUNET_disk_directory_create_for_file (NULL, fn); 43 GNUNET_disk_directory_create_for_file (NULL, fn);
45 return fn; 44 return fn;
@@ -159,22 +158,21 @@ main (int argc, char *argv[])
159 GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */ 158 GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */
160 /* ACTUAL TEST CODE */ 159 /* ACTUAL TEST CODE */
161#endif 160#endif
162 ctx = GNUNET_FSUI_start (NULL, 161 ctx =
163 cfg, "fsuisearchranktest", 32, GNUNET_YES, 162 GNUNET_FSUI_start (NULL, cfg, "fsuisearchranktest", 32, GNUNET_YES,
164 &eventCallback, NULL); 163 &eventCallback, NULL);
165 CHECK (ctx != NULL); 164 CHECK (ctx != NULL);
166 /* upload */ 165 /* upload */
167 fn = makeName (42); 166 fn = makeName (42);
168 GNUNET_disk_file_write (NULL, 167 GNUNET_disk_file_write (NULL, fn, "foo bar test!", strlen ("foo bar test!"),
169 fn, "foo bar test!", strlen ("foo bar test!"), "600"); 168 "600");
170 meta = GNUNET_meta_data_create (); 169 meta = GNUNET_meta_data_create ();
171 kuri = 170 kuri =
172 GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, 171 GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2,
173 (const char **) keywords); 172 (const char **) keywords);
174 waitForEvent = GNUNET_FSUI_upload_completed; 173 waitForEvent = GNUNET_FSUI_upload_completed;
175 upload = 174 upload =
176 GNUNET_FSUI_upload_start (ctx, 175 GNUNET_FSUI_upload_start (ctx, fn,
177 fn,
178 (GNUNET_FSUI_DirectoryScanCallback) & 176 (GNUNET_FSUI_DirectoryScanCallback) &
179 GNUNET_disk_directory_scan, NULL, 0, 0, 177 GNUNET_disk_directory_scan, NULL, 0, 0,
180 GNUNET_YES, GNUNET_NO, GNUNET_NO, 178 GNUNET_YES, GNUNET_NO, GNUNET_NO,
@@ -191,8 +189,8 @@ main (int argc, char *argv[])
191 prog++; 189 prog++;
192 if (prog == 10000) 190 if (prog == 10000)
193 { 191 {
194 fprintf (stderr, 192 fprintf (stderr, "Upload failed to complete -- last event: %u\n",
195 "Upload failed to complete -- last event: %u\n", lastEvent); 193 lastEvent);
196 } 194 }
197 CHECK (prog < 10000); 195 CHECK (prog < 10000);
198 GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); 196 GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
@@ -211,9 +209,8 @@ main (int argc, char *argv[])
211 CHECK (NULL != search); 209 CHECK (NULL != search);
212 GNUNET_FSUI_search_pause (search); 210 GNUNET_FSUI_search_pause (search);
213 GNUNET_FSUI_search_restart (search); 211 GNUNET_FSUI_search_restart (search);
214 while ((uri == NULL) && 212 while ((uri == NULL) && (availability < 3) && (rank != 2) &&
215 (availability < 3) && 213 (GNUNET_shutdown_test () != GNUNET_YES))
216 (rank != 2) && (GNUNET_shutdown_test () != GNUNET_YES))
217 { 214 {
218 prog++; 215 prog++;
219 CHECK (prog < 10000); 216 CHECK (prog < 10000);
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c
index e38a4b965..c65ad2fc1 100644
--- a/src/fs/test_fs_start_stop.c
+++ b/src/fs/test_fs_start_stop.c
@@ -56,12 +56,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
56{ 56{
57 p->cfg = GNUNET_CONFIGURATION_create (); 57 p->cfg = GNUNET_CONFIGURATION_create ();
58#if START_ARM 58#if START_ARM
59 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 59 p->arm_proc =
60 "gnunet-service-arm", 60 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
61 "gnunet-service-arm",
61#if VERBOSE 62#if VERBOSE
62 "-L", "DEBUG", 63 "-L", "DEBUG",
63#endif 64#endif
64 "-c", cfgname, NULL); 65 "-c", cfgname, NULL);
65#endif 66#endif
66 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 67 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
67} 68}
@@ -77,8 +78,7 @@ stop_arm (struct PeerContext *p)
77 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 78 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
78 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 79 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
79 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 80 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
81 "ARM process %u stopped\n",
82 GNUNET_OS_process_get_pid (p->arm_proc)); 82 GNUNET_OS_process_get_pid (p->arm_proc));
83 GNUNET_OS_process_close (p->arm_proc); 83 GNUNET_OS_process_close (p->arm_proc);
84 p->arm_proc = NULL; 84 p->arm_proc = NULL;
@@ -89,17 +89,14 @@ stop_arm (struct PeerContext *p)
89 89
90 90
91static void 91static void
92run (void *cls, 92run (void *cls, char *const *args, const char *cfgfile,
93 char *const *args, 93 const struct GNUNET_CONFIGURATION_Handle *cfg)
94 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
95{ 94{
96 struct GNUNET_FS_Handle *fs; 95 struct GNUNET_FS_Handle *fs;
97 96
98 setup_peer (&p1, "test_fs_data.conf"); 97 setup_peer (&p1, "test_fs_data.conf");
99 fs = GNUNET_FS_start (cfg, 98 fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL,
100 "test-fs-start-stop", 99 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
101 &progress_cb,
102 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
103 GNUNET_assert (NULL != fs); 100 GNUNET_assert (NULL != fs);
104 GNUNET_FS_stop (fs); 101 GNUNET_FS_stop (fs);
105} 102}
@@ -128,9 +125,8 @@ main (int argc, char *argv[])
128 "WARNING", 125 "WARNING",
129#endif 126#endif
130 NULL); 127 NULL);
131 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 128 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
132 argvx, "test-fs-start-stop", 129 "test-fs-start-stop", "nohelp", options, &run, NULL);
133 "nohelp", options, &run, NULL);
134 stop_arm (&p1); 130 stop_arm (&p1);
135 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/"); 131 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/");
136 return 0; 132 return 0;
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c
index 9aa7b2ee3..458d4606b 100644
--- a/src/fs/test_fs_test_lib.c
+++ b/src/fs/test_fs_test_lib.c
@@ -56,8 +56,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
56 } 56 }
57 else 57 else
58 { 58 {
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
60 "Finished download, shutting down\n",
61 (unsigned long long) FILESIZE); 60 (unsigned long long) FILESIZE);
62 } 61 }
63 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); 62 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons);
@@ -74,10 +73,10 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
74 ret = 1; 73 ret = 1;
75 return; 74 return;
76 } 75 }
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 76 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
78 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 77 (unsigned long long) FILESIZE);
79 GNUNET_FS_TEST_download (daemons[0], 78 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
80 TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); 79 NULL);
81} 80}
82 81
83 82
@@ -91,11 +90,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
91 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 90 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
92 return; 91 return;
93 } 92 }
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 93 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
95 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 94 (unsigned long long) FILESIZE);
96 GNUNET_FS_TEST_publish (daemons[0], 95 GNUNET_FS_TEST_publish (daemons[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED,
97 TIMEOUT,
98 1, GNUNET_NO, FILESIZE, SEED,
99 VERBOSE, &do_download, NULL); 96 VERBOSE, &do_download, NULL);
100} 97}
101 98
@@ -112,19 +109,17 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
112 } 109 }
113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
114 "Daemons started, will now try to connect them\n"); 111 "Daemons started, will now try to connect them\n");
115 GNUNET_FS_TEST_daemons_connect (daemons[0], 112 GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish,
116 daemons[1], TIMEOUT, &do_publish, NULL); 113 NULL);
117} 114}
118 115
119 116
120static void 117static void
121run (void *cls, 118run (void *cls, char *const *args, const char *cfgfile,
122 char *const *args, 119 const struct GNUNET_CONFIGURATION_Handle *cfg)
123 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
124{ 120{
125 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 121 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS,
126 TIMEOUT, 122 daemons, &do_connect, NULL);
127 NUM_DAEMONS, daemons, &do_connect, NULL);
128} 123}
129 124
130 125
@@ -152,8 +147,8 @@ main (int argc, char *argv[])
152 "WARNING", 147 "WARNING",
153#endif 148#endif
154 NULL); 149 NULL);
155 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 150 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
156 argvx, "test-fs-test-lib", "nohelp", options, &run, NULL); 151 "test-fs-test-lib", "nohelp", options, &run, NULL);
157 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 152 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
158 return ret; 153 return ret;
159} 154}
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 70a9e0bcf..177b687ca 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -100,16 +100,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
100 (unsigned long long) event->value.publish.completed, 100 (unsigned long long) event->value.publish.completed,
101 (unsigned long long) event->value.publish.size, 101 (unsigned long long) event->value.publish.size,
102 event->value.publish.specifics.progress.depth, 102 event->value.publish.specifics.progress.depth,
103 (unsigned long long) event->value.publish.specifics. 103 (unsigned long long) event->value.publish.specifics.progress.
104 progress.offset); 104 offset);
105#endif 105#endif
106 break; 106 break;
107 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 107 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
108 printf ("Publishing complete, %llu kbps.\n", 108 printf ("Publishing complete, %llu kbps.\n",
109 (unsigned long long) (FILESIZE * 1000 / 109 (unsigned long long) (FILESIZE * 1000 /
110 (1 + 110 (1 +
111 GNUNET_TIME_absolute_get_duration 111 GNUNET_TIME_absolute_get_duration (start).
112 (start).rel_value) / 1024)); 112 rel_value) / 1024));
113 start = GNUNET_TIME_absolute_get (); 113 start = GNUNET_TIME_absolute_get ();
114 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); 114 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
115 GNUNET_assert (unindex != NULL); 115 GNUNET_assert (unindex != NULL);
@@ -118,8 +118,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
118 printf ("Unindex complete, %llu kbps.\n", 118 printf ("Unindex complete, %llu kbps.\n",
119 (unsigned long long) (FILESIZE * 1000 / 119 (unsigned long long) (FILESIZE * 1000 /
120 (1 + 120 (1 +
121 GNUNET_TIME_absolute_get_duration 121 GNUNET_TIME_absolute_get_duration (start).
122 (start).rel_value) / 1024)); 122 rel_value) / 1024));
123 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, 123 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
124 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 124 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
125 break; 125 break;
@@ -130,25 +130,21 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
130 (unsigned long long) event->value.unindex.completed, 130 (unsigned long long) event->value.unindex.completed,
131 (unsigned long long) event->value.unindex.size, 131 (unsigned long long) event->value.unindex.size,
132 event->value.unindex.specifics.progress.depth, 132 event->value.unindex.specifics.progress.depth,
133 (unsigned long long) event->value.unindex.specifics. 133 (unsigned long long) event->value.unindex.specifics.progress.
134 progress.offset); 134 offset);
135#endif 135#endif
136 break; 136 break;
137 case GNUNET_FS_STATUS_PUBLISH_ERROR: 137 case GNUNET_FS_STATUS_PUBLISH_ERROR:
138 fprintf (stderr, 138 fprintf (stderr, "Error publishing file: %s\n",
139 "Error publishing file: %s\n",
140 event->value.publish.specifics.error.message); 139 event->value.publish.specifics.error.message);
141 GNUNET_break (0); 140 GNUNET_break (0);
142 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 141 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
143 NULL,
144 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 142 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
145 break; 143 break;
146 case GNUNET_FS_STATUS_UNINDEX_ERROR: 144 case GNUNET_FS_STATUS_UNINDEX_ERROR:
147 fprintf (stderr, 145 fprintf (stderr, "Error unindexing file: %s\n",
148 "Error unindexing file: %s\n",
149 event->value.unindex.specifics.error.message); 146 event->value.unindex.specifics.error.message);
150 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, 147 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
151 NULL,
152 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 148 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
153 break; 149 break;
154 case GNUNET_FS_STATUS_PUBLISH_START: 150 case GNUNET_FS_STATUS_PUBLISH_START:
@@ -174,8 +170,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
174 break; 170 break;
175 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 171 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
176 GNUNET_assert (unindex == event->value.unindex.uc); 172 GNUNET_assert (unindex == event->value.unindex.uc);
177 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 173 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
178 NULL,
179 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 174 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
180 break; 175 break;
181 default: 176 default:
@@ -191,12 +186,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
191{ 186{
192 p->cfg = GNUNET_CONFIGURATION_create (); 187 p->cfg = GNUNET_CONFIGURATION_create ();
193#if START_ARM 188#if START_ARM
194 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 189 p->arm_proc =
195 "gnunet-service-arm", 190 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
191 "gnunet-service-arm",
196#if VERBOSE 192#if VERBOSE
197 "-L", "DEBUG", 193 "-L", "DEBUG",
198#endif 194#endif
199 "-c", cfgname, NULL); 195 "-c", cfgname, NULL);
200#endif 196#endif
201 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 197 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
202} 198}
@@ -212,8 +208,7 @@ stop_arm (struct PeerContext *p)
212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 208 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
213 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 209 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
214 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 210 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
216 "ARM process %u stopped\n",
217 GNUNET_OS_process_get_pid (p->arm_proc)); 212 GNUNET_OS_process_get_pid (p->arm_proc));
218 GNUNET_OS_process_close (p->arm_proc); 213 GNUNET_OS_process_close (p->arm_proc);
219 p->arm_proc = NULL; 214 p->arm_proc = NULL;
@@ -224,9 +219,8 @@ stop_arm (struct PeerContext *p)
224 219
225 220
226static void 221static void
227run (void *cls, 222run (void *cls, char *const *args, const char *cfgfile,
228 char *const *args, 223 const struct GNUNET_CONFIGURATION_Handle *cfg)
229 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
230{ 224{
231 const char *keywords[] = { 225 const char *keywords[] = {
232 "down_foo", 226 "down_foo",
@@ -241,18 +235,14 @@ run (void *cls,
241 235
242 setup_peer (&p1, "test_fs_unindex_data.conf"); 236 setup_peer (&p1, "test_fs_unindex_data.conf");
243 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 237 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
244 fs = GNUNET_FS_start (cfg, 238 fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL,
245 "test-fs-unindex", 239 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
246 &progress_cb,
247 NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
248 GNUNET_assert (NULL != fs); 240 GNUNET_assert (NULL != fs);
249 buf = GNUNET_malloc (FILESIZE); 241 buf = GNUNET_malloc (FILESIZE);
250 for (i = 0; i < FILESIZE; i++) 242 for (i = 0; i < FILESIZE; i++)
251 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 243 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
252 GNUNET_assert (FILESIZE == 244 GNUNET_assert (FILESIZE ==
253 GNUNET_DISK_fn_write (fn, 245 GNUNET_DISK_fn_write (fn, buf, FILESIZE,
254 buf,
255 FILESIZE,
256 GNUNET_DISK_PERM_USER_READ | 246 GNUNET_DISK_PERM_USER_READ |
257 GNUNET_DISK_PERM_USER_WRITE)); 247 GNUNET_DISK_PERM_USER_WRITE));
258 GNUNET_free (buf); 248 GNUNET_free (buf);
@@ -262,19 +252,16 @@ run (void *cls,
262 bo.anonymity_level = 1; 252 bo.anonymity_level = 1;
263 bo.replication_level = 0; 253 bo.replication_level = 0;
264 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 254 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
265 fi = GNUNET_FS_file_information_create_from_file (fs, 255 fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn,
266 "publish-context", 256 kuri, meta, GNUNET_YES,
267 fn, 257 &bo);
268 kuri,
269 meta, GNUNET_YES, &bo);
270 GNUNET_FS_uri_destroy (kuri); 258 GNUNET_FS_uri_destroy (kuri);
271 GNUNET_CONTAINER_meta_data_destroy (meta); 259 GNUNET_CONTAINER_meta_data_destroy (meta);
272 GNUNET_assert (NULL != fi); 260 GNUNET_assert (NULL != fi);
273 start = GNUNET_TIME_absolute_get (); 261 start = GNUNET_TIME_absolute_get ();
274 publish = GNUNET_FS_publish_start (fs, 262 publish =
275 fi, 263 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
276 NULL, NULL, NULL, 264 GNUNET_FS_PUBLISH_OPTION_NONE);
277 GNUNET_FS_PUBLISH_OPTION_NONE);
278 GNUNET_assert (publish != NULL); 265 GNUNET_assert (publish != NULL);
279} 266}
280 267
@@ -302,8 +289,8 @@ main (int argc, char *argv[])
302 "WARNING", 289 "WARNING",
303#endif 290#endif
304 NULL); 291 NULL);
305 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 292 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
306 argvx, "test-fs-unindex", "nohelp", options, &run, NULL); 293 "test-fs-unindex", "nohelp", options, &run, NULL);
307 stop_arm (&p1); 294 stop_arm (&p1);
308 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); 295 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/");
309 if (NULL != fn) 296 if (NULL != fn)
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index 191dec57d..4fcd1445f 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -102,10 +102,7 @@ static void
102restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 102restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
103{ 103{
104 GNUNET_FS_stop (fs); 104 GNUNET_FS_stop (fs);
105 fs = GNUNET_FS_start (cfg, 105 fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL,
106 "test-fs-unindex-persistence",
107 &progress_cb,
108 NULL,
109 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 106 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
110} 107}
111 108
@@ -144,16 +141,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
144 (unsigned long long) event->value.publish.completed, 141 (unsigned long long) event->value.publish.completed,
145 (unsigned long long) event->value.publish.size, 142 (unsigned long long) event->value.publish.size,
146 event->value.publish.specifics.progress.depth, 143 event->value.publish.specifics.progress.depth,
147 (unsigned long long) event->value.publish.specifics. 144 (unsigned long long) event->value.publish.specifics.progress.
148 progress.offset); 145 offset);
149#endif 146#endif
150 break; 147 break;
151 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 148 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
152 printf ("Publishing complete, %llu kbps.\n", 149 printf ("Publishing complete, %llu kbps.\n",
153 (unsigned long long) (FILESIZE * 1000 / 150 (unsigned long long) (FILESIZE * 1000 /
154 (1 + 151 (1 +
155 GNUNET_TIME_absolute_get_duration 152 GNUNET_TIME_absolute_get_duration (start).
156 (start).rel_value) / 1024)); 153 rel_value) / 1024));
157 start = GNUNET_TIME_absolute_get (); 154 start = GNUNET_TIME_absolute_get ();
158 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); 155 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
159 GNUNET_assert (unindex != NULL); 156 GNUNET_assert (unindex != NULL);
@@ -162,8 +159,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
162 printf ("Unindex complete, %llu kbps.\n", 159 printf ("Unindex complete, %llu kbps.\n",
163 (unsigned long long) (FILESIZE * 1000 / 160 (unsigned long long) (FILESIZE * 1000 /
164 (1 + 161 (1 +
165 GNUNET_TIME_absolute_get_duration 162 GNUNET_TIME_absolute_get_duration (start).
166 (start).rel_value) / 1024)); 163 rel_value) / 1024));
167 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, 164 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
168 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 165 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
169 break; 166 break;
@@ -175,8 +172,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
175 (unsigned long long) event->value.unindex.completed, 172 (unsigned long long) event->value.unindex.completed,
176 (unsigned long long) event->value.unindex.size, 173 (unsigned long long) event->value.unindex.size,
177 event->value.unindex.specifics.progress.depth, 174 event->value.unindex.specifics.progress.depth,
178 (unsigned long long) event->value.unindex.specifics. 175 (unsigned long long) event->value.unindex.specifics.progress.
179 progress.offset); 176 offset);
180#endif 177#endif
181 break; 178 break;
182 case GNUNET_FS_STATUS_PUBLISH_SUSPEND: 179 case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
@@ -199,20 +196,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
199 unindex = event->value.unindex.uc; 196 unindex = event->value.unindex.uc;
200 return "unindex"; 197 return "unindex";
201 case GNUNET_FS_STATUS_PUBLISH_ERROR: 198 case GNUNET_FS_STATUS_PUBLISH_ERROR:
202 fprintf (stderr, 199 fprintf (stderr, "Error publishing file: %s\n",
203 "Error publishing file: %s\n",
204 event->value.publish.specifics.error.message); 200 event->value.publish.specifics.error.message);
205 GNUNET_break (0); 201 GNUNET_break (0);
206 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 202 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
207 NULL,
208 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 203 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
209 break; 204 break;
210 case GNUNET_FS_STATUS_UNINDEX_ERROR: 205 case GNUNET_FS_STATUS_UNINDEX_ERROR:
211 fprintf (stderr, 206 fprintf (stderr, "Error unindexing file: %s\n",
212 "Error unindexing file: %s\n",
213 event->value.unindex.specifics.error.message); 207 event->value.unindex.specifics.error.message);
214 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, 208 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
215 NULL,
216 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 209 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
217 break; 210 break;
218 case GNUNET_FS_STATUS_PUBLISH_START: 211 case GNUNET_FS_STATUS_PUBLISH_START:
@@ -239,8 +232,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
239 break; 232 break;
240 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 233 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
241 GNUNET_assert (unindex == event->value.unindex.uc); 234 GNUNET_assert (unindex == event->value.unindex.uc);
242 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 235 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
243 NULL,
244 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 236 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
245 break; 237 break;
246 default: 238 default:
@@ -256,12 +248,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
256{ 248{
257 p->cfg = GNUNET_CONFIGURATION_create (); 249 p->cfg = GNUNET_CONFIGURATION_create ();
258#if START_ARM 250#if START_ARM
259 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 251 p->arm_proc =
260 "gnunet-service-arm", 252 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
253 "gnunet-service-arm",
261#if VERBOSE 254#if VERBOSE
262 "-L", "DEBUG", 255 "-L", "DEBUG",
263#endif 256#endif
264 "-c", cfgname, NULL); 257 "-c", cfgname, NULL);
265#endif 258#endif
266 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 259 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
267} 260}
@@ -277,8 +270,7 @@ stop_arm (struct PeerContext *p)
277 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
278 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 271 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
279 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
281 "ARM process %u stopped\n",
282 GNUNET_OS_process_get_pid (p->arm_proc)); 274 GNUNET_OS_process_get_pid (p->arm_proc));
283 GNUNET_OS_process_close (p->arm_proc); 275 GNUNET_OS_process_close (p->arm_proc);
284 p->arm_proc = NULL; 276 p->arm_proc = NULL;
@@ -289,9 +281,8 @@ stop_arm (struct PeerContext *p)
289 281
290 282
291static void 283static void
292run (void *cls, 284run (void *cls, char *const *args, const char *cfgfile,
293 char *const *args, 285 const struct GNUNET_CONFIGURATION_Handle *c)
294 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
295{ 286{
296 const char *keywords[] = { 287 const char *keywords[] = {
297 "down_foo", 288 "down_foo",
@@ -307,19 +298,14 @@ run (void *cls,
307 cfg = c; 298 cfg = c;
308 setup_peer (&p1, "test_fs_unindex_data.conf"); 299 setup_peer (&p1, "test_fs_unindex_data.conf");
309 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 300 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
310 fs = GNUNET_FS_start (cfg, 301 fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL,
311 "test-fs-unindex-persistence",
312 &progress_cb,
313 NULL,
314 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 302 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
315 GNUNET_assert (NULL != fs); 303 GNUNET_assert (NULL != fs);
316 buf = GNUNET_malloc (FILESIZE); 304 buf = GNUNET_malloc (FILESIZE);
317 for (i = 0; i < FILESIZE; i++) 305 for (i = 0; i < FILESIZE; i++)
318 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 306 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
319 GNUNET_assert (FILESIZE == 307 GNUNET_assert (FILESIZE ==
320 GNUNET_DISK_fn_write (fn, 308 GNUNET_DISK_fn_write (fn, buf, FILESIZE,
321 buf,
322 FILESIZE,
323 GNUNET_DISK_PERM_USER_READ | 309 GNUNET_DISK_PERM_USER_READ |
324 GNUNET_DISK_PERM_USER_WRITE)); 310 GNUNET_DISK_PERM_USER_WRITE));
325 GNUNET_free (buf); 311 GNUNET_free (buf);
@@ -329,19 +315,16 @@ run (void *cls,
329 bo.anonymity_level = 1; 315 bo.anonymity_level = 1;
330 bo.replication_level = 0; 316 bo.replication_level = 0;
331 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 317 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
332 fi = GNUNET_FS_file_information_create_from_file (fs, 318 fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn,
333 "publish-context", 319 kuri, meta, GNUNET_YES,
334 fn, 320 &bo);
335 kuri,
336 meta, GNUNET_YES, &bo);
337 GNUNET_FS_uri_destroy (kuri); 321 GNUNET_FS_uri_destroy (kuri);
338 GNUNET_CONTAINER_meta_data_destroy (meta); 322 GNUNET_CONTAINER_meta_data_destroy (meta);
339 GNUNET_assert (NULL != fi); 323 GNUNET_assert (NULL != fi);
340 start = GNUNET_TIME_absolute_get (); 324 start = GNUNET_TIME_absolute_get ();
341 publish = GNUNET_FS_publish_start (fs, 325 publish =
342 fi, 326 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
343 NULL, NULL, NULL, 327 GNUNET_FS_PUBLISH_OPTION_NONE);
344 GNUNET_FS_PUBLISH_OPTION_NONE);
345 GNUNET_assert (publish != NULL); 328 GNUNET_assert (publish != NULL);
346} 329}
347 330
@@ -369,8 +352,8 @@ main (int argc, char *argv[])
369 "WARNING", 352 "WARNING",
370#endif 353#endif
371 NULL); 354 NULL);
372 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 355 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
373 argvx, "test-fs-unindex", "nohelp", options, &run, NULL); 356 "test-fs-unindex", "nohelp", options, &run, NULL);
374 stop_arm (&p1); 357 stop_arm (&p1);
375 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); 358 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/");
376 if (NULL != fn) 359 if (NULL != fn)
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index e8f6ed70f..d226147f9 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -209,8 +209,9 @@ testNamespace (int i)
209 } 209 }
210 210
211 uri = GNUNET_FS_uri_to_string (ret); 211 uri = GNUNET_FS_uri_to_string (ret);
212 if (0 != strcmp (uri, 212 if (0 !=
213 "gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test")) 213 strcmp (uri,
214 "gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test"))
214 { 215 {
215 GNUNET_FS_uri_destroy (ret); 216 GNUNET_FS_uri_destroy (ret);
216 GNUNET_free (uri); 217 GNUNET_free (uri);
@@ -284,8 +285,9 @@ testFile (int i)
284 } 285 }
285 286
286 uri = GNUNET_FS_uri_to_string (ret); 287 uri = GNUNET_FS_uri_to_string (ret);
287 if (0 != strcmp (uri, 288 if (0 !=
288 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42")) 289 strcmp (uri,
290 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
289 { 291 {
290 GNUNET_free (uri); 292 GNUNET_free (uri);
291 GNUNET_FS_uri_destroy (ret); 293 GNUNET_FS_uri_destroy (ret);
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 9a209521f..a5570e1d4 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -69,8 +69,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
69 1000LL / del.rel_value); 69 1000LL / del.rel_value);
70 fprintf (stdout, "Download speed was %s/s\n", fancy); 70 fprintf (stdout, "Download speed was %s/s\n", fancy);
71 GNUNET_free (fancy); 71 GNUNET_free (fancy);
72 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 72 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
73 "Finished download, shutting down\n",
74 (unsigned long long) FILESIZE); 73 (unsigned long long) FILESIZE);
75 } 74 }
76 else 75 else
@@ -90,17 +89,17 @@ do_download (void *cls, const char *emsg)
90 if (emsg != NULL) 89 if (emsg != NULL)
91 { 90 {
92 GNUNET_FS_TEST_daemons_stop (2, daemons); 91 GNUNET_FS_TEST_daemons_stop (2, daemons);
93 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n",
94 "Failed to stop source daemon: %s\n", emsg); 93 emsg);
95 GNUNET_FS_uri_destroy (uri); 94 GNUNET_FS_uri_destroy (uri);
96 ok = 1; 95 ok = 1;
97 return; 96 return;
98 } 97 }
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
100 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 99 (unsigned long long) FILESIZE);
101 start_time = GNUNET_TIME_absolute_get (); 100 start_time = GNUNET_TIME_absolute_get ();
102 GNUNET_FS_TEST_download (daemons[0], 101 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
103 TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); 102 NULL);
104 GNUNET_FS_uri_destroy (uri); 103 GNUNET_FS_uri_destroy (uri);
105} 104}
106 105
@@ -147,11 +146,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147 ok = 1; 146 ok = 1;
148 return; 147 return;
149 } 148 }
150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
151 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 150 (unsigned long long) FILESIZE);
152 GNUNET_FS_TEST_publish (daemons[1], 151 GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED,
153 TIMEOUT,
154 1, GNUNET_NO, FILESIZE, SEED,
155 VERBOSE, &do_wait, NULL); 152 VERBOSE, &do_wait, NULL);
156} 153}
157 154
@@ -168,15 +165,14 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
168 } 165 }
169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
170 "Daemons started, will now try to connect them\n"); 167 "Daemons started, will now try to connect them\n");
171 GNUNET_FS_TEST_daemons_connect (daemons[0], 168 GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish,
172 daemons[1], TIMEOUT, &do_publish, NULL); 169 NULL);
173} 170}
174 171
175 172
176static void 173static void
177run (void *cls, 174run (void *cls, char *const *args, const char *cfgfile,
178 char *const *args, 175 const struct GNUNET_CONFIGURATION_Handle *cfg)
179 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
180{ 176{
181 GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf", 177 GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf",
182 TIMEOUT, 2, daemons, &do_connect, NULL); 178 TIMEOUT, 2, daemons, &do_connect, NULL);
@@ -207,9 +203,9 @@ main (int argc, char *argv[])
207 "WARNING", 203 "WARNING",
208#endif 204#endif
209 NULL); 205 NULL);
210 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 206 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
211 argvx, "test-gnunet-service-fs-migration", 207 "test-gnunet-service-fs-migration", "nohelp", options,
212 "nohelp", options, &run, NULL); 208 &run, NULL);
213 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/"); 209 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/");
214 return ok; 210 return ok;
215} 211}
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
index c48f98666..aece0e80a 100644
--- a/src/fs/test_gnunet_service_fs_p2p.c
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -65,8 +65,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
65 1000LL / del.rel_value); 65 1000LL / del.rel_value);
66 fprintf (stdout, "Download speed was %s/s\n", fancy); 66 fprintf (stdout, "Download speed was %s/s\n", fancy);
67 GNUNET_free (fancy); 67 GNUNET_free (fancy);
68 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 68 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
69 "Finished download, shutting down\n",
70 (unsigned long long) FILESIZE); 69 (unsigned long long) FILESIZE);
71 } 70 }
72 else 71 else
@@ -89,11 +88,11 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
89 ok = 1; 88 ok = 1;
90 return; 89 return;
91 } 90 }
92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
93 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 92 (unsigned long long) FILESIZE);
94 start_time = GNUNET_TIME_absolute_get (); 93 start_time = GNUNET_TIME_absolute_get ();
95 GNUNET_FS_TEST_download (daemons[0], 94 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
96 TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); 95 NULL);
97} 96}
98 97
99 98
@@ -108,11 +107,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108 ok = 1; 107 ok = 1;
109 return; 108 return;
110 } 109 }
111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
112 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 111 (unsigned long long) FILESIZE);
113 GNUNET_FS_TEST_publish (daemons[1], 112 GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED,
114 TIMEOUT,
115 1, GNUNET_NO, FILESIZE, SEED,
116 VERBOSE, &do_download, NULL); 113 VERBOSE, &do_download, NULL);
117} 114}
118 115
@@ -123,19 +120,17 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
123 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 120 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
125 "Daemons started, will now try to connect them\n"); 122 "Daemons started, will now try to connect them\n");
126 GNUNET_FS_TEST_daemons_connect (daemons[0], 123 GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish,
127 daemons[1], TIMEOUT, &do_publish, NULL); 124 NULL);
128} 125}
129 126
130 127
131static void 128static void
132run (void *cls, 129run (void *cls, char *const *args, const char *cfgfile,
133 char *const *args, 130 const struct GNUNET_CONFIGURATION_Handle *cfg)
134 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
135{ 131{
136 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 132 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS,
137 TIMEOUT, 133 daemons, &do_connect, NULL);
138 NUM_DAEMONS, daemons, &do_connect, NULL);
139} 134}
140 135
141 136
@@ -163,9 +158,9 @@ main (int argc, char *argv[])
163 "WARNING", 158 "WARNING",
164#endif 159#endif
165 NULL); 160 NULL);
166 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 161 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
167 argvx, "test-gnunet-service-fs-p2p", 162 "test-gnunet-service-fs-p2p", "nohelp", options, &run,
168 "nohelp", options, &run, NULL); 163 NULL);
169 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 164 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
170 return ok; 165 return ok;
171} 166}