Commit 1156680fc0a4713a9a83159705da2f16c6803ed7
1 parent
829568e6
Exists in
master
and in
3 other branches
Compilando em windows
Showing
7 changed files
with
44 additions
and
27 deletions
Show diff stats
XtGlue.c
... | ... | @@ -31,6 +31,10 @@ |
31 | 31 | */ |
32 | 32 | |
33 | 33 | /* glue for missing Xt code */ |
34 | +#if defined(_WIN32) | |
35 | + #include <winsock2.h> | |
36 | + #include <windows.h> | |
37 | +#endif // WIN32 | |
34 | 38 | |
35 | 39 | #include "globals.h" |
36 | 40 | #include "api.h" |
... | ... | @@ -219,9 +223,9 @@ static unsigned long DefaultAddTimeOut(unsigned long interval_ms, H3270 *session |
219 | 223 | prev->next = t_new; |
220 | 224 | } |
221 | 225 | |
222 | - Trace("Timeout added: %p",t_new); | |
226 | + trace("Timeout added: %p",t_new); | |
223 | 227 | |
224 | - return (unsigned long)t_new; | |
228 | + return (unsigned long) t_new; | |
225 | 229 | } |
226 | 230 | |
227 | 231 | static void DefaultRemoveTimeOut(unsigned long timer) |
... | ... | @@ -874,6 +878,9 @@ void RemoveTimeOut(unsigned long timer) |
874 | 878 | unsigned long AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) |
875 | 879 | { |
876 | 880 | CHECK_SESSION_HANDLE(session); |
881 | + | |
882 | + trace("Adding input %d",source); | |
883 | + | |
877 | 884 | if(callbacks->AddInput) |
878 | 885 | return callbacks->AddInput(source,session,fn); |
879 | 886 | return 0; | ... | ... |
host.c
... | ... | @@ -575,8 +575,8 @@ static int do_connect(H3270 *hSession, const char *n) |
575 | 575 | /* Prepare Xt for I/O. */ |
576 | 576 | // x_add_input(hSession); |
577 | 577 | #ifdef _WIN32 |
578 | - hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); | |
579 | - hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); | |
578 | + hSession->ns_exception_id = AddExcept((int) hSession->sockEvent, hSession, net_exception); | |
579 | + hSession->ns_read_id = AddInput((int) hSession->sockEvent, hSession, net_input); | |
580 | 580 | #else |
581 | 581 | hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); |
582 | 582 | hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); | ... | ... |
proxy.c
... | ... | @@ -35,6 +35,10 @@ |
35 | 35 | * proxy.c |
36 | 36 | * This module implements various kinds of proxies. |
37 | 37 | */ |
38 | +#ifdef _WIN32 | |
39 | + #include <winsock2.h> | |
40 | + #include <windows.h> | |
41 | +#endif // _WIN32 | |
38 | 42 | |
39 | 43 | #include "globals.h" |
40 | 44 | #if !defined(PR3287) /*[*/ |
... | ... | @@ -46,10 +50,9 @@ |
46 | 50 | #include <stdlib.h> |
47 | 51 | #endif |
48 | 52 | |
49 | -#if defined(_WIN32) /*[*/ | |
50 | -#include <winsock2.h> | |
51 | -#include <ws2tcpip.h> | |
52 | -#else /*][*/ | |
53 | +#if defined(_WIN32) | |
54 | + #include <ws2tcpip.h> | |
55 | +#else | |
53 | 56 | |
54 | 57 | #include <malloc.h> |
55 | 58 | #include <sys/socket.h> | ... | ... |
resolver.c
... | ... | @@ -35,23 +35,22 @@ |
35 | 35 | * Hostname resolution. |
36 | 36 | */ |
37 | 37 | |
38 | -#include "globals.h" | |
39 | - | |
40 | -#if defined(W3N4) || defined(W3N46) /*[*/ | |
41 | - #error Deprecated | |
42 | -#endif /*]*/ | |
43 | - | |
44 | 38 | #ifdef WIN32 |
45 | 39 | |
46 | - /* Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). */ | |
40 | + // Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). | |
47 | 41 | #undef _WIN32_WINNT |
48 | 42 | #define _WIN32_WINNT 0x0501 |
49 | 43 | |
50 | 44 | #include <winsock2.h> |
45 | + #include <windows.h> | |
51 | 46 | #include <ws2tcpip.h> |
52 | 47 | |
48 | + #include "globals.h" | |
49 | + | |
53 | 50 | #else |
54 | 51 | |
52 | + #include "globals.h" | |
53 | + | |
55 | 54 | #include <sys/socket.h> |
56 | 55 | #include <netinet/in.h> |
57 | 56 | #include <netdb.h> | ... | ... |
telnet.c
... | ... | @@ -473,9 +473,13 @@ static int connect_sock(H3270 *hSession, int sockfd, const struct sockaddr *addr |
473 | 473 | { |
474 | 474 | struct connect_parm p = { sizeof(struct connect_parm), sockfd, addr, addrlen, -1 }; |
475 | 475 | |
476 | +#ifdef _WIN32 | |
477 | + do_connect_sock(hSession,&p); | |
478 | +#else | |
476 | 479 | trace("%s: Connect begin sock=%d",__FUNCTION__,p.sockfd); |
477 | 480 | lib3270_call_thread((int (*)(H3270 *, void *)) do_connect_sock,hSession,&p); |
478 | 481 | trace("%s: Connect ends, rc=%d",__FUNCTION__,p.err); |
482 | +#endif // _WIN32 | |
479 | 483 | |
480 | 484 | return p.err; |
481 | 485 | } |
... | ... | @@ -683,7 +687,6 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
683 | 687 | |
684 | 688 | /* all done */ |
685 | 689 | #if defined(_WIN32) |
686 | - | |
687 | 690 | if(session->sockEvent == NULL) |
688 | 691 | { |
689 | 692 | char ename[256]; |
... | ... | @@ -712,8 +715,12 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
712 | 715 | _exit(1); |
713 | 716 | } |
714 | 717 | |
718 | + trace("Socket: %d Event: %ld",session->sock,session->sockEvent); | |
719 | + | |
715 | 720 | #endif // WIN32 |
716 | 721 | |
722 | + non_blocking(session,1); | |
723 | + | |
717 | 724 | return 0; |
718 | 725 | } |
719 | 726 | #undef close_fail |
... | ... | @@ -956,9 +963,9 @@ void net_input(H3270 *session) |
956 | 963 | |
957 | 964 | CHECK_SESSION_HANDLE(session); |
958 | 965 | |
959 | -// #if defined(_WIN32) | |
966 | +//#if defined(_WIN32) | |
960 | 967 | // for (;;) |
961 | -// #endif | |
968 | +//#endif | |
962 | 969 | { |
963 | 970 | if (session->sock < 0) |
964 | 971 | return; |
... | ... | @@ -1008,9 +1015,8 @@ void net_input(H3270 *session) |
1008 | 1015 | if (nr < 0) |
1009 | 1016 | { |
1010 | 1017 | if (socket_errno() == SE_EWOULDBLOCK) |
1011 | - { | |
1012 | 1018 | return; |
1013 | - } | |
1019 | + | |
1014 | 1020 | #if defined(HAVE_LIBSSL) /*[*/ |
1015 | 1021 | if(session->ssl_con != NULL) |
1016 | 1022 | { |
... | ... | @@ -1064,7 +1070,6 @@ void net_input(H3270 *session) |
1064 | 1070 | } |
1065 | 1071 | |
1066 | 1072 | /* Process the data. */ |
1067 | - | |
1068 | 1073 | if (HALF_CONNECTED) |
1069 | 1074 | { |
1070 | 1075 | if (non_blocking(session,False) < 0) |
... | ... | @@ -3209,6 +3214,8 @@ static int non_blocking(H3270 *session, Boolean on) |
3209 | 3214 | |
3210 | 3215 | #endif // FIONBIO |
3211 | 3216 | |
3217 | + trace("Socket %d is %s",session->sock, on ? "non-blocking" : "blocking"); | |
3218 | + | |
3212 | 3219 | return 0; |
3213 | 3220 | } |
3214 | 3221 | ... | ... |
util.c
... | ... | @@ -35,18 +35,19 @@ |
35 | 35 | * Utility functions for x3270/c3270/s3270/tcl3270 |
36 | 36 | */ |
37 | 37 | |
38 | +#if defined(_WIN32) | |
39 | + #include <winsock2.h> | |
40 | + #include <windows.h> | |
41 | +#endif // _WIN32 | |
42 | + | |
38 | 43 | #include "globals.h" |
39 | 44 | |
40 | 45 | #if defined(_WIN32) |
41 | 46 | |
42 | - #include <windows.h> | |
43 | 47 | #include "winversc.h" |
44 | - | |
45 | - #include <winsock2.h> | |
46 | 48 | #include <ws2tcpip.h> |
47 | 49 | #include <stdio.h> |
48 | 50 | #include <errno.h> |
49 | - | |
50 | 51 | #include "w3miscc.h" |
51 | 52 | |
52 | 53 | #else | ... | ... |
... | ... | @@ -98,11 +98,11 @@ void x_except_on(H3270 *h) |
98 | 98 | RemoveInput(h->ns_read_id); |
99 | 99 | |
100 | 100 | #ifdef WIN32 |
101 | - h->ns_exception_id = AddExcept(h->sockEvent, h, net_exception); | |
101 | + h->ns_exception_id = AddExcept((int) h->sockEvent, h, net_exception); | |
102 | 102 | h->excepting = True; |
103 | 103 | |
104 | 104 | if(h->reading) |
105 | - h->ns_read_id = AddInput(h->sockEvent, h, net_input); | |
105 | + h->ns_read_id = AddInput( (int) h->sockEvent, h, net_input); | |
106 | 106 | #else |
107 | 107 | h->ns_exception_id = AddExcept(h->sock, h, net_exception); |
108 | 108 | h->excepting = True; | ... | ... |