Commit 03b37315ebfe42c0b3de98661a1cf64085c18f8d

Authored by perry.werneck@gmail.com
1 parent 6f6caa9a

Ajustes para flexibilizar configuração do tipo de terminal

src/include/lib3270.h
... ... @@ -938,6 +938,8 @@
938 938  
939 939  
940 940 LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
  941 + LIB3270_EXPORT int lib3270_set_model_name(H3270 *hSession, const char *name);
  942 +
941 943 LIB3270_EXPORT int lib3270_get_model(H3270 *session);
942 944  
943 945 LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr);
... ...
src/include/lib3270/session.h
... ... @@ -255,7 +255,7 @@
255 255 // telnet sub-option buffer
256 256 unsigned char * sbptr;
257 257 unsigned char telnet_state;
258   - char ttype_tmpval[13];
  258 +// char ttype_tmpval[13];
259 259  
260 260 unsigned char myopts[LIB3270_TELNET_N_OPTS];
261 261 unsigned char hisopts[LIB3270_TELNET_N_OPTS];
... ...
src/lib3270/session.c
... ... @@ -177,11 +177,71 @@ static void nop_int(H3270 *session, int width)
177 177 return;
178 178 }
179 179  
180   -static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset)
  180 +int lib3270_set_model_name(H3270 *hSession, const char *model)
181 181 {
182 182 int ovc, ovr;
183 183 char junk;
184 184 int model_number;
  185 +
  186 + if(hSession->cstate != LIB3270_NOT_CONNECTED)
  187 + return EBUSY;
  188 +
  189 + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
  190 + hSession->model_name = &hSession->full_model_name[4];
  191 +
  192 + if(!*model)
  193 + model = "2"; // No model, use the default one
  194 +
  195 + model_number = parse_model_number(hSession,model);
  196 + if (model_number < 0)
  197 + {
  198 + popup_an_error(hSession,"Invalid model number: %s", model);
  199 + model_number = 0;
  200 + }
  201 +
  202 + if (!model_number)
  203 + {
  204 +#if defined(RESTRICT_3279)
  205 + model_number = 3;
  206 +#else
  207 + model_number = 4;
  208 +#endif
  209 + }
  210 +
  211 + if(hSession->mono)
  212 + hSession->m3279 = 0;
  213 + else
  214 + hSession->m3279 = 1;
  215 +
  216 + if(!hSession->extended)
  217 + hSession->oversize = CN;
  218 +
  219 +#if defined(RESTRICT_3279)
  220 + if (hSession->m3279 && model_number == 4)
  221 + model_number = 3;
  222 +#endif
  223 +
  224 + trace("Model_number: %d",model_number);
  225 +
  226 + if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2)
  227 + {
  228 + ovc = 0;
  229 + ovr = 0;
  230 + }
  231 + ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
  232 +
  233 + if (hSession->termname != CN)
  234 + hSession->termtype = hSession->termname;
  235 + else
  236 + hSession->termtype = hSession->full_model_name;
  237 +
  238 + trace("Termtype: %s",hSession->termtype);
  239 +
  240 + return 0;
  241 +}
  242 +
  243 +static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset)
  244 +{
185 245 int f;
186 246  
187 247 memset(hSession,0,sizeof(H3270));
... ... @@ -248,59 +308,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char
248 308 // Initialize toggles
249 309 initialize_toggles(hSession);
250 310  
251   - strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
252   - hSession->model_name = &hSession->full_model_name[4];
253   -
254   - if(!*model)
255   - model = "2"; // No model, use the default one
256   -
257   - model_number = parse_model_number(hSession,model);
258   - if (model_number < 0)
259   - {
260   - popup_an_error(hSession,"Invalid model number: %s", model);
261   - model_number = 0;
262   - }
263   -
264   - if (!model_number)
265   - {
266   -#if defined(RESTRICT_3279)
267   - model_number = 3;
268   -#else
269   - model_number = 4;
270   -#endif
271   - }
272   -
273   - if(hSession->mono)
274   - hSession->m3279 = 0;
275   - else
276   - hSession->m3279 = 1;
277   -
278   - if(!hSession->extended)
279   - hSession->oversize = CN;
280   -
281   -#if defined(RESTRICT_3279)
282   - if (hSession->m3279 && model_number == 4)
283   - model_number = 3;
284   -#endif
285   -
286   - trace("Model_number: %d",model_number);
287   -
288   - if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2)
289   - {
290   - ovc = 0;
291   - ovr = 0;
292   - }
293   - ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
294   -
295   - if (hSession->termname != CN)
296   - hSession->termtype = hSession->termname;
297   - else
298   - hSession->termtype = hSession->full_model_name;
299   -
300   - trace("Termtype: %s",hSession->termtype);
301   -
302   -// if (hSession->apl_mode)
303   -// hSession->charset.host = "apl";
  311 + lib3270_set_model_name(hSession,model);
304 312  
305 313 }
306 314  
... ...
src/lib3270/telnet.c
... ... @@ -684,12 +684,13 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
684 684  
685 685 }
686 686  
687   - /* set up temporary termtype */
  687 + /* set up temporary termtype
688 688 if (session->termname == CN && session->std_ds_host)
689 689 {
690 690 sprintf(session->ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num);
691 691 session->termtype = session->ttype_tmpval;
692 692 }
  693 + */
693 694  
694 695 /* all done */
695 696 #if defined(_WIN32)
... ...