From 2095b1573a8196ba3efdf817324d1b3ee05cbb93 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 13 Jul 2016 13:57:14 +0200 Subject: [PATCH] core: Pass the engine's version string to the engine's new function. * src/engine-backend.h (engine_ops): Add arg 'version' to NEW. * src/engine-assuan.c (llass_new): Add dummy arg 'version'. * src/engine-g13.c (g13_new): Ditto. * src/engine-gpgconf.c (gpgconf_new): Ditto. * src/engine-gpgsm.c (gpgsm_new): Ditto. * src/engine-spawn.c (engspawn_new): Ditto. * src/engine-uiserver.c (uiserver_new): Ditto. * src/engine.c (_gpgme_engine_new): Pass version string to the new function. * src/engine-gpg.c (struct engine_gpg): Add field 'version'. (gpg_new): Add arg 'version'. (gpg_release): Free VERSION. Signed-off-by: Werner Koch --- src/engine-assuan.c | 5 ++++- src/engine-backend.h | 3 ++- src/engine-g13.c | 5 ++++- src/engine-gpg.c | 16 +++++++++++++++- src/engine-gpgconf.c | 5 ++++- src/engine-gpgsm.c | 5 ++++- src/engine-spawn.c | 4 +++- src/engine-uiserver.c | 5 ++++- src/engine.c | 3 ++- 9 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/engine-assuan.c b/src/engine-assuan.c index a3960067..6f58e086 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -212,12 +212,15 @@ llass_release (void *engine) /* Create a new instance. If HOME_DIR is NULL standard options for use with gpg-agent are issued. */ static gpgme_error_t -llass_new (void **engine, const char *file_name, const char *home_dir) +llass_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { gpgme_error_t err = 0; engine_llass_t llass; char *optstr; + (void)version; /* Not yet used. */ + llass = calloc (1, sizeof *llass); if (!llass) return gpg_error_from_syserror (); diff --git a/src/engine-backend.h b/src/engine-backend.h index ea7db144..a15194e6 100644 --- a/src/engine-backend.h +++ b/src/engine-backend.h @@ -44,7 +44,8 @@ struct engine_ops const char *(*get_req_version) (void); gpgme_error_t (*new) (void **r_engine, - const char *file_name, const char *home_dir); + const char *file_name, const char *home_dir, + const char *version); /* Member functions. */ void (*release) (void *engine); diff --git a/src/engine-g13.c b/src/engine-g13.c index 8f24f4c2..afb085d6 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -212,7 +212,8 @@ g13_release (void *engine) static gpgme_error_t -g13_new (void **engine, const char *file_name, const char *home_dir) +g13_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { gpgme_error_t err = 0; engine_g13_t g13; @@ -224,6 +225,8 @@ g13_new (void **engine, const char *file_name, const char *home_dir) char *dft_ttytype = NULL; char *optstr; + (void)version; /* Not yet used. */ + g13 = calloc (1, sizeof *g13); if (!g13) return gpg_error_from_syserror (); diff --git a/src/engine-gpg.c b/src/engine-gpg.c index e507c683..e279f04b 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -78,6 +78,7 @@ typedef gpgme_error_t (*colon_preprocessor_t) (char *line, char **rline); struct engine_gpg { char *file_name; + char *version; char *lc_messages; char *lc_ctype; @@ -388,6 +389,8 @@ gpg_release (void *engine) if (gpg->file_name) free (gpg->file_name); + if (gpg->version) + free (gpg->version); if (gpg->lc_messages) free (gpg->lc_messages); @@ -416,7 +419,8 @@ gpg_release (void *engine) static gpgme_error_t -gpg_new (void **engine, const char *file_name, const char *home_dir) +gpg_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { engine_gpg_t gpg; gpgme_error_t rc = 0; @@ -438,6 +442,16 @@ gpg_new (void **engine, const char *file_name, const char *home_dir) } } + if (version) + { + gpg->version = strdup (version); + if (!gpg->version) + { + rc = gpg_error_from_syserror (); + goto leave; + } + } + gpg->argtail = &gpg->arglist; gpg->status.fd[0] = -1; gpg->status.fd[1] = -1; diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c index bcc95225..2e25d767 100644 --- a/src/engine-gpgconf.c +++ b/src/engine-gpgconf.c @@ -90,11 +90,14 @@ gpgconf_release (void *engine) static gpgme_error_t -gpgconf_new (void **engine, const char *file_name, const char *home_dir) +gpgconf_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { gpgme_error_t err = 0; engine_gpgconf_t gpgconf; + (void)version; /* Not yet used. */ + gpgconf = calloc (1, sizeof *gpgconf); if (!gpgconf) return gpg_error_from_syserror (); diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 3aa9f0bf..d4a1cf77 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -237,7 +237,8 @@ gpgsm_release (void *engine) static gpgme_error_t -gpgsm_new (void **engine, const char *file_name, const char *home_dir) +gpgsm_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { gpgme_error_t err = 0; engine_gpgsm_t gpgsm; @@ -253,6 +254,8 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir) char *dft_ttytype = NULL; char *optstr; + (void)version; /* Not yet used. */ + gpgsm = calloc (1, sizeof *gpgsm); if (!gpgsm) return gpg_error_from_syserror (); diff --git a/src/engine-spawn.c b/src/engine-spawn.c index 3674efb2..b552388e 100644 --- a/src/engine-spawn.c +++ b/src/engine-spawn.c @@ -324,12 +324,14 @@ engspawn_get_req_version (void) static gpgme_error_t -engspawn_new (void **engine, const char *file_name, const char *home_dir) +engspawn_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { engine_spawn_t esp; (void)file_name; (void)home_dir; + (void)version; esp = calloc (1, sizeof *esp); if (!esp) diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index d05ade61..986f1d1d 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -238,7 +238,8 @@ uiserver_release (void *engine) static gpgme_error_t -uiserver_new (void **engine, const char *file_name, const char *home_dir) +uiserver_new (void **engine, const char *file_name, const char *home_dir, + const char *version) { gpgme_error_t err = 0; engine_uiserver_t uiserver; @@ -247,6 +248,8 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir) char *dft_ttytype = NULL; char *optstr; + (void)version; /* Not yet used. */ + uiserver = calloc (1, sizeof *uiserver); if (!uiserver) return gpg_error_from_syserror (); diff --git a/src/engine.c b/src/engine.c index c9449db1..4e59adad 100644 --- a/src/engine.c +++ b/src/engine.c @@ -463,7 +463,8 @@ _gpgme_engine_new (gpgme_engine_info_t info, engine_t *r_engine) { gpgme_error_t err; err = (*engine->ops->new) (&engine->engine, - info->file_name, info->home_dir); + info->file_name, info->home_dir, + info->version); if (err) { free (engine);