diff options
author | NIIBE Yutaka <[email protected]> | 2023-07-07 06:07:34 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-07-10 02:22:43 +0000 |
commit | 37343db08f4aaa36a0f58d2ecf50e7fbba4cacd7 (patch) | |
tree | be0f1034812739c231bd3871ceeb36ca8a4009cf /common/sysutils.c | |
parent | common:w32: Fix gnupg_w32_set_errno. (diff) | |
download | gnupg-37343db08f4aaa36a0f58d2ecf50e7fbba4cacd7.tar.gz gnupg-37343db08f4aaa36a0f58d2ecf50e7fbba4cacd7.zip |
common,gpg,kbx: Factor out open_stream_nc.
* common/sysutils.h (open_stream_nc): New.
* common/sysutils.c (open_stream_nc): New.
* g10/decrypt.c (decrypt_message_fd): Use open_stream_nc.
* g10/server.c (cmd_verify): Likewise.
* kbx/kbxserver.c (prepare_outstream): Likewise.
--
GnuPG-bug-id: 6580
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/sysutils.c')
-rw-r--r-- | common/sysutils.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/sysutils.c b/common/sysutils.c index 73690a760..745b762ba 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -1931,3 +1931,22 @@ gnupg_fd_valid (int fd) close (d); return 1; } + + +/* Open a stream from FD (a file descriptor on POSIX, a system + handle on Windows), non-closed. */ +estream_t +open_stream_nc (gnupg_fd_t fd, const char *mode) +{ + es_syshd_t syshd; + +#ifdef HAVE_W32_SYSTEM + syshd.type = ES_SYSHD_HANDLE; + syshd.u.handle = fd; +#else + syshd.type = ES_SYSHD_FD; + syshd.u.fd = fd; +#endif + + return es_sysopen_nc (&syshd, mode); +} |