2002-03-17 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Add automake conditional HAVE_DOSISH_SYSTEM. gpgme/ 2002-03-18 Marcus Brinkmann <marcus@g10code.de> * Makefile.am (system_components): New variable, set depending on HAVE_DOSISH_SYSTEM. (libgpgme_la_SOURCES): Use system_components. Remove `syshdr.h'. * syshdr.h: File removed. * posix-io.c: Remove !HAVE_DOSISH_SYSTEM safeguard. Clean up source. * posix-sema.c: Likewise. * posix-util.c: Likewise. * w32-io.c: Remove HAVE_DOSISH_SYSTEM safeguard. * w32-sema.c: Likewise. * w32-util.c: Likewise. * posix-io.c: Include `unistd.h', do not include `syshdr.h'. * posix-sema.c: Likewise. * w32-io.c: Include `io.h', do not include `syshdr.h' * w32-sema.c: Likewise. * w32-util.c: Likewise. * data.c: Do not include `syshdr.h'. * wait.c: Likewise. * wait.h: Code cleanup. * mutex.h: New file. * posix-sema.c: Implement.
This commit is contained in:
parent
5a24e01ee8
commit
6cee0a4f3f
@ -1,3 +1,7 @@
|
||||
2002-03-17 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* configure.ac: Add automake conditional HAVE_DOSISH_SYSTEM.
|
||||
|
||||
2002-03-04 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* configure.ac: Bumbed version to 0.3.4-cvs to continue development.
|
||||
|
2
TODO
2
TODO
@ -51,7 +51,7 @@ Hey Emacs, this is -*- outline -*- mode!
|
||||
** Make sure everything is cleaned correctly (esp. test area).
|
||||
|
||||
* Architecture support
|
||||
** Implement posix-sema.c
|
||||
** (nothing currently)
|
||||
|
||||
Bugs reported by Stephane Corthesy:
|
||||
> BTW, here's another bug: it it not possible to retrieve fingerprints
|
||||
|
@ -72,6 +72,7 @@ case "${target}" in
|
||||
# DOS with the DJGPP environment
|
||||
AC_DEFINE(HAVE_DRIVE_LETTERS)
|
||||
AC_DEFINE(HAVE_DOSISH_SYSTEM)
|
||||
have_dosish_system=yes
|
||||
GPG_DEFAULT='c:\\gnupg\\gpg.exe'
|
||||
GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
|
||||
#component_system='COM+'
|
||||
@ -82,6 +83,7 @@ dnl GPG_DEFAULT='/usr/bin/gpg'
|
||||
dnl GPGSM_DEFAULT='/usr/bin/gpgsm'
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes")
|
||||
|
||||
dnl
|
||||
dnl Checks for libraries.
|
||||
|
@ -1,3 +1,30 @@
|
||||
2002-03-18 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* Makefile.am (system_components): New variable, set depending on
|
||||
HAVE_DOSISH_SYSTEM.
|
||||
(libgpgme_la_SOURCES): Use system_components. Remove `syshdr.h'.
|
||||
* syshdr.h: File removed.
|
||||
|
||||
* posix-io.c: Remove !HAVE_DOSISH_SYSTEM safeguard. Clean up source.
|
||||
* posix-sema.c: Likewise.
|
||||
* posix-util.c: Likewise.
|
||||
|
||||
* w32-io.c: Remove HAVE_DOSISH_SYSTEM safeguard.
|
||||
* w32-sema.c: Likewise.
|
||||
* w32-util.c: Likewise.
|
||||
|
||||
* posix-io.c: Include `unistd.h', do not include `syshdr.h'.
|
||||
* posix-sema.c: Likewise.
|
||||
* w32-io.c: Include `io.h', do not include `syshdr.h'
|
||||
* w32-sema.c: Likewise.
|
||||
* w32-util.c: Likewise.
|
||||
* data.c: Do not include `syshdr.h'.
|
||||
* wait.c: Likewise.
|
||||
* wait.h: Code cleanup.
|
||||
|
||||
* mutex.h: New file.
|
||||
* posix-sema.c: Implement.
|
||||
|
||||
2002-03-08 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* util.h [!HAVE_FOPENCOOKIE]: Fixed type. Thanks to Frank Heckenbach.
|
||||
|
@ -35,9 +35,15 @@ AM_CPPFLAGS = -I$(top_srcdir)/assuan
|
||||
libgpgme_la_LIBADD = ../assuan/libassuan.a ../jnlib/libjnlib.a
|
||||
endif
|
||||
|
||||
if HAVE_DOSISH_SYSTEM
|
||||
system_components = w32-util.c w32-sema.c w32-io.c
|
||||
else
|
||||
system_components = posix-util.c posix-sema.c posix-io.c
|
||||
endif
|
||||
|
||||
libgpgme_la_SOURCES = \
|
||||
gpgme.h types.h \
|
||||
util.h util.c posix-util.c w32-util.c \
|
||||
util.h util.c \
|
||||
context.h ops.h \
|
||||
data.c recipient.c signers.c \
|
||||
wait.c wait.h \
|
||||
@ -59,8 +65,8 @@ libgpgme_la_SOURCES = \
|
||||
rungpg.c rungpg.h status-table.h \
|
||||
engine-gpgsm.c engine-gpgsm.h \
|
||||
engine.c engine.h \
|
||||
sema.h posix-sema.c w32-sema.c \
|
||||
syshdr.h io.h posix-io.c w32-io.c \
|
||||
sema.h io.h \
|
||||
${system_components} \
|
||||
gpgme.c debug.c version.c errors.c
|
||||
|
||||
errors.c : gpgme.h
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "syshdr.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
|
@ -43,7 +43,7 @@ extern "C" {
|
||||
AM_PATH_GPGME macro) check that this header matches the installed
|
||||
library. Warning: Do not edit the next line. configure will do
|
||||
that for you! */
|
||||
#define GPGME_VERSION "0.3.5-cvs"
|
||||
#define GPGME_VERSION "0.3.5-cvs-2002-03-10"
|
||||
|
||||
|
||||
/* The opaque data types used by GPGME. */
|
||||
|
124
gpgme/mutex.h
Normal file
124
gpgme/mutex.h
Normal file
@ -0,0 +1,124 @@
|
||||
/* mutex.h - Portable mutual exclusion, independent from any thread library.
|
||||
* Copyright (C) 2002 g10 Code GmbH
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef MUTEX_H
|
||||
#define MUTEX_H
|
||||
|
||||
/* Define MUTEX_FAKE before including the file to get stubs that don't
|
||||
provide any locking at all. Define MUTEX_PTHREAD if you can link
|
||||
against the posix thread library. */
|
||||
|
||||
#if defined(MUTEX_FAKE)
|
||||
|
||||
typedef char mutex_t;
|
||||
#define mutex_init(x) (0)
|
||||
#define mutex_destroy(x)
|
||||
#define mutex_lock(x) (0)
|
||||
#define mutex_unlock(x) (0)
|
||||
|
||||
#elif defined(MUTEX_PTHREAD)
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define mutex_t pthread_mutex_t
|
||||
#define mutex_init(x) pthread_mutex_init (&(x), 0)
|
||||
#define mutex_destroy(x) pthread_mutex_destroy(&(x))
|
||||
#define mutex_lock(x) pthread_mutex_lock (&(x))
|
||||
#define mutex_unlock(x) pthread_mutex_unlock (&(x))
|
||||
|
||||
#else
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* The type of a mutex. */
|
||||
typedef int mutex_t[2];
|
||||
|
||||
inline static int
|
||||
set_close_on_exec (int fd)
|
||||
{
|
||||
int flags = fcntl (fd, F_GETFD, 0);
|
||||
if (flags == -1)
|
||||
return errno;
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl (fd, F_SETFD, flags) == -1)
|
||||
return errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize the mutex variable MUTEX. */
|
||||
inline int
|
||||
mutex_init (mutex_t mutex)
|
||||
{
|
||||
ssize_t amount;
|
||||
int err = 0;
|
||||
|
||||
if (pipe (mutex))
|
||||
return errno;
|
||||
|
||||
err = set_close_on_exec (mutex[0]);
|
||||
if (!err)
|
||||
err = set_close_on_exec (mutex[1]);
|
||||
if (!err)
|
||||
while ((amount = write (mutex[1], " ", 1)) < 0 && errno == EINTR)
|
||||
;
|
||||
if (!err && amount != 1)
|
||||
err = errno;
|
||||
|
||||
if (err)
|
||||
{
|
||||
close (mutex[0]);
|
||||
close (mutex[1]);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Destroy the mutex variable MUTEX. */
|
||||
inline void
|
||||
mutex_destroy (mutex_t mutex)
|
||||
{
|
||||
close (mutex[0]);
|
||||
close (mutex[1]);
|
||||
}
|
||||
|
||||
/* Take the mutex variable MUTEX. */
|
||||
inline int
|
||||
mutex_lock (mutex_t mutex)
|
||||
{
|
||||
char data;
|
||||
int amount;
|
||||
while ((amount = read (mutex[0], &data, 1)) < 0 && errno == EINTR)
|
||||
;
|
||||
return (amount != 1) ? errno : 0;
|
||||
}
|
||||
|
||||
/* Release the mutex variable MUTEX. */
|
||||
inline int
|
||||
mutex_unlock (mutex_t mutex)
|
||||
{
|
||||
int amount;
|
||||
while ((amount = write (mutex[1], " ", 1)) < 0 && errno == EINTR)
|
||||
;
|
||||
return (amount != 1) ? errno : 0;
|
||||
}
|
||||
|
||||
#endif /* MUTEX_FAKE */
|
||||
#endif /* MUTEX_H */
|
449
gpgme/posix-io.c
449
gpgme/posix-io.c
@ -1,6 +1,6 @@
|
||||
/* posix-io.c - Posix I/O functions
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -19,59 +19,62 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include "syshdr.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
static struct {
|
||||
void (*handler)(int,void*);
|
||||
void *value;
|
||||
static struct
|
||||
{
|
||||
void (*handler) (int,void*);
|
||||
void *value;
|
||||
} notify_table[256];
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_read ( int fd, void *buffer, size_t count )
|
||||
_gpgme_io_read (int fd, void *buffer, size_t count)
|
||||
{
|
||||
int nread;
|
||||
int nread;
|
||||
|
||||
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int)count );
|
||||
do {
|
||||
nread = read (fd, buffer, count);
|
||||
} while (nread == -1 && errno == EINTR );
|
||||
DEBUG2 ("fd %d: got %d bytes\n", fd, nread );
|
||||
if ( nread > 0 ) {
|
||||
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer );
|
||||
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count);
|
||||
do
|
||||
{
|
||||
nread = read (fd, buffer, count);
|
||||
}
|
||||
return nread;
|
||||
while (nread == -1 && errno == EINTR );
|
||||
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
|
||||
if (nread > 0)
|
||||
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer);
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_write ( int fd, const void *buffer, size_t count )
|
||||
_gpgme_io_write (int fd, const void *buffer, size_t count)
|
||||
{
|
||||
int nwritten;
|
||||
int nwritten;
|
||||
|
||||
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int)count );
|
||||
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int)count, buffer );
|
||||
do {
|
||||
nwritten = write (fd, buffer, count);
|
||||
} while (nwritten == -1 && errno == EINTR );
|
||||
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int)nwritten );
|
||||
return nwritten;
|
||||
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count);
|
||||
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer);
|
||||
do
|
||||
{
|
||||
nwritten = write (fd, buffer, count);
|
||||
}
|
||||
while (nwritten == -1 && errno == EINTR);
|
||||
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
|
||||
return nwritten;
|
||||
}
|
||||
|
||||
int
|
||||
@ -92,170 +95,184 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_close ( int fd )
|
||||
_gpgme_io_close (int fd)
|
||||
{
|
||||
if ( fd == -1 )
|
||||
return -1;
|
||||
/* first call the notify handler */
|
||||
DEBUG1 ("closing fd %d", fd );
|
||||
if ( fd >= 0 && fd < DIM (notify_table) ) {
|
||||
if (notify_table[fd].handler) {
|
||||
notify_table[fd].handler (fd, notify_table[fd].value);
|
||||
notify_table[fd].handler = NULL;
|
||||
notify_table[fd].value = NULL;
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
/* First call the notify handler. */
|
||||
DEBUG1 ("closing fd %d", fd);
|
||||
if (fd >= 0 && fd < DIM (notify_table))
|
||||
{
|
||||
if (notify_table[fd].handler)
|
||||
{
|
||||
notify_table[fd].handler (fd, notify_table[fd].value);
|
||||
notify_table[fd].handler = NULL;
|
||||
notify_table[fd].value = NULL;
|
||||
}
|
||||
}
|
||||
/* then do the close */
|
||||
return close (fd);
|
||||
/* Then do the close. */
|
||||
return close (fd);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value)
|
||||
{
|
||||
assert (fd != -1);
|
||||
assert (fd != -1);
|
||||
|
||||
if ( fd < 0 || fd >= DIM (notify_table) )
|
||||
return -1;
|
||||
DEBUG1 ("set notification for fd %d", fd );
|
||||
notify_table[fd].handler = handler;
|
||||
notify_table[fd].value = value;
|
||||
return 0;
|
||||
if (fd < 0 || fd >= DIM (notify_table))
|
||||
return -1;
|
||||
DEBUG1 ("set notification for fd %d", fd);
|
||||
notify_table[fd].handler = handler;
|
||||
notify_table[fd].value = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_set_nonblocking ( int fd )
|
||||
_gpgme_io_set_nonblocking (int fd)
|
||||
{
|
||||
int flags;
|
||||
int flags;
|
||||
|
||||
flags = fcntl (fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
return -1;
|
||||
flags |= O_NONBLOCK;
|
||||
return fcntl (fd, F_SETFL, flags);
|
||||
flags = fcntl (fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
return -1;
|
||||
flags |= O_NONBLOCK;
|
||||
return fcntl (fd, F_SETFL, flags);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_spawn ( const char *path, char **argv,
|
||||
struct spawn_fd_item_s *fd_child_list,
|
||||
struct spawn_fd_item_s *fd_parent_list )
|
||||
_gpgme_io_spawn (const char *path, char **argv,
|
||||
struct spawn_fd_item_s *fd_child_list,
|
||||
struct spawn_fd_item_s *fd_parent_list)
|
||||
{
|
||||
static volatile int fixed_signals;
|
||||
pid_t pid;
|
||||
int i;
|
||||
static volatile int fixed_signals;
|
||||
pid_t pid;
|
||||
int i;
|
||||
|
||||
if ( !fixed_signals ) {
|
||||
struct sigaction act;
|
||||
if (!fixed_signals)
|
||||
{
|
||||
struct sigaction act;
|
||||
|
||||
sigaction( SIGPIPE, NULL, &act );
|
||||
if( act.sa_handler == SIG_DFL ) {
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset( &act.sa_mask );
|
||||
act.sa_flags = 0;
|
||||
sigaction( SIGPIPE, &act, NULL);
|
||||
sigaction (SIGPIPE, NULL, &act);
|
||||
if (act.sa_handler == SIG_DFL)
|
||||
{
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset (&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction (SIGPIPE, &act, NULL);
|
||||
}
|
||||
fixed_signals = 1;
|
||||
/* fixme: This is not really MT safe */
|
||||
fixed_signals = 1;
|
||||
/* XXX: This is not really MT safe. */
|
||||
}
|
||||
|
||||
pid = fork ();
|
||||
if (pid == -1)
|
||||
return -1;
|
||||
|
||||
pid = fork ();
|
||||
if (pid == -1)
|
||||
return -1;
|
||||
if (!pid)
|
||||
{
|
||||
/* Child. */
|
||||
int duped_stdin = 0;
|
||||
int duped_stderr = 0;
|
||||
|
||||
if ( !pid ) { /* child */
|
||||
int duped_stdin = 0;
|
||||
int duped_stderr = 0;
|
||||
/* First close all fds which will not be duped. */
|
||||
for (i=0; fd_child_list[i].fd != -1; i++)
|
||||
if (fd_child_list[i].dup_to == -1)
|
||||
close (fd_child_list[i].fd);
|
||||
|
||||
/* first close all fds which will not be duped */
|
||||
for (i=0; fd_child_list[i].fd != -1; i++ ) {
|
||||
if (fd_child_list[i].dup_to == -1 )
|
||||
close (fd_child_list[i].fd);
|
||||
}
|
||||
/* and now dup and close the rest */
|
||||
for (i=0; fd_child_list[i].fd != -1; i++ ) {
|
||||
if (fd_child_list[i].dup_to != -1 ) {
|
||||
if ( dup2 (fd_child_list[i].fd,
|
||||
fd_child_list[i].dup_to ) == -1 ) {
|
||||
DEBUG1 ("dup2 failed in child: %s\n", strerror (errno));
|
||||
_exit (8);
|
||||
/* And now dup and close the rest. */
|
||||
for (i=0; fd_child_list[i].fd != -1; i++)
|
||||
{
|
||||
if (fd_child_list[i].dup_to != -1)
|
||||
{
|
||||
if (dup2 (fd_child_list[i].fd,
|
||||
fd_child_list[i].dup_to) == -1)
|
||||
{
|
||||
DEBUG1 ("dup2 failed in child: %s\n", strerror (errno));
|
||||
_exit (8);
|
||||
}
|
||||
if ( fd_child_list[i].dup_to == 0 )
|
||||
duped_stdin=1;
|
||||
if ( fd_child_list[i].dup_to == 2 )
|
||||
duped_stderr=1;
|
||||
close (fd_child_list[i].fd);
|
||||
if (fd_child_list[i].dup_to == 0)
|
||||
duped_stdin=1;
|
||||
if (fd_child_list[i].dup_to == 2)
|
||||
duped_stderr=1;
|
||||
close (fd_child_list[i].fd);
|
||||
}
|
||||
}
|
||||
|
||||
if( !duped_stdin || !duped_stderr ) {
|
||||
int fd = open ( "/dev/null", O_RDWR );
|
||||
if ( fd == -1 ) {
|
||||
DEBUG1 ("can't open `/dev/null': %s\n", strerror (errno) );
|
||||
_exit (8);
|
||||
if (!duped_stdin || !duped_stderr)
|
||||
{
|
||||
int fd = open ("/dev/null", O_RDWR);
|
||||
if (fd == -1)
|
||||
{
|
||||
DEBUG1 ("can't open `/dev/null': %s\n", strerror (errno));
|
||||
_exit (8);
|
||||
}
|
||||
/* Make sure that the process has a connected stdin */
|
||||
if ( !duped_stdin ) {
|
||||
if ( dup2 ( fd, 0 ) == -1 ) {
|
||||
DEBUG1("dup2(/dev/null, 0) failed: %s\n",
|
||||
strerror (errno) );
|
||||
_exit (8);
|
||||
/* Make sure that the process has a connected stdin. */
|
||||
if (!duped_stdin)
|
||||
{
|
||||
if (dup2 (fd, 0) == -1)
|
||||
{
|
||||
DEBUG1("dup2(/dev/null, 0) failed: %s\n",
|
||||
strerror (errno));
|
||||
_exit (8);
|
||||
}
|
||||
}
|
||||
if ( !duped_stderr ) {
|
||||
if ( dup2 ( fd, 2 ) == -1 ) {
|
||||
DEBUG1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno));
|
||||
_exit (8);
|
||||
}
|
||||
}
|
||||
close (fd);
|
||||
}
|
||||
if (!duped_stderr)
|
||||
if (dup2 (fd, 2) == -1)
|
||||
{
|
||||
DEBUG1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno));
|
||||
_exit (8);
|
||||
}
|
||||
close (fd);
|
||||
}
|
||||
|
||||
execv ( path, argv );
|
||||
/* Hmm: in that case we could write a special status code to the
|
||||
* status-pipe */
|
||||
DEBUG1 ("exec of `%s' failed\n", path );
|
||||
_exit (8);
|
||||
} /* end child */
|
||||
execv ( path, argv );
|
||||
/* Hmm: in that case we could write a special status code to the
|
||||
status-pipe. */
|
||||
DEBUG1 ("exec of `%s' failed\n", path);
|
||||
_exit (8);
|
||||
} /* End child. */
|
||||
|
||||
/* .dup_to is not used in the parent list */
|
||||
for (i=0; fd_parent_list[i].fd != -1; i++ ) {
|
||||
close (fd_parent_list[i].fd);
|
||||
}
|
||||
/* .dup_to is not used in the parent list. */
|
||||
for (i=0; fd_parent_list[i].fd != -1; i++)
|
||||
close (fd_parent_list[i].fd);
|
||||
|
||||
return (int)pid;
|
||||
return (int) pid;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_waitpid ( int pid, int hang, int *r_status, int *r_signal )
|
||||
_gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
*r_status = 0;
|
||||
*r_signal = 0;
|
||||
if ( waitpid ( pid, &status, hang? 0 : WNOHANG ) == pid ) {
|
||||
if ( WIFSIGNALED (status) ) {
|
||||
*r_status = 4; /* Need some value here */
|
||||
*r_signal = WTERMSIG (status);
|
||||
}
|
||||
else if ( WIFEXITED (status) ) {
|
||||
*r_status = WEXITSTATUS (status);
|
||||
}
|
||||
else {
|
||||
*r_status = 4; /* oops */
|
||||
}
|
||||
return 1;
|
||||
*r_status = 0;
|
||||
*r_signal = 0;
|
||||
if (waitpid (pid, &status, hang? 0 : WNOHANG) == pid)
|
||||
{
|
||||
if (WIFSIGNALED (status))
|
||||
{
|
||||
*r_status = 4; /* Need some value here. */
|
||||
*r_signal = WTERMSIG (status);
|
||||
}
|
||||
else if (WIFEXITED (status))
|
||||
*r_status = WEXITSTATUS (status);
|
||||
else
|
||||
*r_status = 4; /* Oops. */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_gpgme_io_kill ( int pid, int hard )
|
||||
_gpgme_io_kill (int pid, int hard)
|
||||
{
|
||||
return kill ( pid, hard? SIGKILL : SIGTERM );
|
||||
return kill (pid, hard ? SIGKILL : SIGTERM);
|
||||
}
|
||||
|
||||
|
||||
@ -266,91 +283,97 @@ _gpgme_io_kill ( int pid, int hard )
|
||||
* >0 = number of signaled fds
|
||||
*/
|
||||
int
|
||||
_gpgme_io_select ( struct io_select_fd_s *fds, size_t nfds )
|
||||
_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds)
|
||||
{
|
||||
static fd_set readfds;
|
||||
static fd_set writefds;
|
||||
int any, i, max_fd, n, count;
|
||||
struct timeval timeout = { 1, 0 }; /* Use a 1s timeout */
|
||||
void *dbg_help = NULL;
|
||||
static fd_set readfds;
|
||||
static fd_set writefds;
|
||||
int any, i, max_fd, n, count;
|
||||
struct timeval timeout = { 1, 0 }; /* Use a 1s timeout. */
|
||||
void *dbg_help = NULL;
|
||||
|
||||
FD_ZERO ( &readfds );
|
||||
FD_ZERO ( &writefds );
|
||||
max_fd = 0;
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&writefds);
|
||||
max_fd = 0;
|
||||
|
||||
if ( _gpgme_debug_level () > 2 )
|
||||
DEBUG_BEGIN (dbg_help, "gpgme:select on [ ");
|
||||
any = 0;
|
||||
for ( i=0; i < nfds; i++ ) {
|
||||
if ( fds[i].fd == -1 )
|
||||
continue;
|
||||
if ( fds[i].frozen ) {
|
||||
DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd );
|
||||
if (_gpgme_debug_level () > 2)
|
||||
DEBUG_BEGIN (dbg_help, "gpgme:select on [ ");
|
||||
any = 0;
|
||||
for (i = 0; i < nfds; i++)
|
||||
{
|
||||
if (fds[i].fd == -1)
|
||||
continue;
|
||||
if (fds[i].frozen)
|
||||
DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd );
|
||||
else if (fds[i].for_read)
|
||||
{
|
||||
assert (!FD_ISSET (fds[i].fd, &readfds));
|
||||
FD_SET (fds[i].fd, &readfds);
|
||||
if (fds[i].fd > max_fd)
|
||||
max_fd = fds[i].fd;
|
||||
DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd);
|
||||
any = 1;
|
||||
}
|
||||
else if ( fds[i].for_read ) {
|
||||
assert ( !FD_ISSET ( fds[i].fd, &readfds ) );
|
||||
FD_SET ( fds[i].fd, &readfds );
|
||||
if ( fds[i].fd > max_fd )
|
||||
max_fd = fds[i].fd;
|
||||
DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd );
|
||||
any = 1;
|
||||
else if (fds[i].for_write)
|
||||
{
|
||||
assert (!FD_ISSET ( fds[i].fd, &writefds));
|
||||
FD_SET (fds[i].fd, &writefds);
|
||||
if (fds[i].fd > max_fd)
|
||||
max_fd = fds[i].fd;
|
||||
DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd);
|
||||
any = 1;
|
||||
}
|
||||
else if ( fds[i].for_write ) {
|
||||
assert ( !FD_ISSET ( fds[i].fd, &writefds ) );
|
||||
FD_SET ( fds[i].fd, &writefds );
|
||||
if ( fds[i].fd > max_fd )
|
||||
max_fd = fds[i].fd;
|
||||
DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd );
|
||||
any = 1;
|
||||
}
|
||||
fds[i].signaled = 0;
|
||||
fds[i].signaled = 0;
|
||||
}
|
||||
DEBUG_END (dbg_help, "]" );
|
||||
if ( !any )
|
||||
return 0;
|
||||
DEBUG_END (dbg_help, "]");
|
||||
if (!any)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
count = select ( max_fd+1, &readfds, &writefds, NULL, &timeout );
|
||||
} while ( count < 0 && errno == EINTR);
|
||||
if ( count < 0 ) {
|
||||
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno) );
|
||||
return -1; /* error */
|
||||
do
|
||||
{
|
||||
count = select (max_fd + 1, &readfds, &writefds, NULL, &timeout);
|
||||
}
|
||||
while (count < 0 && errno == EINTR);
|
||||
if (count < 0)
|
||||
{
|
||||
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
if ( _gpgme_debug_level () > 2 )
|
||||
DEBUG_BEGIN (dbg_help, "select OK [ " );
|
||||
if (DEBUG_ENABLED(dbg_help)) {
|
||||
for (i=0; i <= max_fd; i++ ) {
|
||||
if (FD_ISSET (i, &readfds) )
|
||||
DEBUG_ADD1 (dbg_help, "r%d ", i );
|
||||
if (FD_ISSET (i, &writefds) )
|
||||
DEBUG_ADD1 (dbg_help, "w%d ", i );
|
||||
if (_gpgme_debug_level () > 2)
|
||||
DEBUG_BEGIN (dbg_help, "select OK [ ");
|
||||
if (DEBUG_ENABLED(dbg_help))
|
||||
{
|
||||
for (i = 0; i <= max_fd; i++)
|
||||
{
|
||||
if (FD_ISSET (i, &readfds))
|
||||
DEBUG_ADD1 (dbg_help, "r%d ", i);
|
||||
if (FD_ISSET (i, &writefds))
|
||||
DEBUG_ADD1 (dbg_help, "w%d ", i);
|
||||
}
|
||||
DEBUG_END (dbg_help, "]" );
|
||||
DEBUG_END (dbg_help, "]");
|
||||
}
|
||||
|
||||
/* n is used to optimize it a little bit */
|
||||
for ( n=count, i=0; i < nfds && n ; i++ ) {
|
||||
if ( fds[i].fd == -1 )
|
||||
;
|
||||
else if ( fds[i].for_read ) {
|
||||
if ( FD_ISSET ( fds[i].fd, &readfds ) ) {
|
||||
fds[i].signaled = 1;
|
||||
n--;
|
||||
/* n is used to optimize it a little bit. */
|
||||
for (n = count, i = 0; i < nfds && n; i++)
|
||||
{
|
||||
if (fds[i].fd == -1)
|
||||
;
|
||||
else if (fds[i].for_read)
|
||||
{
|
||||
if (FD_ISSET (fds[i].fd, &readfds))
|
||||
{
|
||||
fds[i].signaled = 1;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
else if ( fds[i].for_write ) {
|
||||
if ( FD_ISSET ( fds[i].fd, &writefds ) ) {
|
||||
fds[i].signaled = 1;
|
||||
n--;
|
||||
else if (fds[i].for_write)
|
||||
{
|
||||
if (FD_ISSET (fds[i].fd, &writefds))
|
||||
{
|
||||
fds[i].signaled = 1;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* posix-sema.c
|
||||
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -19,53 +19,101 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#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 "syshdr.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "sema.h"
|
||||
#include "mutex.h"
|
||||
|
||||
static void
|
||||
sema_fatal (const char *text)
|
||||
{
|
||||
fprintf (stderr, "sema.c: %s\n", text);
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
critsect_init (struct critsect_s *s)
|
||||
{
|
||||
static mutex_t init_lock;
|
||||
static int initialized;
|
||||
mutex_t *mp;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* The very first time we call this function, we assume that
|
||||
only one thread is running, so that we can bootstrap the
|
||||
semaphore code. */
|
||||
mutex_init (init_lock);
|
||||
initialized = 1;
|
||||
}
|
||||
if (!s)
|
||||
return; /* We just want to initialize ourself. */
|
||||
|
||||
/* First test whether it is really not initialized. */
|
||||
mutex_lock (init_lock);
|
||||
if (s->private)
|
||||
{
|
||||
mutex_unlock (init_lock);
|
||||
return;
|
||||
}
|
||||
/* Now initialize it. */
|
||||
mp = xtrymalloc (sizeof *mp);
|
||||
if (!mp)
|
||||
{
|
||||
mutex_unlock (init_lock);
|
||||
sema_fatal ("out of core while creating critical section lock");
|
||||
}
|
||||
mutex_init (*mp);
|
||||
s->private = mp;
|
||||
mutex_unlock (init_lock);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_gpgme_sema_subsystem_init ()
|
||||
{
|
||||
/* FIXME: Posix semaphore support has not yet been implemented */
|
||||
/* FIXME: we should check that there is only one thread running */
|
||||
critsect_init (NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_gpgme_sema_cs_enter ( struct critsect_s *s )
|
||||
_gpgme_sema_cs_enter (struct critsect_s *s)
|
||||
{
|
||||
if (!s->private)
|
||||
critsect_init (s);
|
||||
mutex_lock (*((mutex_t *) s->private));
|
||||
}
|
||||
|
||||
void
|
||||
_gpgme_sema_cs_leave (struct critsect_s *s)
|
||||
{
|
||||
if (!s->private)
|
||||
critsect_init (s);
|
||||
mutex_unlock (*((mutex_t *) s->private));
|
||||
}
|
||||
|
||||
void
|
||||
_gpgme_sema_cs_destroy ( struct critsect_s *s )
|
||||
_gpgme_sema_cs_destroy (struct critsect_s *s)
|
||||
{
|
||||
if (s && s->private)
|
||||
{
|
||||
mutex_destroy (*((mutex_t *) s->private));
|
||||
xfree (s->private);
|
||||
s->private = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* posix-util.c - Utility functions for Posix
|
||||
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -19,10 +19,9 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -49,5 +48,3 @@ _gpgme_get_gpgsm_path (void)
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||
|
@ -1,40 +0,0 @@
|
||||
/* syshdr.h - System specfic header files
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SYSHDR_H
|
||||
#define SYSHDR_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* SYSHDR_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* w32-io.c - W32 API I/O functions
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -19,20 +19,20 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#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 <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <windows.h>
|
||||
#include "syshdr.h"
|
||||
#include <io.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "sema.h"
|
||||
@ -1120,14 +1120,3 @@ _gpgme_io_select ( struct io_select_fd_s *fds, size_t nfds )
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /*HAVE_DOSISH_SYSTEM*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* w32-sema.c
|
||||
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -19,21 +19,20 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#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 <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <windows.h>
|
||||
#include "syshdr.h"
|
||||
#include <io.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "sema.h"
|
||||
@ -113,12 +112,3 @@ _gpgme_sema_cs_destroy ( struct critsect_s *s )
|
||||
s->private = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /*HAVE_DOSISH_SYSTEM*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* w32-util.c - Utility functions for the W32 API
|
||||
* Copyright (C) 1999 Free Software Foundation, Inc
|
||||
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -20,10 +20,9 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -34,60 +33,61 @@
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
#include "syshdr.h"
|
||||
#include <io.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 for HKEY_CURRENT_USER.
|
||||
*/
|
||||
/* 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
|
||||
for HKEY_CURRENT_USER. */
|
||||
static char *
|
||||
read_w32_registry_string ( const char *root,
|
||||
const char *dir, const char *name )
|
||||
read_w32_registry_string (const char *root, const char *dir, const char *name)
|
||||
{
|
||||
HKEY root_key, key_handle;
|
||||
DWORD n1, nbytes;
|
||||
char *result = NULL;
|
||||
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 (!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 */
|
||||
if (RegOpenKeyEx (root_key, dir, 0, KEY_READ, &key_handle))
|
||||
return NULL; /* No need for a RegClose, so return directly. */
|
||||
|
||||
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;
|
||||
nbytes = 1;
|
||||
if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes))
|
||||
goto leave;
|
||||
n1 = nbytes + 1;
|
||||
result = xtrymalloc (n1);
|
||||
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 */
|
||||
result[nbytes] = 0; /* Make sure it is really a string. */
|
||||
|
||||
leave:
|
||||
RegCloseKey( key_handle );
|
||||
return result;
|
||||
leave:
|
||||
RegCloseKey (key_handle);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
find_program_in_registry (const char *name)
|
||||
{
|
||||
@ -98,7 +98,7 @@ find_program_in_registry (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
DEBUG1 ("found %s in registry: `%s'", name, program );
|
||||
DEBUG1 ("found %s in registry: `%s'", name, program);
|
||||
for (i = 0; program[i]; i++)
|
||||
{
|
||||
if (program[i] == '/')
|
||||
@ -108,6 +108,7 @@ find_program_in_registry (const char *name)
|
||||
return program;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
_gpgme_get_gpg_path (void)
|
||||
{
|
||||
@ -135,6 +136,3 @@ _gpgme_get_gpgsm_path (void)
|
||||
#endif
|
||||
return gpgsm_program;
|
||||
}
|
||||
|
||||
|
||||
#endif /*HAVE_DOSISH_SYSTEM*/
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include "syshdr.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
|
22
gpgme/wait.h
22
gpgme/wait.h
@ -1,6 +1,6 @@
|
||||
/* wait.h - definitions for wait.c
|
||||
/* wait.h - Definitions for the wait queue interface.
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
@ -24,17 +24,11 @@
|
||||
|
||||
#include "gpgme.h"
|
||||
|
||||
void _gpgme_remove_proc_from_wait_queue ( int pid );
|
||||
|
||||
GpgmeError _gpgme_register_pipe_handler (
|
||||
void *opaque,
|
||||
int (*handler)(void*,int,int),
|
||||
void *handler_value,
|
||||
int pid, int fd, int inbound );
|
||||
|
||||
#endif /* WAIT_H */
|
||||
|
||||
|
||||
|
||||
void _gpgme_remove_proc_from_wait_queue (int pid);
|
||||
|
||||
GpgmeError _gpgme_register_pipe_handler (void *opaque,
|
||||
int (*handler) (void*, int, int),
|
||||
void *handler_value,
|
||||
int pid, int fd, int inbound);
|
||||
|
||||
#endif /* WAIT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user