[Pkg-gnupg-commit] [libassuan] 187/437: Various minor changes for W32
Eric Dorland
eric at moszumanska.debian.org
Fri May 22 05:33:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libassuan.
commit 6c61bc48f1a3eef71bb8c602501a2737ba5fd153
Author: Werner Koch <wk at gnupg.org>
Date: Tue Jun 12 13:39:37 2007 +0000
Various minor changes for W32
---
ChangeLog | 14 +++++++++++
autogen.sh | 47 ++++++++++++++++++------------------
configure.ac | 19 +++++++++++++--
m4/gnupg-pth.m4 | 17 ++++---------
src/ChangeLog | 34 ++++++++++++++++++++++++++
src/assuan-connect.c | 2 ++
src/assuan-defs.h | 7 ++++++
src/assuan-io-pth.c | 23 +++++++++---------
src/assuan-io.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-
src/assuan-pipe-connect.c | 2 +-
src/assuan-pipe-server.c | 2 ++
src/assuan-socket-server.c | 14 +++++++----
src/assuan.h | 2 ++
src/libassuan.m4 | 2 +-
14 files changed, 189 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3199ade..66adad6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/autogen.sh b/autogen.sh
index 2d1ee0f..8fd8b8d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -30,6 +30,11 @@ check_version () {
DIE=no
+FORCE=
+if test "$1" == "--force"; then
+ FORCE=" --force"
+ shift
+fi
# ***** W32 build script *******
@@ -47,25 +52,20 @@ if test "$1" = "--build-w32"; then
[ -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 @@ if test "$1" = "--build-w32"; then
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 @@ if test "$1" = "--build-amd64"; then
fi
$tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \
- --host=${host} --build=${build}
+ --host=${host} --build=${build}
rc=$?
exit $rc
fi
@@ -193,7 +194,7 @@ echo "Running autoheader..."
$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\"."
diff --git a/configure.ac b/configure.ac
index d32312d..64c3cf3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 @@ AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
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 @@ AC_PROG_RANLIB
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_SIZE_T
AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST
+gl_HEADER_SYS_SOCKET
gl_TYPE_SOCKLEN_T
AC_CHECK_MEMBER(struct cmsghdr.cmsg_len,
diff --git a/m4/gnupg-pth.m4 b/m4/gnupg-pth.m4
index dc8e264..6dc9e0e 100644
--- a/m4/gnupg-pth.m4
+++ b/m4/gnupg-pth.m4
@@ -73,13 +73,11 @@ AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
])
-#
+
# 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 @@ AC_DEFUN([GNUPG_PATH_PTH],
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_DEFUN([GNUPG_PATH_PTH],
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)
diff --git a/src/ChangeLog b/src/ChangeLog
index d1bc5fc..9928072 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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.
diff --git a/src/assuan-connect.c b/src/assuan-connect.c
index 92995d8..e7f01bd 100644
--- a/src/assuan-connect.c
+++ b/src/assuan-connect.c
@@ -62,6 +62,7 @@ assuan_get_pid (assuan_context_t ctx)
/* 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 @@ assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid)
*gid = ctx->peercred.gid;
return 0;
}
+#endif /*_WIN32*/
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index fa04f0b..58c30d4 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -142,9 +142,11 @@ struct assuan_context_s
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 @@ pid_t _assuan_waitpid (pid_t pid, int *status, int options);
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);
diff --git a/src/assuan-io-pth.c b/src/assuan-io-pth.c
index 13f8794..53840e5 100644
--- a/src/assuan-io-pth.c
+++ b/src/assuan-io-pth.c
@@ -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 @@ _assuan_waitpid (pid_t pid, int *status, int options)
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 @@ _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
#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);
diff --git a/src/assuan-io.c b/src/assuan-io.c
index d1f0d5e..6d89579 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -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 @@ _assuan_waitpid (pid_t pid, int *status, int options)
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 @@ _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg)
}
+#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);
diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c
index 8ee9c74..867dc84 100644
--- a/src/assuan-pipe-connect.c
+++ b/src/assuan-pipe-connect.c
@@ -554,7 +554,7 @@ socketpair_connect (assuan_context_t *ctx,
/* 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;
diff --git a/src/assuan-pipe-server.c b/src/assuan-pipe-server.c
index f885161..1b47def 100644
--- a/src/assuan-pipe-server.c
+++ b/src/assuan-pipe-server.c
@@ -92,6 +92,7 @@ _assuan_new_context (assuan_context_t *r_ctx)
/* 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 @@ is_valid_socket (const char *s)
return 0;
return S_ISSOCK (buf.st_mode);
}
+#endif /*!HAVE_W32_SYSTEM*/
int
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index 45c227d..5c46164 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -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,
diff --git a/src/assuan.h b/src/assuan.h
index 9080fd3..6343ae9 100644
--- a/src/assuan.h
+++ b/src/assuan.h
@@ -425,8 +425,10 @@ assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx,
/*-- 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
diff --git a/src/libassuan.m4 b/src/libassuan.m4
index e099b66..004eee3 100644
--- a/src/libassuan.m4
+++ b/src/libassuan.m4
@@ -74,7 +74,7 @@ AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
fi
if test $ok = yes; then
- AC_MSG_RESULT(yes)
+ AC_MSG_RESULT([yes ($libassuan_version)])
else
AC_MSG_RESULT(no)
fi
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git
More information about the Pkg-gnupg-commit
mailing list