Commit 0cba41a136921bb004adab04d58a69839c4dc5fa

Authored by perry.werneck@gmail.com
1 parent 3f562161

Movendo globais para a estrutura de sessao

Showing 1 changed file with 41 additions and 41 deletions   Show diff stats
@@ -166,12 +166,15 @@ Boolean local_process = False; @@ -166,12 +166,15 @@ Boolean local_process = False;
166 // static unsigned char telnet_state; 166 // static unsigned char telnet_state;
167 // static char ttype_tmpval[13]; 167 // static char ttype_tmpval[13];
168 168
169 -#if defined(X3270_TN3270E) /*[*/  
170 -static unsigned long e_funcs; /* negotiated TN3270E functions */  
171 -#define E_OPT(n) (1 << (n))  
172 -static unsigned short e_xmit_seq; /* transmit sequence number */  
173 -static int response_required;  
174 -#endif /*]*/ 169 +#if defined(X3270_TN3270E)
  170 + #define E_OPT(n) (1 << (n))
  171 +#endif // X3270_TN3270E
  172 +
  173 +//#if defined(X3270_TN3270E)
  174 +//static unsigned long e_funcs; /* negotiated TN3270E functions */
  175 +//static unsigned short e_xmit_seq; /* transmit sequence number */
  176 +//static int response_required;
  177 +//#endif
175 178
176 #if defined(X3270_ANSI) /*[*/ 179 #if defined(X3270_ANSI) /*[*/
177 static int ansi_data = 0; 180 static int ansi_data = 0;
@@ -866,11 +869,9 @@ static void net_connected(H3270 *session) @@ -866,11 +869,9 @@ static void net_connected(H3270 *session)
866 (void) memset((char *) h3270.hisopts, 0, sizeof(h3270.hisopts)); 869 (void) memset((char *) h3270.hisopts, 0, sizeof(h3270.hisopts));
867 870
868 #if defined(X3270_TN3270E) /*[*/ 871 #if defined(X3270_TN3270E) /*[*/
869 - e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) |  
870 - E_OPT(TN3270E_FUNC_RESPONSES) |  
871 - E_OPT(TN3270E_FUNC_SYSREQ);  
872 - e_xmit_seq = 0;  
873 - response_required = TN3270E_RSF_NO_RESPONSE; 872 + h3270.e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) | E_OPT(TN3270E_FUNC_RESPONSES) | E_OPT(TN3270E_FUNC_SYSREQ);
  873 + h3270.e_xmit_seq = 0;
  874 + h3270.response_required = TN3270E_RSF_NO_RESPONSE;
874 #endif /*]*/ 875 #endif /*]*/
875 876
876 #if defined(HAVE_LIBSSL) /*[*/ 877 #if defined(HAVE_LIBSSL) /*[*/
@@ -1649,7 +1650,7 @@ tn3270e_negotiate(void) @@ -1649,7 +1650,7 @@ tn3270e_negotiate(void)
1649 } 1650 }
1650 1651
1651 /* Tell them what we can do. */ 1652 /* Tell them what we can do. */
1652 - tn3270e_subneg_send(TN3270E_OP_REQUEST, e_funcs); 1653 + tn3270e_subneg_send(TN3270E_OP_REQUEST, h3270.e_funcs);
1653 break; 1654 break;
1654 } 1655 }
1655 case TN3270E_OP_REJECT: 1656 case TN3270E_OP_REJECT:
@@ -1695,10 +1696,10 @@ tn3270e_negotiate(void) @@ -1695,10 +1696,10 @@ tn3270e_negotiate(void)
1695 tn3270e_function_names(h3270.sbbuf+3, sblen-3)); 1696 tn3270e_function_names(h3270.sbbuf+3, sblen-3));
1696 1697
1697 e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3); 1698 e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3);
1698 - if ((e_rcvd == e_funcs) || (e_funcs & ~e_rcvd)) { 1699 + if ((e_rcvd == h3270.e_funcs) || (h3270.e_funcs & ~e_rcvd)) {
1699 /* They want what we want, or less. Done. */ 1700 /* They want what we want, or less. Done. */
1700 - e_funcs = e_rcvd;  
1701 - tn3270e_subneg_send(TN3270E_OP_IS, e_funcs); 1701 + h3270.e_funcs = e_rcvd;
  1702 + tn3270e_subneg_send(TN3270E_OP_IS, h3270.e_funcs);
1702 tn3270e_negotiated = 1; 1703 tn3270e_negotiated = 1;
1703 trace_dsn("TN3270E option negotiation complete.\n"); 1704 trace_dsn("TN3270E option negotiation complete.\n");
1704 check_in3270(&h3270); 1705 check_in3270(&h3270);
@@ -1707,8 +1708,8 @@ tn3270e_negotiate(void) @@ -1707,8 +1708,8 @@ tn3270e_negotiate(void)
1707 * They want us to do something we can't. 1708 * They want us to do something we can't.
1708 * Request the common subset. 1709 * Request the common subset.
1709 */ 1710 */
1710 - e_funcs &= e_rcvd;  
1711 - tn3270e_subneg_send(TN3270E_OP_REQUEST,e_funcs); 1711 + h3270.e_funcs &= e_rcvd;
  1712 + tn3270e_subneg_send(TN3270E_OP_REQUEST,h3270.e_funcs);
1712 } 1713 }
1713 break; 1714 break;
1714 1715
@@ -1718,14 +1719,14 @@ tn3270e_negotiate(void) @@ -1718,14 +1719,14 @@ tn3270e_negotiate(void)
1718 trace_dsn("IS %s SE\n", 1719 trace_dsn("IS %s SE\n",
1719 tn3270e_function_names(h3270.sbbuf+3, sblen-3)); 1720 tn3270e_function_names(h3270.sbbuf+3, sblen-3));
1720 e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3); 1721 e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3);
1721 - if (e_rcvd != e_funcs) {  
1722 - if (e_funcs & ~e_rcvd) { 1722 + if (e_rcvd != h3270.e_funcs) {
  1723 + if (h3270.e_funcs & ~e_rcvd) {
1723 /* 1724 /*
1724 * They've removed something. This is 1725 * They've removed something. This is
1725 * technically illegal, but we can 1726 * technically illegal, but we can
1726 * live with it. 1727 * live with it.
1727 */ 1728 */
1728 - e_funcs = e_rcvd; 1729 + h3270.e_funcs = e_rcvd;
1729 } else { 1730 } else {
1730 /* 1731 /*
1731 * They've added something. Abandon 1732 * They've added something. Abandon
@@ -1781,10 +1782,10 @@ tn3270e_current_opts(void) @@ -1781,10 +1782,10 @@ tn3270e_current_opts(void)
1781 static char text_buf[1024]; 1782 static char text_buf[1024];
1782 char *s = text_buf; 1783 char *s = text_buf;
1783 1784
1784 - if (!e_funcs || !IN_E) 1785 + if (!h3270.e_funcs || !IN_E)
1785 return CN; 1786 return CN;
1786 for (i = 0; i < 32; i++) { 1787 for (i = 0; i < 32; i++) {
1787 - if (e_funcs & E_OPT(i)) 1788 + if (h3270.e_funcs & E_OPT(i))
1788 s += sprintf(s, "%s%s", (s == text_buf) ? "" : " ", 1789 s += sprintf(s, "%s%s", (s == text_buf) ? "" : " ",
1789 fnn(i)); 1790 fnn(i));
1790 } 1791 }
@@ -1884,24 +1885,24 @@ process_eor(void) @@ -1884,24 +1885,24 @@ process_eor(void)
1884 1885
1885 switch (h->data_type) { 1886 switch (h->data_type) {
1886 case TN3270E_DT_3270_DATA: 1887 case TN3270E_DT_3270_DATA:
1887 - if ((e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)) && 1888 + if ((h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)) &&
1888 !tn3270e_bound) 1889 !tn3270e_bound)
1889 return 0; 1890 return 0;
1890 tn3270e_submode = E_3270; 1891 tn3270e_submode = E_3270;
1891 check_in3270(&h3270); 1892 check_in3270(&h3270);
1892 - response_required = h->response_flag; 1893 + h3270.response_required = h->response_flag;
1893 rv = process_ds(h3270.ibuf + EH_SIZE, 1894 rv = process_ds(h3270.ibuf + EH_SIZE,
1894 (h3270.ibptr - h3270.ibuf) - EH_SIZE); 1895 (h3270.ibptr - h3270.ibuf) - EH_SIZE);
1895 if (rv < 0 && 1896 if (rv < 0 &&
1896 - response_required != TN3270E_RSF_NO_RESPONSE) 1897 + h3270.response_required != TN3270E_RSF_NO_RESPONSE)
1897 tn3270e_nak(rv); 1898 tn3270e_nak(rv);
1898 else if (rv == PDS_OKAY_NO_OUTPUT && 1899 else if (rv == PDS_OKAY_NO_OUTPUT &&
1899 - response_required == TN3270E_RSF_ALWAYS_RESPONSE) 1900 + h3270.response_required == TN3270E_RSF_ALWAYS_RESPONSE)
1900 tn3270e_ack(); 1901 tn3270e_ack();
1901 - response_required = TN3270E_RSF_NO_RESPONSE; 1902 + h3270.response_required = TN3270E_RSF_NO_RESPONSE;
1902 return 0; 1903 return 0;
1903 case TN3270E_DT_BIND_IMAGE: 1904 case TN3270E_DT_BIND_IMAGE:
1904 - if (!(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) 1905 + if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1905 return 0; 1906 return 0;
1906 process_bind(h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE); 1907 process_bind(h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE);
1907 trace_dsn("< BIND PLU-name '%s'\n", plu_name); 1908 trace_dsn("< BIND PLU-name '%s'\n", plu_name);
@@ -1909,7 +1910,7 @@ process_eor(void) @@ -1909,7 +1910,7 @@ process_eor(void)
1909 check_in3270(&h3270); 1910 check_in3270(&h3270);
1910 return 0; 1911 return 0;
1911 case TN3270E_DT_UNBIND: 1912 case TN3270E_DT_UNBIND:
1912 - if (!(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) 1913 + if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1913 return 0; 1914 return 0;
1914 tn3270e_bound = 0; 1915 tn3270e_bound = 0;
1915 if (tn3270e_submode == E_3270) 1916 if (tn3270e_submode == E_3270)
@@ -1925,7 +1926,7 @@ process_eor(void) @@ -1925,7 +1926,7 @@ process_eor(void)
1925 } 1926 }
1926 return 0; 1927 return 0;
1927 case TN3270E_DT_SSCP_LU_DATA: 1928 case TN3270E_DT_SSCP_LU_DATA:
1928 - if (!(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) 1929 + if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1929 return 0; 1930 return 0;
1930 tn3270e_submode = E_SSCP; 1931 tn3270e_submode = E_SSCP;
1931 check_in3270(&h3270); 1932 check_in3270(&h3270);
@@ -2685,9 +2686,9 @@ net_output(void) @@ -2685,9 +2686,9 @@ net_output(void)
2685 tn3270e_header *h = (tn3270e_header *) h3270.obuf_base; 2686 tn3270e_header *h = (tn3270e_header *) h3270.obuf_base;
2686 2687
2687 /* Check for sending a TN3270E response. */ 2688 /* Check for sending a TN3270E response. */
2688 - if (response_required == TN3270E_RSF_ALWAYS_RESPONSE) { 2689 + if (h3270.response_required == TN3270E_RSF_ALWAYS_RESPONSE) {
2689 tn3270e_ack(); 2690 tn3270e_ack();
2690 - response_required = TN3270E_RSF_NO_RESPONSE; 2691 + h3270.response_required = TN3270E_RSF_NO_RESPONSE;
2691 } 2692 }
2692 2693
2693 /* Set the outbound TN3270E header. */ 2694 /* Set the outbound TN3270E header. */
@@ -2695,13 +2696,12 @@ net_output(void) @@ -2695,13 +2696,12 @@ net_output(void)
2695 TN3270E_DT_3270_DATA : TN3270E_DT_SSCP_LU_DATA; 2696 TN3270E_DT_3270_DATA : TN3270E_DT_SSCP_LU_DATA;
2696 h->request_flag = 0; 2697 h->request_flag = 0;
2697 h->response_flag = 0; 2698 h->response_flag = 0;
2698 - h->seq_number[0] = (e_xmit_seq >> 8) & 0xff;  
2699 - h->seq_number[1] = e_xmit_seq & 0xff; 2699 + h->seq_number[0] = (h3270.e_xmit_seq >> 8) & 0xff;
  2700 + h->seq_number[1] = h3270.e_xmit_seq & 0xff;
2700 2701
2701 - trace_dsn("SENT TN3270E(%s NO-RESPONSE %u)\n",  
2702 - IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", e_xmit_seq);  
2703 - if (e_funcs & E_OPT(TN3270E_FUNC_RESPONSES))  
2704 - e_xmit_seq = (e_xmit_seq + 1) & 0x7fff; 2702 + trace_dsn("SENT TN3270E(%s NO-RESPONSE %u)\n",IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", h3270.e_xmit_seq);
  2703 + if (h3270.e_funcs & E_OPT(TN3270E_FUNC_RESPONSES))
  2704 + h3270.e_xmit_seq = (h3270.e_xmit_seq + 1) & 0x7fff;
2705 } 2705 }
2706 #endif /*]*/ 2706 #endif /*]*/
2707 2707
@@ -2994,7 +2994,7 @@ net_abort(void) @@ -2994,7 +2994,7 @@ net_abort(void)
2994 { 2994 {
2995 static unsigned char buf[] = { IAC, AO }; 2995 static unsigned char buf[] = { IAC, AO };
2996 2996
2997 - if (e_funcs & E_OPT(TN3270E_FUNC_SYSREQ)) { 2997 + if (h3270.e_funcs & E_OPT(TN3270E_FUNC_SYSREQ)) {
2998 /* 2998 /*
2999 * I'm not sure yet what to do here. Should the host respond 2999 * I'm not sure yet what to do here. Should the host respond
3000 * to the AO by sending us SSCP-LU data (and putting us into 3000 * to the AO by sending us SSCP-LU data (and putting us into
@@ -3009,7 +3009,7 @@ net_abort(void) @@ -3009,7 +3009,7 @@ net_abort(void)
3009 net_rawout(&h3270, buf, sizeof(buf)); 3009 net_rawout(&h3270, buf, sizeof(buf));
3010 trace_dsn("SENT AO\n"); 3010 trace_dsn("SENT AO\n");
3011 if (tn3270e_bound || 3011 if (tn3270e_bound ||
3012 - !(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) { 3012 + !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) {
3013 tn3270e_submode = E_3270; 3013 tn3270e_submode = E_3270;
3014 check_in3270(&h3270); 3014 check_in3270(&h3270);
3015 } 3015 }
@@ -3151,7 +3151,7 @@ net_snap_options(void) @@ -3151,7 +3151,7 @@ net_snap_options(void)
3151 h3270.obptr += 4; 3151 h3270.obptr += 4;
3152 *h3270.obptr++ = TN3270E_OP_IS; 3152 *h3270.obptr++ = TN3270E_OP_IS;
3153 for (i = 0; i < 32; i++) { 3153 for (i = 0; i < 32; i++) {
3154 - if (e_funcs & E_OPT(i)) 3154 + if (h3270.e_funcs & E_OPT(i))
3155 *h3270.obptr++ = i; 3155 *h3270.obptr++ = i;
3156 } 3156 }
3157 *h3270.obptr++ = IAC; 3157 *h3270.obptr++ = IAC;