From 1156680fc0a4713a9a83159705da2f16c6803ed7 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 10 May 2012 20:58:59 +0000 Subject: [PATCH] Compilando em windows --- XtGlue.c | 11 +++++++++-- host.c | 4 ++-- proxy.c | 11 +++++++---- resolver.c | 13 ++++++------- telnet.c | 19 +++++++++++++------ util.c | 9 +++++---- xio.c | 4 ++-- 7 files changed, 44 insertions(+), 27 deletions(-) diff --git a/XtGlue.c b/XtGlue.c index 8cad2af..d318f93 100644 --- a/XtGlue.c +++ b/XtGlue.c @@ -31,6 +31,10 @@ */ /* glue for missing Xt code */ +#if defined(_WIN32) + #include + #include +#endif // WIN32 #include "globals.h" #include "api.h" @@ -219,9 +223,9 @@ static unsigned long DefaultAddTimeOut(unsigned long interval_ms, H3270 *session prev->next = t_new; } - Trace("Timeout added: %p",t_new); + trace("Timeout added: %p",t_new); - return (unsigned long)t_new; + return (unsigned long) t_new; } static void DefaultRemoveTimeOut(unsigned long timer) @@ -874,6 +878,9 @@ void RemoveTimeOut(unsigned long timer) unsigned long AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) { CHECK_SESSION_HANDLE(session); + + trace("Adding input %d",source); + if(callbacks->AddInput) return callbacks->AddInput(source,session,fn); return 0; diff --git a/host.c b/host.c index 3e5ccb4..8ae74a4 100644 --- a/host.c +++ b/host.c @@ -575,8 +575,8 @@ static int do_connect(H3270 *hSession, const char *n) /* Prepare Xt for I/O. */ // x_add_input(hSession); #ifdef _WIN32 - hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); - hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); + hSession->ns_exception_id = AddExcept((int) hSession->sockEvent, hSession, net_exception); + hSession->ns_read_id = AddInput((int) hSession->sockEvent, hSession, net_input); #else hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); diff --git a/proxy.c b/proxy.c index 1d448b1..fb3ca9d 100644 --- a/proxy.c +++ b/proxy.c @@ -35,6 +35,10 @@ * proxy.c * This module implements various kinds of proxies. */ +#ifdef _WIN32 + #include + #include +#endif // _WIN32 #include "globals.h" #if !defined(PR3287) /*[*/ @@ -46,10 +50,9 @@ #include #endif -#if defined(_WIN32) /*[*/ -#include -#include -#else /*][*/ +#if defined(_WIN32) + #include +#else #include #include diff --git a/resolver.c b/resolver.c index aa1b7cb..b9970d9 100644 --- a/resolver.c +++ b/resolver.c @@ -35,23 +35,22 @@ * Hostname resolution. */ -#include "globals.h" - -#if defined(W3N4) || defined(W3N46) /*[*/ - #error Deprecated -#endif /*]*/ - #ifdef WIN32 - /* Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). */ + // Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #include + #include #include + #include "globals.h" + #else + #include "globals.h" + #include #include #include diff --git a/telnet.c b/telnet.c index c43667e..c075480 100644 --- a/telnet.c +++ b/telnet.c @@ -473,9 +473,13 @@ static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr { struct connect_parm p = { sizeof(struct connect_parm), sockfd, addr, addrlen, -1 }; +#ifdef _WIN32 + do_connect_sock(hSession,&p); +#else trace("%s: Connect begin sock=%d",__FUNCTION__,p.sockfd); lib3270_call_thread((int (*)(H3270 *, void *)) do_connect_sock,hSession,&p); trace("%s: Connect ends, rc=%d",__FUNCTION__,p.err); +#endif // _WIN32 return p.err; } @@ -683,7 +687,6 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo /* all done */ #if defined(_WIN32) - if(session->sockEvent == NULL) { char ename[256]; @@ -712,8 +715,12 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo _exit(1); } + trace("Socket: %d Event: %ld",session->sock,session->sockEvent); + #endif // WIN32 + non_blocking(session,1); + return 0; } #undef close_fail @@ -956,9 +963,9 @@ void net_input(H3270 *session) CHECK_SESSION_HANDLE(session); -// #if defined(_WIN32) +//#if defined(_WIN32) // for (;;) -// #endif +//#endif { if (session->sock < 0) return; @@ -1008,9 +1015,8 @@ void net_input(H3270 *session) if (nr < 0) { if (socket_errno() == SE_EWOULDBLOCK) - { return; - } + #if defined(HAVE_LIBSSL) /*[*/ if(session->ssl_con != NULL) { @@ -1064,7 +1070,6 @@ void net_input(H3270 *session) } /* Process the data. */ - if (HALF_CONNECTED) { if (non_blocking(session,False) < 0) @@ -3209,6 +3214,8 @@ static int non_blocking(H3270 *session, Boolean on) #endif // FIONBIO + trace("Socket %d is %s",session->sock, on ? "non-blocking" : "blocking"); + return 0; } diff --git a/util.c b/util.c index e66acd0..c24adab 100644 --- a/util.c +++ b/util.c @@ -35,18 +35,19 @@ * Utility functions for x3270/c3270/s3270/tcl3270 */ +#if defined(_WIN32) + #include + #include +#endif // _WIN32 + #include "globals.h" #if defined(_WIN32) - #include #include "winversc.h" - - #include #include #include #include - #include "w3miscc.h" #else diff --git a/xio.c b/xio.c index bcab469..5fecfef 100644 --- a/xio.c +++ b/xio.c @@ -98,11 +98,11 @@ void x_except_on(H3270 *h) RemoveInput(h->ns_read_id); #ifdef WIN32 - h->ns_exception_id = AddExcept(h->sockEvent, h, net_exception); + h->ns_exception_id = AddExcept((int) h->sockEvent, h, net_exception); h->excepting = True; if(h->reading) - h->ns_read_id = AddInput(h->sockEvent, h, net_input); + h->ns_read_id = AddInput( (int) h->sockEvent, h, net_input); #else h->ns_exception_id = AddExcept(h->sock, h, net_exception); h->excepting = True; -- libgit2 0.21.2