Commit c830115161b02f8972afc1481d86f38ddfe2db45
1 parent
394b8b92
Exists in
master
and in
5 other branches
Mais funções recebem handle da sessão
Showing
5 changed files
with
221 additions
and
186 deletions
Show diff stats
src/lib3270/ansi.c
@@ -1870,9 +1870,9 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | @@ -1870,9 +1870,9 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | ||
1870 | 1870 | ||
1871 | // See if we have too many. | 1871 | // See if we have too many. |
1872 | if (mb_pending >= MB_MAX) { | 1872 | if (mb_pending >= MB_MAX) { |
1873 | - trace_ds(&h3270,"Multi-byte character "); | 1873 | + trace_ds(hSession,"Multi-byte character "); |
1874 | trace_pending_mb(hSession); | 1874 | trace_pending_mb(hSession); |
1875 | - trace_ds(&h3270," too long, dropping\n"); | 1875 | + trace_ds(hSession," too long, dropping\n"); |
1876 | mb_pending = 0; | 1876 | mb_pending = 0; |
1877 | return 0; | 1877 | return 0; |
1878 | } | 1878 | } |
@@ -1893,9 +1893,9 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | @@ -1893,9 +1893,9 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | ||
1893 | mb_pending = 0; | 1893 | mb_pending = 0; |
1894 | return 2; | 1894 | return 2; |
1895 | } else { | 1895 | } else { |
1896 | - trace_ds(&h3270,"Can't map multi-byte character"); | ||
1897 | - trace_pending_mb(&h3270); | ||
1898 | - trace_ds(&h3270," -> U+%04x to SBCS or DBCS, dropping\n", | 1896 | + trace_ds(hSession,"Can't map multi-byte character"); |
1897 | + trace_pending_mb(hSession); | ||
1898 | + trace_ds(hSession," -> U+%04x to SBCS or DBCS, dropping\n", | ||
1899 | Ubuf[0] & 0xffff); | 1899 | Ubuf[0] & 0xffff); |
1900 | mb_pending = 0; | 1900 | mb_pending = 0; |
1901 | return 0; | 1901 | return 0; |
@@ -1909,14 +1909,14 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | @@ -1909,14 +1909,14 @@ static int dbcs_process(H3270 *hSession, int ch, unsigned char ebc[]) | ||
1909 | return 0; | 1909 | return 0; |
1910 | case U_INVALID_CHAR_FOUND: | 1910 | case U_INVALID_CHAR_FOUND: |
1911 | case U_ILLEGAL_CHAR_FOUND: | 1911 | case U_ILLEGAL_CHAR_FOUND: |
1912 | - trace_ds(&h3270,"Invalid multi-byte character"); | ||
1913 | - trace_pending_mb(&h3270); | ||
1914 | - trace_ds(&h3270,", dropping\n"); | 1912 | + trace_ds(hSession,"Invalid multi-byte character"); |
1913 | + trace_pending_mb(hSession); | ||
1914 | + trace_ds(hSession,", dropping\n"); | ||
1915 | break; | 1915 | break; |
1916 | default: | 1916 | default: |
1917 | - trace_ds(&h3270,"Unexpected ICU error %d translating multi-type character", (int)err); | ||
1918 | - trace_pending_mb(&h3270); | ||
1919 | - trace_ds(&h3270,", dropping\n"); | 1917 | + trace_ds(hSession,"Unexpected ICU error %d translating multi-type character", (int)err); |
1918 | + trace_pending_mb(hSession); | ||
1919 | + trace_ds(hSession,", dropping\n"); | ||
1920 | break; | 1920 | break; |
1921 | } | 1921 | } |
1922 | mb_pending = 0; | 1922 | mb_pending = 0; |
src/lib3270/ctlr.c
@@ -771,13 +771,13 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -771,13 +771,13 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
771 | } | 771 | } |
772 | #endif /*]*/ | 772 | #endif /*]*/ |
773 | 773 | ||
774 | - trace_ds(&h3270,"> "); | 774 | + trace_ds(hSession,"> "); |
775 | hSession->obptr = hSession->obuf; | 775 | hSession->obptr = hSession->obuf; |
776 | 776 | ||
777 | space3270out(hSession,3); | 777 | space3270out(hSession,3); |
778 | *hSession->obptr++ = aid_byte; | 778 | *hSession->obptr++ = aid_byte; |
779 | ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); | 779 | ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); |
780 | - trace_ds(&h3270,"%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); | 780 | + trace_ds(hSession,"%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); |
781 | 781 | ||
782 | baddr = 0; | 782 | baddr = 0; |
783 | do { | 783 | do { |
@@ -1213,7 +1213,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1213,7 +1213,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1213 | } | 1213 | } |
1214 | add_c1 = *cp; | 1214 | add_c1 = *cp; |
1215 | if (add_c1) | 1215 | if (add_c1) |
1216 | - trace_ds(&h3270,"'"); | 1216 | + trace_ds(hSession,"'"); |
1217 | 1217 | ||
1218 | trace_ds(hSession,"%s", see_ebc(add_c1)); | 1218 | trace_ds(hSession,"%s", see_ebc(add_c1)); |
1219 | if (add_c1) | 1219 | if (add_c1) |
@@ -1400,7 +1400,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1400,7 +1400,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1400 | case ORDER_SFE: /* start field extended */ | 1400 | case ORDER_SFE: /* start field extended */ |
1401 | END_TEXT("StartFieldExtended"); | 1401 | END_TEXT("StartFieldExtended"); |
1402 | if (previous != SBA) | 1402 | if (previous != SBA) |
1403 | - trace_ds(&h3270,"%s",rcba(&h3270,h3270.buffer_addr)); | 1403 | + trace_ds(hSession,"%s",rcba(&h3270,h3270.buffer_addr)); |
1404 | previous = ORDER; | 1404 | previous = ORDER; |
1405 | cp++; /* skip order */ | 1405 | cp++; /* skip order */ |
1406 | na = *cp; | 1406 | na = *cp; |
@@ -1413,26 +1413,26 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1413,26 +1413,26 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1413 | for (i = 0; i < (int)na; i++) { | 1413 | for (i = 0; i < (int)na; i++) { |
1414 | cp++; | 1414 | cp++; |
1415 | if (*cp == XA_3270) { | 1415 | if (*cp == XA_3270) { |
1416 | - trace_ds(&h3270," 3270"); | 1416 | + trace_ds(hSession," 3270"); |
1417 | cp++; | 1417 | cp++; |
1418 | START_FIELD(*cp); | 1418 | START_FIELD(*cp); |
1419 | any_fa++; | 1419 | any_fa++; |
1420 | } else if (*cp == XA_FOREGROUND) { | 1420 | } else if (*cp == XA_FOREGROUND) { |
1421 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1421 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1422 | cp++; | 1422 | cp++; |
1423 | if (h3270.m3279) | 1423 | if (h3270.m3279) |
1424 | efa_fg = *cp; | 1424 | efa_fg = *cp; |
1425 | } else if (*cp == XA_BACKGROUND) { | 1425 | } else if (*cp == XA_BACKGROUND) { |
1426 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1426 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1427 | cp++; | 1427 | cp++; |
1428 | if (h3270.m3279) | 1428 | if (h3270.m3279) |
1429 | efa_bg = *cp; | 1429 | efa_bg = *cp; |
1430 | } else if (*cp == XA_HIGHLIGHTING) { | 1430 | } else if (*cp == XA_HIGHLIGHTING) { |
1431 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1431 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1432 | cp++; | 1432 | cp++; |
1433 | efa_gr = *cp & 0x07; | 1433 | efa_gr = *cp & 0x07; |
1434 | } else if (*cp == XA_CHARSET) { | 1434 | } else if (*cp == XA_CHARSET) { |
1435 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1435 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1436 | cp++; | 1436 | cp++; |
1437 | if (*cp == 0xf1) | 1437 | if (*cp == 0xf1) |
1438 | efa_cs = CS_APL; | 1438 | efa_cs = CS_APL; |
@@ -1441,15 +1441,15 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1441,15 +1441,15 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1441 | else | 1441 | else |
1442 | efa_cs = CS_BASE; | 1442 | efa_cs = CS_BASE; |
1443 | } else if (*cp == XA_ALL) { | 1443 | } else if (*cp == XA_ALL) { |
1444 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1444 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1445 | cp++; | 1445 | cp++; |
1446 | } else if (*cp == XA_INPUT_CONTROL) { | 1446 | } else if (*cp == XA_INPUT_CONTROL) { |
1447 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | ||
1448 | - if (h3270.dbcs) | 1447 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1448 | + if (hSession->dbcs) | ||
1449 | efa_ic = (*(cp + 1) == 1); | 1449 | efa_ic = (*(cp + 1) == 1); |
1450 | cp++; | 1450 | cp++; |
1451 | } else { | 1451 | } else { |
1452 | - trace_ds(&h3270,"%s[unsupported]", see_efa(*cp, *(cp + 1))); | 1452 | + trace_ds(hSession,"%s[unsupported]", see_efa(*cp, *(cp + 1))); |
1453 | cp++; | 1453 | cp++; |
1454 | } | 1454 | } |
1455 | } | 1455 | } |
@@ -1469,25 +1469,25 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1469,25 +1469,25 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1469 | previous = ORDER; | 1469 | previous = ORDER; |
1470 | cp++; | 1470 | cp++; |
1471 | if (*cp == XA_FOREGROUND) { | 1471 | if (*cp == XA_FOREGROUND) { |
1472 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1472 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1473 | if (h3270.m3279) | 1473 | if (h3270.m3279) |
1474 | h3270.default_fg = *(cp + 1); | 1474 | h3270.default_fg = *(cp + 1); |
1475 | } else if (*cp == XA_BACKGROUND) { | 1475 | } else if (*cp == XA_BACKGROUND) { |
1476 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1476 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1477 | if (h3270.m3279) | 1477 | if (h3270.m3279) |
1478 | h3270.default_bg = *(cp + 1); | 1478 | h3270.default_bg = *(cp + 1); |
1479 | } else if (*cp == XA_HIGHLIGHTING) { | 1479 | } else if (*cp == XA_HIGHLIGHTING) { |
1480 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1480 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1481 | h3270.default_gr = *(cp + 1) & 0x0f; | 1481 | h3270.default_gr = *(cp + 1) & 0x0f; |
1482 | } else if (*cp == XA_ALL) { | 1482 | } else if (*cp == XA_ALL) { |
1483 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1483 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1484 | h3270.default_fg = 0; | 1484 | h3270.default_fg = 0; |
1485 | h3270.default_bg = 0; | 1485 | h3270.default_bg = 0; |
1486 | h3270.default_gr = 0; | 1486 | h3270.default_gr = 0; |
1487 | h3270.default_cs = 0; | 1487 | h3270.default_cs = 0; |
1488 | h3270.default_ic = 0; | 1488 | h3270.default_ic = 0; |
1489 | } else if (*cp == XA_CHARSET) { | 1489 | } else if (*cp == XA_CHARSET) { |
1490 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1490 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1491 | switch (*(cp + 1)) { | 1491 | switch (*(cp + 1)) { |
1492 | case 0xf1: | 1492 | case 0xf1: |
1493 | h3270.default_cs = CS_APL; | 1493 | h3270.default_cs = CS_APL; |
@@ -1500,13 +1500,13 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1500,13 +1500,13 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1500 | break; | 1500 | break; |
1501 | } | 1501 | } |
1502 | } else if (*cp == XA_INPUT_CONTROL) { | 1502 | } else if (*cp == XA_INPUT_CONTROL) { |
1503 | - trace_ds(&h3270,"%s", see_efa(*cp, *(cp + 1))); | 1503 | + trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1504 | if (*(cp + 1) == 1) | 1504 | if (*(cp + 1) == 1) |
1505 | h3270.default_ic = 1; | 1505 | h3270.default_ic = 1; |
1506 | else | 1506 | else |
1507 | h3270.default_ic = 0; | 1507 | h3270.default_ic = 0; |
1508 | } else | 1508 | } else |
1509 | - trace_ds(&h3270,"%s[unsupported]",see_efa(*cp, *(cp + 1))); | 1509 | + trace_ds(hSession,"%s[unsupported]",see_efa(*cp, *(cp + 1))); |
1510 | cp++; | 1510 | cp++; |
1511 | last_cmd = True; | 1511 | last_cmd = True; |
1512 | last_zpt = False; | 1512 | last_zpt = False; |
@@ -1630,7 +1630,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1630,7 +1630,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1630 | cp--; | 1630 | cp--; |
1631 | break; | 1631 | break; |
1632 | default: | 1632 | default: |
1633 | - trace_ds(&h3270," [invalid DBCS control character X'%02x%02x'; write aborted]",add_c1, add_c2); | 1633 | + trace_ds(hSession," [invalid DBCS control character X'%02x%02x'; write aborted]",add_c1, add_c2); |
1634 | ABORT_WRITEx; | 1634 | ABORT_WRITEx; |
1635 | break; | 1635 | break; |
1636 | } | 1636 | } |
@@ -1660,14 +1660,14 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1660,14 +1660,14 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1660 | default: /* enter character */ | 1660 | default: /* enter character */ |
1661 | if (*cp <= 0x3F) { | 1661 | if (*cp <= 0x3F) { |
1662 | END_TEXT("UnsupportedOrder"); | 1662 | END_TEXT("UnsupportedOrder"); |
1663 | - trace_ds(&h3270,"(%02X)", *cp); | 1663 | + trace_ds(hSession,"(%02X)", *cp); |
1664 | previous = ORDER; | 1664 | previous = ORDER; |
1665 | last_cmd = True; | 1665 | last_cmd = True; |
1666 | last_zpt = False; | 1666 | last_zpt = False; |
1667 | break; | 1667 | break; |
1668 | } | 1668 | } |
1669 | if (previous != TEXT) | 1669 | if (previous != TEXT) |
1670 | - trace_ds(&h3270," '"); | 1670 | + trace_ds(hSession," '"); |
1671 | previous = TEXT; | 1671 | previous = TEXT; |
1672 | #if defined(X3270_DBCS) /*[*/ | 1672 | #if defined(X3270_DBCS) /*[*/ |
1673 | add_dbcs = False; | 1673 | add_dbcs = False; |
@@ -1684,7 +1684,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1684,7 +1684,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1684 | add_c2 = *cp; | 1684 | add_c2 = *cp; |
1685 | if (add_c1 < 0x40 || add_c1 > 0xfe || | 1685 | if (add_c1 < 0x40 || add_c1 > 0xfe || |
1686 | add_c2 < 0x40 || add_c2 > 0xfe) { | 1686 | add_c2 < 0x40 || add_c2 > 0xfe) { |
1687 | - trace_ds(&h3270," [invalid DBCS character X'%02x%02x'; write aborted]",add_c1, add_c2); | 1687 | + trace_ds(hSession," [invalid DBCS character X'%02x%02x'; write aborted]",add_c1, add_c2); |
1688 | ABORT_WRITEx; | 1688 | ABORT_WRITEx; |
1689 | } | 1689 | } |
1690 | add_dbcs = True; | 1690 | add_dbcs = True; |
@@ -1693,7 +1693,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1693,7 +1693,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1693 | } else { | 1693 | } else { |
1694 | #endif /*]*/ | 1694 | #endif /*]*/ |
1695 | add_c1 = *cp; | 1695 | add_c1 = *cp; |
1696 | - trace_ds(&h3270,"%s", see_ebc(*cp)); | 1696 | + trace_ds(hSession,"%s", see_ebc(*cp)); |
1697 | #if defined(X3270_DBCS) /*[*/ | 1697 | #if defined(X3270_DBCS) /*[*/ |
1698 | } | 1698 | } |
1699 | #endif /*]*/ | 1699 | #endif /*]*/ |
@@ -1720,7 +1720,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1720,7 +1720,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1720 | } | 1720 | } |
1721 | set_formatted(hSession); | 1721 | set_formatted(hSession); |
1722 | END_TEXT0; | 1722 | END_TEXT0; |
1723 | - trace_ds(&h3270,"\n"); | 1723 | + trace_ds(hSession,"\n"); |
1724 | if (wcc_keyboard_restore) { | 1724 | if (wcc_keyboard_restore) { |
1725 | h3270.aid = AID_NO; | 1725 | h3270.aid = AID_NO; |
1726 | do_reset(&h3270,False); | 1726 | do_reset(&h3270,False); |
@@ -1773,7 +1773,7 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | @@ -1773,7 +1773,7 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | ||
1773 | * we display other control codes as spaces. | 1773 | * we display other control codes as spaces. |
1774 | */ | 1774 | */ |
1775 | 1775 | ||
1776 | - trace_ds(&h3270,"SSCP-LU data\n"); | 1776 | + trace_ds(hSession,"SSCP-LU data\n"); |
1777 | for (i = 0; i < buflen; cp++, i++) { | 1777 | for (i = 0; i < buflen; cp++, i++) { |
1778 | switch (*cp) { | 1778 | switch (*cp) { |
1779 | case FCORDER_NL: | 1779 | case FCORDER_NL: |
@@ -1797,7 +1797,7 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | @@ -1797,7 +1797,7 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | ||
1797 | /* Some hosts forget they're talking SSCP-LU. */ | 1797 | /* Some hosts forget they're talking SSCP-LU. */ |
1798 | cp++; | 1798 | cp++; |
1799 | i++; | 1799 | i++; |
1800 | - trace_ds(&h3270," StartField%s %s [translated to space]\n",rcba(hSession,hSession->buffer_addr), see_attr(*cp)); | 1800 | + trace_ds(hSession," StartField%s %s [translated to space]\n",rcba(hSession,hSession->buffer_addr), see_attr(*cp)); |
1801 | ctlr_add(hSession,hSession->buffer_addr, EBC_space, hSession->default_cs); | 1801 | ctlr_add(hSession,hSession->buffer_addr, EBC_space, hSession->default_cs); |
1802 | ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | 1802 | ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); |
1803 | ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | 1803 | ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); |
@@ -1807,12 +1807,12 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | @@ -1807,12 +1807,12 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) | ||
1807 | break; | 1807 | break; |
1808 | 1808 | ||
1809 | case ORDER_IC: | 1809 | case ORDER_IC: |
1810 | - trace_ds(&h3270," InsertCursor%s [ignored]\n",rcba(hSession,hSession->buffer_addr)); | 1810 | + trace_ds(hSession," InsertCursor%s [ignored]\n",rcba(hSession,hSession->buffer_addr)); |
1811 | break; | 1811 | break; |
1812 | 1812 | ||
1813 | case ORDER_SBA: | 1813 | case ORDER_SBA: |
1814 | // baddr = DECODE_BADDR(*(cp+1), *(cp+2)); | 1814 | // baddr = DECODE_BADDR(*(cp+1), *(cp+2)); |
1815 | - trace_ds(&h3270," SetBufferAddress%s [ignored]\n", rcba(hSession,DECODE_BADDR(*(cp+1), *(cp+2)))); | 1815 | + trace_ds(hSession," SetBufferAddress%s [ignored]\n", rcba(hSession,DECODE_BADDR(*(cp+1), *(cp+2)))); |
1816 | cp += 2; | 1816 | cp += 2; |
1817 | i += 2; | 1817 | i += 2; |
1818 | break; | 1818 | break; |
@@ -2148,7 +2148,7 @@ void ps_process(H3270 *hSession) | @@ -2148,7 +2148,7 @@ void ps_process(H3270 *hSession) | ||
2148 | /* magic field */ | 2148 | /* magic field */ |
2149 | hSession->ea_buf[1919].fa && FA_IS_SKIP(hSession->ea_buf[1919].fa)) | 2149 | hSession->ea_buf[1919].fa && FA_IS_SKIP(hSession->ea_buf[1919].fa)) |
2150 | { | 2150 | { |
2151 | - ft_cut_data(); | 2151 | + ft_cut_data(hSession); |
2152 | } | 2152 | } |
2153 | #endif | 2153 | #endif |
2154 | } | 2154 | } |
src/lib3270/ft_cut.c
@@ -119,57 +119,64 @@ static int xlate_buffered = 0; /* buffer count */ | @@ -119,57 +119,64 @@ static int xlate_buffered = 0; /* buffer count */ | ||
119 | static int xlate_buf_ix = 0; /* buffer index */ | 119 | static int xlate_buf_ix = 0; /* buffer index */ |
120 | static unsigned char xlate_buf[XLATE_NBUF]; /* buffer */ | 120 | static unsigned char xlate_buf[XLATE_NBUF]; /* buffer */ |
121 | 121 | ||
122 | -static void cut_control_code(void); | ||
123 | -static void cut_data_request(void); | ||
124 | -static void cut_retransmit(void); | ||
125 | -static void cut_data(void); | 122 | +static void cut_control_code(H3270 *hSession); |
123 | +static void cut_data_request(H3270 *hSession); | ||
124 | +static void cut_retransmit(H3270 *hSession); | ||
125 | +static void cut_data(H3270 *hSession); | ||
126 | 126 | ||
127 | -static void cut_ack(void); | ||
128 | -static void cut_abort(unsigned short code, const char *fmt, ...); | 127 | +static void cut_ack(H3270 *hSession); |
128 | +static void cut_abort(H3270 *hSession, unsigned short code, const char *fmt, ...) printflike(3,4); | ||
129 | 129 | ||
130 | static unsigned from6(unsigned char c); | 130 | static unsigned from6(unsigned char c); |
131 | static int xlate_getc(void); | 131 | static int xlate_getc(void); |
132 | 132 | ||
133 | -/* | ||
134 | - * Convert a buffer for uploading (host->local). Overwrites the buffer. | ||
135 | - * Returns the length of the converted data. | 133 | +/** |
134 | + * Convert a buffer for uploading (host->local). Overwrites the buffer. | ||
135 | + * | ||
136 | * If there is a conversion error, calls cut_abort() and returns -1. | 136 | * If there is a conversion error, calls cut_abort() and returns -1. |
137 | + * | ||
138 | + * @return the length of the converted data. | ||
137 | */ | 139 | */ |
138 | -static int | ||
139 | -upload_convert(unsigned char *buf, int len) | 140 | +static int upload_convert(H3270 *hSession, unsigned char *buf, int len) |
140 | { | 141 | { |
141 | unsigned char *ob0 = buf; | 142 | unsigned char *ob0 = buf; |
142 | unsigned char *ob = ob0; | 143 | unsigned char *ob = ob0; |
143 | 144 | ||
144 | - while (len--) { | 145 | + while (len--) |
146 | + { | ||
145 | unsigned char c = *buf++; | 147 | unsigned char c = *buf++; |
146 | char *ixp; | 148 | char *ixp; |
147 | int ix; | 149 | int ix; |
148 | // int oq = -1; | 150 | // int oq = -1; |
149 | 151 | ||
150 | retry: | 152 | retry: |
151 | - if (quadrant < 0) { | 153 | + if (quadrant < 0) |
154 | + { | ||
152 | /* Find the quadrant. */ | 155 | /* Find the quadrant. */ |
153 | - for (quadrant = 0; quadrant < NQ; quadrant++) { | 156 | + for (quadrant = 0; quadrant < NQ; quadrant++) |
157 | + { | ||
154 | if (c == conv[quadrant].selector) | 158 | if (c == conv[quadrant].selector) |
155 | break; | 159 | break; |
156 | } | 160 | } |
157 | - if (quadrant >= NQ) { | ||
158 | - cut_abort(SC_ABORT_XMIT, "%s", _("Data conversion error")); | 161 | + if (quadrant >= NQ) |
162 | + { | ||
163 | + cut_abort(hSession,SC_ABORT_XMIT, "%s", _("Data conversion error")); | ||
159 | return -1; | 164 | return -1; |
160 | } | 165 | } |
161 | continue; | 166 | continue; |
162 | } | 167 | } |
163 | 168 | ||
164 | /* Make sure it's in a valid range. */ | 169 | /* Make sure it's in a valid range. */ |
165 | - if (c < 0x40 || c > 0xf9) { | ||
166 | - cut_abort(SC_ABORT_XMIT, "%s", _("Data conversion error")); | 170 | + if (c < 0x40 || c > 0xf9) |
171 | + { | ||
172 | + cut_abort(hSession,SC_ABORT_XMIT, "%s", _("Data conversion error")); | ||
167 | return -1; | 173 | return -1; |
168 | } | 174 | } |
169 | 175 | ||
170 | /* Translate to a quadrant index. */ | 176 | /* Translate to a quadrant index. */ |
171 | ixp = strchr(alphas, ebc2asc[c]); | 177 | ixp = strchr(alphas, ebc2asc[c]); |
172 | - if (ixp == (char *)NULL) { | 178 | + if (ixp == (char *)NULL) |
179 | + { | ||
173 | /* Try a different quadrant. */ | 180 | /* Try a different quadrant. */ |
174 | // oq = quadrant; | 181 | // oq = quadrant; |
175 | quadrant = -1; | 182 | quadrant = -1; |
@@ -181,8 +188,8 @@ upload_convert(unsigned char *buf, int len) | @@ -181,8 +188,8 @@ upload_convert(unsigned char *buf, int len) | ||
181 | * See if it's mapped by that quadrant, handling NULLs | 188 | * See if it's mapped by that quadrant, handling NULLs |
182 | * specially. | 189 | * specially. |
183 | */ | 190 | */ |
184 | - if (quadrant != OTHER_2 && c != XLATE_NULL && | ||
185 | - !conv[quadrant].xlate[ix]) { | 191 | + if (quadrant != OTHER_2 && c != XLATE_NULL && !conv[quadrant].xlate[ix]) |
192 | + { | ||
186 | /* Try a different quadrant. */ | 193 | /* Try a different quadrant. */ |
187 | // oq = quadrant; | 194 | // oq = quadrant; |
188 | quadrant = -1; | 195 | quadrant = -1; |
@@ -266,25 +273,29 @@ download_convert(unsigned const char *buf, unsigned len, unsigned char *xobuf) | @@ -266,25 +273,29 @@ download_convert(unsigned const char *buf, unsigned len, unsigned char *xobuf) | ||
266 | * Main entry point from ctlr.c. | 273 | * Main entry point from ctlr.c. |
267 | * We have received what looks like an appropriate message from the host. | 274 | * We have received what looks like an appropriate message from the host. |
268 | */ | 275 | */ |
269 | -void | ||
270 | -ft_cut_data(void) | 276 | +void ft_cut_data(H3270 *hSession) |
271 | { | 277 | { |
272 | - switch (h3270.ea_buf[O_FRAME_TYPE].cc) { | ||
273 | - case FT_CONTROL_CODE: | ||
274 | - cut_control_code(); | 278 | + switch (hSession->ea_buf[O_FRAME_TYPE].cc) |
279 | + { | ||
280 | + case FT_CONTROL_CODE: | ||
281 | + cut_control_code(hSession); | ||
275 | break; | 282 | break; |
276 | - case FT_DATA_REQUEST: | ||
277 | - cut_data_request(); | 283 | + |
284 | + case FT_DATA_REQUEST: | ||
285 | + cut_data_request(hSession); | ||
278 | break; | 286 | break; |
279 | - case FT_RETRANSMIT: | ||
280 | - cut_retransmit(); | 287 | + |
288 | + case FT_RETRANSMIT: | ||
289 | + cut_retransmit(hSession); | ||
281 | break; | 290 | break; |
282 | - case FT_DATA: | ||
283 | - cut_data(); | 291 | + |
292 | + case FT_DATA: | ||
293 | + cut_data(hSession); | ||
284 | break; | 294 | break; |
285 | - default: | ||
286 | - trace_ds(&h3270,"< FT unknown 0x%02x\n", h3270.ea_buf[O_FRAME_TYPE].cc); | ||
287 | - cut_abort(SC_ABORT_XMIT, "%s", _("Unknown frame type from host")); | 295 | + |
296 | + default: | ||
297 | + trace_ds(hSession,"< FT unknown 0x%02x\n", hSession->ea_buf[O_FRAME_TYPE].cc); | ||
298 | + cut_abort(hSession,SC_ABORT_XMIT, "%s", _("Unknown frame type from host")); | ||
288 | break; | 299 | break; |
289 | } | 300 | } |
290 | } | 301 | } |
@@ -292,42 +303,42 @@ ft_cut_data(void) | @@ -292,42 +303,42 @@ ft_cut_data(void) | ||
292 | /* | 303 | /* |
293 | * Process a control code from the host. | 304 | * Process a control code from the host. |
294 | */ | 305 | */ |
295 | -static void | ||
296 | -cut_control_code(void) | 306 | +static void cut_control_code(H3270 *hSession) |
297 | { | 307 | { |
298 | unsigned short code; | 308 | unsigned short code; |
299 | char *buf; | 309 | char *buf; |
300 | char *bp; | 310 | char *bp; |
301 | int i; | 311 | int i; |
302 | 312 | ||
303 | - trace_ds(&h3270,"< FT CONTROL_CODE "); | ||
304 | - code = (h3270.ea_buf[O_CC_STATUS_CODE].cc << 8) | h3270.ea_buf[O_CC_STATUS_CODE + 1].cc; | 313 | + trace_ds(hSession,"< FT CONTROL_CODE "); |
314 | + code = (hSession->ea_buf[O_CC_STATUS_CODE].cc << 8) | hSession->ea_buf[O_CC_STATUS_CODE + 1].cc; | ||
315 | + | ||
305 | switch (code) | 316 | switch (code) |
306 | { | 317 | { |
307 | case SC_HOST_ACK: | 318 | case SC_HOST_ACK: |
308 | - trace_ds(&h3270,"HOST_ACK\n"); | 319 | + trace_ds(hSession,"HOST_ACK\n"); |
309 | cut_xfer_in_progress = True; | 320 | cut_xfer_in_progress = True; |
310 | expanded_length = 0; | 321 | expanded_length = 0; |
311 | quadrant = -1; | 322 | quadrant = -1; |
312 | xlate_buffered = 0; | 323 | xlate_buffered = 0; |
313 | - cut_ack(); | 324 | + cut_ack(hSession); |
314 | ft_running(NULL,True); | 325 | ft_running(NULL,True); |
315 | break; | 326 | break; |
316 | 327 | ||
317 | case SC_XFER_COMPLETE: | 328 | case SC_XFER_COMPLETE: |
318 | - trace_ds(&h3270,"XFER_COMPLETE\n"); | ||
319 | - cut_ack(); | 329 | + trace_ds(hSession,"XFER_COMPLETE\n"); |
330 | + cut_ack(hSession); | ||
320 | cut_xfer_in_progress = False; | 331 | cut_xfer_in_progress = False; |
321 | ft_complete(NULL,N_( "Complete" ) ); | 332 | ft_complete(NULL,N_( "Complete" ) ); |
322 | break; | 333 | break; |
323 | 334 | ||
324 | case SC_ABORT_FILE: | 335 | case SC_ABORT_FILE: |
325 | case SC_ABORT_XMIT: | 336 | case SC_ABORT_XMIT: |
326 | - trace_ds(&h3270,"ABORT\n"); | 337 | + trace_ds(hSession,"ABORT\n"); |
327 | cut_xfer_in_progress = False; | 338 | cut_xfer_in_progress = False; |
328 | - cut_ack(); | 339 | + cut_ack(hSession); |
329 | 340 | ||
330 | - if (lib3270_get_ft_state(&h3270) == FT_ABORT_SENT && saved_errmsg != CN) | 341 | + if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && saved_errmsg != CN) |
331 | { | 342 | { |
332 | buf = saved_errmsg; | 343 | buf = saved_errmsg; |
333 | saved_errmsg = CN; | 344 | saved_errmsg = CN; |
@@ -337,7 +348,7 @@ cut_control_code(void) | @@ -337,7 +348,7 @@ cut_control_code(void) | ||
337 | bp = buf = lib3270_malloc(81); | 348 | bp = buf = lib3270_malloc(81); |
338 | 349 | ||
339 | for (i = 0; i < 80; i++) | 350 | for (i = 0; i < 80; i++) |
340 | - *bp++ = ebc2asc[h3270.ea_buf[O_CC_MESSAGE + i].cc]; | 351 | + *bp++ = ebc2asc[hSession->ea_buf[O_CC_MESSAGE + i].cc]; |
341 | 352 | ||
342 | *bp-- = '\0'; | 353 | *bp-- = '\0'; |
343 | 354 | ||
@@ -358,8 +369,8 @@ cut_control_code(void) | @@ -358,8 +369,8 @@ cut_control_code(void) | ||
358 | break; | 369 | break; |
359 | 370 | ||
360 | default: | 371 | default: |
361 | - trace_ds(&h3270,"unknown 0x%04x\n", code); | ||
362 | - cut_abort(SC_ABORT_XMIT, "%s", _("Unknown FT control code from host")); | 372 | + trace_ds(hSession,"unknown 0x%04x\n", code); |
373 | + cut_abort(hSession,SC_ABORT_XMIT, "%s", _("Unknown FT control code from host")); | ||
363 | break; | 374 | break; |
364 | } | 375 | } |
365 | } | 376 | } |
@@ -367,80 +378,80 @@ cut_control_code(void) | @@ -367,80 +378,80 @@ cut_control_code(void) | ||
367 | /* | 378 | /* |
368 | * Process a data request from the host. | 379 | * Process a data request from the host. |
369 | */ | 380 | */ |
370 | -static void | ||
371 | -cut_data_request(void) | 381 | +static void cut_data_request(H3270 *hSession) |
372 | { | 382 | { |
373 | - unsigned char seq = h3270.ea_buf[O_DR_FRAME_SEQ].cc; | 383 | + unsigned char seq = hSession->ea_buf[O_DR_FRAME_SEQ].cc; |
374 | int count; | 384 | int count; |
375 | unsigned char cs; | 385 | unsigned char cs; |
376 | int c; | 386 | int c; |
377 | int i; | 387 | int i; |
378 | unsigned char attr; | 388 | unsigned char attr; |
379 | 389 | ||
380 | - trace_ds(&h3270,"< FT DATA_REQUEST %u\n", from6(seq)); | ||
381 | - if (lib3270_get_ft_state(&h3270) == FT_ABORT_WAIT) | 390 | + trace_ds(hSession,"< FT DATA_REQUEST %u\n", from6(seq)); |
391 | + if (lib3270_get_ft_state(hSession) == FT_ABORT_WAIT) | ||
382 | { | 392 | { |
383 | - cut_abort(SC_ABORT_FILE,"%s",N_("Transfer cancelled by user")); | 393 | + cut_abort(hSession,SC_ABORT_FILE,"%s", N_("Transfer cancelled by user") ); |
384 | return; | 394 | return; |
385 | } | 395 | } |
386 | 396 | ||
387 | /* Copy data into the screen buffer. */ | 397 | /* Copy data into the screen buffer. */ |
388 | count = 0; | 398 | count = 0; |
389 | while (count < O_UP_MAX && (c = xlate_getc()) != EOF) { | 399 | while (count < O_UP_MAX && (c = xlate_getc()) != EOF) { |
390 | - ctlr_add(&h3270,O_UP_DATA + count, c, 0); | 400 | + ctlr_add(hSession,O_UP_DATA + count, c, 0); |
391 | count++; | 401 | count++; |
392 | } | 402 | } |
393 | 403 | ||
394 | /* Check for errors. */ | 404 | /* Check for errors. */ |
395 | - if (ferror(((H3270FT *) h3270.ft)->local_file)) { | 405 | + if (ferror(((H3270FT *) hSession->ft)->local_file)) { |
396 | int j; | 406 | int j; |
397 | 407 | ||
398 | /* Clean out any data we may have written. */ | 408 | /* Clean out any data we may have written. */ |
399 | for (j = 0; j < count; j++) | 409 | for (j = 0; j < count; j++) |
400 | - ctlr_add(&h3270,O_UP_DATA + j, 0, 0); | 410 | + ctlr_add(hSession,O_UP_DATA + j, 0, 0); |
401 | 411 | ||
402 | /* Abort the transfer. */ | 412 | /* Abort the transfer. */ |
403 | - cut_abort(SC_ABORT_FILE,_( "Error \"%s\" reading from local file (rc=%d)" ), strerror(errno), errno); | 413 | + cut_abort(hSession,SC_ABORT_FILE,_( "Error \"%s\" reading from local file (rc=%d)" ), strerror(errno), errno); |
404 | return; | 414 | return; |
405 | } | 415 | } |
406 | 416 | ||
407 | /* Send special data for EOF. */ | 417 | /* Send special data for EOF. */ |
408 | - if (!count && feof(((H3270FT *) h3270.ft)->local_file)) { | ||
409 | - ctlr_add(&h3270,O_UP_DATA, EOF_DATA1, 0); | ||
410 | - ctlr_add(&h3270,O_UP_DATA+1, EOF_DATA2, 0); | 418 | + if (!count && feof(((H3270FT *) hSession->ft)->local_file)) |
419 | + { | ||
420 | + ctlr_add(hSession,O_UP_DATA, EOF_DATA1, 0); | ||
421 | + ctlr_add(hSession,O_UP_DATA+1, EOF_DATA2, 0); | ||
411 | count = 2; | 422 | count = 2; |
412 | } | 423 | } |
413 | 424 | ||
414 | /* Compute the other fields. */ | 425 | /* Compute the other fields. */ |
415 | - ctlr_add(&h3270,O_UP_FRAME_SEQ, seq, 0); | 426 | + ctlr_add(hSession,O_UP_FRAME_SEQ, seq, 0); |
416 | cs = 0; | 427 | cs = 0; |
417 | for (i = 0; i < count; i++) | 428 | for (i = 0; i < count; i++) |
418 | - cs ^= h3270.ea_buf[O_UP_DATA + i].cc; | ||
419 | - ctlr_add(&h3270,O_UP_CSUM, asc2ebc[(int)table6[cs & 0x3f]], 0); | ||
420 | - ctlr_add(&h3270,O_UP_LEN, asc2ebc[(int)table6[(count >> 6) & 0x3f]], 0); | ||
421 | - ctlr_add(&h3270,O_UP_LEN+1, asc2ebc[(int)table6[count & 0x3f]], 0); | 429 | + cs ^= hSession->ea_buf[O_UP_DATA + i].cc; |
430 | + | ||
431 | + ctlr_add(hSession,O_UP_CSUM, asc2ebc[(int)table6[cs & 0x3f]], 0); | ||
432 | + ctlr_add(hSession,O_UP_LEN, asc2ebc[(int)table6[(count >> 6) & 0x3f]], 0); | ||
433 | + ctlr_add(hSession,O_UP_LEN+1, asc2ebc[(int)table6[count & 0x3f]], 0); | ||
422 | 434 | ||
423 | /* XXX: Change the data field attribute so it doesn't display. */ | 435 | /* XXX: Change the data field attribute so it doesn't display. */ |
424 | - attr = h3270.ea_buf[O_DR_SF].fa; | 436 | + attr = hSession->ea_buf[O_DR_SF].fa; |
425 | attr = (attr & ~FA_INTENSITY) | FA_INT_ZERO_NSEL; | 437 | attr = (attr & ~FA_INTENSITY) | FA_INT_ZERO_NSEL; |
426 | - ctlr_add_fa(&h3270,O_DR_SF, attr, 0); | 438 | + ctlr_add_fa(hSession,O_DR_SF, attr, 0); |
427 | 439 | ||
428 | /* Send it up to the host. */ | 440 | /* Send it up to the host. */ |
429 | - trace_ds(&h3270,"> FT DATA %u\n", from6(seq)); | 441 | + trace_ds(hSession,"> FT DATA %u\n", from6(seq)); |
430 | ft_update_length(NULL); | 442 | ft_update_length(NULL); |
431 | expanded_length += count; | 443 | expanded_length += count; |
432 | 444 | ||
433 | - lib3270_enter(&h3270); | 445 | + lib3270_enter(hSession); |
434 | } | 446 | } |
435 | 447 | ||
436 | /* | 448 | /* |
437 | * (Improperly) process a retransmit from the host. | 449 | * (Improperly) process a retransmit from the host. |
438 | */ | 450 | */ |
439 | -static void | ||
440 | -cut_retransmit(void) | 451 | +static void cut_retransmit(H3270 *hSession) |
441 | { | 452 | { |
442 | - trace_ds(&h3270,"< FT RETRANSMIT\n"); | ||
443 | - cut_abort(SC_ABORT_XMIT,"%s",_("Transmission error")); | 453 | + trace_ds(hSession,"< FT RETRANSMIT\n"); |
454 | + cut_abort(hSession,SC_ABORT_XMIT,"%s",_("Transmission error")); | ||
444 | } | 455 | } |
445 | 456 | ||
446 | /* | 457 | /* |
@@ -461,63 +472,70 @@ from6(unsigned char c) | @@ -461,63 +472,70 @@ from6(unsigned char c) | ||
461 | /* | 472 | /* |
462 | * Process data from the host. | 473 | * Process data from the host. |
463 | */ | 474 | */ |
464 | -static void | ||
465 | -cut_data(void) | 475 | +static void cut_data(H3270 *hSession) |
466 | { | 476 | { |
467 | static unsigned char cvbuf[O_RESPONSE - O_DT_DATA]; | 477 | static unsigned char cvbuf[O_RESPONSE - O_DT_DATA]; |
468 | unsigned short raw_length; | 478 | unsigned short raw_length; |
469 | int conv_length; | 479 | int conv_length; |
470 | register int i; | 480 | register int i; |
471 | 481 | ||
472 | - trace_ds(&h3270,"< FT DATA\n"); | ||
473 | - if (((H3270FT *) h3270.ft)->state == LIB3270_FT_STATE_ABORT_WAIT) | 482 | + trace_ds(hSession,"< FT DATA\n"); |
483 | + if (((H3270FT *) hSession->ft)->state == LIB3270_FT_STATE_ABORT_WAIT) | ||
474 | { | 484 | { |
475 | - cut_abort(SC_ABORT_FILE,"%s",_("Transfer cancelled by user")); | 485 | + cut_abort(hSession,SC_ABORT_FILE,"%s",_("Transfer cancelled by user")); |
476 | return; | 486 | return; |
477 | } | 487 | } |
478 | 488 | ||
479 | /* Copy and convert the data. */ | 489 | /* Copy and convert the data. */ |
480 | - raw_length = from6(h3270.ea_buf[O_DT_LEN].cc) << 6 | | ||
481 | - from6(h3270.ea_buf[O_DT_LEN + 1].cc); | ||
482 | - if ((int)raw_length > O_RESPONSE - O_DT_DATA) { | ||
483 | - cut_abort(SC_ABORT_XMIT,"%s",_("Illegal frame length")); | 490 | + raw_length = from6(hSession->ea_buf[O_DT_LEN].cc) << 6 | |
491 | + from6(hSession->ea_buf[O_DT_LEN + 1].cc); | ||
492 | + | ||
493 | + if ((int)raw_length > O_RESPONSE - O_DT_DATA) | ||
494 | + { | ||
495 | + cut_abort(hSession,SC_ABORT_XMIT,"%s",_("Illegal frame length")); | ||
484 | return; | 496 | return; |
485 | } | 497 | } |
498 | + | ||
486 | for (i = 0; i < (int)raw_length; i++) | 499 | for (i = 0; i < (int)raw_length; i++) |
487 | - cvbuf[i] = h3270.ea_buf[O_DT_DATA + i].cc; | 500 | + cvbuf[i] = hSession->ea_buf[O_DT_DATA + i].cc; |
488 | 501 | ||
489 | - if (raw_length == 2 && cvbuf[0] == EOF_DATA1 && cvbuf[1] == EOF_DATA2) { | ||
490 | - trace_ds(&h3270,"< FT EOF\n"); | ||
491 | - cut_ack(); | 502 | + if (raw_length == 2 && cvbuf[0] == EOF_DATA1 && cvbuf[1] == EOF_DATA2) |
503 | + { | ||
504 | + trace_ds(hSession,"< FT EOF\n"); | ||
505 | + cut_ack(hSession); | ||
492 | return; | 506 | return; |
493 | } | 507 | } |
494 | - conv_length = upload_convert(cvbuf, raw_length); | 508 | + |
509 | + conv_length = upload_convert(hSession, cvbuf, raw_length); | ||
495 | if (conv_length < 0) | 510 | if (conv_length < 0) |
496 | return; | 511 | return; |
497 | 512 | ||
498 | /* Write it to the file. */ | 513 | /* Write it to the file. */ |
499 | - if (fwrite((char *)cvbuf, conv_length, 1, ((H3270FT *) h3270.ft)->local_file) == 0) { | ||
500 | - cut_abort(SC_ABORT_FILE,_( "Error \"%s\" writing to local file (rc=%d)" ),strerror(errno),errno); | ||
501 | - } else { | 514 | + if (fwrite((char *)cvbuf, conv_length, 1, ((H3270FT *) hSession->ft)->local_file) == 0) |
515 | + { | ||
516 | + cut_abort(hSession,SC_ABORT_FILE,_( "Error \"%s\" writing to local file (rc=%d)" ),strerror(errno),errno); | ||
517 | + } | ||
518 | + else | ||
519 | + { | ||
502 | ft_length += conv_length; | 520 | ft_length += conv_length; |
503 | ft_update_length(NULL); | 521 | ft_update_length(NULL); |
504 | - cut_ack(); | 522 | + cut_ack(hSession); |
505 | } | 523 | } |
506 | } | 524 | } |
507 | 525 | ||
508 | /* | 526 | /* |
509 | * Acknowledge a host command. | 527 | * Acknowledge a host command. |
510 | */ | 528 | */ |
511 | -static void cut_ack(void) | 529 | +static void cut_ack(H3270 *hSession) |
512 | { | 530 | { |
513 | - trace_ds(&h3270,"> FT ACK\n"); | ||
514 | - lib3270_enter(&h3270); | 531 | + trace_ds(hSession,"> FT ACK\n"); |
532 | + lib3270_enter(hSession); | ||
515 | } | 533 | } |
516 | 534 | ||
517 | /* | 535 | /* |
518 | * Abort a transfer in progress. | 536 | * Abort a transfer in progress. |
519 | */ | 537 | */ |
520 | -static void cut_abort(unsigned short reason, const char *fmt, ...) | 538 | +static void cut_abort(H3270 *hSession, unsigned short reason, const char *fmt, ...) |
521 | { | 539 | { |
522 | va_list args; | 540 | va_list args; |
523 | 541 | ||
@@ -530,13 +548,13 @@ static void cut_abort(unsigned short reason, const char *fmt, ...) | @@ -530,13 +548,13 @@ static void cut_abort(unsigned short reason, const char *fmt, ...) | ||
530 | va_end(args); | 548 | va_end(args); |
531 | 549 | ||
532 | /* Send the abort sequence. */ | 550 | /* Send the abort sequence. */ |
533 | - ctlr_add(&h3270,RO_FRAME_TYPE, RFT_CONTROL_CODE, 0); | ||
534 | - ctlr_add(&h3270,RO_FRAME_SEQ, h3270.ea_buf[O_DT_FRAME_SEQ].cc, 0); | ||
535 | - ctlr_add(&h3270,RO_REASON_CODE, HIGH8(reason), 0); | ||
536 | - ctlr_add(&h3270,RO_REASON_CODE+1, LOW8(reason), 0); | ||
537 | - trace_ds(&h3270,"> FT CONTROL_CODE ABORT\n"); | 551 | + ctlr_add(hSession,RO_FRAME_TYPE, RFT_CONTROL_CODE, 0); |
552 | + ctlr_add(hSession,RO_FRAME_SEQ, hSession->ea_buf[O_DT_FRAME_SEQ].cc, 0); | ||
553 | + ctlr_add(hSession,RO_REASON_CODE, HIGH8(reason), 0); | ||
554 | + ctlr_add(hSession,RO_REASON_CODE+1, LOW8(reason), 0); | ||
555 | + trace_ds(hSession,"> FT CONTROL_CODE ABORT\n"); | ||
538 | 556 | ||
539 | - lib3270_pfkey(&h3270,2); | 557 | + lib3270_pfkey(hSession,2); |
540 | 558 | ||
541 | /* Update the in-progress pop-up. */ | 559 | /* Update the in-progress pop-up. */ |
542 | ft_aborting(NULL); | 560 | ft_aborting(NULL); |
src/lib3270/ft_cutc.h
1 | /* | 1 | /* |
2 | - * Copyright 1996, 1999, 2000 by Paul Mattes. | ||
3 | - * Permission to use, copy, modify, and distribute this software and its | ||
4 | - * documentation for any purpose and without fee is hereby granted, | ||
5 | - * provided that the above copyright notice appear in all copies and that | ||
6 | - * both that copyright notice and this permission notice appear in | ||
7 | - * supporting documentation. | ||
8 | - * | ||
9 | - * x3270, c3270, s3270 and tcl3270 are distributed in the hope that they will | ||
10 | - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE | ||
12 | - * for more details. | 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como ft_cutc.c e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
13 | */ | 28 | */ |
14 | 29 | ||
15 | -LIB3270_INTERNAL void ft_cut_data(void); | 30 | +LIB3270_INTERNAL void ft_cut_data(H3270 *hSession); |
src/lib3270/telnet.c
@@ -882,56 +882,58 @@ static void net_connected(H3270 *session) | @@ -882,56 +882,58 @@ static void net_connected(H3270 *session) | ||
882 | * | 882 | * |
883 | * Called just after a sucessfull connect to setup tn3270 state. | 883 | * Called just after a sucessfull connect to setup tn3270 state. |
884 | * | 884 | * |
885 | - * @param session 3270 session to setup. | 885 | + * @param hSession 3270 session to setup. |
886 | * | 886 | * |
887 | */ | 887 | */ |
888 | -LIB3270_EXPORT void lib3270_setup_session(H3270 *session) | 888 | +LIB3270_EXPORT void lib3270_setup_session(H3270 *hSession) |
889 | { | 889 | { |
890 | - (void) memset((char *) session->myopts, 0, sizeof(session->myopts)); | ||
891 | - (void) memset((char *) session->hisopts, 0, sizeof(session->hisopts)); | 890 | + (void) memset((char *) hSession->myopts, 0, sizeof(hSession->myopts)); |
891 | + (void) memset((char *) hSession->hisopts, 0, sizeof(hSession->hisopts)); | ||
892 | 892 | ||
893 | #if defined(X3270_TN3270E) /*[*/ | 893 | #if defined(X3270_TN3270E) /*[*/ |
894 | - session->e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) | E_OPT(TN3270E_FUNC_RESPONSES) | E_OPT(TN3270E_FUNC_SYSREQ); | ||
895 | - session->e_xmit_seq = 0; | ||
896 | - session->response_required = TN3270E_RSF_NO_RESPONSE; | 894 | + hSession->e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) | E_OPT(TN3270E_FUNC_RESPONSES) | E_OPT(TN3270E_FUNC_SYSREQ); |
895 | + hSession->e_xmit_seq = 0; | ||
896 | + hSession->response_required = TN3270E_RSF_NO_RESPONSE; | ||
897 | #endif /*]*/ | 897 | #endif /*]*/ |
898 | 898 | ||
899 | #if defined(HAVE_LIBSSL) /*[*/ | 899 | #if defined(HAVE_LIBSSL) /*[*/ |
900 | need_tls_follows = False; | 900 | need_tls_follows = False; |
901 | #endif /*]*/ | 901 | #endif /*]*/ |
902 | - session->telnet_state = TNS_DATA; | ||
903 | - session->ibptr = session->ibuf; | 902 | + hSession->telnet_state = TNS_DATA; |
903 | + hSession->ibptr = hSession->ibuf; | ||
904 | 904 | ||
905 | /* clear statistics and flags */ | 905 | /* clear statistics and flags */ |
906 | - time(&session->ns_time); | ||
907 | - session->ns_brcvd = 0; | ||
908 | - session->ns_rrcvd = 0; | ||
909 | - session->ns_bsent = 0; | ||
910 | - session->ns_rsent = 0; | ||
911 | - session->syncing = 0; | ||
912 | - session->tn3270e_negotiated = 0; | ||
913 | - session->tn3270e_submode = E_NONE; | ||
914 | - session->tn3270e_bound = 0; | 906 | + time(&hSession->ns_time); |
907 | + hSession->ns_brcvd = 0; | ||
908 | + hSession->ns_rrcvd = 0; | ||
909 | + hSession->ns_bsent = 0; | ||
910 | + hSession->ns_rsent = 0; | ||
911 | + hSession->syncing = 0; | ||
912 | + hSession->tn3270e_negotiated = 0; | ||
913 | + hSession->tn3270e_submode = E_NONE; | ||
914 | + hSession->tn3270e_bound = 0; | ||
915 | 915 | ||
916 | - setup_lus(session); | 916 | + setup_lus(hSession); |
917 | 917 | ||
918 | - check_linemode(session,True); | 918 | + check_linemode(hSession,True); |
919 | 919 | ||
920 | /* write out the passthru hostname and port nubmer */ | 920 | /* write out the passthru hostname and port nubmer */ |
921 | - if (session->passthru_host) | 921 | + if (hSession->passthru_host) |
922 | { | 922 | { |
923 | - unsigned char *buffer = (unsigned char *) xs_buffer("%s %d\r\n", session->hostname, session->current_port); | ||
924 | - session->write(session, buffer, strlen((char *) buffer)); | 923 | + unsigned char *buffer = (unsigned char *) xs_buffer("%s %d\r\n", hSession->hostname, hSession->current_port); |
924 | + hSession->write(hSession, buffer, strlen((char *) buffer)); | ||
925 | lib3270_free(buffer); | 925 | lib3270_free(buffer); |
926 | - trace_ds(&h3270,"SENT HOSTNAME %s:%d\n", session->hostname, session->current_port); | 926 | + trace_ds(hSession,"SENT HOSTNAME %s:%d\n", hSession->hostname, hSession->current_port); |
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
930 | -/* | ||
931 | - * connection_complete | ||
932 | - * The connection appears to be complete (output is possible or input | ||
933 | - * appeared ready but recv() returned EWOULDBLOCK). Complete the | ||
934 | - * connection-completion processing. | 930 | +/** |
931 | + * Connection_complete. | ||
932 | + * | ||
933 | + * The connection appears to be complete (output is possible or input | ||
934 | + * appeared ready but recv() returned EWOULDBLOCK). Complete the | ||
935 | + * connection-completion processing. | ||
936 | + * | ||
935 | */ | 937 | */ |
936 | static void connection_complete(H3270 *session) | 938 | static void connection_complete(H3270 *session) |
937 | { | 939 | { |