Commit 6a00696ce7a208d64696ba31aba7a1d406b86b4a
1 parent
63165a77
Exists in
master
and in
3 other branches
Ajustes para permitir configuracao de charset por sessao
Showing
5 changed files
with
48 additions
and
40 deletions
Show diff stats
charset.c
... | ... | @@ -88,19 +88,6 @@ static KeySym StringToKeysym(char *s); |
88 | 88 | // static void set_charset_name(char *csname); |
89 | 89 | // static char *charset_name = CN; |
90 | 90 | |
91 | -static void charset_defaults(H3270 *hSession) | |
92 | -{ | |
93 | - /* Go to defaults first. */ | |
94 | - (void) memcpy((char *) hSession->charset.ebc2cg, (const char *)ebc2cg0, 256); | |
95 | - (void) memcpy((char *) hSession->charset.cg2ebc, (const char *)cg2ebc0, 256); | |
96 | - (void) memcpy((char *) hSession->charset.ebc2asc, (const char *)ebc2asc0, 256); | |
97 | - (void) memcpy((char *) hSession->charset.asc2ebc, (const char *)asc2ebc0, 256); | |
98 | -#if defined(X3270_FT) /*[*/ | |
99 | - (void) memcpy((char *)hSession->charset.ft2asc, (const char *)ft2asc0, 256); | |
100 | - (void) memcpy((char *)hSession->charset.asc2ft, (const char *)asc2ft0, 256); | |
101 | -#endif /*]*/ | |
102 | - clear_xks(); | |
103 | -} | |
104 | 91 | |
105 | 92 | struct charset_buffer |
106 | 93 | { |
... | ... | @@ -498,9 +485,9 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop |
498 | 485 | |
499 | 486 | if (scope == BOTH || scope == CS_ONLY) { |
500 | 487 | if (iso <= 0xff) { |
501 | - cg = asc2cg[iso]; | |
488 | + cg = hSession->charset.asc2cg[iso]; | |
502 | 489 | |
503 | - if (cg2asc[cg] == iso || iso == 0) | |
490 | + if (hSession->charset.cg2asc[cg] == iso || iso == 0) | |
504 | 491 | { |
505 | 492 | /* well-defined */ |
506 | 493 | hSession->charset.ebc2cg[ebc] = cg; | ... | ... |
screen.c
... | ... | @@ -337,7 +337,7 @@ void screen_update(H3270 *session, int bstart, int bend) |
337 | 337 | else |
338 | 338 | { |
339 | 339 | if(lib3270_get_toggle(session,LIB3270_TOGGLE_MONOCASE)) |
340 | - addch(session,baddr,asc2uc[session->charset.ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); | |
340 | + addch(session,baddr,session->charset.asc2uc[session->charset.ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); | |
341 | 341 | else |
342 | 342 | addch(session,baddr,session->charset.ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); |
343 | 343 | } | ... | ... |
tables.c
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | #include "globals.h" |
42 | 42 | #include "tablesc.h" |
43 | 43 | |
44 | -const unsigned short asc2cg[256] = { | |
44 | +static const unsigned short asc2cg[256] = { | |
45 | 45 | /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
46 | 46 | /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
47 | 47 | /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
... | ... | @@ -75,7 +75,8 @@ const unsigned short asc2cg[256] = { |
75 | 75 | /*f0*/ 0xf7, 0x5f, 0x43, 0x5d, 0x58, 0x46, 0x53, 0x9d, |
76 | 76 | /*f8*/ 0x9b, 0x44, 0x5e, 0x59, 0x4e, 0x49, 0xf9, 0x47 |
77 | 77 | }; |
78 | -const unsigned short cg2asc[256] = { | |
78 | + | |
79 | +static const unsigned short cg2asc[256] = { | |
79 | 80 | /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xad, |
80 | 81 | /*08*/ 0x3e, 0x3c, 0x5b, 0x5d, 0x29, 0x28, 0x7d, 0x7b, |
81 | 82 | /*10*/ 0x20, 0x3d, 0x27, 0x22, 0x2f, 0x5c, 0x7c, 0xa6, |
... | ... | @@ -110,7 +111,7 @@ const unsigned short cg2asc[256] = { |
110 | 111 | /*f8*/ 0x20, 0xfe, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 |
111 | 112 | }; |
112 | 113 | |
113 | -const unsigned short ebc2cg0[256] = { | |
114 | +static const unsigned short ebc2cg0[256] = { | |
114 | 115 | /*00*/ 0x00, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, |
115 | 116 | /*08*/ 0xdf, 0xdf, 0xdf, 0xdf, 0x02, 0x03, 0x00, 0x00, |
116 | 117 | /*10*/ 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0x04, 0xdf, 0xdf, |
... | ... | @@ -145,7 +146,7 @@ const unsigned short ebc2cg0[256] = { |
145 | 146 | /*f8*/ 0x28, 0x29, 0x69, 0x79, 0x74, 0x64, 0x7e, 0x06 |
146 | 147 | }; |
147 | 148 | |
148 | -const unsigned short cg2ebc0[256] = { | |
149 | +static const unsigned short cg2ebc0[256] = { | |
149 | 150 | /*00*/ 0x00, 0x41, 0x0c, 0x0d, 0x15, 0x19, 0xff, 0xca, |
150 | 151 | /*08*/ 0x6e, 0x4c, 0xba, 0xbb, 0x5d, 0x4d, 0xd0, 0xc0, |
151 | 152 | /*10*/ 0x40, 0x7e, 0x7d, 0x7f, 0x61, 0xe0, 0x4f, 0x6a, |
... | ... | @@ -216,7 +217,7 @@ const unsigned short ebc2asc0[256] = { |
216 | 217 | }; |
217 | 218 | |
218 | 219 | #ifdef EXTENDED_TABLES |
219 | -const unsigned short ebc2asc70[256] = { | |
220 | +static const unsigned short ebc2asc70[256] = { | |
220 | 221 | /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
221 | 222 | /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
222 | 223 | /*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
... | ... | @@ -252,7 +253,7 @@ const unsigned short ebc2asc70[256] = { |
252 | 253 | }; |
253 | 254 | #endif // EXTENDED_TABLES |
254 | 255 | |
255 | -const unsigned short asc2ebc0[256] = { | |
256 | +static const unsigned short asc2ebc0[256] = { | |
256 | 257 | /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
257 | 258 | /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
258 | 259 | /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
... | ... | @@ -288,7 +289,7 @@ const unsigned short asc2ebc0[256] = { |
288 | 289 | }; |
289 | 290 | |
290 | 291 | #ifdef EXTENDED_TABLES |
291 | -const unsigned short ge2asc[256] = { | |
292 | +static const unsigned short ge2asc[256] = { | |
292 | 293 | /*00*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
293 | 294 | /*08*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
294 | 295 | /*10*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
... | ... | @@ -324,7 +325,7 @@ const unsigned short ge2asc[256] = { |
324 | 325 | }; |
325 | 326 | #endif // EXTENDED_TABLES |
326 | 327 | |
327 | -const unsigned short asc2uc[256] = { | |
328 | +static const unsigned short asc2uc[256] = { | |
328 | 329 | /*00*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
329 | 330 | /*08*/ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
330 | 331 | /*10*/ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
... | ... | @@ -358,7 +359,8 @@ const unsigned short asc2uc[256] = { |
358 | 359 | /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, |
359 | 360 | /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff |
360 | 361 | }; |
361 | -const unsigned short ebc2uc[256] = { | |
362 | + | |
363 | +static const unsigned short ebc2uc[256] = { | |
362 | 364 | /*00*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
363 | 365 | /*08*/ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
364 | 366 | /*10*/ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
... | ... | @@ -394,7 +396,7 @@ const unsigned short ebc2uc[256] = { |
394 | 396 | }; |
395 | 397 | #if defined(X3270_FT) /*[*/ |
396 | 398 | |
397 | -const unsigned short ft2asc0[256] = { | |
399 | +static const unsigned short ft2asc0[256] = { | |
398 | 400 | 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, |
399 | 401 | 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, |
400 | 402 | 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
... | ... | @@ -451,6 +453,9 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) |
451 | 453 | memcpy(hSession->charset.cg2ebc, cg2ebc0, sizeof(hSession->charset.cg2ebc)); |
452 | 454 | memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); |
453 | 455 | memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc)); |
456 | + memcpy(hSession->charset.asc2uc, asc2uc, sizeof(hSession->charset.asc2uc)); | |
457 | + memcpy(hSession->charset.asc2cg, asc2cg, sizeof(hSession->charset.asc2cg)); | |
458 | + memcpy(hSession->charset.cg2asc, cg2asc, sizeof(hSession->charset.cg2asc)); | |
454 | 459 | |
455 | 460 | #ifdef EXTENDED_TABLES |
456 | 461 | memcpy(ebc2asc7, ebc2asc70, sizeof(ebc2asc7)); |
... | ... | @@ -462,3 +467,17 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) |
462 | 467 | #endif /*]*/ |
463 | 468 | |
464 | 469 | } |
470 | + | |
471 | +void charset_defaults(H3270 *hSession) | |
472 | +{ | |
473 | + /* Go to defaults first. */ | |
474 | + (void) memcpy((char *) hSession->charset.ebc2cg, (const char *)ebc2cg0, 256); | |
475 | + (void) memcpy((char *) hSession->charset.cg2ebc, (const char *)cg2ebc0, 256); | |
476 | + (void) memcpy((char *) hSession->charset.ebc2asc, (const char *)ebc2asc0, 256); | |
477 | + (void) memcpy((char *) hSession->charset.asc2ebc, (const char *)asc2ebc0, 256); | |
478 | +#if defined(X3270_FT) /*[*/ | |
479 | + (void) memcpy((char *)hSession->charset.ft2asc, (const char *)ft2asc0, 256); | |
480 | + (void) memcpy((char *)hSession->charset.asc2ft, (const char *)asc2ft0, 256); | |
481 | +#endif /*]*/ | |
482 | + clear_xks(); | |
483 | +} | ... | ... |
tablesc.h
... | ... | @@ -17,6 +17,8 @@ |
17 | 17 | * Global declarations for tables.c. |
18 | 18 | */ |
19 | 19 | LIB3270_INTERNAL void initialize_tables(H3270 *hSession); |
20 | +LIB3270_INTERNAL void charset_defaults(H3270 *hSession); | |
21 | + | |
20 | 22 | // LIB3270_INTERNAL unsigned short ebc2cg[256]; |
21 | 23 | // LIB3270_INTERNAL unsigned short cg2ebc[256]; |
22 | 24 | // LIB3270_INTERNAL unsigned short ebc2asc[256]; |
... | ... | @@ -25,18 +27,18 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession); |
25 | 27 | // LIB3270_INTERNAL unsigned short asc2ft[256]; |
26 | 28 | |
27 | 29 | #ifdef EXTENDED_TABLES |
28 | -LIB3270_INTERNAL unsigned short ebc2asc7[256]; | |
29 | -LIB3270_INTERNAL const unsigned short ebc2asc70[256]; | |
30 | -LIB3270_INTERNAL const unsigned short ge2asc[256]; | |
30 | +// LIB3270_INTERNAL unsigned short ebc2asc7[256]; | |
31 | +// LIB3270_INTERNAL const unsigned short ebc2asc70[256]; | |
32 | +// LIB3270_INTERNAL const unsigned short ge2asc[256]; | |
31 | 33 | #endif // EXTENDED_TABLES |
32 | 34 | |
33 | -LIB3270_INTERNAL const unsigned short asc2cg[256]; | |
34 | -LIB3270_INTERNAL const unsigned short cg2asc[256]; | |
35 | -LIB3270_INTERNAL const unsigned short ebc2cg0[256]; | |
36 | -LIB3270_INTERNAL const unsigned short cg2ebc0[256]; | |
37 | -LIB3270_INTERNAL const unsigned short ebc2asc0[256]; | |
38 | -LIB3270_INTERNAL const unsigned short asc2ebc0[256]; | |
39 | -LIB3270_INTERNAL const unsigned short asc2uc[256]; | |
40 | -LIB3270_INTERNAL const unsigned short ebc2uc[256]; | |
41 | -LIB3270_INTERNAL const unsigned short ft2asc0[256]; | |
42 | -LIB3270_INTERNAL const unsigned short asc2ft0[256]; | |
35 | +// LIB3270_INTERNAL const unsigned short asc2cg[256]; | |
36 | +// LIB3270_INTERNAL const unsigned short cg2asc[256]; | |
37 | +// LIB3270_INTERNAL const unsigned short ebc2cg0[256]; | |
38 | +// LIB3270_INTERNAL const unsigned short cg2ebc0[256]; | |
39 | + LIB3270_INTERNAL const unsigned short ebc2asc0[256]; | |
40 | +// LIB3270_INTERNAL const unsigned short asc2ebc0[256]; | |
41 | +// LIB3270_INTERNAL const unsigned short asc2uc[256]; | |
42 | +// LIB3270_INTERNAL const unsigned short ebc2uc[256]; | |
43 | +// LIB3270_INTERNAL const unsigned short ft2asc0[256]; | |
44 | + LIB3270_INTERNAL const unsigned short asc2ft0[256]; | ... | ... |
telnet.c
... | ... | @@ -1966,7 +1966,7 @@ static void process_bind(H3270 *hSession, unsigned char *buf, int buflen) |
1966 | 1966 | if (namelen > BIND_PLU_NAME_MAX) |
1967 | 1967 | namelen = BIND_PLU_NAME_MAX; |
1968 | 1968 | for (i = 0; i < namelen; i++) { |
1969 | - hSession->plu_name[i] = ebc2asc0[buf[BIND_OFF_PLU_NAME + i]]; | |
1969 | + hSession->plu_name[i] = hSession->charset.ebc2asc[buf[BIND_OFF_PLU_NAME + i]]; | |
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | #endif /*]*/ | ... | ... |