mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Replace use of opt.homedir by accessor functions.
* common/homedir.c (the_gnupg_homedir): New var. (gnupg_set_homedir): New. (gnupg_homedir): New. * g10/options.h (struct opt): Remove 'homedir' and replace all users by the new accessor functions. * g13/g13-common.h (struct opt): Ditto. * scd/scdaemon.h (struct opt): Ditto. * sm/gpgsm.h (struct opt): Ditto. * dirmngr/dirmngr.h (struct opt): Ditto. * agent/preset-passphrase.c (opt_homedir): Ditto. * agent/protect-tool.c (opt_homedir): Ditto. -- This will make detection of a non-default homedir easier. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
650abbab71
commit
22a7ef01aa
44 changed files with 188 additions and 179 deletions
|
@ -1,6 +1,6 @@
|
|||
/* homedir.c - Setup the home directory.
|
||||
* Copyright (C) 2004, 2006, 2007, 2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2013 Werner Koch
|
||||
* Copyright (C) 2013, 2016 Werner Koch
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
|
@ -58,6 +58,12 @@
|
|||
#include "util.h"
|
||||
#include "sysutils.h"
|
||||
|
||||
|
||||
/* The GnuPG homedir. This is only accessed by the functions
|
||||
* gnupg_homedir and gnupg_set_homedir. Malloced. */
|
||||
static char *the_gnupg_homedir;
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* A flag used to indicate that a control file for gpgconf has been
|
||||
detected. Under Windows the presence of this file indicates a
|
||||
|
@ -368,6 +374,30 @@ w32_commondir (void)
|
|||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
/* Change the homedir. Some care must be taken to set this early
|
||||
* enough becuase previous calls to gnupg_homedir may else return a
|
||||
* different string. */
|
||||
void
|
||||
gnupg_set_homedir (const char *newdir)
|
||||
{
|
||||
if (!newdir || !*newdir)
|
||||
newdir = default_homedir ();
|
||||
xfree (the_gnupg_homedir);
|
||||
the_gnupg_homedir = xstrdup (newdir);
|
||||
}
|
||||
|
||||
|
||||
/* Return the homedir. The returned string is valid until another
|
||||
* gnupg-set-homedir call. Note that this may be a relative string.
|
||||
* This function replaced the former global opt.homedir. */
|
||||
const char *
|
||||
gnupg_homedir (void)
|
||||
{
|
||||
/* If a homedir has not been set, set it to the default. */
|
||||
if (!the_gnupg_homedir)
|
||||
the_gnupg_homedir = xstrdup (default_homedir ());
|
||||
return the_gnupg_homedir;
|
||||
}
|
||||
|
||||
|
||||
/* Return the name of the sysconfdir. This is a static string. This
|
||||
|
|
|
@ -220,6 +220,8 @@ const char *openpgp_is_curve_supported (const char *name, int *r_algo);
|
|||
/*-- homedir.c --*/
|
||||
const char *standard_homedir (void);
|
||||
const char *default_homedir (void);
|
||||
void gnupg_set_homedir (const char *newdir);
|
||||
const char *gnupg_homedir (void);
|
||||
const char *gnupg_sysconfdir (void);
|
||||
const char *gnupg_bindir (void);
|
||||
const char *gnupg_libexecdir (void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue