summaryrefslogtreecommitdiff
path: root/src/assuan-pipe-server.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-12-19 13:34:54 +0000
committerWerner Koch <wk@gnupg.org>2004-12-19 13:34:54 +0000
commit90e65a7d672e6b56148393ff2b6f8c52bc081ae5 (patch)
treeb88ad30983d4772bce6c7225b7ec54fe00bea1ee /src/assuan-pipe-server.c
parent06d9a26a0ccc8873530679f54bf58e3df5bdb23a (diff)
downloadlibassuan-90e65a7d672e6b56148393ff2b6f8c52bc081ae5.tar.gz
(assuan_init_pipe_server) [W32]: Map file
descriptors using _get_osfhandle.
Diffstat (limited to 'src/assuan-pipe-server.c')
-rw-r--r--src/assuan-pipe-server.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/assuan-pipe-server.c b/src/assuan-pipe-server.c
index 7b2d643..beff9a3 100644
--- a/src/assuan-pipe-server.c
+++ b/src/assuan-pipe-server.c
@@ -22,9 +22,14 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#ifdef HAVE_W32_SYSTEM
+#include <windows.h>
+#include <fcntl.h>
+#endif
#include "assuan-defs.h"
+
static void
deinit_pipe_server (ASSUAN_CONTEXT ctx)
{
@@ -83,7 +88,6 @@ _assuan_new_context (ASSUAN_CONTEXT *r_ctx)
}
-
int
assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
{
@@ -97,8 +101,18 @@ assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
unsigned long ul;
ctx->is_server = 1;
- ctx->inbound.fd = filedes[0];
+#ifdef HAVE_W32_SYSTEM
+ /* MS Windows has so many different types of handle that one
+ needs to tranlsate them at many place forth and back. Also
+ make sure that the fiel descriptos are in binary mode. */
+ setmode (filedes[0], O_BINARY);
+ setmode (filedes[1], O_BINARY);
+ ctx->inbound.fd = _get_osfhandle (filedes[0]);
+ ctx->outbound.fd = _get_osfhandle (filedes[1]);
+#else
+ ctx->inbound.fd = filedes[0];
ctx->outbound.fd = filedes[1];
+#endif
ctx->pipe_mode = 1;
s = getenv ("_assuan_pipe_connect_pid");