[PATCH 2/5] libssh2: headers and implementation of iovec/writev for Windows
Richard W.M. Jones
rjones at redhat.com
Mon Nov 10 15:27:08 UTC 2008
Currently Windows builds use a separate header file in the win32
subdirectory. This patch pulls the important bits out of that header
file into the main "libssh2_priv.h" header file. The extras here are
to check for and use the windows headers, and the implementation of
iovec/writev.
Of course they are defended by #ifdef WIN32 ... #endif so that this
still works on Linux.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
diff -urN libssh2-0.18.orig/configure.in libssh2-0.18.mingw/configure.in
--- libssh2-0.18.orig/configure.in 2007-07-31 10:55:29.000000000 +0100
+++ libssh2-0.18.mingw/configure.in 2008-11-10 14:12:07.000000000 +0000
@@ -249,6 +250,7 @@
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h])
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
+AC_CHECK_HEADERS([windows.h ws2tcpip.h winsock2.h])
AC_CHECK_FUNCS(poll gettimeofday select)
AC_FUNC_ALLOCA
diff -urN libssh2-0.18.orig/src/libssh2_priv.h libssh2-0.18.mingw/src/libssh2_priv.h
--- libssh2-0.18.orig/src/libssh2_priv.h 2007-08-10 23:30:30.000000000 +0100
+++ libssh2-0.18.mingw/src/libssh2_priv.h 2008-11-10 13:57:49.000000000 +0000
@@ -41,6 +41,14 @@
#define LIBSSH2_LIBRARY
#include "libssh2_config.h"
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
/* The following CPP block should really only be in session.c and
packet.c. However, AIX have #define's for 'events' and 'revents'
and we are using those names in libssh2.h, so we need to include
@@ -70,6 +78,28 @@
#include "libssh2_publickey.h"
#include "libssh2_sftp.h"
+/* Provide iovec / writev on WIN32 platform. */
+#ifdef WIN32
+
+/* same as WSABUF */
+struct iovec {
+ u_long iov_len;
+ char *iov_base;
+};
+
+#define inline __inline
+
+static inline int writev(int sock, struct iovec *iov, int nvecs)
+{
+ DWORD ret;
+ if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0) {
+ return ret;
+ }
+ return -1;
+}
+
+#endif /* WIN32 */
+
/* Needed for struct iovec on some platforms */
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
More information about the mingw
mailing list