[svn] assuan - r238 - in trunk: . m4 src

svn author wk cvs at cvs.gnupg.org
Tue Jun 12 15:40:11 CEST 2007


Author: wk
Date: 2007-06-12 15:39:37 +0200 (Tue, 12 Jun 2007)
New Revision: 238

Modified:
   trunk/ChangeLog
   trunk/autogen.sh
   trunk/configure.ac
   trunk/m4/gnupg-pth.m4
   trunk/src/ChangeLog
   trunk/src/assuan-connect.c
   trunk/src/assuan-defs.h
   trunk/src/assuan-io-pth.c
   trunk/src/assuan-io.c
   trunk/src/assuan-pipe-connect.c
   trunk/src/assuan-pipe-server.c
   trunk/src/assuan-socket-server.c
   trunk/src/assuan.h
   trunk/src/libassuan.m4
Log:
Various minor changes for W32


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/ChangeLog	2007-06-12 13:39:37 UTC (rev 238)
@@ -1,3 +1,17 @@
+2007-05-30  Werner Koch  <wk at g10code.com>
+
+	* autogen.sh <--build-w32>: Modernize. 
+
+2007-05-29  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: Require automake 1.10 and autoconf 2.61.
+	(AM_PROG_CC_C_O): New.  Error out if no C-89 cc is installed.
+	(gl_HEADER_SYS_SOCKET): Explicitly add this for documentation. 
+
+2007-05-24  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: Use -Wpointer-arith is possible.
+
 2006-11-22  Werner Koch  <wk at g10code.com>
 
 	Released 1.0.1.

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/autogen.sh	2007-06-12 13:39:37 UTC (rev 238)
@@ -30,6 +30,11 @@
 
 
 DIE=no
+FORCE=
+if test "$1" == "--force"; then
+  FORCE=" --force"
+  shift
+fi
 
 
 # ***** W32 build script *******
@@ -47,25 +52,20 @@
     [ -z "$w32root" ] && w32root="$HOME/w32root"
     echo "Using $w32root as standard install directory" >&2
     
-    # See whether we have the Debian cross compiler package or the
-    # old mingw32/cpd system
-    if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then
-        host=i586-mingw32msvc
-        crossbindir=/usr/$host/bin
-    else
-       host=i386--mingw32
-       if ! mingw32 --version >/dev/null; then
-          echo "We need at least version 0.3 of MingW32/CPD" >&2
-          exit 1
-       fi
-       crossbindir=`mingw32 --install-dir`/bin
-       # Old autoconf version required us to setup the environment
-       # with the proper tool names.
-       CC=`mingw32 --get-path gcc`
-       CPP=`mingw32 --get-path cpp`
-       AR=`mingw32 --get-path ar`
-       RANLIB=`mingw32 --get-path ranlib`
-       export CC CPP AR RANLIB 
+    crossbindir=
+    for host in i586-mingw32msvc i386-mingw32msvc mingw32; do
+        if ${host}-gcc --version >/dev/null 2>&1 ; then
+            crossbindir=/usr/${host}/bin
+            conf_CC="CC=${host}-gcc"
+            break;
+        fi
+    done
+    if [ -z "$crossbindir" ]; then
+        echo "Cross compiler kit not installed" >&2
+        echo "Under Debian GNU/Linux, you may install it using" >&2
+        echo "  apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 
+        echo "Stop." >&2
+        exit 1
     fi
    
     if [ -f "$tsdir/config.log" ]; then
@@ -76,7 +76,8 @@
     fi
 
     ./configure --enable-maintainer-mode  --prefix=${w32root}  \
-            --host=i586-mingw32msvc --build=${build} \
+            --host=${host} --build=${build} \
+            --with-pth-prefix=${w32root} \
             --disable-shared    
 
     exit $?
@@ -122,7 +123,7 @@
     fi
 
     $tsdir/configure --enable-maintainer-mode --prefix=${amd64root}  \
-             --host=${host} --build=${build}
+             --host=${host} --build=${build} 
     rc=$?
     exit $rc
 fi
@@ -193,7 +194,7 @@
 $AUTOHEADER
 echo "Running automake --gnu ..."
 $AUTOMAKE --gnu;
-echo "Running autoconf..."
-$AUTOCONF
+echo "Running autoconf${FORCE} ..."
+$AUTOCONF${FORCE}
 
 echo "You may now run \"./configure --enable-maintainer-mode && make\"."

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/configure.ac	2007-06-12 13:39:37 UTC (rev 238)
@@ -20,8 +20,8 @@
 
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.59)
-min_automake_version="1.9.3"
+AC_PREREQ(2.61)
+min_automake_version="1.10"
 
 # Remember to change the version number immediately *after* a release.
 # Set my_issvn to "yes" for non-released code.  Remember to run an
@@ -67,6 +67,10 @@
 AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_CPP
+AM_PROG_CC_C_O
+if test "x$ac_cv_prog_cc_c89" = "xno" ; then
+  AC_MSG_ERROR([[No C-89 compiler found]])
+fi
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
@@ -75,6 +79,16 @@
 
 if test "$GCC" = yes; then
     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
+
+    AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
+    _gcc_cflags_save=$CFLAGS
+    CFLAGS="-Wpointer-arith"
+    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
+    AC_MSG_RESULT($_gcc_wopt)
+    CFLAGS=$_gcc_cflags_save;
+    if test x"$_gcc_wopt" = xyes ; then
+       CFLAGS="$CFLAGS -Wpointer-arith"
+    fi
 fi
 
 
@@ -162,6 +176,7 @@
 AC_TYPE_SIGNAL
 AC_DECL_SYS_SIGLIST
 
+gl_HEADER_SYS_SOCKET
 gl_TYPE_SOCKLEN_T
 
 AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,

Modified: trunk/m4/gnupg-pth.m4
===================================================================
--- trunk/m4/gnupg-pth.m4	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/m4/gnupg-pth.m4	2007-06-12 13:39:37 UTC (rev 238)
@@ -73,13 +73,11 @@
   ])
 
 
-#
+
 # 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.
+# 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,
@@ -91,8 +89,7 @@
   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
+  if test "$PTH_CONFIG" != "no"; then
     GNUPG_PTH_VERSION_CHECK($tmp)
     if test $have_pth = yes; then      
        PTH_CFLAGS=`$PTH_CONFIG --cflags`
@@ -101,12 +98,6 @@
        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	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/ChangeLog	2007-06-12 13:39:37 UTC (rev 238)
@@ -1,3 +1,37 @@
+2007-06-12  Werner Koch  <wk at g10code.com>
+
+	* assuan-io.c (_assuan_simple_read): Hack to allow reading from a
+	socket.
+	(_assuan_simple_write): Likewise.
+
+2007-06-11  Werner Koch  <wk at g10code.com>
+
+	* assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use
+	pth versions also for W32.
+
+2007-05-29  Werner Koch  <wk at g10code.com>
+
+	* assuan-io-pth.c: Include sys/socket.h only if available.  Remove
+	double inclusion of sys/wait.h
+	
+	* assuan-pipe-connect.c (build_w32_commandline): Make ARGV const.
+
+	* assuan-pipe-server.c (is_valid_socket) [W32]: Do not define.
+
+	* assuan-socket-server.c [W32]: Include ws2tcpip.h to define
+	socklen_t.
+	* assuan-defs.h (struct assuan_context_s): Define most peercred
+	members only if we can really set them.
+	(_assuan_simple_sendmsg, _assuan_simple_recvmsg) [W32]: Use a
+	different prototype.
+	* assuan.h (assuan_get_peercred) [W32]: Do not define.
+	* assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg)
+	[w32]: Use another prototype.
+
+2007-05-09  Werner Koch  <wk at g10code.com>
+
+	* libassuan.m4: Print found version on success.
+
 2007-05-01  Werner Koch  <wk at g10code.com>
 
 	* assuan-uds.c (uds_reader): Cast void ptr for arithmetics.

Modified: trunk/src/assuan-connect.c
===================================================================
--- trunk/src/assuan-connect.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-connect.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -62,6 +62,7 @@
 /* Return user credentials. PID, UID and GID amy be gived as NULL if
    you are not interested in this value.  For getting the pid of the
    peer the assuan_get_pid is usually better suited. */
+#ifndef _WIN32
 assuan_error_t
 assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid)
 {
@@ -77,3 +78,4 @@
     *gid = ctx->peercred.gid;
   return 0;
 }
+#endif /*_WIN32*/

Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-defs.h	2007-06-12 13:39:37 UTC (rev 238)
@@ -142,9 +142,11 @@
 
   struct {
     int   valid;   /* Whether this structure has valid information. */
+#ifdef HAVE_SO_PEERCRED
     pid_t pid;     /* The pid of the peer. */
     uid_t uid;     /* The uid of the peer. */
     gid_t gid;     /* The gid of the peer. */
+#endif /*HAVE_SO_PEERCRED*/
   } peercred;
 
   /* Used for Unix domain sockets.  */
@@ -280,8 +282,13 @@
 ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size);
 ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer,
 			      size_t size);
+#ifdef _WIN32
+int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg);
+int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg);
+#else
 ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg);
 ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg);
+#endif
 
 /*-- assuan-socket.c --*/
 int _assuan_close (int fd);

Modified: trunk/src/assuan-io-pth.c
===================================================================
--- trunk/src/assuan-io-pth.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-io-pth.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -25,8 +25,9 @@
 
 #include <sys/time.h>
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
-#include <sys/wait.h>
+#endif
 #if HAVE_SYS_UIO_H
 # include <sys/uio.h>
 #endif
@@ -55,26 +56,22 @@
 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
 }
 
-
+#ifdef _WIN32
+int
+_assuan_simple_sendmsg (assuan_context_t ctx, void *msg)
+#else
 ssize_t
 _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
+#endif
 {
 #if defined(HAVE_W32_SYSTEM)
   return _assuan_error (ASSUAN_Not_Implemented);
@@ -109,9 +106,13 @@
 #endif
 }
 
-
+#ifdef _WIN32
+int
+_assuan_simple_recvmsg (assuan_context_t ctx, void *msg)
+#else
 ssize_t
 _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
+#endif
 {
 #if defined(HAVE_W32_SYSTEM)
   return _assuan_error (ASSUAN_Not_Implemented);

Modified: trunk/src/assuan-io.c
===================================================================
--- trunk/src/assuan-io.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-io.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -25,7 +25,9 @@
 
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/socket.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
 #include <unistd.h>
 #include <errno.h>
 #ifdef HAVE_W32_SYSTEM
@@ -49,18 +51,69 @@
 ssize_t
 _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
 {
+#ifdef HAVE_W32_SYSTEM
+  /* Due to the peculiarities of the W32 API we can't use read for a
+     network socket and thus we try to use recv first and fallback to
+     read if recv detects that it is not a network socket.  */
+  int n;
+
+  n = recv (ctx->inbound.fd, buffer, size, 0);
+  if (n == -1 && WSAGetLastError () == WSAENOTSOCK)
+    {
+      DWORD nread = 0;
+
+      n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL);
+      if (!n)
+        {
+          errno = EIO; /* FIXME:  We should have a proper mapping.  */
+          n = -1;
+        }
+      else
+        n = (int)nread;
+    }
+  return n;
+#else /*!HAVE_W32_SYSTEM*/
   return read (ctx->inbound.fd, buffer, size);
+#endif /*!HAVE_W32_SYSTEM*/
 }
 
 ssize_t
 _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
 {
+#ifdef HAVE_W32_SYSTEM
+  /* Due to the peculiarities of the W32 API we can't use write for a
+     network socket and thus we try to use send first and fallback to
+     write if send detects that it is not a network socket.  */
+  int n;
+
+  n = send (ctx->outbound.fd, buffer, size, 0);
+  if (n == -1 && WSAGetLastError () == WSAENOTSOCK)
+    {
+      DWORD nwrite;
+
+      n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL);
+      if (!n)
+        {
+          errno = EIO; /* FIXME:  We should have a proper mapping.  */
+          n = -1;
+        }
+      else
+        n = (int)nwrite;
+    }
+  return n;
+#else /*!HAVE_W32_SYSTEM*/
   return write (ctx->outbound.fd, buffer, size);
+#endif /*!HAVE_W32_SYSTEM*/
 }
 
 
+#ifdef HAVE_W32_SYSTEM
+int
+_assuan_simple_sendmsg (assuan_context_t ctx, void *msg)
+#else
 ssize_t
 _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
+#endif
 {
 #ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);
@@ -73,8 +126,13 @@
 }
 
 
+#ifdef HAVE_W32_SYSTEM
+int
+_assuan_simple_recvmsg (assuan_context_t ctx, void *msg)
+#else
 ssize_t
 _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg)
+#endif
 {
 #ifdef HAVE_W32_SYSTEM
   return _assuan_error (ASSUAN_Not_Implemented);

Modified: trunk/src/assuan-pipe-connect.c
===================================================================
--- trunk/src/assuan-pipe-connect.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-pipe-connect.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -554,7 +554,7 @@
 /* Build a command line for use with W32's CreateProcess.  On success
    CMDLINE gets the address of a newly allocated string.  */
 static int
-build_w32_commandline (char * const *argv, char **cmdline)
+build_w32_commandline (const char * const *argv, char **cmdline)
 {
   int i, n;
   const char *s;

Modified: trunk/src/assuan-pipe-server.c
===================================================================
--- trunk/src/assuan-pipe-server.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-pipe-server.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -92,6 +92,7 @@
 
 
 /* Returns true if atoi(S) denotes a valid socket. */
+#ifndef HAVE_W32_SYSTEM
 static int
 is_valid_socket (const char *s)
 {
@@ -101,6 +102,7 @@
     return 0;
   return S_ISSOCK (buf.st_mode);
 }
+#endif /*!HAVE_W32_SYSTEM*/
 
 
 int

Modified: trunk/src/assuan-socket-server.c
===================================================================
--- trunk/src/assuan-socket-server.c	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan-socket-server.c	2007-06-12 13:39:37 UTC (rev 238)
@@ -25,13 +25,19 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
-#ifndef HAVE_W32_SYSTEM
-#include <sys/socket.h>
-#include <sys/un.h>
+#ifdef HAVE_W32_SYSTEM
+# include <windows.h>
+# if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+# elif HAVE_WS2TCPIP_H
+#  include <ws2tcpip.h>
+# endif
 #else
-#include <windows.h>
+# include <sys/socket.h>
+# include <sys/un.h>
 #endif
 
+
 #include "assuan-defs.h"
 
 static struct assuan_io io = { _assuan_simple_read,

Modified: trunk/src/assuan.h
===================================================================
--- trunk/src/assuan.h	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/assuan.h	2007-06-12 13:39:37 UTC (rev 238)
@@ -425,8 +425,10 @@
 /*-- assuan-connect.c --*/
 void assuan_disconnect (assuan_context_t ctx);
 pid_t assuan_get_pid (assuan_context_t ctx);
+#ifndef _WIN32
 assuan_error_t assuan_get_peercred (assuan_context_t ctx,
                                     pid_t *pid, uid_t *uid, gid_t *gid);
+#endif
 
 /*-- assuan-client.c --*/
 assuan_error_t 

Modified: trunk/src/libassuan.m4
===================================================================
--- trunk/src/libassuan.m4	2007-05-06 21:57:58 UTC (rev 237)
+++ trunk/src/libassuan.m4	2007-06-12 13:39:37 UTC (rev 238)
@@ -74,7 +74,7 @@
   fi
 
   if test $ok = yes; then
-    AC_MSG_RESULT(yes)
+    AC_MSG_RESULT([yes ($libassuan_version)])
   else
     AC_MSG_RESULT(no)
   fi




More information about the Gnupg-commits mailing list