diff --git a/src/core/host.c b/src/core/host.c index d182d99..2ad8dc6 100644 --- a/src/core/host.c +++ b/src/core/host.c @@ -64,7 +64,7 @@ /** * @brief Called from timer to attempt an automatic reconnection. */ -static int check_for_auto_reconnect(H3270 *hSession) +static int check_for_auto_reconnect(H3270 *hSession, void GNUC_UNUSED(*userdata)) { if(hSession->auto_reconnect_inprogress) @@ -94,7 +94,7 @@ int lib3270_activate_auto_reconnect(H3270 *hSession, unsigned long msec) return EBUSY; hSession->auto_reconnect_inprogress = 1; - (void) AddTimer(msec, hSession, check_for_auto_reconnect); + (void) AddTimer(msec, hSession, check_for_auto_reconnect, NULL); return 0; } diff --git a/src/core/iocalls.c b/src/core/iocalls.c index 1138ca9..9c55cf2 100644 --- a/src/core/iocalls.c +++ b/src/core/iocalls.c @@ -63,7 +63,7 @@ // Timeout calls static void internal_remove_timer(H3270 *session, void *timer); - static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)); + static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata); static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); static void internal_remove_poll(H3270 *session, void *id); @@ -78,7 +78,7 @@ /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ - static void * (*add_timer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)) + static void * (*add_timer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata) = internal_add_timer; static void (*remove_timer)(H3270 *session, void *timer) @@ -128,7 +128,7 @@ static void ms_ts(unsigned long long *u) } #endif -static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)) +static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata) { timeout_t *t_new; timeout_t *t; @@ -139,6 +139,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int t_new = (timeout_t *) lib3270_malloc(sizeof(timeout_t)); t_new->proc = proc; + t_new->userdata = userdata; t_new->in_play = False; #if defined(_WIN32) @@ -207,28 +208,6 @@ static void internal_remove_timer(H3270 *session, void * timer) if(!st->in_play) lib3270_linked_list_delete_node(&session->timeouts,timer); - /* - timeout_t *t; - timeout_t *prev = TN; - - - if (st->in_play) - return; - - for (t = session->timeouts; t != TN; t = t->next) - { - if (t == st) - { - if (prev != TN) - prev->next = t->next; - else - session->timeouts = t->next; - lib3270_free(t); - return; - } - prev = t; - } - */ } /* I/O events. */ @@ -250,35 +229,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo static void internal_remove_poll(H3270 *session, void *id) { lib3270_linked_list_delete_node(&session->input.list,id); - session->input.changed = 1; - - /* - input_t *ip; - input_t *prev = (input_t *)NULL; - - for (ip = session->inputs; ip != (input_t *) NULL; ip = (input_t *) ip->next) - { - if (ip == (input_t *)id) - break; - - prev = ip; - } - - if (ip == (input_t *)NULL) - { - lib3270_write_log(session,"lib3270","Invalid call to (%s): Input %p wasnt found in the list",__FUNCTION__,id); - return; - } - - if (prev != (input_t *)NULL) - prev->next = ip->next; - else - session->inputs = (input_t *) ip->next; - - lib3270_free(ip); - session->inputs_changed = 1; - */ } static void internal_set_poll_state(H3270 *session, void *id, int enabled) @@ -372,11 +323,11 @@ static void internal_ring_bell(H3270 GNUC_UNUSED(*session)) /* External entry points */ -void * AddTimer(unsigned long interval_ms, H3270 *session, int (*proc)(H3270 *session)) +void * AddTimer(unsigned long interval_ms, H3270 *session, int (*proc)(H3270 *session, void *userdata), void *userdata) { void *timer; CHECK_SESSION_HANDLE(session); - timer = add_timer(session,interval_ms,proc); + timer = add_timer(session,interval_ms,proc,userdata); trace("Timeout %p created with %ld ms",timer,interval_ms); return timer; } @@ -427,7 +378,7 @@ void remove_input_calls(H3270 *session) } } -LIB3270_EXPORT void lib3270_register_timer_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)), void (*rm)(H3270 *session, void *timer)) +LIB3270_EXPORT void lib3270_register_timer_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session,void *userdata), void *userdata), void (*rm)(H3270 *session, void *timer)) { if(add) add_timer = add; diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c index 8f478dc..2e5364f 100644 --- a/src/core/keyboard/kybd.c +++ b/src/core/keyboard/kybd.c @@ -1009,7 +1009,7 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession) /** * @brief Deferred keyboard unlock. */ -static int defer_unlock(H3270 *hSession) +static int defer_unlock(H3270 *hSession, void GNUC_UNUSED(*userdata)) { lib3270_kybdlock_clear(hSession,KL_DEFERRED_UNLOCK); status_reset(hSession); @@ -1067,12 +1067,12 @@ void do_reset(H3270 *hSession, Boolean explicit) if(hSession->unlock_delay_ms) { - hSession->unlock_id = AddTimer(hSession->unlock_delay_ms, hSession, defer_unlock); + hSession->unlock_id = AddTimer(hSession->unlock_delay_ms, hSession, defer_unlock, NULL); } else { hSession->unlock_id = 0; - defer_unlock(hSession); + defer_unlock(hSession, NULL); } } diff --git a/src/core/linux/event_dispatcher.c b/src/core/linux/event_dispatcher.c index 9b9b7d8..716474c 100644 --- a/src/core/linux/event_dispatcher.c +++ b/src/core/linux/event_dispatcher.c @@ -188,7 +188,7 @@ retry: if (t->tv.tv_sec < now.tv_sec ||(t->tv.tv_sec == now.tv_sec && t->tv.tv_usec < now.tv_usec)) { t->in_play = True; - (*t->proc)(hSession); + (*t->proc)(hSession,t->userdata); processed_any = True; lib3270_linked_list_delete_node(&hSession->timeouts,t); diff --git a/src/include/internals.h b/src/include/internals.h index cffed11..23a0e5a 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -274,7 +274,7 @@ typedef struct timeout struct timeval tv; #endif /*]*/ - int (*proc)(H3270 *session); + int (*proc)(H3270 *session, void *userdata); } timeout_t; diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 6e49a94..8fb74b5 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -970,7 +970,7 @@ { unsigned short sz; - void * (*AddTimer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)); + void * (*AddTimer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata); void (*RemoveTimer)(H3270 *session, void *timer); void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); @@ -1001,7 +1001,7 @@ * @param rm Callback for removing a timeout * */ - LIB3270_EXPORT void lib3270_register_timer_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)), void (*rm)(H3270 *session, void *timer)); + LIB3270_EXPORT void lib3270_register_timer_handlers(void * (*add)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata), void (*rm)(H3270 *session, void *timer)); 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)); diff --git a/src/include/utilc.h b/src/include/utilc.h index 629a06c..b6fca5d 100644 --- a/src/include/utilc.h +++ b/src/include/utilc.h @@ -39,7 +39,7 @@ LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *sessio LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie); -LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session)); +LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session, void *userdata), void *userdata); LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie); // LIB3270_INTERNAL const char * KeysymToString(KeySym k); -- libgit2 0.21.2