Commit c9335c4e8b409635d6a06d608a27bc5c2a88aef3
1 parent
6788b80f
Exists in
master
and in
3 other branches
Ajustes para multi-sessão
Showing
8 changed files
with
316 additions
and
300 deletions
Show diff stats
ctlr.c
@@ -26,12 +26,11 @@ | @@ -26,12 +26,11 @@ | ||
26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | * licinio@bb.com.br (Licínio Luis Branco) | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | 28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | ||
30 | * | 29 | * |
31 | */ | 30 | */ |
32 | 31 | ||
33 | -/* | ||
34 | - * ctlr.c | 32 | +/** |
33 | + * @file | ||
35 | * This module handles interpretation of the 3270 data stream and | 34 | * This module handles interpretation of the 3270 data stream and |
36 | * maintenance of the 3270 device state. It was split out from | 35 | * maintenance of the 3270 device state. It was split out from |
37 | * screen.c, which handles X operations. | 36 | * screen.c, which handles X operations. |
@@ -75,11 +74,12 @@ static void ctlr_connect(H3270 *session, int ignored, void *dunno); | @@ -75,11 +74,12 @@ static void ctlr_connect(H3270 *session, int ignored, void *dunno); | ||
75 | static void ticking_stop(H3270 *session); | 74 | static void ticking_stop(H3270 *session); |
76 | static void ctlr_add_ic(H3270 *session, int baddr, unsigned char ic); | 75 | static void ctlr_add_ic(H3270 *session, int baddr, unsigned char ic); |
77 | 76 | ||
78 | -/* | 77 | +/** |
79 | * code_table is used to translate buffer addresses and attributes to the 3270 | 78 | * code_table is used to translate buffer addresses and attributes to the 3270 |
80 | * datastream representation | 79 | * datastream representation |
81 | */ | 80 | */ |
82 | -static unsigned char code_table[64] = { | 81 | +static const unsigned char code_table[64] = |
82 | +{ | ||
83 | 0x40, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, | 83 | 0x40, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, |
84 | 0xC8, 0xC9, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, | 84 | 0xC8, 0xC9, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, |
85 | 0x50, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, | 85 | 0x50, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, |
@@ -1248,7 +1248,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1248,7 +1248,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1248 | if (add_dbcs) | 1248 | if (add_dbcs) |
1249 | { | 1249 | { |
1250 | ctlr_add(hSession,hSession->buffer_addr, add_c2,hSession->default_cs); | 1250 | ctlr_add(hSession,hSession->buffer_addr, add_c2,hSession->default_cs); |
1251 | - ctlr_add_fg(hSession,hSession->buffer_addr, h3270.default_fg); | 1251 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); |
1252 | ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | 1252 | ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); |
1253 | ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | 1253 | ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); |
1254 | ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | 1254 | ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); |
@@ -1345,7 +1345,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1345,7 +1345,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1345 | trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1))); | 1345 | trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1))); |
1346 | cp++; | 1346 | cp++; |
1347 | if (hSession->m3279) | 1347 | if (hSession->m3279) |
1348 | - ctlr_add_fg(hSession,h3270.buffer_addr, *cp); | 1348 | + ctlr_add_fg(hSession,hSession->buffer_addr, *cp); |
1349 | } | 1349 | } |
1350 | else if (*cp == XA_BACKGROUND) | 1350 | else if (*cp == XA_BACKGROUND) |
1351 | { | 1351 | { |
@@ -1358,7 +1358,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1358,7 +1358,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1358 | { | 1358 | { |
1359 | trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1))); | 1359 | trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1))); |
1360 | cp++; | 1360 | cp++; |
1361 | - ctlr_add_gr(hSession,h3270.buffer_addr, *cp & 0x0f); | 1361 | + ctlr_add_gr(hSession,hSession->buffer_addr, *cp & 0x0f); |
1362 | } | 1362 | } |
1363 | else if (*cp == XA_CHARSET) | 1363 | else if (*cp == XA_CHARSET) |
1364 | { | 1364 | { |
@@ -1401,7 +1401,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1401,7 +1401,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1401 | case ORDER_SFE: /* start field extended */ | 1401 | case ORDER_SFE: /* start field extended */ |
1402 | END_TEXT("StartFieldExtended"); | 1402 | END_TEXT("StartFieldExtended"); |
1403 | if (previous != SBA) | 1403 | if (previous != SBA) |
1404 | - trace_ds(hSession,"%s",rcba(hSession,h3270.buffer_addr)); | 1404 | + trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr)); |
1405 | previous = ORDER; | 1405 | previous = ORDER; |
1406 | cp++; /* skip order */ | 1406 | cp++; /* skip order */ |
1407 | na = *cp; | 1407 | na = *cp; |
@@ -1421,12 +1421,12 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1421,12 +1421,12 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1421 | } else if (*cp == XA_FOREGROUND) { | 1421 | } else if (*cp == XA_FOREGROUND) { |
1422 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1422 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1423 | cp++; | 1423 | cp++; |
1424 | - if (h3270.m3279) | 1424 | + if (hSession->m3279) |
1425 | efa_fg = *cp; | 1425 | efa_fg = *cp; |
1426 | } else if (*cp == XA_BACKGROUND) { | 1426 | } else if (*cp == XA_BACKGROUND) { |
1427 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1427 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1428 | cp++; | 1428 | cp++; |
1429 | - if (h3270.m3279) | 1429 | + if (hSession->m3279) |
1430 | efa_bg = *cp; | 1430 | efa_bg = *cp; |
1431 | } else if (*cp == XA_HIGHLIGHTING) { | 1431 | } else if (*cp == XA_HIGHLIGHTING) { |
1432 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1432 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
@@ -1437,7 +1437,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1437,7 +1437,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1437 | cp++; | 1437 | cp++; |
1438 | if (*cp == 0xf1) | 1438 | if (*cp == 0xf1) |
1439 | efa_cs = CS_APL; | 1439 | efa_cs = CS_APL; |
1440 | - else if (h3270.dbcs && (*cp == 0xf8)) | 1440 | + else if (hSession->dbcs && (*cp == 0xf8)) |
1441 | efa_cs = CS_DBCS; | 1441 | efa_cs = CS_DBCS; |
1442 | else | 1442 | else |
1443 | efa_cs = CS_BASE; | 1443 | efa_cs = CS_BASE; |
@@ -1456,11 +1456,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1456,11 +1456,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1456 | } | 1456 | } |
1457 | if (!any_fa) | 1457 | if (!any_fa) |
1458 | START_FIELD(0); | 1458 | START_FIELD(0); |
1459 | - ctlr_add_cs(hSession,h3270.buffer_addr, efa_cs); | ||
1460 | - ctlr_add_fg(hSession,h3270.buffer_addr, efa_fg); | ||
1461 | - ctlr_add_bg(hSession,h3270.buffer_addr, efa_bg); | ||
1462 | - ctlr_add_gr(hSession,h3270.buffer_addr, efa_gr); | ||
1463 | - ctlr_add_ic(hSession,h3270.buffer_addr, efa_ic); | 1459 | + ctlr_add_cs(hSession,hSession->buffer_addr, efa_cs); |
1460 | + ctlr_add_fg(hSession,hSession->buffer_addr, efa_fg); | ||
1461 | + ctlr_add_bg(hSession,hSession->buffer_addr, efa_bg); | ||
1462 | + ctlr_add_gr(hSession,hSession->buffer_addr, efa_gr); | ||
1463 | + ctlr_add_ic(hSession,hSession->buffer_addr, efa_ic); | ||
1464 | INC_BA(hSession->buffer_addr); | 1464 | INC_BA(hSession->buffer_addr); |
1465 | last_cmd = True; | 1465 | last_cmd = True; |
1466 | last_zpt = False; | 1466 | last_zpt = False; |
@@ -1471,41 +1471,41 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1471,41 +1471,41 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1471 | cp++; | 1471 | cp++; |
1472 | if (*cp == XA_FOREGROUND) { | 1472 | if (*cp == XA_FOREGROUND) { |
1473 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1473 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1474 | - if (h3270.m3279) | ||
1475 | - h3270.default_fg = *(cp + 1); | 1474 | + if (hSession->m3279) |
1475 | + hSession->default_fg = *(cp + 1); | ||
1476 | } else if (*cp == XA_BACKGROUND) { | 1476 | } else if (*cp == XA_BACKGROUND) { |
1477 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1477 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1478 | - if (h3270.m3279) | ||
1479 | - h3270.default_bg = *(cp + 1); | 1478 | + if (hSession->m3279) |
1479 | + hSession->default_bg = *(cp + 1); | ||
1480 | } else if (*cp == XA_HIGHLIGHTING) { | 1480 | } else if (*cp == XA_HIGHLIGHTING) { |
1481 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1481 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1482 | - h3270.default_gr = *(cp + 1) & 0x0f; | 1482 | + hSession->default_gr = *(cp + 1) & 0x0f; |
1483 | } else if (*cp == XA_ALL) { | 1483 | } else if (*cp == XA_ALL) { |
1484 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1484 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1485 | - h3270.default_fg = 0; | ||
1486 | - h3270.default_bg = 0; | ||
1487 | - h3270.default_gr = 0; | ||
1488 | - h3270.default_cs = 0; | ||
1489 | - h3270.default_ic = 0; | 1485 | + hSession->default_fg = 0; |
1486 | + hSession->default_bg = 0; | ||
1487 | + hSession->default_gr = 0; | ||
1488 | + hSession->default_cs = 0; | ||
1489 | + hSession->default_ic = 0; | ||
1490 | } else if (*cp == XA_CHARSET) { | 1490 | } else if (*cp == XA_CHARSET) { |
1491 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1491 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1492 | switch (*(cp + 1)) { | 1492 | switch (*(cp + 1)) { |
1493 | case 0xf1: | 1493 | case 0xf1: |
1494 | - h3270.default_cs = CS_APL; | 1494 | + hSession->default_cs = CS_APL; |
1495 | break; | 1495 | break; |
1496 | case 0xf8: | 1496 | case 0xf8: |
1497 | - h3270.default_cs = CS_DBCS; | 1497 | + hSession->default_cs = CS_DBCS; |
1498 | break; | 1498 | break; |
1499 | default: | 1499 | default: |
1500 | - h3270.default_cs = CS_BASE; | 1500 | + hSession->default_cs = CS_BASE; |
1501 | break; | 1501 | break; |
1502 | } | 1502 | } |
1503 | } else if (*cp == XA_INPUT_CONTROL) { | 1503 | } else if (*cp == XA_INPUT_CONTROL) { |
1504 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); | 1504 | trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1))); |
1505 | if (*(cp + 1) == 1) | 1505 | if (*(cp + 1) == 1) |
1506 | - h3270.default_ic = 1; | 1506 | + hSession->default_ic = 1; |
1507 | else | 1507 | else |
1508 | - h3270.default_ic = 0; | 1508 | + hSession->default_ic = 0; |
1509 | } else | 1509 | } else |
1510 | trace_ds(hSession,"%s[unsupported]",see_efa(*cp, *(cp + 1))); | 1510 | trace_ds(hSession,"%s[unsupported]",see_efa(*cp, *(cp + 1))); |
1511 | cp++; | 1511 | cp++; |
@@ -1523,7 +1523,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1523,7 +1523,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1523 | END_TEXT(see_ebc(*cp)); | 1523 | END_TEXT(see_ebc(*cp)); |
1524 | previous = ORDER; | 1524 | previous = ORDER; |
1525 | d = ctlr_lookleft_state(buffer_addr, &why); | 1525 | d = ctlr_lookleft_state(buffer_addr, &why); |
1526 | - if (h3270.default_cs == CS_DBCS || d != DBCS_NONE) { | 1526 | + if (hSession->default_cs == CS_DBCS || d != DBCS_NONE) { |
1527 | ABORT_WRITE("invalid format control order in DBCS field"); | 1527 | ABORT_WRITE("invalid format control order in DBCS field"); |
1528 | } | 1528 | } |
1529 | ctlr_add(hSession,hSession->buffer_addr, *cp, hSession->default_cs); | 1529 | ctlr_add(hSession,hSession->buffer_addr, *cp, hSession->default_cs); |
@@ -1550,11 +1550,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1550,11 +1550,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1550 | } | 1550 | } |
1551 | /* All is well. */ | 1551 | /* All is well. */ |
1552 | previous = ORDER; | 1552 | previous = ORDER; |
1553 | - ctlr_add(hSession,h3270.buffer_addr, *cp, h3270.default_cs); | ||
1554 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1555 | - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); | ||
1556 | - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); | ||
1557 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1553 | + ctlr_add(hSession,hSession->buffer_addr, *cp, hSession->default_cs); |
1554 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1555 | + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | ||
1556 | + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | ||
1557 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1558 | INC_BA(hSession->buffer_addr); | 1558 | INC_BA(hSession->buffer_addr); |
1559 | last_cmd = True; | 1559 | last_cmd = True; |
1560 | last_zpt = False; | 1560 | last_zpt = False; |
@@ -1569,31 +1569,31 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1569,31 +1569,31 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1569 | if (d != DBCS_NONE && why == DBCS_FIELD) { | 1569 | if (d != DBCS_NONE && why == DBCS_FIELD) { |
1570 | ABORT_WRITE("SI in DBCS field"); | 1570 | ABORT_WRITE("SI in DBCS field"); |
1571 | } | 1571 | } |
1572 | - fa_addr = find_field_attribute(hSession,h3270.buffer_addr); | ||
1573 | - baddr = h3270.buffer_addr; | 1572 | + fa_addr = find_field_attribute(hSession,hSession->buffer_addr); |
1573 | + baddr = hSession->buffer_addr; | ||
1574 | DEC_BA(baddr); | 1574 | DEC_BA(baddr); |
1575 | while (!aborted && | 1575 | while (!aborted && |
1576 | ((fa_addr >= 0 && baddr != fa_addr) || | 1576 | ((fa_addr >= 0 && baddr != fa_addr) || |
1577 | - (fa_addr < 0 && baddr != h3270.rows*h3270.cols - 1))) { | ||
1578 | - if (h3270.ea_buf[baddr].cc == FCORDER_SI) { | 1577 | + (fa_addr < 0 && baddr != hSession->rows*hSession->cols - 1))) { |
1578 | + if (hSession->ea_buf[baddr].cc == FCORDER_SI) { | ||
1579 | ABORT_WRITE("double SI"); | 1579 | ABORT_WRITE("double SI"); |
1580 | } | 1580 | } |
1581 | - if (h3270.ea_buf[baddr].cc == FCORDER_SO) | 1581 | + if (hSession->ea_buf[baddr].cc == FCORDER_SO) |
1582 | break; | 1582 | break; |
1583 | DEC_BA(baddr); | 1583 | DEC_BA(baddr); |
1584 | } | 1584 | } |
1585 | if (aborted) | 1585 | if (aborted) |
1586 | break; | 1586 | break; |
1587 | - if (h3270.ea_buf[baddr].cc != FCORDER_SO) { | 1587 | + if (hSession->ea_buf[baddr].cc != FCORDER_SO) { |
1588 | ABORT_WRITE("SI without SO"); | 1588 | ABORT_WRITE("SI without SO"); |
1589 | } | 1589 | } |
1590 | /* All is well. */ | 1590 | /* All is well. */ |
1591 | previous = ORDER; | 1591 | previous = ORDER; |
1592 | - ctlr_add(hSession,h3270.buffer_addr, *cp, h3270.default_cs); | ||
1593 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1594 | - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); | ||
1595 | - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); | ||
1596 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1592 | + ctlr_add(hSession,hSession->buffer_addr, *cp, hSession->default_cs); |
1593 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1594 | + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | ||
1595 | + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | ||
1596 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1597 | INC_BA(hSession->buffer_addr); | 1597 | INC_BA(hSession->buffer_addr); |
1598 | last_cmd = True; | 1598 | last_cmd = True; |
1599 | last_zpt = False; | 1599 | last_zpt = False; |
@@ -1601,11 +1601,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1601,11 +1601,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1601 | case FCORDER_NULL: /* NULL or DBCS control char */ | 1601 | case FCORDER_NULL: /* NULL or DBCS control char */ |
1602 | previous = NULLCH; | 1602 | previous = NULLCH; |
1603 | add_dbcs = False; | 1603 | add_dbcs = False; |
1604 | - d = ctlr_lookleft_state(h3270.buffer_addr, &why); | 1604 | + d = ctlr_lookleft_state(hSession->buffer_addr, &why); |
1605 | if (d == DBCS_RIGHT) { | 1605 | if (d == DBCS_RIGHT) { |
1606 | ABORT_WRITE("NULL overwriting right half of DBCS character"); | 1606 | ABORT_WRITE("NULL overwriting right half of DBCS character"); |
1607 | } | 1607 | } |
1608 | - if (d != DBCS_NONE || h3270.default_cs == CS_DBCS) { | 1608 | + if (d != DBCS_NONE || hSession->default_cs == CS_DBCS) { |
1609 | add_c1 = EBC_null; | 1609 | add_c1 = EBC_null; |
1610 | cp++; | 1610 | cp++; |
1611 | if (cp >= buf + buflen) { | 1611 | if (cp >= buf + buflen) { |
@@ -1641,19 +1641,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1641,19 +1641,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1641 | END_TEXT("NULL"); | 1641 | END_TEXT("NULL"); |
1642 | add_c1 = *cp; | 1642 | add_c1 = *cp; |
1643 | } | 1643 | } |
1644 | - ctlr_add(hSession,h3270.buffer_addr, add_c1, h3270.default_cs); | ||
1645 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1646 | - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); | ||
1647 | - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); | ||
1648 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1644 | + ctlr_add(hSession,hSession->buffer_addr, add_c1, hSession->default_cs); |
1645 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1646 | + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | ||
1647 | + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | ||
1648 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1649 | INC_BA(hSession->buffer_addr); | 1649 | INC_BA(hSession->buffer_addr); |
1650 | if (add_dbcs) | 1650 | if (add_dbcs) |
1651 | { | 1651 | { |
1652 | - ctlr_add(hSession,h3270.buffer_addr, add_c2, h3270.default_cs); | ||
1653 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1654 | - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); | ||
1655 | - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); | ||
1656 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1652 | + ctlr_add(hSession,hSession->buffer_addr, add_c2, hSession->default_cs); |
1653 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1654 | + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | ||
1655 | + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | ||
1656 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1657 | INC_BA(hSession->buffer_addr); | 1657 | INC_BA(hSession->buffer_addr); |
1658 | } | 1658 | } |
1659 | last_cmd = False; | 1659 | last_cmd = False; |
@@ -1699,19 +1699,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1699,19 +1699,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1699 | #if defined(X3270_DBCS) /*[*/ | 1699 | #if defined(X3270_DBCS) /*[*/ |
1700 | } | 1700 | } |
1701 | #endif /*]*/ | 1701 | #endif /*]*/ |
1702 | - ctlr_add(hSession,h3270.buffer_addr, add_c1, h3270.default_cs); | ||
1703 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1704 | - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); | ||
1705 | - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); | ||
1706 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1702 | + ctlr_add(hSession,hSession->buffer_addr, add_c1, hSession->default_cs); |
1703 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1704 | + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); | ||
1705 | + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); | ||
1706 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1707 | INC_BA(hSession->buffer_addr); | 1707 | INC_BA(hSession->buffer_addr); |
1708 | #if defined(X3270_DBCS) /*[*/ | 1708 | #if defined(X3270_DBCS) /*[*/ |
1709 | if (add_dbcs) { | 1709 | if (add_dbcs) { |
1710 | - ctlr_add(h3270.buffer_addr, add_c2, h3270.default_cs); | ||
1711 | - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); | ||
1712 | - ctlr_add_bg(h3270.buffer_addr, h3270.default_bg); | ||
1713 | - ctlr_add_gr(h3270.buffer_addr, h3270.default_gr); | ||
1714 | - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); | 1710 | + ctlr_add(hSession->buffer_addr, add_c2, hSession->default_cs); |
1711 | + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); | ||
1712 | + ctlr_add_bg(hSession->buffer_addr, hSession->default_bg); | ||
1713 | + ctlr_add_gr(hSession->buffer_addr, hSession->default_gr); | ||
1714 | + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); | ||
1715 | INC_BA(hSession->buffer_addr); | 1715 | INC_BA(hSession->buffer_addr); |
1716 | } | 1716 | } |
1717 | #endif /*]*/ | 1717 | #endif /*]*/ |
@@ -1724,9 +1724,9 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1724,9 +1724,9 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
1724 | END_TEXT0; | 1724 | END_TEXT0; |
1725 | trace_ds(hSession,"\n"); | 1725 | trace_ds(hSession,"\n"); |
1726 | if (wcc_keyboard_restore) { | 1726 | if (wcc_keyboard_restore) { |
1727 | - h3270.aid = AID_NO; | 1727 | + hSession->aid = AID_NO; |
1728 | do_reset(hSession,False); | 1728 | do_reset(hSession,False); |
1729 | - } else if (h3270.kybdlock & KL_OIA_TWAIT) { | 1729 | + } else if (hSession->kybdlock & KL_OIA_TWAIT) { |
1730 | lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT); | 1730 | lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT); |
1731 | status_changed(hSession,LIB3270_STATUS_SYSWAIT); | 1731 | status_changed(hSession,LIB3270_STATUS_SYSWAIT); |
1732 | } | 1732 | } |
@@ -2431,7 +2431,7 @@ void ctlr_scroll(H3270 *hSession) | @@ -2431,7 +2431,7 @@ void ctlr_scroll(H3270 *hSession) | ||
2431 | /* Synchronize pending changes prior to this. */ | 2431 | /* Synchronize pending changes prior to this. */ |
2432 | 2432 | ||
2433 | /* Move ea_buf. */ | 2433 | /* Move ea_buf. */ |
2434 | - (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[h3270.cols],qty * sizeof(struct lib3270_ea)); | 2434 | + (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[hSession->cols],qty * sizeof(struct lib3270_ea)); |
2435 | 2435 | ||
2436 | /* Clear the last line. */ | 2436 | /* Clear the last line. */ |
2437 | (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct lib3270_ea)); | 2437 | (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct lib3270_ea)); |
globals.h
@@ -196,7 +196,7 @@ LIB3270_INTERNAL const char * build_rpq_revision; | @@ -196,7 +196,7 @@ LIB3270_INTERNAL const char * build_rpq_revision; | ||
196 | // LIB3270_INTERNAL char *local_encoding; | 196 | // LIB3270_INTERNAL char *local_encoding; |
197 | 197 | ||
198 | #if defined(X3270_DISPLAY) /*[*/ | 198 | #if defined(X3270_DISPLAY) /*[*/ |
199 | - LIB3270_INTERNAL char *locale_name; | 199 | +// LIB3270_INTERNAL char *locale_name; |
200 | #endif /*]*/ | 200 | #endif /*]*/ |
201 | 201 | ||
202 | #endif /*]*/ | 202 | #endif /*]*/ |
@@ -227,7 +227,7 @@ LIB3270_INTERNAL const char * build_rpq_revision; | @@ -227,7 +227,7 @@ LIB3270_INTERNAL const char * build_rpq_revision; | ||
227 | 227 | ||
228 | // LIB3270_INTERNAL Boolean shifted; | 228 | // LIB3270_INTERNAL Boolean shifted; |
229 | // LIB3270_INTERNAL Boolean ssl_host; | 229 | // LIB3270_INTERNAL Boolean ssl_host; |
230 | -LIB3270_INTERNAL Boolean *standard_font; | 230 | +// LIB3270_INTERNAL Boolean *standard_font; |
231 | // LIB3270_INTERNAL Boolean std_ds_host; | 231 | // LIB3270_INTERNAL Boolean std_ds_host; |
232 | // LIB3270_INTERNAL char *termtype; | 232 | // LIB3270_INTERNAL char *termtype; |
233 | // LIB3270_INTERNAL Widget toplevel; | 233 | // LIB3270_INTERNAL Widget toplevel; |
@@ -277,7 +277,7 @@ struct toggle_name { | @@ -277,7 +277,7 @@ struct toggle_name { | ||
277 | }; | 277 | }; |
278 | 278 | ||
279 | 279 | ||
280 | -/* translation lists */ | 280 | +/* translation lists */ /* |
281 | struct trans_list { | 281 | struct trans_list { |
282 | char *name; | 282 | char *name; |
283 | char *pathname; | 283 | char *pathname; |
@@ -286,6 +286,7 @@ struct trans_list { | @@ -286,6 +286,7 @@ struct trans_list { | ||
286 | struct trans_list *next; | 286 | struct trans_list *next; |
287 | }; | 287 | }; |
288 | LIB3270_INTERNAL struct trans_list *trans_list; | 288 | LIB3270_INTERNAL struct trans_list *trans_list; |
289 | +*/ | ||
289 | 290 | ||
290 | /* input key type */ | 291 | /* input key type */ |
291 | // enum keytype { KT_STD, KT_GE }; | 292 | // enum keytype { KT_STD, KT_GE }; |
iocalls.c
@@ -63,9 +63,9 @@ static void internal_remove_input(void *id); | @@ -63,9 +63,9 @@ static void internal_remove_input(void *id); | ||
63 | // static int internal_process_events(int block); | 63 | // static int internal_process_events(int block); |
64 | 64 | ||
65 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); | 65 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); |
66 | -static int internal_wait(int seconds); | 66 | +static int internal_wait(H3270 *hSession, int seconds); |
67 | 67 | ||
68 | -static int internal_event_dispatcher(int block); | 68 | +static int internal_event_dispatcher(H3270 *hSession, int block); |
69 | static void internal_ring_bell(H3270 *); | 69 | static void internal_ring_bell(H3270 *); |
70 | 70 | ||
71 | /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ | 71 | /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ |
@@ -96,10 +96,10 @@ static void internal_ring_bell(H3270 *); | @@ -96,10 +96,10 @@ static void internal_ring_bell(H3270 *); | ||
96 | static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) | 96 | static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) |
97 | = internal_callthread; | 97 | = internal_callthread; |
98 | 98 | ||
99 | - static int (*wait)(int seconds) | 99 | + static int (*wait)(H3270 *hSession, int seconds) |
100 | = internal_wait; | 100 | = internal_wait; |
101 | 101 | ||
102 | - static int (*event_dispatcher)(int wait) | 102 | + static int (*event_dispatcher)(H3270 *hSession,int wait) |
103 | = internal_event_dispatcher; | 103 | = internal_event_dispatcher; |
104 | 104 | ||
105 | static void (*ring_bell)(H3270 *) | 105 | static void (*ring_bell)(H3270 *) |
@@ -333,7 +333,7 @@ static void internal_remove_input(void *id) | @@ -333,7 +333,7 @@ static void internal_remove_input(void *id) | ||
333 | } | 333 | } |
334 | 334 | ||
335 | /* Event dispatcher. */ | 335 | /* Event dispatcher. */ |
336 | -static int internal_event_dispatcher(int block) | 336 | +static int internal_event_dispatcher(H3270 *hSession, int block) |
337 | { | 337 | { |
338 | #if defined(_WIN32) | 338 | #if defined(_WIN32) |
339 | HANDLE ha[MAX_HA]; | 339 | HANDLE ha[MAX_HA]; |
@@ -533,7 +533,7 @@ static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, | @@ -533,7 +533,7 @@ static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, | ||
533 | return 0; | 533 | return 0; |
534 | } | 534 | } |
535 | 535 | ||
536 | -static int internal_wait(int seconds) | 536 | +static int internal_wait(H3270 *hSession, int seconds) |
537 | { | 537 | { |
538 | time_t end; | 538 | time_t end; |
539 | 539 | ||
@@ -542,7 +542,7 @@ static int internal_wait(int seconds) | @@ -542,7 +542,7 @@ static int internal_wait(int seconds) | ||
542 | 542 | ||
543 | while(time(0) < end) | 543 | while(time(0) < end) |
544 | { | 544 | { |
545 | - lib3270_main_iterate(&h3270,1); | 545 | + lib3270_main_iterate(hSession,1); |
546 | } | 546 | } |
547 | 547 | ||
548 | return 0; | 548 | return 0; |
@@ -713,15 +713,15 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * | @@ -713,15 +713,15 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * | ||
713 | return 0; | 713 | return 0; |
714 | } | 714 | } |
715 | 715 | ||
716 | -LIB3270_EXPORT void lib3270_main_iterate(H3270 *session, int block) | 716 | +LIB3270_EXPORT void lib3270_main_iterate(H3270 *hSession, int block) |
717 | { | 717 | { |
718 | - CHECK_SESSION_HANDLE(session); | ||
719 | - event_dispatcher(block); | 718 | + CHECK_SESSION_HANDLE(hSession); |
719 | + event_dispatcher(hSession,block); | ||
720 | } | 720 | } |
721 | 721 | ||
722 | LIB3270_EXPORT int lib3270_wait(H3270 *hSession, int seconds) | 722 | LIB3270_EXPORT int lib3270_wait(H3270 *hSession, int seconds) |
723 | { | 723 | { |
724 | - wait(seconds); | 724 | + wait(hSession,seconds); |
725 | return 0; | 725 | return 0; |
726 | } | 726 | } |
727 | 727 | ||
@@ -731,7 +731,7 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) | @@ -731,7 +731,7 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) | ||
731 | 731 | ||
732 | while(time(0) < end) | 732 | while(time(0) < end) |
733 | { | 733 | { |
734 | - event_dispatcher(1); | 734 | + event_dispatcher(hSession,1); |
735 | 735 | ||
736 | if(hSession->oia_status == LIB3270_STATUS_BLANK) | 736 | if(hSession->oia_status == LIB3270_STATUS_BLANK) |
737 | return 0; | 737 | return 0; |
kybd.c
@@ -2130,7 +2130,7 @@ LIB3270_ACTION( eraseinput ) | @@ -2130,7 +2130,7 @@ LIB3270_ACTION( eraseinput ) | ||
2130 | f = True; | 2130 | f = True; |
2131 | } | 2131 | } |
2132 | if (!hSession->ea_buf[baddr].fa) { | 2132 | if (!hSession->ea_buf[baddr].fa) { |
2133 | - ctlr_add(&h3270,baddr, EBC_null, 0); | 2133 | + ctlr_add(hSession,baddr, EBC_null, 0); |
2134 | } | 2134 | } |
2135 | } while (!hSession->ea_buf[baddr].fa); | 2135 | } while (!hSession->ea_buf[baddr].fa); |
2136 | } else { /* skip protected */ | 2136 | } else { /* skip protected */ |
@@ -2417,7 +2417,7 @@ kybd_scroll_lock(Boolean lock) | @@ -2417,7 +2417,7 @@ kybd_scroll_lock(Boolean lock) | ||
2417 | if (lock) | 2417 | if (lock) |
2418 | kybdlock_set(KL_SCROLLED, "kybd_scroll_lock"); | 2418 | kybdlock_set(KL_SCROLLED, "kybd_scroll_lock"); |
2419 | else | 2419 | else |
2420 | - kybdlock_clr(&h3270, KL_SCROLLED, "kybd_scroll_lock"); | 2420 | + kybdlock_clr(hSession, KL_SCROLLED, "kybd_scroll_lock"); |
2421 | } */ | 2421 | } */ |
2422 | 2422 | ||
2423 | /* | 2423 | /* |
proxy.c
@@ -26,14 +26,15 @@ | @@ -26,14 +26,15 @@ | ||
26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | * licinio@bb.com.br (Licínio Luis Branco) | 27 | * licinio@bb.com.br (Licínio Luis Branco) |
28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | 28 | * kraucer@bb.com.br (Kraucer Fernandes Mazuco) |
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | ||
30 | * | 29 | * |
31 | */ | 30 | */ |
32 | 31 | ||
33 | 32 | ||
34 | -/* | ||
35 | - * proxy.c | 33 | +/** |
34 | + * @file proxy.c | ||
35 | + * | ||
36 | * This module implements various kinds of proxies. | 36 | * This module implements various kinds of proxies. |
37 | + * | ||
37 | */ | 38 | */ |
38 | 39 | ||
39 | #ifdef _WIN32 | 40 | #ifdef _WIN32 |
@@ -101,63 +102,65 @@ enum | @@ -101,63 +102,65 @@ enum | ||
101 | PT_MAX | 102 | PT_MAX |
102 | } proxytype_t; | 103 | } proxytype_t; |
103 | 104 | ||
104 | -/* proxy type names -- keep these in sync with proxytype_t! */ | ||
105 | -char *type_name[] = | ||
106 | -{ | ||
107 | - "unknown", | ||
108 | - "passthru", | ||
109 | - "HTTP", | ||
110 | - "TELNET", | ||
111 | - "SOCKS4", | ||
112 | - "SOCKS4A", | ||
113 | - "SOCKS5", | ||
114 | - "SOCKS5D" | ||
115 | -}; | ||
116 | - | ||
117 | #define PROXY_PASSTHRU "passthru" | 105 | #define PROXY_PASSTHRU "passthru" |
118 | #define PORT_PASSTHRU "3514" | 106 | #define PORT_PASSTHRU "3514" |
119 | 107 | ||
120 | -#define PROXY_HTTP "http" | ||
121 | -#define PORT_HTTP "3128" | 108 | +#define PROXY_HTTP "http" |
109 | +#define PORT_HTTP "3128" | ||
122 | 110 | ||
123 | #define PROXY_TELNET "telnet" | 111 | #define PROXY_TELNET "telnet" |
124 | 112 | ||
125 | #define PROXY_SOCKS4 "socks4" | 113 | #define PROXY_SOCKS4 "socks4" |
126 | -#define PORT_SOCKS4 "1080" | 114 | +#define PORT_SOCKS4 "1080" |
127 | 115 | ||
128 | #define PROXY_SOCKS4A "socks4a" | 116 | #define PROXY_SOCKS4A "socks4a" |
129 | #define PORT_SOCKS4A "1080" | 117 | #define PORT_SOCKS4A "1080" |
130 | 118 | ||
131 | #define PROXY_SOCKS5 "socks5" | 119 | #define PROXY_SOCKS5 "socks5" |
132 | -#define PORT_SOCKS5 "1080" | 120 | +#define PORT_SOCKS5 "1080" |
133 | 121 | ||
134 | #define PROXY_SOCKS5D "socks5d" | 122 | #define PROXY_SOCKS5D "socks5d" |
135 | #define PORT_SOCKS5D "1080" | 123 | #define PORT_SOCKS5D "1080" |
136 | 124 | ||
137 | -static int parse_host_port(char *s, char **phost, char **pport); | 125 | +static int parse_host_port(H3270 *hSession, char *s, char **phost, char **pport); |
138 | 126 | ||
139 | -static int proxy_passthru(int fd, char *host, unsigned short port); | ||
140 | -static int proxy_http(int fd, char *host, unsigned short port); | ||
141 | -static int proxy_telnet(int fd, char *host, unsigned short port); | ||
142 | -static int proxy_socks4(int fd, char *host, unsigned short port, int force_a); | ||
143 | -static int proxy_socks5(int fd, char *host, unsigned short port, int force_d); | 127 | +static int proxy_passthru(H3270 *hSession, int fd, char *host, unsigned short port); |
128 | +static int proxy_http(H3270 *hSession, int fd, char *host, unsigned short port); | ||
129 | +static int proxy_telnet(H3270 *hSession, int fd, char *host, unsigned short port); | ||
130 | +static int proxy_socks4(H3270 *hSession, int fd, char *host, unsigned short port, int force_a); | ||
131 | +static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port, int force_d); | ||
144 | 132 | ||
145 | 133 | ||
146 | -char * proxy_type_name(int type) | 134 | +const char * proxy_type_name(int type) |
147 | { | 135 | { |
148 | - if (type < 1 || type >= PT_MAX) | ||
149 | - return "unknown"; | 136 | + /* proxy type names -- keep these in sync with proxytype_t! */ |
137 | + const char *type_name[] = | ||
138 | + { | ||
139 | + "unknown", | ||
140 | + "passthru", | ||
141 | + "HTTP", | ||
142 | + "TELNET", | ||
143 | + "SOCKS4", | ||
144 | + "SOCKS4A", | ||
145 | + "SOCKS5", | ||
146 | + "SOCKS5D" | ||
147 | + }; | ||
148 | + | ||
149 | + | ||
150 | + if (type < 1 || type >= PT_MAX) | ||
151 | + return "unknown"; | ||
150 | else | 152 | else |
151 | - return type_name[type]; | 153 | + return type_name[type]; |
152 | } | 154 | } |
153 | 155 | ||
154 | -/* | 156 | +/** |
155 | * Resolve the type, hostname and port for a proxy. | 157 | * Resolve the type, hostname and port for a proxy. |
156 | - * Returns -1 for failure, 0 for no proxy, >0 (the proxy type) for success. | 158 | + * |
159 | + * @return -1 for failure, 0 for no proxy, >0 (the proxy type) for success. | ||
157 | */ | 160 | */ |
158 | -int proxy_setup(H3270 *session, char **phost, char **pport) | 161 | +int proxy_setup(H3270 *hSession, char **phost, char **pport) |
159 | { | 162 | { |
160 | - char * proxy = session->proxy; | 163 | + char * proxy = hSession->proxy; |
161 | char * colon; | 164 | char * colon; |
162 | int sl; | 165 | int sl; |
163 | 166 | ||
@@ -166,14 +169,14 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -166,14 +169,14 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
166 | 169 | ||
167 | if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) | 170 | if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) |
168 | { | 171 | { |
169 | - popup_an_error(session,_( "Invalid proxy syntax" ) ); | 172 | + popup_an_error(hSession,_( "Invalid proxy syntax" ) ); |
170 | return -1; | 173 | return -1; |
171 | } | 174 | } |
172 | 175 | ||
173 | sl = colon - proxy; | 176 | sl = colon - proxy; |
174 | if (sl == strlen(PROXY_PASSTHRU) && !strncasecmp(proxy, PROXY_PASSTHRU, sl)) | 177 | if (sl == strlen(PROXY_PASSTHRU) && !strncasecmp(proxy, PROXY_PASSTHRU, sl)) |
175 | { | 178 | { |
176 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 179 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
177 | return -1; | 180 | return -1; |
178 | 181 | ||
179 | if (*pport == CN) | 182 | if (*pport == CN) |
@@ -185,7 +188,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -185,7 +188,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
185 | if (sl == strlen(PROXY_HTTP) && !strncasecmp(proxy, PROXY_HTTP, sl)) | 188 | if (sl == strlen(PROXY_HTTP) && !strncasecmp(proxy, PROXY_HTTP, sl)) |
186 | { | 189 | { |
187 | 190 | ||
188 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 191 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
189 | return -1; | 192 | return -1; |
190 | if (*pport == CN) | 193 | if (*pport == CN) |
191 | *pport = NewString(PORT_HTTP); | 194 | *pport = NewString(PORT_HTTP); |
@@ -195,11 +198,11 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -195,11 +198,11 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
195 | if (sl == strlen(PROXY_TELNET) && !strncasecmp(proxy, PROXY_TELNET, sl)) | 198 | if (sl == strlen(PROXY_TELNET) && !strncasecmp(proxy, PROXY_TELNET, sl)) |
196 | { | 199 | { |
197 | 200 | ||
198 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 201 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
199 | return -1; | 202 | return -1; |
200 | if (*pport == CN) | 203 | if (*pport == CN) |
201 | { | 204 | { |
202 | - popup_an_error(session,_( "Must specify port for telnet proxy" ) ); | 205 | + popup_an_error(hSession,_( "Must specify port for telnet proxy" ) ); |
203 | return -1; | 206 | return -1; |
204 | } | 207 | } |
205 | return PT_TELNET; | 208 | return PT_TELNET; |
@@ -207,7 +210,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -207,7 +210,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
207 | 210 | ||
208 | if (sl == strlen(PROXY_SOCKS4) && !strncasecmp(proxy, PROXY_SOCKS4, sl)) | 211 | if (sl == strlen(PROXY_SOCKS4) && !strncasecmp(proxy, PROXY_SOCKS4, sl)) |
209 | { | 212 | { |
210 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 213 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
211 | return -1; | 214 | return -1; |
212 | 215 | ||
213 | if (*pport == CN) | 216 | if (*pport == CN) |
@@ -218,7 +221,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -218,7 +221,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
218 | 221 | ||
219 | if (sl == strlen(PROXY_SOCKS4A) && !strncasecmp(proxy, PROXY_SOCKS4A, sl)) | 222 | if (sl == strlen(PROXY_SOCKS4A) && !strncasecmp(proxy, PROXY_SOCKS4A, sl)) |
220 | { | 223 | { |
221 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 224 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
222 | return -1; | 225 | return -1; |
223 | 226 | ||
224 | if (*pport == CN) | 227 | if (*pport == CN) |
@@ -229,7 +232,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -229,7 +232,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
229 | 232 | ||
230 | if (sl == strlen(PROXY_SOCKS5) && !strncasecmp(proxy, PROXY_SOCKS5, sl)) | 233 | if (sl == strlen(PROXY_SOCKS5) && !strncasecmp(proxy, PROXY_SOCKS5, sl)) |
231 | { | 234 | { |
232 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 235 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
233 | return -1; | 236 | return -1; |
234 | 237 | ||
235 | if (*pport == CN) | 238 | if (*pport == CN) |
@@ -240,7 +243,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -240,7 +243,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
240 | 243 | ||
241 | if (sl == strlen(PROXY_SOCKS5D) && !strncasecmp(proxy, PROXY_SOCKS5D, sl)) | 244 | if (sl == strlen(PROXY_SOCKS5D) && !strncasecmp(proxy, PROXY_SOCKS5D, sl)) |
242 | { | 245 | { |
243 | - if (parse_host_port(colon + 1, phost, pport) < 0) | 246 | + if (parse_host_port(hSession, colon + 1, phost, pport) < 0) |
244 | return -1; | 247 | return -1; |
245 | 248 | ||
246 | if (*pport == CN) | 249 | if (*pport == CN) |
@@ -249,19 +252,20 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | @@ -249,19 +252,20 @@ int proxy_setup(H3270 *session, char **phost, char **pport) | ||
249 | return PT_SOCKS5D; | 252 | return PT_SOCKS5D; |
250 | } | 253 | } |
251 | 254 | ||
252 | - popup_an_error(session,"Invalid proxy type '%.*s'", sl, proxy); | 255 | + popup_an_error(hSession,_( "Invalid proxy type '%.*s'" ), sl, proxy); |
253 | 256 | ||
254 | return -1; | 257 | return -1; |
255 | } | 258 | } |
256 | 259 | ||
257 | -/* | 260 | +/** |
258 | * Parse host[:port] from a string. | 261 | * Parse host[:port] from a string. |
262 | + * | ||
259 | * 'host' can be in square brackets to allow numeric IPv6 addresses. | 263 | * 'host' can be in square brackets to allow numeric IPv6 addresses. |
260 | * Returns the host name and port name in heap memory. | 264 | * Returns the host name and port name in heap memory. |
261 | - * Returns -1 for failure, 0 for success. | 265 | + * |
266 | + * @return -1 for failure, 0 for success. | ||
262 | */ | 267 | */ |
263 | -static int | ||
264 | -parse_host_port(char *s, char **phost, char **pport) | 268 | +static int parse_host_port(H3270 *hSession, char *s, char **phost, char **pport) |
265 | { | 269 | { |
266 | char *colon; | 270 | char *colon; |
267 | char *hstart; | 271 | char *hstart; |
@@ -277,7 +281,7 @@ parse_host_port(char *s, char **phost, char **pport) | @@ -277,7 +281,7 @@ parse_host_port(char *s, char **phost, char **pport) | ||
277 | rbrack == s + 1 || | 281 | rbrack == s + 1 || |
278 | (*(rbrack + 1) != '\0' && *(rbrack + 1) != ':')) { | 282 | (*(rbrack + 1) != '\0' && *(rbrack + 1) != ':')) { |
279 | 283 | ||
280 | - popup_an_error(NULL,"Invalid proxy hostname syntax"); | 284 | + popup_an_error(hSession,_( "Invalid proxy hostname syntax")); |
281 | return -1; | 285 | return -1; |
282 | } | 286 | } |
283 | if (*(rbrack + 1) == ':') | 287 | if (*(rbrack + 1) == ':') |
@@ -289,7 +293,7 @@ parse_host_port(char *s, char **phost, char **pport) | @@ -289,7 +293,7 @@ parse_host_port(char *s, char **phost, char **pport) | ||
289 | hstart = s; | 293 | hstart = s; |
290 | colon = strchr(s, ':'); | 294 | colon = strchr(s, ':'); |
291 | if (colon == s) { | 295 | if (colon == s) { |
292 | - popup_an_error(NULL,"Invalid proxy hostname syntax"); | 296 | + popup_an_error(hSession,_("Invalid proxy hostname syntax")); |
293 | return -1; | 297 | return -1; |
294 | } | 298 | } |
295 | if (colon == NULL) | 299 | if (colon == NULL) |
@@ -311,37 +315,38 @@ parse_host_port(char *s, char **phost, char **pport) | @@ -311,37 +315,38 @@ parse_host_port(char *s, char **phost, char **pport) | ||
311 | return 0; | 315 | return 0; |
312 | } | 316 | } |
313 | 317 | ||
314 | -/* | 318 | +/** |
315 | * Negotiate with the proxy server. | 319 | * Negotiate with the proxy server. |
316 | - * Returns -1 for failure, 0 for success. | 320 | + * |
321 | + * @return -1 for failure, 0 for success. | ||
317 | */ | 322 | */ |
318 | -int | ||
319 | -proxy_negotiate(int type, int fd, char *host, unsigned short port) | 323 | +int proxy_negotiate(H3270 *hSession, int type, int fd, char *host, unsigned short port) |
320 | { | 324 | { |
321 | - switch (type) { | 325 | + switch (type) |
326 | + { | ||
322 | case PT_NONE: | 327 | case PT_NONE: |
323 | return 0; | 328 | return 0; |
324 | case PT_PASSTHRU: | 329 | case PT_PASSTHRU: |
325 | - return proxy_passthru(fd, host, port); | 330 | + return proxy_passthru(hSession, fd, host, port); |
326 | case PT_HTTP: | 331 | case PT_HTTP: |
327 | - return proxy_http(fd, host, port); | 332 | + return proxy_http(hSession, fd, host, port); |
328 | case PT_TELNET: | 333 | case PT_TELNET: |
329 | - return proxy_telnet(fd, host, port); | 334 | + return proxy_telnet(hSession, fd, host, port); |
330 | case PT_SOCKS4: | 335 | case PT_SOCKS4: |
331 | - return proxy_socks4(fd, host, port, 0); | 336 | + return proxy_socks4(hSession, fd, host, port, 0); |
332 | case PT_SOCKS4A: | 337 | case PT_SOCKS4A: |
333 | - return proxy_socks4(fd, host, port, 1); | 338 | + return proxy_socks4(hSession, fd, host, port, 1); |
334 | case PT_SOCKS5: | 339 | case PT_SOCKS5: |
335 | - return proxy_socks5(fd, host, port, 0); | 340 | + return proxy_socks5(hSession, fd, host, port, 0); |
336 | case PT_SOCKS5D: | 341 | case PT_SOCKS5D: |
337 | - return proxy_socks5(fd, host, port, 1); | 342 | + return proxy_socks5(hSession, fd, host, port, 1); |
338 | default: | 343 | default: |
339 | return -1; | 344 | return -1; |
340 | } | 345 | } |
341 | } | 346 | } |
342 | 347 | ||
343 | /* Sun PASSTHRU proxy. */ | 348 | /* Sun PASSTHRU proxy. */ |
344 | -static int proxy_passthru(int fd, char *host, unsigned short port) | 349 | +static int proxy_passthru(H3270 *hSession, int fd, char *host, unsigned short port) |
345 | { | 350 | { |
346 | char *buf; | 351 | char *buf; |
347 | 352 | ||
@@ -349,24 +354,24 @@ static int proxy_passthru(int fd, char *host, unsigned short port) | @@ -349,24 +354,24 @@ static int proxy_passthru(int fd, char *host, unsigned short port) | ||
349 | (void) sprintf(buf, "%s %u\r\n", host, port); | 354 | (void) sprintf(buf, "%s %u\r\n", host, port); |
350 | 355 | ||
351 | #if defined(X3270_TRACE) /*[*/ | 356 | #if defined(X3270_TRACE) /*[*/ |
352 | - trace_dsn(&h3270,"Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); | ||
353 | - trace_netdata(&h3270,'>', (unsigned char *)buf, (int) strlen(buf)); | 357 | + trace_dsn(hSession,"Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); |
358 | + trace_netdata(hSession,'>', (unsigned char *)buf, (int) strlen(buf)); | ||
354 | #endif /*]*/ | 359 | #endif /*]*/ |
355 | 360 | ||
356 | if (send(fd, buf, strlen(buf), 0) < 0) | 361 | if (send(fd, buf, strlen(buf), 0) < 0) |
357 | { | 362 | { |
358 | - popup_a_sockerr(&h3270,"Passthru Proxy: send error"); | 363 | + popup_a_sockerr(hSession,_( "Passthru Proxy: send error" )); |
359 | lib3270_free(buf); | 364 | lib3270_free(buf); |
360 | return -1; | 365 | return -1; |
361 | } | 366 | } |
362 | lib3270_free(buf); | 367 | lib3270_free(buf); |
363 | 368 | ||
364 | - return 0; | 369 | + return 0; |
365 | } | 370 | } |
366 | 371 | ||
367 | /* HTTP (RFC 2817 CONNECT tunnel) proxy. */ | 372 | /* HTTP (RFC 2817 CONNECT tunnel) proxy. */ |
368 | static int | 373 | static int |
369 | -proxy_http(int fd, char *host, unsigned short port) | 374 | +proxy_http(H3270 *hSession, int fd, char *host, unsigned short port) |
370 | { | 375 | { |
371 | char *buf; | 376 | char *buf; |
372 | char *colon; | 377 | char *colon; |
@@ -385,12 +390,13 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -385,12 +390,13 @@ proxy_http(int fd, char *host, unsigned short port) | ||
385 | port); | 390 | port); |
386 | 391 | ||
387 | #if defined(X3270_TRACE) /*[*/ | 392 | #if defined(X3270_TRACE) /*[*/ |
388 | - trace_dsn(&h3270,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); | ||
389 | - trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); | 393 | + trace_dsn(hSession,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); |
394 | + trace_netdata(hSession, '>', (unsigned char *)buf, (int) strlen(buf)); | ||
390 | #endif /*]*/ | 395 | #endif /*]*/ |
391 | 396 | ||
392 | - if (send(fd, buf, strlen(buf), 0) < 0) { | ||
393 | - popup_a_sockerr(NULL,"HTTP Proxy: send error"); | 397 | + if (send(fd, buf, strlen(buf), 0) < 0) |
398 | + { | ||
399 | + popup_a_sockerr(hSession,_( "HTTP Proxy: send error" )); | ||
394 | lib3270_free(buf); | 400 | lib3270_free(buf); |
395 | return -1; | 401 | return -1; |
396 | } | 402 | } |
@@ -402,24 +408,26 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -402,24 +408,26 @@ proxy_http(int fd, char *host, unsigned short port) | ||
402 | port); | 408 | port); |
403 | 409 | ||
404 | #if defined(X3270_TRACE) /*[*/ | 410 | #if defined(X3270_TRACE) /*[*/ |
405 | - trace_dsn(&h3270,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); | ||
406 | - trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); | 411 | + trace_dsn(hSession,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf); |
412 | + trace_netdata(hSession, '>', (unsigned char *)buf, (int) strlen(buf)); | ||
407 | #endif /*]*/ | 413 | #endif /*]*/ |
408 | 414 | ||
409 | - if (send(fd, buf, strlen(buf), 0) < 0) { | ||
410 | - popup_a_sockerr(NULL,"HTTP Proxy: send error"); | 415 | + if (send(fd, buf, strlen(buf), 0) < 0) |
416 | + { | ||
417 | + popup_a_sockerr(hSession,_( "HTTP Proxy: send error")); | ||
411 | lib3270_free(buf); | 418 | lib3270_free(buf); |
412 | return -1; | 419 | return -1; |
413 | } | 420 | } |
414 | 421 | ||
415 | strcpy(buf, "\r\n"); | 422 | strcpy(buf, "\r\n"); |
416 | #if defined(X3270_TRACE) /*[*/ | 423 | #if defined(X3270_TRACE) /*[*/ |
417 | - trace_dsn(&h3270,"HTTP Proxy: xmit ''\n"); | ||
418 | - trace_netdata(&h3270, '>', (unsigned char *)buf, strlen(buf)); | 424 | + trace_dsn(hSession,"HTTP Proxy: xmit ''\n"); |
425 | + trace_netdata(hSession, '>', (unsigned char *)buf, strlen(buf)); | ||
419 | #endif /*]*/ | 426 | #endif /*]*/ |
420 | 427 | ||
421 | - if (send(fd, buf, strlen(buf), 0) < 0) { | ||
422 | - popup_a_sockerr(NULL,"HTTP Proxy: send error"); | 428 | + if (send(fd, buf, strlen(buf), 0) < 0) |
429 | + { | ||
430 | + popup_a_sockerr(hSession,_( "HTTP Proxy: send error" )); | ||
423 | lib3270_free(buf); | 431 | lib3270_free(buf); |
424 | return -1; | 432 | return -1; |
425 | } | 433 | } |
@@ -429,8 +437,9 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -429,8 +437,9 @@ proxy_http(int fd, char *host, unsigned short port) | ||
429 | * Process the reply. | 437 | * Process the reply. |
430 | * Read a byte at a time until \n or EOF. | 438 | * Read a byte at a time until \n or EOF. |
431 | */ | 439 | */ |
432 | - for (;;) { | ||
433 | - fd_set rfds; | 440 | + for (;;) |
441 | + { | ||
442 | + fd_set rfds; | ||
434 | struct timeval tv; | 443 | struct timeval tv; |
435 | 444 | ||
436 | FD_ZERO(&rfds); | 445 | FD_ZERO(&rfds); |
@@ -438,29 +447,30 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -438,29 +447,30 @@ proxy_http(int fd, char *host, unsigned short port) | ||
438 | tv.tv_sec = 15; | 447 | tv.tv_sec = 15; |
439 | tv.tv_usec = 0; | 448 | tv.tv_usec = 0; |
440 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | 449 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { |
441 | - popup_an_error(NULL,"HTTP Proxy: server timeout"); | 450 | + popup_an_error(hSession,_( "HTTP Proxy: server timeout" )); |
442 | #if defined(X3270_TRACE) /*[*/ | 451 | #if defined(X3270_TRACE) /*[*/ |
443 | if (nread) | 452 | if (nread) |
444 | - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); | 453 | + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread); |
445 | #endif /*]*/ | 454 | #endif /*]*/ |
446 | return -1; | 455 | return -1; |
447 | } | 456 | } |
448 | 457 | ||
449 | nr = recv(fd, &rbuf[nread], 1, 0); | 458 | nr = recv(fd, &rbuf[nread], 1, 0); |
450 | if (nr < 0) { | 459 | if (nr < 0) { |
451 | - popup_a_sockerr(NULL,"HTTP Proxy: receive error"); | 460 | + popup_a_sockerr(hSession,_( "HTTP Proxy: receive error" )); |
452 | #if defined(X3270_TRACE) /*[*/ | 461 | #if defined(X3270_TRACE) /*[*/ |
453 | if (nread) | 462 | if (nread) |
454 | - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); | 463 | + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread); |
455 | #endif /*]*/ | 464 | #endif /*]*/ |
456 | return -1; | 465 | return -1; |
457 | } | 466 | } |
458 | - if (nr == 0) { | 467 | + if (nr == 0) |
468 | + { | ||
459 | #if defined(X3270_TRACE) /*[*/ | 469 | #if defined(X3270_TRACE) /*[*/ |
460 | if (nread) | 470 | if (nread) |
461 | - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); | 471 | + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread); |
462 | #endif /*]*/ | 472 | #endif /*]*/ |
463 | - popup_an_error(NULL,"HTTP Proxy: unexpected EOF"); | 473 | + popup_an_error(hSession,_( "HTTP Proxy: unexpected EOF" )); |
464 | return -1; | 474 | return -1; |
465 | } | 475 | } |
466 | if (rbuf[nread] == '\r') | 476 | if (rbuf[nread] == '\r') |
@@ -475,18 +485,18 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -475,18 +485,18 @@ proxy_http(int fd, char *host, unsigned short port) | ||
475 | rbuf[nread] = '\0'; | 485 | rbuf[nread] = '\0'; |
476 | 486 | ||
477 | #if defined(X3270_TRACE) /*[*/ | 487 | #if defined(X3270_TRACE) /*[*/ |
478 | - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); | ||
479 | - trace_dsn(&h3270,"HTTP Proxy: recv '%s'\n", rbuf); | 488 | + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread); |
489 | + trace_dsn(hSession,"HTTP Proxy: recv '%s'\n", rbuf); | ||
480 | #endif /*]*/ | 490 | #endif /*]*/ |
481 | 491 | ||
482 | if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN) | 492 | if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN) |
483 | { | 493 | { |
484 | - popup_an_error(&h3270,"HTTP Proxy: unrecognized reply"); | 494 | + popup_an_error(hSession,_( "HTTP Proxy: unrecognized reply" )); |
485 | return -1; | 495 | return -1; |
486 | } | 496 | } |
487 | if (*(space + 1) != '2') | 497 | if (*(space + 1) != '2') |
488 | { | 498 | { |
489 | - popup_an_error(&h3270,"HTTP Proxy: CONNECT failed:\n%s", rbuf); | 499 | + popup_an_error(hSession,_( "HTTP Proxy: CONNECT failed:\n%s"), rbuf); |
490 | return -1; | 500 | return -1; |
491 | } | 501 | } |
492 | 502 | ||
@@ -495,7 +505,7 @@ proxy_http(int fd, char *host, unsigned short port) | @@ -495,7 +505,7 @@ proxy_http(int fd, char *host, unsigned short port) | ||
495 | 505 | ||
496 | /* TELNET proxy. */ | 506 | /* TELNET proxy. */ |
497 | static int | 507 | static int |
498 | -proxy_telnet(int fd, char *host, unsigned short port) | 508 | +proxy_telnet(H3270 *hSession, int fd, char *host, unsigned short port) |
499 | { | 509 | { |
500 | char *buf; | 510 | char *buf; |
501 | 511 | ||
@@ -503,13 +513,13 @@ proxy_telnet(int fd, char *host, unsigned short port) | @@ -503,13 +513,13 @@ proxy_telnet(int fd, char *host, unsigned short port) | ||
503 | (void) sprintf(buf, "connect %s %u\r\n", host, port); | 513 | (void) sprintf(buf, "connect %s %u\r\n", host, port); |
504 | 514 | ||
505 | #if defined(X3270_TRACE) /*[*/ | 515 | #if defined(X3270_TRACE) /*[*/ |
506 | - trace_dsn(&h3270,"TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); | ||
507 | - trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); | 516 | + trace_dsn(hSession,"TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf); |
517 | + trace_netdata(hSession, '>', (unsigned char *)buf, (int) strlen(buf)); | ||
508 | #endif /*]*/ | 518 | #endif /*]*/ |
509 | 519 | ||
510 | if (send(fd, buf, strlen(buf), 0) < 0) | 520 | if (send(fd, buf, strlen(buf), 0) < 0) |
511 | { | 521 | { |
512 | - popup_a_sockerr(&h3270,"TELNET Proxy: send error"); | 522 | + popup_a_sockerr(hSession,_( "TELNET Proxy: send error")); |
513 | lib3270_free(buf); | 523 | lib3270_free(buf); |
514 | return -1; | 524 | return -1; |
515 | } | 525 | } |
@@ -520,19 +530,19 @@ proxy_telnet(int fd, char *host, unsigned short port) | @@ -520,19 +530,19 @@ proxy_telnet(int fd, char *host, unsigned short port) | ||
520 | 530 | ||
521 | /* SOCKS version 4 proxy. */ | 531 | /* SOCKS version 4 proxy. */ |
522 | #if defined(HAVE_GETADDRINFO) | 532 | #if defined(HAVE_GETADDRINFO) |
523 | -static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | 533 | +static int proxy_socks4(H3270 *hSession, int fd, char *host, unsigned short port, int force_a) |
524 | { | 534 | { |
525 | - popup_an_error(NULL,"%s", _( "Unsupported socks 4 proxy" ) ); | 535 | + popup_an_error(hSession,"%s", _( "Unsupported socks 4 proxy" ) ); |
526 | return 0; | 536 | return 0; |
527 | } | 537 | } |
528 | #else | 538 | #else |
529 | -static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | 539 | +static int proxy_socks4(H3270 *hSession, int fd, char *host, unsigned short port, int force_a) |
530 | { | 540 | { |
531 | - struct hostent *hp; | 541 | + struct hostent *hp; |
532 | struct in_addr ipaddr; | 542 | struct in_addr ipaddr; |
533 | int use_4a = 0; | 543 | int use_4a = 0; |
534 | char *user; | 544 | char *user; |
535 | - char *buf; | 545 | + char *buf; |
536 | char *s; | 546 | char *s; |
537 | char rbuf[8]; | 547 | char rbuf[8]; |
538 | int nr; | 548 | int nr; |
@@ -578,13 +588,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -578,13 +588,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
578 | s += strlen(host) + 1; | 588 | s += strlen(host) + 1; |
579 | 589 | ||
580 | #if defined(X3270_TRACE) /*[*/ | 590 | #if defined(X3270_TRACE) /*[*/ |
581 | - trace_dsn(&h3270,"SOCKS4 Proxy: version 4 connect port %u address 0.0.0.1 user '%s' host '%s'\n",port, user, host); | ||
582 | - trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf); | 591 | + trace_dsn(hSession,"SOCKS4 Proxy: version 4 connect port %u address 0.0.0.1 user '%s' host '%s'\n",port, user, host); |
592 | + trace_netdata(hSession,'>', (unsigned char *)buf, s - buf); | ||
583 | #endif /*]*/ | 593 | #endif /*]*/ |
584 | 594 | ||
585 | if (send(fd, buf, s - buf, 0) < 0) | 595 | if (send(fd, buf, s - buf, 0) < 0) |
586 | { | 596 | { |
587 | - popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error"); | 597 | + popup_a_sockerr(hSession,_( "SOCKS4 Proxy: send error" )); |
588 | lib3270_free(buf); | 598 | lib3270_free(buf); |
589 | return -1; | 599 | return -1; |
590 | } | 600 | } |
@@ -603,14 +613,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -603,14 +613,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
603 | s += strlen(user) + 1; | 613 | s += strlen(user) + 1; |
604 | 614 | ||
605 | #if defined(X3270_TRACE) /*[*/ | 615 | #if defined(X3270_TRACE) /*[*/ |
606 | - trace_dsn(&h3270,"SOCKS4 Proxy: xmit version 4 connect port %u address %s user '%s'\n",port, inet_ntoa(ipaddr), user); | ||
607 | - trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf); | 616 | + trace_dsn(hSession,_( "SOCKS4 Proxy: xmit version 4 connect port %u address %s user '%s'\n"),port, inet_ntoa(ipaddr), user); |
617 | + trace_netdata(hSession,'>', (unsigned char *)buf, s - buf); | ||
608 | #endif /*]*/ | 618 | #endif /*]*/ |
609 | 619 | ||
610 | if (send(fd, buf, s - buf, 0) < 0) | 620 | if (send(fd, buf, s - buf, 0) < 0) |
611 | { | 621 | { |
612 | lib3270_free(buf); | 622 | lib3270_free(buf); |
613 | - popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error"); | 623 | + popup_a_sockerr(hSession,_("SOCKS4 Proxy: send error")); |
614 | return -1; | 624 | return -1; |
615 | } | 625 | } |
616 | lib3270_free(buf); | 626 | lib3270_free(buf); |
@@ -628,50 +638,55 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -628,50 +638,55 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
628 | FD_SET(fd, &rfds); | 638 | FD_SET(fd, &rfds); |
629 | tv.tv_sec = 15; | 639 | tv.tv_sec = 15; |
630 | tv.tv_usec = 0; | 640 | tv.tv_usec = 0; |
631 | - if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | ||
632 | - popup_an_error(NULL,"SOCKS4 Proxy: server timeout"); | 641 | + if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) |
642 | + { | ||
643 | + popup_an_error(hSession,_("SOCKS4 Proxy: server timeout")); | ||
633 | return -1; | 644 | return -1; |
634 | } | 645 | } |
635 | 646 | ||
636 | - nr = recv(fd, &rbuf[nread], 1, 0); | ||
637 | - if (nr < 0) { | ||
638 | - popup_a_sockerr(NULL,"SOCKS4 Proxy: receive error"); | 647 | + nr = recv(fd, &rbuf[nread], 1, 0); |
648 | + | ||
649 | + if (nr < 0) | ||
650 | + { | ||
651 | + popup_a_sockerr(hSession,_("SOCKS4 Proxy: receive error")); | ||
639 | return -1; | 652 | return -1; |
640 | } | 653 | } |
641 | if (nr == 0) | 654 | if (nr == 0) |
642 | - break; | 655 | + break; |
656 | + | ||
643 | if (++nread >= sizeof(rbuf)) | 657 | if (++nread >= sizeof(rbuf)) |
644 | - break; | 658 | + break; |
645 | } | 659 | } |
646 | 660 | ||
647 | #if defined(X3270_TRACE) /*[*/ | 661 | #if defined(X3270_TRACE) /*[*/ |
648 | - trace_netdata(&h3270,'<', (unsigned char *)rbuf, nread); | 662 | + trace_netdata(hSession,'<', (unsigned char *)rbuf, nread); |
649 | if (use_4a) | 663 | if (use_4a) |
650 | { | 664 | { |
651 | struct in_addr a; | 665 | struct in_addr a; |
652 | 666 | ||
653 | rport = (rbuf[2] << 8) | rbuf[3]; | 667 | rport = (rbuf[2] << 8) | rbuf[3]; |
654 | memcpy(&a, &rbuf[4], 4); | 668 | memcpy(&a, &rbuf[4], 4); |
655 | - trace_dsn(&h3270,"SOCKS4 Proxy: recv status 0x%02x port %u address %s\n",rbuf[1],rport,inet_ntoa(a)); | 669 | + trace_dsn(hSession,_("SOCKS4 Proxy: recv status 0x%02x port %u address %s\n"),rbuf[1],rport,inet_ntoa(a)); |
656 | 670 | ||
657 | } else | 671 | } else |
658 | - trace_dsn(&h3270,"SOCKS4 Proxy: recv status 0x%02x\n", rbuf[1]); | 672 | + trace_dsn(hSession,_("SOCKS4 Proxy: recv status 0x%02x\n"), rbuf[1]); |
659 | #endif /*]*/ | 673 | #endif /*]*/ |
660 | 674 | ||
661 | - switch (rbuf[1]) { | 675 | + switch (rbuf[1]) |
676 | + { | ||
662 | case 0x5a: | 677 | case 0x5a: |
663 | break; | 678 | break; |
664 | case 0x5b: | 679 | case 0x5b: |
665 | - popup_an_error(&h3270,"SOCKS4 Proxy: request rejected or failed"); | 680 | + popup_an_error(hSession,_("SOCKS4 Proxy: request rejected or failed")); |
666 | return -1; | 681 | return -1; |
667 | case 0x5c: | 682 | case 0x5c: |
668 | - popup_an_error(&h3270,"SOCKS4 Proxy: client is not reachable"); | 683 | + popup_an_error(hSession,_("SOCKS4 Proxy: client is not reachable")); |
669 | return -1; | 684 | return -1; |
670 | case 0x5d: | 685 | case 0x5d: |
671 | - popup_an_error(&h3270,"SOCKS4 Proxy: userid error"); | 686 | + popup_an_error(hSession,_("SOCKS4 Proxy: userid error")); |
672 | return -1; | 687 | return -1; |
673 | default: | 688 | default: |
674 | - popup_an_error(&h3270,"SOCKS4 Proxy: unknown status 0x%02x",rbuf[1]); | 689 | + popup_an_error(hSession,_("SOCKS4 Proxy: unknown status 0x%02x",rbuf[1])); |
675 | return -1; | 690 | return -1; |
676 | } | 691 | } |
677 | 692 | ||
@@ -680,8 +695,7 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | @@ -680,8 +695,7 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) | ||
680 | #endif // HAVE_GETADDRINFO | 695 | #endif // HAVE_GETADDRINFO |
681 | 696 | ||
682 | /* SOCKS version 5 (RFC 1928) proxy. */ | 697 | /* SOCKS version 5 (RFC 1928) proxy. */ |
683 | -static int | ||
684 | -proxy_socks5(int fd, char *host, unsigned short port, int force_d) | 698 | +static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port, int force_d) |
685 | { | 699 | { |
686 | union { | 700 | union { |
687 | struct sockaddr sa; | 701 | struct sockaddr sa; |
@@ -700,8 +714,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -700,8 +714,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
700 | int n2read = 0; | 714 | int n2read = 0; |
701 | char nbuf[256]; | 715 | char nbuf[256]; |
702 | int done = 0; | 716 | int done = 0; |
717 | + | ||
703 | #if defined(X3270_TRACE) /*[*/ | 718 | #if defined(X3270_TRACE) /*[*/ |
704 | - char *atype_name[] = { | 719 | + const char *atype_name[] = |
720 | + { | ||
705 | "", | 721 | "", |
706 | "IPv4", | 722 | "IPv4", |
707 | "", | 723 | "", |
@@ -719,12 +735,11 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -719,12 +735,11 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
719 | int rv; | 735 | int rv; |
720 | 736 | ||
721 | /* Resolve the hostname. */ | 737 | /* Resolve the hostname. */ |
722 | - rv = resolve_host_and_port(&h3270,host, CN, &rport, &ha.sa, &ha_len,errmsg, sizeof(errmsg)); | 738 | + rv = resolve_host_and_port(hSession,host, CN, &rport, &ha.sa, &ha_len,errmsg, sizeof(errmsg)); |
723 | if (rv == -2) | 739 | if (rv == -2) |
724 | use_name = 1; | 740 | use_name = 1; |
725 | else if (rv < 0) { | 741 | else if (rv < 0) { |
726 | - popup_an_error(NULL,"SOCKS5 proxy: %s/%u: %s", host, port, | ||
727 | - errmsg); | 742 | + popup_an_error(hSession,_("SOCKS5 proxy: %s/%u: %s"), host, port,errmsg); |
728 | return -1; | 743 | return -1; |
729 | } | 744 | } |
730 | } | 745 | } |
@@ -732,11 +747,12 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -732,11 +747,12 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
732 | /* Send the authentication request to the server. */ | 747 | /* Send the authentication request to the server. */ |
733 | strcpy((char *)rbuf, "\005\001\000"); | 748 | strcpy((char *)rbuf, "\005\001\000"); |
734 | #if defined(X3270_TRACE) /*[*/ | 749 | #if defined(X3270_TRACE) /*[*/ |
735 | - trace_dsn(&h3270,"SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n"); | ||
736 | - trace_netdata(&h3270, '>', rbuf, 3); | 750 | + trace_dsn(hSession,_("SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n")); |
751 | + trace_netdata(hSession, '>', rbuf, 3); | ||
737 | #endif /*]*/ | 752 | #endif /*]*/ |
738 | - if (send(fd, (const char *) rbuf, 3, 0) < 0) { | ||
739 | - popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); | 753 | + if (send(fd, (const char *) rbuf, 3, 0) < 0) |
754 | + { | ||
755 | + popup_a_sockerr(hSession,_("SOCKS5 Proxy: send error")); | ||
740 | return -1; | 756 | return -1; |
741 | } | 757 | } |
742 | 758 | ||
@@ -755,10 +771,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -755,10 +771,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
755 | tv.tv_usec = 0; | 771 | tv.tv_usec = 0; |
756 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) | 772 | if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) |
757 | { | 773 | { |
758 | - popup_an_error(&h3270,"SOCKS5 Proxy: server timeout"); | 774 | + popup_an_error(hSession,_("SOCKS5 Proxy: server timeout")); |
759 | #if defined(X3270_TRACE) /*[*/ | 775 | #if defined(X3270_TRACE) /*[*/ |
760 | if (nread) | 776 | if (nread) |
761 | - trace_netdata(&h3270, '<', rbuf, nread); | 777 | + trace_netdata(hSession, '<', rbuf, nread); |
762 | #endif /*]*/ | 778 | #endif /*]*/ |
763 | return -1; | 779 | return -1; |
764 | } | 780 | } |
@@ -766,19 +782,19 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -766,19 +782,19 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
766 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); | 782 | nr = recv(fd, (char *) &rbuf[nread], 1, 0); |
767 | if (nr < 0) | 783 | if (nr < 0) |
768 | { | 784 | { |
769 | - popup_a_sockerr(&h3270,"SOCKS5 Proxy: receive error"); | 785 | + popup_a_sockerr(hSession,_("SOCKS5 Proxy: receive error")); |
770 | #if defined(X3270_TRACE) /*[*/ | 786 | #if defined(X3270_TRACE) /*[*/ |
771 | if (nread) | 787 | if (nread) |
772 | - trace_netdata(&h3270, '<', rbuf, nread); | 788 | + trace_netdata(hSession, '<', rbuf, nread); |
773 | #endif /*]*/ | 789 | #endif /*]*/ |
774 | return -1; | 790 | return -1; |
775 | } | 791 | } |
776 | if (nr == 0) | 792 | if (nr == 0) |
777 | { | 793 | { |
778 | - popup_a_sockerr(NULL,"SOCKS5 Proxy: unexpected EOF"); | 794 | + popup_a_sockerr(hSession,_("SOCKS5 Proxy: unexpected EOF")); |
779 | #if defined(X3270_TRACE) /*[*/ | 795 | #if defined(X3270_TRACE) /*[*/ |
780 | if (nread) | 796 | if (nread) |
781 | - trace_netdata(&h3270, '<', rbuf, nread); | 797 | + trace_netdata(hSession, '<', rbuf, nread); |
782 | #endif /*]*/ | 798 | #endif /*]*/ |
783 | return -1; | 799 | return -1; |
784 | } | 800 | } |
@@ -787,21 +803,22 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -787,21 +803,22 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
787 | } | 803 | } |
788 | 804 | ||
789 | #if defined(X3270_TRACE) /*[*/ | 805 | #if defined(X3270_TRACE) /*[*/ |
790 | - trace_netdata(&h3270, '<', rbuf, nread); | 806 | + trace_netdata(hSession, '<', rbuf, nread); |
791 | #endif /*]*/ | 807 | #endif /*]*/ |
792 | 808 | ||
793 | if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) | 809 | if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) |
794 | { | 810 | { |
795 | - popup_an_error(&h3270,"SOCKS5 Proxy: bad authentication response"); | 811 | + popup_an_error(hSession,_("SOCKS5 Proxy: bad authentication response")); |
796 | return -1; | 812 | return -1; |
797 | } | 813 | } |
798 | 814 | ||
799 | #if defined(X3270_TRACE) /*[*/ | 815 | #if defined(X3270_TRACE) /*[*/ |
800 | - trace_dsn(&h3270,"SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]); | 816 | + trace_dsn(hSession,"SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]); |
801 | #endif /*]*/ | 817 | #endif /*]*/ |
802 | 818 | ||
803 | - if (rbuf[1] == 0xff) { | ||
804 | - popup_an_error(&h3270,"SOCKS5 Proxy: authentication failure"); | 819 | + if (rbuf[1] == 0xff) |
820 | + { | ||
821 | + popup_an_error(hSession,_("SOCKS5 Proxy: authentication failure")); | ||
805 | return -1; | 822 | return -1; |
806 | } | 823 | } |
807 | 824 | ||
@@ -832,16 +849,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -832,16 +849,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
832 | SET16(s, port); | 849 | SET16(s, port); |
833 | 850 | ||
834 | #if defined(X3270_TRACE) /*[*/ | 851 | #if defined(X3270_TRACE) /*[*/ |
835 | - trace_dsn(&h3270,"SOCKS5 Proxy: xmit version 5 connect %s %s port %u\n", | 852 | + trace_dsn(hSession,"SOCKS5 Proxy: xmit version 5 connect %s %s port %u\n", |
836 | use_name? "domainname": | 853 | use_name? "domainname": |
837 | ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), | 854 | ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), |
838 | use_name? host: nbuf, | 855 | use_name? host: nbuf, |
839 | port); | 856 | port); |
840 | - trace_netdata(&h3270, '>', (unsigned char *)buf, s - buf); | 857 | + trace_netdata(hSession, '>', (unsigned char *)buf, s - buf); |
841 | #endif /*]*/ | 858 | #endif /*]*/ |
842 | 859 | ||
843 | if (send(fd, buf, s - buf, 0) < 0) { | 860 | if (send(fd, buf, s - buf, 0) < 0) { |
844 | - popup_a_sockerr(NULL,"SOCKS5 Proxy: send error"); | 861 | + popup_a_sockerr(hSession,_("SOCKS5 Proxy: send error")); |
845 | lib3270_free(buf); | 862 | lib3270_free(buf); |
846 | return -1; | 863 | return -1; |
847 | } | 864 | } |
@@ -855,8 +872,9 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -855,8 +872,9 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
855 | nread = 0; | 872 | nread = 0; |
856 | done = 0; | 873 | done = 0; |
857 | buf = NULL; | 874 | buf = NULL; |
858 | - while (!done) { | ||
859 | - fd_set rfds; | 875 | + while (!done) |
876 | + { | ||
877 | + fd_set rfds; | ||
860 | struct timeval tv; | 878 | struct timeval tv; |
861 | unsigned char r; | 879 | unsigned char r; |
862 | 880 | ||
@@ -864,27 +882,28 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -864,27 +882,28 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
864 | FD_SET(fd, &rfds); | 882 | FD_SET(fd, &rfds); |
865 | tv.tv_sec = 15; | 883 | tv.tv_sec = 15; |
866 | tv.tv_usec = 0; | 884 | tv.tv_usec = 0; |
867 | - if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { | ||
868 | - popup_an_error(NULL,"SOCKS5 Proxy: server timeout"); | 885 | + if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) |
886 | + { | ||
887 | + popup_an_error(hSession,_("SOCKS5 Proxy: server timeout")); | ||
869 | return -1; | 888 | return -1; |
870 | } | 889 | } |
871 | 890 | ||
872 | nr = recv(fd, (char *) &r, 1, 0); | 891 | nr = recv(fd, (char *) &r, 1, 0); |
873 | if (nr < 0) | 892 | if (nr < 0) |
874 | { | 893 | { |
875 | - popup_a_sockerr(NULL,"SOCKS5 Proxy: receive error"); | 894 | + popup_a_sockerr(hSession,_("SOCKS5 Proxy: receive error")); |
876 | #if defined(X3270_TRACE) /*[*/ | 895 | #if defined(X3270_TRACE) /*[*/ |
877 | if (nread) | 896 | if (nread) |
878 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 897 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
879 | #endif /*]*/ | 898 | #endif /*]*/ |
880 | return -1; | 899 | return -1; |
881 | } | 900 | } |
882 | if (nr == 0) | 901 | if (nr == 0) |
883 | { | 902 | { |
884 | - popup_an_error(&h3270, "SOCKS5 Proxy: unexpected EOF"); | 903 | + popup_an_error(hSession, _("SOCKS5 Proxy: unexpected EOF")); |
885 | #if defined(X3270_TRACE) /*[*/ | 904 | #if defined(X3270_TRACE) /*[*/ |
886 | if (nread) | 905 | if (nread) |
887 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 906 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
888 | #endif /*]*/ | 907 | #endif /*]*/ |
889 | return -1; | 908 | return -1; |
890 | } | 909 | } |
@@ -896,10 +915,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -896,10 +915,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
896 | case 0: | 915 | case 0: |
897 | if (r != 0x05) | 916 | if (r != 0x05) |
898 | { | 917 | { |
899 | - popup_an_error(&h3270, "SOCKS5 Proxy: incorrect reply version 0x%02x", r); | 918 | + popup_an_error(hSession, _("SOCKS5 Proxy: incorrect reply version 0x%02x"), r); |
900 | #if defined(X3270_TRACE) /*[*/ | 919 | #if defined(X3270_TRACE) /*[*/ |
901 | if (nread) | 920 | if (nread) |
902 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 921 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
903 | #endif /*]*/ | 922 | #endif /*]*/ |
904 | return -1; | 923 | return -1; |
905 | } | 924 | } |
@@ -907,52 +926,49 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -907,52 +926,49 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
907 | case 1: | 926 | case 1: |
908 | #if defined(X3270_TRACE) /*[*/ | 927 | #if defined(X3270_TRACE) /*[*/ |
909 | if (r != 0x00) | 928 | if (r != 0x00) |
910 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 929 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
911 | #endif /*]*/ | 930 | #endif /*]*/ |
912 | - switch (r) { | 931 | + switch (r) |
932 | + { | ||
913 | case 0x00: | 933 | case 0x00: |
914 | - break; | 934 | + break; |
915 | case 0x01: | 935 | case 0x01: |
916 | - popup_an_error(&h3270, "SOCKS5 Proxy: server failure"); | 936 | + popup_an_error(hSession, _("SOCKS5 Proxy: server failure")); |
917 | return -1; | 937 | return -1; |
918 | case 0x02: | 938 | case 0x02: |
919 | - popup_an_error(&h3270, "SOCKS5 Proxy: connection not allowed"); | 939 | + popup_an_error(hSession, _("SOCKS5 Proxy: connection not allowed")); |
920 | return -1; | 940 | return -1; |
921 | case 0x03: | 941 | case 0x03: |
922 | - popup_an_error(NULL,"SOCKS5 Proxy: network " | ||
923 | - "unreachable"); | 942 | + popup_an_error(hSession, _("SOCKS5 Proxy: network unreachable")); |
924 | return -1; | 943 | return -1; |
925 | case 0x04: | 944 | case 0x04: |
926 | - popup_an_error(NULL,"SOCKS5 Proxy: host " | ||
927 | - "unreachable"); | 945 | + popup_an_error(hSession, _("SOCKS5 Proxy: host unreachable")); |
928 | return -1; | 946 | return -1; |
929 | case 0x05: | 947 | case 0x05: |
930 | - popup_an_error(NULL,"SOCKS5 Proxy: connection " | ||
931 | - "refused"); | 948 | + popup_an_error(hSession, _("SOCKS5 Proxy: connection refused")); |
932 | return -1; | 949 | return -1; |
933 | case 0x06: | 950 | case 0x06: |
934 | - popup_an_error(NULL,"SOCKS5 Proxy: ttl expired"); | 951 | + popup_an_error(hSession, _("SOCKS5 Proxy: ttl expired")); |
935 | return -1; | 952 | return -1; |
936 | case 0x07: | 953 | case 0x07: |
937 | - popup_an_error(NULL,"SOCKS5 Proxy: command not " | ||
938 | - "supported"); | 954 | + popup_an_error(hSession, _("SOCKS5 Proxy: command not supported")); |
939 | return -1; | 955 | return -1; |
940 | case 0x08: | 956 | case 0x08: |
941 | - popup_an_error(NULL,"SOCKS5 Proxy: address type " | ||
942 | - "not supported"); | 957 | + popup_an_error(hSession, _("SOCKS5 Proxy: address type not supported")); |
943 | return -1; | 958 | return -1; |
944 | default: | 959 | default: |
945 | - popup_an_error(NULL,"SOCKS5 Proxy: unknown server " | ||
946 | - "error 0x%02x", r); | 960 | + popup_an_error(hSession, _("SOCKS5 Proxy: unknown server error 0x%02x"), r); |
947 | return -1; | 961 | return -1; |
948 | } | 962 | } |
949 | break; | 963 | break; |
964 | + | ||
950 | case 2: | 965 | case 2: |
951 | break; | 966 | break; |
952 | case 3: | 967 | case 3: |
953 | - switch (r) { | 968 | + switch (r) |
969 | + { | ||
954 | case 0x01: | 970 | case 0x01: |
955 | - n2read = 6; | 971 | + n2read = 6; |
956 | break; | 972 | break; |
957 | case 0x03: | 973 | case 0x03: |
958 | n2read = -1; | 974 | n2read = -1; |
@@ -963,10 +979,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -963,10 +979,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
963 | break; | 979 | break; |
964 | #endif /*]*/ | 980 | #endif /*]*/ |
965 | default: | 981 | default: |
966 | - popup_an_error(&h3270, "SOCKS5 Proxy: unknown server address type 0x%02x", r); | 982 | + popup_an_error(hSession, _("SOCKS5 Proxy: unknown server address type 0x%02x"), r); |
967 | #if defined(X3270_TRACE) /*[*/ | 983 | #if defined(X3270_TRACE) /*[*/ |
968 | if (nread) | 984 | if (nread) |
969 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 985 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
970 | #endif /*]*/ | 986 | #endif /*]*/ |
971 | return -1; | 987 | return -1; |
972 | } | 988 | } |
@@ -981,7 +997,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -981,7 +997,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
981 | } | 997 | } |
982 | 998 | ||
983 | #if defined(X3270_TRACE) /*[*/ | 999 | #if defined(X3270_TRACE) /*[*/ |
984 | - trace_netdata(&h3270, '<', (unsigned char *)buf, nread); | 1000 | + trace_netdata(hSession, '<', (unsigned char *)buf, nread); |
985 | switch (buf[3]) { | 1001 | switch (buf[3]) { |
986 | case 0x01: /* IPv4 */ | 1002 | case 0x01: /* IPv4 */ |
987 | memcpy(&ha.sin.sin_addr, &buf[4], 4); | 1003 | memcpy(&ha.sin.sin_addr, &buf[4], 4); |
@@ -1008,8 +1024,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | @@ -1008,8 +1024,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) | ||
1008 | break; | 1024 | break; |
1009 | } | 1025 | } |
1010 | rport = (*portp << 8) + *(portp + 1); | 1026 | rport = (*portp << 8) + *(portp + 1); |
1011 | - trace_dsn(&h3270,"SOCKS5 Proxy: recv version %d status 0x%02x address %s %s " | ||
1012 | - "port %u\n", | 1027 | + trace_dsn(hSession,"SOCKS5 Proxy: recv version %d status 0x%02x address %s %s port %u\n", |
1013 | buf[0], buf[1], | 1028 | buf[0], buf[1], |
1014 | atype_name[(unsigned char)buf[3]], | 1029 | atype_name[(unsigned char)buf[3]], |
1015 | nbuf, | 1030 | nbuf, |
proxyc.h
@@ -17,6 +17,6 @@ | @@ -17,6 +17,6 @@ | ||
17 | * Declarations for proxy.c. | 17 | * Declarations for proxy.c. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | -LIB3270_INTERNAL int proxy_setup(H3270 *session, char **phost, char **pport); | ||
21 | -LIB3270_INTERNAL int proxy_negotiate(int type, int fd, char *host, unsigned short port); | ||
22 | -LIB3270_INTERNAL char * proxy_type_name(int type); | 20 | +LIB3270_INTERNAL int proxy_setup(H3270 *session, char **phost, char **pport); |
21 | +LIB3270_INTERNAL int proxy_negotiate(H3270 *session, int type, int fd, char *host, unsigned short port); | ||
22 | +LIB3270_INTERNAL const char * proxy_type_name(int type); |
@@ -79,7 +79,7 @@ int * char_height = &ch; | @@ -79,7 +79,7 @@ int * char_height = &ch; | ||
79 | 79 | ||
80 | /* Globals */ | 80 | /* Globals */ |
81 | static Boolean sfont = False; | 81 | static Boolean sfont = False; |
82 | -Boolean * standard_font = &sfont; | 82 | +static Boolean * standard_font = &sfont; |
83 | 83 | ||
84 | 84 | ||
85 | /* Statics */ | 85 | /* Statics */ |
telnet.c
@@ -812,68 +812,68 @@ static void setup_lus(H3270 *hSession) | @@ -812,68 +812,68 @@ static void setup_lus(H3270 *hSession) | ||
812 | hSession->try_lu = *hSession->curr_lu; | 812 | hSession->try_lu = *hSession->curr_lu; |
813 | } | 813 | } |
814 | 814 | ||
815 | -static void net_connected(H3270 *session) | 815 | +static void net_connected(H3270 *hSession) |
816 | { | 816 | { |
817 | - if(session->proxy_type > 0) | 817 | + if(hSession->proxy_type > 0) |
818 | { | 818 | { |
819 | /* Negotiate with the proxy. */ | 819 | /* Negotiate with the proxy. */ |
820 | - trace_dsn(session,"Connected to proxy server %s, port %u.\n",session->proxy_host, session->proxy_port); | 820 | + trace_dsn(hSession,"Connected to proxy server %s, port %u.\n",hSession->proxy_host, hSession->proxy_port); |
821 | 821 | ||
822 | - if (proxy_negotiate(session->proxy_type, session->sock, session->hostname,session->current_port) < 0) | 822 | + if (proxy_negotiate(hSession, hSession->proxy_type, hSession->sock, hSession->hostname,hSession->current_port) < 0) |
823 | { | 823 | { |
824 | - host_disconnect(session,True); | 824 | + host_disconnect(hSession,True); |
825 | return; | 825 | return; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | - trace_dsn(session,"Connected to %s, port %u%s.\n", session->hostname, session->current_port,session->ssl_host? " via SSL": ""); | 829 | + trace_dsn(hSession,"Connected to %s, port %u%s.\n", hSession->hostname, hSession->current_port,hSession->ssl_host? " via SSL": ""); |
830 | 830 | ||
831 | #if defined(HAVE_LIBSSL) /*[*/ | 831 | #if defined(HAVE_LIBSSL) /*[*/ |
832 | /* Set up SSL. */ | 832 | /* Set up SSL. */ |
833 | - if(session->ssl_con && session->secure == LIB3270_SSL_UNDEFINED) | 833 | + if(hSession->ssl_con && hSession->secure == LIB3270_SSL_UNDEFINED) |
834 | { | 834 | { |
835 | int rc; | 835 | int rc; |
836 | 836 | ||
837 | - set_ssl_state(session,LIB3270_SSL_NEGOTIATING); | 837 | + set_ssl_state(hSession,LIB3270_SSL_NEGOTIATING); |
838 | 838 | ||
839 | - if (SSL_set_fd(session->ssl_con, session->sock) != 1) | 839 | + if (SSL_set_fd(hSession->ssl_con, hSession->sock) != 1) |
840 | { | 840 | { |
841 | - trace_dsn(session,"Can't set fd!\n"); | ||
842 | - popup_system_error(session,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con)); | ||
843 | - set_ssl_state(session,LIB3270_SSL_UNSECURE); | 841 | + trace_dsn(hSession,"Can't set fd!\n"); |
842 | + popup_system_error(hSession,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(hSession->ssl_con)); | ||
843 | + set_ssl_state(hSession,LIB3270_SSL_UNSECURE); | ||
844 | } | 844 | } |
845 | else | 845 | else |
846 | { | 846 | { |
847 | - rc = SSL_connect(session->ssl_con); | 847 | + rc = SSL_connect(hSession->ssl_con); |
848 | 848 | ||
849 | if(rc != 1) | 849 | if(rc != 1) |
850 | { | 850 | { |
851 | unsigned long e = ERR_get_error(); | 851 | unsigned long e = ERR_get_error(); |
852 | - const char * state = SSL_state_string_long(session->ssl_con); | 852 | + const char * state = SSL_state_string_long(hSession->ssl_con); |
853 | 853 | ||
854 | - trace_dsn(session,"TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state); | 854 | + trace_dsn(hSession,"TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state); |
855 | 855 | ||
856 | - host_disconnect(session,True); | 856 | + host_disconnect(hSession,True); |
857 | 857 | ||
858 | - if(e != session->last_ssl_error) | 858 | + if(e != hSession->last_ssl_error) |
859 | { | 859 | { |
860 | - session->message(session,LIB3270_NOTIFY_ERROR,_( "Connection failed" ),_( "SSL negotiation failed" ),state); | ||
861 | - session->last_ssl_error = e; | 860 | + hSession->message(hSession,LIB3270_NOTIFY_ERROR,_( "Connection failed" ),_( "SSL negotiation failed" ),state); |
861 | + hSession->last_ssl_error = e; | ||
862 | } | 862 | } |
863 | return; | 863 | return; |
864 | 864 | ||
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | -// session->secure_connection = True; | ||
869 | - trace_dsn(session,"TLS/SSL tunneled connection complete. Connection is now secure.\n"); | 868 | +// hSession->secure_connection = True; |
869 | + trace_dsn(hSession,"TLS/SSL tunneled connection complete. Connection is now secure.\n"); | ||
870 | 870 | ||
871 | /* Tell everyone else again. */ | 871 | /* Tell everyone else again. */ |
872 | - lib3270_set_connected(session); | 872 | + lib3270_set_connected(hSession); |
873 | } | 873 | } |
874 | #endif /*]*/ | 874 | #endif /*]*/ |
875 | 875 | ||
876 | - lib3270_setup_session(session); | 876 | + lib3270_setup_session(hSession); |
877 | 877 | ||
878 | } | 878 | } |
879 | 879 |