diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-14 08:54:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-14 08:54:54 +0000 |
commit | 94d4ab8921b60870144bc3ba6d885f43976ead78 (patch) | |
tree | da7e588c16d5cbb2a50da3db56297a06c7554125 /src | |
parent | e5813ba1a2630818148fad6c050c4fedf4edcd34 (diff) | |
download | gnunet-94d4ab8921b60870144bc3ba6d885f43976ead78.tar.gz gnunet-94d4ab8921b60870144bc3ba6d885f43976ead78.zip |
-needing yet another API to box stdin for scheduler reading, not ported to W32 yet
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 18 | ||||
-rw-r--r-- | src/util/disk.c | 27 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index ae9cdbbe9..fdd9e8d77 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -425,6 +425,7 @@ GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int i | |||
425 | struct GNUNET_DISK_PipeHandle * | 425 | struct GNUNET_DISK_PipeHandle * |
426 | GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]); | 426 | GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]); |
427 | 427 | ||
428 | |||
428 | /** | 429 | /** |
429 | * Closes an interprocess channel | 430 | * Closes an interprocess channel |
430 | * @param p pipe | 431 | * @param p pipe |
@@ -433,6 +434,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]); | |||
433 | int | 434 | int |
434 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | 435 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); |
435 | 436 | ||
437 | |||
436 | /** | 438 | /** |
437 | * Closes one half of an interprocess channel | 439 | * Closes one half of an interprocess channel |
438 | * | 440 | * |
@@ -465,6 +467,18 @@ const struct GNUNET_DISK_FileHandle * | |||
465 | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, | 467 | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, |
466 | enum GNUNET_DISK_PipeEnd n); | 468 | enum GNUNET_DISK_PipeEnd n); |
467 | 469 | ||
470 | |||
471 | /** | ||
472 | * Get a handle from a native FD. | ||
473 | * | ||
474 | * @param fd native file descriptor | ||
475 | * @return file handle corresponding to the descriptor | ||
476 | */ | ||
477 | const struct GNUNET_DISK_FileHandle * | ||
478 | GNUNET_DISK_get_handle_from_native (FILE *fd); | ||
479 | |||
480 | |||
481 | |||
468 | /** | 482 | /** |
469 | * Read the contents of a binary file into a buffer. | 483 | * Read the contents of a binary file into a buffer. |
470 | * @param h handle to an open file | 484 | * @param h handle to an open file |
@@ -476,6 +490,7 @@ ssize_t | |||
476 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, | 490 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, |
477 | size_t len); | 491 | size_t len); |
478 | 492 | ||
493 | |||
479 | /** | 494 | /** |
480 | * Read the contents of a binary file into a buffer. | 495 | * Read the contents of a binary file into a buffer. |
481 | * Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN | 496 | * Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN |
@@ -488,7 +503,8 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, | |||
488 | */ | 503 | */ |
489 | ssize_t | 504 | ssize_t |
490 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, | 505 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, |
491 | void *result, size_t len); | 506 | void *result, size_t len); |
507 | |||
492 | 508 | ||
493 | /** | 509 | /** |
494 | * Read the contents of a binary file into a buffer. | 510 | * Read the contents of a binary file into a buffer. |
diff --git a/src/util/disk.c b/src/util/disk.c index ecd361ba1..32263584b 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1775,6 +1775,33 @@ GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h) | |||
1775 | 1775 | ||
1776 | 1776 | ||
1777 | /** | 1777 | /** |
1778 | * Get a handle from a native FD. | ||
1779 | * | ||
1780 | * @param fd native file descriptor | ||
1781 | * @return file handle corresponding to the descriptor | ||
1782 | */ | ||
1783 | struct GNUNET_DISK_FileHandle * | ||
1784 | GNUNET_DISK_get_handle_from_native (FILE *fd) | ||
1785 | { | ||
1786 | #if MINGW | ||
1787 | // FIXME: LRN help! | ||
1788 | GNUNET_break (0); | ||
1789 | return NULL; | ||
1790 | #else | ||
1791 | struct GNUNET_DISK_FileHandle *fh; | ||
1792 | int fno; | ||
1793 | |||
1794 | fno = fileno (fd); | ||
1795 | if (-1 == fno) | ||
1796 | return NULL; | ||
1797 | fh = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); | ||
1798 | fh->fd = fno; | ||
1799 | return fh; | ||
1800 | #endif | ||
1801 | } | ||
1802 | |||
1803 | |||
1804 | /** | ||
1778 | * Construct full path to a file inside of the private | 1805 | * Construct full path to a file inside of the private |
1779 | * directory used by GNUnet. Also creates the corresponding | 1806 | * directory used by GNUnet. Also creates the corresponding |
1780 | * directory. If the resulting name is supposed to be | 1807 | * directory. If the resulting name is supposed to be |