diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/sysutils.c | 44 | ||||
-rw-r--r-- | common/sysutils.h | 2 |
2 files changed, 20 insertions, 26 deletions
diff --git a/common/sysutils.c b/common/sysutils.c index 7c3667ce7..042387297 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -556,6 +556,24 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write) #endif } +/* This is the same as translate_sys2libc_fd but takes an integer + which is assumed to be such an system handle. On WindowsCE the + passed FD is a rendezvous ID and the function finishes the pipe + creation. */ +int +translate_sys2libc_fd_int (int fd, int for_write) +{ +#ifdef HAVE_W32_SYSTEM + if (fd <= 2) + return fd; /* Do not do this for error, stdin, stdout, stderr. */ + + return translate_sys2libc_fd ((void*)fd, for_write); +#else + (void)for_write; + return fd; +#endif +} + /* * Parse the string representation of a file reference (file handle on @@ -636,30 +654,6 @@ gnupg_sys2libc_fdstr (const char *fdstr, int for_write, #endif } -/* This is the same as translate_sys2libc_fd but takes a string - which represents a system handle on Windows a file descriptor - on POSIX. - - (1) 0, 1, or 2 which means stdin, stdout, and stderr, respectively. - (2) Integer representation (by %d of printf). - (3) Hex representation which starts as "0x". -*/ -int -translate_sys2libc_fdstr (const char *fdstr, int for_write) -{ - gpg_error_t err; - int fd; - - err = gnupg_sys2libc_fdstr (fdstr, for_write, NULL, &fd); - if (err) - { - log_error ("FDSTR error: %s\n", fdstr); - return -1; - } - - return fd; -} - /* Check whether FNAME has the form "-&nnnn", where N is a non-zero * number. Returns this number or -1 if it is not the case. If the @@ -679,7 +673,7 @@ check_special_filename (const char *fname, int for_write, int notranslate) ; if (!fname[i]) return notranslate? atoi (fname) - /**/ : translate_sys2libc_fdstr (fname, for_write); + /**/ : translate_sys2libc_fd_int (atoi (fname), for_write); } return -1; } diff --git a/common/sysutils.h b/common/sysutils.h index 380a6d9a9..95cbc0bec 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -73,9 +73,9 @@ unsigned int get_uint_nonce (void); void gnupg_sleep (unsigned int seconds); void gnupg_usleep (unsigned int usecs); int translate_sys2libc_fd (gnupg_fd_t fd, int for_write); +int translate_sys2libc_fd_int (int fd, int for_write); gpg_error_t gnupg_sys2libc_fdstr (const char *fdstr, int for_write, gnupg_fd_t *r_hd, int *r_fd); -int translate_sys2libc_fdstr (const char *fdstr, int for_write); int check_special_filename (const char *fname, int for_write, int notranslate); FILE *gnupg_tmpfile (void); void gnupg_reopen_std (const char *pgmname); |