1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

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 <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-06-28 13:59:52 +09:00
parent 7cfbf0dd72
commit cacb018992
No known key found for this signature in database
GPG key ID: 640114AF89DE6054
3 changed files with 15 additions and 51 deletions

View file

@ -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));
}
}