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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-07-13 13:57:14 +02:00
parent 537cb871fd
commit 2095b1573a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
9 changed files with 42 additions and 9 deletions

View File

@ -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 ();

View File

@ -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);

View File

@ -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 ();

View File

@ -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;

View File

@ -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 ();

View File

@ -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 ();

View File

@ -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)

View File

@ -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 ();

View File

@ -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);