Commit 4a7c0b1b1b980ea7f1f2cdf8de94b49391f11bf9

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

Ajustes para multi-sessao

src/lib3270/ctlr.c
... ... @@ -309,7 +309,7 @@ static void ctlr_connect(H3270 *session, int ignored unused, void *dunno)
309 309 session->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT;
310 310 if (!IN_3270 || (IN_SSCP && (session->kybdlock & KL_OIA_TWAIT)))
311 311 {
312   - kybdlock_clr(KL_OIA_TWAIT, "ctlr_connect");
  312 + kybdlock_clr(session,KL_OIA_TWAIT, "ctlr_connect");
313 313 status_reset(session);
314 314 }
315 315  
... ... @@ -457,7 +457,7 @@ void ctlr_erase(H3270 *session, int alt)
457 457 {
458 458 CHECK_SESSION_HANDLE(session);
459 459  
460   - kybd_inhibit(False);
  460 + kybd_inhibit(session,False);
461 461 ctlr_clear(session,True);
462 462 session->erase(session);
463 463  
... ... @@ -1067,7 +1067,7 @@ ctlr_erase_all_unprotected(void)
1067 1067 unsigned char fa;
1068 1068 Boolean f;
1069 1069  
1070   - kybd_inhibit(False);
  1070 + kybd_inhibit(&h3270,False);
1071 1071  
1072 1072 if (h3270.formatted) {
1073 1073 /* find first field attribute */
... ... @@ -1162,7 +1162,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1162 1162 h3270.formatted = True; \
1163 1163 }
1164 1164  
1165   - kybd_inhibit(False);
  1165 + kybd_inhibit(&h3270,False);
1166 1166  
1167 1167 if (buflen < 2)
1168 1168 return PDS_BAD_CMD;
... ... @@ -1865,7 +1865,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1865 1865 h3270.aid = AID_NO;
1866 1866 do_reset(&h3270,False);
1867 1867 } else if (h3270.kybdlock & KL_OIA_TWAIT) {
1868   - kybdlock_clr(KL_OIA_TWAIT, "ctlr_write");
  1868 + kybdlock_clr(&h3270,KL_OIA_TWAIT, "ctlr_write");
1869 1869 status_changed(&h3270,LIB3270_STATUS_SYSWAIT);
1870 1870 }
1871 1871 if (wcc_sound_alarm)
... ...
src/lib3270/kybd.c
... ... @@ -370,38 +370,47 @@ kybdlock_set(unsigned int bits, const char *cause unused)
370 370  
371 371 /* Clear bits in the keyboard lock. */
372 372 void
373   -kybdlock_clr(unsigned int bits, const char *cause unused)
  373 +kybdlock_clr(H3270 *session, unsigned int bits, const char *cause unused)
374 374 {
375 375 unsigned int n;
376 376  
377   - n = h3270.kybdlock & ~bits;
378   - if (n != h3270.kybdlock) {
  377 + n = session->kybdlock & ~bits;
  378 +
  379 + if (n != session->kybdlock)
  380 + {
379 381 #if defined(KYBDLOCK_TRACE)
380 382 trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n",cause, bits, kybdlock, n);
381 383 #endif
382   - if ((h3270.kybdlock ^ n) & KL_DEFERRED_UNLOCK) {
  384 + if ((session->kybdlock ^ n) & KL_DEFERRED_UNLOCK)
  385 + {
383 386 /* Turned off deferred unlock. */
384   - h3270.unlock_delay_time = 0;
  387 + session->unlock_delay_time = 0;
385 388 }
386   - h3270.kybdlock = n;
387   - status_changed(&h3270,LIB3270_STATUS_KYBDLOCK);
  389 + session->kybdlock = n;
  390 + status_changed(session,LIB3270_STATUS_KYBDLOCK);
388 391 }
389 392 }
390 393  
391   -/*
  394 +/**
392 395 * Set or clear enter-inhibit mode.
  396 + *
  397 + * @param session Session handle
  398 + * @param inhibit New state
  399 + *
393 400 */
394   -void
395   -kybd_inhibit(Boolean inhibit)
  401 +void kybd_inhibit(H3270 *session, Boolean inhibit)
396 402 {
397   - if (inhibit) {
  403 + if (inhibit)
  404 + {
398 405 kybdlock_set(KL_ENTER_INHIBIT, "kybd_inhibit");
399   - if (h3270.kybdlock == KL_ENTER_INHIBIT)
400   - status_reset(&h3270);
401   - } else {
402   - kybdlock_clr(KL_ENTER_INHIBIT, "kybd_inhibit");
403   - if (!h3270.kybdlock)
404   - status_reset(&h3270);
  406 + if (session->kybdlock == KL_ENTER_INHIBIT)
  407 + status_reset(session);
  408 + }
  409 + else
  410 + {
  411 + kybdlock_clr(session,KL_ENTER_INHIBIT, "kybd_inhibit");
  412 + if (!session->kybdlock)
  413 + status_reset(session);
405 414 }
406 415 }
407 416  
... ... @@ -413,7 +422,7 @@ void kybd_connect(H3270 *session, int connected, void *dunno)
413 422 if (session->kybdlock & KL_DEFERRED_UNLOCK)
414 423 RemoveTimeOut(session->unlock_id);
415 424  
416   - kybdlock_clr(-1, "kybd_connect");
  425 + kybdlock_clr(session, -1, "kybd_connect");
417 426  
418 427 if (connected) {
419 428 /* Wait for any output or a WCC(restore) from the host */
... ... @@ -431,7 +440,7 @@ void kybd_in3270(H3270 *session, int in3270 unused, void *dunno)
431 440 {
432 441 if (session->kybdlock & KL_DEFERRED_UNLOCK)
433 442 RemoveTimeOut(session->unlock_id);
434   - kybdlock_clr(~KL_AWAITING_FIRST, "kybd_in3270");
  443 + kybdlock_clr(session,~KL_AWAITING_FIRST, "kybd_in3270");
435 444  
436 445 /* There might be a macro pending. */
437 446 if (CONNECTED)
... ... @@ -1378,7 +1387,7 @@ LIB3270_KEY_ACTION( tab )
1378 1387  
1379 1388 if (hSession->kybdlock) {
1380 1389 if (KYBDLOCK_IS_OERR) {
1381   - kybdlock_clr(KL_OERR_MASK, "Tab");
  1390 + kybdlock_clr(hSession,KL_OERR_MASK, "Tab");
1382 1391 status_reset(hSession);
1383 1392 } else {
1384 1393 ENQUEUE_ACTION(lib3270_tab);
... ... @@ -1408,7 +1417,7 @@ LIB3270_KEY_ACTION( backtab )
1408 1417  
1409 1418 if (hSession->kybdlock) {
1410 1419 if (KYBDLOCK_IS_OERR) {
1411   - kybdlock_clr(KL_OERR_MASK, "BackTab");
  1420 + kybdlock_clr(hSession,KL_OERR_MASK, "BackTab");
1412 1421 status_reset(hSession);
1413 1422 } else {
1414 1423 ENQUEUE_ACTION(lib3270_backtab);
... ... @@ -1447,7 +1456,7 @@ LIB3270_KEY_ACTION( backtab )
1447 1456  
1448 1457 static void defer_unlock(H3270 *session)
1449 1458 {
1450   - kybdlock_clr(KL_DEFERRED_UNLOCK, "defer_unlock");
  1459 + kybdlock_clr(session,KL_DEFERRED_UNLOCK, "defer_unlock");
1451 1460 status_reset(session);
1452 1461 if (CONNECTED)
1453 1462 ps_process();
... ... @@ -1501,10 +1510,10 @@ void do_reset(H3270 *session, Boolean explicit)
1501 1510 #endif /*]*/
1502 1511 || (!session->unlock_delay) // && !sms_in_macro())
1503 1512 || (session->unlock_delay_time != 0 && (time(NULL) - session->unlock_delay_time) > 1)) {
1504   - kybdlock_clr(-1, "do_reset");
  1513 + kybdlock_clr(session,-1, "do_reset");
1505 1514 } else if (session->kybdlock &
1506 1515 (KL_DEFERRED_UNLOCK | KL_OIA_TWAIT | KL_OIA_LOCKED | KL_AWAITING_FIRST)) {
1507   - kybdlock_clr(~KL_DEFERRED_UNLOCK, "do_reset");
  1516 + kybdlock_clr(session,~KL_DEFERRED_UNLOCK, "do_reset");
1508 1517 kybdlock_set(KL_DEFERRED_UNLOCK, "do_reset");
1509 1518 session->unlock_id = AddTimeOut(UNLOCK_MS, session, defer_unlock);
1510 1519 }
... ... @@ -1580,7 +1589,7 @@ LIB3270_CURSOR_ACTION( left )
1580 1589 {
1581 1590 if (KYBDLOCK_IS_OERR)
1582 1591 {
1583   - kybdlock_clr(KL_OERR_MASK, "Left");
  1592 + kybdlock_clr(hSession,KL_OERR_MASK, "Left");
1584 1593 status_reset(&h3270);
1585 1594 }
1586 1595 else
... ... @@ -1843,8 +1852,8 @@ LIB3270_CURSOR_ACTION( right )
1843 1852 {
1844 1853 if (KYBDLOCK_IS_OERR)
1845 1854 {
1846   - kybdlock_clr(KL_OERR_MASK, "Right");
1847   - status_reset(&h3270);
  1855 + kybdlock_clr(hSession,KL_OERR_MASK, "Right");
  1856 + status_reset(hSession);
1848 1857 }
1849 1858 else
1850 1859 {
... ... @@ -1876,43 +1885,6 @@ LIB3270_CURSOR_ACTION( right )
1876 1885  
1877 1886  
1878 1887 /*
1879   - * Cursor left 2 positions.
1880   - */ /*
1881   -void
1882   -Left2_action(Widget w unused, XEvent *event, String *params,
1883   - Cardinal *num_params)
1884   -{
1885   - register int baddr;
1886   - enum dbcs_state d;
1887   -
1888   -// reset_idle_timer();
1889   - if (kybdlock) {
1890   - if (KYBDLOCK_IS_OERR) {
1891   - kybdlock_clr(KL_OERR_MASK, "Left2");
1892   - status_reset(&h3270);
1893   - } else {
1894   - enq_ta(Left2_action, CN, CN);
1895   - return;
1896   - }
1897   - }
1898   -#if defined(X3270_ANSI)
1899   - if (IN_ANSI)
1900   - return;
1901   -#endif
1902   - baddr = cursor_addr;
1903   - DEC_BA(baddr);
1904   - d = ctlr_dbcs_state(baddr);
1905   - if (IS_LEFT(d))
1906   - DEC_BA(baddr);
1907   - DEC_BA(baddr);
1908   - d = ctlr_dbcs_state(baddr);
1909   - if (IS_LEFT(d))
1910   - DEC_BA(baddr);
1911   - cursor_move(baddr);
1912   -} */
1913   -
1914   -
1915   -/*
1916 1888 * Cursor to previous word.
1917 1889 */
1918 1890 LIB3270_ACTION( previousword )
... ... @@ -1979,44 +1951,7 @@ LIB3270_ACTION( previousword )
1979 1951 return 0;
1980 1952 }
1981 1953  
1982   -
1983   -/*
1984   - * Cursor right 2 positions.
1985   - */ /*
1986   -void
1987   -Right2_action(Widget w unused, XEvent *event, String *params,
1988   - Cardinal *num_params)
1989   -{
1990   - register int baddr;
1991   - enum dbcs_state d;
1992 1954  
1993   -// reset_idle_timer();
1994   - if (kybdlock) {
1995   - if (KYBDLOCK_IS_OERR) {
1996   - kybdlock_clr(KL_OERR_MASK, "Right2");
1997   - status_reset(&h3270);
1998   - } else {
1999   - enq_ta(Right2_action, CN, CN);
2000   - return;
2001   - }
2002   - }
2003   -#if defined(X3270_ANSI)
2004   - if (IN_ANSI)
2005   - return;
2006   -#endif
2007   - baddr = cursor_addr;
2008   - INC_BA(baddr);
2009   - d = ctlr_dbcs_state(baddr);
2010   - if (IS_RIGHT(d))
2011   - INC_BA(baddr);
2012   - INC_BA(baddr);
2013   - d = ctlr_dbcs_state(baddr);
2014   - if (IS_RIGHT(d))
2015   - INC_BA(baddr);
2016   - cursor_move(baddr);
2017   -}
2018   -*/
2019   -
2020 1955 /* Find the next unprotected word, or -1 */
2021 1956 static int
2022 1957 nu_word(int baddr)
... ... @@ -2146,8 +2081,8 @@ LIB3270_CURSOR_ACTION( up )
2146 2081 if (hSession->kybdlock) {
2147 2082 if (KYBDLOCK_IS_OERR)
2148 2083 {
2149   - kybdlock_clr(KL_OERR_MASK, "Up");
2150   - status_reset(&h3270);
  2084 + kybdlock_clr(hSession,KL_OERR_MASK, "Up");
  2085 + status_reset(hSession);
2151 2086 }
2152 2087 else
2153 2088 {
... ... @@ -2184,8 +2119,8 @@ LIB3270_CURSOR_ACTION( down )
2184 2119 {
2185 2120 if (KYBDLOCK_IS_OERR)
2186 2121 {
2187   - kybdlock_clr(KL_OERR_MASK, "Down");
2188   - status_reset(&h3270);
  2122 + kybdlock_clr(hSession,KL_OERR_MASK, "Down");
  2123 + status_reset(hSession);
2189 2124 } else
2190 2125 {
2191 2126 ENQUEUE_ACTION(lib3270_cursor_down);
... ... @@ -2899,7 +2834,7 @@ kybd_scroll_lock(Boolean lock)
2899 2834 if (lock)
2900 2835 kybdlock_set(KL_SCROLLED, "kybd_scroll_lock");
2901 2836 else
2902   - kybdlock_clr(KL_SCROLLED, "kybd_scroll_lock");
  2837 + kybdlock_clr(&h3270, KL_SCROLLED, "kybd_scroll_lock");
2903 2838 }
2904 2839  
2905 2840 /*
... ...
src/lib3270/kybdc.h
... ... @@ -43,8 +43,8 @@ LIB3270_INTERNAL void add_xk(KeySym key, KeySym assoc);
43 43 LIB3270_INTERNAL void clear_xks(void);
44 44 LIB3270_INTERNAL void do_reset(H3270 *session, Boolean explicit);
45 45 LIB3270_INTERNAL void hex_input(char *s);
46   -LIB3270_INTERNAL void kybdlock_clr(unsigned int bits, const char *cause);
47   -LIB3270_INTERNAL void kybd_inhibit(Boolean inhibit);
  46 +LIB3270_INTERNAL void kybdlock_clr(H3270 *session, unsigned int bits, const char *cause);
  47 +LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit);
48 48 LIB3270_INTERNAL void kybd_init(void);
49 49 LIB3270_INTERNAL int kybd_prime(void);
50 50 LIB3270_INTERNAL void kybd_scroll_lock(Boolean lock);
... ...
src/lib3270/sf.c
... ... @@ -980,5 +980,5 @@ static void
980 980 query_reply_end(void)
981 981 {
982 982 net_output();
983   - kybd_inhibit(True);
  983 + kybd_inhibit(&h3270,True);
984 984 }
... ...
src/lib3270/telnet.c
... ... @@ -1191,7 +1191,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1191 1191 cooked_init();
1192 1192 #endif /*]*/
1193 1193 host_in3270(session,CONNECTED_ANSI);
1194   - kybdlock_clr(KL_AWAITING_FIRST, "telnet_fsm");
  1194 + kybdlock_clr(session,KL_AWAITING_FIRST, "telnet_fsm");
1195 1195 status_reset(session);
1196 1196 ps_process();
1197 1197 }
... ...