From b41cc03c891deac4bb35af3c88f8b635ebfb632c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 25 Nov 2009 17:55:26 +0000 Subject: doc/ 2009-11-25 Marcus Brinkmann * assuan.texi (Data Types): Document assuan_fdopen. src/ 2009-11-25 Marcus Brinkmann * assuan.h (assuan_init_pipe_server): Change type of filedes to assuan_fd_t. (assuan_fdopen): New prototype. * libassuan.vers, libassuan.def: Add assuan_fdopen. * system.c (assuan_fdopen): New function. * assuan-pipe-server.c (assuan_init_pipe_server): Change type of filedes to assuan_fd_t. No longer translate fd to handle. Don't set to binary either (that doesn't do anything for handles, it only affects the libc fd). --- src/system.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/system.c') diff --git a/src/system.c b/src/system.c index ab9e5a1..852ec11 100644 --- a/src/system.c +++ b/src/system.c @@ -43,6 +43,27 @@ #define MAX_OPEN_FDS 20 #endif + +assuan_fd_t +assuan_fdopen (int fd) +{ +#ifdef HAVE_W32_SYSTEM + assuan_fd_t ifd = (assuan_fd_t) _get_osfhandle (fd); + assuan_fd_t ofd; + + if (! DuplicateHandle(GetCurrentProcess(), hfd, + GetCurrentProcess(), &ofd, 0, + TRUE, DUPLICATE_SAME_ACCESS)) + { + errno = EIO; + return ASSUAN_INVALID_FD: + } + return ofd; +#else + return dup (fd); +#endif +} + /* Manage memory specific to a context. */ -- cgit v1.2.3