Commit 8321d0f5097a7315c3ae7ccd665a88325e9e8447
1 parent
b7350201
Exists in
master
and in
5 other branches
Updating version, changing timer management, adding setting for unlock delay.
Showing
11 changed files
with
96 additions
and
209 deletions
Show diff stats
configure.ac
@@ -37,7 +37,7 @@ m4_include([revision.m4]) | @@ -37,7 +37,7 @@ m4_include([revision.m4]) | ||
37 | 37 | ||
38 | dnl Initialise automake with the package name, version and | 38 | dnl Initialise automake with the package name, version and |
39 | dnl bug-reporting address. | 39 | dnl bug-reporting address. |
40 | -AC_INIT([pw3270], [5.0], [perry.werneck@gmail.com]) | 40 | +AC_INIT([pw3270], [5.1], [perry.werneck@gmail.com]) |
41 | 41 | ||
42 | dnl Place auxilliary scripts here. | 42 | dnl Place auxilliary scripts here. |
43 | AC_CONFIG_AUX_DIR([scripts]) | 43 | AC_CONFIG_AUX_DIR([scripts]) |
src/include/lib3270.h
@@ -673,10 +673,10 @@ | @@ -673,10 +673,10 @@ | ||
673 | } LIB3270_IO_FLAG; | 673 | } LIB3270_IO_FLAG; |
674 | 674 | ||
675 | LIB3270_EXPORT void * lib3270_add_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); | 675 | LIB3270_EXPORT void * lib3270_add_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); |
676 | - LIB3270_EXPORT void lib3270_remove_poll(void *id); | 676 | + LIB3270_EXPORT void lib3270_remove_poll(H3270 *session, void *id); |
677 | 677 | ||
678 | - LIB3270_EXPORT void lib3270_remove_poll_fd(int fd); | ||
679 | - LIB3270_EXPORT void lib3270_update_poll_fd(int fd, LIB3270_IO_FLAG flag); | 678 | + LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd); |
679 | + LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag); | ||
680 | 680 | ||
681 | /** Callback table | 681 | /** Callback table |
682 | * | 682 | * |
@@ -687,15 +687,15 @@ | @@ -687,15 +687,15 @@ | ||
687 | { | 687 | { |
688 | unsigned short sz; | 688 | unsigned short sz; |
689 | 689 | ||
690 | - void * (*AddTimeOut)(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | ||
691 | - void (*RemoveTimeOut)(void *timer); | 690 | + void * (*AddTimeOut)(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)); |
691 | + void (*RemoveTimeOut)(H3270 *session, void *timer); | ||
692 | 692 | ||
693 | void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); | 693 | void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); |
694 | - void (*remove_poll)(void *id); | 694 | + void (*remove_poll)(H3270 *session, void *id); |
695 | 695 | ||
696 | int (*Wait)(H3270 *hSession, int seconds); | 696 | int (*Wait)(H3270 *hSession, int seconds); |
697 | - int (*event_dispatcher)(H3270 *hSession, int wait); | ||
698 | - void (*ring_bell)(H3270 *); | 697 | + int (*event_dispatcher)(H3270 *session, int wait); |
698 | + void (*ring_bell)(H3270 *session); | ||
699 | 699 | ||
700 | }; | 700 | }; |
701 | 701 | ||
@@ -716,9 +716,9 @@ | @@ -716,9 +716,9 @@ | ||
716 | * @param rm Callback for removing a timeout | 716 | * @param rm Callback for removing a timeout |
717 | * | 717 | * |
718 | */ | 718 | */ |
719 | - void LIB3270_EXPORT lib3270_register_time_handlers(void * (*add)(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)), void (*rm)(void *timer)); | 719 | + void LIB3270_EXPORT lib3270_register_time_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)), void (*rm)(H3270 *session, void *timer)); |
720 | 720 | ||
721 | - void lib3270_register_fd_handlers(void * (*add)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata), void (*rm)(void *id)); | 721 | + void LIB3270_EXPORT lib3270_register_fd_handlers(void * (*add)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata), void (*rm)(H3270 *, void *id)); |
722 | 722 | ||
723 | /** | 723 | /** |
724 | * Get program message. | 724 | * Get program message. |
@@ -1011,7 +1011,6 @@ | @@ -1011,7 +1011,6 @@ | ||
1011 | 1011 | ||
1012 | LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *hSession, int baddr, int *start, int *end); | 1012 | LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *hSession, int baddr, int *start, int *end); |
1013 | 1013 | ||
1014 | -// LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model); | ||
1015 | LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); | 1014 | LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); |
1016 | 1015 | ||
1017 | LIB3270_EXPORT const char * lib3270_get_model(H3270 *session); | 1016 | LIB3270_EXPORT const char * lib3270_get_model(H3270 *session); |
@@ -1022,6 +1021,18 @@ | @@ -1022,6 +1021,18 @@ | ||
1022 | 1021 | ||
1023 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); | 1022 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); |
1024 | 1023 | ||
1024 | + /** | ||
1025 | + * | ||
1026 | + * Overrides the default value for the unlock delay (the delay between the host unlocking the | ||
1027 | + * keyboard and lib3270 actually performing the unlock). | ||
1028 | + * The value is in milliseconds; use 0 to turn off the delay completely. | ||
1029 | + * | ||
1030 | + * @param session lib3270 session. | ||
1031 | + * @param Delay in milliseconds. | ||
1032 | + * | ||
1033 | + */ | ||
1034 | + LIB3270_EXPORT void lib3270_set_unlock_delay(H3270 *session, unsigned short delay); | ||
1035 | + | ||
1025 | 1036 | ||
1026 | /** | 1037 | /** |
1027 | * Alloc/Realloc memory buffer. | 1038 | * Alloc/Realloc memory buffer. |
src/include/lib3270/session.h
@@ -263,15 +263,16 @@ | @@ -263,15 +263,16 @@ | ||
263 | unsigned char hisopts[LIB3270_TELNET_N_OPTS]; | 263 | unsigned char hisopts[LIB3270_TELNET_N_OPTS]; |
264 | 264 | ||
265 | // kybd.c | 265 | // kybd.c |
266 | - unsigned int kybdlock; /**< keyboard lock state */ | ||
267 | - unsigned char aid; /**< current attention ID */ | 266 | + unsigned int kybdlock; ///< @brief keyboard lock state |
267 | + unsigned char aid; ///< @brief current attention ID | ||
268 | void * unlock_id; | 268 | void * unlock_id; |
269 | time_t unlock_delay_time; | 269 | time_t unlock_delay_time; |
270 | + unsigned long unlock_delay_ms; ///< @brief Delay before actually unlocking the keyboard after the host permits it. | ||
270 | LIB3270_TA * ta_head; | 271 | LIB3270_TA * ta_head; |
271 | LIB3270_TA * ta_tail; | 272 | LIB3270_TA * ta_tail; |
272 | 273 | ||
273 | // ft_dft.c | 274 | // ft_dft.c |
274 | - int dft_buffersize; /**< Buffer size (LIMIN, LIMOUT) */ | 275 | + int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT) |
275 | 276 | ||
276 | // rpq.c | 277 | // rpq.c |
277 | int rpq_complained : 1; | 278 | int rpq_complained : 1; |
src/lib3270/connect.c
@@ -84,7 +84,7 @@ static void net_connected(H3270 *hSession, int fd, LIB3270_IO_FLAG flag, void *d | @@ -84,7 +84,7 @@ static void net_connected(H3270 *hSession, int fd, LIB3270_IO_FLAG flag, void *d | ||
84 | 84 | ||
85 | if(hSession->ns_write_id) { | 85 | if(hSession->ns_write_id) { |
86 | trace("%s write=%p",__FUNCTION__,hSession->ns_write_id); | 86 | trace("%s write=%p",__FUNCTION__,hSession->ns_write_id); |
87 | - lib3270_remove_poll(hSession->ns_write_id); | 87 | + lib3270_remove_poll(hSession, hSession->ns_write_id); |
88 | hSession->ns_write_id = NULL; | 88 | hSession->ns_write_id = NULL; |
89 | } | 89 | } |
90 | 90 |
src/lib3270/ctlr.c
@@ -2860,8 +2860,10 @@ void ticking_start(H3270 *hSession, Boolean anyway) | @@ -2860,8 +2860,10 @@ void ticking_start(H3270 *hSession, Boolean anyway) | ||
2860 | return; | 2860 | return; |
2861 | 2861 | ||
2862 | status_untiming(hSession); | 2862 | status_untiming(hSession); |
2863 | + | ||
2863 | if (hSession->ticking) | 2864 | if (hSession->ticking) |
2864 | - RemoveTimeOut(hSession->tick_id); | 2865 | + RemoveTimeOut(hSession, hSession->tick_id); |
2866 | + | ||
2865 | hSession->ticking = 1; | 2867 | hSession->ticking = 1; |
2866 | hSession->tick_id = AddTimeOut(1000, hSession, keep_ticking); | 2868 | hSession->tick_id = AddTimeOut(1000, hSession, keep_ticking); |
2867 | hSession->t_want = hSession->t_start; | 2869 | hSession->t_want = hSession->t_start; |
@@ -2889,7 +2891,7 @@ static void ticking_stop(H3270 *hSession) | @@ -2889,7 +2891,7 @@ static void ticking_stop(H3270 *hSession) | ||
2889 | 2891 | ||
2890 | if (!hSession->ticking) | 2892 | if (!hSession->ticking) |
2891 | return; | 2893 | return; |
2892 | - RemoveTimeOut(hSession->tick_id); | 2894 | + RemoveTimeOut(hSession, hSession->tick_id); |
2893 | hSession->ticking = 0; | 2895 | hSession->ticking = 0; |
2894 | status_timing(hSession,&hSession->t_start, &t1); | 2896 | status_timing(hSession,&hSession->t_start, &t1); |
2895 | } | 2897 | } |
src/lib3270/iocalls.c
@@ -45,34 +45,34 @@ | @@ -45,34 +45,34 @@ | ||
45 | /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ | 45 | /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ |
46 | 46 | ||
47 | // Timeout calls | 47 | // Timeout calls |
48 | -static void internal_remove_timeout(void *timer); | ||
49 | -static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | 48 | +static void internal_remove_timeout(H3270 *session, void *timer); |
49 | +static void * internal_add_timeout(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)); | ||
50 | 50 | ||
51 | static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); | 51 | static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); |
52 | -static void internal_remove_poll(void *id); | 52 | +static void internal_remove_poll(H3270 *session, void *id); |
53 | 53 | ||
54 | -static int internal_wait(H3270 *hSession, int seconds); | 54 | +static int internal_wait(H3270 *session, int seconds); |
55 | 55 | ||
56 | -static void internal_ring_bell(H3270 *); | 56 | +static void internal_ring_bell(H3270 *session); |
57 | 57 | ||
58 | /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ | 58 | /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ |
59 | 59 | ||
60 | - static void * (*add_timeout)(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)) | 60 | + static void * (*add_timeout)(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)) |
61 | = internal_add_timeout; | 61 | = internal_add_timeout; |
62 | 62 | ||
63 | - static void (*remove_timeout)(void *timer) | 63 | + static void (*remove_timeout)(H3270 *session, void *timer) |
64 | = internal_remove_timeout; | 64 | = internal_remove_timeout; |
65 | 65 | ||
66 | static void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) | 66 | static void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) |
67 | = internal_add_poll; | 67 | = internal_add_poll; |
68 | 68 | ||
69 | - static void (*remove_poll)(void *id) | 69 | + static void (*remove_poll)(H3270 *session, void *id) |
70 | = internal_remove_poll; | 70 | = internal_remove_poll; |
71 | 71 | ||
72 | - static int (*wait)(H3270 *hSession, int seconds) | 72 | + static int (*wait)(H3270 *session, int seconds) |
73 | = internal_wait; | 73 | = internal_wait; |
74 | 74 | ||
75 | - static int (*event_dispatcher)(H3270 *hSession,int wait) | 75 | + static int (*event_dispatcher)(H3270 *session,int wait) |
76 | = lib3270_default_event_dispatcher; | 76 | = lib3270_default_event_dispatcher; |
77 | 77 | ||
78 | static void (*ring_bell)(H3270 *) | 78 | static void (*ring_bell)(H3270 *) |
@@ -134,7 +134,7 @@ static void ms_ts(unsigned long long *u) | @@ -134,7 +134,7 @@ static void ms_ts(unsigned long long *u) | ||
134 | } | 134 | } |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | -static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)) | 137 | +static void * internal_add_timeout(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)) |
138 | { | 138 | { |
139 | timeout_t *t_new; | 139 | timeout_t *t_new; |
140 | timeout_t *t; | 140 | timeout_t *t; |
@@ -199,7 +199,7 @@ static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, vo | @@ -199,7 +199,7 @@ static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, vo | ||
199 | return t_new; | 199 | return t_new; |
200 | } | 200 | } |
201 | 201 | ||
202 | -static void internal_remove_timeout(void * timer) | 202 | +static void internal_remove_timeout(H3270 *session, void * timer) |
203 | { | 203 | { |
204 | timeout_t *st = (timeout_t *)timer; | 204 | timeout_t *st = (timeout_t *)timer; |
205 | timeout_t *t; | 205 | timeout_t *t; |
@@ -243,7 +243,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo | @@ -243,7 +243,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo | ||
243 | return ip; | 243 | return ip; |
244 | } | 244 | } |
245 | 245 | ||
246 | -static void internal_remove_poll(void *id) | 246 | +static void internal_remove_poll(H3270 *session, void *id) |
247 | { | 247 | { |
248 | input_t *ip; | 248 | input_t *ip; |
249 | input_t *prev = (input_t *)NULL; | 249 | input_t *prev = (input_t *)NULL; |
@@ -258,7 +258,7 @@ static void internal_remove_poll(void *id) | @@ -258,7 +258,7 @@ static void internal_remove_poll(void *id) | ||
258 | 258 | ||
259 | if (ip == (input_t *)NULL) | 259 | if (ip == (input_t *)NULL) |
260 | { | 260 | { |
261 | - lib3270_write_log(NULL,"lib3270","Invalid call to (%s): Input %p wasnt found in the list",__FUNCTION__,id); | 261 | + lib3270_write_log(session,"lib3270","Invalid call to (%s): Input %p wasnt found in the list",__FUNCTION__,id); |
262 | return; | 262 | return; |
263 | } | 263 | } |
264 | 264 | ||
@@ -271,12 +271,12 @@ static void internal_remove_poll(void *id) | @@ -271,12 +271,12 @@ static void internal_remove_poll(void *id) | ||
271 | inputs_changed = True; | 271 | inputs_changed = True; |
272 | } | 272 | } |
273 | 273 | ||
274 | -LIB3270_EXPORT void lib3270_remove_poll(void *id) { | 274 | +LIB3270_EXPORT void lib3270_remove_poll(H3270 *session, void *id) { |
275 | debug("%s %p",__FUNCTION__,id); | 275 | debug("%s %p",__FUNCTION__,id); |
276 | - remove_poll(id); | 276 | + remove_poll(session, id); |
277 | } | 277 | } |
278 | 278 | ||
279 | -LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) | 279 | +LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd) |
280 | { | 280 | { |
281 | 281 | ||
282 | input_t *ip; | 282 | input_t *ip; |
@@ -285,7 +285,7 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) | @@ -285,7 +285,7 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) | ||
285 | { | 285 | { |
286 | if(ip->fd == fd) | 286 | if(ip->fd == fd) |
287 | { | 287 | { |
288 | - remove_poll(ip); | 288 | + remove_poll(session, ip); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
@@ -294,7 +294,7 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) | @@ -294,7 +294,7 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) | ||
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | -LIB3270_EXPORT void lib3270_update_poll_fd(int fd, LIB3270_IO_FLAG flag) | 297 | +LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag) |
298 | { | 298 | { |
299 | 299 | ||
300 | input_t *ip; | 300 | input_t *ip; |
@@ -308,7 +308,7 @@ LIB3270_EXPORT void lib3270_update_poll_fd(int fd, LIB3270_IO_FLAG flag) | @@ -308,7 +308,7 @@ LIB3270_EXPORT void lib3270_update_poll_fd(int fd, LIB3270_IO_FLAG flag) | ||
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | - lib3270_write_log(NULL,"iocalls","Invalid or unexpected FD on %s(%d)",__FUNCTION__,fd); | 311 | + lib3270_write_log(session,"iocalls","Invalid or unexpected FD on %s(%d)",__FUNCTION__,fd); |
312 | 312 | ||
313 | } | 313 | } |
314 | 314 | ||
@@ -612,15 +612,18 @@ void * AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 | @@ -612,15 +612,18 @@ void * AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 | ||
612 | { | 612 | { |
613 | void *timer; | 613 | void *timer; |
614 | CHECK_SESSION_HANDLE(session); | 614 | CHECK_SESSION_HANDLE(session); |
615 | - timer = add_timeout(interval_ms,session,proc); | 615 | + timer = add_timeout(session,interval_ms,proc); |
616 | trace("Timeout %p created with %ld ms",timer,interval_ms); | 616 | trace("Timeout %p created with %ld ms",timer,interval_ms); |
617 | return timer; | 617 | return timer; |
618 | } | 618 | } |
619 | 619 | ||
620 | -void RemoveTimeOut(void * timer) | 620 | +void RemoveTimeOut(H3270 *session, void * timer) |
621 | { | 621 | { |
622 | + if(!timer) | ||
623 | + return; | ||
624 | + | ||
622 | trace("Removing timeout %p",timer); | 625 | trace("Removing timeout %p",timer); |
623 | - return remove_timeout(timer); | 626 | + return remove_timeout(session, timer); |
624 | } | 627 | } |
625 | 628 | ||
626 | void x_except_on(H3270 *h) | 629 | void x_except_on(H3270 *h) |
@@ -632,7 +635,7 @@ void x_except_on(H3270 *h) | @@ -632,7 +635,7 @@ void x_except_on(H3270 *h) | ||
632 | return; | 635 | return; |
633 | 636 | ||
634 | if(reading) | 637 | if(reading) |
635 | - lib3270_remove_poll(h->ns_read_id); | 638 | + lib3270_remove_poll(h,h->ns_read_id); |
636 | 639 | ||
637 | h->ns_exception_id = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); | 640 | h->ns_exception_id = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); |
638 | 641 | ||
@@ -646,22 +649,22 @@ void remove_input_calls(H3270 *session) | @@ -646,22 +649,22 @@ void remove_input_calls(H3270 *session) | ||
646 | { | 649 | { |
647 | if(session->ns_read_id) | 650 | if(session->ns_read_id) |
648 | { | 651 | { |
649 | - lib3270_remove_poll(session->ns_read_id); | 652 | + lib3270_remove_poll(session,session->ns_read_id); |
650 | session->ns_read_id = NULL; | 653 | session->ns_read_id = NULL; |
651 | } | 654 | } |
652 | if(session->ns_exception_id) | 655 | if(session->ns_exception_id) |
653 | { | 656 | { |
654 | - lib3270_remove_poll(session->ns_exception_id); | 657 | + lib3270_remove_poll(session,session->ns_exception_id); |
655 | session->ns_exception_id = NULL; | 658 | session->ns_exception_id = NULL; |
656 | } | 659 | } |
657 | if(session->ns_write_id) | 660 | if(session->ns_write_id) |
658 | { | 661 | { |
659 | - lib3270_remove_poll(session->ns_write_id); | 662 | + lib3270_remove_poll(session,session->ns_write_id); |
660 | session->ns_write_id = NULL; | 663 | session->ns_write_id = NULL; |
661 | } | 664 | } |
662 | } | 665 | } |
663 | 666 | ||
664 | -LIB3270_EXPORT void lib3270_register_time_handlers(void * (*add)(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)), void (*rm)(void *timer)) | 667 | +LIB3270_EXPORT void lib3270_register_time_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)), void (*rm)(H3270 *session, void *timer)) |
665 | { | 668 | { |
666 | if(add) | 669 | if(add) |
667 | add_timeout = add; | 670 | add_timeout = add; |
@@ -671,7 +674,7 @@ LIB3270_EXPORT void lib3270_register_time_handlers(void * (*add)(unsigned long i | @@ -671,7 +674,7 @@ LIB3270_EXPORT void lib3270_register_time_handlers(void * (*add)(unsigned long i | ||
671 | 674 | ||
672 | } | 675 | } |
673 | 676 | ||
674 | -LIB3270_EXPORT void lib3270_register_fd_handlers(void * (*add)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata), void (*rm)(void *id)) { | 677 | +LIB3270_EXPORT void lib3270_register_fd_handlers(void * (*add)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata), void (*rm)(H3270 *, void *id)) { |
675 | if(add) | 678 | if(add) |
676 | add_poll = add; | 679 | add_poll = add; |
677 | 680 |
src/lib3270/kybd.c
@@ -124,27 +124,6 @@ static int flush_ta(H3270 *hSession); | @@ -124,27 +124,6 @@ static int flush_ta(H3270 *hSession); | ||
124 | static void key_AID(H3270 *session, unsigned char aid_code); | 124 | static void key_AID(H3270 *session, unsigned char aid_code); |
125 | static void kybdlock_set(H3270 *session, unsigned int bits); | 125 | static void kybdlock_set(H3270 *session, unsigned int bits); |
126 | 126 | ||
127 | -/* | ||
128 | -#if defined(X3270_DBCS) | ||
129 | -Boolean key_WCharacter(unsigned char code[], Boolean *skipped); | ||
130 | -#endif | ||
131 | -*/ | ||
132 | - | ||
133 | -/* | ||
134 | -static int nxk = 0; | ||
135 | -static struct xks | ||
136 | -{ | ||
137 | - KeySym key; | ||
138 | - KeySym assoc; | ||
139 | -} *xk; | ||
140 | -*/ | ||
141 | - | ||
142 | -// static Boolean reverse = False; /* reverse-input mode */ | ||
143 | - | ||
144 | -/* Globals */ | ||
145 | -// unsigned int kybdlock = KL_NOT_CONNECTED; | ||
146 | -//unsigned char aid = AID_NO; /* current attention ID */ | ||
147 | - | ||
148 | /* Composite key mappings. */ | 127 | /* Composite key mappings. */ |
149 | 128 | ||
150 | struct akeysym | 129 | struct akeysym |
@@ -152,14 +131,6 @@ struct akeysym | @@ -152,14 +131,6 @@ struct akeysym | ||
152 | KeySym keysym; | 131 | KeySym keysym; |
153 | enum keytype keytype; | 132 | enum keytype keytype; |
154 | }; | 133 | }; |
155 | -/* | ||
156 | -static struct akeysym cc_first; | ||
157 | -static struct composite { | ||
158 | - struct akeysym k1, k2; | ||
159 | - struct akeysym translation; | ||
160 | -} *composites = NULL; | ||
161 | -static int n_composites = 0; | ||
162 | -*/ | ||
163 | 134 | ||
164 | #define ak_eq(k1, k2) (((k1).keysym == (k2).keysym) && \ | 135 | #define ak_eq(k1, k2) (((k1).keysym == (k2).keysym) && \ |
165 | ((k1).keytype == (k2).keytype)) | 136 | ((k1).keytype == (k2).keytype)) |
@@ -180,12 +151,6 @@ struct ta | @@ -180,12 +151,6 @@ struct ta | ||
180 | unsigned char aid_code; | 151 | unsigned char aid_code; |
181 | }; | 152 | }; |
182 | 153 | ||
183 | -/* | ||
184 | -*ta_head = (struct ta *) NULL, | ||
185 | - *ta_tail = (struct ta *) NULL; | ||
186 | -*/ | ||
187 | - | ||
188 | - | ||
189 | #if defined(DEBUG) | 154 | #if defined(DEBUG) |
190 | #define ENQUEUE_ACTION(x) enq_ta(hSession, (void (*)(H3270 *, const char *, const char *)) x, NULL, NULL, #x) | 155 | #define ENQUEUE_ACTION(x) enq_ta(hSession, (void (*)(H3270 *, const char *, const char *)) x, NULL, NULL, #x) |
191 | #else | 156 | #else |
@@ -445,7 +410,7 @@ void kybd_inhibit(H3270 *session, Boolean inhibit) | @@ -445,7 +410,7 @@ void kybd_inhibit(H3270 *session, Boolean inhibit) | ||
445 | void kybd_connect(H3270 *session, int connected, void *dunno) | 410 | void kybd_connect(H3270 *session, int connected, void *dunno) |
446 | { | 411 | { |
447 | if (session->kybdlock & KL_DEFERRED_UNLOCK) | 412 | if (session->kybdlock & KL_DEFERRED_UNLOCK) |
448 | - RemoveTimeOut(session->unlock_id); | 413 | + RemoveTimeOut(session, session->unlock_id); |
449 | 414 | ||
450 | lib3270_kybdlock_clear(session, -1); | 415 | lib3270_kybdlock_clear(session, -1); |
451 | 416 | ||
@@ -467,7 +432,8 @@ void kybd_connect(H3270 *session, int connected, void *dunno) | @@ -467,7 +432,8 @@ void kybd_connect(H3270 *session, int connected, void *dunno) | ||
467 | void kybd_in3270(H3270 *hSession, int in3270 unused, void *dunno) | 432 | void kybd_in3270(H3270 *hSession, int in3270 unused, void *dunno) |
468 | { | 433 | { |
469 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) | 434 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) |
470 | - RemoveTimeOut(hSession->unlock_id); | 435 | + RemoveTimeOut(hSession, hSession->unlock_id); |
436 | + | ||
471 | lib3270_kybdlock_clear(hSession,~KL_AWAITING_FIRST); | 437 | lib3270_kybdlock_clear(hSession,~KL_AWAITING_FIRST); |
472 | 438 | ||
473 | /* There might be a macro pending. */ | 439 | /* There might be a macro pending. */ |
@@ -1185,7 +1151,7 @@ void do_reset(H3270 *hSession, Boolean explicit) | @@ -1185,7 +1151,7 @@ void do_reset(H3270 *hSession, Boolean explicit) | ||
1185 | * keyboard now, or want to defer further into the future. | 1151 | * keyboard now, or want to defer further into the future. |
1186 | */ | 1152 | */ |
1187 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) | 1153 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) |
1188 | - RemoveTimeOut(hSession->unlock_id); | 1154 | + RemoveTimeOut(hSession, hSession->unlock_id); |
1189 | 1155 | ||
1190 | /* | 1156 | /* |
1191 | * If explicit (from the keyboard), unlock the keyboard now. | 1157 | * If explicit (from the keyboard), unlock the keyboard now. |
@@ -1199,7 +1165,17 @@ void do_reset(H3270 *hSession, Boolean explicit) | @@ -1199,7 +1165,17 @@ void do_reset(H3270 *hSession, Boolean explicit) | ||
1199 | { | 1165 | { |
1200 | lib3270_kybdlock_clear(hSession,~KL_DEFERRED_UNLOCK); | 1166 | lib3270_kybdlock_clear(hSession,~KL_DEFERRED_UNLOCK); |
1201 | kybdlock_set(hSession,KL_DEFERRED_UNLOCK); | 1167 | kybdlock_set(hSession,KL_DEFERRED_UNLOCK); |
1202 | - hSession->unlock_id = AddTimeOut(UNLOCK_MS, hSession, defer_unlock); | 1168 | + |
1169 | + if(hSession->unlock_delay_ms) | ||
1170 | + { | ||
1171 | + hSession->unlock_id = AddTimeOut(hSession->unlock_delay_ms, hSession, defer_unlock); | ||
1172 | + } | ||
1173 | + else | ||
1174 | + { | ||
1175 | + hSession->unlock_id = 0; | ||
1176 | + defer_unlock(hSession); | ||
1177 | + } | ||
1178 | + | ||
1203 | } | 1179 | } |
1204 | 1180 | ||
1205 | /* Clean up other modes. */ | 1181 | /* Clean up other modes. */ |
@@ -2998,95 +2974,8 @@ int kybd_prime(H3270 *hSession) | @@ -2998,95 +2974,8 @@ int kybd_prime(H3270 *hSession) | ||
2998 | } | 2974 | } |
2999 | #endif /*]*/ | 2975 | #endif /*]*/ |
3000 | 2976 | ||
3001 | -/* | ||
3002 | - * Translate a keysym name to a keysym, including APL and extended | ||
3003 | - * characters. | ||
3004 | - */ /* | ||
3005 | -static KeySym | ||
3006 | -MyStringToKeysym(char *s, enum keytype *keytypep) | 2977 | +LIB3270_EXPORT void lib3270_set_unlock_delay(H3270 *session, unsigned short delay) |
3007 | { | 2978 | { |
3008 | - KeySym k; | ||
3009 | - int cc; | ||
3010 | - char *ptr; | ||
3011 | - unsigned char xc; | ||
3012 | - | ||
3013 | - | ||
3014 | -#if defined(X3270_APL) | ||
3015 | - if (!strncmp(s, "apl_", 4)) { | ||
3016 | - int is_ge; | ||
3017 | - | ||
3018 | - k = APLStringToKeysym(s, &is_ge); | ||
3019 | - if (is_ge) | ||
3020 | - *keytypep = KT_GE; | ||
3021 | - else | ||
3022 | - *keytypep = KT_STD; | ||
3023 | - } else | ||
3024 | -#endif | ||
3025 | - { | ||
3026 | - k = StringToKeysym(s); | ||
3027 | - *keytypep = KT_STD; | ||
3028 | - } | ||
3029 | - if (k == NoSymbol && ((xc = utf8_lookup(s, NULL, NULL)) != 0)) | ||
3030 | - k = xc; | ||
3031 | - if (k == NoSymbol && !strcasecmp(s, "euro")) | ||
3032 | - k = 0xa4; | ||
3033 | - if (k == NoSymbol && strlen(s) == 1) | ||
3034 | - k = s[0] & 0xff; | ||
3035 | - if (k < ' ') | ||
3036 | - k = NoSymbol; | ||
3037 | - else if (k > 0xff) { | ||
3038 | - int i; | ||
3039 | - | ||
3040 | - for (i = 0; i < nxk; i++) | ||
3041 | - if (xk[i].key == k) { | ||
3042 | - k = xk[i].assoc; | ||
3043 | - break; | ||
3044 | - } | ||
3045 | - if (k > 0xff) | ||
3046 | - k &= 0xff; | ||
3047 | - } | ||
3048 | - | ||
3049 | - // Allow arbitrary values, e.g., 0x03 for ^C. | ||
3050 | - if (k == NoSymbol && | ||
3051 | - (cc = strtoul(s, &ptr, 0)) > 0 && | ||
3052 | - cc < 0xff && | ||
3053 | - ptr != s && | ||
3054 | - *ptr == '\0') | ||
3055 | - k = cc; | ||
3056 | - | ||
3057 | - return k; | ||
3058 | -} | ||
3059 | -*/ | ||
3060 | - | ||
3061 | -/* Add a key to the extended association table. */ | ||
3062 | -/* | ||
3063 | -void | ||
3064 | -add_xk(KeySym key, KeySym assoc) | ||
3065 | -{ | ||
3066 | - int i; | ||
3067 | - | ||
3068 | - for (i = 0; i < nxk; i++) | ||
3069 | - if (xk[i].key == key) { | ||
3070 | - xk[i].assoc = assoc; | ||
3071 | - return; | ||
3072 | - } | ||
3073 | - xk = (struct xks *) Realloc(xk, (nxk + 1) * sizeof(struct xks)); | ||
3074 | - xk[nxk].key = key; | ||
3075 | - xk[nxk].assoc = assoc; | ||
3076 | - nxk++; | ||
3077 | -} | ||
3078 | -*/ | ||
3079 | - | ||
3080 | -/* Clear the extended association table. */ | ||
3081 | -/* | ||
3082 | -void clear_xks(void) | ||
3083 | -{ | ||
3084 | - if (nxk) { | ||
3085 | - lib3270_free(xk); | ||
3086 | - xk = (struct xks *)NULL; | ||
3087 | - nxk = 0; | ||
3088 | - } | 2979 | + CHECK_SESSION_HANDLE(session); |
2980 | + session->unlock_delay_ms = delay; | ||
3089 | } | 2981 | } |
3090 | -*/ | ||
3091 | - | ||
3092 | - |
src/lib3270/session.c
@@ -242,6 +242,10 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char | @@ -242,6 +242,10 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char | ||
242 | hSession->colors = 16; | 242 | hSession->colors = 16; |
243 | hSession->m3279 = 1; | 243 | hSession->m3279 = 1; |
244 | 244 | ||
245 | + // Keyboard unlock | ||
246 | + hSession->unlock_delay_ms = 350; /* 0.35s after last unlock */ | ||
247 | + | ||
248 | + // CSD | ||
245 | for(f=0;f<4;f++) | 249 | for(f=0;f<4;f++) |
246 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; | 250 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; |
247 | 251 |
src/lib3270/telnet.c
@@ -909,7 +909,7 @@ LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession) | @@ -909,7 +909,7 @@ LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession) | ||
909 | 909 | ||
910 | if(hSession->ns_write_id) | 910 | if(hSession->ns_write_id) |
911 | { | 911 | { |
912 | - lib3270_remove_poll(hSession->ns_write_id); | 912 | + lib3270_remove_poll(hSession, hSession->ns_write_id); |
913 | hSession->ns_write_id = 0; | 913 | hSession->ns_write_id = 0; |
914 | } | 914 | } |
915 | 915 | ||
@@ -1961,7 +1961,7 @@ void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno) | @@ -1961,7 +1961,7 @@ void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno) | ||
1961 | 1961 | ||
1962 | if(session->ns_exception_id) | 1962 | if(session->ns_exception_id) |
1963 | { | 1963 | { |
1964 | - lib3270_remove_poll(session->ns_exception_id); | 1964 | + lib3270_remove_poll(session, session->ns_exception_id); |
1965 | session->ns_exception_id = NULL; | 1965 | session->ns_exception_id = NULL; |
1966 | } | 1966 | } |
1967 | } | 1967 | } |
src/lib3270/utilc.h
@@ -40,9 +40,9 @@ LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session | @@ -40,9 +40,9 @@ LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session | ||
40 | LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); | 40 | LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); |
41 | LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); | 41 | LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); |
42 | 42 | ||
43 | -LIB3270_INTERNAL void RemoveSource(void *); | 43 | +LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie); |
44 | LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); | 44 | LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); |
45 | -LIB3270_INTERNAL void RemoveTimeOut(void *cookie); | 45 | +LIB3270_INTERNAL void RemoveTimeOut(H3270 *session, void *cookie); |
46 | 46 | ||
47 | LIB3270_INTERNAL const char * KeysymToString(KeySym k); | 47 | LIB3270_INTERNAL const char * KeysymToString(KeySym k); |
48 | 48 |
src/pw3270/v3270/iocallback.c
@@ -43,14 +43,11 @@ | @@ -43,14 +43,11 @@ | ||
43 | #include <glib.h> | 43 | #include <glib.h> |
44 | #include "../globals.h" | 44 | #include "../globals.h" |
45 | 45 | ||
46 | -// static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); | ||
47 | -static void static_RemoveSource(void *id); | ||
48 | - | ||
49 | static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); | 46 | static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); |
50 | -static void static_RemoveSource(void *id); | 47 | +static void static_RemoveSource(H3270 *session, void *id); |
51 | 48 | ||
52 | -static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | ||
53 | -static void static_RemoveTimeOut(void * timer); | 49 | +static void * static_AddTimeOut(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session)); |
50 | +static void static_RemoveTimeOut(H3270 *session, void * timer); | ||
54 | static int static_Sleep(H3270 *hSession, int seconds); | 51 | static int static_Sleep(H3270 *hSession, int seconds); |
55 | static int static_RunPendingEvents(H3270 *hSession, int wait); | 52 | static int static_RunPendingEvents(H3270 *hSession, int wait); |
56 | 53 | ||
@@ -116,32 +113,12 @@ static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, voi | @@ -116,32 +113,12 @@ static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, voi | ||
116 | return src; | 113 | return src; |
117 | } | 114 | } |
118 | 115 | ||
119 | -/* | ||
120 | -static void * static_AddOutput(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
121 | -{ | ||
122 | - return AddSource(source,session,G_IO_OUT|G_IO_HUP|G_IO_ERR,fn); | ||
123 | -} | ||
124 | - | ||
125 | - | ||
126 | -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
127 | -{ | ||
128 | - return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); | ||
129 | -} | ||
130 | -*/ | ||
131 | - | ||
132 | -static void static_RemoveSource(void *id) | 116 | +static void static_RemoveSource(H3270 *session, void *id) |
133 | { | 117 | { |
134 | if(id) | 118 | if(id) |
135 | g_source_destroy((GSource *) id); | 119 | g_source_destroy((GSource *) id); |
136 | } | 120 | } |
137 | 121 | ||
138 | -/* | ||
139 | -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | ||
140 | -{ | ||
141 | - return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); | ||
142 | -} | ||
143 | -*/ | ||
144 | - | ||
145 | static gboolean do_timer(TIMER *t) | 122 | static gboolean do_timer(TIMER *t) |
146 | { | 123 | { |
147 | if(!t->remove) | 124 | if(!t->remove) |
@@ -149,7 +126,7 @@ static gboolean do_timer(TIMER *t) | @@ -149,7 +126,7 @@ static gboolean do_timer(TIMER *t) | ||
149 | return FALSE; | 126 | return FALSE; |
150 | } | 127 | } |
151 | 128 | ||
152 | -static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*call)(H3270 *session)) | 129 | +static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*call)(H3270 *session)) |
153 | { | 130 | { |
154 | TIMER *t = g_malloc0(sizeof(TIMER)); | 131 | TIMER *t = g_malloc0(sizeof(TIMER)); |
155 | 132 | ||
@@ -162,7 +139,7 @@ static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*c | @@ -162,7 +139,7 @@ static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*c | ||
162 | return t; | 139 | return t; |
163 | } | 140 | } |
164 | 141 | ||
165 | -static void static_RemoveTimeOut(void * timer) | 142 | +static void static_RemoveTimeOut(H3270 *session, void * timer) |
166 | { | 143 | { |
167 | ((TIMER *) timer)->remove++; | 144 | ((TIMER *) timer)->remove++; |
168 | } | 145 | } |