Commit 93d8be1344ffab8286eddada01a58f64f4a2047f
1 parent
cd358ad9
Exists in
master
and in
3 other branches
Incluindo opcao de linha de comando para definir o modelo do terminal
Showing
3 changed files
with
148 additions
and
147 deletions
Show diff stats
... | ... | @@ -314,8 +314,8 @@ |
314 | 314 | |
315 | 315 | #define query_3270_terminal_status(void) lib3270_get_program_message(NULL) |
316 | 316 | |
317 | - #define set_3270_model(h,m) lib3270_set_model(h,m) | |
318 | - #define get_3270_model(h) lib3270_get_model(h) | |
317 | +// #define set_3270_model(h,m) lib3270_set_model(h,m) | |
318 | +// #define get_3270_model(h) lib3270_get_model(h) | |
319 | 319 | |
320 | 320 | /* Get connection info */ |
321 | 321 | #define get_connected_lu(h) lib3270_get_luname(h) | ... | ... |
ctlr.c
... | ... | @@ -150,6 +150,84 @@ void ctlr_reinit(H3270 *session, unsigned cmask) |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | + /** | |
154 | + * Parse the model number. | |
155 | + * | |
156 | + * @param session Session Handle. | |
157 | + * @param m Model number. | |
158 | + * | |
159 | + * @return -1 (error), 0 (default), or the specified number. | |
160 | + */ | |
161 | +static int parse_model_number(H3270 *session, const char *m) | |
162 | +{ | |
163 | + int sl; | |
164 | + int n; | |
165 | + | |
166 | + if(!m) | |
167 | + return 0; | |
168 | + | |
169 | + sl = strlen(m); | |
170 | + | |
171 | + /* An empty model number is no good. */ | |
172 | + if (!sl) | |
173 | + return 0; | |
174 | + | |
175 | + if (sl > 1) { | |
176 | + /* | |
177 | + * If it's longer than one character, it needs to start with | |
178 | + * '327[89]', and it sets the m3279 resource. | |
179 | + */ | |
180 | + if (!strncmp(m, "3278", 4)) | |
181 | + { | |
182 | + session->m3279 = 0; | |
183 | + } | |
184 | + else if (!strncmp(m, "3279", 4)) | |
185 | + { | |
186 | + session->m3279 = 1; | |
187 | + } | |
188 | + else | |
189 | + { | |
190 | + return -1; | |
191 | + } | |
192 | + m += 4; | |
193 | + sl -= 4; | |
194 | + | |
195 | + /* Check more syntax. -E is allowed, but ignored. */ | |
196 | + switch (m[0]) { | |
197 | + case '\0': | |
198 | + /* Use default model number. */ | |
199 | + return 0; | |
200 | + case '-': | |
201 | + /* Model number specified. */ | |
202 | + m++; | |
203 | + sl--; | |
204 | + break; | |
205 | + default: | |
206 | + return -1; | |
207 | + } | |
208 | + switch (sl) { | |
209 | + case 1: /* n */ | |
210 | + break; | |
211 | + case 3: /* n-E */ | |
212 | + if (strcasecmp(m + 1, "-E")) { | |
213 | + return -1; | |
214 | + } | |
215 | + break; | |
216 | + default: | |
217 | + return -1; | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + /* Check the numeric model number. */ | |
222 | + n = atoi(m); | |
223 | + if (n >= 2 && n <= 5) { | |
224 | + return n; | |
225 | + } else { | |
226 | + return -1; | |
227 | + } | |
228 | + | |
229 | +} | |
230 | + | |
153 | 231 | /** |
154 | 232 | * Get current 3270 model. |
155 | 233 | * |
... | ... | @@ -166,7 +244,7 @@ int lib3270_get_model(H3270 *hSession) |
166 | 244 | * |
167 | 245 | * @param hSession Session handle. |
168 | 246 | * @param model New model (updates model name) |
169 | - */ | |
247 | + */ /* | |
170 | 248 | int lib3270_set_model(H3270 *hSession, int model) |
171 | 249 | { |
172 | 250 | if(CONNECTED) |
... | ... | @@ -176,6 +254,72 @@ int lib3270_set_model(H3270 *hSession, int model) |
176 | 254 | ctlr_reinit(hSession,MODEL_CHANGE); |
177 | 255 | screen_update(hSession,0,hSession->rows*hSession->cols); |
178 | 256 | return 0; |
257 | +} */ | |
258 | + | |
259 | +int lib3270_set_model(H3270 *hSession, const char *model) | |
260 | +{ | |
261 | + int ovc, ovr; | |
262 | + char junk; | |
263 | + int model_number; | |
264 | + | |
265 | + if(hSession->cstate != LIB3270_NOT_CONNECTED) | |
266 | + return EBUSY; | |
267 | + | |
268 | + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); | |
269 | + hSession->model_name = &hSession->full_model_name[4]; | |
270 | + | |
271 | + if(!*model) | |
272 | + model = "2"; // No model, use the default one | |
273 | + | |
274 | + model_number = parse_model_number(hSession,model); | |
275 | + if (model_number < 0) | |
276 | + { | |
277 | + popup_an_error(hSession,"Invalid model number: %s", model); | |
278 | + model_number = 0; | |
279 | + } | |
280 | + | |
281 | + if (!model_number) | |
282 | + { | |
283 | +#if defined(RESTRICT_3279) | |
284 | + model_number = 3; | |
285 | +#else | |
286 | + model_number = 4; | |
287 | +#endif | |
288 | + } | |
289 | + | |
290 | + if(hSession->mono) | |
291 | + hSession->m3279 = 0; | |
292 | + else | |
293 | + hSession->m3279 = 1; | |
294 | + | |
295 | + if(!hSession->extended) | |
296 | + hSession->oversize = CN; | |
297 | + | |
298 | +#if defined(RESTRICT_3279) | |
299 | + if (hSession->m3279 && model_number == 4) | |
300 | + model_number = 3; | |
301 | +#endif | |
302 | + | |
303 | + trace("Model_number: %d",model_number); | |
304 | + | |
305 | + if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) | |
306 | + { | |
307 | + ovc = 0; | |
308 | + ovr = 0; | |
309 | + } | |
310 | + ctlr_set_rows_cols(hSession, model_number, ovc, ovr); | |
311 | + | |
312 | + if (hSession->termname != CN) | |
313 | + hSession->termtype = hSession->termname; | |
314 | + else | |
315 | + hSession->termtype = hSession->full_model_name; | |
316 | + | |
317 | + trace("Termtype: %s",hSession->termtype); | |
318 | + | |
319 | + ctlr_reinit(hSession,MODEL_CHANGE); | |
320 | + screen_update(hSession,0,hSession->rows*hSession->cols); | |
321 | + | |
322 | + return 0; | |
179 | 323 | } |
180 | 324 | |
181 | 325 | void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) | ... | ... |
session.c
... | ... | @@ -54,8 +54,6 @@ |
54 | 54 | |
55 | 55 | /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ |
56 | 56 | |
57 | - static int parse_model_number(H3270 *session, const char *m); | |
58 | - | |
59 | 57 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
60 | 58 | |
61 | 59 | void lib3270_session_free(H3270 *h) |
... | ... | @@ -184,69 +182,6 @@ static void nop_int(H3270 *session, int width) |
184 | 182 | return; |
185 | 183 | } |
186 | 184 | |
187 | -int lib3270_set_model_name(H3270 *hSession, const char *model) | |
188 | -{ | |
189 | - int ovc, ovr; | |
190 | - char junk; | |
191 | - int model_number; | |
192 | - | |
193 | - if(hSession->cstate != LIB3270_NOT_CONNECTED) | |
194 | - return EBUSY; | |
195 | - | |
196 | - strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); | |
197 | - hSession->model_name = &hSession->full_model_name[4]; | |
198 | - | |
199 | - if(!*model) | |
200 | - model = "2"; // No model, use the default one | |
201 | - | |
202 | - model_number = parse_model_number(hSession,model); | |
203 | - if (model_number < 0) | |
204 | - { | |
205 | - popup_an_error(hSession,"Invalid model number: %s", model); | |
206 | - model_number = 0; | |
207 | - } | |
208 | - | |
209 | - if (!model_number) | |
210 | - { | |
211 | -#if defined(RESTRICT_3279) | |
212 | - model_number = 3; | |
213 | -#else | |
214 | - model_number = 4; | |
215 | -#endif | |
216 | - } | |
217 | - | |
218 | - if(hSession->mono) | |
219 | - hSession->m3279 = 0; | |
220 | - else | |
221 | - hSession->m3279 = 1; | |
222 | - | |
223 | - if(!hSession->extended) | |
224 | - hSession->oversize = CN; | |
225 | - | |
226 | -#if defined(RESTRICT_3279) | |
227 | - if (hSession->m3279 && model_number == 4) | |
228 | - model_number = 3; | |
229 | -#endif | |
230 | - | |
231 | - trace("Model_number: %d",model_number); | |
232 | - | |
233 | - if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) | |
234 | - { | |
235 | - ovc = 0; | |
236 | - ovr = 0; | |
237 | - } | |
238 | - ctlr_set_rows_cols(hSession, model_number, ovc, ovr); | |
239 | - | |
240 | - if (hSession->termname != CN) | |
241 | - hSession->termtype = hSession->termname; | |
242 | - else | |
243 | - hSession->termtype = hSession->full_model_name; | |
244 | - | |
245 | - trace("Termtype: %s",hSession->termtype); | |
246 | - | |
247 | - return 0; | |
248 | -} | |
249 | - | |
250 | 185 | static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) |
251 | 186 | { |
252 | 187 | int f; |
... | ... | @@ -313,7 +248,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
313 | 248 | // Initialize toggles |
314 | 249 | initialize_toggles(hSession); |
315 | 250 | |
316 | - lib3270_set_model_name(hSession,model); | |
251 | + lib3270_set_model(hSession,model); | |
317 | 252 | |
318 | 253 | } |
319 | 254 | |
... | ... | @@ -357,84 +292,6 @@ H3270 * lib3270_session_new(const char *model) |
357 | 292 | return hSession; |
358 | 293 | } |
359 | 294 | |
360 | - /** | |
361 | - * Parse the model number. | |
362 | - * | |
363 | - * @param session Session Handle. | |
364 | - * @param m Model number. | |
365 | - * | |
366 | - * @return -1 (error), 0 (default), or the specified number. | |
367 | - */ | |
368 | -static int parse_model_number(H3270 *session, const char *m) | |
369 | -{ | |
370 | - int sl; | |
371 | - int n; | |
372 | - | |
373 | - if(!m) | |
374 | - return 0; | |
375 | - | |
376 | - sl = strlen(m); | |
377 | - | |
378 | - /* An empty model number is no good. */ | |
379 | - if (!sl) | |
380 | - return 0; | |
381 | - | |
382 | - if (sl > 1) { | |
383 | - /* | |
384 | - * If it's longer than one character, it needs to start with | |
385 | - * '327[89]', and it sets the m3279 resource. | |
386 | - */ | |
387 | - if (!strncmp(m, "3278", 4)) | |
388 | - { | |
389 | - session->m3279 = 0; | |
390 | - } | |
391 | - else if (!strncmp(m, "3279", 4)) | |
392 | - { | |
393 | - session->m3279 = 1; | |
394 | - } | |
395 | - else | |
396 | - { | |
397 | - return -1; | |
398 | - } | |
399 | - m += 4; | |
400 | - sl -= 4; | |
401 | - | |
402 | - /* Check more syntax. -E is allowed, but ignored. */ | |
403 | - switch (m[0]) { | |
404 | - case '\0': | |
405 | - /* Use default model number. */ | |
406 | - return 0; | |
407 | - case '-': | |
408 | - /* Model number specified. */ | |
409 | - m++; | |
410 | - sl--; | |
411 | - break; | |
412 | - default: | |
413 | - return -1; | |
414 | - } | |
415 | - switch (sl) { | |
416 | - case 1: /* n */ | |
417 | - break; | |
418 | - case 3: /* n-E */ | |
419 | - if (strcasecmp(m + 1, "-E")) { | |
420 | - return -1; | |
421 | - } | |
422 | - break; | |
423 | - default: | |
424 | - return -1; | |
425 | - } | |
426 | - } | |
427 | - | |
428 | - /* Check the numeric model number. */ | |
429 | - n = atoi(m); | |
430 | - if (n >= 2 && n <= 5) { | |
431 | - return n; | |
432 | - } else { | |
433 | - return -1; | |
434 | - } | |
435 | - | |
436 | -} | |
437 | - | |
438 | 295 | #if defined(DEBUG) |
439 | 296 | void check_session_handle(H3270 **hSession, const char *fname) |
440 | 297 | #else | ... | ... |