aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS9
-rw-r--r--TODO2
-rw-r--r--gpgme/ChangeLog4
-rw-r--r--gpgme/Makefile.am5
-rw-r--r--gpgme/debug.c2
-rw-r--r--gpgme/posix-util.c45
-rw-r--r--gpgme/rungpg.c3
-rw-r--r--gpgme/util.h5
-rw-r--r--gpgme/w32-util.c114
9 files changed, 184 insertions, 5 deletions
diff --git a/AUTHORS b/AUTHORS
index e69de29b..20ea6e00 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -0,0 +1,9 @@
+Program: gpgme
+Maintainer: Werner Koch <[email protected]>
+
+
+ * Code taken from GnuPG: gpgme/w32-util.c
+
+Werner Koch <[email protected]>
+ * Design and most stuff.
diff --git a/TODO b/TODO
index 59a6d8c8..a829ea0e 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,6 @@
* Allow to use GTK's main loop instead of the select stuff in
wait.c
-* Remove all that funny exit code handling - we donn't need it.
+* Remove all that funny exit code handling - we don't need it.
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index 03c72d3f..0f704a5a 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,5 +1,9 @@
2001-01-30 Werner Koch <[email protected]>
+ * posix-util.c, w32-util.c: New.
+ (_gpgme_get_gpg_path): New, suggested by Jan-Oliver.
+ * rungpg.c (_gpgme_gpg_spawn): Use new function to get GPG's path.
+
* signers.c (gpgme_signers_add): Ooops, one should test code and
not just write it; the newarr was not assigned. Thanks to Jos�
for pointing this out. Hmmm, still not tested, why shoudl a coder
diff --git a/gpgme/Makefile.am b/gpgme/Makefile.am
index 20944ac8..59faab48 100644
--- a/gpgme/Makefile.am
+++ b/gpgme/Makefile.am
@@ -13,7 +13,8 @@ libgpgme_la_LDFLAGS = -version-info \
libgpgme_la_INCLUDES = -I$(top_srcdir)/lib
libgpgme_la_SOURCES = \
- gpgme.h types.h util.h util.c debug.c \
+ gpgme.h types.h \
+ util.h util.c posix-util.c w32-util.c \
context.h ops.h \
data.c recipient.c signers.c \
wait.c wait.h \
@@ -31,7 +32,7 @@ libgpgme_la_SOURCES = \
rungpg.c rungpg.h status-table.h \
sema.h posix-sema.c w32-sema.c \
syshdr.h io.h posix-io.c w32-io.c \
- gpgme.c version.c errors.c
+ gpgme.c debug.c version.c errors.c
errors.c : gpgme.h
diff --git a/gpgme/debug.c b/gpgme/debug.c
index f41929b3..7cb5121d 100644
--- a/gpgme/debug.c
+++ b/gpgme/debug.c
@@ -94,7 +94,7 @@ _gpgme_debug_begin ( void **helper, int level, const char *text)
return;
}
- /* Oh what a pitty sthat we don't have a asprintf or snprintf under
+ /* Oh what a pitty that we don't have a asprintf or snprintf under
* Windoze. We definitely should write our own clib for W32! */
sprintf ( ctl->fname, "/tmp/gpgme_debug.%d.%p", getpid (), ctl );
ctl->fp = fopen (ctl->fname, "w+");
diff --git a/gpgme/posix-util.c b/gpgme/posix-util.c
new file mode 100644
index 00000000..3c0c692a
--- /dev/null
+++ b/gpgme/posix-util.c
@@ -0,0 +1,45 @@
+/* posix-util.c - Utility functions for Posix
+ * Copyright (C) 2001 Werner Koch (dd9jn)
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GPGME is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include <config.h>
+#ifndef HAVE_DOSISH_SYSTEM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "util.h"
+
+
+const char *
+_gpgme_get_gpg_path (void)
+{
+ return GPG_PATH;
+}
+
+
+#endif /*!HAVE_DOSISH_SYSTEM*/
+
+
+
+
+
diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c
index 101d9a9f..8c9d2b77 100644
--- a/gpgme/rungpg.c
+++ b/gpgme/rungpg.c
@@ -718,7 +718,8 @@ _gpgme_gpg_spawn( GpgObject gpg, void *opaque )
fd_parent_list[n].dup_to = -1;
- pid = _gpgme_io_spawn (GPG_PATH, gpg->argv, fd_child_list, fd_parent_list);
+ pid = _gpgme_io_spawn (_gpgme_get_gpg_path (),
+ gpg->argv, fd_child_list, fd_parent_list);
xfree (fd_child_list);
if (pid == -1) {
return mk_error (Exec_Error);
diff --git a/gpgme/util.h b/gpgme/util.h
index 65bfa2b4..0d901e65 100644
--- a/gpgme/util.h
+++ b/gpgme/util.h
@@ -119,6 +119,11 @@ char *stpcpy (char *a, const char *b);
+/*-- {posix,w32}-util.c --*/
+const char *_gpgme_get_gpg_path (void);
+
+
+
#endif /* UTIL_H */
diff --git a/gpgme/w32-util.c b/gpgme/w32-util.c
new file mode 100644
index 00000000..f1001a68
--- /dev/null
+++ b/gpgme/w32-util.c
@@ -0,0 +1,114 @@
+/* w32-util.c - Utility functions for the W32 API
+ * Copyright (C) 2001 Werner Koch (dd9jn)
+ * Copyright (C) 1999 Free Software Foundation, Inc
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GPGME is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include <config.h>
+#ifdef HAVE_DOSISH_SYSTEM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <windows.h>
+#include "syshdr.h"
+
+#include "util.h"
+
+/****************
+ * Return a string from the Win32 Registry or NULL in case of
+ * error. Caller must release the return value. A NULL for root
+ * is an alias fro HKEY_CURRENT_USER
+ */
+static char *
+read_w32_registry_string ( const char *root,
+ const char *dir, const char *name )
+{
+ HKEY root_key, key_handle;
+ DWORD n1, nbytes;
+ char *result = NULL;
+
+ if( !root )
+ root_key = HKEY_CURRENT_USER;
+ else if( !strcmp( root, "HKEY_CLASSES_ROOT" ) )
+ root_key = HKEY_CLASSES_ROOT;
+ else if( !strcmp( root, "HKEY_CURRENT_USER" ) )
+ root_key = HKEY_CURRENT_USER;
+ else if( !strcmp( root, "HKEY_LOCAL_MACHINE" ) )
+ root_key = HKEY_LOCAL_MACHINE;
+ else if( !strcmp( root, "HKEY_USERS" ) )
+ root_key = HKEY_USERS;
+ else if( !strcmp( root, "HKEY_PERFORMANCE_DATA" ) )
+ root_key = HKEY_PERFORMANCE_DATA;
+ else if( !strcmp( root, "HKEY_CURRENT_CONFIG" ) )
+ root_key = HKEY_CURRENT_CONFIG;
+ else
+ return NULL;
+
+ if( RegOpenKeyEx( root_key, dir, 0, KEY_READ, &key_handle ) )
+ return NULL; /* no need for a RegClose, so return direct */
+
+ nbytes = 1;
+ if( RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) )
+ goto leave;
+ result = xtrymalloc( (n1=nbytes+1) );
+ if( !result )
+ goto leave;
+ if( RegQueryValueEx( key_handle, name, 0, NULL, result, &n1 ) ) {
+ xfree(result); result = NULL;
+ goto leave;
+ }
+ result[nbytes] = 0; /* make sure it is really a string */
+
+ leave:
+ RegCloseKey( key_handle );
+ return result;
+}
+
+
+const char *
+_gpgme_get_gpg_path (void)
+{
+ static char *gpg_program = NULL;
+
+ if (!gpg_program) {
+ gpg_program = read_w32_registry_string ( NULL,
+ "Software\\GNU\\GnuPG", "gpgProgram" );
+ if (!gpg_program)
+ gpg_program = GPG_PATH;
+ }
+
+ return gpg_program;
+}
+
+
+
+
+#endif /*HAVE_DOSISH_SYSTEM*/
+
+
+
+
+