diff -urN --binary -x b32d libssh-0.5.2.orig/cmake/Modules/FindZLIB.cmake libssh-0.5.2/cmake/Modules/FindZLIB.cmake
--- libssh-0.5.2.orig/cmake/Modules/FindZLIB.cmake	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/cmake/Modules/FindZLIB.cmake	2012-09-10 17:12:25.621354900 +0200
@@ -97,6 +97,7 @@
             zdll
             zlib
             zlib1
+            zlibd
         PATHS
             /usr/local/lib
             /opt/local/lib
diff -urN --binary -x b32d libssh-0.5.2.orig/ConfigureChecks.cmake libssh-0.5.2/ConfigureChecks.cmake
--- libssh-0.5.2.orig/ConfigureChecks.cmake	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/ConfigureChecks.cmake	2012-09-10 17:12:25.636981900 +0200
@@ -46,11 +46,11 @@
 check_include_file(termios.h HAVE_TERMIOS_H)
 
 if (WIN32)
-  check_include_file(wspiapi.h HAVE_WSPIAPI_H)
+  check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
   if (NOT HAVE_WSPIAPI_H)
     message(STATUS "WARNING: Without wspiapi.h, this build will only work on Windows XP and newer versions")
   endif (NOT HAVE_WSPIAPI_H)
-  check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)
+  check_include_files("winsock2.h;ws2tcpip.h" HAVE_WS2TCPIP_H)
   if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
     set(HAVE_GETADDRINFO TRUE)
     set(HAVE_GETHOSTBYNAME TRUE)
diff -urN --binary -x b32d libssh-0.5.2.orig/include/libssh/sftp.h libssh-0.5.2/include/libssh/sftp.h
--- libssh-0.5.2.orig/include/libssh/sftp.h	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/include/libssh/sftp.h	2012-09-10 17:14:16.336573300 +0200
@@ -56,7 +56,7 @@
 #endif /* gid_t */
 #ifdef _MSC_VER
 #ifndef ssize_t
-  typedef _W64 SSIZE_T ssize_t;
+  typedef _W64 SSIZE_T ssh_ssize_t;
 #endif /* ssize_t */
 #endif /* _MSC_VER */
 #endif /* _WIN32 */
@@ -430,7 +430,7 @@
  * @return              Number of bytes written, < 0 on error with ssh and sftp
  *                      error set.
  */
-LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count);
+LIBSSH_API ssh_ssize_t sftp_read(sftp_file file, void *buf, size_t count);
 
 /**
  * @brief Start an asynchronous read from a file using an opened sftp file handle.
@@ -506,7 +506,7 @@
  * @see                 sftp_read()
  * @see                 sftp_close()
  */
-LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count);
+LIBSSH_API ssh_ssize_t sftp_write(sftp_file file, const void *buf, size_t count);
 
 /**
  * @brief Seek to a specific location in a file.
diff -urN --binary -x b32d libssh-0.5.2.orig/src/agent.c libssh-0.5.2/src/agent.c
--- libssh-0.5.2.orig/src/agent.c	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/src/agent.c	2012-09-10 17:14:16.336573300 +0200
@@ -84,7 +84,7 @@
 static size_t atomicio(ssh_socket s, void *buf, size_t n, int do_read) {
   char *b = buf;
   size_t pos = 0;
-  ssize_t res;
+  ssh_ssize_t res;
   ssh_pollfd_t pfd;
   socket_t fd = ssh_socket_get_fd_in(s);
 
diff -urN --binary -x b32d libssh-0.5.2.orig/src/pcap.c libssh-0.5.2/src/pcap.c
--- libssh-0.5.2.orig/src/pcap.c	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/src/pcap.c	2012-09-10 17:12:25.636981900 +0200
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #ifdef _WIN32
+#include <winsock2.h>
 #include <ws2tcpip.h>
 #else
 #include <netinet/in.h>
diff -urN --binary -x b32d libssh-0.5.2.orig/src/sftp.c libssh-0.5.2/src/sftp.c
--- libssh-0.5.2.orig/src/sftp.c	2011-09-16 21:57:36.000000000 +0200
+++ libssh-0.5.2/src/sftp.c	2012-09-10 17:14:16.336573300 +0200
@@ -1739,7 +1739,7 @@
 }
 
 /* Read from a file using an opened sftp file handle. */
-ssize_t sftp_read(sftp_file handle, void *buf, size_t count) {
+ssh_ssize_t sftp_read(sftp_file handle, void *buf, size_t count) {
   sftp_session sftp = handle->sftp;
   sftp_message msg = NULL;
   sftp_status_message status;
@@ -1962,7 +1962,7 @@
   return SSH_ERROR;
 }
 
-ssize_t sftp_write(sftp_file file, const void *buf, size_t count) {
+ssh_ssize_t sftp_write(sftp_file file, const void *buf, size_t count) {
   sftp_session sftp = file->sftp;
   sftp_message msg = NULL;
   sftp_status_message status;
