diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-06 08:12:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-06 08:12:49 +0000 |
commit | 310f312557954662ffc32f74bbacdb63d76ede3d (patch) | |
tree | 495d108cc106401cd72346b406220d8bf7b11039 /src/fs/fs_api.c | |
parent | b535d8ad5ebfdd7d1c7c0eca620cd796486fc303 (diff) | |
download | gnunet-310f312557954662ffc32f74bbacdb63d76ede3d.tar.gz gnunet-310f312557954662ffc32f74bbacdb63d76ede3d.zip |
-doxygen, indentation
Diffstat (limited to 'src/fs/fs_api.c')
-rw-r--r-- | src/fs/fs_api.c | 219 |
1 files changed, 134 insertions, 85 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 43a1235f6..3cd2fa470 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -103,11 +103,12 @@ stop_job (struct GNUNET_FS_QueueEntry *qe) | |||
103 | * Process the jobs in the job queue, possibly starting some | 103 | * Process the jobs in the job queue, possibly starting some |
104 | * and stopping others. | 104 | * and stopping others. |
105 | * | 105 | * |
106 | * @param cls the 'struct GNUNET_FS_Handle' | 106 | * @param cls the `struct GNUNET_FS_Handle *` |
107 | * @param tc scheduler context | 107 | * @param tc scheduler context |
108 | */ | 108 | */ |
109 | static void | 109 | static void |
110 | process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 110 | process_job_queue (void *cls, |
111 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
111 | { | 112 | { |
112 | struct GNUNET_FS_Handle *h = cls; | 113 | struct GNUNET_FS_Handle *h = cls; |
113 | struct GNUNET_FS_QueueEntry *qe; | 114 | struct GNUNET_FS_QueueEntry *qe; |
@@ -307,8 +308,10 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
307 | * @return queue handle | 308 | * @return queue handle |
308 | */ | 309 | */ |
309 | struct GNUNET_FS_QueueEntry * | 310 | struct GNUNET_FS_QueueEntry * |
310 | GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start, | 311 | GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, |
311 | GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks, | 312 | GNUNET_FS_QueueStart start, |
313 | GNUNET_FS_QueueStop stop, void *cls, | ||
314 | unsigned int blocks, | ||
312 | enum GNUNET_FS_QueuePriority priority) | 315 | enum GNUNET_FS_QueuePriority priority) |
313 | { | 316 | { |
314 | struct GNUNET_FS_QueueEntry *qe; | 317 | struct GNUNET_FS_QueueEntry *qe; |
@@ -362,11 +365,12 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe) | |||
362 | * | 365 | * |
363 | * @param h global fs handle | 366 | * @param h global fs handle |
364 | * @param ssf suspend signal function to use | 367 | * @param ssf suspend signal function to use |
365 | * @param ssf_cls closure for ssf | 368 | * @param ssf_cls closure for @a ssf |
366 | * @return fresh top-level activity handle | 369 | * @return fresh top-level activity handle |
367 | */ | 370 | */ |
368 | struct TopLevelActivity * | 371 | struct TopLevelActivity * |
369 | GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, | 372 | GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, |
373 | SuspendSignalFunction ssf, | ||
370 | void *ssf_cls) | 374 | void *ssf_cls) |
371 | { | 375 | { |
372 | struct TopLevelActivity *ret; | 376 | struct TopLevelActivity *ret; |
@@ -386,16 +390,16 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, | |||
386 | * @param top top level activity entry | 390 | * @param top top level activity entry |
387 | */ | 391 | */ |
388 | void | 392 | void |
389 | GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top) | 393 | GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, |
394 | struct TopLevelActivity *top) | ||
390 | { | 395 | { |
391 | GNUNET_CONTAINER_DLL_remove (h->top_head, h->top_tail, top); | 396 | GNUNET_CONTAINER_DLL_remove (h->top_head, h->top_tail, top); |
392 | GNUNET_free (top); | 397 | GNUNET_free (top); |
393 | } | 398 | } |
394 | 399 | ||
395 | 400 | ||
396 | |||
397 | /** | 401 | /** |
398 | * Closure for "data_reader_file". | 402 | * Closure for #data_reader_file(). |
399 | */ | 403 | */ |
400 | struct FileInfo | 404 | struct FileInfo |
401 | { | 405 | { |
@@ -414,25 +418,28 @@ struct FileInfo | |||
414 | /** | 418 | /** |
415 | * Function that provides data by reading from a file. | 419 | * Function that provides data by reading from a file. |
416 | * | 420 | * |
417 | * @param cls closure (points to the file information) | 421 | * @param cls closure with the `struct FileInfo *` |
418 | * @param offset offset to read from; it is possible | 422 | * @param offset offset to read from; it is possible |
419 | * that the caller might need to go backwards | 423 | * that the caller might need to go backwards |
420 | * a bit at times; set to UINT64_MAX to tell | 424 | * a bit at times; set to `UINT64_MAX` to tell |
421 | * the reader that we won't be reading for a while | 425 | * the reader that we won't be reading for a while |
422 | * (used to close the file descriptor but NOT fully | 426 | * (used to close the file descriptor but NOT fully |
423 | * clean up the reader's state); in this case, | 427 | * clean up the reader's state); in this case, |
424 | * a value of '0' for max should be ignored | 428 | * a value of '0' for @a max should be ignored |
425 | * @param max maximum number of bytes that should be | 429 | * @param max maximum number of bytes that should be |
426 | * copied to buf; readers are not allowed | 430 | * copied to @a buf; readers are not allowed |
427 | * to provide less data unless there is an error; | 431 | * to provide less data unless there is an error; |
428 | * a value of "0" will be used at the end to allow | 432 | * a value of "0" will be used at the end to allow |
429 | * the reader to clean up its internal state | 433 | * the reader to clean up its internal state |
430 | * @param buf where the reader should write the data | 434 | * @param buf where the reader should write the data |
431 | * @param emsg location for the reader to store an error message | 435 | * @param emsg location for the reader to store an error message |
432 | * @return number of bytes written, usually "max", 0 on error | 436 | * @return number of bytes written, usually @a max, 0 on error |
433 | */ | 437 | */ |
434 | size_t | 438 | size_t |
435 | GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, | 439 | GNUNET_FS_data_reader_file_ (void *cls, |
440 | uint64_t offset, | ||
441 | size_t max, | ||
442 | void *buf, | ||
436 | char **emsg) | 443 | char **emsg) |
437 | { | 444 | { |
438 | struct FileInfo *fi = cls; | 445 | struct FileInfo *fi = cls; |
@@ -458,11 +465,14 @@ GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, | |||
458 | if (NULL == fi->fd) | 465 | if (NULL == fi->fd) |
459 | { | 466 | { |
460 | fi->fd = | 467 | fi->fd = |
461 | GNUNET_DISK_file_open (fi->filename, GNUNET_DISK_OPEN_READ, | 468 | GNUNET_DISK_file_open (fi->filename, |
469 | GNUNET_DISK_OPEN_READ, | ||
462 | GNUNET_DISK_PERM_NONE); | 470 | GNUNET_DISK_PERM_NONE); |
463 | if (NULL == fi->fd) | 471 | if (NULL == fi->fd) |
464 | { | 472 | { |
465 | GNUNET_asprintf (emsg, _("Could not open file `%s': %s"), fi->filename, | 473 | GNUNET_asprintf (emsg, |
474 | _("Could not open file `%s': %s"), | ||
475 | fi->filename, | ||
466 | STRERROR (errno)); | 476 | STRERROR (errno)); |
467 | return 0; | 477 | return 0; |
468 | } | 478 | } |
@@ -471,13 +481,16 @@ GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, | |||
471 | GNUNET_DISK_file_seek (fi->fd, offset, GNUNET_DISK_SEEK_SET)) || | 481 | GNUNET_DISK_file_seek (fi->fd, offset, GNUNET_DISK_SEEK_SET)) || |
472 | (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))) ) | 482 | (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))) ) |
473 | { | 483 | { |
474 | GNUNET_asprintf (emsg, _("Could not read file `%s': %s"), fi->filename, | 484 | GNUNET_asprintf (emsg, |
485 | _("Could not read file `%s': %s"), | ||
486 | fi->filename, | ||
475 | STRERROR (errno)); | 487 | STRERROR (errno)); |
476 | return 0; | 488 | return 0; |
477 | } | 489 | } |
478 | if (ret != max) | 490 | if (ret != max) |
479 | { | 491 | { |
480 | GNUNET_asprintf (emsg, _("Short read reading from file `%s'!"), | 492 | GNUNET_asprintf (emsg, |
493 | _("Short read reading from file `%s'!"), | ||
481 | fi->filename); | 494 | fi->filename); |
482 | return 0; | 495 | return 0; |
483 | } | 496 | } |
@@ -486,7 +499,7 @@ GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, | |||
486 | 499 | ||
487 | 500 | ||
488 | /** | 501 | /** |
489 | * Create the closure for the 'GNUNET_FS_data_reader_file_' callback. | 502 | * Create the closure for the #GNUNET_FS_data_reader_file_() callback. |
490 | * | 503 | * |
491 | * @param filename file to read | 504 | * @param filename file to read |
492 | * @return closure to use, NULL on error | 505 | * @return closure to use, NULL on error |
@@ -513,22 +526,25 @@ GNUNET_FS_make_file_reader_context_ (const char *filename) | |||
513 | * @param cls closure (points to the buffer) | 526 | * @param cls closure (points to the buffer) |
514 | * @param offset offset to read from; it is possible | 527 | * @param offset offset to read from; it is possible |
515 | * that the caller might need to go backwards | 528 | * that the caller might need to go backwards |
516 | * a bit at times; set to UINT64_MAX to tell | 529 | * a bit at times; set to `UINT64_MAX` to tell |
517 | * the reader that we won't be reading for a while | 530 | * the reader that we won't be reading for a while |
518 | * (used to close the file descriptor but NOT fully | 531 | * (used to close the file descriptor but NOT fully |
519 | * clean up the reader's state); in this case, | 532 | * clean up the reader's state); in this case, |
520 | * a value of '0' for max should be ignored | 533 | * a value of '0' for @a max should be ignored |
521 | * @param max maximum number of bytes that should be | 534 | * @param max maximum number of bytes that should be |
522 | * copied to buf; readers are not allowed | 535 | * copied to @a buf; readers are not allowed |
523 | * to provide less data unless there is an error; | 536 | * to provide less data unless there is an error; |
524 | * a value of "0" will be used at the end to allow | 537 | * a value of "0" will be used at the end to allow |
525 | * the reader to clean up its internal state | 538 | * the reader to clean up its internal state |
526 | * @param buf where the reader should write the data | 539 | * @param buf where the reader should write the data |
527 | * @param emsg location for the reader to store an error message | 540 | * @param emsg location for the reader to store an error message |
528 | * @return number of bytes written, usually "max", 0 on error | 541 | * @return number of bytes written, usually @a max, 0 on error |
529 | */ | 542 | */ |
530 | size_t | 543 | size_t |
531 | GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, | 544 | GNUNET_FS_data_reader_copy_ (void *cls, |
545 | uint64_t offset, | ||
546 | size_t max, | ||
547 | void *buf, | ||
532 | char **emsg) | 548 | char **emsg) |
533 | { | 549 | { |
534 | char *data = cls; | 550 | char *data = cls; |
@@ -555,7 +571,8 @@ GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, | |||
555 | * @return NULL on error | 571 | * @return NULL on error |
556 | */ | 572 | */ |
557 | static char * | 573 | static char * |
558 | get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext, | 574 | get_serialization_file_name (struct GNUNET_FS_Handle *h, |
575 | const char *ext, | ||
559 | const char *ent) | 576 | const char *ent) |
560 | { | 577 | { |
561 | char *basename; | 578 | char *basename; |
@@ -587,8 +604,10 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext, | |||
587 | * @return NULL on error | 604 | * @return NULL on error |
588 | */ | 605 | */ |
589 | static char * | 606 | static char * |
590 | get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | 607 | get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, |
591 | const char *uni, const char *ent) | 608 | const char *ext, |
609 | const char *uni, | ||
610 | const char *ent) | ||
592 | { | 611 | { |
593 | char *basename; | 612 | char *basename; |
594 | char *ret; | 613 | char *ret; |
@@ -616,7 +635,9 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | |||
616 | * @return NULL on error | 635 | * @return NULL on error |
617 | */ | 636 | */ |
618 | static struct GNUNET_BIO_ReadHandle * | 637 | static struct GNUNET_BIO_ReadHandle * |
619 | get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | 638 | get_read_handle (struct GNUNET_FS_Handle *h, |
639 | const char *ext, | ||
640 | const char *ent) | ||
620 | { | 641 | { |
621 | char *fn; | 642 | char *fn; |
622 | struct GNUNET_BIO_ReadHandle *ret; | 643 | struct GNUNET_BIO_ReadHandle *ret; |
@@ -639,7 +660,9 @@ get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | |||
639 | * @return NULL on error | 660 | * @return NULL on error |
640 | */ | 661 | */ |
641 | static struct GNUNET_BIO_WriteHandle * | 662 | static struct GNUNET_BIO_WriteHandle * |
642 | get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | 663 | get_write_handle (struct GNUNET_FS_Handle *h, |
664 | const char *ext, | ||
665 | const char *ent) | ||
643 | { | 666 | { |
644 | char *fn; | 667 | char *fn; |
645 | struct GNUNET_BIO_WriteHandle *ret; | 668 | struct GNUNET_BIO_WriteHandle *ret; |
@@ -718,7 +741,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, | |||
718 | * @param ent entity identifier | 741 | * @param ent entity identifier |
719 | */ | 742 | */ |
720 | static void | 743 | static void |
721 | remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | 744 | remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, |
745 | const char *ext, | ||
722 | const char *uni, const char *ent) | 746 | const char *uni, const char *ent) |
723 | { | 747 | { |
724 | char *filename; | 748 | char *filename; |
@@ -745,7 +769,8 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | |||
745 | * @param uni unique name of parent | 769 | * @param uni unique name of parent |
746 | */ | 770 | */ |
747 | void | 771 | void |
748 | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, | 772 | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, |
773 | const char *ext, | ||
749 | const char *uni) | 774 | const char *uni) |
750 | { | 775 | { |
751 | char *dn; | 776 | char *dn; |
@@ -763,7 +788,7 @@ GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, | |||
763 | 788 | ||
764 | 789 | ||
765 | /** | 790 | /** |
766 | * Serialize a 'start_time'. Since we use start-times to | 791 | * Serialize a start-time. Since we use start-times to |
767 | * calculate the duration of some operation, we actually | 792 | * calculate the duration of some operation, we actually |
768 | * do not serialize the absolute time but the (relative) | 793 | * do not serialize the absolute time but the (relative) |
769 | * duration since the start time. When we then | 794 | * duration since the start time. When we then |
@@ -774,7 +799,7 @@ GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, | |||
774 | * | 799 | * |
775 | * @param wh handle for writing | 800 | * @param wh handle for writing |
776 | * @param timestamp time to serialize | 801 | * @param timestamp time to serialize |
777 | * @return GNUNET_OK on success | 802 | * @return #GNUNET_OK on success |
778 | */ | 803 | */ |
779 | static int | 804 | static int |
780 | write_start_time (struct GNUNET_BIO_WriteHandle *wh, | 805 | write_start_time (struct GNUNET_BIO_WriteHandle *wh, |
@@ -788,10 +813,10 @@ write_start_time (struct GNUNET_BIO_WriteHandle *wh, | |||
788 | 813 | ||
789 | 814 | ||
790 | /** | 815 | /** |
791 | * Serialize a 'start_time'. Since we use start-times to | 816 | * Deserialize a start-time. Since we use start-times to |
792 | * calculate the duration of some operation, we actually | 817 | * calculate the duration of some operation, we actually |
793 | * do not serialize the absolute time but the (relative) | 818 | * do not serialize the absolute time but the (relative) |
794 | * duration since the start time. When we then | 819 | * duration since the start time. Thus, when we then |
795 | * deserialize the start time, we take the current time and | 820 | * deserialize the start time, we take the current time and |
796 | * subtract that duration so that we get again an absolute | 821 | * subtract that duration so that we get again an absolute |
797 | * time stamp that will result in correct performance | 822 | * time stamp that will result in correct performance |
@@ -824,7 +849,8 @@ read_start_time (struct GNUNET_BIO_ReadHandle *rh, | |||
824 | * @return NULL on error | 849 | * @return NULL on error |
825 | */ | 850 | */ |
826 | static struct GNUNET_FS_FileInformation * | 851 | static struct GNUNET_FS_FileInformation * |
827 | deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename); | 852 | deserialize_file_information (struct GNUNET_FS_Handle *h, |
853 | const char *filename); | ||
828 | 854 | ||
829 | 855 | ||
830 | /** | 856 | /** |
@@ -838,7 +864,8 @@ deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename); | |||
838 | * @return NULL on error | 864 | * @return NULL on error |
839 | */ | 865 | */ |
840 | static struct GNUNET_FS_FileInformation * | 866 | static struct GNUNET_FS_FileInformation * |
841 | deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, | 867 | deserialize_fi_node (struct GNUNET_FS_Handle *h, |
868 | const char *fn, | ||
842 | struct GNUNET_BIO_ReadHandle *rh) | 869 | struct GNUNET_BIO_ReadHandle *rh) |
843 | { | 870 | { |
844 | struct GNUNET_FS_FileInformation *ret; | 871 | struct GNUNET_FS_FileInformation *ret; |
@@ -1124,7 +1151,8 @@ get_serialization_short_name (const char *fullname) | |||
1124 | * @return NULL on errror | 1151 | * @return NULL on errror |
1125 | */ | 1152 | */ |
1126 | static char * | 1153 | static char * |
1127 | make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext) | 1154 | make_serialization_file_name (struct GNUNET_FS_Handle *h, |
1155 | const char *ext) | ||
1128 | { | 1156 | { |
1129 | char *fn; | 1157 | char *fn; |
1130 | char *dn; | 1158 | char *dn; |
@@ -1161,7 +1189,8 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext) | |||
1161 | */ | 1189 | */ |
1162 | static char * | 1190 | static char * |
1163 | make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, | 1191 | make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, |
1164 | const char *ext, const char *uni) | 1192 | const char *ext, |
1193 | const char *uni) | ||
1165 | { | 1194 | { |
1166 | char *fn; | 1195 | char *fn; |
1167 | char *dn; | 1196 | char *dn; |
@@ -1226,7 +1255,7 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh, | |||
1226 | 1255 | ||
1227 | /** | 1256 | /** |
1228 | * Create a temporary file on disk to store the current | 1257 | * Create a temporary file on disk to store the current |
1229 | * state of "fi" in. | 1258 | * state of @a fi in. |
1230 | * | 1259 | * |
1231 | * @param fi file information to sync with disk | 1260 | * @param fi file information to sync with disk |
1232 | */ | 1261 | */ |
@@ -1437,10 +1466,13 @@ find_file_position (struct GNUNET_FS_FileInformation *pos, | |||
1437 | * @return #GNUNET_OK to continue (always) | 1466 | * @return #GNUNET_OK to continue (always) |
1438 | */ | 1467 | */ |
1439 | static int | 1468 | static int |
1440 | fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi, | 1469 | fip_signal_resume (void *cls, |
1441 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | 1470 | struct GNUNET_FS_FileInformation *fi, |
1471 | uint64_t length, | ||
1472 | struct GNUNET_CONTAINER_MetaData *meta, | ||
1442 | struct GNUNET_FS_Uri **uri, | 1473 | struct GNUNET_FS_Uri **uri, |
1443 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | 1474 | struct GNUNET_FS_BlockOptions *bo, |
1475 | int *do_index, | ||
1444 | void **client_info) | 1476 | void **client_info) |
1445 | { | 1477 | { |
1446 | struct GNUNET_FS_PublishContext *pc = cls; | 1478 | struct GNUNET_FS_PublishContext *pc = cls; |
@@ -1474,7 +1506,8 @@ fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1474 | * @return #GNUNET_OK (continue to iterate) | 1506 | * @return #GNUNET_OK (continue to iterate) |
1475 | */ | 1507 | */ |
1476 | static int | 1508 | static int |
1477 | deserialize_publish_file (void *cls, const char *filename) | 1509 | deserialize_publish_file (void *cls, |
1510 | const char *filename) | ||
1478 | { | 1511 | { |
1479 | struct GNUNET_FS_Handle *h = cls; | 1512 | struct GNUNET_FS_Handle *h = cls; |
1480 | struct GNUNET_BIO_ReadHandle *rh; | 1513 | struct GNUNET_BIO_ReadHandle *rh; |
@@ -1733,7 +1766,7 @@ cleanup: | |||
1733 | /** | 1766 | /** |
1734 | * Serialize a download request. | 1767 | * Serialize a download request. |
1735 | * | 1768 | * |
1736 | * @param wh the `struct GNUNET_BIO_WriteHandle*` | 1769 | * @param wh handle for writing the download request to disk |
1737 | * @param dr the the request to write to disk | 1770 | * @param dr the the request to write to disk |
1738 | * @return #GNUNET_YES on success, #GNUNET_NO on error | 1771 | * @return #GNUNET_YES on success, #GNUNET_NO on error |
1739 | */ | 1772 | */ |
@@ -1776,10 +1809,9 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) | |||
1776 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || | 1809 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || |
1777 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || | 1810 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || |
1778 | (dr->num_children > CHK_PER_INODE) || | 1811 | (dr->num_children > CHK_PER_INODE) || |
1779 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((0 == dr->depth) | 1812 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || |
1780 | && | 1813 | ( (0 == dr->depth) && |
1781 | (dr->num_children | 1814 | (dr->num_children > 0) ) || |
1782 | > 0)) || | ||
1783 | ((dr->depth > 0) && (0 == dr->num_children))) | 1815 | ((dr->depth > 0) && (0 == dr->num_children))) |
1784 | { | 1816 | { |
1785 | GNUNET_break (0); | 1817 | GNUNET_break (0); |
@@ -1833,7 +1865,8 @@ cleanup: | |||
1833 | */ | 1865 | */ |
1834 | static char * | 1866 | static char * |
1835 | get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc, | 1867 | get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc, |
1836 | const char *uni, const char *ext) | 1868 | const char *uni, |
1869 | const char *ext) | ||
1837 | { | 1870 | { |
1838 | char *par; | 1871 | char *par; |
1839 | char *epar; | 1872 | char *epar; |
@@ -2114,12 +2147,13 @@ cleanup: | |||
2114 | * Function called with a filename of serialized unindexing operation | 2147 | * Function called with a filename of serialized unindexing operation |
2115 | * to deserialize. | 2148 | * to deserialize. |
2116 | * | 2149 | * |
2117 | * @param cls the 'struct GNUNET_FS_Handle*' | 2150 | * @param cls the `struct GNUNET_FS_Handle *` |
2118 | * @param filename complete filename (absolute path) | 2151 | * @param filename complete filename (absolute path) |
2119 | * @return GNUNET_OK (continue to iterate) | 2152 | * @return #GNUNET_OK (continue to iterate) |
2120 | */ | 2153 | */ |
2121 | static int | 2154 | static int |
2122 | deserialize_unindex_file (void *cls, const char *filename) | 2155 | deserialize_unindex_file (void *cls, |
2156 | const char *filename) | ||
2123 | { | 2157 | { |
2124 | struct GNUNET_FS_Handle *h = cls; | 2158 | struct GNUNET_FS_Handle *h = cls; |
2125 | struct GNUNET_BIO_ReadHandle *rh; | 2159 | struct GNUNET_BIO_ReadHandle *rh; |
@@ -2249,7 +2283,8 @@ cleanup: | |||
2249 | if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) | 2283 | if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) |
2250 | { | 2284 | { |
2251 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2285 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2252 | _("Failed to resume unindexing operation `%s': %s\n"), filename, | 2286 | _("Failed to resume unindexing operation `%s': %s\n"), |
2287 | filename, | ||
2253 | emsg); | 2288 | emsg); |
2254 | GNUNET_free (emsg); | 2289 | GNUNET_free (emsg); |
2255 | } | 2290 | } |
@@ -2298,12 +2333,13 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2298 | * Function called with a filename of serialized search result | 2333 | * Function called with a filename of serialized search result |
2299 | * to deserialize. | 2334 | * to deserialize. |
2300 | * | 2335 | * |
2301 | * @param cls the 'struct GNUNET_FS_SearchContext*' | 2336 | * @param cls the `struct GNUNET_FS_SearchContext *` |
2302 | * @param filename complete filename (absolute path) | 2337 | * @param filename complete filename (absolute path) |
2303 | * @return #GNUNET_OK (continue to iterate) | 2338 | * @return #GNUNET_OK (continue to iterate) |
2304 | */ | 2339 | */ |
2305 | static int | 2340 | static int |
2306 | deserialize_search_result (void *cls, const char *filename) | 2341 | deserialize_search_result (void *cls, |
2342 | const char *filename) | ||
2307 | { | 2343 | { |
2308 | struct GNUNET_FS_SearchContext *sc = cls; | 2344 | struct GNUNET_FS_SearchContext *sc = cls; |
2309 | char *ser; | 2345 | char *ser; |
@@ -2375,7 +2411,8 @@ deserialize_search_result (void *cls, const char *filename) | |||
2375 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) | 2411 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) |
2376 | { | 2412 | { |
2377 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2413 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2378 | _("Failed to resume sub-download `%s': %s\n"), download, | 2414 | _("Failed to resume sub-download `%s': %s\n"), |
2415 | download, | ||
2379 | emsg); | 2416 | emsg); |
2380 | GNUNET_free (emsg); | 2417 | GNUNET_free (emsg); |
2381 | } | 2418 | } |
@@ -2392,7 +2429,8 @@ deserialize_search_result (void *cls, const char *filename) | |||
2392 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) | 2429 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) |
2393 | { | 2430 | { |
2394 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2431 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2395 | _("Failed to resume sub-search `%s': %s\n"), update_srch, | 2432 | _("Failed to resume sub-search `%s': %s\n"), |
2433 | update_srch, | ||
2396 | emsg); | 2434 | emsg); |
2397 | GNUNET_free (emsg); | 2435 | GNUNET_free (emsg); |
2398 | } | 2436 | } |
@@ -2476,13 +2514,15 @@ signal_search_resume (struct GNUNET_FS_SearchContext *sc); | |||
2476 | * Iterator over search results signaling resume to the client for | 2514 | * Iterator over search results signaling resume to the client for |
2477 | * each result. | 2515 | * each result. |
2478 | * | 2516 | * |
2479 | * @param cls closure, the 'struct GNUNET_FS_SearchContext' | 2517 | * @param cls closure, the `struct GNUNET_FS_SearchContext *` |
2480 | * @param key current key code | 2518 | * @param key current key code |
2481 | * @param value value in the hash map, the 'struct GNUNET_FS_SearchResult' | 2519 | * @param value value in the hash map, the `struct GNUNET_FS_SearchResult *` |
2482 | * @return GNUNET_YES (we should continue to iterate) | 2520 | * @return #GNUNET_YES (we should continue to iterate) |
2483 | */ | 2521 | */ |
2484 | static int | 2522 | static int |
2485 | signal_result_resume (void *cls, const struct GNUNET_HashCode * key, void *value) | 2523 | signal_result_resume (void *cls, |
2524 | const struct GNUNET_HashCode *key, | ||
2525 | void *value) | ||
2486 | { | 2526 | { |
2487 | struct GNUNET_FS_SearchContext *sc = cls; | 2527 | struct GNUNET_FS_SearchContext *sc = cls; |
2488 | struct GNUNET_FS_ProgressInfo pi; | 2528 | struct GNUNET_FS_ProgressInfo pi; |
@@ -2528,13 +2568,15 @@ free_search_context (struct GNUNET_FS_SearchContext *sc); | |||
2528 | /** | 2568 | /** |
2529 | * Iterator over search results freeing each. | 2569 | * Iterator over search results freeing each. |
2530 | * | 2570 | * |
2531 | * @param cls closure, the 'struct GNUNET_FS_SearchContext' | 2571 | * @param cls closure, the `struct GNUNET_FS_SearchContext *` |
2532 | * @param key current key code | 2572 | * @param key current key code |
2533 | * @param value value in the hash map, the 'struct GNUNET_FS_SearchResult' | 2573 | * @param value value in the hash map, the `struct GNUNET_FS_SearchResult *` |
2534 | * @return GNUNET_YES (we should continue to iterate) | 2574 | * @return #GNUNET_YES (we should continue to iterate) |
2535 | */ | 2575 | */ |
2536 | static int | 2576 | static int |
2537 | free_result (void *cls, const struct GNUNET_HashCode * key, void *value) | 2577 | free_result (void *cls, |
2578 | const struct GNUNET_HashCode *key, | ||
2579 | void *value) | ||
2538 | { | 2580 | { |
2539 | struct GNUNET_FS_SearchResult *sr = value; | 2581 | struct GNUNET_FS_SearchResult *sr = value; |
2540 | 2582 | ||
@@ -2589,12 +2631,13 @@ free_search_context (struct GNUNET_FS_SearchContext *sc) | |||
2589 | * Function called with a filename of serialized sub-download | 2631 | * Function called with a filename of serialized sub-download |
2590 | * to deserialize. | 2632 | * to deserialize. |
2591 | * | 2633 | * |
2592 | * @param cls the 'struct GNUNET_FS_DownloadContext*' (parent) | 2634 | * @param cls the `struct GNUNET_FS_DownloadContext *` (parent) |
2593 | * @param filename complete filename (absolute path) | 2635 | * @param filename complete filename (absolute path) |
2594 | * @return #GNUNET_OK (continue to iterate) | 2636 | * @return #GNUNET_OK (continue to iterate) |
2595 | */ | 2637 | */ |
2596 | static int | 2638 | static int |
2597 | deserialize_subdownload (void *cls, const char *filename) | 2639 | deserialize_subdownload (void *cls, |
2640 | const char *filename) | ||
2598 | { | 2641 | { |
2599 | struct GNUNET_FS_DownloadContext *parent = cls; | 2642 | struct GNUNET_FS_DownloadContext *parent = cls; |
2600 | char *ser; | 2643 | char *ser; |
@@ -2606,9 +2649,9 @@ deserialize_subdownload (void *cls, const char *filename) | |||
2606 | if (NULL == rh) | 2649 | if (NULL == rh) |
2607 | { | 2650 | { |
2608 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2651 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2609 | _ | 2652 | _("Failed to resume sub-download `%s': could not open file `%s'\n"), |
2610 | ("Failed to resume sub-download `%s': could not open file `%s'\n"), | 2653 | ser, |
2611 | ser, filename); | 2654 | filename); |
2612 | GNUNET_free (ser); | 2655 | GNUNET_free (ser); |
2613 | return GNUNET_OK; | 2656 | return GNUNET_OK; |
2614 | } | 2657 | } |
@@ -2616,7 +2659,9 @@ deserialize_subdownload (void *cls, const char *filename) | |||
2616 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) | 2659 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) |
2617 | { | 2660 | { |
2618 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2661 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2619 | _("Failed to resume sub-download `%s': %s\n"), ser, emsg); | 2662 | _("Failed to resume sub-download `%s': %s\n"), |
2663 | ser, | ||
2664 | emsg); | ||
2620 | GNUNET_free (emsg); | 2665 | GNUNET_free (emsg); |
2621 | } | 2666 | } |
2622 | GNUNET_free (ser); | 2667 | GNUNET_free (ser); |
@@ -2646,7 +2691,9 @@ free_download_context (struct GNUNET_FS_DownloadContext *dc) | |||
2646 | GNUNET_free_non_null (dc->serialization); | 2691 | GNUNET_free_non_null (dc->serialization); |
2647 | while (NULL != (dcc = dc->child_head)) | 2692 | while (NULL != (dcc = dc->child_head)) |
2648 | { | 2693 | { |
2649 | GNUNET_CONTAINER_DLL_remove (dc->child_head, dc->child_tail, dcc); | 2694 | GNUNET_CONTAINER_DLL_remove (dc->child_head, |
2695 | dc->child_tail, | ||
2696 | dcc); | ||
2650 | free_download_context (dcc); | 2697 | free_download_context (dcc); |
2651 | } | 2698 | } |
2652 | GNUNET_FS_free_download_request_ (dc->top_request); | 2699 | GNUNET_FS_free_download_request_ (dc->top_request); |
@@ -2851,8 +2898,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2851 | (GNUNET_OK != GNUNET_FS_search_start_searching_ (sc))) | 2898 | (GNUNET_OK != GNUNET_FS_search_start_searching_ (sc))) |
2852 | { | 2899 | { |
2853 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2900 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2854 | _ | 2901 | _("Could not resume running search, will resume as paused search\n")); |
2855 | ("Could not resume running search, will resume as paused search\n")); | ||
2856 | } | 2902 | } |
2857 | signal_search_resume (sc); | 2903 | signal_search_resume (sc); |
2858 | GNUNET_free (uris); | 2904 | GNUNET_free (uris); |
@@ -2869,12 +2915,13 @@ cleanup: | |||
2869 | * Function called with a filename of serialized search operation | 2915 | * Function called with a filename of serialized search operation |
2870 | * to deserialize. | 2916 | * to deserialize. |
2871 | * | 2917 | * |
2872 | * @param cls the 'struct GNUNET_FS_Handle*' | 2918 | * @param cls the `struct GNUNET_FS_Handle *` |
2873 | * @param filename complete filename (absolute path) | 2919 | * @param filename complete filename (absolute path) |
2874 | * @return #GNUNET_OK (continue to iterate) | 2920 | * @return #GNUNET_OK (continue to iterate) |
2875 | */ | 2921 | */ |
2876 | static int | 2922 | static int |
2877 | deserialize_search_file (void *cls, const char *filename) | 2923 | deserialize_search_file (void *cls, |
2924 | const char *filename) | ||
2878 | { | 2925 | { |
2879 | struct GNUNET_FS_Handle *h = cls; | 2926 | struct GNUNET_FS_Handle *h = cls; |
2880 | char *ser; | 2927 | char *ser; |
@@ -2920,7 +2967,7 @@ deserialize_search_file (void *cls, const char *filename) | |||
2920 | * Function called with a filename of serialized download operation | 2967 | * Function called with a filename of serialized download operation |
2921 | * to deserialize. | 2968 | * to deserialize. |
2922 | * | 2969 | * |
2923 | * @param cls the 'struct GNUNET_FS_Handle*' | 2970 | * @param cls the `struct GNUNET_FS_Handle *` |
2924 | * @param filename complete filename (absolute path) | 2971 | * @param filename complete filename (absolute path) |
2925 | * @return #GNUNET_OK (continue to iterate) | 2972 | * @return #GNUNET_OK (continue to iterate) |
2926 | */ | 2973 | */ |
@@ -2982,15 +3029,17 @@ deserialization_master (const char *master_path, GNUNET_FileNameCallback proc, | |||
2982 | * @param cfg configuration to use | 3029 | * @param cfg configuration to use |
2983 | * @param client_name unique identifier for this client | 3030 | * @param client_name unique identifier for this client |
2984 | * @param upcb function to call to notify about FS actions | 3031 | * @param upcb function to call to notify about FS actions |
2985 | * @param upcb_cls closure for upcb | 3032 | * @param upcb_cls closure for @a upcb |
2986 | * @param flags specific attributes for fs-operations | 3033 | * @param flags specific attributes for fs-operations |
2987 | * @param ... list of optional options, terminated with GNUNET_FS_OPTIONS_END | 3034 | * @param ... list of optional options, terminated with #GNUNET_FS_OPTIONS_END |
2988 | * @return NULL on error | 3035 | * @return NULL on error |
2989 | */ | 3036 | */ |
2990 | struct GNUNET_FS_Handle * | 3037 | struct GNUNET_FS_Handle * |
2991 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 3038 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
2992 | const char *client_name, GNUNET_FS_ProgressCallback upcb, | 3039 | const char *client_name, |
2993 | void *upcb_cls, enum GNUNET_FS_Flags flags, ...) | 3040 | GNUNET_FS_ProgressCallback upcb, |
3041 | void *upcb_cls, | ||
3042 | enum GNUNET_FS_Flags flags, ...) | ||
2994 | { | 3043 | { |
2995 | struct GNUNET_FS_Handle *ret; | 3044 | struct GNUNET_FS_Handle *ret; |
2996 | enum GNUNET_FS_OPTIONS opt; | 3045 | enum GNUNET_FS_OPTIONS opt; |
@@ -3047,7 +3096,7 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
3047 | * The callback given to GNUNET_FS_start will no longer be | 3096 | * The callback given to GNUNET_FS_start will no longer be |
3048 | * called after this function returns. | 3097 | * called after this function returns. |
3049 | * | 3098 | * |
3050 | * @param h handle that was returned from GNUNET_FS_start | 3099 | * @param h handle that was returned from #GNUNET_FS_start() |
3051 | */ | 3100 | */ |
3052 | void | 3101 | void |
3053 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) | 3102 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) |
@@ -3061,4 +3110,4 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h) | |||
3061 | } | 3110 | } |
3062 | 3111 | ||
3063 | 3112 | ||
3064 | /* end of fs.c */ | 3113 | /* end of fs_api.c */ |