Commit c9335c4e8b409635d6a06d608a27bc5c2a88aef3

Authored by perry.werneck@gmail.com
1 parent 6788b80f

Ajustes para multi-sessão

ctlr.c
... ... @@ -26,12 +26,11 @@
26 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 27 * licinio@bb.com.br (Licínio Luis Branco)
28 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 34 * This module handles interpretation of the 3270 data stream and
36 35 * maintenance of the 3270 device state. It was split out from
37 36 * screen.c, which handles X operations.
... ... @@ -75,11 +74,12 @@ static void ctlr_connect(H3270 *session, int ignored, void *dunno);
75 74 static void ticking_stop(H3270 *session);
76 75 static void ctlr_add_ic(H3270 *session, int baddr, unsigned char ic);
77 76  
78   -/*
  77 +/**
79 78 * code_table is used to translate buffer addresses and attributes to the 3270
80 79 * datastream representation
81 80 */
82   -static unsigned char code_table[64] = {
  81 +static const unsigned char code_table[64] =
  82 +{
83 83 0x40, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
84 84 0xC8, 0xC9, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
85 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 1248 if (add_dbcs)
1249 1249 {
1250 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 1252 ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg);
1253 1253 ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr);
1254 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 1345 trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1346 1346 cp++;
1347 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 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 1358 {
1359 1359 trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1360 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 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 1401 case ORDER_SFE: /* start field extended */
1402 1402 END_TEXT("StartFieldExtended");
1403 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 1405 previous = ORDER;
1406 1406 cp++; /* skip order */
1407 1407 na = *cp;
... ... @@ -1421,12 +1421,12 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1421 1421 } else if (*cp == XA_FOREGROUND) {
1422 1422 trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1)));
1423 1423 cp++;
1424   - if (h3270.m3279)
  1424 + if (hSession->m3279)
1425 1425 efa_fg = *cp;
1426 1426 } else if (*cp == XA_BACKGROUND) {
1427 1427 trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1)));
1428 1428 cp++;
1429   - if (h3270.m3279)
  1429 + if (hSession->m3279)
1430 1430 efa_bg = *cp;
1431 1431 } else if (*cp == XA_HIGHLIGHTING) {
1432 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 1437 cp++;
1438 1438 if (*cp == 0xf1)
1439 1439 efa_cs = CS_APL;
1440   - else if (h3270.dbcs && (*cp == 0xf8))
  1440 + else if (hSession->dbcs && (*cp == 0xf8))
1441 1441 efa_cs = CS_DBCS;
1442 1442 else
1443 1443 efa_cs = CS_BASE;
... ... @@ -1456,11 +1456,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1456 1456 }
1457 1457 if (!any_fa)
1458 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 1464 INC_BA(hSession->buffer_addr);
1465 1465 last_cmd = True;
1466 1466 last_zpt = False;
... ... @@ -1471,41 +1471,41 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1471 1471 cp++;
1472 1472 if (*cp == XA_FOREGROUND) {
1473 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 1476 } else if (*cp == XA_BACKGROUND) {
1477 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 1480 } else if (*cp == XA_HIGHLIGHTING) {
1481 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 1483 } else if (*cp == XA_ALL) {
1484 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 1490 } else if (*cp == XA_CHARSET) {
1491 1491 trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1)));
1492 1492 switch (*(cp + 1)) {
1493 1493 case 0xf1:
1494   - h3270.default_cs = CS_APL;
  1494 + hSession->default_cs = CS_APL;
1495 1495 break;
1496 1496 case 0xf8:
1497   - h3270.default_cs = CS_DBCS;
  1497 + hSession->default_cs = CS_DBCS;
1498 1498 break;
1499 1499 default:
1500   - h3270.default_cs = CS_BASE;
  1500 + hSession->default_cs = CS_BASE;
1501 1501 break;
1502 1502 }
1503 1503 } else if (*cp == XA_INPUT_CONTROL) {
1504 1504 trace_ds(hSession,"%s", see_efa(*cp, *(cp + 1)));
1505 1505 if (*(cp + 1) == 1)
1506   - h3270.default_ic = 1;
  1506 + hSession->default_ic = 1;
1507 1507 else
1508   - h3270.default_ic = 0;
  1508 + hSession->default_ic = 0;
1509 1509 } else
1510 1510 trace_ds(hSession,"%s[unsupported]",see_efa(*cp, *(cp + 1)));
1511 1511 cp++;
... ... @@ -1523,7 +1523,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1523 1523 END_TEXT(see_ebc(*cp));
1524 1524 previous = ORDER;
1525 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 1527 ABORT_WRITE("invalid format control order in DBCS field");
1528 1528 }
1529 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 1550 }
1551 1551 /* All is well. */
1552 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 1558 INC_BA(hSession->buffer_addr);
1559 1559 last_cmd = True;
1560 1560 last_zpt = False;
... ... @@ -1569,31 +1569,31 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1569 1569 if (d != DBCS_NONE && why == DBCS_FIELD) {
1570 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 1574 DEC_BA(baddr);
1575 1575 while (!aborted &&
1576 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 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 1582 break;
1583 1583 DEC_BA(baddr);
1584 1584 }
1585 1585 if (aborted)
1586 1586 break;
1587   - if (h3270.ea_buf[baddr].cc != FCORDER_SO) {
  1587 + if (hSession->ea_buf[baddr].cc != FCORDER_SO) {
1588 1588 ABORT_WRITE("SI without SO");
1589 1589 }
1590 1590 /* All is well. */
1591 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 1597 INC_BA(hSession->buffer_addr);
1598 1598 last_cmd = True;
1599 1599 last_zpt = False;
... ... @@ -1601,11 +1601,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1601 1601 case FCORDER_NULL: /* NULL or DBCS control char */
1602 1602 previous = NULLCH;
1603 1603 add_dbcs = False;
1604   - d = ctlr_lookleft_state(h3270.buffer_addr, &why);
  1604 + d = ctlr_lookleft_state(hSession->buffer_addr, &why);
1605 1605 if (d == DBCS_RIGHT) {
1606 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 1609 add_c1 = EBC_null;
1610 1610 cp++;
1611 1611 if (cp >= buf + buflen) {
... ... @@ -1641,19 +1641,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1641 1641 END_TEXT("NULL");
1642 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 1649 INC_BA(hSession->buffer_addr);
1650 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 1657 INC_BA(hSession->buffer_addr);
1658 1658 }
1659 1659 last_cmd = False;
... ... @@ -1699,19 +1699,19 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1699 1699 #if defined(X3270_DBCS) /*[*/
1700 1700 }
1701 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 1707 INC_BA(hSession->buffer_addr);
1708 1708 #if defined(X3270_DBCS) /*[*/
1709 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 1715 INC_BA(hSession->buffer_addr);
1716 1716 }
1717 1717 #endif /*]*/
... ... @@ -1724,9 +1724,9 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1724 1724 END_TEXT0;
1725 1725 trace_ds(hSession,"\n");
1726 1726 if (wcc_keyboard_restore) {
1727   - h3270.aid = AID_NO;
  1727 + hSession->aid = AID_NO;
1728 1728 do_reset(hSession,False);
1729   - } else if (h3270.kybdlock & KL_OIA_TWAIT) {
  1729 + } else if (hSession->kybdlock & KL_OIA_TWAIT) {
1730 1730 lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT);
1731 1731 status_changed(hSession,LIB3270_STATUS_SYSWAIT);
1732 1732 }
... ... @@ -2431,7 +2431,7 @@ void ctlr_scroll(H3270 *hSession)
2431 2431 /* Synchronize pending changes prior to this. */
2432 2432  
2433 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 2436 /* Clear the last line. */
2437 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 196 // LIB3270_INTERNAL char *local_encoding;
197 197  
198 198 #if defined(X3270_DISPLAY) /*[*/
199   - LIB3270_INTERNAL char *locale_name;
  199 +// LIB3270_INTERNAL char *locale_name;
200 200 #endif /*]*/
201 201  
202 202 #endif /*]*/
... ... @@ -227,7 +227,7 @@ LIB3270_INTERNAL const char * build_rpq_revision;
227 227  
228 228 // LIB3270_INTERNAL Boolean shifted;
229 229 // LIB3270_INTERNAL Boolean ssl_host;
230   -LIB3270_INTERNAL Boolean *standard_font;
  230 +// LIB3270_INTERNAL Boolean *standard_font;
231 231 // LIB3270_INTERNAL Boolean std_ds_host;
232 232 // LIB3270_INTERNAL char *termtype;
233 233 // LIB3270_INTERNAL Widget toplevel;
... ... @@ -277,7 +277,7 @@ struct toggle_name {
277 277 };
278 278  
279 279  
280   -/* translation lists */
  280 +/* translation lists */ /*
281 281 struct trans_list {
282 282 char *name;
283 283 char *pathname;
... ... @@ -286,6 +286,7 @@ struct trans_list {
286 286 struct trans_list *next;
287 287 };
288 288 LIB3270_INTERNAL struct trans_list *trans_list;
  289 +*/
289 290  
290 291 /* input key type */
291 292 // enum keytype { KT_STD, KT_GE };
... ...
iocalls.c
... ... @@ -63,9 +63,9 @@ static void internal_remove_input(void *id);
63 63 // static int internal_process_events(int block);
64 64  
65 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 69 static void internal_ring_bell(H3270 *);
70 70  
71 71 /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/
... ... @@ -96,10 +96,10 @@ static void internal_ring_bell(H3270 *);
96 96 static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm)
97 97 = internal_callthread;
98 98  
99   - static int (*wait)(int seconds)
  99 + static int (*wait)(H3270 *hSession, int seconds)
100 100 = internal_wait;
101 101  
102   - static int (*event_dispatcher)(int wait)
  102 + static int (*event_dispatcher)(H3270 *hSession,int wait)
103 103 = internal_event_dispatcher;
104 104  
105 105 static void (*ring_bell)(H3270 *)
... ... @@ -333,7 +333,7 @@ static void internal_remove_input(void *id)
333 333 }
334 334  
335 335 /* Event dispatcher. */
336   -static int internal_event_dispatcher(int block)
  336 +static int internal_event_dispatcher(H3270 *hSession, int block)
337 337 {
338 338 #if defined(_WIN32)
339 339 HANDLE ha[MAX_HA];
... ... @@ -533,7 +533,7 @@ static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session,
533 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 538 time_t end;
539 539  
... ... @@ -542,7 +542,7 @@ static int internal_wait(int seconds)
542 542  
543 543 while(time(0) < end)
544 544 {
545   - lib3270_main_iterate(&h3270,1);
  545 + lib3270_main_iterate(hSession,1);
546 546 }
547 547  
548 548 return 0;
... ... @@ -713,15 +713,15 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *
713 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 722 LIB3270_EXPORT int lib3270_wait(H3270 *hSession, int seconds)
723 723 {
724   - wait(seconds);
  724 + wait(hSession,seconds);
725 725 return 0;
726 726 }
727 727  
... ... @@ -731,7 +731,7 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
731 731  
732 732 while(time(0) < end)
733 733 {
734   - event_dispatcher(1);
  734 + event_dispatcher(hSession,1);
735 735  
736 736 if(hSession->oia_status == LIB3270_STATUS_BLANK)
737 737 return 0;
... ...
kybd.c
... ... @@ -2130,7 +2130,7 @@ LIB3270_ACTION( eraseinput )
2130 2130 f = True;
2131 2131 }
2132 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 2135 } while (!hSession->ea_buf[baddr].fa);
2136 2136 } else { /* skip protected */
... ... @@ -2417,7 +2417,7 @@ kybd_scroll_lock(Boolean lock)
2417 2417 if (lock)
2418 2418 kybdlock_set(KL_SCROLLED, "kybd_scroll_lock");
2419 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 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 27 * licinio@bb.com.br (Licínio Luis Branco)
28 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 36 * This module implements various kinds of proxies.
  37 + *
37 38 */
38 39  
39 40 #ifdef _WIN32
... ... @@ -101,63 +102,65 @@ enum
101 102 PT_MAX
102 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 105 #define PROXY_PASSTHRU "passthru"
118 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 111 #define PROXY_TELNET "telnet"
124 112  
125 113 #define PROXY_SOCKS4 "socks4"
126   -#define PORT_SOCKS4 "1080"
  114 +#define PORT_SOCKS4 "1080"
127 115  
128 116 #define PROXY_SOCKS4A "socks4a"
129 117 #define PORT_SOCKS4A "1080"
130 118  
131 119 #define PROXY_SOCKS5 "socks5"
132   -#define PORT_SOCKS5 "1080"
  120 +#define PORT_SOCKS5 "1080"
133 121  
134 122 #define PROXY_SOCKS5D "socks5d"
135 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 152 else
151   - return type_name[type];
  153 + return type_name[type];
152 154 }
153 155  
154   -/*
  156 +/**
155 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 164 char * colon;
162 165 int sl;
163 166  
... ... @@ -166,14 +169,14 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
166 169  
167 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 173 return -1;
171 174 }
172 175  
173 176 sl = colon - proxy;
174 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 180 return -1;
178 181  
179 182 if (*pport == CN)
... ... @@ -185,7 +188,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
185 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 192 return -1;
190 193 if (*pport == CN)
191 194 *pport = NewString(PORT_HTTP);
... ... @@ -195,11 +198,11 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
195 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 202 return -1;
200 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 206 return -1;
204 207 }
205 208 return PT_TELNET;
... ... @@ -207,7 +210,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
207 210  
208 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 214 return -1;
212 215  
213 216 if (*pport == CN)
... ... @@ -218,7 +221,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
218 221  
219 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 225 return -1;
223 226  
224 227 if (*pport == CN)
... ... @@ -229,7 +232,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
229 232  
230 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 236 return -1;
234 237  
235 238 if (*pport == CN)
... ... @@ -240,7 +243,7 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
240 243  
241 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 247 return -1;
245 248  
246 249 if (*pport == CN)
... ... @@ -249,19 +252,20 @@ int proxy_setup(H3270 *session, char **phost, char **pport)
249 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 257 return -1;
255 258 }
256 259  
257   -/*
  260 +/**
258 261 * Parse host[:port] from a string.
  262 + *
259 263 * 'host' can be in square brackets to allow numeric IPv6 addresses.
260 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 270 char *colon;
267 271 char *hstart;
... ... @@ -277,7 +281,7 @@ parse_host_port(char *s, char **phost, char **pport)
277 281 rbrack == s + 1 ||
278 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 285 return -1;
282 286 }
283 287 if (*(rbrack + 1) == ':')
... ... @@ -289,7 +293,7 @@ parse_host_port(char *s, char **phost, char **pport)
289 293 hstart = s;
290 294 colon = strchr(s, ':');
291 295 if (colon == s) {
292   - popup_an_error(NULL,"Invalid proxy hostname syntax");
  296 + popup_an_error(hSession,_("Invalid proxy hostname syntax"));
293 297 return -1;
294 298 }
295 299 if (colon == NULL)
... ... @@ -311,37 +315,38 @@ parse_host_port(char *s, char **phost, char **pport)
311 315 return 0;
312 316 }
313 317  
314   -/*
  318 +/**
315 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 327 case PT_NONE:
323 328 return 0;
324 329 case PT_PASSTHRU:
325   - return proxy_passthru(fd, host, port);
  330 + return proxy_passthru(hSession, fd, host, port);
326 331 case PT_HTTP:
327   - return proxy_http(fd, host, port);
  332 + return proxy_http(hSession, fd, host, port);
328 333 case PT_TELNET:
329   - return proxy_telnet(fd, host, port);
  334 + return proxy_telnet(hSession, fd, host, port);
330 335 case PT_SOCKS4:
331   - return proxy_socks4(fd, host, port, 0);
  336 + return proxy_socks4(hSession, fd, host, port, 0);
332 337 case PT_SOCKS4A:
333   - return proxy_socks4(fd, host, port, 1);
  338 + return proxy_socks4(hSession, fd, host, port, 1);
334 339 case PT_SOCKS5:
335   - return proxy_socks5(fd, host, port, 0);
  340 + return proxy_socks5(hSession, fd, host, port, 0);
336 341 case PT_SOCKS5D:
337   - return proxy_socks5(fd, host, port, 1);
  342 + return proxy_socks5(hSession, fd, host, port, 1);
338 343 default:
339 344 return -1;
340 345 }
341 346 }
342 347  
343 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 351 char *buf;
347 352  
... ... @@ -349,24 +354,24 @@ static int proxy_passthru(int fd, char *host, unsigned short port)
349 354 (void) sprintf(buf, "%s %u\r\n", host, port);
350 355  
351 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 359 #endif /*]*/
355 360  
356 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 364 lib3270_free(buf);
360 365 return -1;
361 366 }
362 367 lib3270_free(buf);
363 368  
364   - return 0;
  369 + return 0;
365 370 }
366 371  
367 372 /* HTTP (RFC 2817 CONNECT tunnel) proxy. */
368 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 376 char *buf;
372 377 char *colon;
... ... @@ -385,12 +390,13 @@ proxy_http(int fd, char *host, unsigned short port)
385 390 port);
386 391  
387 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 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 400 lib3270_free(buf);
395 401 return -1;
396 402 }
... ... @@ -402,24 +408,26 @@ proxy_http(int fd, char *host, unsigned short port)
402 408 port);
403 409  
404 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 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 418 lib3270_free(buf);
412 419 return -1;
413 420 }
414 421  
415 422 strcpy(buf, "\r\n");
416 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 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 431 lib3270_free(buf);
424 432 return -1;
425 433 }
... ... @@ -429,8 +437,9 @@ proxy_http(int fd, char *host, unsigned short port)
429 437 * Process the reply.
430 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 443 struct timeval tv;
435 444  
436 445 FD_ZERO(&rfds);
... ... @@ -438,29 +447,30 @@ proxy_http(int fd, char *host, unsigned short port)
438 447 tv.tv_sec = 15;
439 448 tv.tv_usec = 0;
440 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 451 #if defined(X3270_TRACE) /*[*/
443 452 if (nread)
444   - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread);
  453 + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread);
445 454 #endif /*]*/
446 455 return -1;
447 456 }
448 457  
449 458 nr = recv(fd, &rbuf[nread], 1, 0);
450 459 if (nr < 0) {
451   - popup_a_sockerr(NULL,"HTTP Proxy: receive error");
  460 + popup_a_sockerr(hSession,_( "HTTP Proxy: receive error" ));
452 461 #if defined(X3270_TRACE) /*[*/
453 462 if (nread)
454   - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread);
  463 + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread);
455 464 #endif /*]*/
456 465 return -1;
457 466 }
458   - if (nr == 0) {
  467 + if (nr == 0)
  468 + {
459 469 #if defined(X3270_TRACE) /*[*/
460 470 if (nread)
461   - trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread);
  471 + trace_netdata(hSession, '<', (unsigned char *)rbuf, nread);
462 472 #endif /*]*/
463   - popup_an_error(NULL,"HTTP Proxy: unexpected EOF");
  473 + popup_an_error(hSession,_( "HTTP Proxy: unexpected EOF" ));
464 474 return -1;
465 475 }
466 476 if (rbuf[nread] == '\r')
... ... @@ -475,18 +485,18 @@ proxy_http(int fd, char *host, unsigned short port)
475 485 rbuf[nread] = '\0';
476 486  
477 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 490 #endif /*]*/
481 491  
482 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 495 return -1;
486 496 }
487 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 500 return -1;
491 501 }
492 502  
... ... @@ -495,7 +505,7 @@ proxy_http(int fd, char *host, unsigned short port)
495 505  
496 506 /* TELNET proxy. */
497 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 510 char *buf;
501 511  
... ... @@ -503,13 +513,13 @@ proxy_telnet(int fd, char *host, unsigned short port)
503 513 (void) sprintf(buf, "connect %s %u\r\n", host, port);
504 514  
505 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 518 #endif /*]*/
509 519  
510 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 523 lib3270_free(buf);
514 524 return -1;
515 525 }
... ... @@ -520,19 +530,19 @@ proxy_telnet(int fd, char *host, unsigned short port)
520 530  
521 531 /* SOCKS version 4 proxy. */
522 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 536 return 0;
527 537 }
528 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 542 struct in_addr ipaddr;
533 543 int use_4a = 0;
534 544 char *user;
535   - char *buf;
  545 + char *buf;
536 546 char *s;
537 547 char rbuf[8];
538 548 int nr;
... ... @@ -578,13 +588,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
578 588 s += strlen(host) + 1;
579 589  
580 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 593 #endif /*]*/
584 594  
585 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 598 lib3270_free(buf);
589 599 return -1;
590 600 }
... ... @@ -603,14 +613,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
603 613 s += strlen(user) + 1;
604 614  
605 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 618 #endif /*]*/
609 619  
610 620 if (send(fd, buf, s - buf, 0) < 0)
611 621 {
612 622 lib3270_free(buf);
613   - popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error");
  623 + popup_a_sockerr(hSession,_("SOCKS4 Proxy: send error"));
614 624 return -1;
615 625 }
616 626 lib3270_free(buf);
... ... @@ -628,50 +638,55 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
628 638 FD_SET(fd, &rfds);
629 639 tv.tv_sec = 15;
630 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 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 652 return -1;
640 653 }
641 654 if (nr == 0)
642   - break;
  655 + break;
  656 +
643 657 if (++nread >= sizeof(rbuf))
644   - break;
  658 + break;
645 659 }
646 660  
647 661 #if defined(X3270_TRACE) /*[*/
648   - trace_netdata(&h3270,'<', (unsigned char *)rbuf, nread);
  662 + trace_netdata(hSession,'<', (unsigned char *)rbuf, nread);
649 663 if (use_4a)
650 664 {
651 665 struct in_addr a;
652 666  
653 667 rport = (rbuf[2] << 8) | rbuf[3];
654 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 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 673 #endif /*]*/
660 674  
661   - switch (rbuf[1]) {
  675 + switch (rbuf[1])
  676 + {
662 677 case 0x5a:
663 678 break;
664 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 681 return -1;
667 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 684 return -1;
670 685 case 0x5d:
671   - popup_an_error(&h3270,"SOCKS4 Proxy: userid error");
  686 + popup_an_error(hSession,_("SOCKS4 Proxy: userid error"));
672 687 return -1;
673 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 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 695 #endif // HAVE_GETADDRINFO
681 696  
682 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 700 union {
687 701 struct sockaddr sa;
... ... @@ -700,8 +714,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
700 714 int n2read = 0;
701 715 char nbuf[256];
702 716 int done = 0;
  717 +
703 718 #if defined(X3270_TRACE) /*[*/
704   - char *atype_name[] = {
  719 + const char *atype_name[] =
  720 + {
705 721 "",
706 722 "IPv4",
707 723 "",
... ... @@ -719,12 +735,11 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
719 735 int rv;
720 736  
721 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 739 if (rv == -2)
724 740 use_name = 1;
725 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 743 return -1;
729 744 }
730 745 }
... ... @@ -732,11 +747,12 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
732 747 /* Send the authentication request to the server. */
733 748 strcpy((char *)rbuf, "\005\001\000");
734 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 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 756 return -1;
741 757 }
742 758  
... ... @@ -755,10 +771,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
755 771 tv.tv_usec = 0;
756 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 775 #if defined(X3270_TRACE) /*[*/
760 776 if (nread)
761   - trace_netdata(&h3270, '<', rbuf, nread);
  777 + trace_netdata(hSession, '<', rbuf, nread);
762 778 #endif /*]*/
763 779 return -1;
764 780 }
... ... @@ -766,19 +782,19 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
766 782 nr = recv(fd, (char *) &rbuf[nread], 1, 0);
767 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 786 #if defined(X3270_TRACE) /*[*/
771 787 if (nread)
772   - trace_netdata(&h3270, '<', rbuf, nread);
  788 + trace_netdata(hSession, '<', rbuf, nread);
773 789 #endif /*]*/
774 790 return -1;
775 791 }
776 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 795 #if defined(X3270_TRACE) /*[*/
780 796 if (nread)
781   - trace_netdata(&h3270, '<', rbuf, nread);
  797 + trace_netdata(hSession, '<', rbuf, nread);
782 798 #endif /*]*/
783 799 return -1;
784 800 }
... ... @@ -787,21 +803,22 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
787 803 }
788 804  
789 805 #if defined(X3270_TRACE) /*[*/
790   - trace_netdata(&h3270, '<', rbuf, nread);
  806 + trace_netdata(hSession, '<', rbuf, nread);
791 807 #endif /*]*/
792 808  
793 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 812 return -1;
797 813 }
798 814  
799 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 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 822 return -1;
806 823 }
807 824  
... ... @@ -832,16 +849,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
832 849 SET16(s, port);
833 850  
834 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 853 use_name? "domainname":
837 854 ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"),
838 855 use_name? host: nbuf,
839 856 port);
840   - trace_netdata(&h3270, '>', (unsigned char *)buf, s - buf);
  857 + trace_netdata(hSession, '>', (unsigned char *)buf, s - buf);
841 858 #endif /*]*/
842 859  
843 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 862 lib3270_free(buf);
846 863 return -1;
847 864 }
... ... @@ -855,8 +872,9 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
855 872 nread = 0;
856 873 done = 0;
857 874 buf = NULL;
858   - while (!done) {
859   - fd_set rfds;
  875 + while (!done)
  876 + {
  877 + fd_set rfds;
860 878 struct timeval tv;
861 879 unsigned char r;
862 880  
... ... @@ -864,27 +882,28 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
864 882 FD_SET(fd, &rfds);
865 883 tv.tv_sec = 15;
866 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 888 return -1;
870 889 }
871 890  
872 891 nr = recv(fd, (char *) &r, 1, 0);
873 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 895 #if defined(X3270_TRACE) /*[*/
877 896 if (nread)
878   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  897 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
879 898 #endif /*]*/
880 899 return -1;
881 900 }
882 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 904 #if defined(X3270_TRACE) /*[*/
886 905 if (nread)
887   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  906 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
888 907 #endif /*]*/
889 908 return -1;
890 909 }
... ... @@ -896,10 +915,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
896 915 case 0:
897 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 919 #if defined(X3270_TRACE) /*[*/
901 920 if (nread)
902   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  921 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
903 922 #endif /*]*/
904 923 return -1;
905 924 }
... ... @@ -907,52 +926,49 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
907 926 case 1:
908 927 #if defined(X3270_TRACE) /*[*/
909 928 if (r != 0x00)
910   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  929 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
911 930 #endif /*]*/
912   - switch (r) {
  931 + switch (r)
  932 + {
913 933 case 0x00:
914   - break;
  934 + break;
915 935 case 0x01:
916   - popup_an_error(&h3270, "SOCKS5 Proxy: server failure");
  936 + popup_an_error(hSession, _("SOCKS5 Proxy: server failure"));
917 937 return -1;
918 938 case 0x02:
919   - popup_an_error(&h3270, "SOCKS5 Proxy: connection not allowed");
  939 + popup_an_error(hSession, _("SOCKS5 Proxy: connection not allowed"));
920 940 return -1;
921 941 case 0x03:
922   - popup_an_error(NULL,"SOCKS5 Proxy: network "
923   - "unreachable");
  942 + popup_an_error(hSession, _("SOCKS5 Proxy: network unreachable"));
924 943 return -1;
925 944 case 0x04:
926   - popup_an_error(NULL,"SOCKS5 Proxy: host "
927   - "unreachable");
  945 + popup_an_error(hSession, _("SOCKS5 Proxy: host unreachable"));
928 946 return -1;
929 947 case 0x05:
930   - popup_an_error(NULL,"SOCKS5 Proxy: connection "
931   - "refused");
  948 + popup_an_error(hSession, _("SOCKS5 Proxy: connection refused"));
932 949 return -1;
933 950 case 0x06:
934   - popup_an_error(NULL,"SOCKS5 Proxy: ttl expired");
  951 + popup_an_error(hSession, _("SOCKS5 Proxy: ttl expired"));
935 952 return -1;
936 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 955 return -1;
940 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 958 return -1;
944 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 961 return -1;
948 962 }
949 963 break;
  964 +
950 965 case 2:
951 966 break;
952 967 case 3:
953   - switch (r) {
  968 + switch (r)
  969 + {
954 970 case 0x01:
955   - n2read = 6;
  971 + n2read = 6;
956 972 break;
957 973 case 0x03:
958 974 n2read = -1;
... ... @@ -963,10 +979,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
963 979 break;
964 980 #endif /*]*/
965 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 983 #if defined(X3270_TRACE) /*[*/
968 984 if (nread)
969   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  985 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
970 986 #endif /*]*/
971 987 return -1;
972 988 }
... ... @@ -981,7 +997,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
981 997 }
982 998  
983 999 #if defined(X3270_TRACE) /*[*/
984   - trace_netdata(&h3270, '<', (unsigned char *)buf, nread);
  1000 + trace_netdata(hSession, '<', (unsigned char *)buf, nread);
985 1001 switch (buf[3]) {
986 1002 case 0x01: /* IPv4 */
987 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 1024 break;
1009 1025 }
1010 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 1028 buf[0], buf[1],
1014 1029 atype_name[(unsigned char)buf[3]],
1015 1030 nbuf,
... ...
proxyc.h
... ... @@ -17,6 +17,6 @@
17 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);
... ...
sf.c
... ... @@ -79,7 +79,7 @@ int * char_height = &amp;ch;
79 79  
80 80 /* Globals */
81 81 static Boolean sfont = False;
82   -Boolean * standard_font = &sfont;
  82 +static Boolean * standard_font = &sfont;
83 83  
84 84  
85 85 /* Statics */
... ...
telnet.c
... ... @@ -812,68 +812,68 @@ static void setup_lus(H3270 *hSession)
812 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 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 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 831 #if defined(HAVE_LIBSSL) /*[*/
832 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 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 845 else
846 846 {
847   - rc = SSL_connect(session->ssl_con);
  847 + rc = SSL_connect(hSession->ssl_con);
848 848  
849 849 if(rc != 1)
850 850 {
851 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 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 871 /* Tell everyone else again. */
872   - lib3270_set_connected(session);
  872 + lib3270_set_connected(hSession);
873 873 }
874 874 #endif /*]*/
875 875  
876   - lib3270_setup_session(session);
  876 + lib3270_setup_session(hSession);
877 877  
878 878 }
879 879  
... ...