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