diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 7c38555..c4ddf9f 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -204,18 +204,6 @@ /** - * Connect options. - * - */ - typedef enum _LIB3270_CONNECT_OPTION - { - LIB3270_CONNECT_OPTION_DEFAULTS = 0x0000, /**< Default connection options */ - LIB3270_CONNECT_OPTION_SSL = 0x0001, /**< Secure connection */ - LIB3270_CONNECT_OPTION_WAIT = 0x0002, /**< Wait for screen ready */ - - } LIB3270_CONNECT_OPTION; - - /** * Cursor modes. * * Cursor modes set by library; an application can us it @@ -256,9 +244,12 @@ */ typedef enum lib3270_option { - LIB3270_OPTION_KYBD_AS400 = 0x0001, /**< Prefix every PF with PA1 */ + LIB3270_OPTION_DEFAULTS = 0x0000, + LIB3270_OPTION_AS400 = 0x0001, /**< Prefix every PF with PA1 */ LIB3270_OPTION_TSO = 0x0002, /**< Host is TSO? */ + LIB3270_OPTION_SSL = 0x0004, + LIB3270_OPTION_WAIT = 0x8000 /**< Wait for session ready on connect ? */ } LIB3270_OPTION; @@ -430,12 +421,12 @@ /** - * Get connection options. + * Get session options. * * @param h Session handle. * */ - LIB3270_EXPORT LIB3270_CONNECT_OPTION lib3270_get_connect_options(H3270 *h); + LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); /** * Get URL of the hostname for the connect/reconnect operations. @@ -465,12 +456,12 @@ * @param hSession Session handle. * @param hostname Host name. * @param srvc Service name (telnet if NULL). - * @param opt Connect options. + * @param opt Session options. * * @return 0 for success, EAGAIN if auto-reconnect is in progress, EBUSY if connected, ENOTCONN if connection has failed, -1 on unexpected failure. * */ - LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_CONNECT_OPTION opt); + LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_OPTION opt); /** @@ -1053,7 +1044,6 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); - LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt); LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype); diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index e04830a..366652d 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -141,7 +141,6 @@ struct { - LIB3270_CONNECT_OPTION opt; /**< Connect options */ char * current; /**< The hostname part, stripped of qualifiers, luname and port number */ char * full; /**< The entire string, for use in reconnecting */ char * srvc; /**< The service name */ diff --git a/src/lib3270/connect.c b/src/lib3270/connect.c index 386203e..5b441a8 100644 --- a/src/lib3270/connect.c +++ b/src/lib3270/connect.c @@ -175,7 +175,7 @@ static void net_connected(H3270 *hSession) } #endif // WIN32 - LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_CONNECT_OPTION opt) + LIB3270_EXPORT int lib3270_connect_host(H3270 *hSession, const char *hostname, const char *srvc, LIB3270_OPTION opt) { CHECK_SESSION_HANDLE(hSession); @@ -202,20 +202,20 @@ static void net_connected(H3270 *hSession) hostname = name; } - hSession->host.opt = opt & ~LIB3270_CONNECT_OPTION_WAIT; + hSession->options = opt & ~LIB3270_OPTION_WAIT; Replace(hSession->host.current,strdup(hostname)); Replace(hSession->host.srvc,strdup(srvc)); Replace(hSession->host.full, lib3270_strdup_printf( "%s%s:%s", - opt&LIB3270_CONNECT_OPTION_SSL ? "tn3270s://" : "tn3270://", + opt&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", hostname, srvc )); trace("current_host=\"%s\"",hSession->host.current); - return lib3270_connect(hSession,opt & LIB3270_CONNECT_OPTION_WAIT); + return lib3270_connect(hSession,opt & LIB3270_OPTION_WAIT); } @@ -316,7 +316,7 @@ static void net_connected(H3270 *hSession) hSession->ever_3270 = False; hSession->ssl_host = 0; - if(hSession->host.opt&LIB3270_CONNECT_OPTION_SSL) + if(hSession->options&LIB3270_OPTION_SSL) { #if defined(HAVE_LIBSSL) hSession->ssl_host = 1; diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 92b9bd6..82e2706 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -500,18 +500,18 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) { static const struct _sch { - LIB3270_CONNECT_OPTION opt; - const char * text; - const char * srvc; + LIB3270_OPTION opt; + const char * text; + const char * srvc; } sch[] = { - { LIB3270_CONNECT_OPTION_DEFAULTS, "tn3270://", "telnet" }, - { LIB3270_CONNECT_OPTION_SSL, "tn3270s://", "telnets" }, - { LIB3270_CONNECT_OPTION_DEFAULTS, "telnet://", "telnet" }, - { LIB3270_CONNECT_OPTION_DEFAULTS, "telnets://", "telnets" }, - { LIB3270_CONNECT_OPTION_SSL, "L://", "telnets" }, + { LIB3270_OPTION_DEFAULTS, "tn3270://", "telnet" }, + { LIB3270_OPTION_SSL, "tn3270s://", "telnets" }, + { LIB3270_OPTION_DEFAULTS, "telnet://", "telnet" }, + { LIB3270_OPTION_DEFAULTS, "telnets://", "telnets" }, + { LIB3270_OPTION_SSL, "L://", "telnets" }, - { LIB3270_CONNECT_OPTION_SSL, "L:", "telnets" } // The compatibility should be the last option + { LIB3270_OPTION_SSL, "L:", "telnets" } // The compatibility should be the last option }; char * str = strdup(n); @@ -522,16 +522,16 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) int f; trace("%s(%s)",__FUNCTION__,str); - h->host.opt = LIB3270_CONNECT_OPTION_DEFAULTS; + h->options = LIB3270_OPTION_DEFAULTS; for(f=0;f < sizeof(sch)/sizeof(sch[0]);f++) { size_t sz = strlen(sch[f].text); if(!strncasecmp(hostname,sch[f].text,sz)) { - h->host.opt = sch[f].opt; - srvc = sch[f].srvc; - hostname += sz; + h->options = sch[f].opt; + srvc = sch[f].srvc; + hostname += sz; break; } } @@ -561,7 +561,7 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) Replace(h->host.full, lib3270_strdup_printf( "%s%s:%s%s%s", - h->host.opt&LIB3270_CONNECT_OPTION_SSL ? "tn3270s://" : "tn3270://", + h->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", hostname, srvc, *query ? "?" : "", @@ -579,19 +579,19 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) { CHECK_SESSION_HANDLE(h); - return h->host.current; -} -LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) -{ - CHECK_SESSION_HANDLE(h); - return h->host.srvc; + if(h->host.current) + return h->host.current; + + return ""; } -LIB3270_EXPORT LIB3270_CONNECT_OPTION lib3270_get_connect_options(H3270 *h) +LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) { CHECK_SESSION_HANDLE(h); - return h->host.opt; + if(h->host.srvc) + return h->host.srvc; + return "telnet"; } LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index e005723..6c6e22b 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -572,14 +572,14 @@ LIB3270_FKEY_ACTION( pfkey ) if (hSession->kybdlock) { - if(hSession->options & LIB3270_OPTION_KYBD_AS400) + if(hSession->options & LIB3270_OPTION_AS400) enq_key(hSession,pa_xlate[0]); enq_key(hSession,pf_xlate[key-1]); } else { - if(hSession->options & LIB3270_OPTION_KYBD_AS400) + if(hSession->options & LIB3270_OPTION_AS400) key_AID(hSession,pa_xlate[0]); key_AID(hSession,pf_xlate[key-1]); diff --git a/src/lib3270/options.c b/src/lib3270/options.c index 6e5272d..8aca9f0 100644 --- a/src/lib3270/options.c +++ b/src/lib3270/options.c @@ -39,7 +39,7 @@ static const const LIB3270_OPTION_ENTRY options[LIB3270_OPTION_COUNT+1] = { { - LIB3270_OPTION_KYBD_AS400, + LIB3270_OPTION_AS400, "as400", N_( "Host is AS/400" ), NULL diff --git a/src/pw3270/hostdialog.c b/src/pw3270/hostdialog.c index 9153934..199f7e9 100644 --- a/src/pw3270/hostdialog.c +++ b/src/pw3270/hostdialog.c @@ -40,7 +40,7 @@ } host_type[] = { { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO }, - { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_AS400 }, + { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_AS400 }, { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } }; @@ -353,22 +353,19 @@ gtk_widget_show_all(GTK_WIDGET(table)); #endif - gchar *uri = get_string_from_config("host","uri",""); - - if(uri && *uri && lib3270_set_host(v3270_get_session(widget),uri)) { H3270 *hSession = v3270_get_session(widget); + gchar *uri = get_string_from_config("host","uri",""); + + if(uri && *uri) + lib3270_set_host(hSession,uri); + + g_free(uri); + gtk_entry_set_text(host,lib3270_get_hostname(hSession)); gtk_entry_set_text(port,lib3270_get_srvcname(hSession)); - gtk_toggle_button_set_active(sslcheck,(lib3270_get_connect_options(hSession) & LIB3270_CONNECT_OPTION_SSL) ? TRUE : FALSE); + gtk_toggle_button_set_active(sslcheck,(lib3270_get_options(hSession) & LIB3270_OPTION_SSL) ? TRUE : FALSE); } - else - { - gtk_entry_set_text(host,""); - gtk_entry_set_text(port,"telnet"); - } - - g_free(uri); /* hostname = cfghost; @@ -427,14 +424,13 @@ set_string_to_config("host","systype",host_type[iHostType].name); set_integer_to_config("host","colortype",colortable[iColorTable].colors); - v3270_set_session_options(widget,host_type[iHostType].option); v3270_set_session_color_type(widget,colortable[iColorTable].colors); // if(!lib3270_connect(v3270_get_session(widget),hostname,1)) if(!lib3270_connect_host( v3270_get_session(widget), gtk_entry_get_text(host), gtk_entry_get_text(port), - gtk_toggle_button_get_active(sslcheck) ? LIB3270_CONNECT_OPTION_SSL : LIB3270_CONNECT_OPTION_DEFAULTS)) + host_type[iHostType].option | (gtk_toggle_button_get_active(sslcheck) ? LIB3270_OPTION_SSL : LIB3270_OPTION_DEFAULTS))) { again = FALSE; } -- libgit2 0.21.2