diff options
Diffstat (limited to 'src/fs/fs.c')
-rw-r--r-- | src/fs/fs.c | 521 |
1 files changed, 216 insertions, 305 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 | */ |
150 | struct GNUNET_FS_QueueEntry * | 150 | struct GNUNET_FS_QueueEntry * |
151 | GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, | 151 | GNUNET_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 | */ |
201 | struct TopLevelActivity * | 200 | struct TopLevelActivity * |
202 | GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, | 201 | GNUNET_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 | */ |
263 | size_t | 262 | size_t |
264 | GNUNET_FS_data_reader_file_ (void *cls, | 263 | GNUNET_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 | */ |
349 | size_t | 345 | size_t |
350 | GNUNET_FS_data_reader_copy_ (void *cls, | 346 | GNUNET_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 | */ |
375 | static char * | 370 | static char * |
376 | get_serialization_file_name (struct GNUNET_FS_Handle *h, | 371 | get_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 | */ |
410 | static char * | 402 | static char * |
411 | get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, | 403 | get_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 | */ |
495 | static struct GNUNET_BIO_WriteHandle * | 482 | static struct GNUNET_BIO_WriteHandle * |
496 | get_write_handle_in_dir (struct GNUNET_FS_Handle *h, | 483 | get_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 | */ |
518 | void | 505 | void |
519 | GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, | 506 | GNUNET_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 | */ |
547 | static void | 534 | static void |
548 | remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, | 535 | remove_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 | */ |
575 | void | 562 | void |
576 | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, | 563 | GNUNET_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 | */ |
672 | static struct GNUNET_FS_FileInformation * | 659 | static struct GNUNET_FS_FileInformation * |
673 | deserialize_fi_node (struct GNUNET_FS_Handle *h, | 660 | deserialize_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 | */ |
1281 | static int | 1243 | static int |
1282 | fip_signal_resume (void *cls, | 1244 | fip_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 | */ |
2098 | static void | 2020 | static void deserialize_download (struct GNUNET_FS_Handle *h, |
2099 | deserialize_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 | */ |
2777 | static void | 2690 | static void |
2778 | deserialization_master (const char *master_path, | 2691 | deserialization_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 | */ |
2804 | struct GNUNET_FS_Handle * | 2716 | struct GNUNET_FS_Handle * |
2805 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 2717 | GNUNET_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; |