Some windows-specific stuff

This commit is contained in:
Tim Warren 2015-04-08 11:13:26 -04:00
parent 9c2ad13d03
commit d204a624e4
2 changed files with 23 additions and 1 deletions

View File

@ -10,7 +10,11 @@ SFTP::~SFTP() {
libssh2_sftp_shutdown(sftp_session); libssh2_sftp_shutdown(sftp_session);
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing"); libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session); libssh2_session_free(session);
#ifdef __WXWIN__
closesocket(sock);
#else
close(sock); close(sock);
#endif
libssh2_exit(); libssh2_exit();
freeaddrinfo(host_info_list); freeaddrinfo(host_info_list);
freeaddrinfo(&host_info); freeaddrinfo(&host_info);
@ -73,6 +77,18 @@ string SFTP::getFile(const char *path)
void SFTP::ssh_connect(const char *host, const char *user, const char *pass, const char *port) void SFTP::ssh_connect(const char *host, const char *user, const char *pass, const char *port)
{ {
#ifdef __WXWIN__
WSADATA wsadata;
int err;
err = WSAStartup(MAKEWORD(2,0), &wsadata);
if (err != 0)
{
cerr << "WSAStartup failed with error:" << err << endl;
return;
}
#endif
// Clear out memory in addr structure // Clear out memory in addr structure
memset(&host_info, 0, sizeof host_info); memset(&host_info, 0, sizeof host_info);

View File

@ -12,7 +12,13 @@
// Socket includes // Socket includes
#include <cstring> #include <cstring>
#ifdef __WXWIN__
#include <winsock2.h>
#else
#include <sys/socket.h> #include <sys/socket.h>
#endif
#include <netdb.h> #include <netdb.h>
#include <stdio.h> #include <stdio.h>