Преглед на файлове

2008-09-30 Marcus Brinkmann <marcus@g10code.com>

	* src/get-path.c (find_program_in_inst_dir): New function.
	(get_gpgsm_path, get_gpg_agent_path): Use it to check in install dir.
Marcus Brinkmann преди 17 години
родител
ревизия
5457e31080
променени са 2 файла, в които са добавени 42 реда и са изтрити 0 реда
  1. 5 0
      ChangeLog
  2. 37 0
      src/get-path.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-09-30  Marcus Brinkmann  <marcus@g10code.com>
+
+	* src/get-path.c (find_program_in_inst_dir): New function.
+	(get_gpgsm_path, get_gpg_agent_path): Use it to check in install dir.
+
 2008-09-30  Werner Koch  <wk@g10code.de>
 
 	* src/Makefile.am (scute_DEPENDENCIES): Use .libs/versioninfo.o

+ 37 - 0
src/get-path.c

@@ -244,6 +244,39 @@ w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e)
     return -1;
 }
 
+
+static char *
+find_program_in_inst_dir (const char *name)
+{
+  char *result = NULL;
+  char *tmp;
+
+  tmp = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
+				  "Software\\GNU\\GnuPG",
+				  "Install Directory");
+  if (!tmp)
+    return NULL;
+
+  result = malloc (strlen (tmp) + 1 + strlen (name) + 1);
+  if (!result)
+    {
+      free (tmp);
+      return NULL;
+    }
+
+  strcpy (stpcpy (stpcpy (result, tmp), "\\"), name);
+  free (tmp);
+  if (access (result, F_OK))
+    {
+      free (result);
+      return NULL;
+    }
+
+  return result;
+}
+
+
+
 static char *
 find_program_at_standard_place (const char *name)
 {
@@ -274,6 +307,8 @@ get_gpgsm_path (void)
   static const char *pgmname;
 
 #ifdef HAVE_W32_SYSTEM
+  if (!pgmname)
+    pgmname = find_program_in_inst_dir ("gpgsm.exe");
   if (!pgmname)
     pgmname = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe");
 #endif
@@ -289,6 +324,8 @@ get_gpg_agent_path (void)
   static const char *pgmname;
 
 #ifdef HAVE_W32_SYSTEM
+  if (!pgmname)
+    pgmname = find_program_in_inst_dir ("gpg-agent.exe");
   if (!pgmname)
     pgmname = find_program_at_standard_place ("GNU\\GnuPG\\gpg-agent.exe");
 #endif