From a860f21aca683099c1647493a0463fc0b9afd425 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Wed, 8 Apr 2015 18:28:49 -0400 Subject: [PATCH] Add PWMD_OPTION_SERVER_VERSION. To retrieve the pwmd server version after connecting. One less redundant call a client has to make. --- doc/libpwmd.3 | 7 +++++-- src/libpwmd.c | 15 +++++++++++++++ src/libpwmd.h.in | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/libpwmd.3 b/doc/libpwmd.3 index fa476354..1bfa68dc 100644 --- a/doc/libpwmd.3 +++ b/doc/libpwmd.3 @@ -1,4 +1,4 @@ -.TH "libpwmd.h" 3 "Fri Oct 31 2014" "Version 7.3.0" "libpwmd" \" -*- nroff -*- +.TH "libpwmd.h" 3 "Wed Apr 8 2015" "Version 7.3.0" "libpwmd" \" -*- nroff -*- .ad l .nh .SH NAME @@ -151,7 +151,7 @@ libgpg-error returns an error code as a bitmask of an error source and the error .RI "enum \fBpwmd_pinentry_t\fP { \fBPWMD_PINENTRY_OPEN\fP, \fBPWMD_PINENTRY_OPEN_FAILED\fP, \fBPWMD_PINENTRY_SAVE\fP, \fBPWMD_PINENTRY_SAVE_CONFIRM\fP, \fBPWMD_PINENTRY_SAVE_FAILED\fP, \fBPWMD_PINENTRY_CONFIRM\fP, \fBPWMD_PINENTRY_USER\fP, \fBPWMD_PINENTRY_CLOSE\fP }" .br .ti -1c -.RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_ERROR\fP, \fBPWMD_OPTION_PINENTRY_PROMPT\fP, \fBPWMD_OPTION_PINENTRY_DESC\fP, \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP, \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP, \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_KNOWNHOST_CB\fP, \fBPWMD_OPTION_KNOWNHOST_DATA\fP, \fBPWMD_OPTION_INQUIRE_TOTAL\fP, \fBPWMD_OPTION_LOCK_ON_OPEN\fP, \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBPWMD_OPTION_TLS_VERIFY\fP, \fBPWMD_OPTION_SIGPIPE\fP }" +.RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_ERROR\fP, \fBPWMD_OPTION_PINENTRY_PROMPT\fP, \fBPWMD_OPTION_PINENTRY_DESC\fP, \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP, \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP, \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_KNOWNHOST_CB\fP, \fBPWMD_OPTION_KNOWNHOST_DATA\fP, \fBPWMD_OPTION_INQUIRE_TOTAL\fP, \fBPWMD_OPTION_LOCK_ON_OPEN\fP, \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBPWMD_OPTION_TLS_VERIFY\fP, \fBPWMD_OPTION_SIGPIPE\fP, \fBPWMD_OPTION_SERVER_VERSION\fP }" .br .in -1c .SS "Functions" @@ -575,6 +575,9 @@ An int specifying whether to enable TLS hostname verification on the server cert .TP \fB\fIPWMD_OPTION_SIGPIPE \fP\fP Set to 1 to not modify the signal handler to ignore SIGPIPE\&. The default is 0, or to ignore this signal\&. +.TP +\fB\fIPWMD_OPTION_SERVER_VERSION \fP\fP +Get the version of the pwmd server as an unsigned integer\&. This is a read-only setting and is only available after connecting\&. .SS "enum \fBpwmd_pinentry_t\fP" .PP diff --git a/src/libpwmd.c b/src/libpwmd.c index cd6d148f..fdd341a3 100644 --- a/src/libpwmd.c +++ b/src/libpwmd.c @@ -1373,6 +1373,21 @@ pwmd_get_set_opt (pwm_t *pwm, pwmd_option_t opt, int get, va_list ap) switch (opt) { + case PWMD_OPTION_SERVER_VERSION: + if (!get) + return GPG_ERR_NOT_SUPPORTED; + + if (!pwm) + rc = GPG_ERR_INV_ARG; + else if (!pwm->ctx) + rc = GPG_ERR_INV_STATE; + else + { + unsigned *u = va_arg (ap, unsigned *); + *u = pwm->version; + } + + break; case PWMD_OPTION_SIGPIPE: if (get) { diff --git a/src/libpwmd.h.in b/src/libpwmd.h.in index c34cfc47..11d5a673 100644 --- a/src/libpwmd.h.in +++ b/src/libpwmd.h.in @@ -509,6 +509,10 @@ typedef enum /*! Set to 1 to not modify the signal handler to ignore SIGPIPE. The default * is 0, or to ignore this signal. */ PWMD_OPTION_SIGPIPE, + + /*! Get the version of the pwmd server as an unsigned integer. This is a + * read-only setting and is only available after connecting. */ + PWMD_OPTION_SERVER_VERSION, } pwmd_option_t; -- 2.11.4.GIT