Commit 688efc9c6240e04630743e0eaa4c6ce09d44b139
1 parent
28ac456c
Exists in
master
and in
1 other branch
Updating IPC components.
Showing
6 changed files
with
65 additions
and
79 deletions
Show diff stats
client/src/core/host.cc
... | ... | @@ -211,20 +211,11 @@ |
211 | 211 | throw std::system_error(ENOTSUP, std::system_category()); |
212 | 212 | } |
213 | 213 | |
214 | - void Host::input(const char *text, size_t sz) { | |
215 | - | |
216 | -#ifdef DEBUG | |
217 | - { | |
218 | - string str = string(text,sz); | |
219 | - clog << __FUNCTION__ << "(\"" << str << "\")" << endl; | |
220 | - } | |
221 | -#endif // DEBUG | |
222 | - | |
214 | + Host & Host::input(const char *text, size_t sz) { | |
223 | 215 | this->session->input(text, sz); |
224 | - | |
216 | + return *this; | |
225 | 217 | } |
226 | 218 | |
227 | - | |
228 | 219 | Host & Host::input(const char *text, const char control_char) { |
229 | 220 | |
230 | 221 | for(const char * ptr = strchr(text,control_char); ptr; ptr = strchr(text,control_char)) { | ... | ... |
client/src/core/session.cc
... | ... | @@ -74,6 +74,24 @@ |
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | + Session & Session::push(const PFKey key) { | |
78 | + return pfkey( ((unsigned short) key) + 1); | |
79 | + } | |
80 | + | |
81 | + Session & Session::push(const PAKey key) { | |
82 | + return pakey( ((unsigned short) key) + 1); | |
83 | + } | |
84 | + | |
85 | + Session & Session::push(int row, int col, const std::string &text) { | |
86 | + return push(row,col,text.c_str(),text.size()); | |
87 | + } | |
88 | + | |
89 | + Session & Session::push(int baddr, const std::string &text) { | |
90 | + return push(baddr,text.c_str(),text.size()); | |
91 | + } | |
92 | + | |
93 | + | |
94 | + | |
77 | 95 | } |
78 | 96 | |
79 | 97 | ... | ... |
client/src/include/ipc-client-internals.h
... | ... | @@ -204,10 +204,9 @@ |
204 | 204 | /// @brief Set field at current posicion, jumps to next writable field. |
205 | 205 | TN3270::Session & push(const char *text) override; |
206 | 206 | |
207 | - TN3270::Session & push(int baddr, const std::string &text) override; | |
208 | - TN3270::Session & push(int row, int col, const std::string &text) override; | |
209 | - TN3270::Session & push(const PFKey key) override; | |
210 | - TN3270::Session & push(const PAKey key) override; | |
207 | + TN3270::Session & push(int baddr, const char *text, int length = -1) override; | |
208 | + TN3270::Session & push(int row, int col, const char *text, int length = -1) override; | |
209 | + | |
211 | 210 | TN3270::Session & push(const Action action) override; |
212 | 211 | |
213 | 212 | // Get contents. |
... | ... | @@ -374,10 +373,9 @@ |
374 | 373 | /// @brief Set field at current posicion, jumps to next writable field. |
375 | 374 | TN3270::Session & push(const char *text) override; |
376 | 375 | |
377 | - TN3270::Session & push(int baddr, const std::string &text) override; | |
378 | - TN3270::Session & push(int row, int col, const std::string &text) override; | |
379 | - TN3270::Session & push(const PFKey key) override; | |
380 | - TN3270::Session & push(const PAKey key) override; | |
376 | + TN3270::Session & push(int baddr, const char *text, int length = -1) override; | |
377 | + TN3270::Session & push(int row, int col, const char *text, int length = -1) override; | |
378 | + | |
381 | 379 | TN3270::Session & push(const Action action) override; |
382 | 380 | |
383 | 381 | // Get contents. | ... | ... |
client/src/session/local/session.cc
... | ... | @@ -252,10 +252,10 @@ |
252 | 252 | return *this; |
253 | 253 | } |
254 | 254 | |
255 | - TN3270::Session & Local::Session::push(int baddr, const std::string &text) { | |
255 | + TN3270::Session & Local::Session::push(int baddr, const char * text, int length) { | |
256 | 256 | std::lock_guard<std::mutex> lock(sync); |
257 | 257 | |
258 | - string converted = convertToHost(text.c_str(),text.size()); | |
258 | + string converted = convertToHost(text, length); | |
259 | 259 | |
260 | 260 | if(lib3270_set_string_at_address(this->hSession,baddr,(unsigned char *) converted.c_str(),converted.length()) < 0) { |
261 | 261 | throw std::system_error(errno, std::system_category()); |
... | ... | @@ -264,10 +264,10 @@ |
264 | 264 | return *this; |
265 | 265 | } |
266 | 266 | |
267 | - TN3270::Session & Local::Session::push(int row, int col, const std::string &text) { | |
267 | + TN3270::Session & Local::Session::push(int row, int col, const char *text, int length) { | |
268 | 268 | std::lock_guard<std::mutex> lock(sync); |
269 | 269 | |
270 | - string converted = convertToHost(text.c_str(),text.size()); | |
270 | + string converted = convertToHost(text,length); | |
271 | 271 | |
272 | 272 | if(lib3270_set_string_at(this->hSession,row,col,(unsigned char *) converted.c_str())) { |
273 | 273 | throw std::system_error(errno, std::system_category()); |
... | ... | @@ -276,18 +276,6 @@ |
276 | 276 | return *this; |
277 | 277 | } |
278 | 278 | |
279 | - TN3270::Session & Local::Session::push(const PFKey key) { | |
280 | - std::lock_guard<std::mutex> lock(sync); | |
281 | - lib3270_pfkey(hSession,(int) key); | |
282 | - return *this; | |
283 | - } | |
284 | - | |
285 | - TN3270::Session & Local::Session::push(const PAKey key) { | |
286 | - std::lock_guard<std::mutex> lock(sync); | |
287 | - lib3270_pakey(hSession,(int) key); | |
288 | - return *this; | |
289 | - } | |
290 | - | |
291 | 279 | TN3270::Session & Local::Session::push(const Action action) { |
292 | 280 | |
293 | 281 | typedef int (*ActionCallback)(H3270 *); | ... | ... |
client/src/session/remote/session.cc
... | ... | @@ -127,6 +127,8 @@ |
127 | 127 | |
128 | 128 | TN3270::Session & IPC::Session::input(const char *text, size_t length) { |
129 | 129 | |
130 | + throw std::system_error(ENOTSUP, std::system_category()); | |
131 | + | |
130 | 132 | return *this; |
131 | 133 | } |
132 | 134 | |
... | ... | @@ -148,13 +150,17 @@ |
148 | 150 | |
149 | 151 | } |
150 | 152 | |
151 | - TN3270::Session & IPC::Session::push(int baddr, const std::string &text) { | |
153 | + TN3270::Session & IPC::Session::push(int baddr, const char *text, int length) { | |
152 | 154 | |
153 | 155 | int rc; |
154 | 156 | |
157 | + if(length < 0) | |
158 | + length = strlen(text); | |
159 | + | |
155 | 160 | Request(*this,"setStringAtAddress") |
156 | 161 | .push((uint32_t) baddr) |
157 | - .push(text.c_str()) | |
162 | + .push(text) | |
163 | + .push((uint32_t) length) | |
158 | 164 | .call() |
159 | 165 | .pop(rc); |
160 | 166 | |
... | ... | @@ -166,48 +172,18 @@ |
166 | 172 | |
167 | 173 | } |
168 | 174 | |
169 | - TN3270::Session & IPC::Session::push(int row, int col, const std::string &text) { | |
175 | + TN3270::Session & IPC::Session::push(int row, int col, const char *text, int length) { | |
170 | 176 | |
171 | 177 | int32_t rc; |
172 | 178 | |
179 | + if(length < 0) | |
180 | + length = strlen(text); | |
181 | + | |
173 | 182 | Request(*this,"setStringAt") |
174 | 183 | .push((uint32_t) row) |
175 | 184 | .push((uint32_t) col) |
176 | - .push(text.c_str()) | |
177 | - .call() | |
178 | - .pop(rc); | |
179 | - | |
180 | - if(rc) { | |
181 | - throw std::system_error((int) rc, std::system_category()); | |
182 | - } | |
183 | - | |
184 | - return *this; | |
185 | - | |
186 | - } | |
187 | - | |
188 | - TN3270::Session & IPC::Session::push(const PFKey key) { | |
189 | - | |
190 | - int32_t rc; | |
191 | - | |
192 | - Request(*this,"pfkey") | |
193 | - .push((uint32_t) key) | |
194 | - .call() | |
195 | - .pop(rc); | |
196 | - | |
197 | - if(rc) { | |
198 | - throw std::system_error((int) rc, std::system_category()); | |
199 | - } | |
200 | - | |
201 | - return *this; | |
202 | - | |
203 | - } | |
204 | - | |
205 | - TN3270::Session & IPC::Session::push(const PAKey key) { | |
206 | - | |
207 | - int32_t rc; | |
208 | - | |
209 | - Request(*this,"pakey") | |
210 | - .push((uint32_t) key) | |
185 | + .push(text) | |
186 | + .push((uint32_t) length) | |
211 | 187 | .call() |
212 | 188 | .pop(rc); |
213 | 189 | ... | ... |
common/src/include/lib3270/ipc.h
... | ... | @@ -294,10 +294,15 @@ |
294 | 294 | /// @brief Send PA. |
295 | 295 | virtual Session & pakey(unsigned short value) = 0; |
296 | 296 | |
297 | - virtual Session & push(int baddr, const std::string &text) = 0; | |
298 | - virtual Session & push(int row, int col, const std::string &text) = 0; | |
299 | - virtual Session & push(const PFKey key) = 0; | |
300 | - virtual Session & push(const PAKey key) = 0; | |
297 | + virtual Session & push(int baddr, const char *text, int length) = 0; | |
298 | + virtual Session & push(int row, int col, const char *text, int length) = 0; | |
299 | + | |
300 | + Session & push(int row, int col, const std::string &text); | |
301 | + Session & push(int baddr, const std::string &text); | |
302 | + | |
303 | + Session & push(const PFKey key); | |
304 | + Session & push(const PAKey key); | |
305 | + | |
301 | 306 | virtual Session & push(const Action action) = 0; |
302 | 307 | |
303 | 308 | // Get contents. |
... | ... | @@ -342,8 +347,6 @@ |
342 | 347 | /// @brief Write error to log file. |
343 | 348 | void error(const char *fmt, ...) const; |
344 | 349 | |
345 | - void input(const char *text, size_t sz); | |
346 | - | |
347 | 350 | public: |
348 | 351 | Host(const char *id = nullptr, const char *url = nullptr, time_t timeout = DEFAULT_TIMEOUT); |
349 | 352 | ~Host(); |
... | ... | @@ -435,6 +438,8 @@ |
435 | 438 | /// @param control_char Control character used to identify commands. |
436 | 439 | Host & input(const char *text, const char control_char = '@'); |
437 | 440 | |
441 | + Host & input(const char *text, size_t sz); | |
442 | + | |
438 | 443 | /// @brief Set field at current posicion, jumps to next writable field. |
439 | 444 | inline Host & push(const char *text) { |
440 | 445 | session->push(text); |
... | ... | @@ -452,11 +457,21 @@ |
452 | 457 | return *this; |
453 | 458 | } |
454 | 459 | |
460 | + inline Host & push(int baddr, const char *text, int length = -1) { | |
461 | + session->push(baddr,text,length); | |
462 | + return *this; | |
463 | + } | |
464 | + | |
455 | 465 | inline Host & push(int row, int col, const std::string &text) { |
456 | 466 | session->push(row,col,text); |
457 | 467 | return *this; |
458 | 468 | } |
459 | 469 | |
470 | + inline Host & push(int row, int col, const char *text, int length = -1) { | |
471 | + session->push(row,col,text,length); | |
472 | + return *this; | |
473 | + } | |
474 | + | |
460 | 475 | inline Host & push(const PFKey key) { |
461 | 476 | session->push(key); |
462 | 477 | return *this; | ... | ... |