Commit 63483dc70f43cf246b1c06d69108a48065bbaf62

Authored by Perry Werneck
1 parent 2938cc60

Adding APIs to get keyboard lock state.

sdk/lib3270-delayed.pc.in
... ... @@ -13,5 +13,5 @@ Description: @PACKAGE_DESCRIPTION@
13 13 Version: @PACKAGE_VERSION@
14 14 Libs: -L\@libdir@ -l@LIB3270_NAME@.delayed
15 15 Libs.private: @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@
16   -Cflags: -I@includedir@ -DLIB3270_NAME=@LIB3270_NAME@
  16 +Cflags: -DLIB3270_NAME=@LIB3270_NAME@
17 17  
... ...
sdk/lib3270-static.pc.in
... ... @@ -11,5 +11,5 @@ Name: @PACKAGE_NAME@-static
11 11 Description: @PACKAGE_DESCRIPTION@ (static library)
12 12 Version: @PACKAGE_VERSION@
13 13 Libs: -L\@libdir@ -l@LIB3270_NAME@.static @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@
14   -Cflags: -I@includedir@
  14 +Cflags: -DLIB3270_NAME=@LIB3270_NAME@
15 15  
... ...
sdk/lib3270.pc.in
... ... @@ -13,5 +13,5 @@ Description: @PACKAGE_DESCRIPTION@
13 13 Version: @PACKAGE_VERSION@
14 14 Libs: -L\@libdir@ -l@LIB3270_NAME@
15 15 Libs.private: @LIBS@ @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ @LDAP_LIBS@ @LIBCURL_LIBS@
16   -Cflags: -I@includedir@
  16 +Cflags: -DLIB3270_NAME=@LIB3270_NAME@
17 17  
... ...
src/core/ctlr.c
... ... @@ -116,9 +116,8 @@ static const unsigned char code_table[64] =
116 116 } \
117 117 }
118 118  
119   -
120   -/*
121   - * Initialize the emulated 3270 hardware.
  119 +/**
  120 + * @brief Initialize the emulated 3270 hardware.
122 121 */
123 122 void ctlr_init(H3270 *session, unsigned GNUC_UNUSED(cmask))
124 123 {
... ... @@ -127,8 +126,9 @@ void ctlr_init(H3270 *session, unsigned GNUC_UNUSED(cmask))
127 126 lib3270_register_schange(session,LIB3270_STATE_CONNECT, ctlr_connect, 0);
128 127 lib3270_register_schange(session,LIB3270_STATE_3270_MODE, ctlr_connect, 0);
129 128 }
130   -/*
131   - * Reinitialize the emulated 3270 hardware.
  129 +
  130 +/**
  131 + * @brief Reinitialize the emulated 3270 hardware.
132 132 */
133 133 void ctlr_reinit(H3270 *session, unsigned cmask)
134 134 {
... ... @@ -153,7 +153,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
153 153 }
154 154  
155 155 /**
156   - * Parse the model number.
  156 + * @brief Parse the model number.
157 157 *
158 158 * @param session Session Handle.
159 159 * @param m Model number.
... ... @@ -231,7 +231,7 @@ static int parse_model_number(H3270 *session, const char *m)
231 231 }
232 232  
233 233 /**
234   - * Get current 3270 model.
  234 + * @brief Get current 3270 model.
235 235 *
236 236 * @param hSession selected 3270 session.
237 237 * @return Current model number.
... ... @@ -366,7 +366,7 @@ static void set_formatted(H3270 *hSession, int state)
366 366 }
367 367  
368 368 /**
369   - * Update the formatted screen flag.
  369 + * @brief Update the formatted screen flag.
370 370 *
371 371 * A formatted screen is a screen that has at least one field somewhere on it.
372 372 *
... ... @@ -787,8 +787,8 @@ enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
787 787 }
788 788 }
789 789  
790   -/*
791   - * Functions to insert SA attributes into the inbound data stream.
  790 +/**
  791 + * @brief Functions to insert SA attributes into the inbound data stream.
792 792 */
793 793 static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, unsigned char *currentp, Boolean *anyp)
794 794 {
... ... @@ -805,11 +805,10 @@ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value,
805 805 *anyp = False;
806 806 }
807 807  
808   -/*
809   - * Translate an internal character set number to a 3270DS characte set number.
  808 +/**
  809 + * @brief Translate an internal character set number to a 3270DS characte set number.
810 810 */
811   -static unsigned char
812   -host_cs(unsigned char cs)
  811 +static unsigned char host_cs(unsigned char cs)
813 812 {
814 813 switch (cs & CS_MASK) {
815 814 case CS_APL:
... ... @@ -851,7 +850,7 @@ static void insert_sa(H3270 *hSession, int baddr, unsigned char *current_fgp, un
851 850  
852 851  
853 852 /**
854   - * Process a 3270 Read-Modified command and transmit the data back to the host.
  853 + * @brief Process a 3270 Read-Modified command and transmit the data back to the host.
855 854 */
856 855 void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
857 856 {
... ...
src/core/iocalls.c
... ... @@ -35,6 +35,7 @@
35 35 #include "xioc.h"
36 36 #include "telnetc.h"
37 37 #include "utilc.h"
  38 +#include "kybdc.h"
38 39  
39 40 #if defined(_WIN32)
40 41 #include <ws2tcpip.h>
... ... @@ -477,6 +478,33 @@ LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds)
477 478 return errno = ENOTSUP;
478 479 }
479 480  
  481 +LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds)
  482 +{
  483 + time_t end = time(0)+seconds;
  484 +
  485 + FAIL_IF_NOT_ONLINE(hSession);
  486 +
  487 + event_dispatcher(hSession,0);
  488 +
  489 + do
  490 + {
  491 + if(!lib3270_connected(hSession))
  492 + {
  493 + errno = ENOTCONN;
  494 + return -1;
  495 + }
  496 +
  497 + if(KYBDLOCK_IS_OERR(hSession))
  498 + break;
  499 +
  500 + event_dispatcher(hSession,1);
  501 +
  502 + }
  503 + while(hSession->kybdlock && time(0) < end);
  504 +
  505 + return hSession->kybdlock;
  506 +}
  507 +
480 508 LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
481 509 {
482 510 time_t end = time(0)+seconds;
... ... @@ -484,6 +512,11 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
484 512 FAIL_IF_NOT_ONLINE(hSession);
485 513  
486 514 event_dispatcher(hSession,0);
  515 +
  516 + // Keyboard is locked by operator error, fails!
  517 + if(hSession->kybdlock && KYBDLOCK_IS_OERR(hSession))
  518 + return -1;
  519 +
487 520 do
488 521 {
489 522 if(!lib3270_lock_status(hSession))
... ...
src/core/keyboard/kybd.c
... ... @@ -478,6 +478,7 @@ static void key_AID(H3270 *hSession, unsigned char aid_code)
478 478 {
479 479 if (hSession->kybdlock & KL_OIA_MINUS)
480 480 return;
  481 +
481 482 if (aid_code != AID_ENTER && aid_code != AID_CLEAR)
482 483 {
483 484 status_changed(hSession,LIB3270_MESSAGE_MINUS);
... ... @@ -499,6 +500,7 @@ static void key_AID(H3270 *hSession, unsigned char aid_code)
499 500 lib3270_set_toggle(hSession,LIB3270_TOGGLE_INSERT,0);
500 501 kybdlock_set(hSession,KL_OIA_TWAIT | KL_OIA_LOCKED);
501 502 }
  503 +
502 504 hSession->aid = aid_code;
503 505 ctlr_read_modified(hSession, hSession->aid, False);
504 506 ticking_start(hSession,False);
... ...
src/core/properties.c
... ... @@ -56,6 +56,11 @@
56 56 return hSession->starting != 0;
57 57 }
58 58  
  59 + unsigned int lib3270_get_kybdlock(H3270 *hSession)
  60 + {
  61 + return hSession->kybdlock;
  62 + }
  63 +
59 64 const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void)
60 65 {
61 66  
... ... @@ -234,6 +239,13 @@
234 239 lib3270_set_unlock_delay // Set value.
235 240 },
236 241  
  242 + {
  243 + "kybdlock", // Property name.
  244 + N_( "Keyboard lock status" ), // Property description.
  245 + lib3270_get_kybdlock, // Get value.
  246 + NULL // Set value.
  247 + },
  248 +
237 249 /*
238 250 {
239 251 "", // Property name.
... ...
src/include/kybdc.h
... ... @@ -101,7 +101,7 @@
101 101  
102 102  
103 103 LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit);
104   - LIB3270_INTERNAL int kybd_prime(H3270 *hSession);
  104 + LIB3270_INTERNAL int kybd_prime(H3270 *hSession);
105 105 LIB3270_INTERNAL void kybd_scroll_lock(Boolean lock);
106 106 LIB3270_INTERNAL void kybd_connect(H3270 *session, int connected, void *dunno);
107 107 LIB3270_INTERNAL void kybd_in3270(H3270 *session, int in3270, void *dunno);
... ...
src/include/lib3270.h
... ... @@ -1032,6 +1032,14 @@
1032 1032 LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds);
1033 1033  
1034 1034 /**
  1035 + * @brief Wait for keyboard unlock.
  1036 + * @param seconds Number of seconds to wait.
  1037 + *
  1038 + * @return keyboard lock status or -1 on error.
  1039 + */
  1040 + LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds);
  1041 +
  1042 + /**
1035 1043 * "beep" to notify user.
1036 1044 *
1037 1045 * If available play a sound signal do alert user.
... ...
src/include/statusc.h
... ... @@ -26,11 +26,7 @@ LIB3270_INTERNAL void status_oerr(H3270 *session, int error_type);
26 26 LIB3270_INTERNAL void status_reset(H3270 *session);
27 27 LIB3270_INTERNAL void status_twait(H3270 *session);
28 28  
29   -
30   -
31   -
32 29 LIB3270_INTERNAL void status_changed(H3270 *session, LIB3270_MESSAGE id);
33   -
34 30 LIB3270_INTERNAL void set_status(H3270 *session, LIB3270_FLAG id, Boolean on);
35 31  
36 32  
... ...