Commit 62ed4ef47e17366a751263500ea6d3855f859c7e
1 parent
1b8493c9
Exists in
master
and in
1 other branch
Implementing hllapi_set_session_property(const LPSTR property, const
LPSTR value) method.
Showing
5 changed files
with
61 additions
and
1 deletions
Show diff stats
src/core/controller.cc
| ... | ... | @@ -70,6 +70,11 @@ |
| 70 | 70 | |
| 71 | 71 | debug("Will set timeout to %d",120); |
| 72 | 72 | |
| 73 | +#ifdef DEBUG | |
| 74 | + // Hack to speed up the tests. | |
| 75 | + hllapi_host->setProperty("crl_download",false); | |
| 76 | +#endif // DEBUG | |
| 77 | + | |
| 73 | 78 | hllapi_host->setTimeout(120); |
| 74 | 79 | |
| 75 | 80 | } catch(const std::exception &e) { | ... | ... |
src/core/hllapi.cc
| ... | ... | @@ -470,7 +470,38 @@ HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) |
| 470 | 470 | |
| 471 | 471 | } else { |
| 472 | 472 | |
| 473 | - return HLLAPI_STATUS_BAD_PARAMETER; | |
| 473 | + int rc = HLLAPI_STATUS_BAD_PARAMETER; | |
| 474 | + | |
| 475 | + char * buffer = NULL; | |
| 476 | + asprintf(&buffer,"%u",(unsigned int) value); | |
| 477 | + | |
| 478 | + if(!buffer) | |
| 479 | + return HLLAPI_STATUS_SYSTEM_ERROR; | |
| 480 | + | |
| 481 | + try { | |
| 482 | + | |
| 483 | + getSession().setProperty(param,buffer); | |
| 484 | + | |
| 485 | + } catch(const std::system_error &e) { | |
| 486 | + | |
| 487 | + rc = hllapi_translate_error(e); | |
| 488 | + | |
| 489 | + } catch(const std::exception &e) { | |
| 490 | + | |
| 491 | + // Error getting session or lock state | |
| 492 | + hllapi_lasterror = e.what(); | |
| 493 | + rc = HLLAPI_STATUS_SYSTEM_ERROR; | |
| 494 | + | |
| 495 | + } catch(...) { | |
| 496 | + | |
| 497 | + // Unexpected error getting session or lock state | |
| 498 | + hllapi_lasterror = _( "Unexpected error" ); | |
| 499 | + rc = HLLAPI_STATUS_SYSTEM_ERROR; | |
| 500 | + | |
| 501 | + } | |
| 502 | + | |
| 503 | + free(buffer); | |
| 504 | + return rc; | |
| 474 | 505 | |
| 475 | 506 | } |
| 476 | 507 | ... | ... |
src/core/set.cc
| ... | ... | @@ -117,3 +117,20 @@ |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | 119 | } |
| 120 | + | |
| 121 | + HLLAPI_API_CALL hllapi_set_session_property(const LPSTR property, const LPSTR value) { | |
| 122 | + | |
| 123 | + if(!(property && *property)) { | |
| 124 | + hllapi_lasterror = _( "Invalid property name" ); | |
| 125 | + return HLLAPI_STATUS_BAD_PARAMETER; | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + return set([property,value](TN3270::Host &host) { | |
| 130 | + | |
| 131 | + host.setProperty(property,value); | |
| 132 | + | |
| 133 | + }); | |
| 134 | + | |
| 135 | + } | |
| 136 | + | ... | ... |
src/include/lib3270/hllapi.h
| ... | ... | @@ -330,6 +330,7 @@ |
| 330 | 330 | HLLAPI_API_CALL hllapi_pakey(WORD key); |
| 331 | 331 | |
| 332 | 332 | HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value); |
| 333 | + HLLAPI_API_CALL hllapi_set_session_property(const LPSTR property, const LPSTR value); | |
| 333 | 334 | |
| 334 | 335 | HLLAPI_API_CALL hllapi_enter(void); |
| 335 | 336 | HLLAPI_API_CALL hllapi_erase(void); | ... | ... |
src/testprogram/testprogram.cc
| ... | ... | @@ -89,6 +89,9 @@ |
| 89 | 89 | |
| 90 | 90 | #endif // ! defined(_MSC_VER) |
| 91 | 91 | |
| 92 | + cout << "Host: \"" << host << "\"" << endl | |
| 93 | + << "Session: \"" << session << "\"" << endl; | |
| 94 | + | |
| 92 | 95 | try { |
| 93 | 96 | |
| 94 | 97 | rc = hllapi_init((char *) session); |
| ... | ... | @@ -101,6 +104,9 @@ |
| 101 | 104 | |
| 102 | 105 | hllapi_set_timeout(10); |
| 103 | 106 | |
| 107 | + // Hack to speed up connection. | |
| 108 | + hllapi_set_session_property("crl_download","0"); | |
| 109 | + | |
| 104 | 110 | } catch(const std::exception &e) { |
| 105 | 111 | |
| 106 | 112 | cerr << e.what() << endl; | ... | ... |