Commit 6fccf19ecf4f78938c8af839fd048c8744eafa3f
1 parent
6739b90c
Exists in
master
and in
3 other branches
Iniciando jni android, ajustes no processo de conexão
Showing
2 changed files
with
49 additions
and
119 deletions
Show diff stats
telnet.c
... | ... | @@ -623,8 +623,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
623 | 623 | } |
624 | 624 | #endif |
625 | 625 | |
626 | - /* set the socket to be non-delaying */ | |
627 | - if (non_blocking(session,False) < 0) | |
626 | + /* set the socket to be non-delaying during connect */ | |
627 | + if(non_blocking(session,False) < 0) | |
628 | 628 | close_fail; |
629 | 629 | |
630 | 630 | #if !defined(_WIN32) |
... | ... | @@ -646,23 +646,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
646 | 646 | if(!rc) |
647 | 647 | { |
648 | 648 | trace_dsn("Connected.\n"); |
649 | - | |
650 | -// if(non_blocking(session,False) < 0) | |
651 | -// close_fail; | |
652 | - | |
653 | 649 | net_connected(session); |
654 | - | |
655 | -/* | |
656 | - break; | |
657 | - case SE_EWOULDBLOCK: // Connection in progress | |
658 | - case SE_EINPROGRESS: | |
659 | - *pending = True; | |
660 | - trace_dsn("Connection pending.\n"); | |
661 | -#if !defined(_WIN32) | |
662 | - output_id = AddOutput(session->sock, session, output_possible); | |
663 | -#endif | |
664 | - break; | |
665 | -*/ | |
666 | 650 | } |
667 | 651 | else |
668 | 652 | { |
... | ... | @@ -813,7 +797,6 @@ static void net_connected(H3270 *session) |
813 | 797 | } |
814 | 798 | else |
815 | 799 | { |
816 | - // non_blocking(session,False); | |
817 | 800 | rc = SSL_connect(session->ssl_con); |
818 | 801 | |
819 | 802 | if(rc != 1) |
... | ... | @@ -837,7 +820,6 @@ static void net_connected(H3270 *session) |
837 | 820 | return; |
838 | 821 | |
839 | 822 | } |
840 | - non_blocking(session,True); | |
841 | 823 | } |
842 | 824 | |
843 | 825 | // session->secure_connection = True; |
... | ... | @@ -911,30 +893,6 @@ static void connection_complete(void) |
911 | 893 | } |
912 | 894 | |
913 | 895 | /* |
914 | -#if !defined(_WIN32) | |
915 | -// | |
916 | -// output_possible | |
917 | -// Output is possible on the socket. Used only when a connection is | |
918 | -// pending, to determine that the connection is complete. | |
919 | -// | |
920 | -static void output_possible(H3270 *session) | |
921 | -{ | |
922 | - trace("%s: %s",__FUNCTION__,HALF_CONNECTED ? "Half connected" : "Connected"); | |
923 | - if (HALF_CONNECTED) | |
924 | - { | |
925 | - connection_complete(); | |
926 | - } | |
927 | - | |
928 | - if (output_id) | |
929 | - { | |
930 | - RemoveInput(output_id); | |
931 | - output_id = 0L; | |
932 | - } | |
933 | -} | |
934 | -#endif | |
935 | -*/ | |
936 | - | |
937 | -/* | |
938 | 896 | * net_disconnect |
939 | 897 | * Shut down the socket. |
940 | 898 | */ |
... | ... | @@ -990,17 +948,17 @@ void net_input(H3270 *session) |
990 | 948 | register unsigned char *cp; |
991 | 949 | int nr; |
992 | 950 | |
993 | - if(!session) | |
994 | - session = &h3270; | |
951 | + CHECK_SESSION_HANDLE(session); | |
995 | 952 | |
996 | -#if defined(_WIN32) /*[*/ | |
997 | - for (;;) | |
998 | -#endif /*]*/ | |
953 | +// #if defined(_WIN32) | |
954 | +// for (;;) | |
955 | +// #endif | |
999 | 956 | { |
1000 | 957 | if (session->sock < 0) |
1001 | 958 | return; |
1002 | 959 | |
1003 | -#if defined(_WIN32) /*[*/ | |
960 | +/* | |
961 | +#if defined(_WIN32) | |
1004 | 962 | if (HALF_CONNECTED) { |
1005 | 963 | |
1006 | 964 | if (connect(session->sock, &haddr.sa, sizeof(haddr)) < 0) { |
... | ... | @@ -1009,7 +967,7 @@ void net_input(H3270 *session) |
1009 | 967 | switch (err) { |
1010 | 968 | case WSAEISCONN: |
1011 | 969 | connection_complete(); |
1012 | - /* and go get data...? */ | |
970 | + // and go get data...? | |
1013 | 971 | break; |
1014 | 972 | case WSAEALREADY: |
1015 | 973 | case WSAEWOULDBLOCK: |
... | ... | @@ -1025,31 +983,26 @@ void net_input(H3270 *session) |
1025 | 983 | } |
1026 | 984 | } |
1027 | 985 | } |
1028 | -#endif /*]*/ | |
986 | +#endif | |
987 | +*/ | |
1029 | 988 | |
1030 | 989 | #if defined(X3270_ANSI) /*[*/ |
1031 | 990 | ansi_data = 0; |
1032 | 991 | #endif /*]*/ |
1033 | 992 | |
1034 | -// #if defined(_WIN32) | |
1035 | -// (void) ResetEvent(session->sock_handle); | |
1036 | -//#endif /*]*/ | |
1037 | - | |
1038 | 993 | #if defined(HAVE_LIBSSL) |
1039 | 994 | if (session->ssl_con != NULL) |
1040 | 995 | nr = SSL_read(session->ssl_con, (char *) netrbuf, BUFSZ); |
1041 | 996 | else |
1042 | -#endif // HAVE_LIBSSL | |
1043 | -/* | |
1044 | -#if defined(LOCAL_PROCESS) | |
1045 | - if (local_process) | |
1046 | - nr = read(sock, (char *) netrbuf, BUFSZ); | |
1047 | - else | |
1048 | -#endif | |
1049 | -*/ | |
1050 | 997 | nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0); |
1051 | - if (nr < 0) { | |
1052 | - if (socket_errno() == SE_EWOULDBLOCK) { | |
998 | +#else | |
999 | + nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0); | |
1000 | +#endif // HAVE_LIBSSL | |
1001 | + | |
1002 | + if (nr < 0) | |
1003 | + { | |
1004 | + if (socket_errno() == SE_EWOULDBLOCK) | |
1005 | + { | |
1053 | 1006 | return; |
1054 | 1007 | } |
1055 | 1008 | #if defined(HAVE_LIBSSL) /*[*/ |
... | ... | @@ -1082,28 +1035,22 @@ void net_input(H3270 *session) |
1082 | 1035 | connection_complete(); |
1083 | 1036 | return; |
1084 | 1037 | } |
1085 | -/* | |
1086 | -#if defined(LOCAL_PROCESS) / | |
1087 | - if (errno == EIO && local_process) { | |
1088 | - trace_dsn("RCVD local process disconnect\n"); | |
1089 | - host_disconnect(session,False); | |
1090 | - return; | |
1091 | - } | |
1092 | -#endif | |
1093 | -*/ | |
1038 | + | |
1094 | 1039 | trace_dsn("RCVD socket error %d\n", errno); |
1040 | + | |
1095 | 1041 | if (HALF_CONNECTED) |
1096 | 1042 | { |
1097 | - popup_a_sockerr(NULL, N_( "%s:%d" ),h3270.hostname, h3270.current_port); | |
1043 | + popup_a_sockerr(session, N_( "%s:%d" ),h3270.hostname, h3270.current_port); | |
1098 | 1044 | } |
1099 | 1045 | else if (socket_errno() != SE_ECONNRESET) |
1100 | 1046 | { |
1101 | - popup_a_sockerr(NULL, N_( "Socket read error" ) ); | |
1047 | + popup_a_sockerr(session, N_( "Socket read error" ) ); | |
1102 | 1048 | } |
1103 | 1049 | |
1104 | 1050 | host_disconnect(session,True); |
1105 | 1051 | return; |
1106 | - } else if (nr == 0) { | |
1052 | + } else if (nr == 0) | |
1053 | + { | |
1107 | 1054 | /* Host disconnected. */ |
1108 | 1055 | trace_dsn("RCVD disconnect\n"); |
1109 | 1056 | host_disconnect(session,False); |
... | ... | @@ -1123,50 +1070,31 @@ void net_input(H3270 *session) |
1123 | 1070 | net_connected(session); |
1124 | 1071 | } |
1125 | 1072 | |
1126 | -#if defined(X3270_TRACE) /*[*/ | |
1127 | 1073 | trace_netdata('<', netrbuf, nr); |
1128 | -#endif /*]*/ | |
1129 | 1074 | |
1130 | 1075 | ns_brcvd += nr; |
1131 | - for (cp = netrbuf; cp < (netrbuf + nr); cp++) { | |
1132 | -/* | |
1133 | -#if defined(LOCAL_PROCESS) | |
1134 | - if (local_process) { | |
1135 | - // More to do here, probably. | |
1136 | - if (IN_NEITHER) { // now can assume ANSI mode | |
1137 | - host_in3270(CONNECTED_ANSI); | |
1138 | - hisopts[TELOPT_ECHO] = 1; | |
1139 | - check_linemode(False); | |
1140 | - kybdlock_clr(KL_AWAITING_FIRST, "telnet_fsm"); | |
1141 | - status_reset(); | |
1142 | - ps_process(); | |
1143 | - } | |
1144 | - ansi_process((unsigned int) *cp); | |
1145 | - } else { | |
1146 | -#endif | |
1147 | -*/ | |
1148 | - if (telnet_fsm(*cp)) | |
1149 | - { | |
1150 | - (void) ctlr_dbcs_postprocess(); | |
1151 | - host_disconnect(&h3270,True); | |
1152 | - return; | |
1153 | - } | |
1154 | -/* | |
1155 | -#if defined(LOCAL_PROCESS) | |
1076 | + for (cp = netrbuf; cp < (netrbuf + nr); cp++) | |
1077 | + { | |
1078 | + if (telnet_fsm(*cp)) | |
1079 | + { | |
1080 | + (void) ctlr_dbcs_postprocess(); | |
1081 | + host_disconnect(session,True); | |
1082 | + return; | |
1156 | 1083 | } |
1157 | -#endif | |
1158 | -*/ | |
1159 | 1084 | } |
1160 | 1085 | |
1161 | -#if defined(X3270_ANSI) /*[*/ | |
1162 | - if (IN_ANSI) { | |
1086 | +#if defined(X3270_ANSI) | |
1087 | + if (IN_ANSI) | |
1088 | + { | |
1163 | 1089 | (void) ctlr_dbcs_postprocess(); |
1164 | 1090 | } |
1165 | - if (ansi_data) { | |
1091 | + | |
1092 | + if (ansi_data) | |
1093 | + { | |
1166 | 1094 | trace_dsn("\n"); |
1167 | 1095 | ansi_data = 0; |
1168 | 1096 | } |
1169 | -#endif /*]*/ | |
1097 | +#endif // X3270_ANSI | |
1170 | 1098 | |
1171 | 1099 | } |
1172 | 1100 | |
... | ... | @@ -2043,9 +1971,7 @@ net_rawout(unsigned const char *buf, int len) |
2043 | 1971 | { |
2044 | 1972 | int nw; |
2045 | 1973 | |
2046 | -#if defined(X3270_TRACE) /*[*/ | |
2047 | 1974 | trace_netdata('>', buf, len); |
2048 | -#endif /*]*/ | |
2049 | 1975 | |
2050 | 1976 | while (len) { |
2051 | 1977 | #if defined(OMTU) /*[*/ |
... | ... | @@ -2633,7 +2559,7 @@ check_linemode(Boolean init) |
2633 | 2559 | } |
2634 | 2560 | |
2635 | 2561 | |
2636 | -#if defined(X3270_TRACE) /*[*/ | |
2562 | +#if defined(X3270_TRACE) | |
2637 | 2563 | |
2638 | 2564 | /* |
2639 | 2565 | * nnn |
... | ... | @@ -2681,11 +2607,9 @@ opt(unsigned char c) |
2681 | 2607 | return nnn((int)c); |
2682 | 2608 | } |
2683 | 2609 | |
2684 | - | |
2685 | 2610 | #define LINEDUMP_MAX 32 |
2686 | 2611 | |
2687 | -void | |
2688 | -trace_netdata(char direction, unsigned const char *buf, int len) | |
2612 | +void trace_netdata(char direction, unsigned const char *buf, int len) | |
2689 | 2613 | { |
2690 | 2614 | int offset; |
2691 | 2615 | struct timeval ts; |
... | ... | @@ -2708,7 +2632,7 @@ trace_netdata(char direction, unsigned const char *buf, int len) |
2708 | 2632 | } |
2709 | 2633 | trace_dsn("\n"); |
2710 | 2634 | } |
2711 | -#endif /*]*/ | |
2635 | +#endif // X3270_TRACE | |
2712 | 2636 | |
2713 | 2637 | |
2714 | 2638 | /* | ... | ... |
telnetc.h
... | ... | @@ -55,9 +55,15 @@ LIB3270_INTERNAL void net_send_werase(void); |
55 | 55 | LIB3270_INTERNAL Boolean net_snap_options(void); |
56 | 56 | LIB3270_INTERNAL void space3270out(int n); |
57 | 57 | LIB3270_INTERNAL const char *tn3270e_current_opts(void); |
58 | -LIB3270_INTERNAL void trace_netdata(char direction, unsigned const char *buf, int len); | |
59 | 58 | LIB3270_INTERNAL char *net_proxy_type(void); |
60 | 59 | LIB3270_INTERNAL char *net_proxy_host(void); |
61 | 60 | LIB3270_INTERNAL char *net_proxy_port(void); |
62 | 61 | |
62 | +#if defined(X3270_TRACE) | |
63 | + LIB3270_INTERNAL void trace_netdata(char direction, unsigned const char *buf, int len); | |
64 | +#else | |
65 | + #define trace_netdata(direction, buf, len) /* */ | |
66 | +#endif // X3270_TRACE | |
67 | + | |
68 | + | |
63 | 69 | LIB3270_INTERNAL int net_getsockname(const H3270 *h3270, void *buf, int *len); | ... | ... |