diff options
-rw-r--r-- | src/include/gnunet_bio_lib.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_disk_lib.h | 107 | ||||
-rw-r--r-- | src/transport/plugin_transport_http.c | 12 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 14 | ||||
-rw-r--r-- | src/util/bio.c | 18 | ||||
-rw-r--r-- | src/util/disk.c | 76 |
6 files changed, 121 insertions, 110 deletions
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h index 8bb783c75..a9ac0c1cd 100644 --- a/src/include/gnunet_bio_lib.h +++ b/src/include/gnunet_bio_lib.h | |||
@@ -104,12 +104,12 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, | |||
104 | * @param what describes what is being read (for error message creation) | 104 | * @param what describes what is being read (for error message creation) |
105 | * @param result the buffer to store a pointer to the (allocated) string to | 105 | * @param result the buffer to store a pointer to the (allocated) string to |
106 | * (note that *result could be set to NULL as well) | 106 | * (note that *result could be set to NULL as well) |
107 | * @param maxLen maximum allowed length for the string | 107 | * @param max_length maximum allowed length for the string |
108 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 108 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
109 | */ | 109 | */ |
110 | int | 110 | int |
111 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | 111 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, |
112 | char **result, size_t maxLen); | 112 | char **result, size_t max_length); |
113 | 113 | ||
114 | 114 | ||
115 | /** | 115 | /** |
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 022cfc2af..a800010f8 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -387,7 +387,7 @@ GNUNET_DISK_mkdtemp (const char *t); | |||
387 | * @param fn file name to be opened | 387 | * @param fn file name to be opened |
388 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags | 388 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags |
389 | * @param perm permissions for the newly created file, use | 389 | * @param perm permissions for the newly created file, use |
390 | * GNUNET_DISK_PERM_NONE if a file could not be created by this | 390 | * #GNUNET_DISK_PERM_NONE if a file could not be created by this |
391 | * call (because of flags) | 391 | * call (because of flags) |
392 | * @return IO handle on success, NULL on error | 392 | * @return IO handle on success, NULL on error |
393 | */ | 393 | */ |
@@ -401,7 +401,7 @@ GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, | |||
401 | * | 401 | * |
402 | * @param fh open file handle | 402 | * @param fh open file handle |
403 | * @param size where to write size of the file | 403 | * @param size where to write size of the file |
404 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 404 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
405 | */ | 405 | */ |
406 | int | 406 | int |
407 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | 407 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
@@ -411,8 +411,8 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | |||
411 | /** | 411 | /** |
412 | * Creates an interprocess channel | 412 | * Creates an interprocess channel |
413 | * | 413 | * |
414 | * @param blocking_read creates an asynchronous pipe for reading if set to GNUNET_NO | 414 | * @param blocking_read creates an asynchronous pipe for reading if set to #GNUNET_NO |
415 | * @param blocking_write creates an asynchronous pipe for writing if set to GNUNET_NO | 415 | * @param blocking_write creates an asynchronous pipe for writing if set to #GNUNET_NO |
416 | * @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT only) | 416 | * @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT only) |
417 | * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) | 417 | * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) |
418 | * @return handle to the new pipe, NULL on error | 418 | * @return handle to the new pipe, NULL on error |
@@ -425,8 +425,8 @@ GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int i | |||
425 | * Creates a pipe object from a couple of file descriptors. | 425 | * Creates a pipe object from a couple of file descriptors. |
426 | * Useful for wrapping existing pipe FDs. | 426 | * Useful for wrapping existing pipe FDs. |
427 | * | 427 | * |
428 | * @param blocking_read creates an asynchronous pipe for reading if set to GNUNET_NO | 428 | * @param blocking_read creates an asynchronous pipe for reading if set to #GNUNET_NO |
429 | * @param blocking_write creates an asynchronous pipe for writing if set to GNUNET_NO | 429 | * @param blocking_write creates an asynchronous pipe for writing if set to #GNUNET_NO |
430 | * @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes | 430 | * @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes |
431 | * | 431 | * |
432 | * @return handle to the new pipe, NULL on error | 432 | * @return handle to the new pipe, NULL on error |
@@ -438,7 +438,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]); | |||
438 | /** | 438 | /** |
439 | * Closes an interprocess channel | 439 | * Closes an interprocess channel |
440 | * @param p pipe | 440 | * @param p pipe |
441 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 441 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
442 | */ | 442 | */ |
443 | int | 443 | int |
444 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | 444 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); |
@@ -449,12 +449,13 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | |||
449 | * | 449 | * |
450 | * @param p pipe to close end of | 450 | * @param p pipe to close end of |
451 | * @param end which end of the pipe to close | 451 | * @param end which end of the pipe to close |
452 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 452 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
453 | */ | 453 | */ |
454 | int | 454 | int |
455 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, | 455 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, |
456 | enum GNUNET_DISK_PipeEnd end); | 456 | enum GNUNET_DISK_PipeEnd end); |
457 | 457 | ||
458 | |||
458 | /** | 459 | /** |
459 | * Detaches one of the ends from the pipe. | 460 | * Detaches one of the ends from the pipe. |
460 | * Detached end is a fully-functional FileHandle, it will | 461 | * Detached end is a fully-functional FileHandle, it will |
@@ -505,6 +506,7 @@ struct GNUNET_DISK_FileHandle * | |||
505 | GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh); | 506 | GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh); |
506 | #endif | 507 | #endif |
507 | 508 | ||
509 | |||
508 | /** | 510 | /** |
509 | * Get a handle from a native integer FD. | 511 | * Get a handle from a native integer FD. |
510 | * | 512 | * |
@@ -514,6 +516,7 @@ GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh); | |||
514 | struct GNUNET_DISK_FileHandle * | 516 | struct GNUNET_DISK_FileHandle * |
515 | GNUNET_DISK_get_handle_from_int_fd (int fno); | 517 | GNUNET_DISK_get_handle_from_int_fd (int fno); |
516 | 518 | ||
519 | |||
517 | /** | 520 | /** |
518 | * Get a handle from a native FD. | 521 | * Get a handle from a native FD. |
519 | * | 522 | * |
@@ -529,7 +532,7 @@ GNUNET_DISK_get_handle_from_native (FILE *fd); | |||
529 | * @param h handle to an open file | 532 | * @param h handle to an open file |
530 | * @param result the buffer to write the result to | 533 | * @param result the buffer to write the result to |
531 | * @param len the maximum number of bytes to read | 534 | * @param len the maximum number of bytes to read |
532 | * @return the number of bytes read on success, GNUNET_SYSERR on failure | 535 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure |
533 | */ | 536 | */ |
534 | ssize_t | 537 | ssize_t |
535 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, | 538 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, |
@@ -544,11 +547,12 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, | |||
544 | * @param h handle to an open file | 547 | * @param h handle to an open file |
545 | * @param result the buffer to write the result to | 548 | * @param result the buffer to write the result to |
546 | * @param len the maximum number of bytes to read | 549 | * @param len the maximum number of bytes to read |
547 | * @return the number of bytes read on success, GNUNET_SYSERR on failure | 550 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure |
548 | */ | 551 | */ |
549 | ssize_t | 552 | ssize_t |
550 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, | 553 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, |
551 | void *result, size_t len); | 554 | void *result, |
555 | size_t len); | ||
552 | 556 | ||
553 | 557 | ||
554 | /** | 558 | /** |
@@ -557,10 +561,12 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, | |||
557 | * @param fn file name | 561 | * @param fn file name |
558 | * @param result the buffer to write the result to | 562 | * @param result the buffer to write the result to |
559 | * @param len the maximum number of bytes to read | 563 | * @param len the maximum number of bytes to read |
560 | * @return number of bytes read, GNUNET_SYSERR on failure | 564 | * @return number of bytes read, #GNUNET_SYSERR on failure |
561 | */ | 565 | */ |
562 | ssize_t | 566 | ssize_t |
563 | GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); | 567 | GNUNET_DISK_fn_read (const char *fn, |
568 | void *result, | ||
569 | size_t len); | ||
564 | 570 | ||
565 | 571 | ||
566 | /** | 572 | /** |
@@ -569,7 +575,7 @@ GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); | |||
569 | * @param h handle to open file | 575 | * @param h handle to open file |
570 | * @param buffer the data to write | 576 | * @param buffer the data to write |
571 | * @param n number of bytes to write | 577 | * @param n number of bytes to write |
572 | * @return number of bytes written on success, GNUNET_SYSERR on error | 578 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
573 | */ | 579 | */ |
574 | ssize_t | 580 | ssize_t |
575 | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | 581 | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, |
@@ -581,7 +587,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | |||
581 | * @param h handle to open file | 587 | * @param h handle to open file |
582 | * @param buffer the data to write | 588 | * @param buffer the data to write |
583 | * @param n number of bytes to write | 589 | * @param n number of bytes to write |
584 | * @return number of bytes written on success, GNUNET_SYSERR on error | 590 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
585 | */ | 591 | */ |
586 | ssize_t | 592 | ssize_t |
587 | GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, | 593 | GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, |
@@ -597,7 +603,7 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, | |||
597 | * @param buffer the data to write | 603 | * @param buffer the data to write |
598 | * @param n number of bytes to write | 604 | * @param n number of bytes to write |
599 | * @param mode file permissions | 605 | * @param mode file permissions |
600 | * @return number of bytes written on success, GNUNET_SYSERR on error | 606 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
601 | */ | 607 | */ |
602 | ssize_t | 608 | ssize_t |
603 | GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, | 609 | GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, |
@@ -609,7 +615,7 @@ GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, | |||
609 | * | 615 | * |
610 | * @param src file to copy | 616 | * @param src file to copy |
611 | * @param dst destination file name | 617 | * @param dst destination file name |
612 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 618 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
613 | */ | 619 | */ |
614 | int | 620 | int |
615 | GNUNET_DISK_file_copy (const char *src, const char *dst); | 621 | GNUNET_DISK_file_copy (const char *src, const char *dst); |
@@ -618,13 +624,13 @@ GNUNET_DISK_file_copy (const char *src, const char *dst); | |||
618 | /** | 624 | /** |
619 | * Scan a directory for files. | 625 | * Scan a directory for files. |
620 | * | 626 | * |
621 | * @param dirName the name of the directory | 627 | * @param dir_name the name of the directory |
622 | * @param callback the method to call for each file | 628 | * @param callback the method to call for each file |
623 | * @param callback_cls closure for callback | 629 | * @param callback_cls closure for @a callback |
624 | * @return the number of files found, -1 on error | 630 | * @return the number of files found, -1 on error |
625 | */ | 631 | */ |
626 | int | 632 | int |
627 | GNUNET_DISK_directory_scan (const char *dirName, | 633 | GNUNET_DISK_directory_scan (const char *dir_name, |
628 | GNUNET_FileNameCallback callback, | 634 | GNUNET_FileNameCallback callback, |
629 | void *callback_cls); | 635 | void *callback_cls); |
630 | 636 | ||
@@ -639,16 +645,14 @@ struct GNUNET_DISK_DirectoryIterator; | |||
639 | * Function called to iterate over a directory. | 645 | * Function called to iterate over a directory. |
640 | * | 646 | * |
641 | * @param cls closure | 647 | * @param cls closure |
642 | * @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to | 648 | * @param di argument to pass to #GNUNET_DISK_directory_iterator_next to |
643 | * get called on the next entry (or finish cleanly); | 649 | * get called on the next entry (or finish cleanly); |
644 | * NULL on error (will be the last call in that case) | 650 | * NULL on error (will be the last call in that case) |
645 | * @param filename complete filename (absolute path) | 651 | * @param filename complete filename (absolute path) |
646 | * @param dirname directory name (absolute path) | 652 | * @param dirname directory name (absolute path) |
647 | */ | 653 | */ |
648 | typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls, | 654 | typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls, |
649 | struct | 655 | struct GNUNET_DISK_DirectoryIterator *di, |
650 | GNUNET_DISK_DirectoryIterator | ||
651 | * di, | ||
652 | const char *filename, | 656 | const char *filename, |
653 | const char *dirname); | 657 | const char *dirname); |
654 | 658 | ||
@@ -659,10 +663,10 @@ typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls, | |||
659 | * filename in the directory (if there is one). | 663 | * filename in the directory (if there is one). |
660 | * | 664 | * |
661 | * @param iter opaque handle for the iterator | 665 | * @param iter opaque handle for the iterator |
662 | * @param can set to GNUNET_YES to terminate the iteration early | 666 | * @param can set to #GNUNET_YES to terminate the iteration early |
663 | * @return GNUNET_YES if iteration will continue, | 667 | * @return #GNUNET_YES if iteration will continue, |
664 | * GNUNET_NO if this was the last entry (and iteration is complete), | 668 | * #GNUNET_NO if this was the last entry (and iteration is complete), |
665 | * GNUNET_SYSERR if "can" was YES | 669 | * #GNUNET_SYSERR if @a can was #GNUNET_YES |
666 | */ | 670 | */ |
667 | int | 671 | int |
668 | GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, | 672 | GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, |
@@ -676,15 +680,15 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, | |||
676 | * may provide a simpler API. | 680 | * may provide a simpler API. |
677 | * | 681 | * |
678 | * @param prio priority to use | 682 | * @param prio priority to use |
679 | * @param dirName the name of the directory | 683 | * @param dir_name the name of the directory |
680 | * @param callback the method to call for each file | 684 | * @param callback the method to call for each file |
681 | * @param callback_cls closure for callback | 685 | * @param callback_cls closure for @a callback |
682 | * @return GNUNET_YES if directory is not empty and 'callback' | 686 | * @return #GNUNET_YES if directory is not empty and @a callback |
683 | * will be called later, GNUNET_NO otherwise, GNUNET_SYSERR on error. | 687 | * will be called later, #GNUNET_NO otherwise, #GNUNET_SYSERR on error. |
684 | */ | 688 | */ |
685 | int | 689 | int |
686 | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | 690 | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, |
687 | const char *dirName, | 691 | const char *dir_name, |
688 | GNUNET_DISK_DirectoryIteratorCallback | 692 | GNUNET_DISK_DirectoryIteratorCallback |
689 | callback, void *callback_cls); | 693 | callback, void *callback_cls); |
690 | 694 | ||
@@ -694,24 +698,24 @@ GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | |||
694 | * a file. | 698 | * a file. |
695 | * | 699 | * |
696 | * @param filename name of a file in the directory | 700 | * @param filename name of a file in the directory |
697 | * @returns GNUNET_OK on success, GNUNET_SYSERR on failure, | 701 | * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, |
698 | * GNUNET_NO if directory exists but is not writeable | 702 | * #GNUNET_NO if directory exists but is not writeable |
699 | */ | 703 | */ |
700 | int | 704 | int |
701 | GNUNET_DISK_directory_create_for_file (const char *filename); | 705 | GNUNET_DISK_directory_create_for_file (const char *filename); |
702 | 706 | ||
703 | 707 | ||
704 | /** | 708 | /** |
705 | * Test if "fil" is a directory and listable. Optionally, also check if the | 709 | * Test if @a fil is a directory and listable. Optionally, also check if the |
706 | * directory is readable. Will not print an error message if the directory does | 710 | * directory is readable. Will not print an error message if the directory does |
707 | * not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file exists | 711 | * not exist. Will log errors if #GNUNET_SYSERR is returned (i.e., a file exists |
708 | * with the same name). | 712 | * with the same name). |
709 | * | 713 | * |
710 | * @param fil filename to test | 714 | * @param fil filename to test |
711 | * @param is_readable GNUNET_YES to additionally check if "fil" is readable; | 715 | * @param is_readable #GNUNET_YES to additionally check if @a fil is readable; |
712 | * GNUNET_NO to disable this check | 716 | * #GNUNET_NO to disable this check |
713 | * @return GNUNET_YES if yes, GNUNET_NO if not; GNUNET_SYSERR if it | 717 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it |
714 | * does not exist or stat'ed | 718 | * does not exist or `stat`ed |
715 | */ | 719 | */ |
716 | int | 720 | int |
717 | GNUNET_DISK_directory_test (const char *fil, int is_readable); | 721 | GNUNET_DISK_directory_test (const char *fil, int is_readable); |
@@ -742,27 +746,28 @@ GNUNET_DISK_directory_create (const char *dir); | |||
742 | * Lock a part of a file. | 746 | * Lock a part of a file. |
743 | * | 747 | * |
744 | * @param fh file handle | 748 | * @param fh file handle |
745 | * @param lockStart absolute position from where to lock | 749 | * @param lock_start absolute position from where to lock |
746 | * @param lockEnd absolute position until where to lock | 750 | * @param lock_end absolute position until where to lock |
747 | * @param excl #GNUNET_YES for an exclusive lock | 751 | * @param excl #GNUNET_YES for an exclusive lock |
748 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 752 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
749 | */ | 753 | */ |
750 | int | 754 | int |
751 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, | 755 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, |
752 | OFF_T lockEnd, int excl); | 756 | OFF_T lock_start, |
757 | OFF_T lock_end, int excl); | ||
753 | 758 | ||
754 | 759 | ||
755 | /** | 760 | /** |
756 | * Unlock a part of a file. | 761 | * Unlock a part of a file. |
757 | * | 762 | * |
758 | * @param fh file handle | 763 | * @param fh file handle |
759 | * @param unlockStart absolute position from where to unlock | 764 | * @param unlock_start absolute position from where to unlock |
760 | * @param unlockEnd absolute position until where to unlock | 765 | * @param unlock_end absolute position until where to unlock |
761 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 766 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
762 | */ | 767 | */ |
763 | int | 768 | int |
764 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, | 769 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlock_start, |
765 | OFF_T unlockEnd); | 770 | OFF_T unlock_end); |
766 | 771 | ||
767 | 772 | ||
768 | /** | 773 | /** |
@@ -791,7 +796,7 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user); | |||
791 | * DIR_SEPARATOR_STR as the last argument before NULL). | 796 | * DIR_SEPARATOR_STR as the last argument before NULL). |
792 | * | 797 | * |
793 | * @param cfg configuration to use | 798 | * @param cfg configuration to use |
794 | * @param serviceName name of the service asking | 799 | * @param service_name name of the service asking |
795 | * @param ... is NULL-terminated list of | 800 | * @param ... is NULL-terminated list of |
796 | * path components to append to the | 801 | * path components to append to the |
797 | * private directory name. | 802 | * private directory name. |
@@ -799,7 +804,7 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user); | |||
799 | */ | 804 | */ |
800 | char * | 805 | char * |
801 | GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, | 806 | GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, |
802 | const char *serviceName, ...); | 807 | const char *service_name, ...); |
803 | 808 | ||
804 | 809 | ||
805 | /** | 810 | /** |
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 937f4f62f..637e74063 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -829,7 +829,7 @@ http_check_ipv6 (struct Plugin *plugin) | |||
829 | 829 | ||
830 | 830 | ||
831 | int | 831 | int |
832 | http_get_addresses (struct Plugin *plugin, const char *serviceName, | 832 | http_get_addresses (struct Plugin *plugin, const char *service_name, |
833 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 833 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
834 | struct sockaddr ***addrs, socklen_t ** addr_lens) | 834 | struct sockaddr ***addrs, socklen_t ** addr_lens) |
835 | { | 835 | { |
@@ -852,10 +852,10 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName, | |||
852 | disablev6 = !plugin->ipv6; | 852 | disablev6 = !plugin->ipv6; |
853 | 853 | ||
854 | port = 0; | 854 | port = 0; |
855 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) | 855 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) |
856 | { | 856 | { |
857 | GNUNET_break (GNUNET_OK == | 857 | GNUNET_break (GNUNET_OK == |
858 | GNUNET_CONFIGURATION_get_value_number (cfg, serviceName, | 858 | GNUNET_CONFIGURATION_get_value_number (cfg, service_name, |
859 | "PORT", &port)); | 859 | "PORT", &port)); |
860 | if (port > 65535) | 860 | if (port > 65535) |
861 | { | 861 | { |
@@ -873,10 +873,10 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName, | |||
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO")) | 876 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) |
877 | { | 877 | { |
878 | GNUNET_break (GNUNET_OK == | 878 | GNUNET_break (GNUNET_OK == |
879 | GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, | 879 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, |
880 | "BINDTO", &hostname)); | 880 | "BINDTO", &hostname)); |
881 | } | 881 | } |
882 | else | 882 | else |
@@ -886,7 +886,7 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName, | |||
886 | { | 886 | { |
887 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 887 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
888 | "Resolving `%s' since that is where `%s' will bind to.\n", | 888 | "Resolving `%s' since that is where `%s' will bind to.\n", |
889 | hostname, serviceName); | 889 | hostname, service_name); |
890 | memset (&hints, 0, sizeof (struct addrinfo)); | 890 | memset (&hints, 0, sizeof (struct addrinfo)); |
891 | if (disablev6) | 891 | if (disablev6) |
892 | hints.ai_family = AF_INET; | 892 | hints.ai_family = AF_INET; |
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 58e5db46a..5695e1d7d 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -2341,7 +2341,7 @@ server_nat_port_map_callback (void *cls, int add_remove, const struct sockaddr * | |||
2341 | * Get valid server addresses | 2341 | * Get valid server addresses |
2342 | * | 2342 | * |
2343 | * @param plugin the plugin handle | 2343 | * @param plugin the plugin handle |
2344 | * @param serviceName the servicename | 2344 | * @param service_name the servicename |
2345 | * @param cfg configuration handle | 2345 | * @param cfg configuration handle |
2346 | * @param addrs addresses | 2346 | * @param addrs addresses |
2347 | * @param addr_lens address length | 2347 | * @param addr_lens address length |
@@ -2349,7 +2349,7 @@ server_nat_port_map_callback (void *cls, int add_remove, const struct sockaddr * | |||
2349 | */ | 2349 | */ |
2350 | static int | 2350 | static int |
2351 | server_get_addresses (struct HTTP_Server_Plugin *plugin, | 2351 | server_get_addresses (struct HTTP_Server_Plugin *plugin, |
2352 | const char *serviceName, | 2352 | const char *service_name, |
2353 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 2353 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
2354 | struct sockaddr ***addrs, socklen_t ** addr_lens) | 2354 | struct sockaddr ***addrs, socklen_t ** addr_lens) |
2355 | { | 2355 | { |
@@ -2372,10 +2372,10 @@ server_get_addresses (struct HTTP_Server_Plugin *plugin, | |||
2372 | disablev6 = !plugin->use_ipv6; | 2372 | disablev6 = !plugin->use_ipv6; |
2373 | 2373 | ||
2374 | port = 0; | 2374 | port = 0; |
2375 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) | 2375 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) |
2376 | { | 2376 | { |
2377 | GNUNET_break (GNUNET_OK == | 2377 | GNUNET_break (GNUNET_OK == |
2378 | GNUNET_CONFIGURATION_get_value_number (cfg, serviceName, | 2378 | GNUNET_CONFIGURATION_get_value_number (cfg, service_name, |
2379 | "PORT", &port)); | 2379 | "PORT", &port)); |
2380 | if (port > 65535) | 2380 | if (port > 65535) |
2381 | { | 2381 | { |
@@ -2393,10 +2393,10 @@ server_get_addresses (struct HTTP_Server_Plugin *plugin, | |||
2393 | } | 2393 | } |
2394 | 2394 | ||
2395 | 2395 | ||
2396 | if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO")) | 2396 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) |
2397 | { | 2397 | { |
2398 | GNUNET_break (GNUNET_OK == | 2398 | GNUNET_break (GNUNET_OK == |
2399 | GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, | 2399 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, |
2400 | "BINDTO", &hostname)); | 2400 | "BINDTO", &hostname)); |
2401 | } | 2401 | } |
2402 | else | 2402 | else |
@@ -2406,7 +2406,7 @@ server_get_addresses (struct HTTP_Server_Plugin *plugin, | |||
2406 | { | 2406 | { |
2407 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2407 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
2408 | "Resolving `%s' since that is where `%s' will bind to.\n", | 2408 | "Resolving `%s' since that is where `%s' will bind to.\n", |
2409 | hostname, serviceName); | 2409 | hostname, service_name); |
2410 | memset (&hints, 0, sizeof (struct addrinfo)); | 2410 | memset (&hints, 0, sizeof (struct addrinfo)); |
2411 | if (disablev6) | 2411 | if (disablev6) |
2412 | hints.ai_family = AF_INET; | 2412 | hints.ai_family = AF_INET; |
diff --git a/src/util/bio.c b/src/util/bio.c index 0c62021b5..0a1c213f3 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -219,12 +219,14 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, | |||
219 | * @param what describes what is being read (for error message creation) | 219 | * @param what describes what is being read (for error message creation) |
220 | * @param result the buffer to store a pointer to the (allocated) string to | 220 | * @param result the buffer to store a pointer to the (allocated) string to |
221 | * (note that *result could be set to NULL as well) | 221 | * (note that *result could be set to NULL as well) |
222 | * @param maxLen maximum allowed length for the string | 222 | * @param max_length maximum allowed length for the string |
223 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 223 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
224 | */ | 224 | */ |
225 | int | 225 | int |
226 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | 226 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, |
227 | char **result, size_t maxLen) | 227 | const char *what, |
228 | char **result, | ||
229 | size_t max_length) | ||
228 | { | 230 | { |
229 | char *buf; | 231 | char *buf; |
230 | uint32_t big; | 232 | uint32_t big; |
@@ -240,10 +242,10 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
240 | *result = NULL; | 242 | *result = NULL; |
241 | return GNUNET_OK; | 243 | return GNUNET_OK; |
242 | } | 244 | } |
243 | if (big > maxLen) | 245 | if (big > max_length) |
244 | { | 246 | { |
245 | GNUNET_asprintf (&h->emsg, _("String `%s' longer than allowed (%u > %u)"), | 247 | GNUNET_asprintf (&h->emsg, _("String `%s' longer than allowed (%u > %u)"), |
246 | what, big, maxLen); | 248 | what, big, max_length); |
247 | return GNUNET_SYSERR; | 249 | return GNUNET_SYSERR; |
248 | } | 250 | } |
249 | buf = GNUNET_malloc (big); | 251 | buf = GNUNET_malloc (big); |
@@ -270,7 +272,8 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
270 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 272 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
271 | */ | 273 | */ |
272 | int | 274 | int |
273 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, | 275 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, |
276 | const char *what, | ||
274 | struct GNUNET_CONTAINER_MetaData **result) | 277 | struct GNUNET_CONTAINER_MetaData **result) |
275 | { | 278 | { |
276 | uint32_t size; | 279 | uint32_t size; |
@@ -344,7 +347,8 @@ GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, | |||
344 | int | 347 | int |
345 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, | 348 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, |
346 | const char *file, | 349 | const char *file, |
347 | int line, int64_t * i) | 350 | int line, |
351 | int64_t *i) | ||
348 | { | 352 | { |
349 | int64_t big; | 353 | int64_t big; |
350 | 354 | ||
diff --git a/src/util/disk.c b/src/util/disk.c index 7729fd8ee..9390743fd 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1107,7 +1107,7 @@ GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, | |||
1107 | /** | 1107 | /** |
1108 | * Scan a directory for files. | 1108 | * Scan a directory for files. |
1109 | * | 1109 | * |
1110 | * @param dirName the name of the directory | 1110 | * @param dir_name the name of the directory |
1111 | * @param callback the method to call for each file, | 1111 | * @param callback the method to call for each file, |
1112 | * can be NULL, in that case, we only count | 1112 | * can be NULL, in that case, we only count |
1113 | * @param callback_cls closure for callback | 1113 | * @param callback_cls closure for callback |
@@ -1115,7 +1115,7 @@ GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, | |||
1115 | * ieration aborted by callback returning GNUNET_SYSERR | 1115 | * ieration aborted by callback returning GNUNET_SYSERR |
1116 | */ | 1116 | */ |
1117 | int | 1117 | int |
1118 | GNUNET_DISK_directory_scan (const char *dirName, | 1118 | GNUNET_DISK_directory_scan (const char *dir_name, |
1119 | GNUNET_FileNameCallback callback, | 1119 | GNUNET_FileNameCallback callback, |
1120 | void *callback_cls) | 1120 | void *callback_cls) |
1121 | { | 1121 | { |
@@ -1129,8 +1129,8 @@ GNUNET_DISK_directory_scan (const char *dirName, | |||
1129 | unsigned int name_len; | 1129 | unsigned int name_len; |
1130 | unsigned int n_size; | 1130 | unsigned int n_size; |
1131 | 1131 | ||
1132 | GNUNET_assert (dirName != NULL); | 1132 | GNUNET_assert (dir_name != NULL); |
1133 | dname = GNUNET_STRINGS_filename_expand (dirName); | 1133 | dname = GNUNET_STRINGS_filename_expand (dir_name); |
1134 | if (dname == NULL) | 1134 | if (dname == NULL) |
1135 | return GNUNET_SYSERR; | 1135 | return GNUNET_SYSERR; |
1136 | while ((strlen (dname) > 0) && (dname[strlen (dname) - 1] == DIR_SEPARATOR)) | 1136 | while ((strlen (dname) > 0) && (dname[strlen (dname) - 1] == DIR_SEPARATOR)) |
@@ -1144,7 +1144,7 @@ GNUNET_DISK_directory_scan (const char *dirName, | |||
1144 | if (!S_ISDIR (istat.st_mode)) | 1144 | if (!S_ISDIR (istat.st_mode)) |
1145 | { | 1145 | { |
1146 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Expected `%s' to be a directory!\n"), | 1146 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Expected `%s' to be a directory!\n"), |
1147 | dirName); | 1147 | dir_name); |
1148 | GNUNET_free (dname); | 1148 | GNUNET_free (dname); |
1149 | return GNUNET_SYSERR; | 1149 | return GNUNET_SYSERR; |
1150 | } | 1150 | } |
@@ -1310,7 +1310,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, | |||
1310 | * may provide a simpler API. | 1310 | * may provide a simpler API. |
1311 | * | 1311 | * |
1312 | * @param prio priority to use | 1312 | * @param prio priority to use |
1313 | * @param dirName the name of the directory | 1313 | * @param dir_name the name of the directory |
1314 | * @param callback the method to call for each file | 1314 | * @param callback the method to call for each file |
1315 | * @param callback_cls closure for callback | 1315 | * @param callback_cls closure for callback |
1316 | * @return GNUNET_YES if directory is not empty and 'callback' | 1316 | * @return GNUNET_YES if directory is not empty and 'callback' |
@@ -1318,7 +1318,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, | |||
1318 | */ | 1318 | */ |
1319 | int | 1319 | int |
1320 | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | 1320 | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, |
1321 | const char *dirName, | 1321 | const char *dir_name, |
1322 | GNUNET_DISK_DirectoryIteratorCallback | 1322 | GNUNET_DISK_DirectoryIteratorCallback |
1323 | callback, void *callback_cls) | 1323 | callback, void *callback_cls) |
1324 | { | 1324 | { |
@@ -1327,14 +1327,14 @@ GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | |||
1327 | di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); | 1327 | di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); |
1328 | di->callback = callback; | 1328 | di->callback = callback; |
1329 | di->callback_cls = callback_cls; | 1329 | di->callback_cls = callback_cls; |
1330 | di->directory = OPENDIR (dirName); | 1330 | di->directory = OPENDIR (dir_name); |
1331 | if (di->directory == NULL) | 1331 | if (di->directory == NULL) |
1332 | { | 1332 | { |
1333 | GNUNET_free (di); | 1333 | GNUNET_free (di); |
1334 | callback (callback_cls, NULL, NULL, NULL); | 1334 | callback (callback_cls, NULL, NULL, NULL); |
1335 | return GNUNET_SYSERR; | 1335 | return GNUNET_SYSERR; |
1336 | } | 1336 | } |
1337 | di->dirname = GNUNET_strdup (dirName); | 1337 | di->dirname = GNUNET_strdup (dir_name); |
1338 | di->priority = prio; | 1338 | di->priority = prio; |
1339 | return GNUNET_DISK_directory_iterator_next (di, GNUNET_NO); | 1339 | return GNUNET_DISK_directory_iterator_next (di, GNUNET_NO); |
1340 | } | 1340 | } |
@@ -1400,10 +1400,11 @@ GNUNET_DISK_directory_remove (const char *filename) | |||
1400 | * | 1400 | * |
1401 | * @param src file to copy | 1401 | * @param src file to copy |
1402 | * @param dst destination file name | 1402 | * @param dst destination file name |
1403 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1403 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1404 | */ | 1404 | */ |
1405 | int | 1405 | int |
1406 | GNUNET_DISK_file_copy (const char *src, const char *dst) | 1406 | GNUNET_DISK_file_copy (const char *src, |
1407 | const char *dst) | ||
1407 | { | 1408 | { |
1408 | char *buf; | 1409 | char *buf; |
1409 | uint64_t pos; | 1410 | uint64_t pos; |
@@ -1514,14 +1515,14 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1514 | /** | 1515 | /** |
1515 | * Lock a part of a file | 1516 | * Lock a part of a file |
1516 | * @param fh file handle | 1517 | * @param fh file handle |
1517 | * @param lockStart absolute position from where to lock | 1518 | * @param lock_start absolute position from where to lock |
1518 | * @param lockEnd absolute position until where to lock | 1519 | * @param lock_end absolute position until where to lock |
1519 | * @param excl GNUNET_YES for an exclusive lock | 1520 | * @param excl GNUNET_YES for an exclusive lock |
1520 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1521 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1521 | */ | 1522 | */ |
1522 | int | 1523 | int |
1523 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, | 1524 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lock_start, |
1524 | OFF_T lockEnd, int excl) | 1525 | OFF_T lock_end, int excl) |
1525 | { | 1526 | { |
1526 | if (fh == NULL) | 1527 | if (fh == NULL) |
1527 | { | 1528 | { |
@@ -1535,20 +1536,20 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, | |||
1535 | memset (&fl, 0, sizeof (struct flock)); | 1536 | memset (&fl, 0, sizeof (struct flock)); |
1536 | fl.l_type = excl ? F_WRLCK : F_RDLCK; | 1537 | fl.l_type = excl ? F_WRLCK : F_RDLCK; |
1537 | fl.l_whence = SEEK_SET; | 1538 | fl.l_whence = SEEK_SET; |
1538 | fl.l_start = lockStart; | 1539 | fl.l_start = lock_start; |
1539 | fl.l_len = lockEnd; | 1540 | fl.l_len = lock_end; |
1540 | 1541 | ||
1541 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; | 1542 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; |
1542 | #else | 1543 | #else |
1543 | OVERLAPPED o; | 1544 | OVERLAPPED o; |
1544 | OFF_T diff = lockEnd - lockStart; | 1545 | OFF_T diff = lock_end - lock_start; |
1545 | DWORD diff_low, diff_high; | 1546 | DWORD diff_low, diff_high; |
1546 | diff_low = (DWORD) (diff & 0xFFFFFFFF); | 1547 | diff_low = (DWORD) (diff & 0xFFFFFFFF); |
1547 | diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); | 1548 | diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); |
1548 | 1549 | ||
1549 | memset (&o, 0, sizeof (OVERLAPPED)); | 1550 | memset (&o, 0, sizeof (OVERLAPPED)); |
1550 | o.Offset = (DWORD) (lockStart & 0xFFFFFFFF);; | 1551 | o.Offset = (DWORD) (lock_start & 0xFFFFFFFF);; |
1551 | o.OffsetHigh = (DWORD) (((lockStart & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); | 1552 | o.OffsetHigh = (DWORD) (((lock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); |
1552 | 1553 | ||
1553 | if (!LockFileEx | 1554 | if (!LockFileEx |
1554 | (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY, | 1555 | (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY, |
@@ -1566,13 +1567,13 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, | |||
1566 | /** | 1567 | /** |
1567 | * Unlock a part of a file | 1568 | * Unlock a part of a file |
1568 | * @param fh file handle | 1569 | * @param fh file handle |
1569 | * @param unlockStart absolute position from where to unlock | 1570 | * @param unlock_start absolute position from where to unlock |
1570 | * @param unlockEnd absolute position until where to unlock | 1571 | * @param unlock_end absolute position until where to unlock |
1571 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1572 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1572 | */ | 1573 | */ |
1573 | int | 1574 | int |
1574 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, | 1575 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlock_start, |
1575 | OFF_T unlockEnd) | 1576 | OFF_T unlock_end) |
1576 | { | 1577 | { |
1577 | if (fh == NULL) | 1578 | if (fh == NULL) |
1578 | { | 1579 | { |
@@ -1586,20 +1587,20 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, | |||
1586 | memset (&fl, 0, sizeof (struct flock)); | 1587 | memset (&fl, 0, sizeof (struct flock)); |
1587 | fl.l_type = F_UNLCK; | 1588 | fl.l_type = F_UNLCK; |
1588 | fl.l_whence = SEEK_SET; | 1589 | fl.l_whence = SEEK_SET; |
1589 | fl.l_start = unlockStart; | 1590 | fl.l_start = unlock_start; |
1590 | fl.l_len = unlockEnd; | 1591 | fl.l_len = unlock_end; |
1591 | 1592 | ||
1592 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; | 1593 | return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK; |
1593 | #else | 1594 | #else |
1594 | OVERLAPPED o; | 1595 | OVERLAPPED o; |
1595 | OFF_T diff = unlockEnd - unlockStart; | 1596 | OFF_T diff = unlock_end - unlock_start; |
1596 | DWORD diff_low, diff_high; | 1597 | DWORD diff_low, diff_high; |
1597 | diff_low = (DWORD) (diff & 0xFFFFFFFF); | 1598 | diff_low = (DWORD) (diff & 0xFFFFFFFF); |
1598 | diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); | 1599 | diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); |
1599 | 1600 | ||
1600 | memset (&o, 0, sizeof (OVERLAPPED)); | 1601 | memset (&o, 0, sizeof (OVERLAPPED)); |
1601 | o.Offset = (DWORD) (unlockStart & 0xFFFFFFFF);; | 1602 | o.Offset = (DWORD) (unlock_start & 0xFFFFFFFF);; |
1602 | o.OffsetHigh = (DWORD) (((unlockStart & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); | 1603 | o.OffsetHigh = (DWORD) (((unlock_start & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF); |
1603 | 1604 | ||
1604 | if (!UnlockFileEx (fh->h, 0, diff_low, diff_high, &o)) | 1605 | if (!UnlockFileEx (fh->h, 0, diff_low, diff_high, &o)) |
1605 | { | 1606 | { |
@@ -1620,12 +1621,13 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart, | |||
1620 | * @param fn file name to be opened | 1621 | * @param fn file name to be opened |
1621 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags | 1622 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags |
1622 | * @param perm permissions for the newly created file, use | 1623 | * @param perm permissions for the newly created file, use |
1623 | * GNUNET_DISK_PERM_USER_NONE if a file could not be created by this | 1624 | * #GNUNET_DISK_PERM_USER_NONE if a file could not be created by this |
1624 | * call (because of flags) | 1625 | * call (because of flags) |
1625 | * @return IO handle on success, NULL on error | 1626 | * @return IO handle on success, NULL on error |
1626 | */ | 1627 | */ |
1627 | struct GNUNET_DISK_FileHandle * | 1628 | struct GNUNET_DISK_FileHandle * |
1628 | GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, | 1629 | GNUNET_DISK_file_open (const char *fn, |
1630 | enum GNUNET_DISK_OpenFlags flags, | ||
1629 | enum GNUNET_DISK_AccessPermissions perm) | 1631 | enum GNUNET_DISK_AccessPermissions perm) |
1630 | { | 1632 | { |
1631 | char *expfn; | 1633 | char *expfn; |
@@ -1925,7 +1927,7 @@ GNUNET_DISK_get_handle_from_native (FILE *fd) | |||
1925 | * DIR_SEPARATOR_STR as the last argument before NULL). | 1927 | * DIR_SEPARATOR_STR as the last argument before NULL). |
1926 | * | 1928 | * |
1927 | * @param cfg configuration to use (determines HOME) | 1929 | * @param cfg configuration to use (determines HOME) |
1928 | * @param serviceName name of the service | 1930 | * @param service_name name of the service |
1929 | * @param ... is NULL-terminated list of | 1931 | * @param ... is NULL-terminated list of |
1930 | * path components to append to the | 1932 | * path components to append to the |
1931 | * private directory name. | 1933 | * private directory name. |
@@ -1933,7 +1935,7 @@ GNUNET_DISK_get_handle_from_native (FILE *fd) | |||
1933 | */ | 1935 | */ |
1934 | char * | 1936 | char * |
1935 | GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1937 | GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1936 | const char *serviceName, ...) | 1938 | const char *service_name, ...) |
1937 | { | 1939 | { |
1938 | const char *c; | 1940 | const char *c; |
1939 | char *pfx; | 1941 | char *pfx; |
@@ -1942,19 +1944,19 @@ GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1942 | unsigned int needed; | 1944 | unsigned int needed; |
1943 | 1945 | ||
1944 | if (GNUNET_OK != | 1946 | if (GNUNET_OK != |
1945 | GNUNET_CONFIGURATION_get_value_filename (cfg, serviceName, "HOME", &pfx)) | 1947 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "HOME", &pfx)) |
1946 | return NULL; | 1948 | return NULL; |
1947 | if (pfx == NULL) | 1949 | if (pfx == NULL) |
1948 | { | 1950 | { |
1949 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1951 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1950 | _("No `%s' specified for service `%s' in configuration.\n"), "HOME", | 1952 | _("No `%s' specified for service `%s' in configuration.\n"), "HOME", |
1951 | serviceName); | 1953 | service_name); |
1952 | return NULL; | 1954 | return NULL; |
1953 | } | 1955 | } |
1954 | needed = strlen (pfx) + 2; | 1956 | needed = strlen (pfx) + 2; |
1955 | if ((pfx[strlen (pfx) - 1] != '/') && (pfx[strlen (pfx) - 1] != '\\')) | 1957 | if ((pfx[strlen (pfx) - 1] != '/') && (pfx[strlen (pfx) - 1] != '\\')) |
1956 | needed++; | 1958 | needed++; |
1957 | va_start (ap, serviceName); | 1959 | va_start (ap, service_name); |
1958 | while (1) | 1960 | while (1) |
1959 | { | 1961 | { |
1960 | c = va_arg (ap, const char *); | 1962 | c = va_arg (ap, const char *); |
@@ -1969,7 +1971,7 @@ GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1969 | ret = GNUNET_malloc (needed); | 1971 | ret = GNUNET_malloc (needed); |
1970 | strcpy (ret, pfx); | 1972 | strcpy (ret, pfx); |
1971 | GNUNET_free (pfx); | 1973 | GNUNET_free (pfx); |
1972 | va_start (ap, serviceName); | 1974 | va_start (ap, service_name); |
1973 | while (1) | 1975 | while (1) |
1974 | { | 1976 | { |
1975 | c = va_arg (ap, const char *); | 1977 | c = va_arg (ap, const char *); |