Commit 4ce1a163bbb0c2187bdaa39916c89bf73dca3843

Authored by perry.werneck@gmail.com
1 parent fa57e324

Movendo mais campos para a estrutura de controle de sessao

src/include/lib3270/session.h
... ... @@ -185,6 +185,26 @@
185 185 int ibuf_size; /**< size of ibuf */
186 186 unsigned char * obuf; /**< 3270 output buffer */
187 187 unsigned char * obptr;
  188 + time_t ns_time;
  189 + int ns_brcvd;
  190 + int ns_rrcvd;
  191 + int ns_bsent;
  192 + int ns_rsent;
  193 + struct timeval ds_ts;
  194 +
  195 + // 3270 input buffer
  196 + unsigned char * ibptr;
  197 + unsigned char * obuf_base;
  198 + int obuf_size;
  199 + unsigned char * netrbuf;
  200 +
  201 + // network input buffer
  202 + unsigned char * sbbuf;
  203 +
  204 + // telnet sub-option buffer
  205 + unsigned char * sbptr;
  206 + unsigned char telnet_state;
  207 + char ttype_tmpval[13];
188 208  
189 209 unsigned char myopts[LIB3270_TELNET_N_OPTS];
190 210 unsigned char hisopts[LIB3270_TELNET_N_OPTS];
... ...
src/lib3270/telnet.c
... ... @@ -18,7 +18,7 @@
18 18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 19 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 20 *
21   - * Este programa está nomeado como telnet.c e possui 3477 linhas de código.
  21 + * Este programa está nomeado como telnet.c e possui - linhas de código.
22 22 *
23 23 * Contatos:
24 24 *
... ... @@ -116,11 +116,11 @@
116 116  
117 117 /* Globals */
118 118 // char *hostname = CN;
119   -time_t ns_time;
120   -int ns_brcvd;
121   -int ns_rrcvd;
122   -int ns_bsent;
123   -int ns_rsent;
  119 +// time_t ns_time;
  120 +//int ns_brcvd;
  121 +//int ns_rrcvd;
  122 +//int ns_bsent;
  123 +//int ns_rsent;
124 124 // unsigned char *obuf; /* 3270 output buffer */
125 125 // unsigned char *obptr = (unsigned char *) NULL;
126 126 //int linemode = 1;
... ... @@ -133,7 +133,7 @@ Boolean local_process = False;
133 133 */
134 134  
135 135 /* Externals */
136   -extern struct timeval ds_ts;
  136 +// extern struct timeval ds_ts;
137 137  
138 138 /* Statics */
139 139 // static int sock = -1; /* active socket */
... ... @@ -153,18 +153,18 @@ extern struct timeval ds_ts;
153 153 // static int ibuf_size = 0; /* size of ibuf */
154 154  
155 155 /* 3270 input buffer */
156   -static unsigned char *ibptr;
157   -static unsigned char *obuf_base = (unsigned char *)NULL;
158   -static int obuf_size = 0;
159   -static unsigned char *netrbuf = (unsigned char *)NULL;
  156 +// static unsigned char *ibptr;
  157 +// static unsigned char *obuf_base = (unsigned char *)NULL;
  158 +// static int obuf_size = 0;
  159 +// static unsigned char *netrbuf = (unsigned char *)NULL;
160 160  
161 161 /* network input buffer */
162   -static unsigned char *sbbuf = (unsigned char *)NULL;
  162 +// static unsigned char *sbbuf = (unsigned char *)NULL;
163 163  
164 164 /* telnet sub-option buffer */
165   -static unsigned char *sbptr;
166   -static unsigned char telnet_state;
167   -static char ttype_tmpval[13];
  165 +// static unsigned char *sbptr;
  166 +// static unsigned char telnet_state;
  167 +// static char ttype_tmpval[13];
168 168  
169 169 #if defined(X3270_TN3270E) /*[*/
170 170 static unsigned long e_funcs; /* negotiated TN3270E functions */
... ... @@ -511,8 +511,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
511 511 sockstart(session);
512 512 #endif
513 513  
514   - if (netrbuf == (unsigned char *)NULL)
515   - netrbuf = (unsigned char *)lib3270_malloc(BUFSZ);
  514 + if (session->netrbuf == (unsigned char *)NULL)
  515 + session->netrbuf = (unsigned char *)lib3270_malloc(BUFSZ);
516 516  
517 517 #if defined(X3270_ANSI) /*[*/
518 518 if (!t_valid)
... ... @@ -704,8 +704,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
704 704 /* set up temporary termtype */
705 705 if (session->termname == CN && session->std_ds_host)
706 706 {
707   - sprintf(ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num);
708   - session->termtype = ttype_tmpval;
  707 + sprintf(session->ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num);
  708 + session->termtype = session->ttype_tmpval;
709 709 }
710 710  
711 711 /* all done */
... ... @@ -876,16 +876,16 @@ static void net_connected(H3270 *session)
876 876 #if defined(HAVE_LIBSSL) /*[*/
877 877 need_tls_follows = False;
878 878 #endif /*]*/
879   - telnet_state = TNS_DATA;
880   - ibptr = h3270.ibuf;
  879 + h3270.telnet_state = TNS_DATA;
  880 + h3270.ibptr = h3270.ibuf;
881 881  
882 882 /* clear statistics and flags */
883   - (void) time(&ns_time);
884   - ns_brcvd = 0;
885   - ns_rrcvd = 0;
886   - ns_bsent = 0;
887   - ns_rsent = 0;
888   - session->syncing = 0;
  883 + time(&session->ns_time);
  884 + session->ns_brcvd = 0;
  885 + session->ns_rrcvd = 0;
  886 + session->ns_bsent = 0;
  887 + session->ns_rsent = 0;
  888 + session->syncing = 0;
889 889 tn3270e_negotiated = 0;
890 890 tn3270e_submode = E_NONE;
891 891 tn3270e_bound = 0;
... ... @@ -1015,11 +1015,11 @@ void net_input(H3270 *session)
1015 1015  
1016 1016 #if defined(HAVE_LIBSSL)
1017 1017 if (session->ssl_con != NULL)
1018   - nr = SSL_read(session->ssl_con, (char *) netrbuf, BUFSZ);
  1018 + nr = SSL_read(session->ssl_con, (char *) session->netrbuf, BUFSZ);
1019 1019 else
1020   - nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0);
  1020 + nr = recv(session->sock, (char *) session->netrbuf, BUFSZ, 0);
1021 1021 #else
1022   - nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0);
  1022 + nr = recv(session->sock, (char *) session->netrbuf, BUFSZ, 0);
1023 1023 #endif // HAVE_LIBSSL
1024 1024  
1025 1025 if (nr < 0)
... ... @@ -1087,10 +1087,10 @@ void net_input(H3270 *session)
1087 1087 net_connected(session);
1088 1088 }
1089 1089  
1090   - trace_netdata('<', netrbuf, nr);
  1090 + trace_netdata('<', session->netrbuf, nr);
1091 1091  
1092   - ns_brcvd += nr;
1093   - for (cp = netrbuf; cp < (netrbuf + nr); cp++)
  1092 + session->ns_brcvd += nr;
  1093 + for (cp = session->netrbuf; cp < (session->netrbuf + nr); cp++)
1094 1094 {
1095 1095 if (telnet_fsm(session,*cp))
1096 1096 {
... ... @@ -1181,10 +1181,10 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1181 1181 int sl;
1182 1182 #endif /*]*/
1183 1183  
1184   - switch (telnet_state) {
  1184 + switch (session->telnet_state) {
1185 1185 case TNS_DATA: /* normal data processing */
1186 1186 if (c == IAC) { /* got a telnet command */
1187   - telnet_state = TNS_IAC;
  1187 + session->telnet_state = TNS_IAC;
1188 1188 #if defined(X3270_ANSI) /*[*/
1189 1189 if (ansi_data) {
1190 1190 trace_dsn("\n");
... ... @@ -1252,36 +1252,36 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1252 1252 #endif /*]*/
1253 1253 } else
1254 1254 store3270in(c);
1255   - telnet_state = TNS_DATA;
  1255 + h3270.telnet_state = TNS_DATA;
1256 1256 break;
1257 1257 case EOR: /* eor, process accumulated input */
1258 1258 if (IN_3270 || (IN_E && tn3270e_negotiated)) {
1259   - ns_rrcvd++;
  1259 + h3270.ns_rrcvd++;
1260 1260 if (process_eor())
1261 1261 return -1;
1262 1262 } else
1263 1263 Warning(NULL, _( "EOR received when not in 3270 mode, ignored." ));
1264 1264 trace_dsn("RCVD EOR\n");
1265   - ibptr = h3270.ibuf;
1266   - telnet_state = TNS_DATA;
  1265 + h3270.ibptr = h3270.ibuf;
  1266 + h3270.telnet_state = TNS_DATA;
1267 1267 break;
1268 1268 case WILL:
1269   - telnet_state = TNS_WILL;
  1269 + h3270.telnet_state = TNS_WILL;
1270 1270 break;
1271 1271 case WONT:
1272   - telnet_state = TNS_WONT;
  1272 + h3270.telnet_state = TNS_WONT;
1273 1273 break;
1274 1274 case DO:
1275   - telnet_state = TNS_DO;
  1275 + h3270.telnet_state = TNS_DO;
1276 1276 break;
1277 1277 case DONT:
1278   - telnet_state = TNS_DONT;
  1278 + h3270.telnet_state = TNS_DONT;
1279 1279 break;
1280 1280 case SB:
1281   - telnet_state = TNS_SB;
1282   - if (sbbuf == (unsigned char *)NULL)
1283   - sbbuf = (unsigned char *)lib3270_malloc(1024);
1284   - sbptr = sbbuf;
  1281 + h3270.telnet_state = TNS_SB;
  1282 + if (session->sbbuf == (unsigned char *)NULL)
  1283 + session->sbbuf = (unsigned char *)lib3270_malloc(1024);
  1284 + session->sbptr = session->sbbuf;
1285 1285 break;
1286 1286 case DM:
1287 1287 trace_dsn("\n");
... ... @@ -1290,16 +1290,16 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1290 1290 session->syncing = 0;
1291 1291 x_except_on(session);
1292 1292 }
1293   - telnet_state = TNS_DATA;
  1293 + h3270.telnet_state = TNS_DATA;
1294 1294 break;
1295 1295 case GA:
1296 1296 case NOP:
1297 1297 trace_dsn("\n");
1298   - telnet_state = TNS_DATA;
  1298 + h3270.telnet_state = TNS_DATA;
1299 1299 break;
1300 1300 default:
1301 1301 trace_dsn("???\n");
1302   - telnet_state = TNS_DATA;
  1302 + h3270.telnet_state = TNS_DATA;
1303 1303 break;
1304 1304 }
1305 1305 break;
... ... @@ -1346,7 +1346,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1346 1346 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
1347 1347 break;
1348 1348 }
1349   - telnet_state = TNS_DATA;
  1349 + h3270.telnet_state = TNS_DATA;
1350 1350 break;
1351 1351 case TNS_WONT: /* telnet WONT DO OPTION command */
1352 1352 trace_dsn("%s\n", opt(c));
... ... @@ -1358,7 +1358,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1358 1358 check_in3270(&h3270);
1359 1359 check_linemode(False);
1360 1360 }
1361   - telnet_state = TNS_DATA;
  1361 + h3270.telnet_state = TNS_DATA;
1362 1362 break;
1363 1363 case TNS_DO: /* telnet PLEASE DO OPTION command */
1364 1364 trace_dsn("%s\n", opt(c));
... ... @@ -1419,7 +1419,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1419 1419 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
1420 1420 break;
1421 1421 }
1422   - telnet_state = TNS_DATA;
  1422 + h3270.telnet_state = TNS_DATA;
1423 1423 break;
1424 1424 case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */
1425 1425 trace_dsn("%s\n", opt(c));
... ... @@ -1431,25 +1431,25 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1431 1431 check_in3270(&h3270);
1432 1432 check_linemode(False);
1433 1433 }
1434   - telnet_state = TNS_DATA;
  1434 + h3270.telnet_state = TNS_DATA;
1435 1435 break;
1436 1436 case TNS_SB: /* telnet sub-option string command */
1437 1437 if (c == IAC)
1438   - telnet_state = TNS_SB_IAC;
  1438 + h3270.telnet_state = TNS_SB_IAC;
1439 1439 else
1440   - *sbptr++ = c;
  1440 + *h3270.sbptr++ = c;
1441 1441 break;
1442 1442 case TNS_SB_IAC: /* telnet sub-option string command */
1443   - *sbptr++ = c;
  1443 + *h3270.sbptr++ = c;
1444 1444 if (c == SE) {
1445   - telnet_state = TNS_DATA;
1446   - if (sbbuf[0] == TELOPT_TTYPE &&
1447   - sbbuf[1] == TELQUAL_SEND) {
  1445 + h3270.telnet_state = TNS_DATA;
  1446 + if (session->sbbuf[0] == TELOPT_TTYPE &&
  1447 + session->sbbuf[1] == TELQUAL_SEND) {
1448 1448 int tt_len, tb_len;
1449 1449 char *tt_out;
1450 1450  
1451   - trace_dsn("%s %s\n", opt(sbbuf[0]),
1452   - telquals[sbbuf[1]]);
  1451 + trace_dsn("%s %s\n", opt(session->sbbuf[0]),
  1452 + telquals[session->sbbuf[1]]);
1453 1453 if (lus != (char **)NULL && try_lu == CN) {
1454 1454 /* None of the LUs worked. */
1455 1455 popup_an_error(NULL,"Cannot connect to specified LU");
... ... @@ -1486,7 +1486,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1486 1486 }
1487 1487 #if defined(X3270_TN3270E) /*[*/
1488 1488 else if (h3270.myopts[TELOPT_TN3270E] &&
1489   - sbbuf[0] == TELOPT_TN3270E) {
  1489 + h3270.sbbuf[0] == TELOPT_TN3270E) {
1490 1490 if (tn3270e_negotiate())
1491 1491 return -1;
1492 1492 }
... ... @@ -1494,13 +1494,13 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1494 1494 #if defined(HAVE_LIBSSL) /*[*/
1495 1495 else if (need_tls_follows &&
1496 1496 h3270.myopts[TELOPT_STARTTLS] &&
1497   - sbbuf[0] == TELOPT_STARTTLS) {
1498   - continue_tls(sbbuf, sbptr - sbbuf);
  1497 + h3270.sbbuf[0] == TELOPT_STARTTLS) {
  1498 + continue_tls(h3270.sbbuf, h3270.sbptr - h3270.sbbuf);
1499 1499 }
1500 1500 #endif /*]*/
1501 1501  
1502 1502 } else {
1503   - telnet_state = TNS_SB;
  1503 + h3270.telnet_state = TNS_SB;
1504 1504 }
1505 1505 break;
1506 1506 }
... ... @@ -1583,24 +1583,24 @@ tn3270e_negotiate(void)
1583 1583  
1584 1584 /* Find out how long the subnegotiation buffer is. */
1585 1585 for (sblen = 0; ; sblen++) {
1586   - if (sbbuf[sblen] == SE)
  1586 + if (h3270.sbbuf[sblen] == SE)
1587 1587 break;
1588 1588 }
1589 1589  
1590 1590 trace_dsn("TN3270E ");
1591 1591  
1592   - switch (sbbuf[1]) {
  1592 + switch (h3270.sbbuf[1]) {
1593 1593  
1594 1594 case TN3270E_OP_SEND:
1595 1595  
1596   - if (sbbuf[2] == TN3270E_OP_DEVICE_TYPE) {
  1596 + if (h3270.sbbuf[2] == TN3270E_OP_DEVICE_TYPE) {
1597 1597  
1598 1598 /* Host wants us to send our device type. */
1599 1599 trace_dsn("SEND DEVICE-TYPE SE\n");
1600 1600  
1601 1601 tn3270e_request();
1602 1602 } else {
1603   - trace_dsn("SEND ??%u SE\n", sbbuf[2]);
  1603 + trace_dsn("SEND ??%u SE\n", h3270.sbbuf[2]);
1604 1604 }
1605 1605 break;
1606 1606  
... ... @@ -1609,7 +1609,7 @@ tn3270e_negotiate(void)
1609 1609 /* Device type negotiation. */
1610 1610 trace_dsn("DEVICE-TYPE ");
1611 1611  
1612   - switch (sbbuf[2]) {
  1612 + switch (h3270.sbbuf[2]) {
1613 1613 case TN3270E_OP_IS: {
1614 1614 int tnlen, snlen;
1615 1615  
... ... @@ -1617,24 +1617,24 @@ tn3270e_negotiate(void)
1617 1617  
1618 1618 /* Isolate the terminal type and session. */
1619 1619 tnlen = 0;
1620   - while (sbbuf[3+tnlen] != SE &&
1621   - sbbuf[3+tnlen] != TN3270E_OP_CONNECT)
  1620 + while (h3270.sbbuf[3+tnlen] != SE &&
  1621 + h3270.sbbuf[3+tnlen] != TN3270E_OP_CONNECT)
1622 1622 tnlen++;
1623 1623 snlen = 0;
1624   - if (sbbuf[3+tnlen] == TN3270E_OP_CONNECT) {
1625   - while(sbbuf[3+tnlen+1+snlen] != SE)
  1624 + if (h3270.sbbuf[3+tnlen] == TN3270E_OP_CONNECT) {
  1625 + while(h3270.sbbuf[3+tnlen+1+snlen] != SE)
1626 1626 snlen++;
1627 1627 }
1628 1628 trace_dsn("IS %.*s CONNECT %.*s SE\n",
1629   - tnlen, &sbbuf[3],
1630   - snlen, &sbbuf[3+tnlen+1]);
  1629 + tnlen, &h3270.sbbuf[3],
  1630 + snlen, &h3270.sbbuf[3+tnlen+1]);
1631 1631  
1632 1632 /* Remember the LU. */
1633 1633 if (tnlen) {
1634 1634 if (tnlen > LU_MAX)
1635 1635 tnlen = LU_MAX;
1636 1636 (void)strncpy(reported_type,
1637   - (char *)&sbbuf[3], tnlen);
  1637 + (char *)&h3270.sbbuf[3], tnlen);
1638 1638 reported_type[tnlen] = '\0';
1639 1639 h3270.connected_type = reported_type;
1640 1640 }
... ... @@ -1642,7 +1642,7 @@ tn3270e_negotiate(void)
1642 1642 if (snlen > LU_MAX)
1643 1643 snlen = LU_MAX;
1644 1644 (void)strncpy(reported_lu,
1645   - (char *)&sbbuf[3+tnlen+1], snlen);
  1645 + (char *)&h3270.sbbuf[3+tnlen+1], snlen);
1646 1646 reported_lu[snlen] = '\0';
1647 1647 h3270.connected_lu = reported_lu;
1648 1648 status_lu(&h3270,h3270.connected_lu);
... ... @@ -1656,11 +1656,10 @@ tn3270e_negotiate(void)
1656 1656  
1657 1657 /* Device type failure. */
1658 1658  
1659   - trace_dsn("REJECT REASON %s SE\n", rsn(sbbuf[4]));
1660   - if (sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE ||
1661   - sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) {
1662   - backoff_tn3270e("Host rejected device type or "
1663   - "request type");
  1659 + trace_dsn("REJECT REASON %s SE\n", rsn(h3270.sbbuf[4]));
  1660 + if (h3270.sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE ||
  1661 + h3270.sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) {
  1662 + backoff_tn3270e(_( "Host rejected device type or request type" ));
1664 1663 break;
1665 1664 }
1666 1665  
... ... @@ -1670,14 +1669,14 @@ tn3270e_negotiate(void)
1670 1669 tn3270e_request();
1671 1670 } else if (lus != (char **)NULL) {
1672 1671 /* No more LUs to try. Give up. */
1673   - backoff_tn3270e("Host rejected resource(s)");
  1672 + backoff_tn3270e(_("Host rejected resource(s)"));
1674 1673 } else {
1675   - backoff_tn3270e("Device type rejected");
  1674 + backoff_tn3270e(_("Device type rejected"));
1676 1675 }
1677 1676  
1678 1677 break;
1679 1678 default:
1680   - trace_dsn("??%u SE\n", sbbuf[2]);
  1679 + trace_dsn("??%u SE\n", h3270.sbbuf[2]);
1681 1680 break;
1682 1681 }
1683 1682 break;
... ... @@ -1687,15 +1686,15 @@ tn3270e_negotiate(void)
1687 1686 /* Functions negotiation. */
1688 1687 trace_dsn("FUNCTIONS ");
1689 1688  
1690   - switch (sbbuf[2]) {
  1689 + switch (h3270.sbbuf[2]) {
1691 1690  
1692 1691 case TN3270E_OP_REQUEST:
1693 1692  
1694 1693 /* Host is telling us what functions they want. */
1695 1694 trace_dsn("REQUEST %s SE\n",
1696   - tn3270e_function_names(sbbuf+3, sblen-3));
  1695 + tn3270e_function_names(h3270.sbbuf+3, sblen-3));
1697 1696  
1698   - e_rcvd = tn3270e_fdecode(sbbuf+3, sblen-3);
  1697 + e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3);
1699 1698 if ((e_rcvd == e_funcs) || (e_funcs & ~e_rcvd)) {
1700 1699 /* They want what we want, or less. Done. */
1701 1700 e_funcs = e_rcvd;
... ... @@ -1717,8 +1716,8 @@ tn3270e_negotiate(void)
1717 1716  
1718 1717 /* They accept our last request, or a subset thereof. */
1719 1718 trace_dsn("IS %s SE\n",
1720   - tn3270e_function_names(sbbuf+3, sblen-3));
1721   - e_rcvd = tn3270e_fdecode(sbbuf+3, sblen-3);
  1719 + tn3270e_function_names(h3270.sbbuf+3, sblen-3));
  1720 + e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3);
1722 1721 if (e_rcvd != e_funcs) {
1723 1722 if (e_funcs & ~e_rcvd) {
1724 1723 /*
... ... @@ -1732,8 +1731,7 @@ tn3270e_negotiate(void)
1732 1731 * They've added something. Abandon
1733 1732 * TN3270E, they're brain dead.
1734 1733 */
1735   - backoff_tn3270e("Host illegally added "
1736   - "function(s)");
  1734 + backoff_tn3270e("Host illegally added function(s)");
1737 1735 break;
1738 1736 }
1739 1737 }
... ... @@ -1743,13 +1741,13 @@ tn3270e_negotiate(void)
1743 1741 break;
1744 1742  
1745 1743 default:
1746   - trace_dsn("??%u SE\n", sbbuf[2]);
  1744 + trace_dsn("??%u SE\n", h3270.sbbuf[2]);
1747 1745 break;
1748 1746 }
1749 1747 break;
1750 1748  
1751 1749 default:
1752   - trace_dsn("??%u SE\n", sbbuf[1]);
  1750 + trace_dsn("??%u SE\n", h3270.sbbuf[1]);
1753 1751 }
1754 1752  
1755 1753 /* Good enough for now. */
... ... @@ -1869,7 +1867,7 @@ process_bind(unsigned char *buf, int buflen)
1869 1867 static int
1870 1868 process_eor(void)
1871 1869 {
1872   - if (h3270.syncing || !(ibptr - h3270.ibuf))
  1870 + if (h3270.syncing || !(h3270.ibptr - h3270.ibuf))
1873 1871 return(0);
1874 1872  
1875 1873 #if defined(X3270_TN3270E) /*[*/
... ... @@ -1893,7 +1891,7 @@ process_eor(void)
1893 1891 check_in3270(&h3270);
1894 1892 response_required = h->response_flag;
1895 1893 rv = process_ds(h3270.ibuf + EH_SIZE,
1896   - (ibptr - h3270.ibuf) - EH_SIZE);
  1894 + (h3270.ibptr - h3270.ibuf) - EH_SIZE);
1897 1895 if (rv < 0 &&
1898 1896 response_required != TN3270E_RSF_NO_RESPONSE)
1899 1897 tn3270e_nak(rv);
... ... @@ -1905,7 +1903,7 @@ process_eor(void)
1905 1903 case TN3270E_DT_BIND_IMAGE:
1906 1904 if (!(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1907 1905 return 0;
1908   - process_bind(h3270.ibuf + EH_SIZE, (ibptr - h3270.ibuf) - EH_SIZE);
  1906 + process_bind(h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE);
1909 1907 trace_dsn("< BIND PLU-name '%s'\n", plu_name);
1910 1908 tn3270e_bound = 1;
1911 1909 check_in3270(&h3270);
... ... @@ -1922,7 +1920,7 @@ process_eor(void)
1922 1920 /* In tn3270e NVT mode */
1923 1921 tn3270e_submode = E_NVT;
1924 1922 check_in3270(&h3270);
1925   - for (s = h3270.ibuf; s < ibptr; s++) {
  1923 + for (s = h3270.ibuf; s < h3270.ibptr; s++) {
1926 1924 ansi_process(*s++);
1927 1925 }
1928 1926 return 0;
... ... @@ -1931,7 +1929,7 @@ process_eor(void)
1931 1929 return 0;
1932 1930 tn3270e_submode = E_SSCP;
1933 1931 check_in3270(&h3270);
1934   - ctlr_write_sscp_lu(&h3270, h3270.ibuf + EH_SIZE,(ibptr - h3270.ibuf) - EH_SIZE);
  1932 + ctlr_write_sscp_lu(&h3270, h3270.ibuf + EH_SIZE,(h3270.ibptr - h3270.ibuf) - EH_SIZE);
1935 1933 return 0;
1936 1934 default:
1937 1935 /* Should do something more extraordinary here. */
... ... @@ -1940,7 +1938,7 @@ process_eor(void)
1940 1938 } else
1941 1939 #endif /*]*/
1942 1940 {
1943   - (void) process_ds(h3270.ibuf, ibptr - h3270.ibuf);
  1941 + (void) process_ds(h3270.ibuf, h3270.ibptr - h3270.ibuf);
1944 1942 }
1945 1943 return 0;
1946 1944 }
... ... @@ -2050,7 +2048,7 @@ net_rawout(H3270 *session, unsigned const char *buf, int len)
2050 2048 return;
2051 2049 }
2052 2050 }
2053   - ns_bsent += nw;
  2051 + h3270.ns_bsent += nw;
2054 2052 len -= nw;
2055 2053 buf += nw;
2056 2054 bot:
... ... @@ -2476,7 +2474,7 @@ check_in3270(H3270 *session)
2476 2474 {
2477 2475 h3270.ibuf = (unsigned char *) lib3270_malloc(BUFSIZ);
2478 2476 h3270.ibuf_size = BUFSIZ;
2479   - ibptr = h3270.ibuf;
  2477 + h3270.ibptr = h3270.ibuf;
2480 2478 }
2481 2479  
2482 2480 #if defined(X3270_ANSI) /*[*/
... ... @@ -2507,13 +2505,13 @@ check_in3270(H3270 *session)
2507 2505 static void
2508 2506 store3270in(unsigned char c)
2509 2507 {
2510   - if (ibptr - h3270.ibuf >= h3270.ibuf_size)
  2508 + if (h3270.ibptr - h3270.ibuf >= h3270.ibuf_size)
2511 2509 {
2512 2510 h3270.ibuf_size += BUFSIZ;
2513 2511 h3270.ibuf = (unsigned char *) lib3270_realloc((char *) h3270.ibuf, h3270.ibuf_size);
2514   - ibptr = h3270.ibuf + h3270.ibuf_size - BUFSIZ;
  2512 + h3270.ibptr = h3270.ibuf + h3270.ibuf_size - BUFSIZ;
2515 2513 }
2516   - *ibptr++ = c;
  2514 + *h3270.ibptr++ = c;
2517 2515 }
2518 2516  
2519 2517 /*
... ... @@ -2527,18 +2525,17 @@ void space3270out(int n)
2527 2525 unsigned nc = 0; /* amount of data currently in obuf */
2528 2526 unsigned more = 0;
2529 2527  
2530   - if (obuf_size)
  2528 + if (h3270.obuf_size)
2531 2529 nc = h3270.obptr - h3270.obuf;
2532 2530  
2533   - while ((nc + n + EH_SIZE) > (obuf_size + more)) {
  2531 + while ((nc + n + EH_SIZE) > (h3270.obuf_size + more)) {
2534 2532 more += BUFSIZ;
2535 2533 }
2536 2534  
2537 2535 if (more) {
2538   - obuf_size += more;
2539   - obuf_base = (unsigned char *)Realloc((char *)obuf_base,
2540   - obuf_size);
2541   - h3270.obuf = obuf_base + EH_SIZE;
  2536 + h3270.obuf_size += more;
  2537 + h3270.obuf_base = (unsigned char *)Realloc((char *) h3270.obuf_base,h3270.obuf_size);
  2538 + h3270.obuf = h3270.obuf_base + EH_SIZE;
2542 2539 h3270.obptr = h3270.obuf + nc;
2543 2540 }
2544 2541 }
... ... @@ -2645,11 +2642,11 @@ void trace_netdata(char direction, unsigned const char *buf, int len)
2645 2642 return;
2646 2643 (void) gettimeofday(&ts, (struct timezone *)NULL);
2647 2644 if (IN_3270) {
2648   - tdiff = ((1.0e6 * (double)(ts.tv_sec - ds_ts.tv_sec)) +
2649   - (double)(ts.tv_usec - ds_ts.tv_usec)) / 1.0e6;
  2645 + tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) +
  2646 + (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6;
2650 2647 trace_dsn("%c +%gs\n", direction, tdiff);
2651 2648 }
2652   - ds_ts = ts;
  2649 + h3270.ds_ts = ts;
2653 2650 for (offset = 0; offset < len; offset++) {
2654 2651 if (!(offset % LINEDUMP_MAX))
2655 2652 trace_dsn("%s%c 0x%-3x ",
... ... @@ -2677,7 +2674,7 @@ net_output(void)
2677 2674 unsigned char *nxoptr, *xoptr;
2678 2675  
2679 2676 #if defined(X3270_TN3270E) /*[*/
2680   -#define BSTART ((IN_TN3270E || IN_SSCP) ? obuf_base : h3270.obuf)
  2677 +#define BSTART ((IN_TN3270E || IN_SSCP) ? h3270.obuf_base : h3270.obuf)
2681 2678 #else /*][*/
2682 2679 #define BSTART obuf
2683 2680 #endif /*]*/
... ... @@ -2685,7 +2682,7 @@ net_output(void)
2685 2682 #if defined(X3270_TN3270E) /*[*/
2686 2683 /* Set the TN3720E header. */
2687 2684 if (IN_TN3270E || IN_SSCP) {
2688   - tn3270e_header *h = (tn3270e_header *)obuf_base;
  2685 + tn3270e_header *h = (tn3270e_header *) h3270.obuf_base;
2689 2686  
2690 2687 /* Check for sending a TN3270E response. */
2691 2688 if (response_required == TN3270E_RSF_ALWAYS_RESPONSE) {
... ... @@ -2732,7 +2729,7 @@ net_output(void)
2732 2729 net_rawout(&h3270,xobuf, xoptr - xobuf);
2733 2730  
2734 2731 trace_dsn("SENT EOR\n");
2735   - ns_rsent++;
  2732 + h3270.ns_rsent++;
2736 2733 #undef BSTART
2737 2734 }
2738 2735  
... ...
src/lib3270/trace_ds.c
... ... @@ -113,7 +113,8 @@ static void wtrace(const char *fmt, ...);
113 113 // static void stop_tracing(void);
114 114  
115 115 /* Globals */
116   -struct timeval ds_ts;
  116 +// struct timeval ds_ts;
  117 +
117 118 static void (*vwtrace)(H3270 *session, const char *fmt, va_list args) = __vwtrace;
118 119 Boolean trace_skipping = False;
119 120  
... ...