1
1

Richard W.M. Jones' 5 patches that enables libssh2 to get cross-compiled with

mingw
Этот коммит содержится в:
Daniel Stenberg 2008-11-10 16:48:41 +00:00
родитель 95b73812e7
Коммит 5438cffd9a
17 изменённых файлов: 114 добавлений и 44 удалений

Просмотреть файл

@ -1,7 +1,7 @@
# AC_PREREQ(2.57)
AC_INIT(libssh2, [-], libssh2-devel@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([src/libssh2_config.h example/simple/config.h])
AC_CONFIG_HEADER([src/libssh2_config.h])
AM_MAINTAINER_MODE
dnl SED is needed by some of the tools
@ -61,6 +61,7 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_C_BIGENDIAN
if test -z "$PKG_CONFIG"; then
@ -258,6 +259,7 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
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 strtoll)
case $host in

Просмотреть файл

@ -10,6 +10,6 @@ noinst_PROGRAMS = ssh2 \
sftp_RW_nonblock \
sftpdir sftpdir_nonblock
INCLUDES = -I. -I$(top_srcdir)/include
INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include
LDADD = $(top_builddir)/src/libssh2.la

Просмотреть файл

@ -1,10 +1,10 @@
/*
* $Id: scp.c,v 1.10 2007/08/09 01:10:11 dfandrich Exp $
* $Id: scp.c,v 1.11 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#ifdef HAVE_WINSOCK2_H
@ -50,7 +50,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,10 +1,10 @@
/*
* $Id: scp_nonblock.c,v 1.12 2008/09/30 08:55:35 bagder Exp $
* $Id: scp_nonblock.c,v 1.13 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SCP transfers in a non-blocking manner.
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#ifdef HAVE_WINSOCK2_H
@ -53,7 +53,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -94,7 +94,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance */

Просмотреть файл

@ -1,10 +1,10 @@
/*
* $Id: scp_write.c,v 1.5 2007/08/09 01:10:11 dfandrich Exp $
* $Id: scp_write.c,v 1.6 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#ifdef HAVE_WINSOCK2_H
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,10 +1,10 @@
/*
* $Id: scp_write_nonblock.c,v 1.8 2008/09/30 08:55:35 bagder Exp $
* $Id: scp_write_nonblock.c,v 1.9 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -111,7 +111,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp.c,v 1.14 2007/09/24 12:14:18 bagder Exp $
* $Id: sftp.c,v 1.15 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP transfers.
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password /tmp/secrets -p|-i|-k"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_RW_nonblock.c,v 1.11 2008/09/30 08:55:35 bagder Exp $
* $Id: sftp_RW_nonblock.c,v 1.12 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP transfers in a non-blocking manner.
*
@ -9,7 +9,7 @@
* Using the SFTP server running on 127.0.0.1
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
/* Ultra basic "connect to port 22 on localhost"
@ -93,7 +93,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_mkdir.c,v 1.7 2007/08/09 01:10:11 dfandrich Exp $
* $Id: sftp_mkdir.c,v 1.8 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP mkdir
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password /tmp/sftp_mkdir"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_mkdir_nonblock.c,v 1.10 2008/09/30 08:55:35 bagder Exp $
* $Id: sftp_mkdir_nonblock.c,v 1.11 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP non-blocking mkdir.
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password /tmp/sftp_write_nonblock.c"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -97,7 +97,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_nonblock.c,v 1.14 2008/09/30 08:55:35 bagder Exp $
* $Id: sftp_nonblock.c,v 1.15 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP non-blocking transfers.
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password /tmp/secrets"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -100,7 +100,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance */

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_write.c,v 1.8 2007/08/09 01:10:11 dfandrich Exp $
* $Id: sftp_write.c,v 1.9 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP write transfers.
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password sftp_write.c /tmp/secrets"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftp_write_nonblock.c,v 1.11 2008/09/30 08:55:35 bagder Exp $
* $Id: sftp_write_nonblock.c,v 1.12 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP non-blocking write transfers.
*
@ -9,7 +9,7 @@
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -60,7 +60,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -112,7 +112,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftpdir.c,v 1.9 2007/08/09 01:10:11 dfandrich Exp $
* $Id: sftpdir.c,v 1.10 2008/11/10 16:48:41 bagder Exp $
*
* Sample doing an SFTP directory listing.
*
@ -9,7 +9,7 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: sftpdir_nonblock.c,v 1.11 2008/09/30 08:55:35 bagder Exp $
* $Id: sftpdir_nonblock.c,v 1.12 2008/11/10 16:48:41 bagder Exp $
*
* Sample doing an SFTP directory listing.
*
@ -9,7 +9,7 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@ -97,7 +97,12 @@ int main(int argc, char *argv[])
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: ssh2.c,v 1.17 2007/08/09 01:10:11 dfandrich Exp $
* $Id: ssh2.c,v 1.18 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SSH2 connect.
*
@ -9,10 +9,13 @@
* "ssh2 host user password [-p|-i|-k]"
*/
#include "config.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
#endif
@ -73,7 +76,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {

Просмотреть файл

@ -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>