Commit 92d61be158a899e79005528fba280151b66919c5

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

Updating IPC calls.

client/ipcclient.cbp 0 → 100644
... ... @@ -0,0 +1,91 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  2 +<CodeBlocks_project_file>
  3 + <FileVersion major="1" minor="6" />
  4 + <Project>
  5 + <Option title="IPC Client library for lib3270/pw3270" />
  6 + <Option makefile_is_custom="1" />
  7 + <Option pch_mode="2" />
  8 + <Option compiler="gcc" />
  9 + <Build>
  10 + <Target title="Debug">
  11 + <Option output=".bin/Debug/ipc3270" prefix_auto="1" extension_auto="1" />
  12 + <Option object_output=".obj/Debug/" />
  13 + <Option type="1" />
  14 + <Option compiler="gcc" />
  15 + <Compiler>
  16 + <Add option="-g" />
  17 + <Add option="-DDEBUG=1" />
  18 + </Compiler>
  19 + </Target>
  20 + <Target title="Release">
  21 + <Option output=".bin/Release/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" />
  22 + <Option object_output=".obj/Release/" />
  23 + <Option type="1" />
  24 + <Option compiler="gcc" />
  25 + <Compiler>
  26 + <Add option="-O2" />
  27 + <Add option="-std=c++11" />
  28 + <Add option="-DNDEBUG=1" />
  29 + </Compiler>
  30 + <Linker>
  31 + <Add option="-s" />
  32 + </Linker>
  33 + </Target>
  34 + </Build>
  35 + <Compiler>
  36 + <Add option="-Wall" />
  37 + <Add option="`pkg-config --clags lib3270`" />
  38 + <Add directory="../include" />
  39 + </Compiler>
  40 + <Linker>
  41 + <Add option="`pkg-config --libs lib3270`" />
  42 + </Linker>
  43 + <Unit filename="../common/src/include/lib3270/ipc.h" />
  44 + <Unit filename="../include/config.h.in" />
  45 + <Unit filename="src/core/abstract.cc" />
  46 + <Unit filename="src/core/constants.cc" />
  47 + <Unit filename="src/core/events.cc" />
  48 + <Unit filename="src/core/linux/request.cc" />
  49 + <Unit filename="src/core/session.cc" />
  50 + <Unit filename="src/core/windows/request.cc" />
  51 + <Unit filename="src/core/windows/resources.rc" />
  52 + <Unit filename="src/core/windows/resources.rc.in" />
  53 + <Unit filename="src/host/actions.cc" />
  54 + <Unit filename="src/host/host.cc" />
  55 + <Unit filename="src/host/init.cc" />
  56 + <Unit filename="src/host/pop.cc" />
  57 + <Unit filename="src/host/private.h" />
  58 + <Unit filename="src/host/push.cc" />
  59 + <Unit filename="src/host/states.cc" />
  60 + <Unit filename="src/host/stream.cc" />
  61 + <Unit filename="src/host/string.cc" />
  62 + <Unit filename="src/include/ipc-client-internals.h" />
  63 + <Unit filename="src/session/get.cc" />
  64 + <Unit filename="src/session/local/actions.cc" />
  65 + <Unit filename="src/session/local/events.cc" />
  66 + <Unit filename="src/session/local/get.cc" />
  67 + <Unit filename="src/session/local/init.cc" />
  68 + <Unit filename="src/session/local/private.h" />
  69 + <Unit filename="src/session/local/properties.cc" />
  70 + <Unit filename="src/session/local/set.cc" />
  71 + <Unit filename="src/session/local/tools.cc" />
  72 + <Unit filename="src/session/remote/actions.cc" />
  73 + <Unit filename="src/session/remote/get.cc" />
  74 + <Unit filename="src/session/remote/linux/request.cc" />
  75 + <Unit filename="src/session/remote/linux/session.cc" />
  76 + <Unit filename="src/session/remote/private.h" />
  77 + <Unit filename="src/session/remote/properties.cc" />
  78 + <Unit filename="src/session/remote/set.cc" />
  79 + <Unit filename="src/session/remote/tools.cc" />
  80 + <Unit filename="src/session/remote/windows/request.cc" />
  81 + <Unit filename="src/session/remote/windows/session.cc" />
  82 + <Unit filename="src/session/set.cc" />
  83 + <Unit filename="src/testprogram/testprogram.cc" />
  84 + <Extensions>
  85 + <code_completion />
  86 + <envvars />
  87 + <debugger />
  88 + <lib_finder disable_auto="1" />
  89 + </Extensions>
  90 + </Project>
  91 +</CodeBlocks_project_file>
... ...
client/lib3270++.cbp
... ... @@ -1,91 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2   -<CodeBlocks_project_file>
3   - <FileVersion major="1" minor="6" />
4   - <Project>
5   - <Option title="IPC Client library for lib3270/pw3270" />
6   - <Option makefile_is_custom="1" />
7   - <Option pch_mode="2" />
8   - <Option compiler="gcc" />
9   - <Build>
10   - <Target title="Debug">
11   - <Option output=".bin/Debug/ipc3270" prefix_auto="1" extension_auto="1" />
12   - <Option object_output=".obj/Debug/" />
13   - <Option type="1" />
14   - <Option compiler="gcc" />
15   - <Compiler>
16   - <Add option="-g" />
17   - <Add option="-DDEBUG=1" />
18   - </Compiler>
19   - </Target>
20   - <Target title="Release">
21   - <Option output=".bin/Release/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" />
22   - <Option object_output=".obj/Release/" />
23   - <Option type="1" />
24   - <Option compiler="gcc" />
25   - <Compiler>
26   - <Add option="-O2" />
27   - <Add option="-std=c++11" />
28   - <Add option="-DNDEBUG=1" />
29   - </Compiler>
30   - <Linker>
31   - <Add option="-s" />
32   - </Linker>
33   - </Target>
34   - </Build>
35   - <Compiler>
36   - <Add option="-Wall" />
37   - <Add option="`pkg-config --clags lib3270`" />
38   - <Add directory="../include" />
39   - </Compiler>
40   - <Linker>
41   - <Add option="`pkg-config --libs lib3270`" />
42   - </Linker>
43   - <Unit filename="../common/src/include/lib3270/ipc.h" />
44   - <Unit filename="../include/config.h.in" />
45   - <Unit filename="src/core/abstract.cc" />
46   - <Unit filename="src/core/constants.cc" />
47   - <Unit filename="src/core/events.cc" />
48   - <Unit filename="src/core/linux/request.cc" />
49   - <Unit filename="src/core/session.cc" />
50   - <Unit filename="src/core/windows/request.cc" />
51   - <Unit filename="src/core/windows/resources.rc" />
52   - <Unit filename="src/core/windows/resources.rc.in" />
53   - <Unit filename="src/host/actions.cc" />
54   - <Unit filename="src/host/host.cc" />
55   - <Unit filename="src/host/init.cc" />
56   - <Unit filename="src/host/pop.cc" />
57   - <Unit filename="src/host/private.h" />
58   - <Unit filename="src/host/push.cc" />
59   - <Unit filename="src/host/states.cc" />
60   - <Unit filename="src/host/stream.cc" />
61   - <Unit filename="src/host/string.cc" />
62   - <Unit filename="src/include/ipc-client-internals.h" />
63   - <Unit filename="src/session/get.cc" />
64   - <Unit filename="src/session/local/actions.cc" />
65   - <Unit filename="src/session/local/events.cc" />
66   - <Unit filename="src/session/local/get.cc" />
67   - <Unit filename="src/session/local/init.cc" />
68   - <Unit filename="src/session/local/private.h" />
69   - <Unit filename="src/session/local/properties.cc" />
70   - <Unit filename="src/session/local/set.cc" />
71   - <Unit filename="src/session/local/tools.cc" />
72   - <Unit filename="src/session/remote/actions.cc" />
73   - <Unit filename="src/session/remote/get.cc" />
74   - <Unit filename="src/session/remote/linux/request.cc" />
75   - <Unit filename="src/session/remote/linux/session.cc" />
76   - <Unit filename="src/session/remote/private.h" />
77   - <Unit filename="src/session/remote/properties.cc" />
78   - <Unit filename="src/session/remote/set.cc" />
79   - <Unit filename="src/session/remote/tools.cc" />
80   - <Unit filename="src/session/remote/windows/request.cc" />
81   - <Unit filename="src/session/remote/windows/session.cc" />
82   - <Unit filename="src/session/set.cc" />
83   - <Unit filename="src/testprogram/testprogram.cc" />
84   - <Extensions>
85   - <code_completion />
86   - <envvars />
87   - <debugger />
88   - <lib_finder disable_auto="1" />
89   - </Extensions>
90   - </Project>
91   -</CodeBlocks_project_file>
client/src/core/session.cc
... ... @@ -71,16 +71,19 @@
71 71 pakey( ((unsigned short) key) + 1);
72 72 }
73 73  
74   - LIB3270_KEYBOARD_LOCK_STATE Session::input(const char *text, const char control_char) {
  74 + LIB3270_KEYBOARD_LOCK_STATE Session::input(const std::string &str, const char control_char) {
75 75  
76   - size_t sz;
77 76 LIB3270_KEYBOARD_LOCK_STATE rc = (LIB3270_KEYBOARD_LOCK_STATE) 0;
78 77  
  78 + size_t sz;
  79 + const char * text = str.c_str();
  80 +
79 81 for(const char * ptr = strchr(text,control_char); ptr; ptr = strchr(text,control_char)) {
80 82  
81   - // Wait for unlock, ignore errors.
82 83 sz = (size_t) (ptr-text);
83 84 if(sz) {
  85 +
  86 + // Wait for unlock, insert text.
84 87 if( (rc = waitForKeyboardUnlock()) != 0) {
85 88 return rc;
86 89 }
... ... @@ -356,9 +359,10 @@
356 359  
357 360 sz = strlen(text);
358 361 if(sz) {
359   - rc = waitForKeyboardUnlock();
360   - if(!rc)
361   - push(text,sz);
  362 + if( (rc = waitForKeyboardUnlock()) != 0) {
  363 + return rc;
  364 + }
  365 + push(text,sz);
362 366 }
363 367  
364 368 return rc;
... ...
client/src/host/actions.cc
... ... @@ -50,12 +50,12 @@ TN3270::Host &amp; TN3270::Host::disconnect() {
50 50 return *this;
51 51 }
52 52  
53   -TN3270::Host & TN3270::Host::waitForReady(time_t timeout) {
  53 +TN3270::Host & TN3270::Host::waitForReady() {
54 54 this->session->waitForReady(timeout);
55 55 return *this;
56 56 }
57 57  
58   -TN3270::Host & TN3270::Host::waitForKeyboardUnlock(time_t timeout) {
  58 +TN3270::Host & TN3270::Host::waitForKeyboardUnlock() {
59 59 this->session->waitForKeyboardUnlock(timeout);
60 60 return *this;
61 61 }
... ...
client/src/host/push.cc
... ... @@ -70,8 +70,7 @@ TN3270::Host &amp; TN3270::Host::push(const std::string &amp;text) {
70 70 return *this;
71 71 }
72 72  
73   -TN3270::Host & TN3270::Host::input(const char *text, const char control_char) {
74   - session->input(text,control_char);
75   - return *this;
  73 +LIB3270_KEYBOARD_LOCK_STATE TN3270::Host::input(const char *text, int length, const char control_char) {
  74 + return session->input(string(text,(size_t) length),control_char);
76 75 }
77 76  
... ...
client/src/session/local/get.cc
... ... @@ -103,7 +103,7 @@
103 103  
104 104 }
105 105  
106   - LIB3270_KEYBOARD_LOCK_STATE Local::Session::getKeyboardUnlock() const {
  106 + LIB3270_KEYBOARD_LOCK_STATE Local::Session::getKeyboardLockState() const {
107 107 std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync);
108 108 return lib3270_get_keyboard_lock_state(hSession);
109 109 }
... ...
client/src/session/local/private.h
... ... @@ -121,7 +121,7 @@
121 121 std::string getVersion() const override;
122 122 std::string getRevision() const override;
123 123 std::string getLUName() const override;
124   - LIB3270_KEYBOARD_LOCK_STATE getKeyboardUnlock() const override;
  124 + LIB3270_KEYBOARD_LOCK_STATE getKeyboardLockState() const override;
125 125  
126 126 std::string getHostURL() const override;
127 127 void setHostURL(const char *url) override;
... ...
client/src/session/remote/get.cc
... ... @@ -109,7 +109,7 @@
109 109  
110 110 }
111 111  
112   - LIB3270_KEYBOARD_LOCK_STATE IPC::Session::getKeyboardUnlock() const {
  112 + LIB3270_KEYBOARD_LOCK_STATE IPC::Session::getKeyboardLockState() const {
113 113 unsigned int value;
114 114 getProperty("kybdlock",value);
115 115 return (LIB3270_KEYBOARD_LOCK_STATE) value;
... ...
client/src/session/remote/private.h
... ... @@ -119,7 +119,7 @@
119 119 std::string getVersion() const override;
120 120 std::string getRevision() const override;
121 121 std::string getLUName() const override;
122   - LIB3270_KEYBOARD_LOCK_STATE getKeyboardUnlock() const override;
  122 + LIB3270_KEYBOARD_LOCK_STATE getKeyboardLockState() const override;
123 123  
124 124 std::string getHostURL() const override;
125 125 void setHostURL(const char *url) override;
... ...
client/src/testprogram/testprogram.cc
... ... @@ -99,7 +99,7 @@
99 99 host.connect(nullptr);
100 100  
101 101 cout
102   - << "Wait for unlock returns " << host.getKeyboardUnlock() << std::endl
  102 + << "Wait for unlock returns " << host.getKeyboardLockState() << std::endl
103 103 << "Connection state is " << toCharString(host.getConnectionState()) << std::endl
104 104 << "Program message is " << toCharString(host.getProgramMessage()) << std::endl
105 105 << "Luname is " << host.getLUName() << std::endl
... ...
common/src/include/lib3270/ipc.h
... ... @@ -284,7 +284,7 @@
284 284 /**
285 285 * @brief Input string parsing control char.
286 286 */
287   - LIB3270_KEYBOARD_LOCK_STATE input(const char *text, const char control_char);
  287 + LIB3270_KEYBOARD_LOCK_STATE input(const std::string &str, const char control_char = '@');
288 288  
289 289 // Properties.
290 290 virtual void getProperty(const char *name, int &value) const = 0;
... ... @@ -297,7 +297,7 @@
297 297 virtual std::string getVersion() const = 0;
298 298 virtual std::string getRevision() const = 0;
299 299 virtual std::string getLUName() const = 0;
300   - virtual LIB3270_KEYBOARD_LOCK_STATE getKeyboardUnlock() const = 0;
  300 + virtual LIB3270_KEYBOARD_LOCK_STATE getKeyboardLockState() const = 0;
301 301  
302 302 virtual std::string getHostURL() const = 0;
303 303 virtual void setHostURL(const char *url) = 0;
... ... @@ -406,7 +406,7 @@
406 406 /**
407 407 * @brief Input string parsing control char.
408 408 */
409   - Host & input(const char *text, const char control_char);
  409 + LIB3270_KEYBOARD_LOCK_STATE input(const char *text, int length = -1, const char control_char = '@');
410 410  
411 411 Host & push(int baddr, const std::string &text);
412 412 Host & push(int row, int col, const std::string &text);
... ... @@ -441,8 +441,8 @@
441 441 // Actions
442 442 Host & connect(const char *url = nullptr);
443 443 Host & disconnect();
444   - Host & waitForReady(time_t timeout = DEFAULT_TIMEOUT);
445   - Host & waitForKeyboardUnlock(time_t timeout = DEFAULT_TIMEOUT);
  444 + Host & waitForReady();
  445 + Host & waitForKeyboardUnlock();
446 446  
447 447 /// @brief Execute action by name.
448 448 inline Host & action(const char *action_name) {
... ... @@ -513,8 +513,8 @@
513 513 return session->getLUName();
514 514 }
515 515  
516   - inline LIB3270_KEYBOARD_LOCK_STATE getKeyboardUnlock() const {
517   - return session->getKeyboardUnlock();
  516 + inline LIB3270_KEYBOARD_LOCK_STATE getKeyboardLockState() const {
  517 + return session->getKeyboardLockState();
518 518 }
519 519  
520 520 // Actions
... ...