Commit 52880afad43651af4cede05fab2df0f49c6a3a8a
1 parent
e8f938a2
Exists in
master
and in
3 other branches
Updating API calls for the new version.
Showing
6 changed files
with
56 additions
and
17 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -617,7 +617,7 @@ |
617 | 617 | * @param h Session handle. |
618 | 618 | * @param s String to input. |
619 | 619 | * |
620 | - * @return Negative if error or number of processed characters. | |
620 | + * @return -1 if error (sets errno) or number of processed characters. | |
621 | 621 | * |
622 | 622 | */ |
623 | 623 | LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str); |
... | ... | @@ -625,7 +625,7 @@ |
625 | 625 | #define lib3270_set_text_at(h,r,c,t) lib3270_set_string_at(h,r,c,t) |
626 | 626 | |
627 | 627 | /** |
628 | - * @brief Set string at defined position. | |
628 | + * @brief Set string at defined row/column. | |
629 | 629 | * |
630 | 630 | * @param hSession Session handle. |
631 | 631 | * @param row Row for the first character. |
... | ... | @@ -637,6 +637,18 @@ |
637 | 637 | */ |
638 | 638 | LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, const unsigned char *str); |
639 | 639 | |
640 | + /** | |
641 | + * @brief Set string at defined adress. | |
642 | + * | |
643 | + * @param hSession Session handle. | |
644 | + * @param baddr Adress for the first character. | |
645 | + * @param str String to set. | |
646 | + * | |
647 | + * @return Negative if error or number of processed characters. | |
648 | + * | |
649 | + */ | |
650 | + LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str); | |
651 | + | |
640 | 652 | LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str); |
641 | 653 | |
642 | 654 | /** |
... | ... | @@ -979,7 +991,7 @@ |
979 | 991 | * @return Contents at position if available, or NULL. Release it with lib3270_free() |
980 | 992 | * |
981 | 993 | */ |
982 | - LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf); | |
994 | + LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int len, char lf); | |
983 | 995 | |
984 | 996 | /** |
985 | 997 | * @brief Get text at requested position |
... | ... | @@ -993,7 +1005,7 @@ |
993 | 1005 | * @return Contents at position if available, or NULL. Release it with lib3270_free() |
994 | 1006 | * |
995 | 1007 | */ |
996 | - LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len, char lf); | |
1008 | + LIB3270_EXPORT char * lib3270_get_string_at(H3270 *h, int row, int col, int len, char lf); | |
997 | 1009 | |
998 | 1010 | /** |
999 | 1011 | * @brief Check for text at requested position | ... | ... |
src/lib3270++/local/session.cc
... | ... | @@ -117,7 +117,7 @@ |
117 | 117 | |
118 | 118 | std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); |
119 | 119 | |
120 | - char * text = lib3270_get_text(hSession, baddr, len, lf); | |
120 | + char * text = lib3270_get_string_at_address(hSession, baddr, len, lf); | |
121 | 121 | |
122 | 122 | if(!text) { |
123 | 123 | throw std::runtime_error( _("Can't get screen contents") ); |
... | ... | @@ -135,7 +135,7 @@ |
135 | 135 | |
136 | 136 | std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); |
137 | 137 | |
138 | - char * text = lib3270_get_text_at(hSession, row, col, sz, lf); | |
138 | + char * text = lib3270_get_string_at(hSession, row, col, sz, lf); | |
139 | 139 | |
140 | 140 | if(!text) { |
141 | 141 | throw std::runtime_error( _("Can't get screen contents") ); | ... | ... |
src/lib3270/macros.c
src/lib3270/paste.c
... | ... | @@ -266,24 +266,51 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, cons |
266 | 266 | return rc; |
267 | 267 | } |
268 | 268 | |
269 | +LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str) | |
270 | +{ | |
271 | + int rc = -1; | |
272 | + | |
273 | + FAIL_IF_NOT_ONLINE(hSession); | |
274 | + | |
275 | + if(hSession->kybdlock) | |
276 | + { | |
277 | + errno = EPERM; | |
278 | + return -1; | |
279 | + } | |
280 | + | |
281 | + if(lib3270_set_cursor_address(hSession,baddr) < 0) | |
282 | + return -1; | |
283 | + | |
284 | + if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | |
285 | + lib3270_unselect(hSession); | |
286 | + | |
287 | + hSession->cbk.suspend(hSession); | |
288 | + rc = set_string(hSession, str); | |
289 | + hSession->cbk.resume(hSession); | |
290 | + | |
291 | + return rc; | |
292 | +} | |
269 | 293 | |
270 | 294 | /** |
271 | - * Set string at cursor position. | |
295 | + * @brief Set string at cursor position. | |
272 | 296 | * |
273 | 297 | * @param hSession Session handle. |
274 | 298 | * @param str String to set |
275 | 299 | * |
276 | - * @return Number of characters inserted; <0 in case of error. | |
300 | + * @return -1 if error (sets errno) or number of processed characters. | |
277 | 301 | * |
278 | 302 | */ |
279 | 303 | LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) |
280 | 304 | { |
281 | 305 | int rc; |
282 | 306 | |
283 | - CHECK_SESSION_HANDLE(hSession); | |
307 | + FAIL_IF_NOT_ONLINE(hSession); | |
284 | 308 | |
285 | 309 | if(hSession->kybdlock) |
286 | - return -EINVAL; | |
310 | + { | |
311 | + errno = EPERM; | |
312 | + return -1; | |
313 | + } | |
287 | 314 | |
288 | 315 | hSession->cbk.suspend(hSession); |
289 | 316 | rc = set_string(hSession, str); | ... | ... |
src/lib3270/screen.c
... | ... | @@ -363,7 +363,7 @@ void screen_update(H3270 *session, int bstart, int bend) |
363 | 363 | |
364 | 364 | #ifdef DEBUG |
365 | 365 | { |
366 | - char *text = lib3270_get_text(session,0,-1,'\n'); | |
366 | + char *text = lib3270_get_string_at_address(session,0,-1,'\n'); | |
367 | 367 | trace("First screen:\n%s\n",text); |
368 | 368 | lib3270_free(text); |
369 | 369 | } | ... | ... |
src/lib3270/selection.c
... | ... | @@ -473,7 +473,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u |
473 | 473 | return lib3270_realloc(text,sz); |
474 | 474 | } |
475 | 475 | |
476 | -LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf) | |
476 | +LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int len, char lf) | |
477 | 477 | { |
478 | 478 | char * buffer; |
479 | 479 | int maxlen; |
... | ... | @@ -528,10 +528,10 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf) |
528 | 528 | return buffer; |
529 | 529 | } |
530 | 530 | |
531 | -LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len, char lf) | |
531 | +LIB3270_EXPORT char * lib3270_get_string_at(H3270 *h, int row, int col, int len, char lf) | |
532 | 532 | { |
533 | 533 | CHECK_SESSION_HANDLE(h); |
534 | - return lib3270_get_text(h, ((row-1) * h->cols) + (col-1), len, lf); | |
534 | + return lib3270_get_string_at_address(h, ((row-1) * h->cols) + (col-1), len, lf); | |
535 | 535 | } |
536 | 536 | |
537 | 537 | LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text, char lf) |
... | ... | @@ -540,7 +540,7 @@ LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *t |
540 | 540 | size_t sz = strlen(text); |
541 | 541 | char * contents; |
542 | 542 | |
543 | - contents = lib3270_get_text_at(h,row,col,sz,lf); | |
543 | + contents = lib3270_get_string_at(h,row,col,sz,lf); | |
544 | 544 | if(!contents) |
545 | 545 | return -1; |
546 | 546 | |
... | ... | @@ -567,7 +567,7 @@ LIB3270_EXPORT char * lib3270_get_field_text_at(H3270 *session, int baddr) |
567 | 567 | if(first < 0) |
568 | 568 | return NULL; |
569 | 569 | |
570 | - return lib3270_get_text(session,first,lib3270_field_length(session,first)+1,0); | |
570 | + return lib3270_get_string_at_address(session,first,lib3270_field_length(session,first)+1,0); | |
571 | 571 | } |
572 | 572 | |
573 | 573 | LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession) | ... | ... |