[svn] assuan - r217 - in trunk: . doc m4 src

svn author wk cvs at cvs.gnupg.org
Mon Oct 9 13:35:36 CEST 2006


Author: wk
Date: 2006-10-09 13:35:35 +0200 (Mon, 09 Oct 2006)
New Revision: 217

Added:
   trunk/m4/gnupg-pth.m4
   trunk/src/assuan-io-pth.c
Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/configure.ac
   trunk/doc/assuan.texi
   trunk/m4/Makefile.am
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/assuan-io.c
   trunk/src/libassuan-config.in
   trunk/src/libassuan.m4
Log:
Splitted up into a standad lib and an pth enabled one.
Also enhanced libassuan-config and libassuan.m4.
Not really tested!


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/ChangeLog	2006-10-09 11:35:35 UTC (rev 217)
@@ -1,3 +1,7 @@
+2006-10-09  Werner Koch  <wk at g10code.com>
+
+	* m4/gnupg-pth.m4: New.  Taked from GnuPG.
+
 2006-10-04  Werner Koch  <wk at g10code.com>
 
 	Released 0.9.2.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/NEWS	2006-10-09 11:35:35 UTC (rev 217)
@@ -1,3 +1,8 @@
+Noteworthy changes in version 0.9.3
+------------------------------------------------
+
+
+
 Noteworthy changes in version 0.9.2 (2006-10-04)
 ------------------------------------------------
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/configure.ac	2006-10-09 11:35:35 UTC (rev 217)
@@ -25,7 +25,7 @@
 
 # Version number: Remember to change it immediately *after* a release.
 #                 Add a "-cvs" prefix for non-released code.
-AC_INIT(libassuan, 0.9.2, gnupg-devel at gnupg.org)
+AC_INIT(libassuan, 0.9.3-cvs, gnupg-devel at gnupg.org)
 # Note, that this is not yet available as a shared library.
 
 PACKAGE=$PACKAGE_NAME
@@ -106,24 +106,39 @@
 fi
 dnl AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
 
+#
+# See whether we can build a Pth enabled version
+#
+GNUPG_PATH_PTH
+AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes")
+
+
 # Check for network libraries.
 NETLIBS=
 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
 	[NETLIBS="-lsocket"]))
 
 # For src/libassuan-config.in
-LIBASSUAN_CONFIG_LIBS="-lassuan"
+LIBASSUAN_CONFIG_LIB="-lassuan"
 LIBASSUAN_CONFIG_CFLAGS=""
+LIBASSUAN_CONFIG_API_VERSION="1"
+LIBASSUAN_CONFIG_THREAD_MODULES=
+if test "$have_pth" = yes; then
+LIBASSUAN_CONFIG_THREAD_MODULES="pth"
+fi
+LIBASSUAN_CONFIG_EXTRA_LIBS=
 if test "$have_w32_system" = yes; then
-  LIBASSUAN_CONFIG_LIBS="$LIBASSUAN_CONFIG_LIBS -lwsock32"
+  LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lwsock32"
 fi
 if test x"$NETLIBS" != x; then
-  LIBASSUAN_CONFIG_LIBS="$LIBASSUAN_CONFIG_LIBS $NETLIBS"
+  LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS"
 fi
-AC_SUBST(LIBASSUAN_CONFIG_LIBS)
+AC_SUBST(LIBASSUAN_CONFIG_LIB)
 AC_SUBST(LIBASSUAN_CONFIG_CFLAGS)
+AC_SUBST(LIBASSUAN_CONFIG_API_VERSION)
+AC_SUBST(LIBASSUAN_CONFIG_THREAD_MODULES)
+AC_SUBST(LIBASSUAN_CONFIG_EXTRA_LIBS)
 
-
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([string.h locale.h sys/uio.h])

Modified: trunk/doc/assuan.texi
===================================================================
--- trunk/doc/assuan.texi	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/doc/assuan.texi	2006-10-09 11:35:35 UTC (rev 217)
@@ -507,6 +507,11 @@
 gcc -o foo foo.c $(libassuan-config --cflags --libs)
 @end example
 
+If your application uses Pth or pthread, you need to pass the option
+ at option{--thread=pth} respective @option{--thread=pthread} to the
+invocation of @command{libassuan-config}.
+
+
 @node Automake
 @section Building sources using Automake
 
@@ -534,7 +539,24 @@
 LDADD = $(LIBASSUAN_LIBS)
 @end example
 
+ at defmac AM_PATH_LIBASSUAN_PTH (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
+Same as @code{AM_PATH_LIBASSUAN} but checks for the GNU Pth enabled
+version of the library and defines @code{LIBASSUAN_PTH_CFLAGS}
+ at code{LIBASSUAN_PTH_LIBS} instead.  Use this is you are using GNU Pth.
+Note that you also need to pass the appropriate options for Pth to the
+compiler and linker.
+ at end defmac
 
+ at defmac AM_PATH_LIBASSUAN_PTHREAD (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
+Same as @code{AM_PATH_LIBASSUAN} but checks for the pthreads enabled
+version of the library and defines @code{LIBASSUAN_PTHREAD_CFLAGS}
+ at code{LIBASSUAN_PTHREAD_LIBS} instead.  Use this is you are using GNU Pth.
+Note that you also need to pass the appropriate options for Pth to the
+compiler and linker.
+ at end defmac
+
+
+
 @node Multi Threading
 @section Multi Threading
 

Modified: trunk/m4/Makefile.am
===================================================================
--- trunk/m4/Makefile.am	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/m4/Makefile.am	2006-10-09 11:35:35 UTC (rev 217)
@@ -1 +1 @@
-EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 autobuild.m4
+EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 autobuild.m4 gnupg-pth.m4

Added: trunk/m4/gnupg-pth.m4
===================================================================
--- trunk/m4/gnupg-pth.m4	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/m4/gnupg-pth.m4	2006-10-09 11:35:35 UTC (rev 217)
@@ -0,0 +1,114 @@
+dnl GnuPG's check for Pth.
+dnl       Copyright (C) 2003 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; as a special exception the author gives
+dnl unlimited permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+dnl This file is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+
+# GNUPG_PTH_VERSION_CHECK(REQUIRED)
+# 
+# If the version is sufficient, HAVE_PTH will be set to yes.
+#
+# Taken and modified from the m4 macros which come with Pth.
+AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
+  [
+    _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
+    _req_version="ifelse([$1],,1.2.0,$1)"
+
+    AC_MSG_CHECKING(for PTH - version >= $_req_version)
+    for _var in _pth_version _req_version; do
+        eval "_val=\"\$${_var}\""
+        _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
+        _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
+        _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
+        _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
+        case $_rtype in
+            "a" ) _rtype=0 ;;
+            "b" ) _rtype=1 ;;
+            "." ) _rtype=2 ;;
+        esac
+        _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
+              "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
+        eval "${_var}_hex=\"\$_hex\""
+    done
+    have_pth=no
+    if test ".$_pth_version_hex" != .; then
+        if test ".$_req_version_hex" != .; then
+            if test $_pth_version_hex -ge $_req_version_hex; then
+                have_pth=yes
+            fi
+        fi
+    fi
+    if test $have_pth = yes; then
+       AC_MSG_RESULT(yes)
+       AC_MSG_CHECKING([whether PTH installation is sane])
+       AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
+         _gnupg_pth_save_cflags=$CFLAGS
+         _gnupg_pth_save_ldflags=$LDFLAGS
+         _gnupg_pth_save_libs=$LIBS
+         CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
+         LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
+         LIBS="$LIBS `$PTH_CONFIG --libs`"
+         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
+                                         ],
+                                         [[ pth_init ();]])],
+                        gnupg_cv_pth_is_sane=yes,
+                        gnupg_cv_pth_is_sane=no)
+         CFLAGS=$_gnupg_pth_save_cflags
+         LDFLAGS=$_gnupg_pth_save_ldflags
+         LIBS=$_gnupg_pth_save_libs
+       ])
+       if test $gnupg_cv_pth_is_sane != yes; then
+          have_pth=no
+       fi
+       AC_MSG_RESULT($gnupg_cv_pth_is_sane)
+    else
+       AC_MSG_RESULT(no)
+    fi    
+  ])
+
+
+#
+# GNUPG_PATH_PTH([MINIMUM_VERSION])
+#
+# This is a special version of the check whioch assumes that a
+# emulation for W32 systems is available. The test assumes that
+# $have_w32_system has already been set.  On return $have_pth is set
+# as well as HAVE_PTH is defined and PTH_CLFAGS and PTH_LIBS are AS_SUBST.
+#
+AC_DEFUN([GNUPG_PATH_PTH],
+[ AC_ARG_WITH(pth-prefix,
+             AC_HELP_STRING([--with-pth-prefix=PFX],
+                           [prefix where GNU Pth is installed (optional)]),
+     pth_config_prefix="$withval", pth_config_prefix="")
+  if test x$pth_config_prefix != x ; then
+     PTH_CONFIG="$pth_config_prefix/bin/pth-config"
+  fi
+  AC_PATH_PROG(PTH_CONFIG, pth-config, no)
+  tmp=ifelse([$1], ,1.3.7,$1)
+  if test "$have_w32_system" = no; then
+   if test "$PTH_CONFIG" != "no"; then
+    GNUPG_PTH_VERSION_CHECK($tmp)
+    if test $have_pth = yes; then      
+       PTH_CFLAGS=`$PTH_CONFIG --cflags`
+       PTH_LIBS=`$PTH_CONFIG --ldflags`
+       PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`"
+       AC_DEFINE(HAVE_PTH, 1,
+                [Defined if the GNU Pth is available])
+    fi
+   fi
+  else 
+   have_pth=yes
+   PTH_CFLAGS=""
+   PTH_LIBS=""
+   AC_DEFINE(HAVE_PTH, 1)
+  fi
+  AC_SUBST(PTH_CFLAGS)
+  AC_SUBST(PTH_LIBS)
+])
+

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/src/ChangeLog	2006-10-09 11:35:35 UTC (rev 217)
@@ -1,3 +1,12 @@
+2006-10-09  Werner Koch  <wk at g10code.com>
+
+	* assuan-io.c: Removed Pth support.
+	* assuan-io-pth.c: New. Based on assuan-io.c
+
+2006-10-06  Werner Koch  <wk at g10code.com>
+
+	* libassuan-config.in: New options --api-version and --thread.
+
 2006-10-04  Werner Koch  <wk at g10code.com>
 
 	* assuan-client.c (assuan_transact): Need to map old assuan status

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/src/Makefile.am	2006-10-09 11:35:35 UTC (rev 217)
@@ -24,15 +24,20 @@
 BUILT_SOURCES = assuan-errors.c
 MOSTLYCLEANFILES = assuan-errors.c
 
+if HAVE_PTH
+libassuan_pth = libassuan-pth.a
+else
+libassuan_pth = 
+endif
+
 bin_SCRIPTS = libassuan-config
 m4datadir = $(datadir)/aclocal
 m4data_DATA = libassuan.m4
-lib_LIBRARIES = libassuan.a
+lib_LIBRARIES = libassuan.a $(libassuan_pth)
 include_HEADERS = assuan.h
 
 
-#libassuan_a_LDFLAGS =
-libassuan_a_SOURCES = \
+common_sources = \
 	assuan-defs.h \
 	assuan-util.c \
 	assuan-errors.c \
@@ -47,11 +52,16 @@
 	assuan-pipe-connect.c \
 	assuan-socket-connect.c \
 	assuan-uds.c \
-	assuan-io.c \
 	assuan-logging.c \
 	assuan-socket.c
 
+libassuan_a_SOURCES = $(common_sources) assuan-io.c
 libassuan_a_LIBADD = @LIBOBJS@
 
+if HAVE_PTH
+libassuan_pth_a_SOURCES = $(common_sources) assuan-io-pth.c
+libassuan_pth_a_LIBADD = @LIBOBJS@
+endif
+
 assuan-errors.c : assuan.h mkerrors
 	$(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c

Copied: trunk/src/assuan-io-pth.c (from rev 215, trunk/src/assuan-io.c)
===================================================================
--- trunk/src/assuan-io.c	2006-10-04 17:45:47 UTC (rev 215)
+++ trunk/src/assuan-io-pth.c	2006-10-09 11:35:35 UTC (rev 217)
@@ -0,0 +1,147 @@
+/* assuan-io-pth.c - Pth version of assua-io.c.
+ *	Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Assuan.
+ *
+ * Assuan is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Assuan 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA. 
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#if HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+#include <unistd.h>
+#include <errno.h>
+#ifdef HAVE_W32_SYSTEM
+# include <windows.h>
+#else
+# include <sys/wait.h>
+#endif
+#include <pth.h>
+
+#include "assuan-defs.h"
+
+
+
+#ifndef HAVE_W32_SYSTEM
+pid_t 
+_assuan_waitpid (pid_t pid, int *status, int options)
+{
+  return pth_waitpid (pid, status, options);
+}
+#endif
+
+
+ssize_t
+_assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
+{
+#ifndef HAVE_W32_SYSTEM
+  return pth_read (ctx->inbound.fd, buffer, size);
+#else
+  return recv (ctx->inbound.fd, buffer, size, 0);
+#endif
+}
+
+ssize_t
+_assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
+{
+#ifndef HAVE_W32_SYSTEM
+  return pth_write (ctx->outbound.fd, buffer, size);
+#else
+  return send (ctx->outbound.fd, buffer, size, 0);
+#endif
+}
+
+
+ssize_t
+_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
+{
+#if defined(HAVE_W32_SYSTEM)
+  return _assuan_error (ASSUAN_Not_Implemented);
+#else
+  /* Pth does not provide a sendmsg function.  Thus we implement it here.  */
+  int ret;
+  int fd = ctx->outbound.fd;
+  int fdmode;
+
+  fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
+  if (fdmode == PTH_FDMODE_ERROR)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  if (fdmode == PTH_FDMODE_BLOCK)
+    {
+      fd_set fds;
+
+      FD_ZERO (&fds);
+      FD_SET (fd, &fds);
+      while ( (ret = pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
+              && errno == EINTR)
+        ;
+      if (ret < 0)
+        return -1;
+    }
+
+  while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
+    ;
+  return ret;
+#endif
+}
+
+
+ssize_t
+_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
+{
+#if defined(HAVE_W32_SYSTEM)
+  return _assuan_error (ASSUAN_Not_Implemented);
+#else
+  /* Pth does not provide a recvmsg function.  Thus we implement it here.  */
+  int ret;
+  int fd = ctx->inbound.fd;
+  int fdmode;
+
+  fdmode = pth_fdmode (fd, PTH_FDMODE_POLL);
+  if (fdmode == PTH_FDMODE_ERROR)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  if (fdmode == PTH_FDMODE_BLOCK)
+    {
+      fd_set fds;
+
+      FD_ZERO (&fds);
+      FD_SET (fd, &fds);
+      while ( (ret = pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
+              && errno == EINTR)
+        ;
+      if (ret < 0)
+        return -1;
+    }
+
+  while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
+    ;
+  return ret;
+#endif
+}

Modified: trunk/src/assuan-io.c
===================================================================
--- trunk/src/assuan-io.c	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/src/assuan-io.c	2006-10-09 11:35:35 UTC (rev 217)
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
@@ -39,65 +40,12 @@
 
 #include "assuan-defs.h"
 
-/* We can't include pth.h and we are not sure whether other headers
-   already included it.  This we define macros with the same
-   values. */
-#define MY_PTH_FDMODE_ERROR    (-1)
-#define MY_PTH_FDMODE_POLL     0
-#define MY_PTH_FDMODE_BLOCK    1
-#define MY_PTH_FDMODE_NONBLOCK 2
 
-
-#ifndef _ASSUAN_NO_PTH
-extern pid_t   pth_waitpid (pid_t pid, int *status, int options);
-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 int     pth_fdmode (int, int);
-extern int     pth_select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
-
 #ifndef HAVE_W32_SYSTEM
-#pragma weak pth_waitpid
-#pragma weak pth_read
-#pragma weak pth_write
-#pragma weak pth_fdmode
-#pragma weak pth_select
-#endif
-#endif /*!_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_fdmode. */
-static int
-my_pth_fdmode (int fd, int mode)
-{
-  if (pth_fdmode)
-    return pth_fdmode (fd, mode);
-  else
-    return MY_PTH_FDMODE_NONBLOCK; /* This is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
-
-#ifndef _ASSUAN_NO_PTH
-/* Wrapper around pth_select. */
-static int 
-my_pth_select (int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
-               struct timeval *timeout)
-{
-  if (pth_select)
-    return pth_select (nfd, rfds, wfds, efds, timeout);
-  else
-    return 1; /* Fake one fd ready; this is okay, given the way we use it. */
-}
-#endif /*_ASSUAN_NO_PTH*/
-
-#ifndef HAVE_W32_SYSTEM
 pid_t 
 _assuan_waitpid (pid_t pid, int *status, int options)
 {
-#ifdef _ASSUAN_NO_PTH
   return waitpid (pid, status, options);
-#else
-  return (pth_waitpid ? pth_waitpid : waitpid) (pid, status, options);
-#endif
 }
 #endif
 
@@ -105,72 +53,26 @@
 ssize_t
 _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
 {
-#ifdef _ASSUAN_NO_PTH
   return read (ctx->inbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
-  return (pth_read ? pth_read : read) (ctx->inbound.fd, buffer, size);
-# else
-  return pth_read ? pth_read (ctx->inbound.fd, buffer, size)
-                  : recv (ctx->inbound.fd, buffer, size, 0);
-# endif
-#endif
 }
 
 ssize_t
 _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
 {
-#ifdef _ASSUAN_NO_PTH
   return write (ctx->outbound.fd, buffer, size);
-#else
-# ifndef HAVE_W32_SYSTEM
-  return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size);
-# else
-  return pth_write ? pth_write (ctx->outbound.fd, buffer, size)
-                   : send (ctx->outbound.fd, buffer, size, 0);
-# endif
-#endif
 }
 
 
 ssize_t
 _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
 {
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
+#else
   int ret;
   while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR)
     ;
   return ret;
-#else
-  /* Pth does not provide a sendmsg function.  Thus we implement it here.  */
-  int ret;
-  int fd = ctx->outbound.fd;
-  int fdmode;
-
-  fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
-  if (fdmode == MY_PTH_FDMODE_ERROR)
-    {
-      errno = EBADF;
-      return -1;
-    }
-  if (fdmode == MY_PTH_FDMODE_BLOCK)
-    {
-      fd_set fds;
-
-      FD_ZERO (&fds);
-      FD_SET (fd, &fds);
-      while ( (ret = my_pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0
-              && errno == EINTR)
-        ;
-      if (ret < 0)
-        return -1;
-    }
-
-  while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR)
-    ;
-  return ret;
 #endif
 }
 
@@ -178,40 +80,12 @@
 ssize_t
 _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
 {
-#if defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);
-#elif defined(_ASSUAN_NO_PTH)
+#else
   int ret;
   while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR)
     ;
   return ret;
-#else
-  /* Pth does not provide a recvmsg function.  Thus we implement it here.  */
-  int ret;
-  int fd = ctx->inbound.fd;
-  int fdmode;
-
-  fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL);
-  if (fdmode == MY_PTH_FDMODE_ERROR)
-    {
-      errno = EBADF;
-      return -1;
-    }
-  if (fdmode == MY_PTH_FDMODE_BLOCK)
-    {
-      fd_set fds;
-
-      FD_ZERO (&fds);
-      FD_SET (fd, &fds);
-      while ( (ret = my_pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0
-              && errno == EINTR)
-        ;
-      if (ret < 0)
-        return -1;
-    }
-
-  while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR)
-    ;
-  return ret;
 #endif
 }

Modified: trunk/src/libassuan-config.in
===================================================================
--- trunk/src/libassuan-config.in	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/src/libassuan-config.in	2006-10-09 11:35:35 UTC (rev 217)
@@ -10,8 +10,12 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 PGM=libassuan-config
-libs="@LIBASSUAN_CONFIG_LIBS@"
+lib="@LIBASSUAN_CONFIG_LIB@"
+extralibs="@LIBASSUAN_CONFIG_EXTRA_LIBS@"
 cflags="@LIBASSUAN_CONFIG_CFLAGS@"
+api_version="@LIBASSUAN_CONFIG_API_VERSION@"
+all_thread_modules="@LIBASSUAN_CONFIG_THREAD_MODULES@"
+thread_module=
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 includes=""
@@ -22,12 +26,18 @@
 echo_prefix=no
 echo_exec_prefix=no
 
+if test x"$all_thread_modules" = x; then
+  all_thread_modules="none pthread"
+else
+  all_thread_modules="none pthread $all_thread_modules"
+fi
 
 usage()
 {
 	cat <<EOF
 Usage: $PGM [OPTIONS]
 Options:
+	[--thread={`echo "${all_thread_modules}" | sed 's/ /|/g'`}]
 	[--prefix[=DIR]]
 	[--exec-prefix[=DIR]]
 	[--version]
@@ -38,7 +48,7 @@
 }
 
 if test $# -eq 0; then
-	usage 1 1>&2
+  usage 1 1>&2
 fi
 
 while test $# -gt 0; do
@@ -64,6 +74,25 @@
       echo "@VERSION@"
       exit 0
       ;;
+    --api-version)
+      echo_api_version=yes
+      ;;
+    --thread=*)
+      for mod in $all_thread_modules; do
+	if test "$mod" = "$optarg"; then
+           thread_module="-$mod"
+	fi
+      done
+      if test "x$thread_module" = "x"; then
+	usage 1 1>&2
+      fi
+      if test "$thread_module" = "-none"; then
+        thread_module=""
+      fi
+      if test "$thread_module" = "-pthread"; then
+        thread_module=""
+      fi
+      ;;
     --cflags)
       echo_cflags=yes
       ;;
@@ -85,6 +114,11 @@
     echo $exec_prefix
 fi
 
+if test "$echo_api_version" = "yes"; then
+    echo $api_version
+fi
+
+
 if test "$echo_cflags" = "yes"; then
     if test "@includedir@" != "/usr/include" ; then
       includes="-I at includedir@"
@@ -100,11 +134,11 @@
 if test "$echo_libs" = "yes"; then
     if test "@libdir@" != "/usr/lib" ; then
       libdirs="-L at libdir@"
-      for i in $libs ; do
+      for i in $lib $extralibs ; do
 	if test "$i" = "-L at libdir@" ; then
 	  libdirs=""
 	fi
       done
     fi
-    echo $libdirs $libs
+    echo $libdirs $lib${thread_module} $extralibs
 fi

Modified: trunk/src/libassuan.m4
===================================================================
--- trunk/src/libassuan.m4	2006-10-04 17:52:08 UTC (rev 216)
+++ trunk/src/libassuan.m4	2006-10-09 11:35:35 UTC (rev 217)
@@ -9,68 +9,152 @@
 dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-
-dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
-dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
 dnl
-AC_DEFUN([AM_PATH_LIBASSUAN],
+dnl Common code used for libassuan detection [internal]
+dnl Returns ok set to yes or no.
+dnl
+AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
 [ AC_ARG_WITH(libassuan-prefix,
-            AC_HELP_STRING([--with-libassuan-prefix=PFX],
-                           [prefix where LIBASSUAN is installed (optional)]),
+              AC_HELP_STRING([--with-libassuan-prefix=PFX],
+                             [prefix where LIBASSUAN is installed (optional)]),
      libassuan_config_prefix="$withval", libassuan_config_prefix="")
   if test x$libassuan_config_prefix != x ; then
-     libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
-     if test x${LIBASSUAN_CONFIG+set} != xset ; then
-        LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
-     fi
+    libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
+    if test x${LIBASSUAN_CONFIG+set} != xset ; then
+      LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
+    fi
   fi
+  AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no)
 
-  AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no)
-  min_libassuan_version=ifelse([$1], ,0.0.1,$1)
-  AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version)
+  tmp=ifelse([$1], ,1:0.9.2,$1)
+  if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+    req_libassuan_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
+    min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+  else
+    req_libassuan_api=0
+    min_libassuan_version="$tmp"
+  fi
+
+  if test "$LIBASSUAN_CONFIG" != "no" ; then
+    libassuan_version=`$LIBASSUAN_CONFIG --version`
+  fi
+  libassuan_version_major=`echo $libassuan_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+  libassuan_version_minor=`echo $libassuan_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+  libassuan_version_micro=`echo $libassuan_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+
+  AC_MSG_CHECKING(for LIBASSUAN ifelse([$2], ,,[$2 ])- version >= $min_libassuan_version)
   ok=no
   if test "$LIBASSUAN_CONFIG" != "no" ; then
+    ifelse([$2], ,,[if `$LIBASSUAN_CONFIG --thread=$2 2> /dev/null` ; then])
     req_major=`echo $min_libassuan_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
     req_minor=`echo $min_libassuan_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
     req_micro=`echo $min_libassuan_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
-    libassuan_config_version=`$LIBASSUAN_CONFIG $libassuan_config_args --version`
-    major=`echo $libassuan_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
-    minor=`echo $libassuan_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
-    micro=`echo $libassuan_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
-    if test "$major" -gt "$req_major"; then
+    if test "$libassuan_version_major" -gt "$req_major"; then
         ok=yes
     else 
-        if test "$major" -eq "$req_major"; then
-            if test "$minor" -gt "$req_minor"; then
+        if test "$libassuan_version_major" -eq "$req_major"; then
+            if test "$libassuan_version_minor" -gt "$req_minor"; then
                ok=yes
             else
-               if test "$minor" -eq "$req_minor"; then
-                   if test "$micro" -ge "$req_micro"; then
+               if test "$libassuan_version_minor" -eq "$req_minor"; then
+                   if test "$libassuan_version_micro" -ge "$req_micro"; then
                      ok=yes
                    fi
                fi
             fi
         fi
     fi
+    ifelse([$2], ,,[fi])
   fi
+
   if test $ok = yes; then
+    AC_MSG_RESULT(yes)
+  else
+    AC_MSG_RESULT(no)
+  fi
+
+  if test $ok = yes; then
+    if test "$req_libassuan_api" -gt 0 ; then
+      tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0`
+      if test "$tmp" -gt 0 ; then
+        AC_MSG_CHECKING([LIBASSUAN ifelse([$2], ,,[$2 ])API version])
+        if test "$req_libassuan_api" -eq "$tmp" ; then
+          AC_MSG_RESULT(okay)
+        else
+          ok=no
+          AC_MSG_RESULT([does not match.  want=$req_libassuan_api got=$tmp.])
+        fi
+      fi
+    fi
+  fi
+
+])
+
+
+
+dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
+dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN],
+[ _AM_PATH_LIBASSUAN_COMMON($1)
+  if test $ok = yes; then
     LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
     LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
-    AC_MSG_RESULT(yes)
     ifelse([$2], , :, [$2])
   else
     LIBASSUAN_CFLAGS=""
     LIBASSUAN_LIBS=""
-    AC_MSG_RESULT(no)
     ifelse([$3], , :, [$3])
   fi
   AC_SUBST(LIBASSUAN_CFLAGS)
   AC_SUBST(LIBASSUAN_LIBS)
 ])
+
+
+dnl AM_PATH_LIBASSUAN_PTH([MINIMUM-VERSION,
+dnl                      [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTH_CFLAGSand LIBASSUAN_PTH_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTH],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pth)
+  if test $ok = yes; then
+    LIBASSUAN_PTH_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+    LIBASSUAN_PTH_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+    ifelse([$2], , :, [$2])
+  else
+    LIBASSUAN_PTH_CFLAGS=""
+    LIBASSUAN_PTH_LIBS=""
+    ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(LIBASSUAN_PTH_CFLAGS)
+  AC_SUBST(LIBASSUAN_PTH_LIBS)
+])
+
+
+dnl AM_PATH_LIBASSUAN_PTHREAD([MINIMUM-VERSION,
+dnl                           [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTHREAD_CFLAGS 
+dnl                           and LIBASSUAN_PTHREAD_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTHREAD],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pth)
+  if test $ok = yes; then
+    LIBASSUAN_PTHREAD_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+    LIBASSUAN_PTHREAD_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+    ifelse([$2], , :, [$2])
+  else
+    LIBASSUAN_PTHREAD_CFLAGS=""
+    LIBASSUAN_PTHREAD_LIBS=""
+    ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(LIBASSUAN_PTHREAD_CFLAGS)
+  AC_SUBST(LIBASSUAN_PTHREAD_LIBS)
+])
+




More information about the Gnupg-commits mailing list