From 70ad251f77de81cebc29979e4fb7d1847f6b89a4 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 7 Feb 2012 23:04:38 +0000 Subject: [PATCH] Movendo timer para funcoes da estrutura de controle de sessao --- latest/src/include/lib3270/api.h | 1 + latest/src/lib/ctlr.c | 62 ++++++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index b4b9a8b..e39dd65 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -274,6 +274,7 @@ void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr); void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col); void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); + void (*set_timer)(H3270 *session, unsigned char on); void (*update_luname)(H3270 *session, const char *name); void (*update_status)(H3270 *session, LIB3270_STATUS id); diff --git a/latest/src/lib/ctlr.c b/latest/src/lib/ctlr.c index 1e98eed..aaecee3 100644 --- a/latest/src/lib/ctlr.c +++ b/latest/src/lib/ctlr.c @@ -2770,39 +2770,53 @@ void ticking_start(H3270 *session, Boolean anyway) { CHECK_SESSION_HANDLE(session); - (void) gettimeofday(&t_start, (struct timezone *) 0); - - mticking = True; + if(session->set_timer) + { + if(toggled(SHOW_TIMING) || anyway) + session->set_timer(session,-1); + } + else + { + (void) gettimeofday(&t_start, (struct timezone *) 0); + + mticking = True; + + if (!toggled(SHOW_TIMING) && !anyway) + return; + status_untiming(session); + if (ticking) + RemoveTimeOut(tick_id); + ticking = True; + tick_id = AddTimeOut(1000, session, keep_ticking); + t_want = t_start; + } - if (!toggled(SHOW_TIMING) && !anyway) - return; - status_untiming(session); - if (ticking) - RemoveTimeOut(tick_id); - ticking = True; - tick_id = AddTimeOut(1000, session, keep_ticking); - t_want = t_start; } static void ticking_stop(H3270 *session) { - struct timeval t1; - CHECK_SESSION_HANDLE(session); - (void) gettimeofday(&t1, (struct timezone *) 0); - if (mticking) { -// sms_accumulate_time(&t_start, &t1); - mticking = False; - } else { - return; + if(session->set_timer) + { + session->set_timer(session,0); } + else + { + struct timeval t1; - if (!ticking) - return; - RemoveTimeOut(tick_id); - ticking = False; - status_timing(session,&t_start, &t1); + (void) gettimeofday(&t1, (struct timezone *) 0); + if (mticking) + mticking = False; + else + return; + + if (!ticking) + return; + RemoveTimeOut(tick_id); + ticking = False; + status_timing(session,&t_start, &t1); + } } void -- libgit2 0.21.2