From bb600aa8fd2f9575ee7afc64c978e3e7523b1173 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 28 Oct 2015 16:24:30 +0100 Subject: w32: Add new global flag "w32-inst-dir". * src/gpgme.c (gpgme_set_global_flag): Add flag "w32-inst-dir"; * src/posix-util.c (_gpgme_set_override_inst_dir): New stub. * src/w32-util.c (override_inst_dir): New var. (_gpgme_get_inst_dir): Return this var is set. (_gpgme_set_override_inst_dir): New. -- See https://lists.gnupg.org/pipermail/gnupg-devel/2015-September/030267.html for background. Signed-off-by: Werner Koch --- src/w32-util.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/w32-util.c') diff --git a/src/w32-util.c b/src/w32-util.c index 9aba26f5..f611b6c0 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -85,7 +85,10 @@ static HMODULE my_hmodule; binaries. The are set only once by gpgme_set_global_flag. */ static char *default_gpg_name; static char *default_gpgconf_name; - +/* If this variable is not NULL the value is assumed to be the + installation directory. The variable may only be set once by + gpgme_set_global_flag and accessed by _gpgme_get_inst_dir. */ +static char *override_inst_dir; #ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW @@ -347,6 +350,9 @@ _gpgme_get_inst_dir (void) { static char *inst_dir; + if (override_inst_dir) + return override_inst_dir; + LOCK (get_path_lock); if (!inst_dir) { @@ -456,6 +462,28 @@ _gpgme_set_default_gpgconf_name (const char *name) } +/* Set the override installation directory. This function may only be + called by gpgme_set_global_flag. Returns 0 on success. */ +int +_gpgme_set_override_inst_dir (const char *dir) +{ + if (!override_inst_dir) + { + override_inst_dir = malloc (strlen (dir) + 1); + if (override_inst_dir) + { + strcpy (override_inst_dir, dir); + replace_slashes (override_inst_dir); + /* Remove a trailing slash. */ + if (*override_inst_dir + && override_inst_dir[strlen (override_inst_dir)-1] == '\\') + override_inst_dir[strlen (override_inst_dir)-1] = 0; + } + } + return !override_inst_dir; +} + + /* Return the full file name of the GPG binary. This function is used iff gpgconf was not found and thus it can be assumed that gpg2 is not installed. This function is only called by get_gpgconf_item -- cgit v1.2.3