aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2005-02-15 11:02:32 +0000
committerWerner Koch <[email protected]>2005-02-15 11:02:32 +0000
commitbb71180d07b0ce8a2293acf61541cf631f285012 (patch)
tree895410ed291b16654608a02c407b93db7adba325 /g10/misc.c
parent* curl-shim.c (curl_easy_perform): Fix compile warning. (diff)
downloadgnupg-bb71180d07b0ce8a2293acf61541cf631f285012.tar.gz
gnupg-bb71180d07b0ce8a2293acf61541cf631f285012.zip
* gpg.sgml: Add bkuptocard command for --edit-key.
* passphrase.c (agent_get_passphrase): Don't call free_public_key if PK is NULL. (passphrase_clear_cache): Ditto. Removed debug output. (passphrase_to_dek): Ditto.
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 2c3fbf129..9334dae21 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -51,6 +51,8 @@
#ifndef CSIDL_FLAG_CREATE
#define CSIDL_FLAG_CREATE 0x8000
#endif
+#include "errors.h"
+#include "dynload.h"
#endif /*_WIN32*/
#include "util.h"
@@ -1018,6 +1020,46 @@ parse_options(char *str,unsigned int *options,
}
+/* This is a helper function to load a Windows function from either of
+ one DLLs. */
+#ifdef HAVE_W32_SYSTEM
+static HRESULT
+w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e)
+{
+ static int initialized;
+ static HRESULT (* WINAPI func)(HWND,int,HANDLE,DWORD,LPSTR);
+
+ if (!initialized)
+ {
+ static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL };
+ void *handle;
+ int i;
+
+ initialized = 1;
+
+ for (i=0, handle = NULL; !handle && dllnames[i]; i++)
+ {
+ handle = dlopen (dllnames[i], RTLD_LAZY);
+ if (handle)
+ {
+ func = dlsym (handle, "SHGetFolderPathA");
+ if (!func)
+ {
+ dlclose (handle);
+ handle = NULL;
+ }
+ }
+ }
+ }
+
+ if (func)
+ return func (a,b,c,d,e);
+ else
+ return -1;
+}
+#endif /*HAVE_W32_SYSTEM*/
+
+
/* Set up the default home directory. The usual --homedir option
should be parsed later. */
char *
@@ -1040,8 +1082,8 @@ default_homedir (void)
using a system roaming serives might be better than to let
them do it manually. A security conscious user will anyway
use the registry entry to have better control. */
- if (SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
- NULL, 0, path) >= 0)
+ if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
+ NULL, 0, path) >= 0)
{
char *tmp = xmalloc (strlen (path) + 6 +1);
strcpy (stpcpy (tmp, path), "\\gnupg");