aboutsummaryrefslogtreecommitdiffstats
path: root/common/asshelp.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-01-08 05:42:29 +0000
committerWerner Koch <[email protected]>2016-01-08 05:42:29 +0000
commit496643291e1e346434e9c98405c5a370957eb7d3 (patch)
treee14c574127f53f58397ef9a2e00841632c9db258 /common/asshelp.c
parentcommon: New put_membuf_cb to replace static membuf_data_cb. (diff)
downloadgnupg-496643291e1e346434e9c98405c5a370957eb7d3.tar.gz
gnupg-496643291e1e346434e9c98405c5a370957eb7d3.zip
common: New function get_assuan_server_version.
* common/asshelp.c: Include membuf.h. (get_assuan_server_version): New. * g10/call-agent.c (agent_get_version): Use new function. -- Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--common/asshelp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/common/asshelp.c b/common/asshelp.c
index d33ffb556..f2b4402e1 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -42,6 +42,7 @@
#include "exechelp.h"
#include "sysutils.h"
#include "status.h"
+#include "membuf.h"
#include "asshelp.h"
/* The type we use for lock_agent_spawning. */
@@ -699,3 +700,40 @@ start_new_dirmngr (assuan_context_t *r_ctx,
*r_ctx = ctx;
return 0;
}
+
+
+/* Return the version of a server using "GETINFO version". On success
+ 0 is returned and R_VERSION receives a malloced string with the
+ version which must be freed by the caller. On error NULL is stored
+ at R_VERSION and an error code returned. Mode is in general 0 but
+ certian values may be used to modify the used version command:
+
+ MODE == 0 = Use "GETINFO version"
+ MODE == 2 - Use "SCD GETINFO version"
+ */
+gpg_error_t
+get_assuan_server_version (assuan_context_t ctx, int mode, char **r_version)
+{
+ gpg_error_t err;
+ membuf_t data;
+
+ init_membuf (&data, 64);
+ err = assuan_transact (ctx,
+ mode == 2? "SCD GETINFO version"
+ /**/ : "GETINFO version",
+ put_membuf_cb, &data,
+ NULL, NULL, NULL, NULL);
+ if (err)
+ {
+ xfree (get_membuf (&data, NULL));
+ *r_version = NULL;
+ }
+ else
+ {
+ put_membuf (&data, "", 1);
+ *r_version = get_membuf (&data, NULL);
+ if (!*r_version)
+ err = gpg_error_from_syserror ();
+ }
+ return err;
+}