Commit 9a49cd0dac4815177586fcf2d04cae1f80c94d9c

Authored by Perry Werneck
1 parent 428019a9
Exists in master and in 1 other branch develop

Debuggint IPC calls, small adjustments for performance.

@@ -323,7 +323,7 @@ dnl --------------------------------------------------------------------------- @@ -323,7 +323,7 @@ dnl ---------------------------------------------------------------------------
323 323
324 AC_CONFIG_FILES(Makefile) 324 AC_CONFIG_FILES(Makefile)
325 AC_CONFIG_FILES(locale/Makefile) 325 AC_CONFIG_FILES(locale/Makefile)
326 -AC_CONFIG_FILES(sdk/libhllapi.pc) 326 +AC_CONFIG_FILES(sdk/hllapi.pc)
327 327
328 dnl --------------------------------------------------------------------------- 328 dnl ---------------------------------------------------------------------------
329 dnl Output the generated config.status script. 329 dnl Output the generated config.status script.
sdk/hllapi.pc.in 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +prefix=@prefix@
  2 +exec_prefix=@exec_prefix@
  3 +libdir=@libdir@
  4 +includedir=@includedir@
  5 +
  6 +version_major=@PACKAGE_MAJOR_VERSION@
  7 +version_minor=@PACKAGE_MINOR_VERSION@
  8 +
  9 +Name: @PACKAGE_NAME@
  10 +Description: @PACKAGE_DESCRIPTION@
  11 +Version: @PACKAGE_VERSION@
  12 +Requires: ipc3270 lib3270
  13 +Libs: -lhllapi
  14 +Libs.private: @LIBS@ @INTL_LIBS@ @IPC3270_LIBS@
  15 +Cflags:
  16 +
sdk/libhllapi.pc.in
@@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
1 -prefix=@prefix@  
2 -exec_prefix=@exec_prefix@  
3 -libdir=@libdir@  
4 -includedir=@includedir@  
5 -  
6 -version_major=@PACKAGE_MAJOR_VERSION@  
7 -version_minor=@PACKAGE_MINOR_VERSION@  
8 -  
9 -Name: @PACKAGE_NAME@  
10 -Description: @PACKAGE_DESCRIPTION@  
11 -Version: @PACKAGE_VERSION@  
12 -Requires: libipc3270 lib3270  
13 -Libs: -lhllapi  
14 -Libs.private: @LIBS@ @INTL_LIBS@ @IPC3270_LIBS@  
15 -Cflags:  
16 -  
src/core/calls.cc
@@ -88,6 +88,8 @@ @@ -88,6 +88,8 @@
88 88
89 HLLAPI_API_CALL hllapi_get_state(void) { 89 HLLAPI_API_CALL hllapi_get_state(void) {
90 90
  91 + debug("",__FUNCTION__);
  92 +
91 try { 93 try {
92 94
93 switch(hllapi_get_message_id()) { 95 switch(hllapi_get_message_id()) {
@@ -144,6 +146,7 @@ @@ -144,6 +146,7 @@
144 146
145 HLLAPI_API_CALL hllapi_disconnect(void) { 147 HLLAPI_API_CALL hllapi_disconnect(void) {
146 148
  149 + trace("%s",__FUNCTION__);
147 try { 150 try {
148 151
149 getSession().disconnect(); 152 getSession().disconnect();
@@ -222,12 +225,7 @@ @@ -222,12 +225,7 @@
222 225
223 try { 226 try {
224 227
225 - TN3270::Host &host = getSession();  
226 -  
227 - if(!host.isConnected())  
228 - return HLLAPI_STATUS_DISCONNECTED;  
229 -  
230 - host.wait(seconds); 228 + getSession().wait(seconds);
231 229
232 return hllapi_get_state(); 230 return hllapi_get_state();
233 231
@@ -257,6 +255,24 @@ @@ -257,6 +255,24 @@
257 255
258 } 256 }
259 257
  258 + HLLAPI_API_CALL hllapi_wait_for_text_at(WORD row, WORD col, LPSTR text) {
  259 +
  260 + try {
  261 +
  262 + getSession().wait((unsigned short) row, (unsigned short) col, (const char *) text);
  263 +
  264 + return HLLAPI_STATUS_SUCCESS;
  265 +
  266 + } catch(std::exception &e) {
  267 +
  268 + hllapi_lasterror = e.what();
  269 +
  270 + }
  271 +
  272 + return HLLAPI_STATUS_SYSTEM_ERROR;
  273 +
  274 + }
  275 +
260 HLLAPI_API_CALL hllapi_cmp_text_at_address(WORD addr, LPSTR text) { 276 HLLAPI_API_CALL hllapi_cmp_text_at_address(WORD addr, LPSTR text) {
261 277
262 try { 278 try {
src/core/controller.cc
@@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
32 /*--[ Globals ]--------------------------------------------------------------------------------------*/ 32 /*--[ Globals ]--------------------------------------------------------------------------------------*/
33 33
34 static TN3270::Host * hllapi_host = nullptr; 34 static TN3270::Host * hllapi_host = nullptr;
35 - static time_t hllapi_timeout = 120;  
36 std::string hllapi_lasterror = ""; 35 std::string hllapi_lasterror = "";
37 36
38 /*--[ Implement ]------------------------------------------------------------------------------------*/ 37 /*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -69,7 +68,7 @@ @@ -69,7 +68,7 @@
69 hllapi_host = new TN3270::Host(*id ? id : nullptr, "UTF-8"); 68 hllapi_host = new TN3270::Host(*id ? id : nullptr, "UTF-8");
70 #endif // _WIN32 69 #endif // _WIN32
71 70
72 - hllapi_host->setTimeout(hllapi_timeout); 71 + hllapi_host->setTimeout(120);
73 72
74 } 73 }
75 catch(std::exception &e) 74 catch(std::exception &e)
@@ -78,6 +77,7 @@ @@ -78,6 +77,7 @@
78 return HLLAPI_STATUS_SYSTEM_ERROR; 77 return HLLAPI_STATUS_SYSTEM_ERROR;
79 } 78 }
80 79
  80 + debug("hllapi_host=%p",hllapi_host);
81 return HLLAPI_STATUS_SUCCESS; 81 return HLLAPI_STATUS_SUCCESS;
82 82
83 } 83 }
@@ -110,6 +110,7 @@ @@ -110,6 +110,7 @@
110 throw runtime_error( _("Not initialized") ); 110 throw runtime_error( _("Not initialized") );
111 } 111 }
112 112
  113 + trace("%s()=%p",__FUNCTION__,hllapi_host);
113 return *hllapi_host; 114 return *hllapi_host;
114 115
115 } 116 }
src/core/hllapi.cc
@@ -453,6 +453,11 @@ HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) @@ -453,6 +453,11 @@ HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value)
453 // UNLOCKDELAY 453 // UNLOCKDELAY
454 hllapi_set_unlock_delay(value); 454 hllapi_set_unlock_delay(value);
455 455
  456 + } else if(!strncasecmp(param,"TIMEOUT",len)) {
  457 +
  458 + // UNLOCKDELAY
  459 + hllapi_set_timeout(value);
  460 +
456 } else { 461 } else {
457 462
458 return HLLAPI_STATUS_BAD_PARAMETER; 463 return HLLAPI_STATUS_BAD_PARAMETER;
src/core/keyboard.cc
@@ -103,3 +103,19 @@ static DWORD set(std::function<void(TN3270::Host &)> worker) noexcept { @@ -103,3 +103,19 @@ static DWORD set(std::function<void(TN3270::Host &)> worker) noexcept {
103 return HLLAPI_STATUS_SYSTEM_ERROR; 103 return HLLAPI_STATUS_SYSTEM_ERROR;
104 } 104 }
105 105
  106 + HLLAPI_API_CALL hllapi_set_timeout(WORD seconds) {
  107 +
  108 + try {
  109 +
  110 + getSession().setTimeout((time_t) seconds);
  111 + return HLLAPI_STATUS_SUCCESS;
  112 +
  113 + } catch(std::exception &e) {
  114 +
  115 + hllapi_lasterror = e.what();
  116 +
  117 + }
  118 +
  119 + return HLLAPI_STATUS_SYSTEM_ERROR;
  120 +
  121 + }
src/include/lib3270/hllapi.h
@@ -137,7 +137,7 @@ @@ -137,7 +137,7 @@
137 137
138 #else 138 #else
139 139
140 - #include <cstdint> 140 + #include <stdint.h>
141 141
142 // From wtypesbase.h 142 // From wtypesbase.h
143 typedef uint8_t BYTE; 143 typedef uint8_t BYTE;
@@ -324,6 +324,7 @@ @@ -324,6 +324,7 @@
324 324
325 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds); 325 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
326 HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds); 326 HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds);
  327 + HLLAPI_API_CALL hllapi_wait_for_text_at(WORD row, WORD col, LPSTR text);
327 HLLAPI_API_CALL hllapi_wait(WORD seconds); 328 HLLAPI_API_CALL hllapi_wait(WORD seconds);
328 HLLAPI_API_CALL hllapi_pfkey(WORD key); 329 HLLAPI_API_CALL hllapi_pfkey(WORD key);
329 HLLAPI_API_CALL hllapi_pakey(WORD key); 330 HLLAPI_API_CALL hllapi_pakey(WORD key);
@@ -346,6 +347,7 @@ @@ -346,6 +347,7 @@
346 HLLAPI_API_CSTR hllapi_get_last_error(); 347 HLLAPI_API_CSTR hllapi_get_last_error();
347 348
348 HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms); 349 HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms);
  350 + HLLAPI_API_CALL hllapi_set_timeout(WORD seconds);
349 351
350 HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos); 352 HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos);
351 HLLAPI_API_CALL hllapi_set_cursor_position(WORD row, WORD col); 353 HLLAPI_API_CALL hllapi_set_cursor_position(WORD row, WORD col);