From 0ea63d327065b2cbd6f6d0f1a338fa75b800acc6 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Tue, 24 Mar 2009 19:32:02 -0400 Subject: [PATCH] Re-add pwmd_pending_line(). The difference is that assuan_read_line() won't be called. Rather pwmd_process() should be called but only when not in a command. --- src/libpwmd.c | 14 +++++++++++++- src/libpwmd.h.in | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libpwmd.c b/src/libpwmd.c index edb1cadb..fad09bfc 100644 --- a/src/libpwmd.c +++ b/src/libpwmd.c @@ -1068,6 +1068,17 @@ static gpg_error_t parse_assuan_line(pwm_t *pwm) return rc; } +gpg_error_t pwmd_pending_line(pwm_t *pwm) +{ + if (!pwm) + return GPG_ERR_INV_ARG; + + if (!pwm->ctx) + return GPG_ERR_INV_STATE; + + return assuan_pending_line(pwm->ctx) ? 0 : GPG_ERR_NO_DATA; +} + pwmd_async_t pwmd_process(pwm_t *pwm, gpg_error_t *rc, const char **result) { fd_set fds; @@ -1087,7 +1098,8 @@ pwmd_async_t pwmd_process(pwm_t *pwm, gpg_error_t *rc, const char **result) /* When not in a command, this will let libassuan process status messages * by calling PWMD_OPTION_STATUS_FUNC. The client can poll the file * descriptor returned by pwmd_get_fd() to determine when this should be - * called. */ + * called or call pwmd_pending_line() to determine whether a buffered line + * needs to be processed. */ if (pwm->cmd == ASYNC_CMD_NONE) { *rc = assuan_command(pwm, pwm->ctx, NULL, "NOP"); return pwm->state; diff --git a/src/libpwmd.h.in b/src/libpwmd.h.in index 52bcbeda..6842a612 100644 --- a/src/libpwmd.h.in +++ b/src/libpwmd.h.in @@ -285,6 +285,15 @@ 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)); +/* 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. + * + * Pending lines usually only happen when out of a command (not a running + * command) and are usually status messages. + */ +gpg_error_t pwmd_pending_line(pwm_t *pwm) __attribute__ ((warn_unused_result)); + /* * Sets a libpwmd option 'opt'. The next argument should be of the data type * required for the option. Returns 0 on success or an error code. -- 2.11.4.GIT