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 | 37 | |
| 38 | 38 | dnl Initialise automake with the package name, version and |
| 39 | 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 | 42 | dnl Place auxilliary scripts here. |
| 43 | 43 | AC_CONFIG_AUX_DIR([scripts]) | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -673,10 +673,10 @@ |
| 673 | 673 | } LIB3270_IO_FLAG; |
| 674 | 674 | |
| 675 | 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 | 681 | /** Callback table |
| 682 | 682 | * |
| ... | ... | @@ -687,15 +687,15 @@ |
| 687 | 687 | { |
| 688 | 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 | 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 | 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 | 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 | 724 | * Get program message. |
| ... | ... | @@ -1011,7 +1011,6 @@ |
| 1011 | 1011 | |
| 1012 | 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 | 1014 | LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); |
| 1016 | 1015 | |
| 1017 | 1016 | LIB3270_EXPORT const char * lib3270_get_model(H3270 *session); |
| ... | ... | @@ -1022,6 +1021,18 @@ |
| 1022 | 1021 | |
| 1023 | 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 | 1038 | * Alloc/Realloc memory buffer. | ... | ... |
src/include/lib3270/session.h
| ... | ... | @@ -263,15 +263,16 @@ |
| 263 | 263 | unsigned char hisopts[LIB3270_TELNET_N_OPTS]; |
| 264 | 264 | |
| 265 | 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 | 268 | void * unlock_id; |
| 269 | 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 | 271 | LIB3270_TA * ta_head; |
| 271 | 272 | LIB3270_TA * ta_tail; |
| 272 | 273 | |
| 273 | 274 | // ft_dft.c |
| 274 | - int dft_buffersize; /**< Buffer size (LIMIN, LIMOUT) */ | |
| 275 | + int dft_buffersize; ///< @brief Buffer size (LIMIN, LIMOUT) | |
| 275 | 276 | |
| 276 | 277 | // rpq.c |
| 277 | 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 | 84 | |
| 85 | 85 | if(hSession->ns_write_id) { |
| 86 | 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 | 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 | 2860 | return; |
| 2861 | 2861 | |
| 2862 | 2862 | status_untiming(hSession); |
| 2863 | + | |
| 2863 | 2864 | if (hSession->ticking) |
| 2864 | - RemoveTimeOut(hSession->tick_id); | |
| 2865 | + RemoveTimeOut(hSession, hSession->tick_id); | |
| 2866 | + | |
| 2865 | 2867 | hSession->ticking = 1; |
| 2866 | 2868 | hSession->tick_id = AddTimeOut(1000, hSession, keep_ticking); |
| 2867 | 2869 | hSession->t_want = hSession->t_start; |
| ... | ... | @@ -2889,7 +2891,7 @@ static void ticking_stop(H3270 *hSession) |
| 2889 | 2891 | |
| 2890 | 2892 | if (!hSession->ticking) |
| 2891 | 2893 | return; |
| 2892 | - RemoveTimeOut(hSession->tick_id); | |
| 2894 | + RemoveTimeOut(hSession, hSession->tick_id); | |
| 2893 | 2895 | hSession->ticking = 0; |
| 2894 | 2896 | status_timing(hSession,&hSession->t_start, &t1); |
| 2895 | 2897 | } | ... | ... |
src/lib3270/iocalls.c
| ... | ... | @@ -45,34 +45,34 @@ |
| 45 | 45 | /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ |
| 46 | 46 | |
| 47 | 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 | 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 | 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 | 61 | = internal_add_timeout; |
| 62 | 62 | |
| 63 | - static void (*remove_timeout)(void *timer) | |
| 63 | + static void (*remove_timeout)(H3270 *session, void *timer) | |
| 64 | 64 | = internal_remove_timeout; |
| 65 | 65 | |
| 66 | 66 | static void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata) |
| 67 | 67 | = internal_add_poll; |
| 68 | 68 | |
| 69 | - static void (*remove_poll)(void *id) | |
| 69 | + static void (*remove_poll)(H3270 *session, void *id) | |
| 70 | 70 | = internal_remove_poll; |
| 71 | 71 | |
| 72 | - static int (*wait)(H3270 *hSession, int seconds) | |
| 72 | + static int (*wait)(H3270 *session, int seconds) | |
| 73 | 73 | = internal_wait; |
| 74 | 74 | |
| 75 | - static int (*event_dispatcher)(H3270 *hSession,int wait) | |
| 75 | + static int (*event_dispatcher)(H3270 *session,int wait) | |
| 76 | 76 | = lib3270_default_event_dispatcher; |
| 77 | 77 | |
| 78 | 78 | static void (*ring_bell)(H3270 *) |
| ... | ... | @@ -134,7 +134,7 @@ static void ms_ts(unsigned long long *u) |
| 134 | 134 | } |
| 135 | 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 | 139 | timeout_t *t_new; |
| 140 | 140 | timeout_t *t; |
| ... | ... | @@ -199,7 +199,7 @@ static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, vo |
| 199 | 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 | 204 | timeout_t *st = (timeout_t *)timer; |
| 205 | 205 | timeout_t *t; |
| ... | ... | @@ -243,7 +243,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo |
| 243 | 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 | 248 | input_t *ip; |
| 249 | 249 | input_t *prev = (input_t *)NULL; |
| ... | ... | @@ -258,7 +258,7 @@ static void internal_remove_poll(void *id) |
| 258 | 258 | |
| 259 | 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 | 262 | return; |
| 263 | 263 | } |
| 264 | 264 | |
| ... | ... | @@ -271,12 +271,12 @@ static void internal_remove_poll(void *id) |
| 271 | 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 | 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 | 282 | input_t *ip; |
| ... | ... | @@ -285,7 +285,7 @@ LIB3270_EXPORT void lib3270_remove_poll_fd(int fd) |
| 285 | 285 | { |
| 286 | 286 | if(ip->fd == fd) |
| 287 | 287 | { |
| 288 | - remove_poll(ip); | |
| 288 | + remove_poll(session, ip); | |
| 289 | 289 | return; |
| 290 | 290 | } |
| 291 | 291 | } |
| ... | ... | @@ -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 | 300 | input_t *ip; |
| ... | ... | @@ -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 | 612 | { |
| 613 | 613 | void *timer; |
| 614 | 614 | CHECK_SESSION_HANDLE(session); |
| 615 | - timer = add_timeout(interval_ms,session,proc); | |
| 615 | + timer = add_timeout(session,interval_ms,proc); | |
| 616 | 616 | trace("Timeout %p created with %ld ms",timer,interval_ms); |
| 617 | 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 | 625 | trace("Removing timeout %p",timer); |
| 623 | - return remove_timeout(timer); | |
| 626 | + return remove_timeout(session, timer); | |
| 624 | 627 | } |
| 625 | 628 | |
| 626 | 629 | void x_except_on(H3270 *h) |
| ... | ... | @@ -632,7 +635,7 @@ void x_except_on(H3270 *h) |
| 632 | 635 | return; |
| 633 | 636 | |
| 634 | 637 | if(reading) |
| 635 | - lib3270_remove_poll(h->ns_read_id); | |
| 638 | + lib3270_remove_poll(h,h->ns_read_id); | |
| 636 | 639 | |
| 637 | 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 | 649 | { |
| 647 | 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 | 653 | session->ns_read_id = NULL; |
| 651 | 654 | } |
| 652 | 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 | 658 | session->ns_exception_id = NULL; |
| 656 | 659 | } |
| 657 | 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 | 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 | 669 | if(add) |
| 667 | 670 | add_timeout = add; |
| ... | ... | @@ -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 | 678 | if(add) |
| 676 | 679 | add_poll = add; |
| 677 | 680 | ... | ... |
src/lib3270/kybd.c
| ... | ... | @@ -124,27 +124,6 @@ static int flush_ta(H3270 *hSession); |
| 124 | 124 | static void key_AID(H3270 *session, unsigned char aid_code); |
| 125 | 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 | 127 | /* Composite key mappings. */ |
| 149 | 128 | |
| 150 | 129 | struct akeysym |
| ... | ... | @@ -152,14 +131,6 @@ struct akeysym |
| 152 | 131 | KeySym keysym; |
| 153 | 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 | 135 | #define ak_eq(k1, k2) (((k1).keysym == (k2).keysym) && \ |
| 165 | 136 | ((k1).keytype == (k2).keytype)) |
| ... | ... | @@ -180,12 +151,6 @@ struct ta |
| 180 | 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 | 154 | #if defined(DEBUG) |
| 190 | 155 | #define ENQUEUE_ACTION(x) enq_ta(hSession, (void (*)(H3270 *, const char *, const char *)) x, NULL, NULL, #x) |
| 191 | 156 | #else |
| ... | ... | @@ -445,7 +410,7 @@ void kybd_inhibit(H3270 *session, Boolean inhibit) |
| 445 | 410 | void kybd_connect(H3270 *session, int connected, void *dunno) |
| 446 | 411 | { |
| 447 | 412 | if (session->kybdlock & KL_DEFERRED_UNLOCK) |
| 448 | - RemoveTimeOut(session->unlock_id); | |
| 413 | + RemoveTimeOut(session, session->unlock_id); | |
| 449 | 414 | |
| 450 | 415 | lib3270_kybdlock_clear(session, -1); |
| 451 | 416 | |
| ... | ... | @@ -467,7 +432,8 @@ void kybd_connect(H3270 *session, int connected, void *dunno) |
| 467 | 432 | void kybd_in3270(H3270 *hSession, int in3270 unused, void *dunno) |
| 468 | 433 | { |
| 469 | 434 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) |
| 470 | - RemoveTimeOut(hSession->unlock_id); | |
| 435 | + RemoveTimeOut(hSession, hSession->unlock_id); | |
| 436 | + | |
| 471 | 437 | lib3270_kybdlock_clear(hSession,~KL_AWAITING_FIRST); |
| 472 | 438 | |
| 473 | 439 | /* There might be a macro pending. */ |
| ... | ... | @@ -1185,7 +1151,7 @@ void do_reset(H3270 *hSession, Boolean explicit) |
| 1185 | 1151 | * keyboard now, or want to defer further into the future. |
| 1186 | 1152 | */ |
| 1187 | 1153 | if (hSession->kybdlock & KL_DEFERRED_UNLOCK) |
| 1188 | - RemoveTimeOut(hSession->unlock_id); | |
| 1154 | + RemoveTimeOut(hSession, hSession->unlock_id); | |
| 1189 | 1155 | |
| 1190 | 1156 | /* |
| 1191 | 1157 | * If explicit (from the keyboard), unlock the keyboard now. |
| ... | ... | @@ -1199,7 +1165,17 @@ void do_reset(H3270 *hSession, Boolean explicit) |
| 1199 | 1165 | { |
| 1200 | 1166 | lib3270_kybdlock_clear(hSession,~KL_DEFERRED_UNLOCK); |
| 1201 | 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 | 1181 | /* Clean up other modes. */ |
| ... | ... | @@ -2998,95 +2974,8 @@ int kybd_prime(H3270 *hSession) |
| 2998 | 2974 | } |
| 2999 | 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 | 242 | hSession->colors = 16; |
| 243 | 243 | hSession->m3279 = 1; |
| 244 | 244 | |
| 245 | + // Keyboard unlock | |
| 246 | + hSession->unlock_delay_ms = 350; /* 0.35s after last unlock */ | |
| 247 | + | |
| 248 | + // CSD | |
| 245 | 249 | for(f=0;f<4;f++) |
| 246 | 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 | 909 | |
| 910 | 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 | 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 | 1961 | |
| 1962 | 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 | 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 | 40 | LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); |
| 41 | 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 | 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 | 47 | LIB3270_INTERNAL const char * KeysymToString(KeySym k); |
| 48 | 48 | ... | ... |
src/pw3270/v3270/iocallback.c
| ... | ... | @@ -43,14 +43,11 @@ |
| 43 | 43 | #include <glib.h> |
| 44 | 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 | 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 | 51 | static int static_Sleep(H3270 *hSession, int seconds); |
| 55 | 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 | 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 | 118 | if(id) |
| 135 | 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 | 122 | static gboolean do_timer(TIMER *t) |
| 146 | 123 | { |
| 147 | 124 | if(!t->remove) |
| ... | ... | @@ -149,7 +126,7 @@ static gboolean do_timer(TIMER *t) |
| 149 | 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 | 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 | 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 | 144 | ((TIMER *) timer)->remove++; |
| 168 | 145 | } | ... | ... |