From 67ed21d67e9658822e943a6aa64527aa8d7ba69b Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Wed, 25 Mar 2009 21:00:12 -0400 Subject: [PATCH] Added pwmd_get_fd2() to return the FD used by pwmd_open_async2() and pwmd_save_async2(). --- src/libpwmd.c | 16 ++++++++++++++++ src/libpwmd.h.in | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/src/libpwmd.c b/src/libpwmd.c index 247434d2..5ee06110 100644 --- a/src/libpwmd.c +++ b/src/libpwmd.c @@ -2283,6 +2283,22 @@ gpg_error_t pwmd_get_fd(pwm_t *pwm, int *fd) return 0; } +gpg_error_t pwmd_get_fd2(pwm_t *pwm, int *fd) +{ +#ifndef WITH_PINENTRY + return GPG_ERR_NOT_IMPLEMENTED; +#else + if (!pwm) + return GPG_ERR_INV_ARG; + + if (pwm->nb_fd == -1) + return GPG_ERR_INV_STATE; + + *fd = pwm->nb_fd; + return 0; +#endif +} + pwm_t *pwmd_new(const char *name) { pwm_t *h = pwmd_calloc(1, sizeof(pwm_t)); diff --git a/src/libpwmd.h.in b/src/libpwmd.h.in index ace09e11..e0fc4229 100644 --- a/src/libpwmd.h.in +++ b/src/libpwmd.h.in @@ -266,6 +266,13 @@ gpg_error_t pwmd_get_hostkey_async(pwm_t *pwm, const char *hostname, int port) _ */ gpg_error_t pwmd_get_fd(pwm_t *pwm, int *fd) __attribute__ ((warn_unused_result)); +/* This sets fd to the file descriptor used in the pwmd_open_async2() and + * pwmd_save_async2() functions. Returns 0 on success or an error which would + * only happen if the file decsriptor is invalid (the metioned functions + * haven't been called). + */ +gpg_error_t pwmd_get_fd2(pwm_t *pwm, int *fd) __attribute__ ((warn_unused_result)); + /* Returns 0 if there is a pending (buffered) line needing to be processed. In * this case, pwmd_process() should be called. Returns GPG_ERR_NO_DATA if * there is no pending line. -- 2.11.4.GIT