[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Building libssh on Visual Studio 2005


Hi,

  The attached patch fix the build process on VS2005.
You'll still need to hack the cmake stuff, as I don't know enough of cmake to fix this by myself. I've modified the final .vcproj produced by cmake to make it use the included .def file (so ssh.dll actually export symbols).

The second patch fix the closesocket issue I've forgot in the initial patch, and apply to last git + the first patch.
Hope it helps.
From 2777be30231d1c0264550709080fca24b4d1dfd7 Mon Sep 17 00:00:00 2001
From: unknown <Cyril@.(none)>
Date: Sat, 27 Jun 2009 14:43:27 +0200
Subject: [PATCH 1/2] Cyril: Win32 Visual Studio 2005 support

---
 build/ssh.def         |  675 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/libssh/priv.h |   19 ++-
 include/libssh/sftp.h |   19 ++
 libssh/auth.c         |   13 +-
 libssh/channels.c     |    3 +-
 libssh/connect.c      |    1 -
 libssh/crypt.c        |    1 -
 libssh/dh.c           |   17 ++
 libssh/keyfiles.c     |    1 -
 libssh/misc.c         |   21 +-
 libssh/options.c      |   11 +-
 libssh/packet.c       |    3 +-
 libssh/poll.c         |    1 +
 libssh/server.c       |    3 +-
 libssh/sftp.c         |    8 +-
 libssh/sftpserver.c   |    1 -
 libssh/socket.c       |    5 +-
 libssh/string.c       |    1 -
 libssh/wrapper.c      |  126 ++++++++--
 19 files changed, 886 insertions(+), 43 deletions(-)
 create mode 100644 build/ssh.def

diff --git a/build/ssh.def b/build/ssh.def
new file mode 100644
index 0000000..bf0e4a6
--- /dev/null
+++ b/build/ssh.def
@@ -0,0 +1,675 @@
+EXPORTS
+ssh_accept
+ssh_bind_accept
+ssh_bind_fd_toaccept
+ssh_bind_free
+ssh_bind_get_fd
+ssh_bind_listen
+ssh_bind_new
+ssh_bind_set_blocking
+ssh_bind_set_fd
+ssh_bind_set_options
+sftp_client_message_free
+sftp_get_client_message
+sftp_handle
+sftp_handle_alloc
+sftp_handle_remove
+sftp_reply_attr
+sftp_reply_data
+sftp_reply_handle
+sftp_reply_name
+sftp_reply_names
+sftp_reply_names_add
+sftp_reply_status
+buffer_add_attributes
+sftp_async_read
+sftp_async_read_begin
+sftp_attributes_free
+sftp_canonicalize_path
+sftp_chmod
+sftp_chown
+sftp_close
+sftp_closedir
+sftp_dir_close
+sftp_dir_eof
+sftp_file_close
+sftp_file_set_blocking
+sftp_file_set_nonblocking
+sftp_free
+sftp_fstat
+sftp_get_error
+sftp_init
+sftp_lstat
+sftp_mkdir
+sftp_new
+sftp_open
+sftp_opendir
+sftp_packet_free
+sftp_packet_read
+sftp_packet_write
+sftp_parse_attr
+sftp_read
+sftp_readdir
+sftp_rename
+sftp_rewind
+sftp_rm
+sftp_rmdir
+sftp_seek
+sftp_seek64
+sftp_server_init
+sftp_server_new
+sftp_server_version
+sftp_setstat
+sftp_stat
+sftp_tell
+sftp_tell64
+sftp_unlink
+sftp_utimes
+sftp_write
+crypt_set_algorithms
+crypt_set_algorithms_server
+crypto_free
+crypto_new
+hmac_final
+hmac_init
+hmac_update
+md5_final
+md5_init
+md5_update
+sha1
+sha1_final
+sha1_init
+sha1_update
+string_burn
+string_copy
+string_data
+string_fill
+string_free
+string_from_char
+string_len
+string_new
+string_to_char
+ssh_socket_blocking_flush
+ssh_socket_close
+ssh_socket_completeread
+ssh_socket_completewrite
+ssh_socket_data_available
+ssh_socket_data_writable
+ssh_socket_fd_isset
+ssh_socket_fd_set
+ssh_socket_free
+ssh_socket_get_fd
+ssh_socket_get_status
+ssh_socket_init
+ssh_socket_is_open
+ssh_socket_new
+ssh_socket_nonblocking_flush
+ssh_socket_poll
+ssh_socket_read
+ssh_socket_set_except
+ssh_socket_set_fd
+ssh_socket_set_toread
+ssh_socket_set_towrite
+ssh_socket_wait_for_data
+ssh_socket_write
+ssh_cleanup
+ssh_get_disconnect_message
+ssh_get_fd
+ssh_get_status
+ssh_get_version
+ssh_handle_packets
+ssh_new
+ssh_set_blocking
+ssh_set_fd_except
+ssh_set_fd_toread
+ssh_set_fd_towrite
+ssh_set_options
+ssh_silent_disconnect
+packet_flush
+packet_parse
+packet_read
+packet_send
+packet_translate
+packet_wait
+ssh_options_allow_ssh1
+ssh_options_allow_ssh2
+ssh_options_copy
+ssh_options_default_known_hosts_file
+ssh_options_default_ssh_dir
+ssh_options_default_username
+ssh_options_free
+ssh_options_getopt
+ssh_options_new
+ssh_options_set_auth_callback
+ssh_options_set_banner
+ssh_options_set_bind
+ssh_options_set_dsa_server_key
+ssh_options_set_fd
+ssh_options_set_host
+ssh_options_set_identity
+ssh_options_set_known_hosts_file
+ssh_options_set_log_function
+ssh_options_set_log_verbosity
+ssh_options_set_port
+ssh_options_set_rsa_server_key
+ssh_options_set_ssh_dir
+ssh_options_set_status_callback
+ssh_options_set_timeout
+ssh_options_set_username
+ssh_options_set_wanted_algos
+ntohll
+ssh_file_readaccess_ok
+ssh_get_user_home_dir
+ssh_version
+ssh_message_auth_password
+ssh_message_auth_reply_success
+ssh_message_auth_set_methods
+ssh_message_auth_user
+ssh_message_channel_request_open_reply_accept
+ssh_message_channel_request_reply_success
+ssh_message_channel_request_subsystem
+ssh_message_free
+ssh_message_get
+ssh_message_reply_default
+ssh_message_subtype
+ssh_message_type
+match_hostname
+ssh_log
+publickey_free
+publickey_from_privatekey
+publickey_from_string
+publickey_make_dss
+publickey_make_rsa
+publickey_to_string
+signature_free
+signature_from_string
+ssh_do_sign
+ssh_encrypt_rsa1
+ssh_sign_session_id
+ssh_type_from_name
+ssh_type_to_char
+_privatekey_from_file
+privatekey_free
+privatekey_from_file
+publickey_from_file
+ssh_is_server_known
+ssh_write_knownhost
+try_publickey_from_file
+default_methods
+set_kex
+space_tokenize
+ssh_find_matching
+ssh_get_kex
+ssh_get_kex1
+ssh_kex_nums
+ssh_list_kex
+ssh_send_kex
+supported_methods
+verify_existing_algo
+ssh_finalize
+compress_buffer
+decompress_buffer
+ssh_get_error
+ssh_get_error_code
+ssh_set_error
+dh_build_k
+dh_generate_e
+dh_generate_f
+dh_generate_x
+dh_generate_y
+dh_get_e
+dh_get_f
+dh_import_e
+dh_import_f
+dh_import_pubkey
+generate_session_keys
+hashbufin_add_cookie
+hashbufout_add_cookie
+make_bignum_string
+make_sessionid
+make_string_bn
+signature_verify
+ssh_crypto_finalize
+ssh_crypto_init
+ssh_get_hexa
+ssh_get_pubkey
+ssh_get_pubkey_hash
+ssh_get_random
+ssh_print_bignum
+ssh_print_hexa
+packet_decrypt
+packet_decrypt_len
+packet_encrypt
+packet_hmac_verify
+ssh_crc32
+??_C@_00CNPNBAHC@?$AA@
+??_C@_02GMHACPFF@?$CFu?$AA@
+??_C@_03FPEIBLKH@tcp?$AA@
+??_C@_03OCLLGKEH@udp?$AA@
+??_C@_05LGDGBMPG@65535?$AA@
+??_C@_06EFDIEKOB@ws2_32?$AA@
+??_C@_06PEGLMMGL@wship6?$AA@
+??_C@_0M@MBIPAJOD@getaddrinfo?$AA@
+??_C@_0M@NNJNLPKG@getnameinfo?$AA@
+??_C@_0N@EHOPPMLH@freeaddrinfo?$AA@
+?bInitialized@?1??WspiapiLoad@@9@9
+?buff@?1??gai_strerrorA@@9@9
+?iNumGlobal@?1??WspiapiLoad@@9@9
+?pfFreeAddrInfo@?1??WspiapiFreeAddrInfo@@9@9
+?pfGetAddrInfo@?1??WspiapiGetAddrInfo@@9@9
+?rgtGlobal@?1??WspiapiLoad@@9@9
+gai_strerrorA
+ssh_connect_host
+ssh_select
+ssh_connect
+ssh_copyright
+ssh_disconnect
+ssh_get_banner
+ssh_get_issue_banner
+ssh_send_banner
+ssh_service_request
+channel_change_pty_size
+channel_close
+channel_default_bufferize
+channel_free
+channel_get_exit_status
+channel_get_session
+channel_handle
+channel_is_closed
+channel_is_eof
+channel_is_open
+channel_new
+channel_open_forward
+channel_open_session
+channel_poll
+channel_read
+channel_read_buffer
+channel_read_nonblocking
+channel_request_env
+channel_request_exec
+channel_request_pty
+channel_request_pty_size
+channel_request_sftp
+channel_request_shell
+channel_request_subsystem
+channel_select
+channel_send_eof
+channel_set_blocking
+channel_write
+ssh_channel_from_local
+ssh_channel_new_id
+buffer_add_buffer
+buffer_add_data
+buffer_add_ssh_string
+buffer_add_u32
+buffer_add_u64
+buffer_add_u8
+buffer_free
+buffer_get
+buffer_get_data
+buffer_get_len
+buffer_get_mpint
+buffer_get_rest
+buffer_get_rest_len
+buffer_get_ssh_string
+buffer_get_u32
+buffer_get_u64
+buffer_get_u8
+buffer_new
+buffer_pass_bytes
+buffer_pass_bytes_end
+buffer_prepend_data
+buffer_reinit
+base64_to_bin
+bin_to_base64
+ssh_auth_list
+ssh_userauth_autopubkey
+ssh_userauth_kbdint
+ssh_userauth_kbdint_getinstruction
+ssh_userauth_kbdint_getname
+ssh_userauth_kbdint_getnprompts
+ssh_userauth_kbdint_getprompt
+ssh_userauth_kbdint_setanswer
+ssh_userauth_list
+ssh_userauth_none
+ssh_userauth_offer_pubkey
+ssh_userauth_password
+ssh_userauth_pubkey
+??_C@_00CNPNBAHC@?$AA@
+??_C@_02GMHACPFF@?$CFu?$AA@
+??_C@_03FPEIBLKH@tcp?$AA@
+??_C@_03OCLLGKEH@udp?$AA@
+??_C@_05LGDGBMPG@65535?$AA@
+??_C@_06EFDIEKOB@ws2_32?$AA@
+??_C@_06PEGLMMGL@wship6?$AA@
+??_C@_0M@MBIPAJOD@getaddrinfo?$AA@
+??_C@_0M@NNJNLPKG@getnameinfo?$AA@
+??_C@_0N@EHOPPMLH@freeaddrinfo?$AA@
+?bInitialized@?1??WspiapiLoad@@9@9
+?buff@?1??gai_strerrorA@@9@9
+?iNumGlobal@?1??WspiapiLoad@@9@9
+?pfFreeAddrInfo@?1??WspiapiFreeAddrInfo@@9@9
+?pfGetAddrInfo@?1??WspiapiGetAddrInfo@@9@9
+?rgtGlobal@?1??WspiapiLoad@@9@9
+_privatekey_from_file
+base64_to_bin
+bin_to_base64
+buffer_add_attributes
+buffer_add_buffer
+buffer_add_data
+buffer_add_ssh_string
+buffer_add_u32
+buffer_add_u64
+buffer_add_u8
+buffer_free
+buffer_get
+buffer_get_data
+buffer_get_len
+buffer_get_mpint
+buffer_get_rest
+buffer_get_rest_len
+buffer_get_ssh_string
+buffer_get_u32
+buffer_get_u64
+buffer_get_u8
+buffer_new
+buffer_pass_bytes
+buffer_pass_bytes_end
+buffer_prepend_data
+buffer_reinit
+channel_change_pty_size
+channel_close
+channel_default_bufferize
+channel_free
+channel_get_exit_status
+channel_get_session
+channel_handle
+channel_is_closed
+channel_is_eof
+channel_is_open
+channel_new
+channel_open_forward
+channel_open_session
+channel_poll
+channel_read
+channel_read_buffer
+channel_read_nonblocking
+channel_request_env
+channel_request_exec
+channel_request_pty
+channel_request_pty_size
+channel_request_sftp
+channel_request_shell
+channel_request_subsystem
+channel_select
+channel_send_eof
+channel_set_blocking
+channel_write
+compress_buffer
+crypt_set_algorithms
+crypt_set_algorithms_server
+crypto_free
+crypto_new
+decompress_buffer
+default_methods
+dh_build_k
+dh_generate_e
+dh_generate_f
+dh_generate_x
+dh_generate_y
+dh_get_e
+dh_get_f
+dh_import_e
+dh_import_f
+dh_import_pubkey
+gai_strerrorA
+generate_session_keys
+hashbufin_add_cookie
+hashbufout_add_cookie
+hmac_final
+hmac_init
+hmac_update
+make_bignum_string
+make_sessionid
+make_string_bn
+match_hostname
+md5_final
+md5_init
+md5_update
+ntohll
+packet_decrypt
+packet_decrypt_len
+packet_encrypt
+packet_flush
+packet_hmac_verify
+packet_parse
+packet_read
+packet_send
+packet_translate
+packet_wait
+privatekey_free
+privatekey_from_file
+publickey_free
+publickey_from_file
+publickey_from_privatekey
+publickey_from_string
+publickey_make_dss
+publickey_make_rsa
+publickey_to_string
+set_kex
+sftp_async_read
+sftp_async_read_begin
+sftp_attributes_free
+sftp_canonicalize_path
+sftp_chmod
+sftp_chown
+sftp_client_message_free
+sftp_close
+sftp_closedir
+sftp_dir_close
+sftp_dir_eof
+sftp_file_close
+sftp_file_set_blocking
+sftp_file_set_nonblocking
+sftp_free
+sftp_fstat
+sftp_get_client_message
+sftp_get_error
+sftp_handle
+sftp_handle_alloc
+sftp_handle_remove
+sftp_init
+sftp_lstat
+sftp_mkdir
+sftp_new
+sftp_open
+sftp_opendir
+sftp_packet_free
+sftp_packet_read
+sftp_packet_write
+sftp_parse_attr
+sftp_read
+sftp_readdir
+sftp_rename
+sftp_reply_attr
+sftp_reply_data
+sftp_reply_handle
+sftp_reply_name
+sftp_reply_names
+sftp_reply_names_add
+sftp_reply_status
+sftp_rewind
+sftp_rm
+sftp_rmdir
+sftp_seek
+sftp_seek64
+sftp_server_init
+sftp_server_new
+sftp_server_version
+sftp_setstat
+sftp_stat
+sftp_tell
+sftp_tell64
+sftp_unlink
+sftp_utimes
+sftp_write
+sha1
+sha1_final
+sha1_init
+sha1_update
+signature_free
+signature_from_string
+signature_verify
+space_tokenize
+ssh_accept
+ssh_auth_list
+ssh_bind_accept
+ssh_bind_fd_toaccept
+ssh_bind_free
+ssh_bind_get_fd
+ssh_bind_listen
+ssh_bind_new
+ssh_bind_set_blocking
+ssh_bind_set_fd
+ssh_bind_set_options
+ssh_channel_from_local
+ssh_channel_new_id
+ssh_cleanup
+ssh_connect
+ssh_connect_host
+ssh_copyright
+ssh_crc32
+ssh_crypto_finalize
+ssh_crypto_init
+ssh_disconnect
+ssh_do_sign
+ssh_encrypt_rsa1
+ssh_file_readaccess_ok
+ssh_finalize
+ssh_find_matching
+ssh_get_banner
+ssh_get_disconnect_message
+ssh_get_error
+ssh_get_error_code
+ssh_get_fd
+ssh_get_hexa
+ssh_get_issue_banner
+ssh_get_kex
+ssh_get_kex1
+ssh_get_pubkey
+ssh_get_pubkey_hash
+ssh_clean_pubkey_hash
+ssh_get_random
+ssh_get_status
+ssh_get_user_home_dir
+ssh_get_version
+ssh_handle_packets
+ssh_is_server_known
+ssh_kex_nums
+ssh_list_kex
+ssh_log
+ssh_crypto_init
+ssh_message_auth_password
+ssh_message_auth_reply_success
+ssh_message_auth_set_methods
+ssh_message_auth_user
+ssh_message_channel_request_open_reply_accept
+ssh_message_channel_request_reply_success
+ssh_message_channel_request_subsystem
+ssh_message_free
+ssh_message_get
+ssh_message_reply_default
+ssh_message_subtype
+ssh_message_type
+ssh_new
+ssh_options_allow_ssh1
+ssh_options_allow_ssh2
+ssh_options_copy
+ssh_options_default_known_hosts_file
+ssh_options_default_ssh_dir
+ssh_options_default_username
+ssh_options_free
+ssh_options_getopt
+ssh_options_new
+ssh_options_set_auth_callback
+ssh_options_set_banner
+ssh_options_set_bind
+ssh_options_set_dsa_server_key
+ssh_options_set_fd
+ssh_options_set_host
+ssh_options_set_identity
+ssh_options_set_known_hosts_file
+ssh_options_set_log_function
+ssh_options_set_log_verbosity
+ssh_options_set_port
+ssh_options_set_rsa_server_key
+ssh_options_set_ssh_dir
+ssh_options_set_status_callback
+ssh_options_set_timeout
+ssh_options_set_username
+ssh_options_set_wanted_algos
+ssh_print_bignum
+ssh_print_hexa
+ssh_select
+ssh_send_banner
+ssh_send_kex
+ssh_service_request
+ssh_set_blocking
+ssh_set_error
+ssh_set_fd_except
+ssh_set_fd_toread
+ssh_set_fd_towrite
+ssh_set_options
+ssh_sign_session_id
+ssh_silent_disconnect
+ssh_socket_blocking_flush
+ssh_socket_close
+ssh_socket_completeread
+ssh_socket_completewrite
+ssh_socket_data_available
+ssh_socket_data_writable
+ssh_socket_fd_isset
+ssh_socket_fd_set
+ssh_socket_free
+ssh_socket_get_fd
+ssh_socket_get_status
+ssh_socket_init
+ssh_socket_is_open
+ssh_socket_new
+ssh_socket_nonblocking_flush
+ssh_socket_poll
+ssh_socket_read
+ssh_socket_set_except
+ssh_socket_set_fd
+ssh_socket_set_toread
+ssh_socket_set_towrite
+ssh_socket_wait_for_data
+ssh_socket_write
+ssh_type_from_name
+ssh_type_to_char
+ssh_userauth_autopubkey
+ssh_userauth_kbdint
+ssh_userauth_kbdint_getinstruction
+ssh_userauth_kbdint_getname
+ssh_userauth_kbdint_getnprompts
+ssh_userauth_kbdint_getprompt
+ssh_userauth_kbdint_setanswer
+ssh_userauth_list
+ssh_userauth_none
+ssh_userauth_offer_pubkey
+ssh_userauth_password
+ssh_userauth_pubkey
+ssh_version
+ssh_write_knownhost
+string_burn
+string_copy
+string_data
+string_fill
+string_free
+string_from_char
+string_len
+string_new
+string_to_char
+supported_methods
+try_publickey_from_file
+verify_existing_algo
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 4c380de..b4a5bea 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -29,6 +29,13 @@
 
 #ifndef _LIBSSH_PRIV_H
 #define _LIBSSH_PRIV_H
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#else
+#include <unistd.h>
+#endif
+
 #include "config.h"
 #include "libssh/libssh.h"
 
@@ -171,10 +178,20 @@ void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
 
 /* strings and buffers */
 /* must be 32 bits number + immediatly our data */
+#ifdef _MSC_VER 
+#pragma pack(1)
+#endif
 struct string_struct {
 	u32 size;
 	unsigned char string[MAX_PACKET_LEN];
-} __attribute__ ((packed));
+}
+#ifndef _MSC_VER 
+__attribute__ ((packed))
+#endif
+;
+#ifdef _MSC_VER 
+#pragma pack()
+#endif
 
 /** Describes a buffer state at a moment
  */
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h
index 83c6f1d..d80b851 100644
--- a/include/libssh/sftp.h
+++ b/include/libssh/sftp.h
@@ -56,6 +56,14 @@ extern "C" {
 #ifndef gid_t
   typedef long gid_t;
 #endif /* gid_t */
+#ifndef mode_t
+  typedef long mode_t;
+#endif /* mode_t */
+#ifndef ssize_t
+    typedef _W64 signed int ssize_t;
+#endif /* ssize_t */
+
+
 #endif /* _WIN32 */
 
 typedef struct sftp_session_struct {
@@ -470,6 +478,17 @@ int sftp_seek64(SFTP_FILE *file, u64 new_offset);
 unsigned long sftp_tell(SFTP_FILE *file);
 
 /**
+ * @brief Report current byte position in file.
+ *
+ * @param file          Open sftp file handle.
+ *
+ * @return              The offset of the current byte relative to the beginning
+ *                      of the file associated with the file descriptor. < 0 on
+ *                      error.
+ */
+ssize_t sftp_tell64(SFTP_FILE *file);
+
+/**
  * @brief Rewinds the position of the file pointer to the beginning of the
  * file.
  *
diff --git a/libssh/auth.c b/libssh/auth.c
index 752341d..e4bb220 100644
--- a/libssh/auth.c
+++ b/libssh/auth.c
@@ -750,6 +750,8 @@ error:
   return rc;
 }
 
+#ifndef _MSC_VER
+/* This requires GCC extensions */
 static struct keys_struct keytab[] = {
   {
     .privatekey = "%s/.ssh/identity",
@@ -768,7 +770,16 @@ static struct keys_struct keytab[] = {
     .publickey = NULL
   }
 };
-
+#else
+static const char privKey_1[] = "%s/.ssh/identity";
+static const char pubKey_1[] = "%s/.ssh/identity.pub";
+static const char privKey_2[] = "%s/.ssh/id_dsa";
+static const char pubKey_2[] = "%s/.ssh/id_dsa.pub";
+static const char privKey_3[] = "%s/.ssh/id_rsa";
+static const char pubKey_3[] = "%s/.ssh/id_rsa.pub";
+
+static struct keys_struct keytab[] = { { privKey_1, pubKey_1}, { privKey_2, pubKey_2}, { privKey_3, pubKey_3}, {0}};
+#endif
 /* this function initialy was in the client */
 /* but the fools are the ones who never change mind */
 
diff --git a/libssh/channels.c b/libssh/channels.c
index 3b36299..689fb3a 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -24,7 +24,6 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
 
@@ -934,7 +933,7 @@ int channel_write(CHANNEL *channel, const void *data, u32 len) {
 
     channel->remote_window -= effectivelen;
     len -= effectivelen;
-    data += effectivelen;
+    data = ((u8*)data + effectivelen);
   }
 
   leave_function();
diff --git a/libssh/connect.c b/libssh/connect.c
index f784323..fbd8484 100644
--- a/libssh/connect.c
+++ b/libssh/connect.c
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #ifdef _WIN32
 /* getaddrinfo, freeaddrinfo, getnameinfo */
diff --git a/libssh/crypt.c b/libssh/crypt.c
index 3e9a852..a95a27b 100644
--- a/libssh/crypt.c
+++ b/libssh/crypt.c
@@ -21,7 +21,6 @@
  * MA 02111-1307, USA.
  */
 
-#include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/libssh/dh.c b/libssh/dh.c
index d926215..1c5ba78 100644
--- a/libssh/dh.c
+++ b/libssh/dh.c
@@ -847,6 +847,23 @@ int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) {
   return MD5_DIGEST_LEN;
 }
 
+/** \addtogroup ssh_session
+ * @{ */
+/**
+ * @brief Deallocate the hash obtained by ssh_get_pubkey_hash.
+ * This is required under Microsoft platform as this library might use a 
+ * different C library than your software, hence a different heap.
+ *
+ * @param  hash         The buffer to deallocate.
+ *
+ * @see ssh_get_pubkey_hash
+ */
+void ssh_clean_pubkey_hash(unsigned char **hash) 
+{
+    SAFE_FREE(*hash);
+    *hash = NULL;
+}
+
 STRING *ssh_get_pubkey(SSH_SESSION *session){
     return string_copy(session->current_crypto->server_pubkey);
 }
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 1918427..8af9f8e 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -25,7 +25,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <ctype.h>
diff --git a/libssh/misc.c b/libssh/misc.c
index 83a0520..5d0c9fc 100644
--- a/libssh/misc.c
+++ b/libssh/misc.c
@@ -24,7 +24,6 @@
 
 #include <limits.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -33,8 +32,8 @@
 
 #ifdef _WIN32
 #define _WIN32_IE 0x0400 //SHGetSpecialFolderPath
+#include <winsock2.h> // Must be the first to include
 #include <shlobj.h>
-#include <winsock2.h>
 #else
 #include <pwd.h>
 #include <arpa/inet.h>
@@ -77,6 +76,15 @@ char *ssh_get_user_home_dir(void) {
 
   return NULL;
 }
+    
+ /* we have read access on file */
+ int ssh_file_readaccess_ok(const char *file) {
+  if (_access(file, 4) < 0) {
+    return 0;
+  }
+
+  return 1;
+}   
 #else /* _WIN32 */
 
 char *ssh_get_user_home_dir(void) {
@@ -92,9 +100,6 @@ char *ssh_get_user_home_dir(void) {
 
   return szPath;
 }
-
-#endif
-
 /* we have read access on file */
 int ssh_file_readaccess_ok(const char *file) {
   if (access(file, R_OK) < 0) {
@@ -103,13 +108,15 @@ int ssh_file_readaccess_ok(const char *file) {
 
   return 1;
 }
+   
+#endif
 
 u64 ntohll(u64 a) {
 #ifdef WORDS_BIGENDIAN
   return a;
 #else
-  u32 low = a & 0xffffffff;
-  u32 high = a >> 32 ;
+  u32 low = (u32)(a & 0xffffffff);
+  u32 high = (u32)(a >> 32);
   low = ntohl(low);
   high = ntohl(high);
 
diff --git a/libssh/options.c b/libssh/options.c
index 7c0246e..fed91b8 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -24,10 +24,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
 #ifndef _WIN32
 #include <pwd.h>
+#else
+#include <winsock2.h>
 #endif
 #include <sys/types.h>
 #include "libssh/priv.h"
@@ -589,6 +590,7 @@ int ssh_options_default_username(SSH_OPTIONS *opt) {
     return 0;
   }
 #else
+{
   DWORD Size = 0;
   GetUserName(NULL, &Size); //Get Size
   user = malloc(Size);
@@ -601,6 +603,7 @@ int ssh_options_default_username(SSH_OPTIONS *opt) {
   } else {
     SAFE_FREE(user);
   }
+}
 #endif
   return -1;
 }
@@ -836,7 +839,10 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) {
   int ssh1 = 0;
 #endif
   int ssh2 = 1;
-
+#ifdef _MSC_VER
+    /* Not supported with a Microsoft compiler */
+    return -1;
+#else
   int saveoptind = optind; /* need to save 'em */
   int saveopterr = opterr;
 
@@ -985,6 +991,7 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) {
   }
 
   return 0;
+#endif 
 }
 
 /**
diff --git a/libssh/packet.c b/libssh/packet.c
index 2304441..291e3d2 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -23,7 +23,6 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <string.h>
 #include <errno.h>
 
@@ -148,7 +147,7 @@ static int packet_read2(SSH_SESSION *session) {
          * have been decrypted)
          */
         if (packet_decrypt(session,
-              buffer_get(session->in_buffer) + blocksize,
+              ((u8*)buffer_get(session->in_buffer) + blocksize),
               buffer_get_len(session->in_buffer) - blocksize) < 0) {
           ssh_set_error(session, SSH_FATAL, "Decrypt error");
           goto error;
diff --git a/libssh/poll.c b/libssh/poll.c
index c20300d..6bac5a1 100644
--- a/libssh/poll.c
+++ b/libssh/poll.c
@@ -54,6 +54,7 @@ int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout) {
 
 #include <stdio.h>
 #include <windows.h>
+#include <errno.h>
 
 static int poll_rest (HANDLE *handles, int nhandles,
     pollfd_t *fds, nfds_t nfds, int timeout) {
diff --git a/libssh/server.c b/libssh/server.c
index 25021f6..241cece 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -32,7 +32,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 
 #include "libssh/priv.h"
 #include "libssh/libssh.h"
@@ -45,7 +44,7 @@
 #define SOCKOPT_TYPE_ARG4 char
 
 /* We need to provide hstrerror. Not we can't call the parameter h_errno because it's #defined */
-inline char *hstrerror(int h_errno_val) {
+static char *hstrerror(int h_errno_val) {
   static char text[50] = {0};
 
   snprintf(text, sizeof(text), "gethostbyname error %d\n", h_errno_val);
diff --git a/libssh/sftp.c b/libssh/sftp.c
index 9776c3d..4c02932 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -582,7 +582,7 @@ static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, u32 id){
  * between them.
  * Returns a new ID ready to use in a request
  */
-static inline u32 sftp_get_new_id(SFTP_SESSION *session) {
+static u32 sftp_get_new_id(SFTP_SESSION *session) {
   return ++session->id_counter;
 }
 
@@ -1777,7 +1777,11 @@ int sftp_seek64(SFTP_FILE *file, u64 new_offset) {
 
 /* Report current byte position in file. */
 unsigned long sftp_tell(SFTP_FILE *file) {
-  return file->offset;
+  return (unsigned long)file->offset;
+}
+/* Report current byte position in file. */
+ssize_t sftp_tell64(SFTP_FILE *file) {
+  return (ssize_t)file->offset;
 }
 
 /* Rewinds the position of the file pointer to the beginning of the file.*/
diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c
index b005799..1ccb717 100644
--- a/libssh/sftpserver.c
+++ b/libssh/sftpserver.c
@@ -21,7 +21,6 @@
  * MA 02111-1307, USA.
  */
 
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/libssh/socket.c b/libssh/socket.c
index 16da8cc..56a576b 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -21,7 +21,6 @@
  * MA 02111-1307, USA.
  */
 
-#include <unistd.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
@@ -264,7 +263,7 @@ int ssh_socket_completeread(struct socket *s, void *buffer, u32 len) {
     return SSH_ERROR;
   }
 
-  while((r = ssh_socket_unbuffered_read(s, buffer + total, toread))) {
+  while((r = ssh_socket_unbuffered_read(s, ((u8*)buffer + total), toread))) {
     if (r < 0) {
       return SSH_ERROR;
     }
@@ -303,7 +302,7 @@ int ssh_socket_completewrite(struct socket *s, const void *buffer, u32 len) {
       return SSH_ERROR;
     }
     len -= written;
-    buffer += written;
+    buffer = ((u8*)buffer +  written);
   }
 
   leave_function();
diff --git a/libssh/string.c b/libssh/string.c
index 9fb6c3a..10449c1 100644
--- a/libssh/string.c
+++ b/libssh/string.c
@@ -22,7 +22,6 @@
  */
 
 #include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
 
 #ifndef _WIN32
diff --git a/libssh/wrapper.c b/libssh/wrapper.c
index f2011d8..3be271c 100644
--- a/libssh/wrapper.c
+++ b/libssh/wrapper.c
@@ -577,11 +577,11 @@ static int des3_set_key(struct crypto_struct *cipher, void *key) {
     }
 
     DES_set_odd_parity(key);
-    DES_set_odd_parity(key + 8);
-    DES_set_odd_parity(key + 16);
+    DES_set_odd_parity((void*)((u8*)key + 8));
+    DES_set_odd_parity((void*)((u8*)key + 16));
     DES_set_key_unchecked(key, cipher->key);
-    DES_set_key_unchecked(key + 8, cipher->key + sizeof(DES_key_schedule));
-    DES_set_key_unchecked(key + 16, cipher->key + 2 * sizeof(DES_key_schedule));
+    DES_set_key_unchecked((void*)((u8*)key + 8), (void*)((u8*)cipher->key + sizeof(DES_key_schedule)));
+    DES_set_key_unchecked((void*)((u8*)key + 16), (void*)((u8*)cipher->key + 2 * sizeof(DES_key_schedule)));
   }
 
   return 0;
@@ -590,16 +590,16 @@ static int des3_set_key(struct crypto_struct *cipher, void *key) {
 static void des3_encrypt(struct crypto_struct *cipher, void *in,
     void *out, unsigned long len, void *IV) {
   DES_ede3_cbc_encrypt(in, out, len, cipher->key,
-      cipher->key + sizeof(DES_key_schedule),
-      cipher->key + 2 * sizeof(DES_key_schedule),
+      (void*)((u8*)cipher->key + sizeof(DES_key_schedule)),
+      (void*)((u8*)cipher->key + 2 * sizeof(DES_key_schedule)),
       IV, 1);
 }
 
 static void des3_decrypt(struct crypto_struct *cipher, void *in,
     void *out, unsigned long len, void *IV) {
   DES_ede3_cbc_encrypt(in, out, len, cipher->key,
-      cipher->key + sizeof(DES_key_schedule),
-      cipher->key + 2 * sizeof(DES_key_schedule),
+      (void*)((u8*)cipher->key + sizeof(DES_key_schedule)),
+      (void*)((u8*)cipher->key + 2 * sizeof(DES_key_schedule)),
       IV, 0);
 }
 
@@ -609,10 +609,10 @@ static void des3_1_encrypt(struct crypto_struct *cipher, void *in,
   ssh_print_hexa("Encrypt IV before", IV, 24);
 #endif
   DES_ncbc_encrypt(in, out, len, cipher->key, IV, 1);
-  DES_ncbc_encrypt(out, in, len, cipher->key + sizeof(DES_key_schedule),
-      IV + 8, 0);
-  DES_ncbc_encrypt(in, out, len, cipher->key + 2 * sizeof(DES_key_schedule),
-      IV + 16, 1);
+  DES_ncbc_encrypt(out, in, len, (void*)((u8*)cipher->key + sizeof(DES_key_schedule)),
+      (void*)((u8*)IV + 8), 0);
+  DES_ncbc_encrypt(in, out, len, (void*)((u8*)cipher->key + 2 * sizeof(DES_key_schedule)),
+      (void*)((u8*)IV + 16), 1);
 #ifdef DEBUG_CRYPTO
   ssh_print_hexa("Encrypt IV after", IV, 24);
 #endif
@@ -624,11 +624,11 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
   ssh_print_hexa("Decrypt IV before", IV, 24);
 #endif
 
-  DES_ncbc_encrypt(in, out, len, cipher->key + 2 * sizeof(DES_key_schedule),
+  DES_ncbc_encrypt(in, out, len, (void*)((u8*)cipher->key + 2 * sizeof(DES_key_schedule)),
       IV, 0);
-  DES_ncbc_encrypt(out, in, len, cipher->key + sizeof(DES_key_schedule),
-      IV + 8, 1);
-  DES_ncbc_encrypt(in, out, len, cipher->key, IV + 16, 0);
+  DES_ncbc_encrypt(out, in, len, (void*)((u8*)cipher->key + sizeof(DES_key_schedule)),
+      (void*)((u8*)IV + 8), 1);
+  DES_ncbc_encrypt(in, out, len, cipher->key, (void*)((u8*)IV + 16), 0);
 
 #ifdef DEBUG_CRYPTO
   ssh_print_hexa("Decrypt IV after", IV, 24);
@@ -638,6 +638,8 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
 #endif /* HAS_DES */
 
 /* the table of supported ciphers */
+#ifndef _MSC_VER
+/* Those are GCC extension */
 static struct crypto_struct ssh_ciphertab[] = {
 #ifdef HAS_BLOWFISH
   {
@@ -712,6 +714,7 @@ static struct crypto_struct ssh_ciphertab[] = {
   },
 #endif /* HAS_DES */
   {
+#ifndef _MSC_VER
     .name            = NULL,
     .blocksize       = 0,
     .keylen          = 0,
@@ -721,8 +724,99 @@ static struct crypto_struct ssh_ciphertab[] = {
     .set_decrypt_key = NULL,
     .cbc_encrypt     = NULL,
     .cbc_decrypt     = NULL
+    #else
+    0
+#endif
   }
 };
+#else
+/* Warning, if you modify crypto_struct, you must make sure the order is correct here */
+static struct crypto_struct ssh_ciphertab[] = {
+#ifdef HAS_BLOWFISH
+  {
+    "blowfish-cbc",
+    8,
+    sizeof (BF_KEY),
+    NULL,
+    128,
+    blowfish_set_key,
+    blowfish_set_key,
+    blowfish_encrypt,
+    blowfish_decrypt
+  },
+#endif /* HAS_BLOWFISH */
+#ifdef HAS_AES
+  {
+    "aes128-cbc",
+    16,
+    sizeof(AES_KEY),
+    NULL,
+    128,
+    aes_set_encrypt_key,
+    aes_set_decrypt_key,
+    aes_encrypt,
+    aes_decrypt
+  },
+  {
+    "aes192-cbc",
+    16,
+    sizeof(AES_KEY),
+    NULL,
+    192,
+    aes_set_encrypt_key,
+    aes_set_decrypt_key,
+    aes_encrypt,
+    aes_decrypt
+  },
+  {
+    "aes256-cbc",
+    16,
+    sizeof(AES_KEY),
+    NULL,
+    256,
+    aes_set_encrypt_key,
+    aes_set_decrypt_key,
+    aes_encrypt,
+    aes_decrypt
+  },
+#endif /* HAS_AES */
+#ifdef HAS_DES
+  {
+    "3des-cbc",
+    8,
+    sizeof(DES_key_schedule) * 3,
+    NULL,
+    192,
+    des3_set_key,
+    des3_set_key,
+    des3_encrypt,
+    des3_decrypt
+  },
+  {
+    "3des-cbc-ssh1",
+    8,
+    sizeof(DES_key_schedule) * 3,
+    NULL,
+    192,
+    des3_set_key,
+    des3_set_key,
+    des3_1_encrypt,
+    des3_1_decrypt
+  },
+#endif /* HAS_DES */
+  {
+    NULL,
+    0,
+    0,
+    NULL,
+    0,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+  }
+};
+#endif
 #endif /* OPENSSL_CRYPTO */
 
 /* it allocates a new cipher structure based on its offset into the global table */
-- 
1.6.3.2.1299.gee46c

From bcba99159c199d3dcb353cd1c6bb651555504264 Mon Sep 17 00:00:00 2001
From: unknown <Cyril@.(none)>
Date: Tue, 7 Jul 2009 10:32:01 +0200
Subject: [PATCH 2/2] Fixed few issues I've met

---
 ConfigureChecks.cmake           |    3 +
 build/build_make.sh             |  152 ---------------------------------------
 build/ssh.def                   |    2 +
 cmake/Modules/FindOpenSSL.cmake |   13 ++--
 cmake/Modules/FindZLIB.cmake    |   10 ++-
 include/libssh/libssh.h         |    6 ++
 include/libssh/sftp.h           |    2 +-
 libssh/connect.c                |    4 +
 libssh/init.c                   |    2 +-
 9 files changed, 30 insertions(+), 164 deletions(-)
 delete mode 100755 build/build_make.sh

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 0b1629e..7fe289b 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -22,6 +22,9 @@ check_include_file(terminos.h HAVE_TERMIOS_H)
 check_include_file(openssl/aes.h HAVE_OPENSSL_AES_H)
 check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
 check_include_file(openssl/des.h HAVE_OPENSSL_DES_H)
+set(HAVE_OPENSSL_AES_H TRUE)
+set(HAVE_OPENSSL_BLOWFISH_H TRUE)
+set(HAVE_OPENSSL_DES_H TRUE)
 
 # FUNCTIONS
 check_function_exists(cfmakeraw HAVE_CFMAKERAW)
diff --git a/build/build_make.sh b/build/build_make.sh
deleted file mode 100755
index 5b26988..0000000
--- a/build/build_make.sh
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-#
-# Last Change: 2008-06-18 14:13:46
-#
-# Script to build libssh on UNIX.
-#
-# Copyright (c) 2006-2007 Andreas Schneider <mail@xxxxxxxxxxxx>
-#
-
-SOURCE_DIR=".."
-
-LANG=C
-export LANG
-
-SCRIPT="$0"
-COUNT=0
-while [ -L "${SCRIPT}" ]
-do
-	SCRIPT=$(readlink ${SCRIPT})
-	COUNT=$(expr ${COUNT} + 1)
-	if [ ${COUNT} -gt 100 ]; then
-		echo "Too many symbolic links"
-		exit 1
-	fi
-done
-BUILDDIR=$(dirname ${SCRIPT})
-
-cleanup_and_exit () {
-	if test "$1" = 0 -o -z "$1" ; then
-		exit 0
-	else
-		exit $1
-	fi
-}
-
-function configure() {
-	cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
-}
-
-function compile() {
-	CPUCOUNT=$(grep -c processor /proc/cpuinfo)
-	if [ "${CPUCOUNT}" -gt "1" ]; then
-		make -j${CPUCOUNT} $1 || cleanup_and_exit $?
-	else
-		make $1 || exit $?
-	fi
-}
-
-function clean_build_dir() {
-	find ! -path "*.svn*" ! -name "*.bat" ! -name "*.sh" ! -name "." -print0 | xargs -0 rm -rf
-}
-
-function usage () {
-echo "Usage: `basename $0` [--prefix /install_prefix|--build [debug|final]|--clean|--verbose|--libsuffix (32|64)|--help]"
-    cleanup_and_exit
-}
-
-cd ${BUILDDIR}
-
-OPTIONS="--graphviz=${BUILDDIR}/libssh.dot -DUNIT_TESTING=ON -DWITH_SSH1=ON -DWITH_SERVER=ON"
-
-while test -n "$1"; do
-	PARAM="$1"
-	ARG="$2"
-	shift
-	case ${PARAM} in
-		*-*=*)
-		ARG=${PARAM#*=}
-		PARAM=${PARAM%%=*}
-		set -- "----noarg=${PARAM}" "$@"
-	esac
-	case ${PARAM} in
-		*-help|-h)
-			#echo_help
-			usage
-			cleanup_and_exit
-		;;
-		*-build)
-			DOMAKE="1"
-			BUILD_TYPE="${ARG}"
-			test -n "${BUILD_TYPE}" && shift
-		;;
-		*-clean)
-			clean_build_dir
-			cleanup_and_exit
-		;;
-		*-verbose)
-			DOVERBOSE="1"
-		;;
-		*-memtest)
-			OPTIONS="${OPTIONS} -DMEM_NULL_TESTS=ON"
-		;;
-		*-libsuffix)
-			OPTIONS="${OPTIONS} -DLIB_SUFFIX=${ARG}"
-			shift
-		;;
-		*-prefix)
-			OPTIONS="${OPTIONS} -DCMAKE_INSTALL_PREFIX=${ARG}"
-			shift
-		;;
-		*-sysconfdir)
-			OPTIONS="${OPTIONS} -DSYSCONF_INSTALL_DIR=${ARG}"
-			shift
-		;;
-		----noarg)
-			echo "$ARG does not take an argument"
-			cleanup_and_exit
-		;;
-		-*)
-			echo Unknown Option "$PARAM". Exit.
-			cleanup_and_exit 1
-		;;
-		*)
-			usage
-		;;
-	esac
-done
-
-if [ "${DOMAKE}" == "1" ]; then
-	OPTIONS="${OPTIONS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
-fi
-
-if [ -n "${DOVERBOSE}" ]; then
-	OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=1"
-else
-	OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=0"
-fi
-
-test -f "${BUILDDIR}/.build.log" && rm -f ${BUILDDIR}/.build.log
-touch ${BUILDDIR}/.build.log
-# log everything from here to .build.log
-exec 1> >(exec -a 'build logging tee' tee -a ${BUILDDIR}/.build.log) 2>&1
-echo "${HOST} started build at $(date)."
-echo
-
-configure ${OPTIONS} "$@"
-
-if [ -n "${DOMAKE}" ]; then
-	test -n "${DOVERBOSE}" && compile VERBOSE=1 || compile
-fi
-
-DOT=$(which dot 2>/dev/null)
-if [ -n "${DOT}" ]; then
-	${DOT} -Tpng -o${BUILDDIR}/libssh.png ${BUILDDIR}/libssh.dot
-	${DOT} -Tsvg -o${BUILDDIR}/libssh.svg ${BUILDDIR}/libssh.dot
-fi
-
-exec >&0 2>&0		# so that the logging tee finishes
-sleep 1			# wait till tee terminates
-
-cleanup_and_exit 0
-
diff --git a/build/ssh.def b/build/ssh.def
index bf0e4a6..5c2036d 100644
--- a/build/ssh.def
+++ b/build/ssh.def
@@ -1,4 +1,6 @@
 EXPORTS
+ssh_init
+ssh_finalize
 ssh_accept
 ssh_bind_accept
 ssh_bind_fd_toaccept
diff --git a/cmake/Modules/FindOpenSSL.cmake b/cmake/Modules/FindOpenSSL.cmake
index 1943c66..eb17014 100644
--- a/cmake/Modules/FindOpenSSL.cmake
+++ b/cmake/Modules/FindOpenSSL.cmake
@@ -42,9 +42,9 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
   )
   mark_as_advanced(OPENSSL_INCLUDE_DIR)
 
-  find_library(SSL_LIBRARY
+  find_path(SSL_LIBRARY
     NAMES
-      ssl
+      libssl.a
     PATHS
       ${_OPENSSL_LIBDIR}
       /usr/lib
@@ -54,9 +54,9 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
   )
   mark_as_advanced(SSL_LIBRARY)
 
-  find_library(SSLEAY32_LIBRARY
+  find_path(SSLEAY32_LIBRARY
     NAMES
-      ssleay32
+      ssleay32-0.9.8.dll 
     PATHS
       ${_OPENSSL_LIBDIR}
       /usr/lib
@@ -78,9 +78,9 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
   )
   mark_as_advanced(SSLEAY32MD_LIBRARY)
 
-  find_library(CRYPTO_LIBRARY
+  find_path(CRYPTO_LIBRARY
     NAMES
-      crypto
+      cryptoeay32-0.9.8.dll
     PATHS
       ${_OPENSSL_LIBDIR}
       /usr/lib
@@ -147,6 +147,7 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
       message(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
     endif (NOT OpenSSL_FIND_QUIETLY)
   else (OPENSSL_FOUND)
+    message(STATUS "${OPENSSL_INCLUDE_DIR}")
     if (OpenSSL_FIND_REQUIRED)
       message(FATAL_ERROR "Could not find OpenSSL")
     endif (OpenSSL_FIND_REQUIRED)
diff --git a/cmake/Modules/FindZLIB.cmake b/cmake/Modules/FindZLIB.cmake
index e9d14b0..cf244b3 100644
--- a/cmake/Modules/FindZLIB.cmake
+++ b/cmake/Modules/FindZLIB.cmake
@@ -23,19 +23,20 @@ else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
     NAMES
       zlib.h
     PATHS
+      ${CMAKE_INCLUDE_PATH}/zlib-1.2.3
       /usr/include
       /usr/local/include
       /opt/local/include
       /sw/include
+      d:/Temp/Dokan/zlib-1.2.3
   )
   mark_as_advanced(ZLIB_INCLUDE_DIR)
 
-  find_library(Z_LIBRARY
+  find_path(Z_LIBRARY
     NAMES
-      z
-      zlib
-      zlib1
+      zlib1.dll
     PATHS
+      ${CMAKE_LIBRARY_PATH}/zlib-1.2.3
       /usr/lib
       /usr/local/lib
       /opt/local/lib
@@ -68,6 +69,7 @@ else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
     endif (NOT ZLIB_FIND_QUIETLY)
   else (ZLIB_FOUND)
     if (ZLIB_FIND_REQUIRED)
+      message(STATUS "${ZLIB_INCLUDE_DIR} ${Z_LIBRARY}")
       message(FATAL_ERROR "Could not find ZLIB")
     endif (ZLIB_FIND_REQUIRED)
   endif (ZLIB_FOUND)
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 18d42c7..409c686 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -157,6 +157,11 @@ int ssh_get_error_code(void *error);
 /* version checks */
 const char *ssh_version(int req_version);
 
+/* The initialization function */
+int ssh_init(void);
+/* The cleaning function */
+int ssh_finalize(void);
+
 /** \addtogroup ssh_log
  * @{
  */
@@ -238,6 +243,7 @@ int ssh_get_random(void *where,int len,int strong);
 
 /* this one can be called by the client to see the hash of the public key before accepting it */
 int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
+void ssh_clean_pubkey_hash(unsigned char **hash);
 STRING *ssh_get_pubkey(SSH_SESSION *session);
 
 /* in connect.c */
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h
index d80b851..6548360 100644
--- a/include/libssh/sftp.h
+++ b/include/libssh/sftp.h
@@ -38,7 +38,7 @@
 
 #ifndef SFTP_H
 #define SFTP_H
-#include <libssh/libssh.h>
+#include "libssh.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/libssh/connect.c b/libssh/connect.c
index fbd8484..d2e4587 100644
--- a/libssh/connect.c
+++ b/libssh/connect.c
@@ -66,6 +66,9 @@ static void sock_set_blocking(socket_t sock) {
   ioctlsocket(sock, FIONBIO, &nonblocking);
 }
 
+static void close(socket_t sock) {
+  closesocket(sock);  
+}
 #ifndef gai_strerror
 char WSAAPI *gai_strerrorA(int code) {
   static char buf[256];
@@ -84,6 +87,7 @@ static void sock_set_nonblocking(socket_t sock) {
 static void sock_set_blocking(socket_t sock) {
   fcntl(sock, F_SETFL, 0);
 }
+
 #endif /* _WIN32 */
 
 static int getai(const char *host, int port, struct addrinfo **ai) {
diff --git a/libssh/init.c b/libssh/init.c
index 8d2ae03..b71fc79 100644
--- a/libssh/init.c
+++ b/libssh/init.c
@@ -34,7 +34,7 @@
 /**
  * @brief initialize global cryptographic data structures.
  *
- * This function should only be called once, at the begining of the program, in the main thread. It may be omitted if your program is not multithreaded.
+ * This function should only be called once, at the beginning of the program, in the main thread. It may be omitted if your program is not multithreaded.
  *
  * @returns 0
  */
-- 
1.6.3.2.1299.gee46c


Follow-Ups:
Re: Building libssh on Visual Studio 2005Andreas Schneider <mail@xxxxxxxxxxxx>
Re: Building libssh on Visual Studio 2005Andreas Schneider <mail@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org