Commit 037fc4f7c1361834c49b0fd33030949ee5a4003a

Authored by perry.werneck@gmail.com
1 parent 03d44b56

Movendo statics para a estrutura de sessao

src/include/lib3270/session.h
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 #ifndef LIB3270_SESSION_H_INCLUDED 32 #ifndef LIB3270_SESSION_H_INCLUDED
33 33
34 #define LIB3270_SESSION_H_INCLUDED 1 34 #define LIB3270_SESSION_H_INCLUDED 1
  35 + #include <sys/time.h>
35 36
36 #define LIB3270_LUNAME_LENGTH 16 37 #define LIB3270_LUNAME_LENGTH 16
37 #define LIB3270_FULL_MODEL_NAME_LENGTH 13 38 #define LIB3270_FULL_MODEL_NAME_LENGTH 13
@@ -99,6 +100,7 @@ @@ -99,6 +100,7 @@
99 int onlcr : 1; 100 int onlcr : 1;
100 int bsd_tm : 1; 101 int bsd_tm : 1;
101 int syncing : 1; 102 int syncing : 1;
  103 + int reverse : 1; /**< reverse-input mode */
102 104
103 char * oversize; 105 char * oversize;
104 106
@@ -171,6 +173,9 @@ @@ -171,6 +173,9 @@
171 173
172 // kybd.c 174 // kybd.c
173 unsigned int kybdlock; 175 unsigned int kybdlock;
  176 + unsigned char aid; /**< current attention ID */
  177 + void * unlock_id;
  178 + time_t unlock_delay_time;
174 179
175 // Widget info 180 // Widget info
176 void * widget; 181 void * widget;
src/lib3270/ctlr.c
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 #include "screenc.h" 66 #include "screenc.h"
67 67
68 /* Externals: kybd.c */ 68 /* Externals: kybd.c */
69 -extern unsigned char aid; 69 +// extern unsigned char aid;
70 70
71 /* Globals */ 71 /* Globals */
72 // int ROWS, COLS; 72 // int ROWS, COLS;
@@ -537,19 +537,19 @@ process_ds(unsigned char *buf, int buflen) @@ -537,19 +537,19 @@ process_ds(unsigned char *buf, int buflen)
537 case CMD_RB: /* read buffer */ 537 case CMD_RB: /* read buffer */
538 case SNA_CMD_RB: 538 case SNA_CMD_RB:
539 trace_ds("ReadBuffer\n"); 539 trace_ds("ReadBuffer\n");
540 - ctlr_read_buffer(aid); 540 + ctlr_read_buffer(h3270.aid);
541 return PDS_OKAY_OUTPUT; 541 return PDS_OKAY_OUTPUT;
542 break; 542 break;
543 case CMD_RM: /* read modifed */ 543 case CMD_RM: /* read modifed */
544 case SNA_CMD_RM: 544 case SNA_CMD_RM:
545 trace_ds("ReadModified\n"); 545 trace_ds("ReadModified\n");
546 - ctlr_read_modified(aid, False); 546 + ctlr_read_modified(h3270.aid, False);
547 return PDS_OKAY_OUTPUT; 547 return PDS_OKAY_OUTPUT;
548 break; 548 break;
549 case CMD_RMA: /* read modifed all */ 549 case CMD_RMA: /* read modifed all */
550 case SNA_CMD_RMA: 550 case SNA_CMD_RMA:
551 trace_ds("ReadModifiedAll\n"); 551 trace_ds("ReadModifiedAll\n");
552 - ctlr_read_modified(aid, True); 552 + ctlr_read_modified(h3270.aid, True);
553 return PDS_OKAY_OUTPUT; 553 return PDS_OKAY_OUTPUT;
554 break; 554 break;
555 case CMD_WSF: /* write structured field */ 555 case CMD_WSF: /* write structured field */
@@ -1105,7 +1105,7 @@ ctlr_erase_all_unprotected(void) @@ -1105,7 +1105,7 @@ ctlr_erase_all_unprotected(void)
1105 } else { 1105 } else {
1106 ctlr_clear(&h3270,True); 1106 ctlr_clear(&h3270,True);
1107 } 1107 }
1108 - aid = AID_NO; 1108 + h3270.aid = AID_NO;
1109 do_reset(&h3270,False); 1109 do_reset(&h3270,False);
1110 ALL_CHANGED; 1110 ALL_CHANGED;
1111 } 1111 }
@@ -1862,7 +1862,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1862,7 +1862,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1862 END_TEXT0; 1862 END_TEXT0;
1863 trace_ds("\n"); 1863 trace_ds("\n");
1864 if (wcc_keyboard_restore) { 1864 if (wcc_keyboard_restore) {
1865 - aid = AID_NO; 1865 + h3270.aid = AID_NO;
1866 do_reset(&h3270,False); 1866 do_reset(&h3270,False);
1867 } else if (h3270.kybdlock & KL_OIA_TWAIT) { 1867 } else if (h3270.kybdlock & KL_OIA_TWAIT) {
1868 kybdlock_clr(KL_OIA_TWAIT, "ctlr_write"); 1868 kybdlock_clr(KL_OIA_TWAIT, "ctlr_write");
@@ -1986,7 +1986,7 @@ ctlr_write_sscp_lu(unsigned char buf[], int buflen) @@ -1986,7 +1986,7 @@ ctlr_write_sscp_lu(unsigned char buf[], int buflen)
1986 sscp_start = h3270.buffer_addr; 1986 sscp_start = h3270.buffer_addr;
1987 1987
1988 /* Unlock the keyboard. */ 1988 /* Unlock the keyboard. */
1989 - aid = AID_NO; 1989 + h3270.aid = AID_NO;
1990 do_reset(&h3270,False); 1990 do_reset(&h3270,False);
1991 1991
1992 } 1992 }
src/lib3270/ft_dft.c
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 #include <errno.h> 57 #include <errno.h>
58 // #include <malloc.h> 58 // #include <malloc.h>
59 59
60 -extern unsigned char aid; 60 +// extern unsigned char aid;
61 61
62 /* Macros. */ 62 /* Macros. */
63 #define OPEN_MSG "FT:MSG" /* Open request for message */ 63 #define OPEN_MSG "FT:MSG" /* Open request for message */
@@ -462,7 +462,7 @@ dft_get_request(void) @@ -462,7 +462,7 @@ dft_get_request(void)
462 Replace(dft_savebuf, (unsigned char *)lib3270_malloc(dft_savebuf_max)); 462 Replace(dft_savebuf, (unsigned char *)lib3270_malloc(dft_savebuf_max));
463 } 463 }
464 (void) memcpy(dft_savebuf, obuf, dft_savebuf_len); 464 (void) memcpy(dft_savebuf, obuf, dft_savebuf_len);
465 - aid = AID_SF; 465 + h3270.aid = AID_SF;
466 466
467 /* Write the data. */ 467 /* Write the data. */
468 net_output(); 468 net_output();
src/lib3270/kybd.c
@@ -108,8 +108,8 @@ static unsigned char pa_xlate[] = { @@ -108,8 +108,8 @@ static unsigned char pa_xlate[] = {
108 }; 108 };
109 #define PF_SZ (sizeof(pf_xlate)/sizeof(pf_xlate[0])) 109 #define PF_SZ (sizeof(pf_xlate)/sizeof(pf_xlate[0]))
110 #define PA_SZ (sizeof(pa_xlate)/sizeof(pa_xlate[0])) 110 #define PA_SZ (sizeof(pa_xlate)/sizeof(pa_xlate[0]))
111 -static void * unlock_id;  
112 -static time_t unlock_delay_time; 111 +// static void * unlock_id;
  112 +// static time_t unlock_delay_time;
113 #define UNLOCK_MS 350 /* 0.35s after last unlock */ 113 #define UNLOCK_MS 350 /* 0.35s after last unlock */
114 static Boolean key_Character(int code, Boolean with_ge, Boolean pasting,Boolean *skipped); 114 static Boolean key_Character(int code, Boolean with_ge, Boolean pasting,Boolean *skipped);
115 static Boolean flush_ta(void); 115 static Boolean flush_ta(void);
@@ -129,11 +129,11 @@ static struct xks { @@ -129,11 +129,11 @@ static struct xks {
129 KeySym assoc; 129 KeySym assoc;
130 } *xk; 130 } *xk;
131 131
132 -static Boolean reverse = False; /* reverse-input mode */ 132 +// static Boolean reverse = False; /* reverse-input mode */
133 133
134 /* Globals */ 134 /* Globals */
135 // unsigned int kybdlock = KL_NOT_CONNECTED; 135 // unsigned int kybdlock = KL_NOT_CONNECTED;
136 -unsigned char aid = AID_NO; /* current attention ID */ 136 +//unsigned char aid = AID_NO; /* current attention ID */
137 137
138 /* Composite key mappings. */ 138 /* Composite key mappings. */
139 139
@@ -361,7 +361,7 @@ kybdlock_set(unsigned int bits, const char *cause unused) @@ -361,7 +361,7 @@ kybdlock_set(unsigned int bits, const char *cause unused)
361 #endif /*]*/ 361 #endif /*]*/
362 if ((h3270.kybdlock ^ bits) & KL_DEFERRED_UNLOCK) { 362 if ((h3270.kybdlock ^ bits) & KL_DEFERRED_UNLOCK) {
363 /* Turned on deferred unlock. */ 363 /* Turned on deferred unlock. */
364 - unlock_delay_time = time(NULL); 364 + h3270.unlock_delay_time = time(NULL);
365 } 365 }
366 h3270.kybdlock = n; 366 h3270.kybdlock = n;
367 status_changed(&h3270,LIB3270_STATUS_KYBDLOCK); 367 status_changed(&h3270,LIB3270_STATUS_KYBDLOCK);
@@ -381,7 +381,7 @@ kybdlock_clr(unsigned int bits, const char *cause unused) @@ -381,7 +381,7 @@ kybdlock_clr(unsigned int bits, const char *cause unused)
381 #endif 381 #endif
382 if ((h3270.kybdlock ^ n) & KL_DEFERRED_UNLOCK) { 382 if ((h3270.kybdlock ^ n) & KL_DEFERRED_UNLOCK) {
383 /* Turned off deferred unlock. */ 383 /* Turned off deferred unlock. */
384 - unlock_delay_time = 0; 384 + h3270.unlock_delay_time = 0;
385 } 385 }
386 h3270.kybdlock = n; 386 h3270.kybdlock = n;
387 status_changed(&h3270,LIB3270_STATUS_KYBDLOCK); 387 status_changed(&h3270,LIB3270_STATUS_KYBDLOCK);
@@ -411,7 +411,7 @@ kybd_inhibit(Boolean inhibit) @@ -411,7 +411,7 @@ kybd_inhibit(Boolean inhibit)
411 void kybd_connect(H3270 *session, int connected, void *dunno) 411 void kybd_connect(H3270 *session, int connected, void *dunno)
412 { 412 {
413 if (session->kybdlock & KL_DEFERRED_UNLOCK) 413 if (session->kybdlock & KL_DEFERRED_UNLOCK)
414 - RemoveTimeOut(unlock_id); 414 + RemoveTimeOut(session->unlock_id);
415 415
416 kybdlock_clr(-1, "kybd_connect"); 416 kybdlock_clr(-1, "kybd_connect");
417 417
@@ -430,7 +430,7 @@ void kybd_connect(H3270 *session, int connected, void *dunno) @@ -430,7 +430,7 @@ void kybd_connect(H3270 *session, int connected, void *dunno)
430 void kybd_in3270(H3270 *session, int in3270 unused, void *dunno) 430 void kybd_in3270(H3270 *session, int in3270 unused, void *dunno)
431 { 431 {
432 if (session->kybdlock & KL_DEFERRED_UNLOCK) 432 if (session->kybdlock & KL_DEFERRED_UNLOCK)
433 - RemoveTimeOut(unlock_id); 433 + RemoveTimeOut(session->unlock_id);
434 kybdlock_clr(~KL_AWAITING_FIRST, "kybd_in3270"); 434 kybdlock_clr(~KL_AWAITING_FIRST, "kybd_in3270");
435 435
436 /* There might be a macro pending. */ 436 /* There might be a macro pending. */
@@ -542,8 +542,8 @@ static void key_AID(H3270 *session, unsigned char aid_code) @@ -542,8 +542,8 @@ static void key_AID(H3270 *session, unsigned char aid_code)
542 lib3270_set_toggle(&h3270,LIB3270_TOGGLE_INSERT,0); 542 lib3270_set_toggle(&h3270,LIB3270_TOGGLE_INSERT,0);
543 kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID"); 543 kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID");
544 } 544 }
545 - aid = aid_code;  
546 - ctlr_read_modified(aid, False); 545 + h3270.aid = aid_code;
  546 + ctlr_read_modified(h3270.aid, False);
547 ticking_start(&h3270,False); 547 ticking_start(&h3270,False);
548 status_ctlr_done(&h3270); 548 status_ctlr_done(&h3270);
549 } 549 }
@@ -1489,7 +1489,7 @@ void do_reset(H3270 *session, Boolean explicit) @@ -1489,7 +1489,7 @@ void do_reset(H3270 *session, Boolean explicit)
1489 * keyboard now, or want to defer further into the future. 1489 * keyboard now, or want to defer further into the future.
1490 */ 1490 */
1491 if (session->kybdlock & KL_DEFERRED_UNLOCK) 1491 if (session->kybdlock & KL_DEFERRED_UNLOCK)
1492 - RemoveTimeOut(unlock_id); 1492 + RemoveTimeOut(session->unlock_id);
1493 1493
1494 /* 1494 /*
1495 * If explicit (from the keyboard), unlock the keyboard now. 1495 * If explicit (from the keyboard), unlock the keyboard now.
@@ -1500,13 +1500,13 @@ void do_reset(H3270 *session, Boolean explicit) @@ -1500,13 +1500,13 @@ void do_reset(H3270 *session, Boolean explicit)
1500 || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE 1500 || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE
1501 #endif /*]*/ 1501 #endif /*]*/
1502 || (!session->unlock_delay) // && !sms_in_macro()) 1502 || (!session->unlock_delay) // && !sms_in_macro())
1503 - || (unlock_delay_time != 0 && (time(NULL) - unlock_delay_time) > 1)) { 1503 + || (session->unlock_delay_time != 0 && (time(NULL) - session->unlock_delay_time) > 1)) {
1504 kybdlock_clr(-1, "do_reset"); 1504 kybdlock_clr(-1, "do_reset");
1505 } else if (session->kybdlock & 1505 } else if (session->kybdlock &
1506 (KL_DEFERRED_UNLOCK | KL_OIA_TWAIT | KL_OIA_LOCKED | KL_AWAITING_FIRST)) { 1506 (KL_DEFERRED_UNLOCK | KL_OIA_TWAIT | KL_OIA_LOCKED | KL_AWAITING_FIRST)) {
1507 kybdlock_clr(~KL_DEFERRED_UNLOCK, "do_reset"); 1507 kybdlock_clr(~KL_DEFERRED_UNLOCK, "do_reset");
1508 kybdlock_set(KL_DEFERRED_UNLOCK, "do_reset"); 1508 kybdlock_set(KL_DEFERRED_UNLOCK, "do_reset");
1509 - unlock_id = AddTimeOut(UNLOCK_MS, session, defer_unlock); 1509 + session->unlock_id = AddTimeOut(UNLOCK_MS, session, defer_unlock);
1510 } 1510 }
1511 1511
1512 /* Clean up other modes. */ 1512 /* Clean up other modes. */
@@ -1709,7 +1709,8 @@ LIB3270_ACTION( delete ) @@ -1709,7 +1709,8 @@ LIB3270_ACTION( delete )
1709 #endif /*]*/ 1709 #endif /*]*/
1710 if (!do_delete()) 1710 if (!do_delete())
1711 return 0; 1711 return 0;
1712 - if (reverse) { 1712 + if (hSession->reverse)
  1713 + {
1713 int baddr = hSession->cursor_addr; 1714 int baddr = hSession->cursor_addr;
1714 1715
1715 DEC_BA(baddr); 1716 DEC_BA(baddr);
@@ -1737,7 +1738,7 @@ LIB3270_ACTION( backspace ) @@ -1737,7 +1738,7 @@ LIB3270_ACTION( backspace )
1737 return 0; 1738 return 0;
1738 } 1739 }
1739 #endif /*]*/ 1740 #endif /*]*/
1740 - if (reverse) 1741 + if (hSession->reverse)
1741 (void) do_delete(); 1742 (void) do_delete();
1742 else if (!hSession->flipped) 1743 else if (!hSession->flipped)
1743 do_left(); 1744 do_left();
src/lib3270/session.c
@@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
44 #include "ctlrc.h" 44 #include "ctlrc.h"
45 #include "ftc.h" 45 #include "ftc.h"
46 #include "kybdc.h" 46 #include "kybdc.h"
  47 +#include "3270ds.h"
47 48
48 /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ 49 /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
49 50
@@ -195,6 +196,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) @@ -195,6 +196,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
195 hSession->cstate = LIB3270_NOT_CONNECTED; 196 hSession->cstate = LIB3270_NOT_CONNECTED;
196 hSession->oia_status = -1; 197 hSession->oia_status = -1;
197 hSession->kybdlock = KL_NOT_CONNECTED; 198 hSession->kybdlock = KL_NOT_CONNECTED;
  199 + hSession->aid = AID_NO;
198 200
199 #ifdef _WIN32 201 #ifdef _WIN32
200 hSession->sockEvent = NULL; 202 hSession->sockEvent = NULL;