diff options
| author | Werner Koch <[email protected]> | 2014-01-06 16:16:52 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2014-01-06 16:16:52 +0000 | 
| commit | 6564e5e78e8c6e5a120675a5699b5b75248cfbc7 (patch) | |
| tree | f60419297debdcd94c12f9c05dc7918b759c2200 /src/posix-util.c | |
| parent | Locate engine names only at runtime and prefer GnuPG-2. (diff) | |
| download | gpgme-6564e5e78e8c6e5a120675a5699b5b75248cfbc7.tar.gz gpgme-6564e5e78e8c6e5a120675a5699b5b75248cfbc7.zip | |
Add global flags disable-gpgconf, gpgconf-name, and gpg-name.
* src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf",
"gpgconf-name", and "gpg-name".
* src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New.
(get_gpgconf_item): Minor debug info change.
* src/posix-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.
(walk_path): Add debug output on failure.
* src/w32-util.c (default_gpg_name, default_gpgconf_name): Add vars.
(replace_slashes): New.
(get_basename): New.
(_gpgme_set_default_gpg_name): New.
(_gpgme_set_default_gpgconf_name): New.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars.
* tests/t-engine-info.c (main): Add --verbose and --set-global-flag
options.
--
Note that the Windows part has not been tested.
Diffstat (limited to 'src/posix-util.c')
| -rw-r--r-- | src/posix-util.c | 47 | 
1 files changed, 45 insertions, 2 deletions
| diff --git a/src/posix-util.c b/src/posix-util.c index d4e4e3f4..5bfc4865 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -29,6 +29,46 @@  #include "util.h"  #include "sys-util.h" +#include "debug.h" + +/* These variables store the malloced name of alternative default +   binaries.  The are set only once by gpgme_set_global_flag.  */ +static char *default_gpg_name; +static char *default_gpgconf_name; + +/* Set the default name for the gpg binary.  This function may only be +   called by gpgme_set_global_flag.  Returns 0 on success.  Leading +   directories are removed from NAME.  */ +int +_gpgme_set_default_gpg_name (const char *name) +{ +  const char *s; + +  s = strrchr (name, '/'); +  if (s) +    name = s + 1; + +  if (!default_gpg_name) +    default_gpg_name = strdup (name); +  return !default_gpg_name; +} + +/* Set the default name for the gpgconf binary.  This function may +   only be called by gpgme_set_global_flag.  Returns 0 on success. +   Leading directories are removed from NAME.  */ +int +_gpgme_set_default_gpgconf_name (const char *name) +{ +  const char *s; + +  s = strrchr (name, '/'); +  if (s) +    name = s + 1; + +  if (!default_gpgconf_name) +    default_gpgconf_name = strdup (name); +  return !default_gpgconf_name; +}  /* Find an executable program PGM along the envvar PATH.  */ @@ -60,6 +100,9 @@ walk_path (const char *pgm)        path = s + 1;      } +  _gpgme_debug (DEBUG_ENGINE, "gpgme-walk_path: '%s' not found in '%s'", +                pgm, path); +    free (fname);    return NULL;  } @@ -72,7 +115,7 @@ walk_path (const char *pgm)  char *  _gpgme_get_gpg_path (void)  { -  return walk_path ("gpg"); +  return walk_path (default_gpg_name? default_gpg_name : "gpg");  } @@ -81,7 +124,7 @@ _gpgme_get_gpg_path (void)  char *  _gpgme_get_gpgconf_path (void)  { -  return walk_path ("gpgconf"); +  return walk_path (default_gpgconf_name? default_gpgconf_name : "gpgconf");  }  /* See w32-util.c */ | 
