diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 2e987a9..60a6ab0 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -938,6 +938,8 @@ LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model); + LIB3270_EXPORT int lib3270_set_model_name(H3270 *hSession, const char *name); + LIB3270_EXPORT int lib3270_get_model(H3270 *session); LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr); diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 0cb13c8..0293a4f 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -255,7 +255,7 @@ // telnet sub-option buffer unsigned char * sbptr; unsigned char telnet_state; - char ttype_tmpval[13]; +// char ttype_tmpval[13]; unsigned char myopts[LIB3270_TELNET_N_OPTS]; unsigned char hisopts[LIB3270_TELNET_N_OPTS]; diff --git a/src/lib3270/session.c b/src/lib3270/session.c index d0519f9..61b32a1 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -177,11 +177,71 @@ static void nop_int(H3270 *session, int width) return; } -static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) +int lib3270_set_model_name(H3270 *hSession, const char *model) { int ovc, ovr; char junk; int model_number; + + if(hSession->cstate != LIB3270_NOT_CONNECTED) + return EBUSY; + + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); + hSession->model_name = &hSession->full_model_name[4]; + + if(!*model) + model = "2"; // No model, use the default one + + model_number = parse_model_number(hSession,model); + if (model_number < 0) + { + popup_an_error(hSession,"Invalid model number: %s", model); + model_number = 0; + } + + if (!model_number) + { +#if defined(RESTRICT_3279) + model_number = 3; +#else + model_number = 4; +#endif + } + + if(hSession->mono) + hSession->m3279 = 0; + else + hSession->m3279 = 1; + + if(!hSession->extended) + hSession->oversize = CN; + +#if defined(RESTRICT_3279) + if (hSession->m3279 && model_number == 4) + model_number = 3; +#endif + + trace("Model_number: %d",model_number); + + if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) + { + ovc = 0; + ovr = 0; + } + ctlr_set_rows_cols(hSession, model_number, ovc, ovr); + + if (hSession->termname != CN) + hSession->termtype = hSession->termname; + else + hSession->termtype = hSession->full_model_name; + + trace("Termtype: %s",hSession->termtype); + + return 0; +} + +static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) +{ int f; memset(hSession,0,sizeof(H3270)); @@ -248,59 +308,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char // Initialize toggles initialize_toggles(hSession); - strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); - hSession->model_name = &hSession->full_model_name[4]; - - if(!*model) - model = "2"; // No model, use the default one - - model_number = parse_model_number(hSession,model); - if (model_number < 0) - { - popup_an_error(hSession,"Invalid model number: %s", model); - model_number = 0; - } - - if (!model_number) - { -#if defined(RESTRICT_3279) - model_number = 3; -#else - model_number = 4; -#endif - } - - if(hSession->mono) - hSession->m3279 = 0; - else - hSession->m3279 = 1; - - if(!hSession->extended) - hSession->oversize = CN; - -#if defined(RESTRICT_3279) - if (hSession->m3279 && model_number == 4) - model_number = 3; -#endif - - trace("Model_number: %d",model_number); - - if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) - { - ovc = 0; - ovr = 0; - } - ctlr_set_rows_cols(hSession, model_number, ovc, ovr); - - if (hSession->termname != CN) - hSession->termtype = hSession->termname; - else - hSession->termtype = hSession->full_model_name; - - trace("Termtype: %s",hSession->termtype); - -// if (hSession->apl_mode) -// hSession->charset.host = "apl"; + lib3270_set_model_name(hSession,model); } diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index c838a4b..8bf566f 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -684,12 +684,13 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo } - /* set up temporary termtype */ + /* set up temporary termtype if (session->termname == CN && session->std_ds_host) { sprintf(session->ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); session->termtype = session->ttype_tmpval; } + */ /* all done */ #if defined(_WIN32) -- libgit2 0.21.2