From cacb01899224a4b5370b96f16f1844a1ef510b3f Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 28 Jun 2023 13:59:52 +0900 Subject: tools:gpgtar: Clean up the use of --status-fd. * common/sysutils.c (gnupg_parse_fdstr): Rename from gnupg_sys2libc_fdstr, as there is no translation any more. * common/sysutils.h (gnupg_parse_fdstr): Rename from gnupg_sys2libc_fdstr. * tools/gpgtar.c (main): Use gnupg_parse_fdstr, in cleaner way. -- GnuPG-bug-id: 6562 Signed-off-by: NIIBE Yutaka --- tools/gpgtar.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'tools/gpgtar.c') diff --git a/tools/gpgtar.c b/tools/gpgtar.c index 01efacc7d..ace5e5978 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -511,49 +511,30 @@ main (int argc, char **argv) * status fd is passed verbatim to gpg. */ if (opt.status_fd) { - int fd = -1; + es_syshd_t syshd; -#ifdef HAVE_W32_SYSTEM - gnupg_fd_t hd; - - err = gnupg_sys2libc_fdstr (opt.status_fd, 1, &hd, NULL); - if ((uintptr_t)hd == 1) - fd = 1; - else if ((uintptr_t)hd == 2) - fd = 2; -#else - err = gnupg_sys2libc_fdstr (opt.status_fd, 1, NULL, &fd); -#endif + err = gnupg_parse_fdstr (opt.status_fd, &syshd); if (err) log_fatal ("status-fd is invalid: %s\n", gpg_strerror (err)); - if (fd == 1) + if (syshd.type == ES_SYSHD_FD && syshd.u.fd == 1) { opt.status_stream = es_stdout; if (!skip_crypto) log_fatal ("using stdout for the status-fd is not possible\n"); } - else if (fd == 2) + else if (syshd.type == ES_SYSHD_FD && syshd.u.fd == 2) opt.status_stream = es_stderr; else { - es_syshd_t syshd; - -#ifdef HAVE_W32_SYSTEM - syshd.type = ES_SYSHD_HANDLE; - syshd.u.handle = hd; -#else - syshd.type = ES_SYSHD_FD; - syshd.u.fd = fd; -#endif opt.status_stream = es_sysopen (&syshd, "w"); if (opt.status_stream) es_setvbuf (opt.status_stream, NULL, _IOLBF, 0); } if (!opt.status_stream) { - log_fatal ("can't open fd %d for status output: %s\n", - fd, strerror (errno)); + log_fatal ("can't open fd %s for status output: %s\n", + opt.status_fd, strerror (errno)); } } -- cgit v1.2.3