diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 6d1b9ae..bb26b59 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1060,6 +1060,7 @@ LIB3270_EXPORT unsigned short lib3270_get_color_type(H3270 *hSession); LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name); + LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name); LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); diff --git a/src/include/pw3270/v3270.h b/src/include/pw3270/v3270.h index d0fd6e1..ed04df7 100644 --- a/src/include/pw3270/v3270.h +++ b/src/include/pw3270/v3270.h @@ -213,6 +213,7 @@ LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on); LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options); LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype); + LIB3270_EXPORT int v3270_set_host_type(GtkWidget *widget, const char *name); LIB3270_EXPORT const gchar * v3270_set_host(GtkWidget *widget, const gchar *uri); LIB3270_EXPORT const gchar * v3270_get_hostname(GtkWidget *widget); LIB3270_EXPORT GtkWidget * v3270_get_default_widget(void); diff --git a/src/lib3270/options.c b/src/lib3270/options.c index 77cd22a..326c4d0 100644 --- a/src/lib3270/options.c +++ b/src/lib3270/options.c @@ -33,6 +33,18 @@ /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ + 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 } + }; + /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ @@ -80,13 +92,9 @@ LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) LIB3270_EXPORT unsigned short lib3270_get_color_type(H3270 *hSession) { CHECK_SESSION_HANDLE(hSession); - - trace("******************* %d",hSession->colors); - return hSession->mono ? 2 : hSession->colors; } - LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype) { CHECK_SESSION_HANDLE(hSession); @@ -135,20 +143,21 @@ LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) return (hSession->options & LIB3270_OPTION_TSO) != 0; } -LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) +LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name) { - static const struct _host_type - { - const char * name; - LIB3270_OPTION option; - } host_type[] = + int f; + + for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) { - { "S390", LIB3270_OPTION_S390 }, - { "AS400", LIB3270_OPTION_AS400 }, - { "TSO", LIB3270_OPTION_TSO }, - { "VM/CMS", 0 } - }; + if(!strcasecmp(host_type[f].name,name)) + return host_type[f].option; + } + return 0; +} + +LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, const char *name) +{ int f; for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index 713abd3..abaf208 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -1552,6 +1552,12 @@ int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) return lib3270_set_color_type(GTK_V3270(widget)->host,colortype); } +int v3270_set_host_type(GtkWidget *widget, const char *name) +{ + g_return_val_if_fail(GTK_IS_V3270(widget),EFAULT); + return lib3270_set_host_type(GTK_V3270(widget)->host,name); +} + unsigned short v3270_get_session_color_type(GtkWidget *widget) { g_return_val_if_fail(GTK_IS_V3270(widget),-1); diff --git a/src/pw3270/window.c b/src/pw3270/window.c index 01d5392..559dbdf 100644 --- a/src/pw3270/window.c +++ b/src/pw3270/window.c @@ -195,13 +195,13 @@ g_free(ptr); } + */ + if(colors) set_integer_to_config("host","colortype",colors); else colors = get_integer_from_config("host","colortype",16); - */ - pw3270_set_session_color_type(widget,colors); if(host) -- libgit2 0.21.2