From 8ad22290df34c73881f42f02cdd28551ec265077 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 29 Sep 2023 11:01:50 +0900 Subject: [PATCH] gpgme-tool: Support use of Windows HANDLE for INPUT/OUTPUT/MESSAGE. * src/gpgme-tool.c [HAVE_W32_SYSTEM] (server_data_obj): Implement for Windows HANDLE. -- GnuPG-bug-id: 6634 Signed-off-by: NIIBE Yutaka --- src/gpgme-tool.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 7d3ca16d..0aa24510 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -1909,7 +1909,19 @@ server_data_obj (assuan_fd_t fd, char *fn, int out, err = gpgme_data_new_from_stream (data, *fs); } else - err = gpgme_data_new_from_fd (data, (int) fd); + { + int posix_fd; + +#if defined(HAVE_W32_SYSTEM) + posix_fd = _open_osfhandle ((intptr_t)fd, out ? 1 : 0); + if (posix_fd == -1) + return gpg_error_from_syserror (); +#else + posix_fd = fd; +#endif + + err = gpgme_data_new_from_fd (data, posix_fd); + } if (err) return err;