From 615e14f3488b8c9021bfbf08d6ef3c0c4df63058 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 26 Mar 2013 13:27:03 +0000 Subject: [PATCH] Melhorando teste de "TerminalReady" --- src/include/lib3270.h | 5 +++-- src/lib3270/ctlr.c | 13 ++++++------- src/lib3270/iocalls.c | 4 ++-- src/lib3270/kybd.c | 4 ++-- src/lib3270/screen.c | 36 ++++++++++++++++++++++++++++++++++++ src/lib3270/statusc.h | 3 --- 6 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 2a015cf..f0c2d6d 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -189,7 +189,7 @@ LIB3270_MESSAGE_NUMERIC, /**< 8 - */ LIB3270_MESSAGE_OVERFLOW, /**< 9 - */ LIB3270_MESSAGE_INHIBIT, /**< 10 - */ - LIB3270_MESSAGE_KYBDLOCK, /**< 11 - */ + LIB3270_MESSAGE_KYBDLOCK, /**< 11 - Keyboard is locked */ LIB3270_MESSAGE_X, /**< 12 - */ LIB3270_MESSAGE_RESOLVING, /**< 13 - Resolving hostname (running DNS query) */ @@ -707,9 +707,10 @@ LIB3270_EXPORT int lib3270_in_sscp(H3270 *h); LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h); LIB3270_EXPORT int lib3270_in_e(H3270 *h); + LIB3270_EXPORT int lib3270_lock_status(H3270 *h); + LIB3270_EXPORT int lib3270_is_ready(H3270 *h); #define lib3270_is_connected(h) lib3270_in_tn3270e(h) - #define lib3270_is_ready(h) lib3270_get_program_message(h) == LIB3270_MESSAGE_NONE LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session); LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session); diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index e6e61ed..c7bfb7c 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -2205,21 +2205,20 @@ int ctlr_any_data(H3270 *session) * Clear the text (non-status) portion of the display. Also resets the cursor * and buffer addresses and extended attributes. */ -void -ctlr_clear(H3270 *session, Boolean can_snap) +void ctlr_clear(H3270 *session, Boolean can_snap) { /* Snap any data that is about to be lost into the trace file. */ +#if defined(X3270_TRACE) + if (ctlr_any_data(session)) { -#if defined(X3270_TRACE) /*[*/ if (can_snap && !session->trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE)) trace_screen(session); -#endif /*]*/ -// scroll_save(session->maxROWS, ever_3270 ? False : True); } -#if defined(X3270_TRACE) /*[*/ + session->trace_skipping = 0; -#endif /*]*/ + +#endif /* Clear the screen. */ (void) memset((char *)session->ea_buf, 0, session->rows*session->cols*sizeof(struct lib3270_ea)); diff --git a/src/lib3270/iocalls.c b/src/lib3270/iocalls.c index d4bc22a..49bca6e 100644 --- a/src/lib3270/iocalls.c +++ b/src/lib3270/iocalls.c @@ -726,14 +726,14 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) { time_t end = time(0)+seconds; - if(hSession->oia_status == LIB3270_STATUS_BLANK) + if(!lib3270_lock_status(hSession)) return 0; while(time(0) < end) { event_dispatcher(hSession,1); - if(hSession->oia_status == LIB3270_STATUS_BLANK) + if(!lib3270_lock_status(hSession)) return 0; if(!lib3270_connected(hSession)) diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 22f294f..9552549 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -384,7 +384,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits) hSession->unlock_delay_time = time(NULL); } hSession->kybdlock = n; - status_changed(hSession,LIB3270_STATUS_KYBDLOCK); + status_changed(hSession,LIB3270_MESSAGE_KYBDLOCK); } } @@ -409,7 +409,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) hSession->unlock_delay_time = 0; } hSession->kybdlock = n; - status_changed(hSession,LIB3270_STATUS_KYBDLOCK); + status_changed(hSession,LIB3270_MESSAGE_KYBDLOCK); } } diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 5368676..2e9cf24 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -528,6 +528,42 @@ LIB3270_EXPORT LIB3270_STATUS lib3270_get_program_message(H3270 *session) return session->oia_status; } +/** + * Check if the terminal is ready for commands. + * + * @param h Session handle. + * + * @return 0 if the terminal is ready (no message, keyboard unlocked), LIB3270_MESSAGE if not + * + */ +LIB3270_EXPORT int lib3270_lock_status(H3270 *hSession) +{ + CHECK_SESSION_HANDLE(hSession); + + if(hSession->oia_status) + return hSession->oia_status; + + if(hSession->kybdlock) + return LIB3270_MESSAGE_KYBDLOCK; + + return LIB3270_MESSAGE_NONE; + +} + +/** + * Check if terminal is ready for actions. + * + * @param h Session handle. + * + * @return Non zero if terminal is ready for commands. + * + */ +LIB3270_EXPORT int lib3270_is_ready(H3270 *hSession) +{ + return lib3270_lock_status(hSession) == LIB3270_MESSAGE_NONE; +} + + void status_changed(H3270 *session, LIB3270_STATUS id) { CHECK_SESSION_HANDLE(session); diff --git a/src/lib3270/statusc.h b/src/lib3270/statusc.h index c875074..381bf6d 100644 --- a/src/lib3270/statusc.h +++ b/src/lib3270/statusc.h @@ -35,7 +35,4 @@ LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on); #define status_typeahead(h,on) set_status(h,OIA_FLAG_TYPEAHEAD,on) -// #define status_kybdlock(h) status_changed(h,LIB3270_STATUS_KYBDLOCK) -// #define status_syswait(h) status_changed(h,LIB3270_STATUS_SYSWAIT) -// #define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS) -- libgit2 0.21.2