Commit 4f80c9e5182d6ab8b1dd2e88385c5396c8cefeb7
1 parent
441d46fc
Exists in
master
and in
3 other branches
Migração para multi-sessão, mais ajustes. Migrando gtkbox para versão 3
Showing
2 changed files
with
117 additions
and
123 deletions
Show diff stats
telnet.c
| ... | ... | @@ -215,14 +215,14 @@ static void check_linemode(H3270 *hSession, Boolean init); |
| 215 | 215 | static int non_blocking(H3270 *session, Boolean on); |
| 216 | 216 | static void net_connected(H3270 *session); |
| 217 | 217 | #if defined(X3270_TN3270E) /*[*/ |
| 218 | -static int tn3270e_negotiate(void); | |
| 218 | +static int tn3270e_negotiate(H3270 *hSession); | |
| 219 | 219 | #endif /*]*/ |
| 220 | 220 | static int process_eor(void); |
| 221 | 221 | #if defined(X3270_TN3270E) /*[*/ |
| 222 | 222 | #if defined(X3270_TRACE) /*[*/ |
| 223 | 223 | static const char *tn3270e_function_names(const unsigned char *, int); |
| 224 | 224 | #endif /*]*/ |
| 225 | -static void tn3270e_subneg_send(unsigned char, unsigned long); | |
| 225 | +static void tn3270e_subneg_send(H3270 *hSession, unsigned char, unsigned long); | |
| 226 | 226 | static unsigned long tn3270e_fdecode(const unsigned char *, int); |
| 227 | 227 | static void tn3270e_ack(void); |
| 228 | 228 | static void tn3270e_nak(enum pds); |
| ... | ... | @@ -240,7 +240,7 @@ static void do_eof(char c); |
| 240 | 240 | static void do_eol(char c); |
| 241 | 241 | static void do_lnext(char c); |
| 242 | 242 | static char parse_ctlchar(char *s); |
| 243 | -static void cooked_init(void); | |
| 243 | +static void cooked_init(H3270 *hSession); | |
| 244 | 244 | #endif /*]*/ |
| 245 | 245 | |
| 246 | 246 | #if defined(X3270_TRACE) /*[*/ |
| ... | ... | @@ -1149,8 +1149,7 @@ set16(char *buf, int n) |
| 1149 | 1149 | * send_naws |
| 1150 | 1150 | * Send a Telnet window size sub-option negotation. |
| 1151 | 1151 | */ |
| 1152 | -static void | |
| 1153 | -send_naws(void) | |
| 1152 | +static void send_naws(H3270 *hSession) | |
| 1154 | 1153 | { |
| 1155 | 1154 | char naws_msg[14]; |
| 1156 | 1155 | int naws_len = 0; |
| ... | ... | @@ -1161,18 +1160,17 @@ send_naws(void) |
| 1161 | 1160 | naws_len += set16(naws_msg + naws_len, XMIT_ROWS); |
| 1162 | 1161 | (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE); |
| 1163 | 1162 | naws_len += 2; |
| 1164 | - net_rawout(&h3270,(unsigned char *)naws_msg, naws_len); | |
| 1163 | + net_rawout(hSession,(unsigned char *)naws_msg, naws_len); | |
| 1165 | 1164 | trace_dsn("SENT %s NAWS %d %d %s\n", cmd(SB), XMIT_COLS, XMIT_ROWS, cmd(SE)); |
| 1166 | 1165 | } |
| 1167 | 1166 | |
| 1168 | 1167 | |
| 1169 | 1168 | |
| 1170 | 1169 | /* Advance 'try_lu' to the next desired LU name. */ |
| 1171 | -static void | |
| 1172 | -next_lu(void) | |
| 1170 | +static void next_lu(H3270 *hSession) | |
| 1173 | 1171 | { |
| 1174 | - if (h3270.curr_lu != (char **)NULL && (h3270.try_lu = *++h3270.curr_lu) == CN) | |
| 1175 | - h3270.curr_lu = (char **)NULL; | |
| 1172 | + if (hSession->curr_lu != (char **)NULL && (hSession->try_lu = *++hSession->curr_lu) == CN) | |
| 1173 | + hSession->curr_lu = (char **)NULL; | |
| 1176 | 1174 | } |
| 1177 | 1175 | |
| 1178 | 1176 | /* |
| ... | ... | @@ -1202,7 +1200,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1202 | 1200 | if (IN_NEITHER) { /* now can assume ANSI mode */ |
| 1203 | 1201 | #if defined(X3270_ANSI)/*[*/ |
| 1204 | 1202 | if (session->linemode) |
| 1205 | - cooked_init(); | |
| 1203 | + cooked_init(session); | |
| 1206 | 1204 | #endif /*]*/ |
| 1207 | 1205 | host_in3270(session,CONNECTED_ANSI); |
| 1208 | 1206 | kybdlock_clr(session,KL_AWAITING_FIRST, "telnet_fsm"); |
| ... | ... | @@ -1393,7 +1391,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1393 | 1391 | check_linemode(&h3270,False); |
| 1394 | 1392 | } |
| 1395 | 1393 | if (c == TELOPT_NAWS) |
| 1396 | - send_naws(); | |
| 1394 | + send_naws(&h3270); | |
| 1397 | 1395 | #if defined(HAVE_LIBSSL) /*[*/ |
| 1398 | 1396 | if (c == TELOPT_STARTTLS) { |
| 1399 | 1397 | static unsigned char follows_msg[] = { |
| ... | ... | @@ -1485,12 +1483,12 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1485 | 1483 | lib3270_free(tt_out); |
| 1486 | 1484 | |
| 1487 | 1485 | /* Advance to the next LU name. */ |
| 1488 | - next_lu(); | |
| 1486 | + next_lu(&h3270); | |
| 1489 | 1487 | } |
| 1490 | 1488 | #if defined(X3270_TN3270E) /*[*/ |
| 1491 | 1489 | else if (h3270.myopts[TELOPT_TN3270E] && |
| 1492 | 1490 | h3270.sbbuf[0] == TELOPT_TN3270E) { |
| 1493 | - if (tn3270e_negotiate()) | |
| 1491 | + if (tn3270e_negotiate(&h3270)) | |
| 1494 | 1492 | return -1; |
| 1495 | 1493 | } |
| 1496 | 1494 | #endif /*]*/ |
| ... | ... | @@ -1575,35 +1573,35 @@ backoff_tn3270e(const char *why) |
| 1575 | 1573 | * Negotiation of TN3270E options. |
| 1576 | 1574 | * Returns 0 if okay, -1 if we have to give up altogether. |
| 1577 | 1575 | */ |
| 1578 | -static int | |
| 1579 | -tn3270e_negotiate(void) | |
| 1576 | +static int tn3270e_negotiate(H3270 *hSession) | |
| 1580 | 1577 | { |
| 1581 | -#define LU_MAX 32 | |
| 1582 | - static char reported_lu[LU_MAX+1]; | |
| 1583 | - static char reported_type[LU_MAX+1]; | |
| 1578 | +// #define LU_MAX 32 | |
| 1579 | +// static char reported_lu[LU_MAX+1]; | |
| 1580 | +// static char reported_type[LU_MAX+1]; | |
| 1581 | + | |
| 1584 | 1582 | int sblen; |
| 1585 | 1583 | unsigned long e_rcvd; |
| 1586 | 1584 | |
| 1587 | 1585 | /* Find out how long the subnegotiation buffer is. */ |
| 1588 | 1586 | for (sblen = 0; ; sblen++) { |
| 1589 | - if (h3270.sbbuf[sblen] == SE) | |
| 1587 | + if (hSession->sbbuf[sblen] == SE) | |
| 1590 | 1588 | break; |
| 1591 | 1589 | } |
| 1592 | 1590 | |
| 1593 | 1591 | trace_dsn("TN3270E "); |
| 1594 | 1592 | |
| 1595 | - switch (h3270.sbbuf[1]) { | |
| 1593 | + switch (hSession->sbbuf[1]) { | |
| 1596 | 1594 | |
| 1597 | 1595 | case TN3270E_OP_SEND: |
| 1598 | 1596 | |
| 1599 | - if (h3270.sbbuf[2] == TN3270E_OP_DEVICE_TYPE) { | |
| 1597 | + if (hSession->sbbuf[2] == TN3270E_OP_DEVICE_TYPE) { | |
| 1600 | 1598 | |
| 1601 | 1599 | /* Host wants us to send our device type. */ |
| 1602 | 1600 | trace_dsn("SEND DEVICE-TYPE SE\n"); |
| 1603 | 1601 | |
| 1604 | 1602 | tn3270e_request(); |
| 1605 | 1603 | } else { |
| 1606 | - trace_dsn("SEND ??%u SE\n", h3270.sbbuf[2]); | |
| 1604 | + trace_dsn("SEND ??%u SE\n", hSession->sbbuf[2]); | |
| 1607 | 1605 | } |
| 1608 | 1606 | break; |
| 1609 | 1607 | |
| ... | ... | @@ -1612,7 +1610,7 @@ tn3270e_negotiate(void) |
| 1612 | 1610 | /* Device type negotiation. */ |
| 1613 | 1611 | trace_dsn("DEVICE-TYPE "); |
| 1614 | 1612 | |
| 1615 | - switch (h3270.sbbuf[2]) { | |
| 1613 | + switch (hSession->sbbuf[2]) { | |
| 1616 | 1614 | case TN3270E_OP_IS: { |
| 1617 | 1615 | int tnlen, snlen; |
| 1618 | 1616 | |
| ... | ... | @@ -1620,57 +1618,55 @@ tn3270e_negotiate(void) |
| 1620 | 1618 | |
| 1621 | 1619 | /* Isolate the terminal type and session. */ |
| 1622 | 1620 | tnlen = 0; |
| 1623 | - while (h3270.sbbuf[3+tnlen] != SE && | |
| 1624 | - h3270.sbbuf[3+tnlen] != TN3270E_OP_CONNECT) | |
| 1621 | + while (hSession->sbbuf[3+tnlen] != SE && | |
| 1622 | + hSession->sbbuf[3+tnlen] != TN3270E_OP_CONNECT) | |
| 1625 | 1623 | tnlen++; |
| 1626 | 1624 | snlen = 0; |
| 1627 | - if (h3270.sbbuf[3+tnlen] == TN3270E_OP_CONNECT) { | |
| 1628 | - while(h3270.sbbuf[3+tnlen+1+snlen] != SE) | |
| 1625 | + if (hSession->sbbuf[3+tnlen] == TN3270E_OP_CONNECT) { | |
| 1626 | + while(hSession->sbbuf[3+tnlen+1+snlen] != SE) | |
| 1629 | 1627 | snlen++; |
| 1630 | 1628 | } |
| 1631 | 1629 | trace_dsn("IS %.*s CONNECT %.*s SE\n", |
| 1632 | - tnlen, &h3270.sbbuf[3], | |
| 1633 | - snlen, &h3270.sbbuf[3+tnlen+1]); | |
| 1630 | + tnlen, &hSession->sbbuf[3], | |
| 1631 | + snlen, &hSession->sbbuf[3+tnlen+1]); | |
| 1634 | 1632 | |
| 1635 | 1633 | /* Remember the LU. */ |
| 1636 | 1634 | if (tnlen) { |
| 1637 | - if (tnlen > LU_MAX) | |
| 1638 | - tnlen = LU_MAX; | |
| 1639 | - (void)strncpy(reported_type, | |
| 1640 | - (char *)&h3270.sbbuf[3], tnlen); | |
| 1641 | - reported_type[tnlen] = '\0'; | |
| 1642 | - h3270.connected_type = reported_type; | |
| 1635 | + if (tnlen > LIB3270_LU_MAX) | |
| 1636 | + tnlen = LIB3270_LU_MAX; | |
| 1637 | + (void)strncpy(hSession->reported_type,(char *)&hSession->sbbuf[3], tnlen); | |
| 1638 | + hSession->reported_type[tnlen] = '\0'; | |
| 1639 | + hSession->connected_type = hSession->reported_type; | |
| 1643 | 1640 | } |
| 1644 | 1641 | if (snlen) { |
| 1645 | - if (snlen > LU_MAX) | |
| 1646 | - snlen = LU_MAX; | |
| 1647 | - (void)strncpy(reported_lu, | |
| 1648 | - (char *)&h3270.sbbuf[3+tnlen+1], snlen); | |
| 1649 | - reported_lu[snlen] = '\0'; | |
| 1650 | - h3270.connected_lu = reported_lu; | |
| 1651 | - status_lu(&h3270,h3270.connected_lu); | |
| 1642 | + if (snlen > LIB3270_LU_MAX) | |
| 1643 | + snlen = LIB3270_LU_MAX; | |
| 1644 | + (void)strncpy(hSession->reported_lu,(char *)&hSession->sbbuf[3+tnlen+1], snlen); | |
| 1645 | + hSession->reported_lu[snlen] = '\0'; | |
| 1646 | + hSession->connected_lu = hSession->reported_lu; | |
| 1647 | + status_lu(hSession,hSession->connected_lu); | |
| 1652 | 1648 | } |
| 1653 | 1649 | |
| 1654 | 1650 | /* Tell them what we can do. */ |
| 1655 | - tn3270e_subneg_send(TN3270E_OP_REQUEST, h3270.e_funcs); | |
| 1651 | + tn3270e_subneg_send(hSession, TN3270E_OP_REQUEST, hSession->e_funcs); | |
| 1656 | 1652 | break; |
| 1657 | 1653 | } |
| 1658 | 1654 | case TN3270E_OP_REJECT: |
| 1659 | 1655 | |
| 1660 | 1656 | /* Device type failure. */ |
| 1661 | 1657 | |
| 1662 | - trace_dsn("REJECT REASON %s SE\n", rsn(h3270.sbbuf[4])); | |
| 1663 | - if (h3270.sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE || | |
| 1664 | - h3270.sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) { | |
| 1658 | + trace_dsn("REJECT REASON %s SE\n", rsn(hSession->sbbuf[4])); | |
| 1659 | + if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE || | |
| 1660 | + hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) { | |
| 1665 | 1661 | backoff_tn3270e(_( "Host rejected device type or request type" )); |
| 1666 | 1662 | break; |
| 1667 | 1663 | } |
| 1668 | 1664 | |
| 1669 | - next_lu(); | |
| 1670 | - if (h3270.try_lu != CN) { | |
| 1665 | + next_lu(hSession); | |
| 1666 | + if (hSession->try_lu != CN) { | |
| 1671 | 1667 | /* Try the next LU. */ |
| 1672 | 1668 | tn3270e_request(); |
| 1673 | - } else if (h3270.lus != (char **)NULL) { | |
| 1669 | + } else if (hSession->lus != (char **)NULL) { | |
| 1674 | 1670 | /* No more LUs to try. Give up. */ |
| 1675 | 1671 | backoff_tn3270e(_("Host rejected resource(s)")); |
| 1676 | 1672 | } else { |
| ... | ... | @@ -1679,7 +1675,7 @@ tn3270e_negotiate(void) |
| 1679 | 1675 | |
| 1680 | 1676 | break; |
| 1681 | 1677 | default: |
| 1682 | - trace_dsn("??%u SE\n", h3270.sbbuf[2]); | |
| 1678 | + trace_dsn("??%u SE\n", hSession->sbbuf[2]); | |
| 1683 | 1679 | break; |
| 1684 | 1680 | } |
| 1685 | 1681 | break; |
| ... | ... | @@ -1689,46 +1685,45 @@ tn3270e_negotiate(void) |
| 1689 | 1685 | /* Functions negotiation. */ |
| 1690 | 1686 | trace_dsn("FUNCTIONS "); |
| 1691 | 1687 | |
| 1692 | - switch (h3270.sbbuf[2]) { | |
| 1688 | + switch (hSession->sbbuf[2]) { | |
| 1693 | 1689 | |
| 1694 | 1690 | case TN3270E_OP_REQUEST: |
| 1695 | 1691 | |
| 1696 | 1692 | /* Host is telling us what functions they want. */ |
| 1697 | 1693 | trace_dsn("REQUEST %s SE\n", |
| 1698 | - tn3270e_function_names(h3270.sbbuf+3, sblen-3)); | |
| 1694 | + tn3270e_function_names(hSession->sbbuf+3, sblen-3)); | |
| 1699 | 1695 | |
| 1700 | - e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3); | |
| 1701 | - if ((e_rcvd == h3270.e_funcs) || (h3270.e_funcs & ~e_rcvd)) { | |
| 1696 | + e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3); | |
| 1697 | + if ((e_rcvd == hSession->e_funcs) || (hSession->e_funcs & ~e_rcvd)) { | |
| 1702 | 1698 | /* They want what we want, or less. Done. */ |
| 1703 | - h3270.e_funcs = e_rcvd; | |
| 1704 | - tn3270e_subneg_send(TN3270E_OP_IS, h3270.e_funcs); | |
| 1705 | - h3270.tn3270e_negotiated = 1; | |
| 1699 | + hSession->e_funcs = e_rcvd; | |
| 1700 | + tn3270e_subneg_send(hSession, TN3270E_OP_IS, hSession->e_funcs); | |
| 1701 | + hSession->tn3270e_negotiated = 1; | |
| 1706 | 1702 | trace_dsn("TN3270E option negotiation complete.\n"); |
| 1707 | - check_in3270(&h3270); | |
| 1703 | + check_in3270(hSession); | |
| 1708 | 1704 | } else { |
| 1709 | 1705 | /* |
| 1710 | 1706 | * They want us to do something we can't. |
| 1711 | 1707 | * Request the common subset. |
| 1712 | 1708 | */ |
| 1713 | - h3270.e_funcs &= e_rcvd; | |
| 1714 | - tn3270e_subneg_send(TN3270E_OP_REQUEST,h3270.e_funcs); | |
| 1709 | + hSession->e_funcs &= e_rcvd; | |
| 1710 | + tn3270e_subneg_send(hSession, TN3270E_OP_REQUEST,hSession->e_funcs); | |
| 1715 | 1711 | } |
| 1716 | 1712 | break; |
| 1717 | 1713 | |
| 1718 | 1714 | case TN3270E_OP_IS: |
| 1719 | 1715 | |
| 1720 | 1716 | /* They accept our last request, or a subset thereof. */ |
| 1721 | - trace_dsn("IS %s SE\n", | |
| 1722 | - tn3270e_function_names(h3270.sbbuf+3, sblen-3)); | |
| 1723 | - e_rcvd = tn3270e_fdecode(h3270.sbbuf+3, sblen-3); | |
| 1724 | - if (e_rcvd != h3270.e_funcs) { | |
| 1725 | - if (h3270.e_funcs & ~e_rcvd) { | |
| 1717 | + trace_dsn("IS %s SE\n",tn3270e_function_names(hSession->sbbuf+3, sblen-3)); | |
| 1718 | + e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3); | |
| 1719 | + if (e_rcvd != hSession->e_funcs) { | |
| 1720 | + if (hSession->e_funcs & ~e_rcvd) { | |
| 1726 | 1721 | /* |
| 1727 | 1722 | * They've removed something. This is |
| 1728 | 1723 | * technically illegal, but we can |
| 1729 | 1724 | * live with it. |
| 1730 | 1725 | */ |
| 1731 | - h3270.e_funcs = e_rcvd; | |
| 1726 | + hSession->e_funcs = e_rcvd; | |
| 1732 | 1727 | } else { |
| 1733 | 1728 | /* |
| 1734 | 1729 | * They've added something. Abandon |
| ... | ... | @@ -1738,19 +1733,19 @@ tn3270e_negotiate(void) |
| 1738 | 1733 | break; |
| 1739 | 1734 | } |
| 1740 | 1735 | } |
| 1741 | - h3270.tn3270e_negotiated = 1; | |
| 1736 | + hSession->tn3270e_negotiated = 1; | |
| 1742 | 1737 | trace_dsn("TN3270E option negotiation complete.\n"); |
| 1743 | - check_in3270(&h3270); | |
| 1738 | + check_in3270(hSession); | |
| 1744 | 1739 | break; |
| 1745 | 1740 | |
| 1746 | 1741 | default: |
| 1747 | - trace_dsn("??%u SE\n", h3270.sbbuf[2]); | |
| 1742 | + trace_dsn("??%u SE\n", hSession->sbbuf[2]); | |
| 1748 | 1743 | break; |
| 1749 | 1744 | } |
| 1750 | 1745 | break; |
| 1751 | 1746 | |
| 1752 | 1747 | default: |
| 1753 | - trace_dsn("??%u SE\n", h3270.sbbuf[1]); | |
| 1748 | + trace_dsn("??%u SE\n", hSession->sbbuf[1]); | |
| 1754 | 1749 | } |
| 1755 | 1750 | |
| 1756 | 1751 | /* Good enough for now. */ |
| ... | ... | @@ -1776,7 +1771,7 @@ tn3270e_function_names(const unsigned char *buf, int len) |
| 1776 | 1771 | } |
| 1777 | 1772 | #endif /*]*/ |
| 1778 | 1773 | |
| 1779 | -/* Expand the current TN3270E function codes into text. */ | |
| 1774 | +/* Expand the current TN3270E function codes into text. */ /* | |
| 1780 | 1775 | const char * |
| 1781 | 1776 | tn3270e_current_opts(void) |
| 1782 | 1777 | { |
| ... | ... | @@ -1793,10 +1788,10 @@ tn3270e_current_opts(void) |
| 1793 | 1788 | } |
| 1794 | 1789 | return text_buf; |
| 1795 | 1790 | } |
| 1791 | +*/ | |
| 1796 | 1792 | |
| 1797 | 1793 | /* Transmit a TN3270E FUNCTIONS REQUEST or FUNCTIONS IS message. */ |
| 1798 | -static void | |
| 1799 | -tn3270e_subneg_send(unsigned char op, unsigned long funcs) | |
| 1794 | +static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long funcs) | |
| 1800 | 1795 | { |
| 1801 | 1796 | unsigned char proto_buf[7 + 32]; |
| 1802 | 1797 | int proto_len; |
| ... | ... | @@ -1814,7 +1809,7 @@ tn3270e_subneg_send(unsigned char op, unsigned long funcs) |
| 1814 | 1809 | /* Complete and send out the protocol message. */ |
| 1815 | 1810 | proto_buf[proto_len++] = IAC; |
| 1816 | 1811 | proto_buf[proto_len++] = SE; |
| 1817 | - net_rawout(&h3270, proto_buf, proto_len); | |
| 1812 | + net_rawout(hSession, proto_buf, proto_len); | |
| 1818 | 1813 | |
| 1819 | 1814 | /* Complete and send out the trace text. */ |
| 1820 | 1815 | trace_dsn("SENT %s %s FUNCTIONS %s %s %s\n", |
| ... | ... | @@ -1841,12 +1836,11 @@ tn3270e_fdecode(const unsigned char *buf, int len) |
| 1841 | 1836 | #endif /*]*/ |
| 1842 | 1837 | |
| 1843 | 1838 | #if defined(X3270_TN3270E) /*[*/ |
| 1844 | -static void | |
| 1845 | -process_bind(unsigned char *buf, int buflen) | |
| 1839 | +static void process_bind(H3270 *hSession, unsigned char *buf, int buflen) | |
| 1846 | 1840 | { |
| 1847 | 1841 | int namelen, i; |
| 1848 | 1842 | |
| 1849 | - (void) memset(h3270.plu_name, '\0', sizeof(h3270.plu_name)); | |
| 1843 | + (void) memset(hSession->plu_name, '\0', sizeof(hSession->plu_name)); | |
| 1850 | 1844 | |
| 1851 | 1845 | /* Make sure it's a BIND. */ |
| 1852 | 1846 | if (buflen < 1 || buf[0] != BIND_RU) { |
| ... | ... | @@ -1862,7 +1856,7 @@ process_bind(unsigned char *buf, int buflen) |
| 1862 | 1856 | if (namelen > BIND_PLU_NAME_MAX) |
| 1863 | 1857 | namelen = BIND_PLU_NAME_MAX; |
| 1864 | 1858 | for (i = 0; i < namelen; i++) { |
| 1865 | - h3270.plu_name[i] = ebc2asc0[buf[BIND_OFF_PLU_NAME + i]]; | |
| 1859 | + hSession->plu_name[i] = ebc2asc0[buf[BIND_OFF_PLU_NAME + i]]; | |
| 1866 | 1860 | } |
| 1867 | 1861 | } |
| 1868 | 1862 | #endif /*]*/ |
| ... | ... | @@ -1906,7 +1900,7 @@ process_eor(void) |
| 1906 | 1900 | case TN3270E_DT_BIND_IMAGE: |
| 1907 | 1901 | if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) |
| 1908 | 1902 | return 0; |
| 1909 | - process_bind(h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE); | |
| 1903 | + process_bind(&h3270, h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE); | |
| 1910 | 1904 | trace_dsn("< BIND PLU-name '%s'\n", h3270.plu_name); |
| 1911 | 1905 | h3270.tn3270e_bound = 1; |
| 1912 | 1906 | check_in3270(&h3270); |
| ... | ... | @@ -2051,14 +2045,14 @@ net_rawout(H3270 *session, unsigned const char *buf, int len) |
| 2051 | 2045 | return; |
| 2052 | 2046 | } |
| 2053 | 2047 | } |
| 2054 | - h3270.ns_bsent += nw; | |
| 2048 | + session->ns_bsent += nw; | |
| 2055 | 2049 | len -= nw; |
| 2056 | 2050 | buf += nw; |
| 2057 | 2051 | bot: |
| 2058 | -#if defined(OMTU) /*[*/ | |
| 2052 | +#if defined(OMTU) | |
| 2059 | 2053 | if (pause) |
| 2060 | 2054 | sleep(1); |
| 2061 | -#endif /*]*/ | |
| 2055 | +#endif | |
| 2062 | 2056 | ; |
| 2063 | 2057 | } |
| 2064 | 2058 | } |
| ... | ... | @@ -2069,7 +2063,7 @@ net_rawout(H3270 *session, unsigned const char *buf, int len) |
| 2069 | 2063 | * net_hexansi_out |
| 2070 | 2064 | * Send uncontrolled user data to the host in ANSI mode, performing IAC |
| 2071 | 2065 | * and CR quoting as necessary. |
| 2072 | - */ | |
| 2066 | + */ /* | |
| 2073 | 2067 | void |
| 2074 | 2068 | net_hexansi_out(unsigned char *buf, int len) |
| 2075 | 2069 | { |
| ... | ... | @@ -2079,8 +2073,8 @@ net_hexansi_out(unsigned char *buf, int len) |
| 2079 | 2073 | if (!len) |
| 2080 | 2074 | return; |
| 2081 | 2075 | |
| 2082 | -#if defined(X3270_TRACE) /*[*/ | |
| 2083 | - /* Trace the data. */ | |
| 2076 | +#if defined(X3270_TRACE) | |
| 2077 | + // Trace the data. | |
| 2084 | 2078 | if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) { |
| 2085 | 2079 | int i; |
| 2086 | 2080 | |
| ... | ... | @@ -2089,9 +2083,9 @@ net_hexansi_out(unsigned char *buf, int len) |
| 2089 | 2083 | trace_dsn(" %s", ctl_see((int) *(buf+i))); |
| 2090 | 2084 | trace_dsn("\n"); |
| 2091 | 2085 | } |
| 2092 | -#endif /*]*/ | |
| 2086 | +#endif | |
| 2093 | 2087 | |
| 2094 | - /* Expand it. */ | |
| 2088 | + // Expand it | |
| 2095 | 2089 | tbuf = xbuf = (unsigned char *)lib3270_malloc(2*len); |
| 2096 | 2090 | while (len) { |
| 2097 | 2091 | unsigned char c = *buf++; |
| ... | ... | @@ -2104,10 +2098,11 @@ net_hexansi_out(unsigned char *buf, int len) |
| 2104 | 2098 | *tbuf++ = '\0'; |
| 2105 | 2099 | } |
| 2106 | 2100 | |
| 2107 | - /* Send it to the host. */ | |
| 2101 | + // Send it to the host | |
| 2108 | 2102 | net_rawout(&h3270,xbuf, tbuf - xbuf); |
| 2109 | 2103 | lib3270_free(xbuf); |
| 2110 | 2104 | } |
| 2105 | +*/ | |
| 2111 | 2106 | |
| 2112 | 2107 | /* |
| 2113 | 2108 | * net_cookedout |
| ... | ... | @@ -2195,14 +2190,13 @@ static void net_cookout(H3270 *hSession, const char *buf, int len) |
| 2195 | 2190 | * Cooked mode input processing. |
| 2196 | 2191 | */ |
| 2197 | 2192 | |
| 2198 | -static void | |
| 2199 | -cooked_init(void) | |
| 2193 | +static void cooked_init(H3270 *hSession) | |
| 2200 | 2194 | { |
| 2201 | - if (h3270.lbuf == (unsigned char *)NULL) | |
| 2202 | - h3270.lbuf = (unsigned char *)lib3270_malloc(BUFSZ); | |
| 2203 | - h3270.lbptr = h3270.lbuf; | |
| 2204 | - h3270.lnext = 0; | |
| 2205 | - h3270.backslashed = 0; | |
| 2195 | + if (hSession->lbuf == (unsigned char *)NULL) | |
| 2196 | + hSession->lbuf = (unsigned char *)lib3270_malloc(BUFSZ); | |
| 2197 | + hSession->lbptr = hSession->lbuf; | |
| 2198 | + hSession->lnext = 0; | |
| 2199 | + hSession->backslashed = 0; | |
| 2206 | 2200 | } |
| 2207 | 2201 | |
| 2208 | 2202 | static void |
| ... | ... | @@ -2216,7 +2210,7 @@ static void |
| 2216 | 2210 | forward_data(void) |
| 2217 | 2211 | { |
| 2218 | 2212 | net_cookedout(&h3270, (char *) h3270.lbuf, h3270.lbptr - h3270.lbuf); |
| 2219 | - cooked_init(); | |
| 2213 | + cooked_init(&h3270); | |
| 2220 | 2214 | } |
| 2221 | 2215 | |
| 2222 | 2216 | static void |
| ... | ... | @@ -2244,7 +2238,7 @@ static void do_intr(H3270 *hSession, char c) |
| 2244 | 2238 | return; |
| 2245 | 2239 | } |
| 2246 | 2240 | ansi_process_s(ctl_see((int) c)); |
| 2247 | - cooked_init(); | |
| 2241 | + cooked_init(hSession); | |
| 2248 | 2242 | net_interrupt(); |
| 2249 | 2243 | } |
| 2250 | 2244 | |
| ... | ... | @@ -2256,7 +2250,7 @@ static void do_quit(H3270 *hSession, char c) |
| 2256 | 2250 | return; |
| 2257 | 2251 | } |
| 2258 | 2252 | ansi_process_s(ctl_see((int) c)); |
| 2259 | - cooked_init(); | |
| 2253 | + cooked_init(hSession); | |
| 2260 | 2254 | net_break(); |
| 2261 | 2255 | } |
| 2262 | 2256 | |
| ... | ... | @@ -2422,10 +2416,10 @@ check_in3270(H3270 *session) |
| 2422 | 2416 | #endif /*]*/ |
| 2423 | 2417 | |
| 2424 | 2418 | #if defined(X3270_TN3270E) /*[*/ |
| 2425 | - if (h3270.myopts[TELOPT_TN3270E]) { | |
| 2426 | - if (!h3270.tn3270e_negotiated) | |
| 2419 | + if (session->myopts[TELOPT_TN3270E]) { | |
| 2420 | + if (!session->tn3270e_negotiated) | |
| 2427 | 2421 | new_cstate = CONNECTED_INITIAL_E; |
| 2428 | - else switch (h3270.tn3270e_submode) { | |
| 2422 | + else switch (session->tn3270e_submode) { | |
| 2429 | 2423 | case E_NONE: |
| 2430 | 2424 | new_cstate = CONNECTED_INITIAL_E; |
| 2431 | 2425 | break; |
| ... | ... | @@ -2441,11 +2435,11 @@ check_in3270(H3270 *session) |
| 2441 | 2435 | } |
| 2442 | 2436 | } else |
| 2443 | 2437 | #endif /*]*/ |
| 2444 | - if (h3270.myopts[TELOPT_BINARY] && | |
| 2445 | - h3270.myopts[TELOPT_EOR] && | |
| 2446 | - h3270.myopts[TELOPT_TTYPE] && | |
| 2447 | - h3270.hisopts[TELOPT_BINARY] && | |
| 2448 | - h3270.hisopts[TELOPT_EOR]) { | |
| 2438 | + if (session->myopts[TELOPT_BINARY] && | |
| 2439 | + session->myopts[TELOPT_EOR] && | |
| 2440 | + session->myopts[TELOPT_TTYPE] && | |
| 2441 | + session->hisopts[TELOPT_BINARY] && | |
| 2442 | + session->hisopts[TELOPT_EOR]) { | |
| 2449 | 2443 | new_cstate = CONNECTED_3270; |
| 2450 | 2444 | } else if (session->cstate == CONNECTED_INITIAL) { |
| 2451 | 2445 | /* Nothing has happened, yet. */ |
| ... | ... | @@ -2465,33 +2459,33 @@ check_in3270(H3270 *session) |
| 2465 | 2459 | * TN3270E mode, reset the LU list so we can try again |
| 2466 | 2460 | * in the new mode. |
| 2467 | 2461 | */ |
| 2468 | - if (h3270.lus != (char **)NULL && was_in_e != IN_E) { | |
| 2469 | - h3270.curr_lu = h3270.lus; | |
| 2470 | - h3270.try_lu = *h3270.curr_lu; | |
| 2462 | + if (session->lus != (char **)NULL && was_in_e != IN_E) { | |
| 2463 | + session->curr_lu = session->lus; | |
| 2464 | + session->try_lu = *session->curr_lu; | |
| 2471 | 2465 | } |
| 2472 | 2466 | #endif /*]*/ |
| 2473 | 2467 | |
| 2474 | 2468 | /* Allocate the initial 3270 input buffer. */ |
| 2475 | - if(new_cstate >= CONNECTED_INITIAL && !(h3270.ibuf_size && h3270.ibuf)) | |
| 2469 | + if(new_cstate >= CONNECTED_INITIAL && !(session->ibuf_size && session->ibuf)) | |
| 2476 | 2470 | { |
| 2477 | - h3270.ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); | |
| 2478 | - h3270.ibuf_size = BUFSIZ; | |
| 2479 | - h3270.ibptr = h3270.ibuf; | |
| 2471 | + session->ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); | |
| 2472 | + session->ibuf_size = BUFSIZ; | |
| 2473 | + session->ibptr = session->ibuf; | |
| 2480 | 2474 | } |
| 2481 | 2475 | |
| 2482 | 2476 | #if defined(X3270_ANSI) /*[*/ |
| 2483 | 2477 | /* Reinitialize line mode. */ |
| 2484 | - if ((new_cstate == CONNECTED_ANSI && h3270.linemode) || | |
| 2478 | + if ((new_cstate == CONNECTED_ANSI && session->linemode) || | |
| 2485 | 2479 | new_cstate == CONNECTED_NVT) |
| 2486 | - cooked_init(); | |
| 2480 | + cooked_init(session); | |
| 2487 | 2481 | #endif /*]*/ |
| 2488 | 2482 | |
| 2489 | 2483 | #if defined(X3270_TN3270E) /*[*/ |
| 2490 | 2484 | /* If we fell out of TN3270E, remove the state. */ |
| 2491 | - if (!h3270.myopts[TELOPT_TN3270E]) { | |
| 2492 | - h3270.tn3270e_negotiated = 0; | |
| 2493 | - h3270.tn3270e_submode = E_NONE; | |
| 2494 | - h3270.tn3270e_bound = 0; | |
| 2485 | + if (!session->myopts[TELOPT_TN3270E]) { | |
| 2486 | + session->tn3270e_negotiated = 0; | |
| 2487 | + session->tn3270e_submode = E_NONE; | |
| 2488 | + session->tn3270e_bound = 0; | |
| 2495 | 2489 | } |
| 2496 | 2490 | #endif /*]*/ |
| 2497 | 2491 | trace_dsn("Now operating in %s mode.\n",state_name[new_cstate]); |
| ... | ... | @@ -2575,7 +2569,7 @@ static void check_linemode(H3270 *hSession, Boolean init) |
| 2575 | 2569 | } |
| 2576 | 2570 | #if defined(X3270_ANSI) /*[*/ |
| 2577 | 2571 | if (IN_ANSI && hSession->linemode) |
| 2578 | - cooked_init(); | |
| 2572 | + cooked_init(hSession); | |
| 2579 | 2573 | #endif /*]*/ |
| 2580 | 2574 | } |
| 2581 | 2575 | } | ... | ... |
telnetc.h
| ... | ... | @@ -37,7 +37,7 @@ LIB3270_INTERNAL void net_charmode(void); |
| 37 | 37 | LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *); |
| 38 | 38 | LIB3270_INTERNAL void net_disconnect(H3270 *session); |
| 39 | 39 | LIB3270_INTERNAL void net_exception(H3270 *session); |
| 40 | -LIB3270_INTERNAL void net_hexansi_out(unsigned char *buf, int len); | |
| 40 | +// LIB3270_INTERNAL void net_hexansi_out(unsigned char *buf, int len); | |
| 41 | 41 | LIB3270_INTERNAL void net_input(H3270 *session); |
| 42 | 42 | LIB3270_INTERNAL void net_interrupt(void); |
| 43 | 43 | LIB3270_INTERNAL void net_linemode(void); |
| ... | ... | @@ -54,7 +54,7 @@ LIB3270_INTERNAL void net_send_kill(void); |
| 54 | 54 | 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 | -LIB3270_INTERNAL const char *tn3270e_current_opts(void); | |
| 57 | +// LIB3270_INTERNAL const char *tn3270e_current_opts(void); | |
| 58 | 58 | LIB3270_INTERNAL char *net_proxy_type(void); |
| 59 | 59 | LIB3270_INTERNAL char *net_proxy_host(void); |
| 60 | 60 | LIB3270_INTERNAL char *net_proxy_port(void); | ... | ... |