Commit 03d44b56445fa14258ba5170ea0fee1c59fc316b

Authored by perry.werneck@gmail.com
1 parent 2ef5a0e8

Movendo mais campos para a estrutura de sessao

pw3270.cbp
... ... @@ -59,6 +59,7 @@
59 59 <Unit filename="src/include/lib3270/filetransfer.h" />
60 60 <Unit filename="src/include/lib3270/html.h" />
61 61 <Unit filename="src/include/lib3270/log.h" />
  62 + <Unit filename="src/include/lib3270/macros.h" />
62 63 <Unit filename="src/include/lib3270/popup.h" />
63 64 <Unit filename="src/include/lib3270/selection.h" />
64 65 <Unit filename="src/include/lib3270/session.h" />
... ...
src/include/lib3270/action_table.h
... ... @@ -55,9 +55,9 @@
55 55 DECLARE_LIB3270_CURSOR_ACTION( newline )
56 56  
57 57 /* Misc actions */
58   - DECLARE_LIB3270_CLEAR_SELECTION_ACTION( reset )
59   - DECLARE_LIB3270_CLEAR_SELECTION_ACTION( clear )
60   - DECLARE_LIB3270_CLEAR_SELECTION_ACTION( eraseinput )
  58 + DECLARE_LIB3270_ACTION( reset )
  59 + DECLARE_LIB3270_ACTION( clear )
  60 + DECLARE_LIB3270_ACTION( eraseinput )
61 61  
62 62 DECLARE_LIB3270_ACTION( selectfield )
63 63 DECLARE_LIB3270_ACTION( selectall )
... ...
src/include/lib3270/actions.h
... ... @@ -30,13 +30,10 @@
30 30 *
31 31 */
32 32  
  33 + // Standard actions
33 34 #define DECLARE_LIB3270_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession);
34 35 #define LIB3270_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession)
35 36  
36   - // Clear actions - When called the selected area is cleared
37   - #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession);
38   - #define LIB3270_CLEAR_SELECTION_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession)
39   -
40 37 // Single key actions
41 38 #define DECLARE_LIB3270_KEY_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession);
42 39 #define LIB3270_KEY_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession)
... ... @@ -49,7 +46,6 @@
49 46 #define DECLARE_LIB3270_FKEY_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession, int key);
50 47 #define LIB3270_FKEY_ACTION( name ) LIB3270_EXPORT int lib3270_ ## name (H3270 *hSession, int key)
51 48  
52   -
53 49 // Load action table entries
54 50 #include <lib3270/action_table.h>
55 51  
... ...
src/include/lib3270/macros.h
... ... @@ -30,29 +30,7 @@
30 30 *
31 31 */
32 32  
33   - #define DECLARE_LIB3270_MACRO( name ) LIB3270_EXPORT char * lib3270_macro_ ## name (H3270 *hSession, int argc, const char **argv);
34 33 #define LIB3270_MACRO( name ) LIB3270_EXPORT char * lib3270_macro_ ## name (H3270 *hSession, int argc, const char **argv)
35 34  
36   - typedef struct _lib3270_macro_list
37   - {
38   - const char *name;
39   - char *(*exec)(H3270 *session, int argc, const char **argv);
40   - } LIB3270_MACRO_LIST;
41   -
42   -
43   -/*---[ Macro entries ]---------------------------------------------------------------------------------*/
44   -
45   - LIB3270_EXPORT const LIB3270_MACRO_LIST * get_3270_calls(void);
46   -
47   - DECLARE_LIB3270_MACRO( connect )
48   - DECLARE_LIB3270_MACRO( cstate )
49   - DECLARE_LIB3270_MACRO( disconnect )
50   - DECLARE_LIB3270_MACRO( encoding )
51   - DECLARE_LIB3270_MACRO( get )
52   - DECLARE_LIB3270_MACRO( luname )
53   - DECLARE_LIB3270_MACRO( set )
54   - DECLARE_LIB3270_MACRO( status )
55   - DECLARE_LIB3270_MACRO( pf )
56   - DECLARE_LIB3270_MACRO( pa )
57   - DECLARE_LIB3270_MACRO( enter )
  35 + LIB3270_EXPORT char * lib3270_run_macro(H3270 *session, const char **argv);
58 36  
... ...
src/include/lib3270/session.h
... ... @@ -169,6 +169,9 @@
169 169 unsigned char myopts[LIB3270_TELNET_N_OPTS];
170 170 unsigned char hisopts[LIB3270_TELNET_N_OPTS];
171 171  
  172 + // kybd.c
  173 + unsigned int kybdlock;
  174 +
172 175 // Widget info
173 176 void * widget;
174 177  
... ...
src/lib3270/ctlr.c
... ... @@ -307,7 +307,7 @@ static void ctlr_connect(H3270 *session, int ignored unused, void *dunno)
307 307 session->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY;
308 308 else
309 309 session->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT;
310   - if (!IN_3270 || (IN_SSCP && (kybdlock & KL_OIA_TWAIT)))
  310 + if (!IN_3270 || (IN_SSCP && (session->kybdlock & KL_OIA_TWAIT)))
311 311 {
312 312 kybdlock_clr(KL_OIA_TWAIT, "ctlr_connect");
313 313 status_reset(session);
... ... @@ -1106,7 +1106,7 @@ ctlr_erase_all_unprotected(void)
1106 1106 ctlr_clear(&h3270,True);
1107 1107 }
1108 1108 aid = AID_NO;
1109   - do_reset(False);
  1109 + do_reset(&h3270,False);
1110 1110 ALL_CHANGED;
1111 1111 }
1112 1112  
... ... @@ -1863,10 +1863,10 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1863 1863 trace_ds("\n");
1864 1864 if (wcc_keyboard_restore) {
1865 1865 aid = AID_NO;
1866   - do_reset(False);
1867   - } else if (kybdlock & KL_OIA_TWAIT) {
  1866 + do_reset(&h3270,False);
  1867 + } else if (h3270.kybdlock & KL_OIA_TWAIT) {
1868 1868 kybdlock_clr(KL_OIA_TWAIT, "ctlr_write");
1869   - status_syswait();
  1869 + status_changed(&h3270,LIB3270_STATUS_SYSWAIT);
1870 1870 }
1871 1871 if (wcc_sound_alarm)
1872 1872 lib3270_ring_bell(NULL);
... ... @@ -1987,7 +1987,7 @@ ctlr_write_sscp_lu(unsigned char buf[], int buflen)
1987 1987  
1988 1988 /* Unlock the keyboard. */
1989 1989 aid = AID_NO;
1990   - do_reset(False);
  1990 + do_reset(&h3270,False);
1991 1991  
1992 1992 }
1993 1993  
... ... @@ -2286,7 +2286,7 @@ ps_process(void)
2286 2286 if (lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE && /* transfer in progress */
2287 2287 h3270.formatted && /* screen is formatted */
2288 2288 !h3270.screen_alt && /* 24x80 screen */
2289   - !kybdlock && /* keyboard not locked */
  2289 + !h3270.kybdlock && /* keyboard not locked */
2290 2290 /* magic field */
2291 2291 h3270.ea_buf[1919].fa && FA_IS_SKIP(h3270.ea_buf[1919].fa)) {
2292 2292 ft_cut_data();
... ...
src/lib3270/kybd.c
... ... @@ -132,7 +132,7 @@ static struct xks {
132 132 static Boolean reverse = False; /* reverse-input mode */
133 133  
134 134 /* Globals */
135   -unsigned int kybdlock = KL_NOT_CONNECTED;
  135 +// unsigned int kybdlock = KL_NOT_CONNECTED;
136 136 unsigned char aid = AID_NO; /* current attention ID */
137 137  
138 138 /* Composite key mappings. */
... ... @@ -175,7 +175,7 @@ static struct ta
175 175  
176 176 static const char dxl[] = "0123456789abcdef";
177 177 #define FROM_HEX(c) (strchr(dxl, tolower(c)) - dxl)
178   -#define KYBDLOCK_IS_OERR (kybdlock && !(kybdlock & ~KL_OERR_MASK))
  178 +#define KYBDLOCK_IS_OERR (h3270.kybdlock && !(h3270.kybdlock & ~KL_OERR_MASK))
179 179  
180 180  
181 181 /*
... ... @@ -191,7 +191,7 @@ static int enq_chk(void)
191 191 }
192 192  
193 193 /* If operator error, complain and drop it. */
194   - if (kybdlock & KL_OERR_MASK)
  194 + if (h3270.kybdlock & KL_OERR_MASK)
195 195 {
196 196 lib3270_ring_bell(NULL);
197 197 trace_event(" dropped (operator error)\n");
... ... @@ -199,9 +199,9 @@ static int enq_chk(void)
199 199 }
200 200  
201 201 /* If scroll lock, complain and drop it. */
202   - if (kybdlock & KL_SCROLLED)
  202 + if (h3270.kybdlock & KL_SCROLLED)
203 203 {
204   - lib3270_ring_bell(NULL);
  204 + lib3270_ring_bell(&h3270);
205 205 trace_event(" dropped (scrolled)\n");
206 206 return -1;
207 207 }
... ... @@ -244,7 +244,7 @@ static int enq_chk(void)
244 244 }
245 245 ta_tail = ta;
246 246  
247   - trace_event(" Key-aid queued (kybdlock 0x%x)\n", kybdlock);
  247 + trace_event(" Key-aid queued (kybdlock 0x%x)\n", h3270.kybdlock);
248 248 }
249 249  
250 250 /*
... ... @@ -282,7 +282,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char
282 282 }
283 283 ta_tail = ta;
284 284  
285   - trace_event(" action queued (kybdlock 0x%x)\n", kybdlock);
  285 + trace_event(" action queued (kybdlock 0x%x)\n", h3270.kybdlock);
286 286 }
287 287  
288 288 /*
... ... @@ -292,7 +292,7 @@ Boolean run_ta(void)
292 292 {
293 293 struct ta *ta;
294 294  
295   - if (kybdlock || (ta = ta_head) == (struct ta *)NULL)
  295 + if (h3270.kybdlock || (ta = ta_head) == (struct ta *)NULL)
296 296 return False;
297 297  
298 298 if ((ta_head = ta->next) == (struct ta *)NULL)
... ... @@ -353,18 +353,18 @@ kybdlock_set(unsigned int bits, const char *cause unused)
353 353 {
354 354 unsigned int n;
355 355  
356   - n = kybdlock | bits;
357   - if (n != kybdlock) {
  356 + n = h3270.kybdlock | bits;
  357 + if (n != h3270.kybdlock) {
358 358 #if defined(KYBDLOCK_TRACE) /*[*/
359 359 trace_event(" %s: kybdlock |= 0x%04x, 0x%04x -> 0x%04x\n",
360 360 cause, bits, kybdlock, n);
361 361 #endif /*]*/
362   - if ((kybdlock ^ bits) & KL_DEFERRED_UNLOCK) {
  362 + if ((h3270.kybdlock ^ bits) & KL_DEFERRED_UNLOCK) {
363 363 /* Turned on deferred unlock. */
364 364 unlock_delay_time = time(NULL);
365 365 }
366   - kybdlock = n;
367   - status_kybdlock();
  366 + h3270.kybdlock = n;
  367 + status_changed(&h3270,LIB3270_STATUS_KYBDLOCK);
368 368 }
369 369 }
370 370  
... ... @@ -374,18 +374,17 @@ kybdlock_clr(unsigned int bits, const char *cause unused)
374 374 {
375 375 unsigned int n;
376 376  
377   - n = kybdlock & ~bits;
378   - if (n != kybdlock) {
379   -#if defined(KYBDLOCK_TRACE) /*[*/
380   - trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n",
381   - cause, bits, kybdlock, n);
382   -#endif /*]*/
383   - if ((kybdlock ^ n) & KL_DEFERRED_UNLOCK) {
  377 + n = h3270.kybdlock & ~bits;
  378 + if (n != h3270.kybdlock) {
  379 +#if defined(KYBDLOCK_TRACE)
  380 + trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n",cause, bits, kybdlock, n);
  381 +#endif
  382 + if ((h3270.kybdlock ^ n) & KL_DEFERRED_UNLOCK) {
384 383 /* Turned off deferred unlock. */
385 384 unlock_delay_time = 0;
386 385 }
387   - kybdlock = n;
388   - status_kybdlock();
  386 + h3270.kybdlock = n;
  387 + status_changed(&h3270,LIB3270_STATUS_KYBDLOCK);
389 388 }
390 389 }
391 390  
... ... @@ -397,11 +396,11 @@ kybd_inhibit(Boolean inhibit)
397 396 {
398 397 if (inhibit) {
399 398 kybdlock_set(KL_ENTER_INHIBIT, "kybd_inhibit");
400   - if (kybdlock == KL_ENTER_INHIBIT)
  399 + if (h3270.kybdlock == KL_ENTER_INHIBIT)
401 400 status_reset(&h3270);
402 401 } else {
403 402 kybdlock_clr(KL_ENTER_INHIBIT, "kybd_inhibit");
404   - if (!kybdlock)
  403 + if (!h3270.kybdlock)
405 404 status_reset(&h3270);
406 405 }
407 406 }
... ... @@ -411,7 +410,7 @@ kybd_inhibit(Boolean inhibit)
411 410 */
412 411 void kybd_connect(H3270 *session, int connected, void *dunno)
413 412 {
414   - if (kybdlock & KL_DEFERRED_UNLOCK)
  413 + if (session->kybdlock & KL_DEFERRED_UNLOCK)
415 414 RemoveTimeOut(unlock_id);
416 415  
417 416 kybdlock_clr(-1, "kybd_connect");
... ... @@ -430,7 +429,7 @@ void kybd_connect(H3270 *session, int connected, void *dunno)
430 429 */
431 430 void kybd_in3270(H3270 *session, int in3270 unused, void *dunno)
432 431 {
433   - if (kybdlock & KL_DEFERRED_UNLOCK)
  432 + if (session->kybdlock & KL_DEFERRED_UNLOCK)
434 433 RemoveTimeOut(unlock_id);
435 434 kybdlock_clr(~KL_AWAITING_FIRST, "kybd_in3270");
436 435  
... ... @@ -523,10 +522,10 @@ static void key_AID(H3270 *session, unsigned char aid_code)
523 522 trace("IN_SSCP: %d cursor_addr: %d",IN_SSCP,h3270.cursor_addr);
524 523  
525 524 if (IN_SSCP) {
526   - if (kybdlock & KL_OIA_MINUS)
  525 + if (h3270.kybdlock & KL_OIA_MINUS)
527 526 return;
528 527 if (aid_code != AID_ENTER && aid_code != AID_CLEAR) {
529   - status_minus();
  528 + status_changed(&h3270,LIB3270_STATUS_MINUS);
530 529 kybdlock_set(KL_OIA_MINUS, "key_AID");
531 530 return;
532 531 }
... ... @@ -555,9 +554,9 @@ LIB3270_FKEY_ACTION( pfkey )
555 554 if (key < 1 || key > PF_SZ)
556 555 return EINVAL;
557 556  
558   - if (kybdlock & KL_OIA_MINUS)
  557 + if (hSession->kybdlock & KL_OIA_MINUS)
559 558 return -1;
560   - else if (kybdlock)
  559 + else if (hSession->kybdlock)
561 560 enq_key(pf_xlate[key-1]);
562 561 else
563 562 key_AID(hSession,pf_xlate[key-1]);
... ... @@ -572,9 +571,9 @@ LIB3270_FKEY_ACTION( pakey )
572 571 return EINVAL;
573 572 }
574 573  
575   - if (kybdlock & KL_OIA_MINUS)
  574 + if (hSession->kybdlock & KL_OIA_MINUS)
576 575 return -1;
577   - else if (kybdlock)
  576 + else if (hSession->kybdlock)
578 577 enq_key(pa_xlate[key-1]);
579 578 else
580 579 key_AID(hSession,pa_xlate[key-1]);
... ... @@ -760,7 +759,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
760 759 if (skipped != NULL)
761 760 *skipped = False;
762 761  
763   - if (kybdlock)
  762 + if (h3270.kybdlock)
764 763 {
765 764 char codename[64];
766 765  
... ... @@ -1377,10 +1376,10 @@ LIB3270_KEY_ACTION( tab )
1377 1376  
1378 1377 // reset_idle_timer();
1379 1378  
1380   - if (kybdlock) {
  1379 + if (hSession->kybdlock) {
1381 1380 if (KYBDLOCK_IS_OERR) {
1382 1381 kybdlock_clr(KL_OERR_MASK, "Tab");
1383   - status_reset(&h3270);
  1382 + status_reset(hSession);
1384 1383 } else {
1385 1384 ENQUEUE_ACTION(lib3270_tab);
1386 1385 return 0;
... ... @@ -1407,10 +1406,10 @@ LIB3270_KEY_ACTION( backtab )
1407 1406  
1408 1407 // reset_idle_timer();
1409 1408  
1410   - if (kybdlock) {
  1409 + if (hSession->kybdlock) {
1411 1410 if (KYBDLOCK_IS_OERR) {
1412 1411 kybdlock_clr(KL_OERR_MASK, "BackTab");
1413   - status_reset(&h3270);
  1412 + status_reset(hSession);
1414 1413 } else {
1415 1414 ENQUEUE_ACTION(lib3270_backtab);
1416 1415 return 0;
... ... @@ -1418,26 +1417,26 @@ LIB3270_KEY_ACTION( backtab )
1418 1417 }
1419 1418 if (!IN_3270)
1420 1419 return 0;
1421   - baddr = h3270.cursor_addr;
  1420 + baddr = hSession->cursor_addr;
1422 1421 DEC_BA(baddr);
1423   - if (h3270.ea_buf[baddr].fa) /* at bof */
  1422 + if (hSession->ea_buf[baddr].fa) /* at bof */
1424 1423 DEC_BA(baddr);
1425 1424 sbaddr = baddr;
1426 1425 while (True) {
1427 1426 nbaddr = baddr;
1428 1427 INC_BA(nbaddr);
1429   - if (h3270.ea_buf[baddr].fa &&
1430   - !FA_IS_PROTECTED(h3270.ea_buf[baddr].fa) &&
1431   - !h3270.ea_buf[nbaddr].fa)
  1428 + if (hSession->ea_buf[baddr].fa &&
  1429 + !FA_IS_PROTECTED(hSession->ea_buf[baddr].fa) &&
  1430 + !hSession->ea_buf[nbaddr].fa)
1432 1431 break;
1433 1432 DEC_BA(baddr);
1434 1433 if (baddr == sbaddr) {
1435   - cursor_move(&h3270,0);
  1434 + cursor_move(hSession,0);
1436 1435 return 0;
1437 1436 }
1438 1437 }
1439 1438 INC_BA(baddr);
1440   - cursor_move(&h3270,baddr);
  1439 + cursor_move(hSession,baddr);
1441 1440 return 0;
1442 1441 }
1443 1442  
... ... @@ -1457,8 +1456,7 @@ static void defer_unlock(H3270 *session)
1457 1456 /*
1458 1457 * Reset keyboard lock.
1459 1458 */
1460   -void
1461   -do_reset(Boolean explicit)
  1459 +void do_reset(H3270 *session, Boolean explicit)
1462 1460 {
1463 1461 /*
1464 1462 * If explicit (from the keyboard) and there is typeahead or
... ... @@ -1467,7 +1465,7 @@ do_reset(Boolean explicit)
1467 1465  
1468 1466 if (explicit
1469 1467 #if defined(X3270_FT) /*[*/
1470   - || lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE
  1468 + || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE
1471 1469 #endif /*]*/
1472 1470 ) {
1473 1471 Boolean half_reset = False;
... ... @@ -1475,19 +1473,12 @@ do_reset(Boolean explicit)
1475 1473 if (flush_ta())
1476 1474 half_reset = True;
1477 1475  
1478   -/*
1479   - if (composing != NONE) {
1480   - composing = NONE;
1481   - status_compose(False, 0, KT_STD);
1482   - half_reset = True;
1483   - }
1484   -*/
1485 1476 if (half_reset)
1486 1477 return;
1487 1478 }
1488 1479  
1489 1480 /* Always clear insert mode. */
1490   - lib3270_set_toggle(&h3270,LIB3270_TOGGLE_INSERT,0);
  1481 + lib3270_set_toggle(session,LIB3270_TOGGLE_INSERT,0);
1491 1482  
1492 1483 /* Otherwise, if not connect, reset is a no-op. */
1493 1484 if (!CONNECTED)
... ... @@ -1497,7 +1488,7 @@ do_reset(Boolean explicit)
1497 1488 * Remove any deferred keyboard unlock. We will either unlock the
1498 1489 * keyboard now, or want to defer further into the future.
1499 1490 */
1500   - if (kybdlock & KL_DEFERRED_UNLOCK)
  1491 + if (session->kybdlock & KL_DEFERRED_UNLOCK)
1501 1492 RemoveTimeOut(unlock_id);
1502 1493  
1503 1494 /*
... ... @@ -1506,29 +1497,28 @@ do_reset(Boolean explicit)
1506 1497 */
1507 1498 if (explicit
1508 1499 #if defined(X3270_FT) /*[*/
1509   - || lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE
  1500 + || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE
1510 1501 #endif /*]*/
1511   - || (!h3270.unlock_delay) // && !sms_in_macro())
  1502 + || (!session->unlock_delay) // && !sms_in_macro())
1512 1503 || (unlock_delay_time != 0 && (time(NULL) - unlock_delay_time) > 1)) {
1513 1504 kybdlock_clr(-1, "do_reset");
1514   - } else if (kybdlock &
  1505 + } else if (session->kybdlock &
1515 1506 (KL_DEFERRED_UNLOCK | KL_OIA_TWAIT | KL_OIA_LOCKED | KL_AWAITING_FIRST)) {
1516 1507 kybdlock_clr(~KL_DEFERRED_UNLOCK, "do_reset");
1517 1508 kybdlock_set(KL_DEFERRED_UNLOCK, "do_reset");
1518   - unlock_id = AddTimeOut(UNLOCK_MS, &h3270, defer_unlock);
  1509 + unlock_id = AddTimeOut(UNLOCK_MS, session, defer_unlock);
1519 1510 }
1520 1511  
1521 1512 /* Clean up other modes. */
1522   - status_reset(&h3270);
1523   - mcursor_normal(&h3270);
  1513 + status_reset(session);
  1514 + mcursor_normal(session);
1524 1515  
1525 1516 }
1526 1517  
1527   -LIB3270_CLEAR_SELECTION_ACTION( reset )
  1518 +LIB3270_ACTION( reset )
1528 1519 {
1529   -// reset_idle_timer();
1530   -
1531   - do_reset(True);
  1520 + lib3270_unselect(hSession);
  1521 + do_reset(hSession,True);
1532 1522 return 0;
1533 1523 }
1534 1524  
... ... @@ -1539,7 +1529,8 @@ LIB3270_CLEAR_SELECTION_ACTION( reset )
1539 1529 LIB3270_ACTION( firstfield )
1540 1530 {
1541 1531 // reset_idle_timer();
1542   - if (kybdlock) {
  1532 + if (hSession->kybdlock)
  1533 + {
1543 1534 ENQUEUE_ACTION(lib3270_firstfield);
1544 1535 return 0;
1545 1536 }
... ... @@ -1585,7 +1576,7 @@ void Left_action(Widget w unused, XEvent *event, String *params, Cardinal *num_p
1585 1576  
1586 1577 LIB3270_CURSOR_ACTION( left )
1587 1578 {
1588   - if (kybdlock)
  1579 + if (hSession->kybdlock)
1589 1580 {
1590 1581 if (KYBDLOCK_IS_OERR)
1591 1582 {
... ... @@ -1705,7 +1696,7 @@ do_delete(void)
1705 1696  
1706 1697 LIB3270_ACTION( delete )
1707 1698 {
1708   - if (kybdlock)
  1699 + if (hSession->kybdlock)
1709 1700 {
1710 1701 ENQUEUE_ACTION(lib3270_delete);
1711 1702 return 0;
... ... @@ -1735,7 +1726,7 @@ LIB3270_ACTION( delete )
1735 1726 */
1736 1727 LIB3270_ACTION( backspace )
1737 1728 {
1738   - if (kybdlock)
  1729 + if (hSession->kybdlock)
1739 1730 {
1740 1731 ENQUEUE_ACTION( lib3270_backspace );
1741 1732 return 0;
... ... @@ -1825,7 +1816,7 @@ do_erase(void)
1825 1816 LIB3270_ACTION( erase )
1826 1817 {
1827 1818 // reset_idle_timer();
1828   - if (kybdlock) {
  1819 + if (hSession->kybdlock) {
1829 1820 ENQUEUE_ACTION(lib3270_erase);
1830 1821 return 0;
1831 1822 }
... ... @@ -1847,7 +1838,7 @@ LIB3270_CURSOR_ACTION( right )
1847 1838 register int baddr;
1848 1839 enum dbcs_state d;
1849 1840  
1850   - if (kybdlock)
  1841 + if (hSession->kybdlock)
1851 1842 {
1852 1843 if (KYBDLOCK_IS_OERR)
1853 1844 {
... ... @@ -1931,7 +1922,7 @@ LIB3270_ACTION( previousword )
1931 1922 Boolean prot;
1932 1923  
1933 1924 // reset_idle_timer();
1934   - if (kybdlock) {
  1925 + if (hSession->kybdlock) {
1935 1926 ENQUEUE_ACTION(lib3270_previousword);
1936 1927 // enq_ta(PreviousWord_action, CN, CN);
1937 1928 return 0;
... ... @@ -2082,7 +2073,7 @@ LIB3270_ACTION( nextword )
2082 2073 unsigned char c;
2083 2074  
2084 2075 // reset_idle_timer();
2085   - if (kybdlock) {
  2076 + if (hSession->kybdlock) {
2086 2077 ENQUEUE_ACTION( lib3270_nextword );
2087 2078 // enq_ta(NextWord_action, CN, CN);
2088 2079 return 0;
... ... @@ -2151,7 +2142,7 @@ LIB3270_CURSOR_ACTION( up )
2151 2142 register int baddr;
2152 2143  
2153 2144 // reset_idle_timer();
2154   - if (kybdlock) {
  2145 + if (hSession->kybdlock) {
2155 2146 if (KYBDLOCK_IS_OERR)
2156 2147 {
2157 2148 kybdlock_clr(KL_OERR_MASK, "Up");
... ... @@ -2188,7 +2179,7 @@ LIB3270_CURSOR_ACTION( down )
2188 2179 register int baddr;
2189 2180  
2190 2181 // reset_idle_timer();
2191   - if (kybdlock)
  2182 + if (hSession->kybdlock)
2192 2183 {
2193 2184 if (KYBDLOCK_IS_OERR)
2194 2185 {
... ... @@ -2222,11 +2213,9 @@ LIB3270_CURSOR_ACTION( newline )
2222 2213 register int baddr, faddr;
2223 2214 register unsigned char fa;
2224 2215  
2225   -// reset_idle_timer();
2226   - if (kybdlock)
  2216 + if (hSession->kybdlock)
2227 2217 {
2228 2218 ENQUEUE_ACTION(lib3270_cursor_newline);
2229   -// enq_ta(Newline_action, CN, CN);
2230 2219 return 0;
2231 2220 }
2232 2221 #if defined(X3270_ANSI) /*[*/
... ... @@ -2254,7 +2243,7 @@ LIB3270_CURSOR_ACTION( newline )
2254 2243 */
2255 2244 LIB3270_ACTION( dup )
2256 2245 {
2257   - if (kybdlock)
  2246 + if (hSession->kybdlock)
2258 2247 {
2259 2248 ENQUEUE_ACTION(lib3270_dup);
2260 2249 return 0;
... ... @@ -2277,7 +2266,7 @@ LIB3270_ACTION( dup )
2277 2266 */
2278 2267 LIB3270_ACTION( fieldmark )
2279 2268 {
2280   - if (kybdlock)
  2269 + if (hSession->kybdlock)
2281 2270 {
2282 2271 ENQUEUE_ACTION(lib3270_fieldmark);
2283 2272 return 0;
... ... @@ -2301,13 +2290,11 @@ LIB3270_ACTION( fieldmark )
2301 2290 */
2302 2291 LIB3270_KEY_ACTION( enter )
2303 2292 {
2304   -// reset_idle_timer();
2305   -
2306   - trace("%s (kybdlock & KL_OIA_MINUS): %d kybdlock: %d",__FUNCTION__,(kybdlock & KL_OIA_MINUS),kybdlock);
  2293 + trace("%s (kybdlock & KL_OIA_MINUS): %d kybdlock: %d",__FUNCTION__,(hSession->kybdlock & KL_OIA_MINUS),hSession->kybdlock);
2307 2294  
2308   - if (kybdlock & KL_OIA_MINUS)
  2295 + if (hSession->kybdlock & KL_OIA_MINUS)
2309 2296 return -1;
2310   - else if (kybdlock)
  2297 + else if (hSession->kybdlock)
2311 2298 ENQUEUE_ACTION(lib3270_enter);
2312 2299 else
2313 2300 key_AID(hSession,AID_ENTER);
... ... @@ -2326,9 +2313,9 @@ LIB3270_ACTION( sysreq )
2326 2313 } else
2327 2314 #endif /*]*/
2328 2315 {
2329   - if (kybdlock & KL_OIA_MINUS)
  2316 + if (hSession->kybdlock & KL_OIA_MINUS)
2330 2317 return 0;
2331   - else if (kybdlock)
  2318 + else if (hSession->kybdlock)
2332 2319 ENQUEUE_ACTION(lib3270_sysreq);
2333 2320 else
2334 2321 key_AID(hSession,AID_SYSREQ);
... ... @@ -2343,9 +2330,9 @@ LIB3270_ACTION( sysreq )
2343 2330 LIB3270_ACTION( clear )
2344 2331 {
2345 2332 // reset_idle_timer();
2346   - if (kybdlock & KL_OIA_MINUS)
  2333 + if (hSession->kybdlock & KL_OIA_MINUS)
2347 2334 return 0;
2348   - if (kybdlock && CONNECTED) {
  2335 + if (hSession->kybdlock && CONNECTED) {
2349 2336 ENQUEUE_ACTION(lib3270_clear);
2350 2337 return 0;
2351 2338 }
... ... @@ -2485,7 +2472,7 @@ LIB3270_ACTION( eraseeol )
2485 2472 enum dbcs_why why = DBCS_FIELD;
2486 2473  
2487 2474 // reset_idle_timer();
2488   - if (kybdlock)
  2475 + if (hSession->kybdlock)
2489 2476 {
2490 2477 ENQUEUE_ACTION(lib3270_eraseeol);
2491 2478 return 0;
... ... @@ -2551,7 +2538,7 @@ LIB3270_ACTION( eraseeof )
2551 2538 enum dbcs_why why = DBCS_FIELD;
2552 2539  
2553 2540 // reset_idle_timer();
2554   - if (kybdlock)
  2541 + if (hSession->kybdlock)
2555 2542 {
2556 2543 ENQUEUE_ACTION(lib3270_eraseeof);
2557 2544 return 0;
... ... @@ -2601,7 +2588,7 @@ LIB3270_ACTION( eraseinput )
2601 2588 Boolean f;
2602 2589  
2603 2590 // reset_idle_timer();
2604   - if (kybdlock) {
  2591 + if (hSession->kybdlock) {
2605 2592 ENQUEUE_ACTION( lib3270_eraseinput );
2606 2593 return 0;
2607 2594 }
... ... @@ -2664,7 +2651,7 @@ LIB3270_ACTION( deleteword )
2664 2651 register unsigned char fa;
2665 2652  
2666 2653 // reset_idle_timer();
2667   - if (kybdlock) {
  2654 + if (hSession->kybdlock) {
2668 2655 ENQUEUE_ACTION(lib3270_deleteword);
2669 2656 // enq_ta(DeleteWord_action, CN, CN);
2670 2657 return 0;
... ... @@ -2731,7 +2718,7 @@ LIB3270_ACTION( deletefield )
2731 2718 register unsigned char fa;
2732 2719  
2733 2720 // reset_idle_timer();
2734   - if (kybdlock) {
  2721 + if (hSession->kybdlock) {
2735 2722 ENQUEUE_ACTION(lib3270_deletefield);
2736 2723 // enq_ta(DeleteField_action, CN, CN);
2737 2724 return 0;
... ... @@ -2836,8 +2823,8 @@ LIB3270_ACTION( fieldend )
2836 2823 unsigned char fa, c;
2837 2824 int last_nonblank = -1;
2838 2825  
2839   -// reset_idle_timer();
2840   - if (kybdlock) {
  2826 + if (hSession->kybdlock)
  2827 + {
2841 2828 ENQUEUE_ACTION( lib3270_fieldend );
2842 2829 return 0;
2843 2830 }
... ... @@ -3003,7 +2990,8 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
3003 2990 * It isn't possible to unlock the keyboard from a string,
3004 2991 * so if the keyboard is locked, it's fatal
3005 2992 */
3006   - if (kybdlock) {
  2993 + if (session->kybdlock)
  2994 + {
3007 2995 trace_event(" keyboard locked, string dropped\n");
3008 2996 return 0;
3009 2997 }
... ... @@ -3350,7 +3338,7 @@ kybd_prime(void)
3350 3338 * No point in trying if the screen isn't formatted, the keyboard
3351 3339 * is locked, or we aren't in 3270 mode.
3352 3340 */
3353   - if (!h3270.formatted || kybdlock || !IN_3270)
  3341 + if (!h3270.formatted || h3270.kybdlock || !IN_3270)
3354 3342 return 0;
3355 3343  
3356 3344 fa = get_field_attribute(&h3270,h3270.cursor_addr);
... ...
src/lib3270/kybdc.h
... ... @@ -22,7 +22,7 @@
22 22 #define KYBDC_H_INCLUDED
23 23  
24 24 /* keyboard lock states */
25   -LIB3270_INTERNAL unsigned int kybdlock;
  25 +// LIB3270_INTERNAL unsigned int kybdlock;
26 26 #define KL_OERR_MASK 0x000f
27 27 #define KL_OERR_PROTECTED 1
28 28 #define KL_OERR_NUMERIC 2
... ... @@ -37,114 +37,11 @@ LIB3270_INTERNAL unsigned int kybdlock;
37 37 #define KL_SCROLLED 0x0400
38 38 #define KL_OIA_MINUS 0x0800
39 39  
40   -// void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause, Boolean *skipped);
41   -
42   -/* actions */ /*
43   -extern void AltCursor_action(Widget w, XEvent *event, String *params,
44   - Cardinal *num_params);
45   -extern void Attn_action(Widget w, XEvent *event, String *params,
46   - Cardinal *num_params);
47   -extern void BackSpace_action(Widget w, XEvent *event, String *params,
48   - Cardinal *num_params);
49   -extern void BackTab_action(Widget w, XEvent *event, String *params,
50   - Cardinal *num_params);
51   -extern void CircumNot_action(Widget w, XEvent *event, String *params,
52   - Cardinal *num_params); */
53   -/*
54   -extern void Clear_action(Widget w, XEvent *event, String *params,
55   - Cardinal *num_params);
56   -*/ /*
57   -extern void Compose_action(Widget w, XEvent *event, String *params,
58   - Cardinal *num_params);
59   -extern void CursorSelect_action(Widget w, XEvent *event, String *params,
60   - Cardinal *num_params);
61   -extern void Default_action(Widget w, XEvent *event, String *params,
62   - Cardinal *num_params);
63   -extern void DeleteField_action(Widget w, XEvent *event, String *params,
64   - Cardinal *num_params);
65   -extern void DeleteWord_action(Widget w, XEvent *event, String *params,
66   - Cardinal *num_params);
67   -extern void Delete_action(Widget w, XEvent *event, String *params,
68   - Cardinal *num_params);
69   -extern void Down_action(Widget w, XEvent *event, String *params,
70   - Cardinal *num_params);
71   -extern void Dup_action(Widget w, XEvent *event, String *params,
72   - Cardinal *num_params);
73   -extern void Enter_action(Widget w, XEvent *event, String *params,
74   - Cardinal *num_params);
75   -extern void EraseEOF_action(Widget w, XEvent *event, String *params,
76   - Cardinal *num_params);
77   -extern void EraseInput_action(Widget w, XEvent *event, String *params,
78   - Cardinal *num_params);
79   -extern void Erase_action(Widget w, XEvent *event, String *params,
80   - Cardinal *num_params);
81   -extern void FieldEnd_action(Widget w, XEvent *event, String *params,
82   - Cardinal *num_params);
83   -extern void FieldMark_action(Widget w, XEvent *event, String *params,
84   - Cardinal *num_params);
85   -extern void Flip_action(Widget w, XEvent *event, String *params,
86   - Cardinal *num_params);
87   -extern void HexString_action(Widget w, XEvent *event, String *params,
88   - Cardinal *num_params);
89   -extern void Home_action(Widget w, XEvent *event, String *params,
90   - Cardinal *num_params);
91   -extern void ignore_action(Widget w, XEvent *event, String *params,
92   - Cardinal *num_params);
93   -extern void Insert_action(Widget w, XEvent *event, String *params,
94   - Cardinal *num_params);
95   -extern void Interrupt_action(Widget w, XEvent *event, String *params,
96   - Cardinal *num_params);
97   -extern void Key_action(Widget w, XEvent *event, String *params,
98   - Cardinal *num_params);
99   -extern void Left2_action(Widget w, XEvent *event, String *params,
100   - Cardinal *num_params);
101   -extern void Left_action(Widget w, XEvent *event, String *params,
102   - Cardinal *num_params);
103   -extern void MonoCase_action(Widget w, XEvent *event, String *params,
104   - Cardinal *num_params);
105   -extern void MouseSelect_action(Widget w, XEvent *event, String *params,
106   - Cardinal *num_params);
107   -extern void MoveCursor_action(Widget w, XEvent *event, String *params,
108   - Cardinal *num_params);
109   -extern void Newline_action(Widget w, XEvent *event, String *params,
110   - Cardinal *num_params);
111   -extern void NextWord_action(Widget w, XEvent *event, String *params,
112   - Cardinal *num_params);
113   -extern void PA_action(Widget w, XEvent *event, String *params,
114   - Cardinal *num_params);
115   -extern void PA_Shift_action(Widget w, XEvent *event, String *params,
116   - Cardinal *num_params);
117   -
118   -//extern void PF_action(Widget w, XEvent *event, String *params, Cardinal *num_params);
119   -
120   -extern void PreviousWord_action(Widget w, XEvent *event, String *params,
121   - Cardinal *num_params);
122   -extern void Reset_action(Widget w, XEvent *event, String *params,
123   - Cardinal *num_params);
124   -extern void Right2_action(Widget w, XEvent *event, String *params,
125   - Cardinal *num_params);
126   -extern void Right_action(Widget w, XEvent *event, String *params,
127   - Cardinal *num_params);
128   -extern void String_action(Widget w, XEvent *event, String *params,
129   - Cardinal *num_params);
130   -extern void SysReq_action(Widget w, XEvent *event, String *params,
131   - Cardinal *num_params);
132   -extern void Tab_action(Widget w, XEvent *event, String *params,
133   - Cardinal *num_params);
134   -extern void TemporaryKeymap_action(Widget w, XEvent *event, String *params,
135   - Cardinal *num_params);
136   -extern void ToggleInsert_action(Widget w, XEvent *event, String *params,
137   - Cardinal *num_params);
138   -extern void ToggleReverse_action(Widget w, XEvent *event, String *params,
139   - Cardinal *num_params);
140   -extern void Up_action(Widget w, XEvent *event, String *params, Cardinal *num_params);
141   -
142   -*/
143 40  
144 41 /* other functions */
145 42 LIB3270_INTERNAL void add_xk(KeySym key, KeySym assoc);
146 43 LIB3270_INTERNAL void clear_xks(void);
147   -LIB3270_INTERNAL void do_reset(Boolean explicit);
  44 +LIB3270_INTERNAL void do_reset(H3270 *session, Boolean explicit);
148 45 LIB3270_INTERNAL void hex_input(char *s);
149 46 LIB3270_INTERNAL void kybdlock_clr(unsigned int bits, const char *cause);
150 47 LIB3270_INTERNAL void kybd_inhibit(Boolean inhibit);
... ...
src/lib3270/macros.c
... ... @@ -342,7 +342,6 @@
342 342 action[] =
343 343 {
344 344 #define DECLARE_LIB3270_ACTION( name ) { #name, lib3270_ ## name },
345   - #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) { #name, lib3270_ ## name },
346 345 #define DECLARE_LIB3270_KEY_ACTION( name ) { #name, lib3270_ ## name },
347 346 #define DECLARE_LIB3270_CURSOR_ACTION( name ) { #name, lib3270_cursor_ ## name },
348 347 #define DECLARE_LIB3270_FKEY_ACTION( name ) /* */
... ...
src/lib3270/paste.c
... ... @@ -186,12 +186,12 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
186 186 data.orig_addr = h->cursor_addr;
187 187 data.orig_col = BA_TO_COL(h->cursor_addr);
188 188  
189   - if(kybdlock)
  189 + if(h->kybdlock)
190 190 return -EINVAL;
191 191  
192 192 h->suspend(h);
193 193  
194   - while(*str && last && !kybdlock && h->cursor_addr >= data.orig_addr)
  194 + while(*str && last && !h->kybdlock && h->cursor_addr >= data.orig_addr)
195 195 {
196 196 switch(*str)
197 197 {
... ...
src/lib3270/screen.c
... ... @@ -454,11 +454,11 @@ void status_reset(H3270 *session)
454 454 {
455 455 CHECK_SESSION_HANDLE(session);
456 456  
457   - if (kybdlock & KL_ENTER_INHIBIT)
  457 + if (session->kybdlock & KL_ENTER_INHIBIT)
458 458 {
459 459 status_changed(session,LIB3270_STATUS_INHIBIT);
460 460 }
461   - else if (kybdlock & KL_DEFERRED_UNLOCK)
  461 + else if (session->kybdlock & KL_DEFERRED_UNLOCK)
462 462 {
463 463 status_changed(session,LIB3270_STATUS_X);
464 464 }
... ... @@ -540,7 +540,7 @@ static void status_connect(H3270 *session, int connected, void *dunno)
540 540 {
541 541 set_status(session,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP);
542 542  
543   - if (kybdlock & KL_AWAITING_FIRST)
  543 + if (session->kybdlock & KL_AWAITING_FIRST)
544 544 id = LIB3270_STATUS_AWAITING_FIRST;
545 545 else
546 546 id = LIB3270_STATUS_CONNECTED;
... ...
src/lib3270/session.c
... ... @@ -43,6 +43,7 @@
43 43 #include "screenc.h"
44 44 #include "ctlrc.h"
45 45 #include "ftc.h"
  46 +#include "kybdc.h"
46 47  
47 48 /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
48 49  
... ... @@ -193,6 +194,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
193 194 hSession->model_num = -1;
194 195 hSession->cstate = LIB3270_NOT_CONNECTED;
195 196 hSession->oia_status = -1;
  197 + hSession->kybdlock = KL_NOT_CONNECTED;
196 198  
197 199 #ifdef _WIN32
198 200 hSession->sockEvent = NULL;
... ...
src/lib3270/statusc.h
... ... @@ -35,7 +35,7 @@ LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on);
35 35  
36 36  
37 37 #define status_typeahead(h,on) set_status(h,OIA_FLAG_TYPEAHEAD,on)
38   -#define status_kybdlock() status_changed(NULL,LIB3270_STATUS_KYBDLOCK)
39   -#define status_syswait() status_changed(NULL,LIB3270_STATUS_SYSWAIT)
40   -#define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS)
  38 +// #define status_kybdlock(h) status_changed(h,LIB3270_STATUS_KYBDLOCK)
  39 +// #define status_syswait(h) status_changed(h,LIB3270_STATUS_SYSWAIT)
  40 +// #define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS)
41 41  
... ...
src/lib3270/telnet.c
... ... @@ -2131,7 +2131,7 @@ static void
2131 2131 net_cookout(const char *buf, int len)
2132 2132 {
2133 2133  
2134   - if (!IN_ANSI || (kybdlock & KL_AWAITING_FIRST))
  2134 + if (!IN_ANSI || (h3270.kybdlock & KL_AWAITING_FIRST))
2135 2135 return;
2136 2136  
2137 2137 if (linemode) {
... ...