Commit 0cd4a4ece9f79c47408b8b54a2b34da3f52fafda
1 parent
834eada6
Exists in
master
and in
3 other branches
Implementando novo widget para seleção de servidor
Showing
2 changed files
with
60 additions
and
11 deletions
Show diff stats
host.c
| ... | ... | @@ -492,6 +492,20 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
| 492 | 492 | trace("%s ends",__FUNCTION__); |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | +static void update_host(H3270 *h) | |
| 496 | +{ | |
| 497 | + Replace(h->host.full, | |
| 498 | + lib3270_strdup_printf( | |
| 499 | + "%s%s:%s", | |
| 500 | + h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
| 501 | + h->host.current, | |
| 502 | + h->host.srvc | |
| 503 | + )); | |
| 504 | + | |
| 505 | + trace("hosturl=[%s]",h->host.full); | |
| 506 | + | |
| 507 | +} | |
| 508 | + | |
| 495 | 509 | LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) |
| 496 | 510 | { |
| 497 | 511 | CHECK_SESSION_HANDLE(h); |
| ... | ... | @@ -558,17 +572,8 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) |
| 558 | 572 | |
| 559 | 573 | Replace(h->host.current,strdup(hostname)); |
| 560 | 574 | Replace(h->host.srvc,strdup(srvc)); |
| 561 | - Replace(h->host.full, | |
| 562 | - lib3270_strdup_printf( | |
| 563 | - "%s%s:%s%s%s", | |
| 564 | - h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
| 565 | - hostname, | |
| 566 | - srvc, | |
| 567 | - *query ? "?" : "", | |
| 568 | - query | |
| 569 | - )); | |
| 570 | - | |
| 571 | - trace("hosturl=[%s]",h->host.full); | |
| 575 | + | |
| 576 | + update_host(h); | |
| 572 | 577 | |
| 573 | 578 | free(str); |
| 574 | 579 | } |
| ... | ... | @@ -586,6 +591,13 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) |
| 586 | 591 | return ""; |
| 587 | 592 | } |
| 588 | 593 | |
| 594 | +LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) | |
| 595 | +{ | |
| 596 | + CHECK_SESSION_HANDLE(h); | |
| 597 | + Replace(h->host.current,strdup(hostname)); | |
| 598 | + update_host(h); | |
| 599 | +} | |
| 600 | + | |
| 589 | 601 | LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) |
| 590 | 602 | { |
| 591 | 603 | CHECK_SESSION_HANDLE(h); |
| ... | ... | @@ -594,6 +606,13 @@ LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) |
| 594 | 606 | return "telnet"; |
| 595 | 607 | } |
| 596 | 608 | |
| 609 | +LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) | |
| 610 | +{ | |
| 611 | + CHECK_SESSION_HANDLE(h); | |
| 612 | + Replace(h->host.srvc,strdup(srvc)); | |
| 613 | + update_host(h); | |
| 614 | +} | |
| 615 | + | |
| 597 | 616 | LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) |
| 598 | 617 | { |
| 599 | 618 | CHECK_SESSION_HANDLE(h); | ... | ... |
options.c
| ... | ... | @@ -134,3 +134,33 @@ LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) |
| 134 | 134 | CHECK_SESSION_HANDLE(hSession); |
| 135 | 135 | return (hSession->options & LIB3270_OPTION_TSO) != 0; |
| 136 | 136 | } |
| 137 | + | |
| 138 | +LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) | |
| 139 | +{ | |
| 140 | + static const struct _host_type | |
| 141 | + { | |
| 142 | + const char * name; | |
| 143 | + LIB3270_OPTION option; | |
| 144 | + } host_type[] = | |
| 145 | + { | |
| 146 | + { "S390", LIB3270_OPTION_S390 }, | |
| 147 | + { "AS400", LIB3270_OPTION_AS400 }, | |
| 148 | + { "TSO", LIB3270_OPTION_TSO }, | |
| 149 | + { "VM/CMS", 0 } | |
| 150 | + }; | |
| 151 | + | |
| 152 | + int f; | |
| 153 | + | |
| 154 | + for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) | |
| 155 | + { | |
| 156 | + if(!strcasecmp(host_type[f].name,name)) | |
| 157 | + { | |
| 158 | + hSession->options &= ~LIB3270_OPTION_HOST_TYPE; | |
| 159 | + hSession->options |= host_type[f].option; | |
| 160 | + return 0; | |
| 161 | + } | |
| 162 | + } | |
| 163 | + | |
| 164 | + return EINVAL; | |
| 165 | +} | |
| 166 | + | ... | ... |