diff --git a/host.c b/host.c index 82e2706..402320c 100644 --- a/host.c +++ b/host.c @@ -492,6 +492,20 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) trace("%s ends",__FUNCTION__); } +static void update_host(H3270 *h) +{ + Replace(h->host.full, + lib3270_strdup_printf( + "%s%s:%s", + h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", + h->host.current, + h->host.srvc + )); + + trace("hosturl=[%s]",h->host.full); + +} + LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) { CHECK_SESSION_HANDLE(h); @@ -558,17 +572,8 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) Replace(h->host.current,strdup(hostname)); Replace(h->host.srvc,strdup(srvc)); - Replace(h->host.full, - lib3270_strdup_printf( - "%s%s:%s%s%s", - h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", - hostname, - srvc, - *query ? "?" : "", - query - )); - - trace("hosturl=[%s]",h->host.full); + + update_host(h); free(str); } @@ -586,6 +591,13 @@ LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) return ""; } +LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) +{ + CHECK_SESSION_HANDLE(h); + Replace(h->host.current,strdup(hostname)); + update_host(h); +} + LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) { CHECK_SESSION_HANDLE(h); @@ -594,6 +606,13 @@ LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) return "telnet"; } +LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) +{ + CHECK_SESSION_HANDLE(h); + Replace(h->host.srvc,strdup(srvc)); + update_host(h); +} + LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) { CHECK_SESSION_HANDLE(h); diff --git a/options.c b/options.c index 588b62e..77cd22a 100644 --- a/options.c +++ b/options.c @@ -134,3 +134,33 @@ LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) CHECK_SESSION_HANDLE(hSession); return (hSession->options & LIB3270_OPTION_TSO) != 0; } + +LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) +{ + static const struct _host_type + { + const char * name; + LIB3270_OPTION option; + } host_type[] = + { + { "S390", LIB3270_OPTION_S390 }, + { "AS400", LIB3270_OPTION_AS400 }, + { "TSO", LIB3270_OPTION_TSO }, + { "VM/CMS", 0 } + }; + + int f; + + for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) + { + if(!strcasecmp(host_type[f].name,name)) + { + hSession->options &= ~LIB3270_OPTION_HOST_TYPE; + hSession->options |= host_type[f].option; + return 0; + } + } + + return EINVAL; +} + -- libgit2 0.21.2