Commit 492a455996cd4e975ba16d8ecb8b37e94d7c63d3
1 parent
51027b5f
Exists in
master
and in
3 other branches
Adding userdata pointer on timer handle.
Showing
7 changed files
with
17 additions
and
66 deletions
Show diff stats
src/core/host.c
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | /** |
65 | 65 | * @brief Called from timer to attempt an automatic reconnection. |
66 | 66 | */ |
67 | -static int check_for_auto_reconnect(H3270 *hSession) | |
67 | +static int check_for_auto_reconnect(H3270 *hSession, void GNUC_UNUSED(*userdata)) | |
68 | 68 | { |
69 | 69 | |
70 | 70 | if(hSession->auto_reconnect_inprogress) |
... | ... | @@ -94,7 +94,7 @@ int lib3270_activate_auto_reconnect(H3270 *hSession, unsigned long msec) |
94 | 94 | return EBUSY; |
95 | 95 | |
96 | 96 | hSession->auto_reconnect_inprogress = 1; |
97 | - (void) AddTimer(msec, hSession, check_for_auto_reconnect); | |
97 | + (void) AddTimer(msec, hSession, check_for_auto_reconnect, NULL); | |
98 | 98 | |
99 | 99 | return 0; |
100 | 100 | } | ... | ... |
src/core/iocalls.c
... | ... | @@ -63,7 +63,7 @@ |
63 | 63 | |
64 | 64 | // Timeout calls |
65 | 65 | static void internal_remove_timer(H3270 *session, void *timer); |
66 | - static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)); | |
66 | + static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata); | |
67 | 67 | |
68 | 68 | static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); |
69 | 69 | static void internal_remove_poll(H3270 *session, void *id); |
... | ... | @@ -78,7 +78,7 @@ |
78 | 78 | |
79 | 79 | /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ |
80 | 80 | |
81 | - static void * (*add_timer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)) | |
81 | + static void * (*add_timer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata) | |
82 | 82 | = internal_add_timer; |
83 | 83 | |
84 | 84 | static void (*remove_timer)(H3270 *session, void *timer) |
... | ... | @@ -128,7 +128,7 @@ static void ms_ts(unsigned long long *u) |
128 | 128 | } |
129 | 129 | #endif |
130 | 130 | |
131 | -static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)) | |
131 | +static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata) | |
132 | 132 | { |
133 | 133 | timeout_t *t_new; |
134 | 134 | timeout_t *t; |
... | ... | @@ -139,6 +139,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int |
139 | 139 | t_new = (timeout_t *) lib3270_malloc(sizeof(timeout_t)); |
140 | 140 | |
141 | 141 | t_new->proc = proc; |
142 | + t_new->userdata = userdata; | |
142 | 143 | t_new->in_play = False; |
143 | 144 | |
144 | 145 | #if defined(_WIN32) |
... | ... | @@ -207,28 +208,6 @@ static void internal_remove_timer(H3270 *session, void * timer) |
207 | 208 | if(!st->in_play) |
208 | 209 | lib3270_linked_list_delete_node(&session->timeouts,timer); |
209 | 210 | |
210 | - /* | |
211 | - timeout_t *t; | |
212 | - timeout_t *prev = TN; | |
213 | - | |
214 | - | |
215 | - if (st->in_play) | |
216 | - return; | |
217 | - | |
218 | - for (t = session->timeouts; t != TN; t = t->next) | |
219 | - { | |
220 | - if (t == st) | |
221 | - { | |
222 | - if (prev != TN) | |
223 | - prev->next = t->next; | |
224 | - else | |
225 | - session->timeouts = t->next; | |
226 | - lib3270_free(t); | |
227 | - return; | |
228 | - } | |
229 | - prev = t; | |
230 | - } | |
231 | - */ | |
232 | 211 | } |
233 | 212 | |
234 | 213 | /* I/O events. */ |
... | ... | @@ -250,35 +229,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo |
250 | 229 | static void internal_remove_poll(H3270 *session, void *id) |
251 | 230 | { |
252 | 231 | lib3270_linked_list_delete_node(&session->input.list,id); |
253 | - | |
254 | 232 | session->input.changed = 1; |
255 | - | |
256 | - /* | |
257 | - input_t *ip; | |
258 | - input_t *prev = (input_t *)NULL; | |
259 | - | |
260 | - for (ip = session->inputs; ip != (input_t *) NULL; ip = (input_t *) ip->next) | |
261 | - { | |
262 | - if (ip == (input_t *)id) | |
263 | - break; | |
264 | - | |
265 | - prev = ip; | |
266 | - } | |
267 | - | |
268 | - if (ip == (input_t *)NULL) | |
269 | - { | |
270 | - lib3270_write_log(session,"lib3270","Invalid call to (%s): Input %p wasnt found in the list",__FUNCTION__,id); | |
271 | - return; | |
272 | - } | |
273 | - | |
274 | - if (prev != (input_t *)NULL) | |
275 | - prev->next = ip->next; | |
276 | - else | |
277 | - session->inputs = (input_t *) ip->next; | |
278 | - | |
279 | - lib3270_free(ip); | |
280 | - session->inputs_changed = 1; | |
281 | - */ | |
282 | 233 | } |
283 | 234 | |
284 | 235 | 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)) |
372 | 323 | |
373 | 324 | /* External entry points */ |
374 | 325 | |
375 | -void * AddTimer(unsigned long interval_ms, H3270 *session, int (*proc)(H3270 *session)) | |
326 | +void * AddTimer(unsigned long interval_ms, H3270 *session, int (*proc)(H3270 *session, void *userdata), void *userdata) | |
376 | 327 | { |
377 | 328 | void *timer; |
378 | 329 | CHECK_SESSION_HANDLE(session); |
379 | - timer = add_timer(session,interval_ms,proc); | |
330 | + timer = add_timer(session,interval_ms,proc,userdata); | |
380 | 331 | trace("Timeout %p created with %ld ms",timer,interval_ms); |
381 | 332 | return timer; |
382 | 333 | } |
... | ... | @@ -427,7 +378,7 @@ void remove_input_calls(H3270 *session) |
427 | 378 | } |
428 | 379 | } |
429 | 380 | |
430 | -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)) | |
381 | +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)) | |
431 | 382 | { |
432 | 383 | if(add) |
433 | 384 | add_timer = add; | ... | ... |
src/core/keyboard/kybd.c
... | ... | @@ -1009,7 +1009,7 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession) |
1009 | 1009 | /** |
1010 | 1010 | * @brief Deferred keyboard unlock. |
1011 | 1011 | */ |
1012 | -static int defer_unlock(H3270 *hSession) | |
1012 | +static int defer_unlock(H3270 *hSession, void GNUC_UNUSED(*userdata)) | |
1013 | 1013 | { |
1014 | 1014 | lib3270_kybdlock_clear(hSession,KL_DEFERRED_UNLOCK); |
1015 | 1015 | status_reset(hSession); |
... | ... | @@ -1067,12 +1067,12 @@ void do_reset(H3270 *hSession, Boolean explicit) |
1067 | 1067 | |
1068 | 1068 | if(hSession->unlock_delay_ms) |
1069 | 1069 | { |
1070 | - hSession->unlock_id = AddTimer(hSession->unlock_delay_ms, hSession, defer_unlock); | |
1070 | + hSession->unlock_id = AddTimer(hSession->unlock_delay_ms, hSession, defer_unlock, NULL); | |
1071 | 1071 | } |
1072 | 1072 | else |
1073 | 1073 | { |
1074 | 1074 | hSession->unlock_id = 0; |
1075 | - defer_unlock(hSession); | |
1075 | + defer_unlock(hSession, NULL); | |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | } | ... | ... |
src/core/linux/event_dispatcher.c
... | ... | @@ -188,7 +188,7 @@ retry: |
188 | 188 | if (t->tv.tv_sec < now.tv_sec ||(t->tv.tv_sec == now.tv_sec && t->tv.tv_usec < now.tv_usec)) |
189 | 189 | { |
190 | 190 | t->in_play = True; |
191 | - (*t->proc)(hSession); | |
191 | + (*t->proc)(hSession,t->userdata); | |
192 | 192 | processed_any = True; |
193 | 193 | |
194 | 194 | lib3270_linked_list_delete_node(&hSession->timeouts,t); | ... | ... |
src/include/internals.h
src/include/lib3270.h
... | ... | @@ -970,7 +970,7 @@ |
970 | 970 | { |
971 | 971 | unsigned short sz; |
972 | 972 | |
973 | - void * (*AddTimer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session)); | |
973 | + void * (*AddTimer)(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session, void *userdata), void *userdata); | |
974 | 974 | void (*RemoveTimer)(H3270 *session, void *timer); |
975 | 975 | |
976 | 976 | 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 @@ |
1001 | 1001 | * @param rm Callback for removing a timeout |
1002 | 1002 | * |
1003 | 1003 | */ |
1004 | - 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)); | |
1004 | + 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)); | |
1005 | 1005 | |
1006 | 1006 | 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)); |
1007 | 1007 | ... | ... |
src/include/utilc.h
... | ... | @@ -39,7 +39,7 @@ LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *sessio |
39 | 39 | LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); |
40 | 40 | |
41 | 41 | LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie); |
42 | -LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session)); | |
42 | +LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session, void *userdata), void *userdata); | |
43 | 43 | LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie); |
44 | 44 | |
45 | 45 | // LIB3270_INTERNAL const char * KeysymToString(KeySym k); | ... | ... |