diff options
author | Justus Winter <[email protected]> | 2016-10-18 11:55:12 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-10-18 16:54:49 +0000 |
commit | f2d39a6d051413289c717b9cd2dc387a270b8e7c (patch) | |
tree | a77ee62a58e54cdf86aba40891fec9a957674ebb /common/exechelp-w32.c | |
parent | common,w32: Make use of default_errsource in exechelp. (diff) | |
download | gnupg-f2d39a6d051413289c717b9cd2dc387a270b8e7c.tar.gz gnupg-f2d39a6d051413289c717b9cd2dc387a270b8e7c.zip |
common,w32: Extend gnupg_create_inbound_pipe et al.
* common/exechelp-w32.c (do_create_pipe): Rename, add arguments, and
create a stream if reqested.
(gnupg_create_inbound_pipe): Use the extended function to open the
stream if requested.
(gnupg_create_outbound_pipe): Likewise.
(gnupg_create_pipe): Update call site.
Fixes-commit: 5d991e333a1885adc40abd9d00c01fec4bd5d9d7
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'common/exechelp-w32.c')
-rw-r--r-- | common/exechelp-w32.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index 418eb9b55..c5d6b08da 100644 --- a/common/exechelp-w32.c +++ b/common/exechelp-w32.c @@ -301,7 +301,8 @@ w32_open_null (int for_write) static gpg_error_t -do_create_pipe (int filedes[2], int flags) +create_pipe_and_estream (int filedes[2], int flags, + estream_t *r_fp, int outbound, int nonblock) { gpg_error_t err = 0; HANDLE fds[2]; @@ -330,6 +331,25 @@ do_create_pipe (int filedes[2], int flags) err = 0; } } + + if (! err && r_fp) + { + if (!outbound) + *r_fp = es_fdopen (filedes[0], nonblock? "r,nonblock" : "r"); + else + *r_fp = es_fdopen (filedes[1], nonblock? "w,nonblock" : "w"); + if (!*r_fp) + { + err = my_error_from_syserror (); + log_error (_("error creating a stream for a pipe: %s\n"), + gpg_strerror (err)); + close (filedes[0]); + close (filedes[1]); + filedes[0] = filedes[1] = -1; + return err; + } + } + return err; } @@ -339,10 +359,8 @@ do_create_pipe (int filedes[2], int flags) gpg_error_t gnupg_create_inbound_pipe (int filedes[2], estream_t *r_fp, int nonblock) { - if (r_fp) - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); - else - return do_create_pipe (filedes, INHERIT_WRITE); + return create_pipe_and_estream (filedes, INHERIT_WRITE, + r_fp, 0, nonblock); } @@ -352,10 +370,8 @@ gnupg_create_inbound_pipe (int filedes[2], estream_t *r_fp, int nonblock) gpg_error_t gnupg_create_outbound_pipe (int filedes[2], estream_t *r_fp, int nonblock) { - if (r_fp) - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); - else - return do_create_pipe (filedes, INHERIT_READ); + return create_pipe_and_estream (filedes, INHERIT_READ, + r_fp, 1, nonblock); } @@ -364,7 +380,8 @@ gnupg_create_outbound_pipe (int filedes[2], estream_t *r_fp, int nonblock) gpg_error_t gnupg_create_pipe (int filedes[2]) { - return do_create_pipe (filedes, INHERIT_BOTH); + return create_pipe_and_estream (filedes, INHERIT_BOTH, + NULL, 0, 0); } |