Commit 492a455996cd4e975ba16d8ecb8b37e94d7c63d3

Authored by Perry Werneck
1 parent 51027b5f

Adding userdata pointer on timer handle.

src/core/host.c
@@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@
64 /** 64 /**
65 * @brief Called from timer to attempt an automatic reconnection. 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 if(hSession->auto_reconnect_inprogress) 70 if(hSession->auto_reconnect_inprogress)
@@ -94,7 +94,7 @@ int lib3270_activate_auto_reconnect(H3270 *hSession, unsigned long msec) @@ -94,7 +94,7 @@ int lib3270_activate_auto_reconnect(H3270 *hSession, unsigned long msec)
94 return EBUSY; 94 return EBUSY;
95 95
96 hSession->auto_reconnect_inprogress = 1; 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 return 0; 99 return 0;
100 } 100 }
src/core/iocalls.c
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 63
64 // Timeout calls 64 // Timeout calls
65 static void internal_remove_timer(H3270 *session, void *timer); 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 static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); 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 static void internal_remove_poll(H3270 *session, void *id); 69 static void internal_remove_poll(H3270 *session, void *id);
@@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
78 78
79 /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ 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 = internal_add_timer; 82 = internal_add_timer;
83 83
84 static void (*remove_timer)(H3270 *session, void *timer) 84 static void (*remove_timer)(H3270 *session, void *timer)
@@ -128,7 +128,7 @@ static void ms_ts(unsigned long long *u) @@ -128,7 +128,7 @@ static void ms_ts(unsigned long long *u)
128 } 128 }
129 #endif 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 timeout_t *t_new; 133 timeout_t *t_new;
134 timeout_t *t; 134 timeout_t *t;
@@ -139,6 +139,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int @@ -139,6 +139,7 @@ static void * internal_add_timer(H3270 *session, unsigned long interval_ms, int
139 t_new = (timeout_t *) lib3270_malloc(sizeof(timeout_t)); 139 t_new = (timeout_t *) lib3270_malloc(sizeof(timeout_t));
140 140
141 t_new->proc = proc; 141 t_new->proc = proc;
  142 + t_new->userdata = userdata;
142 t_new->in_play = False; 143 t_new->in_play = False;
143 144
144 #if defined(_WIN32) 145 #if defined(_WIN32)
@@ -207,28 +208,6 @@ static void internal_remove_timer(H3270 *session, void * timer) @@ -207,28 +208,6 @@ static void internal_remove_timer(H3270 *session, void * timer)
207 if(!st->in_play) 208 if(!st->in_play)
208 lib3270_linked_list_delete_node(&session->timeouts,timer); 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 /* I/O events. */ 213 /* I/O events. */
@@ -250,35 +229,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo @@ -250,35 +229,7 @@ static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, vo
250 static void internal_remove_poll(H3270 *session, void *id) 229 static void internal_remove_poll(H3270 *session, void *id)
251 { 230 {
252 lib3270_linked_list_delete_node(&session->input.list,id); 231 lib3270_linked_list_delete_node(&session->input.list,id);
253 -  
254 session->input.changed = 1; 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 static void internal_set_poll_state(H3270 *session, void *id, int enabled) 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,11 +323,11 @@ static void internal_ring_bell(H3270 GNUC_UNUSED(*session))
372 323
373 /* External entry points */ 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 void *timer; 328 void *timer;
378 CHECK_SESSION_HANDLE(session); 329 CHECK_SESSION_HANDLE(session);
379 - timer = add_timer(session,interval_ms,proc); 330 + timer = add_timer(session,interval_ms,proc,userdata);
380 trace("Timeout %p created with %ld ms",timer,interval_ms); 331 trace("Timeout %p created with %ld ms",timer,interval_ms);
381 return timer; 332 return timer;
382 } 333 }
@@ -427,7 +378,7 @@ void remove_input_calls(H3270 *session) @@ -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 if(add) 383 if(add)
433 add_timer = add; 384 add_timer = add;
src/core/keyboard/kybd.c
@@ -1009,7 +1009,7 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession) @@ -1009,7 +1009,7 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession)
1009 /** 1009 /**
1010 * @brief Deferred keyboard unlock. 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 lib3270_kybdlock_clear(hSession,KL_DEFERRED_UNLOCK); 1014 lib3270_kybdlock_clear(hSession,KL_DEFERRED_UNLOCK);
1015 status_reset(hSession); 1015 status_reset(hSession);
@@ -1067,12 +1067,12 @@ void do_reset(H3270 *hSession, Boolean explicit) @@ -1067,12 +1067,12 @@ void do_reset(H3270 *hSession, Boolean explicit)
1067 1067
1068 if(hSession->unlock_delay_ms) 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 else 1072 else
1073 { 1073 {
1074 hSession->unlock_id = 0; 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,7 +188,7 @@ retry:
188 if (t->tv.tv_sec < now.tv_sec ||(t->tv.tv_sec == now.tv_sec && t->tv.tv_usec < now.tv_usec)) 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 t->in_play = True; 190 t->in_play = True;
191 - (*t->proc)(hSession); 191 + (*t->proc)(hSession,t->userdata);
192 processed_any = True; 192 processed_any = True;
193 193
194 lib3270_linked_list_delete_node(&hSession->timeouts,t); 194 lib3270_linked_list_delete_node(&hSession->timeouts,t);
src/include/internals.h
@@ -274,7 +274,7 @@ typedef struct timeout @@ -274,7 +274,7 @@ typedef struct timeout
274 struct timeval tv; 274 struct timeval tv;
275 #endif /*]*/ 275 #endif /*]*/
276 276
277 - int (*proc)(H3270 *session); 277 + int (*proc)(H3270 *session, void *userdata);
278 278
279 } timeout_t; 279 } timeout_t;
280 280
src/include/lib3270.h
@@ -970,7 +970,7 @@ @@ -970,7 +970,7 @@
970 { 970 {
971 unsigned short sz; 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 void (*RemoveTimer)(H3270 *session, void *timer); 974 void (*RemoveTimer)(H3270 *session, void *timer);
975 975
976 void * (*add_poll)(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); 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,7 +1001,7 @@
1001 * @param rm Callback for removing a timeout 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 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)); 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,7 +39,7 @@ LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *sessio
39 LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); 39 LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session));
40 40
41 LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie); 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 LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie); 43 LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie);
44 44
45 // LIB3270_INTERNAL const char * KeysymToString(KeySym k); 45 // LIB3270_INTERNAL const char * KeysymToString(KeySym k);