2003-08-18 Marcus Brinkmann <marcus@g10code.de>

*configure.ac (AM_PATH_GPG_ERROR): Require 0.3.

assuan/
See README.1st.

gpgme/
2003-08-19  Marcus Brinkmann  <marcus@g10code.de>

	The ath files (ath.h, ath.c, ath-pth.c, ath-pthread.c,
	ath-compat.c, ath-pth-compat.c and ath-pthread-compat.c) have been
	updated to have better thread support, and the Makefile.am was
	changed to reflect that.

	* util.h [!HAVE_FOPENCOOKIE]: Remove fopencookie declaration.
	* engine-gpgsm.c (gpgsm_assuan_simple_command): Set ERR to return
	value of status_fnc.
	* rungpg.c (start): Return SAVED_ERRNO, not errno.
This commit is contained in:
Marcus Brinkmann 2003-08-20 20:20:46 +00:00
parent c93237c3a4
commit 0217495902
19 changed files with 852 additions and 276 deletions

View File

@ -3,6 +3,7 @@
* configure.ac: If building Assuan, check for funopen and * configure.ac: If building Assuan, check for funopen and
fopencookie, and make isascii, putc_unlocked and memrchr fopencookie, and make isascii, putc_unlocked and memrchr
replacement functions. replacement functions.
(AM_PATH_GPG_ERROR): Require 0.3.
2003-07-31 Marcus Brinkmann <marcus@g10code.de> 2003-07-31 Marcus Brinkmann <marcus@g10code.de>

10
NEWS
View File

@ -1,6 +1,16 @@
Noteworthy changes in version 0.4.3 (unreleased) Noteworthy changes in version 0.4.3 (unreleased)
------------------------------------------------ ------------------------------------------------
* libgpgme should not be used for threaded programs anymore. This
never worked reliably in all cases, because you had to
be careful about the linking order and libtool wouldn't do that for
you automatically. Instead, now you have to link against
libgpgme-pthread for applications using pthread and libgpgme-pth for
applications using GNU Pth.
The old code for automagically detecting the thread library is
still part of libgpgme, but it is DEPRECATED.
* gpgme_get_key fails with GPG_ERR_AMBIGUOUS_NAME if the key ID * gpgme_get_key fails with GPG_ERR_AMBIGUOUS_NAME if the key ID
provided was not unique, instead returning the first matching key. provided was not unique, instead returning the first matching key.

6
TODO
View File

@ -1,12 +1,14 @@
Hey Emacs, this is -*- outline -*- mode! Hey Emacs, this is -*- outline -*- mode!
* Before release: * Before release:
** Nothing. ** Write --thread option for gpgme-config.
** Document new thread support.
* ABI's to break: * ABI's to break:
** I/O and User Data could be made extensible. But this can be done ** I/O and User Data could be made extensible. But this can be done
without breaking the ABI hopefully. without breaking the ABI hopefully.
** Compatibility interfaces that can be removed in future versions: ** Compatibility interfaces that can be removed in future versions:
*** ath compatibility modules.
*** gpgme_data_new_from_filepart *** gpgme_data_new_from_filepart
*** gpgme_data_new_from_file *** gpgme_data_new_from_file
*** gpgme_data_new_with_read_cb *** gpgme_data_new_with_read_cb
@ -24,6 +26,7 @@ Hey Emacs, this is -*- outline -*- mode!
*** All Gpgme* typedefs. *** All Gpgme* typedefs.
* Thread support: * Thread support:
** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
** Build thread modules for static linking (which just suck in the ** Build thread modules for static linking (which just suck in the
desired symbols the hard way). !! desired symbols the hard way). !!
** Ordering the libs is important, but libtool gets it wrong. Argh. ** Ordering the libs is important, but libtool gets it wrong. Argh.
@ -76,6 +79,7 @@ Hey Emacs, this is -*- outline -*- mode!
* Operations * Operations
** If an operation failed, make sure that the result functions don't return ** If an operation failed, make sure that the result functions don't return
corrupt partial information. !!! corrupt partial information. !!!
NOTE: The EOF status handler is not called in this case !!!
** If no passphrase cb is installed, status handler is not run even if ** If no passphrase cb is installed, status handler is not run even if
password is required by crypto engine. !! password is required by crypto engine. !!
** Export status handler need much more work. !!! ** Export status handler need much more work. !!!

View File

@ -26,6 +26,7 @@ MOSTLYCLEANFILES = assuan-errors.c
noinst_LTLIBRARIES = libassuan.la noinst_LTLIBRARIES = libassuan.la
AM_CPPFLAGS = -D_ASSUAN_IN_GPGME_BUILD_ASSUAN
#libassuan_la_LDFLAGS = #libassuan_la_LDFLAGS =
libassuan_la_SOURCES = \ libassuan_la_SOURCES = \

View File

@ -1,3 +1,22 @@
This is a modified copy of the libassuan library. Don't modify it, This is a modified copy of the libassuan library. Don't modify it,
but instead modify the original Assuan library and merge the changes but instead modify the original Assuan library and merge the changes
back into this copy. back into this copy.
The changes to the original libassuan, that have to preserved when
updating this directory, are:
* Makefile.am
** Build the library with libtool as a convenience library, which can
be linked into the shared library GPGME.
** Do not install the library or the header file.
** Define -D_ASSUAN_IN_GPGME_BUILD_ASSUAN to wrap some POSIX functions
with ATH replacements.
* assuan.h
** Define _ASSUAN_IN_GPGME to enable GPGME specific code.
** Put all exported Assuan functions in the _gpgme namespace.
** Also wrap all system functions that are wrapped by GNU Pth to
_gpgme wrappers.
* assuan-io.c
** Don't try to support GNU Pth here.

View File

@ -22,6 +22,21 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#ifdef _ASSUAN_IN_GPGME
ssize_t
_assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size)
{
return read (ctx->inbound.fd, buffer, size);
}
ssize_t
_assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size)
{
return write (ctx->outbound.fd, buffer, size);
}
#else
extern ssize_t pth_read (int fd, void *buffer, size_t size); extern ssize_t pth_read (int fd, void *buffer, size_t size);
extern ssize_t pth_write (int fd, const void *buffer, size_t size); extern ssize_t pth_write (int fd, const void *buffer, size_t size);
@ -39,3 +54,5 @@ _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size)
{ {
return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size); return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size);
} }
#endif

View File

@ -25,11 +25,128 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h>
#define _ASSUAN_IN_GPGME
#ifdef _ASSUAN_IN_GPGME
#define _ASSUAN_EXT_SYM_PREFIX _gpgme_
#ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN
int _gpgme_io_read (int fd, void *buffer, size_t count);
int _gpgme_io_write (int fd, const void *buffer, size_t count);
ssize_t _gpgme_ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout);
ssize_t _gpgme_ath_waitpid (pid_t pid, int *status, int options);
int _gpgme_ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
int _gpgme_ath_connect (int s, struct sockaddr *addr, socklen_t length);
int _gpgme_ath_sendmsg (int s, const struct msghdr *msg, int flags);
int _gpgme_ath_recvmsg (int s, struct msghdr *msg, int flags);
#define read _gpgme_io_read
#define write _gpgme_io_write
#define waitpid _gpgme_ath_waitpid
#define select _gpgme_ath_select
#define accept _gpgme_ath_accept
#define connect _gpgme_ath_connect
#define sendmsg _gpgme_ath_sendmsg
#define recvmsg _gpgme_ath_recvmsg
#endif
#endif
#ifdef _ASSUAN_EXT_SYM_PREFIX
#define _ASSUAN_PREFIX1(x,y) x ## y
#define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y)
#define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
#define assuan_ _ASSUAN_PREFIX(assuan_)
#define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
#define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify)
#define assuan_register_reset_notify \
_ASSUAN_PREFIX(assuan_register_reset_notify)
#define assuan_register_cancel_notify \
_ASSUAN_PREFIX(assuan_register_cancel_notify)
#define assuan_register_input_notify \
_ASSUAN_PREFIX(assuan_register_input_notify)
#define assuan_register_output_notify \
_ASSUAN_PREFIX(assuan_register_output_notify)
#define assuan_register_option_handler \
_ASSUAN_PREFIX(assuan_register_option_handler)
#define assuan_process _ASSUAN_PREFIX(assuan_process)
#define assuan_process_next _ASSUAN_PREFIX(assuan_process_next)
#define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds)
#define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp)
#define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line)
#define assuan_write_status _ASSUAN_PREFIX(assuan_write_status)
#define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd)
#define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line)
#define assuan_accept _ASSUAN_PREFIX(assuan_accept)
#define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd)
#define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd)
#define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd)
#define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd)
#define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server)
#define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server)
#define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server)
#define assuan_init_connected_socket_server \
_ASSUAN_PREFIX(assuan_init_connected_socket_server)
#define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect)
#define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect)
#define assuan_domain_connect _ASSUAN_PREFIX(assuan_domain_connect)
#define assuan_init_domain_server _ASSUAN_PREFIX(assuan_init_domain_server)
#define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect)
#define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid)
#define assuan_transact _ASSUAN_PREFIX(assuan_transact)
#define assuan_inquire _ASSUAN_PREFIX(assuan_inquire)
#define assuan_read_line _ASSUAN_PREFIX(assuan_read_line)
#define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line)
#define assuan_write_line _ASSUAN_PREFIX(assuan_write_line)
#define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
#define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
#define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
#define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
#define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
#define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
#define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
#define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
#define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
#define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
#define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
#define assuan_set_assuan_log_stream \
_ASSUAN_PREFIX(assuan_set_assuan_log_stream)
#define assuan_get_assuan_log_stream \
_ASSUAN_PREFIX(assuan_get_assuan_log_stream)
#define assuan_get_assuan_log_prefix \
_ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
/* And now the internal functions, argh... */
#define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
#define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
#define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
#define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
#define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
#define _assuan_register_std_commands \
_ASSUAN_PREFIX(_assuan_register_std_commands)
#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
#define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
#define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
#define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
#define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
#define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
#define _assuan_free _ASSUAN_PREFIX(_assuan_free)
#define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
#define _assuan_log_sanitized_string \
_ASSUAN_PREFIX(_assuan_log_sanitized_string)
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
typedef enum typedef enum
{ {
ASSUAN_No_Error = 0, ASSUAN_No_Error = 0,

View File

@ -157,7 +157,7 @@ if test "$ac_cv_func_vasprintf" != yes; then
GNUPG_CHECK_VA_COPY GNUPG_CHECK_VA_COPY
fi fi
AM_PATH_GPG_ERROR(0.1,, AC_MSG_ERROR([libgpg-error was not found])) AM_PATH_GPG_ERROR(0.3,, AC_MSG_ERROR([libgpg-error was not found]))
AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME, AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
[The default error source for GPGME.]) [The default error source for GPGME.])
@ -243,24 +243,23 @@ fi
AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
dnl Make the version number in gpgme/gpgme.h the same as the one here. # Make the version number in gpgme/gpgme.h the same as the one here.
dnl (this is easier than to have a *.in file just for one substitution) # (this is easier than to have a *.in file just for one substitution)
GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION) GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
dnl Substitution used for gpgme-config # Substitution used for gpgme-config
GPGME_CONFIG_LIBS="-lgpgme" GPGME_CONFIG_LIBS="-lgpgme"
GPGME_CONFIG_CFLAGS="" GPGME_CONFIG_CFLAGS=""
AC_SUBST(GPGME_CONFIG_LIBS) AC_SUBST(GPGME_CONFIG_LIBS)
AC_SUBST(GPGME_CONFIG_CFLAGS) AC_SUBST(GPGME_CONFIG_CFLAGS)
dnl Frob'da Variables # Frob'da Variables
LTLIBOBJS=`echo "$LIB@&t@OBJS" | LTLIBOBJS=`echo "$LIB@&t@OBJS" |
sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
AC_SUBST(LTLIBOBJS) AC_SUBST(LTLIBOBJS)
dnl #
dnl Create config files # Create config files
dnl
AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile
tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile

View File

@ -1,3 +1,19 @@
2003-08-19 Marcus Brinkmann <marcus@g10code.de>
The ath files (ath.h, ath.c, ath-pth.c, ath-pthread.c,
ath-compat.c, ath-pth-compat.c and ath-pthread-compat.c) have been
updated to have better thread support, and the Makefile.am was
changed to reflect that.
* util.h [!HAVE_FOPENCOOKIE]: Remove fopencookie declaration.
* engine-gpgsm.c (gpgsm_assuan_simple_command): Set ERR to return
value of status_fnc.
* rungpg.c (start): Return SAVED_ERRNO, not errno.
2003-08-18 Marcus Brinkmann <marcus@g10code.de>
* rungpg.c (start): Use saved_errno instead errno.
2003-08-18 Marcus Brinkmann <marcus@g10code.de> 2003-08-18 Marcus Brinkmann <marcus@g10code.de>
* funopen.c, putc_unlocked.c, isascii.c, memrchr.c: New files. * funopen.c, putc_unlocked.c, isascii.c, memrchr.c: New files.

View File

@ -26,7 +26,20 @@ bin_SCRIPTS = gpgme-config
m4datadir = $(datadir)/aclocal m4datadir = $(datadir)/aclocal
m4data_DATA = gpgme.m4 m4data_DATA = gpgme.m4
include_HEADERS = gpgme.h include_HEADERS = gpgme.h
lib_LTLIBRARIES = libgpgme.la
if HAVE_PTHREAD
ltlib_gpgme_pthread = libgpgme-pthread.la
else
ltlib_gpgme_pthread =
endif
if HAVE_PTH
ltlib_gpgme_pth = libgpgme-pth.la
else
ltlib_gpgme_pth =
endif
noinst_LTLIBRARIES = libgpgme-real.la
lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_pthread) $(ltlib_gpgme_pth)
if HAVE_LD_VERSION_SCRIPT if HAVE_LD_VERSION_SCRIPT
libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers
@ -34,9 +47,6 @@ else
libgpgme_version_script_cmd = libgpgme_version_script_cmd =
endif endif
libgpgme_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
if BUILD_ASSUAN if BUILD_ASSUAN
assuan_cppflags = -I$(top_srcdir)/assuan assuan_cppflags = -I$(top_srcdir)/assuan
assuan_libobjs = ../assuan/libassuan.la assuan_libobjs = ../assuan/libassuan.la
@ -45,22 +55,10 @@ assuan_cppflags =
assuan_libobjs = assuan_libobjs =
endif endif
if HAVE_PTHREAD
ath_components_pthread = ath-pthread.c
else
ath_components_pthread =
endif
if HAVE_PTH
ath_components_pth = ath-pth.c
else
ath_components_pth =
endif
ath_components = ath.h ath.c ${ath_components_pthread} ${ath_components_pth}
if HAVE_DOSISH_SYSTEM if HAVE_DOSISH_SYSTEM
system_components = w32-util.c w32-sema.c w32-io.c system_components = w32-util.c w32-sema.c w32-io.c
else else
system_components = ${ath_components} posix-util.c posix-sema.c posix-io.c system_components = ath.h posix-util.c posix-sema.c posix-io.c
endif endif
if HAVE_GPGSM if HAVE_GPGSM
@ -69,7 +67,7 @@ else
gpgsm_components = gpgsm_components =
endif endif
libgpgme_la_SOURCES = \ libgpgme_real_la_SOURCES = \
gpgme.h util.h conversion.c context.h ops.h \ gpgme.h util.h conversion.c context.h ops.h \
data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \ data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \
data-compat.c \ data-compat.c \
@ -81,13 +79,48 @@ libgpgme_la_SOURCES = \
key.c keylist.c trust-item.c trustlist.c \ key.c keylist.c trust-item.c trustlist.c \
import.c export.c genkey.c delete.c edit.c \ import.c export.c genkey.c delete.c edit.c \
engine.h engine-backend.h engine.c rungpg.c status-table.h \ engine.h engine-backend.h engine.c rungpg.c status-table.h \
${gpgsm_components} sema.h io.h ${system_components} \ $(gpgsm_components) sema.h io.h $(system_components) \
debug.c debug.h gpgme.c version.c error.c debug.c debug.h gpgme.c version.c error.c
AM_CPPFLAGS = ${assuan_cppflags} @GPG_ERROR_CFLAGS@ # libgpgme_la_SOURCES = ath.h ath.c
libgpgme_la_DEPENDENCIES = ${assuan_libobjs} @LTLIBOBJS@ \ if HAVE_PTH
$(srcdir)/libgpgme.vers ath_pth_src = ath-pth-compat.c
libgpgme_la_LIBADD = ${assuan_libobjs} @LTLIBOBJS@ @GPG_ERROR_LIBS@ else
ath_pth_src =
endif
if HAVE_PTHREAD
ath_pthread_src = ath-pthread-compat.c
else
ath_pthread_src =
endif
libgpgme_la_SOURCES = ath.h ath-compat.c $(ath_pth_src) $(ath_pthread_src)
libgpgme_pthread_la_SOURCES = ath.h ath-pthread.c
libgpgme_pth_la_SOURCES = ath.h ath-pth.c
AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@
libgpgme_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
libgpgme_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \
@LTLIBOBJS@ $(srcdir)/libgpgme.vers
libgpgme_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \
@GPG_ERROR_LIBS@
libgpgme_pthread_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
libgpgme_pthread_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \
@LTLIBOBJS@ $(srcdir)/libgpgme.vers
libgpgme_pthread_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \
-lpthread @GPG_ERROR_LIBS@
libgpgme_pth_la_CPPFLAGS = $(AM_CPPFLAGS) @PTH_CPPFLAGS@
libgpgme_pth_la_LDFLAGS = @PTH_LDFLAGS@ \
$(libgpgme_version_script_cmd) -version-info \
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
libgpgme_pth_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \
@LTLIBOBJS@ $(srcdir)/libgpgme.vers
libgpgme_pth_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \
@PTH_LIBS@ @GPG_ERROR_LIBS@
status-table.h : gpgme.h status-table.h : gpgme.h
$(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h $(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h

123
gpgme/ath-pth-compat.c Normal file
View File

@ -0,0 +1,123 @@
/* ath-pth.c - Pth module for self-adapting thread-safeness 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
*/
#include <stdlib.h>
#include <errno.h>
#include <pth.h>
#include "ath.h"
#pragma weak pth_mutex_init
#pragma weak pth_mutex_acquire
#pragma weak pth_mutex_release
#pragma weak pth_read
#pragma weak pth_write
#pragma weak pth_select
#pragma weak pth_waitpid
#pragma weak pth_accept
#pragma weak pth_connect
/* The lock we take while checking for lazy lock initialization. */
static pth_mutex_t check_init_lock = PTH_MUTEX_INIT;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */
static int
mutex_pth_init (void **priv, int just_check)
{
int err = 0;
if (just_check)
pth_mutex_acquire (&check_init_lock, 0, NULL);
if (!*priv || !just_check)
{
pth_mutex_t *lock = malloc (sizeof (pth_mutex_t));
if (!lock)
err = ENOMEM;
if (!err)
{
err = pth_mutex_init (lock);
if (err == FALSE)
err = errno;
else
err = 0;
if (err)
free (lock);
else
*priv = lock;
}
}
if (just_check)
pth_mutex_release (&check_init_lock);
return err;
}
static int
mutex_pth_destroy (void *priv)
{
free (priv);
return 0;
}
static int
mutex_pth_lock (void *priv)
{
int ret = pth_mutex_acquire ((pth_mutex_t *) priv, 0, NULL);
return ret == FALSE ? errno : 0;
}
static int
mutex_pth_unlock (void *priv)
{
int ret = pth_mutex_release ((pth_mutex_t *) priv);
return ret == FALSE ? errno : 0;
}
static struct ath_ops ath_pth_ops =
{
mutex_pth_init,
mutex_pth_destroy,
mutex_pth_lock,
mutex_pth_unlock,
pth_read,
pth_write,
pth_select,
pth_waitpid,
pth_accept,
pth_connect,
NULL, /* FIXME: When GNU PTh has sendmsg. */
NULL /* FIXME: When GNU PTh has recvmsg. */
};
struct ath_ops *
ath_pth_available (void)
{
if (pth_mutex_init && pth_mutex_acquire && pth_mutex_release
&& pth_read && pth_write && pth_select && pth_waitpid)
return &ath_pth_ops;
else
return 0;
}

View File

@ -1,36 +1,34 @@
/* ath-pth.c - Pth module for self-adapting thread-safeness library /* ath-pth.c - Pth module for self-adapting thread-safeness library
* Copyright (C) 2002 g10 Code GmbH Copyright (C) 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <pth.h> #include <pth.h>
#include "ath.h" #include "ath.h"
#pragma weak pth_mutex_init
#pragma weak pth_mutex_acquire
#pragma weak pth_mutex_release
#pragma weak pth_read
#pragma weak pth_write
#pragma weak pth_select
#pragma weak pth_waitpid
/* The lock we take while checking for lazy lock initialization. */ /* The lock we take while checking for lazy lock initialization. */
static pth_mutex_t check_init_lock = PTH_MUTEX_INIT; static pth_mutex_t check_init_lock = PTH_MUTEX_INIT;
@ -38,7 +36,7 @@ static pth_mutex_t check_init_lock = PTH_MUTEX_INIT;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if /* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */ it is not already initialized. */
static int static int
mutex_pth_init (void **priv, int just_check) mutex_pth_init (ath_mutex_t *priv, int just_check)
{ {
int err = 0; int err = 0;
@ -60,7 +58,7 @@ mutex_pth_init (void **priv, int just_check)
if (err) if (err)
free (lock); free (lock);
else else
*priv = lock; *priv = (ath_mutex_t) lock;
} }
} }
if (just_check) if (just_check)
@ -69,49 +67,111 @@ mutex_pth_init (void **priv, int just_check)
} }
static int void
mutex_pth_destroy (void *priv) ath_init (void)
{ {
free (priv); /* Nothing to do. */
return 0;
} }
static int int
mutex_pth_lock (void *priv) ath_mutex_init (ath_mutex_t *lock)
{ {
int ret = pth_mutex_acquire ((pth_mutex_t *) priv, 0, NULL); return mutex_pth_init (lock, 0);
}
int
ath_mutex_destroy (ath_mutex_t *lock)
{
int err = mutex_pth_init (lock, 1);
if (!err)
{
/* GNU Pth has no destructor function. */
free (*lock);
}
return err;
}
int
ath_mutex_lock (ath_mutex_t *lock)
{
int ret = mutex_pth_init (lock, 1);
if (ret)
return ret;
ret = pth_mutex_acquire ((pth_mutex_t *) *lock, 0, NULL);
return ret == FALSE ? errno : 0; return ret == FALSE ? errno : 0;
} }
static int int
mutex_pth_unlock (void *priv) ath_mutex_unlock (ath_mutex_t *lock)
{ {
int ret = pth_mutex_release ((pth_mutex_t *) priv); int ret = mutex_pth_init (lock, 1);
if (ret)
return ret;
ret = pth_mutex_release ((pth_mutex_t *) *lock);
return ret == FALSE ? errno : 0; return ret == FALSE ? errno : 0;
} }
static struct ath_ops ath_pth_ops = ssize_t
ath_read (int fd, void *buf, size_t nbytes)
{ {
mutex_pth_init, return pth_read (fd, buf, nbytes);
mutex_pth_destroy,
mutex_pth_lock,
mutex_pth_unlock,
pth_read,
pth_write,
pth_select,
pth_waitpid
};
struct ath_ops *
ath_pth_available (void)
{
if (pth_mutex_init && pth_mutex_acquire && pth_mutex_release
&& pth_read && pth_write && pth_select && pth_waitpid)
return &ath_pth_ops;
else
return 0;
} }
ssize_t
ath_write (int fd, const void *buf, size_t nbytes)
{
return pth_write (fd, buf, nbytes);
}
ssize_t
ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout)
{
return pth_select (nfd, rset, wset, eset, timeout);
}
ssize_t
ath_waitpid (pid_t pid, int *status, int options)
{
return pth_waitpid (pid, status, options);
}
int
ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
{
return pth_accept (s, addr, length_ptr);
}
int
ath_connect (int s, struct sockaddr *addr, socklen_t length)
{
return pth_connect (s, addr, length);
}
int
ath_sendmsg (int s, const struct msghdr *msg, int flags)
{
/* FIXME: GNU Pth is missing pth_sendmsg. */
return sendmsg (s, msg, flags);
}
int
ath_recvmsg (int s, struct msghdr *msg, int flags)
{
/* FIXME: GNU Pth is missing pth_recvmsg. */
return recvmsg (s, msg, flags);
}

104
gpgme/ath-pthread-compat.c Normal file
View File

@ -0,0 +1,104 @@
/* ath-pthread.c - pthread module for self-adapting thread-safeness 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
*/
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>
#include "ath.h"
/* Need to include pthread_create in our check, as the GNU C library
has the pthread_mutex_* functions in their public interface. */
#pragma weak pthread_create
#pragma weak pthread_mutex_init
#pragma weak pthread_mutex_destroy
#pragma weak pthread_mutex_lock
#pragma weak pthread_mutex_unlock
/* The lock we take while checking for lazy lock initialization. */
static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */
static int
mutex_pthread_init (void **priv, int just_check)
{
int err = 0;
if (just_check)
pthread_mutex_lock (&check_init_lock);
if (!*priv || !just_check)
{
pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t));
if (!lock)
err = ENOMEM;
if (!err)
{
err = pthread_mutex_init (lock, NULL);
if (err)
free (lock);
else
*priv = lock;
}
}
if (just_check)
pthread_mutex_unlock (&check_init_lock);
return err;
}
static int
mutex_pthread_destroy (void *priv)
{
int err = pthread_mutex_destroy ((pthread_mutex_t *) priv);
free (priv);
return err;
}
static struct ath_ops ath_pthread_ops =
{
mutex_pthread_init,
mutex_pthread_destroy,
(int (*) (void *)) pthread_mutex_lock,
(int (*) (void *)) pthread_mutex_unlock,
NULL, /* read */
NULL, /* write */
NULL, /* select */
NULL, /* waitpid */
NULL, /* accept */
NULL, /* connect */
NULL, /* sendmsg */
NULL /* recvmsg */
};
struct ath_ops *
ath_pthread_available (void)
{
/* Need to include pthread_create in our check, as the GNU C library
has the pthread_mutex_* functions in their public interface. */
if (pthread_create
&& pthread_mutex_init && pthread_mutex_destroy
&& pthread_mutex_lock && pthread_mutex_unlock)
return &ath_pthread_ops;
else
return 0;
}

View File

@ -1,36 +1,42 @@
/* ath-pthread.c - pthread module for self-adapting thread-safeness library /* ath-pthread.c - pthread module for self-adapting thread-safeness library
* Copyright (C) 2002 g10 Code GmbH Copyright (C) 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
# include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <pthread.h> #include <pthread.h>
#include "ath.h" #include "ath.h"
/* Need to include pthread_create in our check, as the GNU C library
has the pthread_mutex_* functions in their public interface. */
#pragma weak pthread_create
#pragma weak pthread_mutex_init
#pragma weak pthread_mutex_destroy
#pragma weak pthread_mutex_lock
#pragma weak pthread_mutex_unlock
/* The lock we take while checking for lazy lock initialization. */ /* The lock we take while checking for lazy lock initialization. */
static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER;
@ -38,7 +44,7 @@ static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if /* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */ it is not already initialized. */
static int static int
mutex_pthread_init (void **priv, int just_check) mutex_pthread_init (ath_mutex_t *priv, int just_check)
{ {
int err = 0; int err = 0;
@ -55,7 +61,7 @@ mutex_pthread_init (void **priv, int just_check)
if (err) if (err)
free (lock); free (lock);
else else
*priv = lock; *priv = (ath_mutex_t) lock;
} }
} }
if (just_check) if (just_check)
@ -64,37 +70,106 @@ mutex_pthread_init (void **priv, int just_check)
} }
static int void
mutex_pthread_destroy (void *priv) ath_init (void)
{ {
int err = pthread_mutex_destroy ((pthread_mutex_t *) priv); /* Nothing to do. */
free (priv); }
int
ath_mutex_init (ath_mutex_t *lock)
{
return mutex_pthread_init (lock, 0);
}
int
ath_mutex_destroy (ath_mutex_t *lock)
{
int err = mutex_pthread_init (lock, 1);
if (!err)
{
err = pthread_mutex_destroy ((pthread_mutex_t *) *lock);
free (*lock);
}
return err; return err;
} }
static struct ath_ops ath_pthread_ops = int
ath_mutex_lock (ath_mutex_t *lock)
{ {
mutex_pthread_init, int ret = mutex_pthread_init (lock, 1);
mutex_pthread_destroy, if (ret)
(int (*) (void *)) pthread_mutex_lock, return ret;
(int (*) (void *)) pthread_mutex_unlock,
NULL, /* read */
NULL, /* write */
NULL, /* select */
NULL /* waitpid */
};
return pthread_mutex_lock ((pthread_mutex_t *) *lock);
struct ath_ops * }
ath_pthread_available (void)
{
/* Need to include pthread_create in our check, as the GNU C library int
has the pthread_mutex_* functions in their public interface. */ ath_mutex_unlock (ath_mutex_t *lock)
if (pthread_create {
&& pthread_mutex_init && pthread_mutex_destroy int ret = mutex_pthread_init (lock, 1);
&& pthread_mutex_lock && pthread_mutex_unlock) if (ret)
return &ath_pthread_ops; return ret;
else
return 0; return pthread_mutex_unlock ((pthread_mutex_t *) *lock);
}
ssize_t
ath_read (int fd, void *buf, size_t nbytes)
{
return read (fd, buf, nbytes);
}
ssize_t
ath_write (int fd, const void *buf, size_t nbytes)
{
return write (fd, buf, nbytes);
}
ssize_t
ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout)
{
return select (nfd, rset, wset, eset, timeout);
}
ssize_t
ath_waitpid (pid_t pid, int *status, int options)
{
return waitpid (pid, status, options);
}
int
ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
{
return accept (s, addr, length_ptr);
}
int
ath_connect (int s, struct sockaddr *addr, socklen_t length)
{
return connect (s, addr, length);
}
int
ath_sendmsg (int s, const struct msghdr *msg, int flags)
{
return sendmsg (s, msg, flags);
}
int
ath_recvmsg (int s, struct msghdr *msg, int flags)
{
return recvmsg (s, msg, flags);
} }

View File

@ -1,27 +1,27 @@
/* ath.c - self-adapting thread-safeness library /* ath.c - Thread-safeness library.
* Copyright (C) 2002 g10 Code GmbH Copyright (C) 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <assert.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
@ -33,83 +33,61 @@
#include "ath.h" #include "ath.h"
static struct ath_ops *ath_ops;
void #define MUTEX_UNLOCKED ((ath_mutex_t) 0)
ath_init (void) #define MUTEX_LOCKED ((ath_mutex_t) 1)
{ #define MUTEX_DESTROYED ((ath_mutex_t) 2)
#ifdef HAVE_PTHREAD
if (!ath_ops)
ath_ops = ath_pthread_available ();
#endif
#ifdef HAVE_PTH
if (!ath_ops)
ath_ops = ath_pth_available ();
#endif
#ifdef HAVE_ATH_DUMMY
if (!ath_ops)
ath_ops = ath_dummy_available ();
#endif
}
int int
ath_mutex_init (ath_mutex_t *lock) ath_mutex_init (ath_mutex_t *lock)
{ {
if (!ath_ops) #ifndef NDEBUG
*lock = MUTEX_UNLOCKED;
#endif
return 0; return 0;
return ath_ops->mutex_init (lock, 0);
} }
int int
ath_mutex_destroy (ath_mutex_t *lock) ath_mutex_destroy (ath_mutex_t *lock)
{ {
int err; #ifndef NDEBUG
if (!ath_ops) assert (*lock == MUTEX_UNLOCKED);
*lock = MUTEX_DESTROYED;
#endif
return 0; return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_destroy (*lock);
return err;
} }
int int
ath_mutex_lock (ath_mutex_t *lock) ath_mutex_lock (ath_mutex_t *lock)
{ {
int err; #ifndef NDEBUG
assert (*lock == MUTEX_UNLOCKED);
if (!ath_ops) *lock = MUTEX_LOCKED;
#endif
return 0; return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_lock (*lock);
return err;
} }
int int
ath_mutex_unlock (ath_mutex_t *lock) ath_mutex_unlock (ath_mutex_t *lock)
{ {
int err; #ifndef NDEBUG
assert (*lock == MUTEX_LOCKED);
if (!ath_ops) *lock = MUTEX_UNLOCKED;
#endif
return 0; return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_unlock (*lock);
return err;
} }
ssize_t ssize_t
ath_read (int fd, void *buf, size_t nbytes) ath_read (int fd, void *buf, size_t nbytes)
{ {
if (ath_ops && ath_ops->read)
return ath_ops->read (fd, buf, nbytes);
else
return read (fd, buf, nbytes); return read (fd, buf, nbytes);
} }
@ -117,9 +95,6 @@ ath_read (int fd, void *buf, size_t nbytes)
ssize_t ssize_t
ath_write (int fd, const void *buf, size_t nbytes) ath_write (int fd, const void *buf, size_t nbytes)
{ {
if (ath_ops && ath_ops->write)
return ath_ops->write (fd, buf, nbytes);
else
return write (fd, buf, nbytes); return write (fd, buf, nbytes);
} }
@ -128,9 +103,6 @@ ssize_t
ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout) struct timeval *timeout)
{ {
if (ath_ops && ath_ops->select)
return ath_ops->select (nfd, rset, wset, eset, timeout);
else
return select (nfd, rset, wset, eset, timeout); return select (nfd, rset, wset, eset, timeout);
} }
@ -138,8 +110,33 @@ ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
ssize_t ssize_t
ath_waitpid (pid_t pid, int *status, int options) ath_waitpid (pid_t pid, int *status, int options)
{ {
if (ath_ops && ath_ops->waitpid)
return ath_ops->waitpid (pid, status, options);
else
return waitpid (pid, status, options); return waitpid (pid, status, options);
} }
int
ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
{
return accept (s, addr, length_ptr);
}
int
ath_connect (int s, struct sockaddr *addr, socklen_t length)
{
return connect (s, addr, length);
}
int
ath_sendmsg (int s, const struct msghdr *msg, int flags)
{
return sendmsg (s, msg, flags);
}
int
ath_recvmsg (int s, struct msghdr *msg, int flags)
{
return recvmsg (s, msg, flags);
}

View File

@ -1,47 +1,49 @@
/* ath.h - interfaces for self-adapting thread-safeness library /* ath.h - Interfaces for thread-safeness library.
* Copyright (C) 2002 g10 Code GmbH Copyright (C) 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#ifndef ATH_H #ifndef ATH_H
#define ATH_H #define ATH_H
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
/* Define ATH_EXT_SYM_PREFIX if you want to give all external symbols
/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
a prefix. */ a prefix. */
#define ATH_EXT_SYM_PREFIX _gpgme_ #define _ATH_EXT_SYM_PREFIX _gpgme_
#ifdef ATH_EXT_SYM_PREFIX #ifdef _ATH_EXT_SYM_PREFIX
#define ATH_PREFIX1(x,y) x ## y #define _ATH_PREFIX1(x,y) x ## y
#define ATH_PREFIX2(x,y) ATH_PREFIX1(x,y) #define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
#define ATH_PREFIX(x) ATH_PREFIX2(ATH_EXT_SYM_PREFIX,x) #define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
#define ath_init ATH_PREFIX(ath_init) #define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
#define ath_mutex_init ATH_PREFIX(ath_mutex_init) #define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
#define ath_mutex_destroy ATH_PREFIX(ath_mutex_destroy) #define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
#define ath_mutex_lock ATH_PREFIX(ath_mutex_lock) #define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
#define ath_mutex_unlock ATH_PREFIX(ath_mutex_unlock) #define ath_read _ATH_PREFIX(ath_read)
#define ath_read ATH_PREFIX(ath_read) #define ath_write _ATH_PREFIX(ath_write)
#define ath_write ATH_PREFIX(ath_write) #define ath_select _ATH_PREFIX(ath_select)
#define ath_select ATH_PREFIX(ath_select) #define ath_waitpid _ATH_PREFIX(ath_waitpid)
#define ath_waitpid ATH_PREFIX(ath_waitpid) #define ath_connect _ATH_PREFIX(ath_connect)
#define ath_pthread_available ATH_PREFIX(ath_pthread_available) #define ath_accept _ATH_PREFIX(ath_accept)
#define ath_pth_available ATH_PREFIX(ath_pth_available) #define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
#define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
#endif #endif
@ -61,8 +63,13 @@ ssize_t ath_write (int fd, const void *buf, size_t nbytes);
ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout); struct timeval *timeout);
ssize_t ath_waitpid (pid_t pid, int *status, int options); ssize_t ath_waitpid (pid_t pid, int *status, int options);
int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
int ath_connect (int s, struct sockaddr *addr, socklen_t length);
int ath_sendmsg (int s, const struct msghdr *msg, int flags);
int ath_recvmsg (int s, struct msghdr *msg, int flags);
#define _ATH_COMPAT
#ifdef _ATH_COMPAT
struct ath_ops struct ath_ops
{ {
int (*mutex_init) (void **priv, int just_check); int (*mutex_init) (void **priv, int just_check);
@ -74,14 +81,21 @@ struct ath_ops
ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout); struct timeval *timeout);
ssize_t (*waitpid) (pid_t pid, int *status, int options); ssize_t (*waitpid) (pid_t pid, int *status, int options);
int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
int (*connect) (int s, struct sockaddr *addr, socklen_t length);
int (*sendmsg) (int s, const struct msghdr *msg, int flags);
int (*recvmsg) (int s, struct msghdr *msg, int flags);
}; };
/* Initialize the any-thread package. */ /* Initialize the any-thread package. */
#define ath_init _ATH_PREFIX(ath_init)
void ath_init (void); void ath_init (void);
/* Used by ath_pkg_init. */ /* Used by ath_pkg_init. */
#define ath_pthread_available _ATH_PREFIX(ath_pthread_available)
struct ath_ops *ath_pthread_available (void); struct ath_ops *ath_pthread_available (void);
#define ath_pth_available _ATH_PREFIX(ath_pth_available)
struct ath_ops *ath_pth_available (void); struct ath_ops *ath_pth_available (void);
struct ath_ops *ath_dummy_available (void); #endif
#endif /* ATH_H */ #endif /* ATH_H */

View File

@ -601,7 +601,7 @@ gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd,
r = parse_status (line + 2); r = parse_status (line + 2);
if (r >= 0 && status_fnc) if (r >= 0 && status_fnc)
status_fnc (status_fnc_value, r, rest); err = status_fnc (status_fnc_value, r, rest);
else else
err = gpg_error (GPG_ERR_GENERAL); err = gpg_error (GPG_ERR_GENERAL);
} }
@ -685,7 +685,7 @@ status_handler (void *opaque, int fd)
if (assuan_err) if (assuan_err)
{ {
/* Try our best to terminate the connection friendly. */ /* Try our best to terminate the connection friendly. */
assuan_write_line (gpgsm->assuan_ctx, "BYE"); /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */
err = map_assuan_error (assuan_err); err = map_assuan_error (assuan_err);
} }
else if (linelen >= 3 else if (linelen >= 3

View File

@ -1097,7 +1097,7 @@ start (engine_gpg_t gpg)
saved_errno = errno; saved_errno = errno;
free (fd_child_list); free (fd_child_list);
if (status == -1) if (status == -1)
return gpg_error_from_errno (errno); return gpg_error_from_errno (saved_errno);
/*_gpgme_register_term_handler ( closure, closure_value, pid );*/ /*_gpgme_register_term_handler ( closure, closure_value, pid );*/

View File

@ -43,21 +43,7 @@ char *stpcpy (char *a, const char *b);
int vasprintf (char **result, const char *format, va_list args); int vasprintf (char **result, const char *format, va_list args);
int asprintf (char **result, const char *format, ...); int asprintf (char **result, const char *format, ...);
#endif #endif
#endif
#if !HAVE_FOPENCOOKIE
#include <fcntl.h> /* make sure that ssize_t and off_t are defined */
typedef struct
{
ssize_t (*read)(void*,char*,size_t);
ssize_t (*write)(void*,const char*,size_t);
int (*seek)(void*,off_t*,int);
int (*close)(void*);
} _IO_cookie_io_functions_t;
typedef _IO_cookie_io_functions_t cookie_io_functions_t;
FILE *fopencookie (void *cookie, const char *opentype,
cookie_io_functions_t funclist);
#endif /*!HAVE_FOPENCOOKIE*/
#endif /*HAVE_CONFIG_H*/
/*-- conversion.c --*/ /*-- conversion.c --*/