Lookup the path in the Registry
This commit is contained in:
parent
75cd8aeaa8
commit
9db5d05376
9
AUTHORS
9
AUTHORS
@ -0,0 +1,9 @@
|
|||||||
|
Program: gpgme
|
||||||
|
Maintainer: Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
|
||||||
|
FSF <gnu@gnu.org>
|
||||||
|
* Code taken from GnuPG: gpgme/w32-util.c
|
||||||
|
|
||||||
|
Werner Koch <wk@gnupg.org>
|
||||||
|
* Design and most stuff.
|
2
TODO
2
TODO
@ -5,6 +5,6 @@
|
|||||||
* Allow to use GTK's main loop instead of the select stuff in
|
* Allow to use GTK's main loop instead of the select stuff in
|
||||||
wait.c
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2001-01-30 Werner Koch <wk@gnupg.org>
|
2001-01-30 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* 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
|
* signers.c (gpgme_signers_add): Ooops, one should test code and
|
||||||
not just write it; the newarr was not assigned. Thanks to José
|
not just write it; the newarr was not assigned. Thanks to José
|
||||||
for pointing this out. Hmmm, still not tested, why shoudl a coder
|
for pointing this out. Hmmm, still not tested, why shoudl a coder
|
||||||
|
@ -13,7 +13,8 @@ libgpgme_la_LDFLAGS = -version-info \
|
|||||||
libgpgme_la_INCLUDES = -I$(top_srcdir)/lib
|
libgpgme_la_INCLUDES = -I$(top_srcdir)/lib
|
||||||
|
|
||||||
libgpgme_la_SOURCES = \
|
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 \
|
context.h ops.h \
|
||||||
data.c recipient.c signers.c \
|
data.c recipient.c signers.c \
|
||||||
wait.c wait.h \
|
wait.c wait.h \
|
||||||
@ -31,7 +32,7 @@ libgpgme_la_SOURCES = \
|
|||||||
rungpg.c rungpg.h status-table.h \
|
rungpg.c rungpg.h status-table.h \
|
||||||
sema.h posix-sema.c w32-sema.c \
|
sema.h posix-sema.c w32-sema.c \
|
||||||
syshdr.h io.h posix-io.c w32-io.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
|
errors.c : gpgme.h
|
||||||
|
@ -94,7 +94,7 @@ _gpgme_debug_begin ( void **helper, int level, const char *text)
|
|||||||
return;
|
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! */
|
* Windoze. We definitely should write our own clib for W32! */
|
||||||
sprintf ( ctl->fname, "/tmp/gpgme_debug.%d.%p", getpid (), ctl );
|
sprintf ( ctl->fname, "/tmp/gpgme_debug.%d.%p", getpid (), ctl );
|
||||||
ctl->fp = fopen (ctl->fname, "w+");
|
ctl->fp = fopen (ctl->fname, "w+");
|
||||||
|
45
gpgme/posix-util.c
Normal file
45
gpgme/posix-util.c
Normal file
@ -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*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -718,7 +718,8 @@ _gpgme_gpg_spawn( GpgObject gpg, void *opaque )
|
|||||||
fd_parent_list[n].dup_to = -1;
|
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);
|
xfree (fd_child_list);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
return mk_error (Exec_Error);
|
return mk_error (Exec_Error);
|
||||||
|
@ -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 */
|
#endif /* UTIL_H */
|
||||||
|
|
||||||
|
|
||||||
|
114
gpgme/w32-util.c
Normal file
114
gpgme/w32-util.c
Normal file
@ -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*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user