diff --git a/src/include/lib3270.h b/src/include/lib3270.h index abdbb14..92c9176 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -452,7 +452,7 @@ * @brief Set host id for the connect/reconnect operations. * * @param h Session handle. - * @param url URL of host to set in the format tn3270://hostname:service or tn3270s://hostname:service . + * @param url URL of host to set in the format tn3270://hostname:service or tn3270s://hostname:service * * @return 0 * @@ -460,6 +460,15 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *url); /** + * @brief Get the URL of the predefined tn3270 host. + * + * @param hSession Session handle. + * + * @return URL of the predefined host in the format tn3270://hostname:service or tn3270s://hostname:service + */ + LIB3270_EXPORT const char * lib3270_get_default_host(H3270 *hSession); + + /** * @brief Set URL for the certificate revocation list. * * @param hSession Session handle. diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 3e6e7c5..f24e455 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -265,136 +265,134 @@ LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) } +LIB3270_EXPORT const char * lib3270_get_default_host(H3270 *hSession unused) +{ +#ifdef LIB3270_DEFAULT_HOST + return LIB3270_DEFAULT_HOST; +#else + return getenv("LIB3270_DEFAULT_HOST"); +#endif // LIB3270_DEFAULT_HOST +} + LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) { FAIL_IF_ONLINE(h); if(!n) - { -#ifdef LIB3270_DEFAULT_HOST - n = LIB3270_DEFAULT_HOST; -#else - n = getenv("LIB3270_DEFAULT_HOST"); - if(!n) - return errno = EINVAL; -#endif // LIB3270_DEFAULT_HOST - } + n = lib3270_get_default_host(h); - if(!h->host.full || strcmp(n,h->host.full)) + if(!n) + return errno = ENOENT; + + static const struct _sch + { + char ssl; + const char * text; + const char * srvc; + } sch[] = { - static const struct _sch - { - char ssl; - const char * text; - const char * srvc; - } sch[] = - { #ifdef HAVE_LIBSSL - { 1, "tn3270s://", "telnets" }, - { 1, "telnets://", "telnets" }, - { 1, "L://", "telnets" }, - { 1, "L:", "telnets" }, + { 1, "tn3270s://", "telnets" }, + { 1, "telnets://", "telnets" }, + { 1, "L://", "telnets" }, + { 1, "L:", "telnets" }, #endif // HAVE_LIBSSL - { 0, "tn3270://", "telnet" }, - { 0, "telnet://", "telnet" } + { 0, "tn3270://", "telnet" }, + { 0, "telnet://", "telnet" } - }; + }; - char * str = strdup(n); - char * hostname = str; - const char * srvc = "telnet"; - char * ptr; - char * query = ""; - int f; + lib3270_autoptr(char) str = strdup(n); + char * hostname = str; + const char * srvc = "telnet"; + char * ptr; + char * query = ""; + int f; - trace("%s(%s)",__FUNCTION__,str); + trace("%s(%s)",__FUNCTION__,str); #ifdef HAVE_LIBSSL - h->ssl.enabled = 0; + h->ssl.enabled = 0; #endif // HAVE_LIBSSL - for(f=0;f < sizeof(sch)/sizeof(sch[0]);f++) + for(f=0;f < sizeof(sch)/sizeof(sch[0]);f++) + { + size_t sz = strlen(sch[f].text); + if(!strncasecmp(hostname,sch[f].text,sz)) { - size_t sz = strlen(sch[f].text); - if(!strncasecmp(hostname,sch[f].text,sz)) - { #ifdef HAVE_LIBSSL - h->ssl.enabled = sch[f].ssl; + h->ssl.enabled = sch[f].ssl; #endif // HAVE_LIBSSL - srvc = sch[f].srvc; - hostname += sz; - break; - } + srvc = sch[f].srvc; + hostname += sz; + break; } + } - if(!*hostname) - return 0; + if(!*hostname) + return 0; - ptr = strchr(hostname,':'); - if(ptr) - { - *(ptr++) = 0; - srvc = ptr; - query = strchr(ptr,'?'); + ptr = strchr(hostname,':'); + if(ptr) + { + *(ptr++) = 0; + srvc = ptr; + query = strchr(ptr,'?'); - trace("QUERY=[%s]",query); + trace("QUERY=[%s]",query); - if(query) - *(query++) = 0; - else - query = ""; - } + if(query) + *(query++) = 0; + else + query = ""; + } - trace("SRVC=[%s]",srvc); + trace("SRVC=[%s]",srvc); - Replace(h->host.current,strdup(hostname)); - Replace(h->host.srvc,strdup(srvc)); + Replace(h->host.current,strdup(hostname)); + Replace(h->host.srvc,strdup(srvc)); - // Verifica parâmetros - if(query && *query) - { - char *str = strdup(query); - char *ptr; + // Verifica parâmetros + if(query && *query) + { + lib3270_autoptr(char) str = strdup(query); + char *ptr; #ifdef HAVE_STRTOK_R - char *saveptr = NULL; - for(ptr = strtok_r(str,"&",&saveptr);ptr;ptr=strtok_r(NULL,"&",&saveptr)) + char *saveptr = NULL; + for(ptr = strtok_r(str,"&",&saveptr);ptr;ptr=strtok_r(NULL,"&",&saveptr)) #else - for(ptr = strtok(str,"&");ptr;ptr=strtok(NULL,"&")) + for(ptr = strtok(str,"&");ptr;ptr=strtok(NULL,"&")) #endif + { + char *var = ptr; + char *val = strchr(ptr,'='); + if(val) { - char *var = ptr; - char *val = strchr(ptr,'='); - if(val) - { - *(val++) = 0; + *(val++) = 0; - if(lib3270_set_string_property(h, var, val, 0) == 0) - continue; + if(lib3270_set_string_property(h, var, val, 0) == 0) + continue; - lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); + lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); - } - else - { - if(lib3270_set_int_property(h,var,1,0)) - continue; - - lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); - } + } + else + { + if(lib3270_set_int_property(h,var,1,0)) + continue; + lib3270_write_log(h,"","Can't set attribute \"%s\": %s",var,strerror(errno)); } - free(str); } - // Notifica atualização - update_host(h); - - free(str); } + // Notifica atualização + update_host(h); + return 0; } diff --git a/src/lib3270/iocalls.c b/src/lib3270/iocalls.c index b0d2e04..0a8a0b8 100644 --- a/src/lib3270/iocalls.c +++ b/src/lib3270/iocalls.c @@ -449,6 +449,9 @@ LIB3270_EXPORT int lib3270_register_io_controller(const LIB3270_IO_CONTROLLER *c if(cbk->run_task) run_task = cbk->run_task; + if(cbk->set_poll_state) + set_poll_state = cbk->set_poll_state; + return 0; } diff --git a/src/lib3270/properties.c b/src/lib3270/properties.c index 4b42664..660ed8e 100644 --- a/src/lib3270/properties.c +++ b/src/lib3270/properties.c @@ -350,42 +350,42 @@ { "luname", // Property name. - N_( "" ), // Property description. + N_( "The name of the active LU" ), // Property description. lib3270_get_luname, // Get value. lib3270_set_luname // Set value. }, { "url", // Property name. - N_( "" ), // Property description. + N_( "URL of the current host" ), // Property description. lib3270_get_url, // Get value. lib3270_set_url // Set value. }, { "model", // Property name. - N_( "" ), // Property description. + N_( "Model name" ), // Property description. lib3270_get_model, // Get value. lib3270_set_model // Set value. }, { "host_type", // Property name. - N_( "" ), // Property description. + N_( "Host type name" ), // Property description. lib3270_get_host_type_name, // Get value. lib3270_set_host_type_by_name // Set value. }, { "host_charset", // Property name. - N_( "" ), // Property description. + N_( "Host charset" ), // Property description. lib3270_get_host_charset, // Get value. lib3270_set_host_charset // Set value. }, { "display_charset", // Property name. - N_( "" ), // Property description. + N_( "Display charset" ), // Property description. lib3270_get_display_charset, // Get value. NULL // Set value. }, @@ -405,10 +405,17 @@ }, { - "crlpath", // Property name. - N_( "URL for the CRL file" ), // Property description. - lib3270_get_crl_url, // Get value. - lib3270_set_crl_url, // Set value. + "crlpath", // Property name. + N_( "URL for the certificate revocation list" ), // Property description. + lib3270_get_crl_url, // Get value. + lib3270_set_crl_url, // Set value. + }, + + { + "default_host", // Property name. + N_( "Default host URL" ), // Property description. + lib3270_get_default_host, // Get value. + NULL // Set value. }, diff --git a/src/lib3270/ssl/negotiate.c b/src/lib3270/ssl/negotiate.c index a01beca..4378eac 100644 --- a/src/lib3270/ssl/negotiate.c +++ b/src/lib3270/ssl/negotiate.c @@ -270,10 +270,6 @@ static int background_ssl_negotiation(H3270 *hSession, void *message) X509_free(peer); } - - /* Tell the world that we are (still) connected, now in secure mode. */ - lib3270_set_connected_initial(hSession); - return 0; } @@ -300,6 +296,11 @@ int ssl_negotiate(H3270 *hSession) } + else + { + /* Tell the world that we are (still) connected, now in secure mode. */ + lib3270_set_connected_initial(hSession); + } non_blocking(hSession,True); -- libgit2 0.21.2