diff --git a/sdk/lib3270-delayed.pc.in b/sdk/lib3270-delayed.pc.in index 1a25675..109899b 100644 --- a/sdk/lib3270-delayed.pc.in +++ b/sdk/lib3270-delayed.pc.in @@ -13,5 +13,5 @@ Description: @PACKAGE_DESCRIPTION@ Version: @PACKAGE_VERSION@ Libs: -L\@libdir@ -l@LIB3270_NAME@.delayed Libs.private: @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@ -Cflags: -I@includedir@ -DLIB3270_NAME=@LIB3270_NAME@ +Cflags: -DLIB3270_NAME=@LIB3270_NAME@ diff --git a/sdk/lib3270-static.pc.in b/sdk/lib3270-static.pc.in index 579e93a..be5b729 100644 --- a/sdk/lib3270-static.pc.in +++ b/sdk/lib3270-static.pc.in @@ -11,5 +11,5 @@ Name: @PACKAGE_NAME@-static Description: @PACKAGE_DESCRIPTION@ (static library) Version: @PACKAGE_VERSION@ Libs: -L\@libdir@ -l@LIB3270_NAME@.static @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@ -Cflags: -I@includedir@ +Cflags: -DLIB3270_NAME=@LIB3270_NAME@ diff --git a/sdk/lib3270.pc.in b/sdk/lib3270.pc.in index e2a5efe..756cdf5 100644 --- a/sdk/lib3270.pc.in +++ b/sdk/lib3270.pc.in @@ -13,5 +13,5 @@ Description: @PACKAGE_DESCRIPTION@ Version: @PACKAGE_VERSION@ Libs: -L\@libdir@ -l@LIB3270_NAME@ Libs.private: @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@ -Cflags: -I@includedir@ +Cflags: -DLIB3270_NAME=@LIB3270_NAME@ diff --git a/src/core/ctlr.c b/src/core/ctlr.c index 530e945..6364649 100644 --- a/src/core/ctlr.c +++ b/src/core/ctlr.c @@ -116,9 +116,8 @@ static const unsigned char code_table[64] = } \ } - -/* - * Initialize the emulated 3270 hardware. +/** + * @brief Initialize the emulated 3270 hardware. */ void ctlr_init(H3270 *session, unsigned GNUC_UNUSED(cmask)) { @@ -127,8 +126,9 @@ void ctlr_init(H3270 *session, unsigned GNUC_UNUSED(cmask)) lib3270_register_schange(session,LIB3270_STATE_CONNECT, ctlr_connect, 0); lib3270_register_schange(session,LIB3270_STATE_3270_MODE, ctlr_connect, 0); } -/* - * Reinitialize the emulated 3270 hardware. + +/** + * @brief Reinitialize the emulated 3270 hardware. */ void ctlr_reinit(H3270 *session, unsigned cmask) { @@ -153,7 +153,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask) } /** - * Parse the model number. + * @brief Parse the model number. * * @param session Session Handle. * @param m Model number. @@ -231,7 +231,7 @@ static int parse_model_number(H3270 *session, const char *m) } /** - * Get current 3270 model. + * @brief Get current 3270 model. * * @param hSession selected 3270 session. * @return Current model number. @@ -366,7 +366,7 @@ static void set_formatted(H3270 *hSession, int state) } /** - * Update the formatted screen flag. + * @brief Update the formatted screen flag. * * A formatted screen is a screen that has at least one field somewhere on it. * @@ -787,8 +787,8 @@ enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen) } } -/* - * Functions to insert SA attributes into the inbound data stream. +/** + * @brief Functions to insert SA attributes into the inbound data stream. */ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, unsigned char *currentp, Boolean *anyp) { @@ -805,11 +805,10 @@ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, *anyp = False; } -/* - * Translate an internal character set number to a 3270DS characte set number. +/** + * @brief Translate an internal character set number to a 3270DS characte set number. */ -static unsigned char -host_cs(unsigned char cs) +static unsigned char host_cs(unsigned char cs) { switch (cs & CS_MASK) { case CS_APL: @@ -851,7 +850,7 @@ static void insert_sa(H3270 *hSession, int baddr, unsigned char *current_fgp, un /** - * Process a 3270 Read-Modified command and transmit the data back to the host. + * @brief Process a 3270 Read-Modified command and transmit the data back to the host. */ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) { diff --git a/src/core/iocalls.c b/src/core/iocalls.c index 48f2221..d9b65ac 100644 --- a/src/core/iocalls.c +++ b/src/core/iocalls.c @@ -35,6 +35,7 @@ #include "xioc.h" #include "telnetc.h" #include "utilc.h" +#include "kybdc.h" #if defined(_WIN32) #include @@ -477,6 +478,33 @@ LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds) return errno = ENOTSUP; } +LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds) +{ + time_t end = time(0)+seconds; + + FAIL_IF_NOT_ONLINE(hSession); + + event_dispatcher(hSession,0); + + do + { + if(!lib3270_connected(hSession)) + { + errno = ENOTCONN; + return -1; + } + + if(KYBDLOCK_IS_OERR(hSession)) + break; + + event_dispatcher(hSession,1); + + } + while(hSession->kybdlock && time(0) < end); + + return hSession->kybdlock; +} + LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) { time_t end = time(0)+seconds; @@ -484,6 +512,11 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) FAIL_IF_NOT_ONLINE(hSession); event_dispatcher(hSession,0); + + // Keyboard is locked by operator error, fails! + if(hSession->kybdlock && KYBDLOCK_IS_OERR(hSession)) + return -1; + do { if(!lib3270_lock_status(hSession)) diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c index a0450b0..c1ea0a9 100644 --- a/src/core/keyboard/kybd.c +++ b/src/core/keyboard/kybd.c @@ -478,6 +478,7 @@ static void key_AID(H3270 *hSession, unsigned char aid_code) { if (hSession->kybdlock & KL_OIA_MINUS) return; + if (aid_code != AID_ENTER && aid_code != AID_CLEAR) { status_changed(hSession,LIB3270_MESSAGE_MINUS); @@ -499,6 +500,7 @@ static void key_AID(H3270 *hSession, unsigned char aid_code) lib3270_set_toggle(hSession,LIB3270_TOGGLE_INSERT,0); kybdlock_set(hSession,KL_OIA_TWAIT | KL_OIA_LOCKED); } + hSession->aid = aid_code; ctlr_read_modified(hSession, hSession->aid, False); ticking_start(hSession,False); diff --git a/src/core/properties.c b/src/core/properties.c index 18abae6..3fa8932 100644 --- a/src/core/properties.c +++ b/src/core/properties.c @@ -56,6 +56,11 @@ return hSession->starting != 0; } + unsigned int lib3270_get_kybdlock(H3270 *hSession) + { + return hSession->kybdlock; + } + const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void) { @@ -234,6 +239,13 @@ lib3270_set_unlock_delay // Set value. }, + { + "kybdlock", // Property name. + N_( "Keyboard lock status" ), // Property description. + lib3270_get_kybdlock, // Get value. + NULL // Set value. + }, + /* { "", // Property name. diff --git a/src/include/kybdc.h b/src/include/kybdc.h index e6e316e..4399caf 100644 --- a/src/include/kybdc.h +++ b/src/include/kybdc.h @@ -101,7 +101,7 @@ LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit); - LIB3270_INTERNAL int kybd_prime(H3270 *hSession); + LIB3270_INTERNAL int kybd_prime(H3270 *hSession); LIB3270_INTERNAL void kybd_scroll_lock(Boolean lock); LIB3270_INTERNAL void kybd_connect(H3270 *session, int connected, void *dunno); LIB3270_INTERNAL void kybd_in3270(H3270 *session, int in3270, void *dunno); diff --git a/src/include/lib3270.h b/src/include/lib3270.h index cee8a95..89323cd 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1032,6 +1032,14 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds); /** + * @brief Wait for keyboard unlock. + * @param seconds Number of seconds to wait. + * + * @return keyboard lock status or -1 on error. + */ + LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds); + + /** * "beep" to notify user. * * If available play a sound signal do alert user. diff --git a/src/include/statusc.h b/src/include/statusc.h index 55973c5..71c61ca 100644 --- a/src/include/statusc.h +++ b/src/include/statusc.h @@ -26,11 +26,7 @@ LIB3270_INTERNAL void status_oerr(H3270 *session, int error_type); LIB3270_INTERNAL void status_reset(H3270 *session); LIB3270_INTERNAL void status_twait(H3270 *session); - - - LIB3270_INTERNAL void status_changed(H3270 *session, LIB3270_MESSAGE id); - LIB3270_INTERNAL void set_status(H3270 *session, LIB3270_FLAG id, Boolean on); -- libgit2 0.21.2