Commit cfe92185ea984254bbb1b13aaf2362b86d756f57
1 parent
cf558eee
Exists in
master
and in
3 other branches
Iniciando implementação de charsets configurados
Showing
7 changed files
with
43 additions
and
40 deletions
Show diff stats
charset.c
... | ... | @@ -88,16 +88,16 @@ 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(void) | |
91 | +static void charset_defaults(H3270 *hSession) | |
92 | 92 | { |
93 | 93 | /* Go to defaults first. */ |
94 | - (void) memcpy((char *)ebc2cg, (const char *)ebc2cg0, 256); | |
95 | - (void) memcpy((char *)cg2ebc, (const char *)cg2ebc0, 256); | |
96 | - (void) memcpy((char *)ebc2asc, (const char *)ebc2asc0, 256); | |
97 | - (void) memcpy((char *)asc2ebc, (const char *)asc2ebc0, 256); | |
94 | + (void) memcpy((char *)ebc2cg, (const char *)ebc2cg0, 256); | |
95 | + (void) memcpy((char *)cg2ebc, (const char *)cg2ebc0, 256); | |
96 | + (void) memcpy((char *) hSession->charset.ebc2asc, (const char *)ebc2asc0, 256); | |
97 | + (void) memcpy((char *)asc2ebc, (const char *)asc2ebc0, 256); | |
98 | 98 | #if defined(X3270_FT) /*[*/ |
99 | - (void) memcpy((char *)ft2asc, (const char *)ft2asc0, 256); | |
100 | - (void) memcpy((char *)asc2ft, (const char *)asc2ft0, 256); | |
99 | + (void) memcpy((char *)ft2asc, (const char *)ft2asc0, 256); | |
100 | + (void) memcpy((char *)asc2ft, (const char *)asc2ft0, 256); | |
101 | 101 | #endif /*]*/ |
102 | 102 | clear_xks(); |
103 | 103 | } |
... | ... | @@ -116,11 +116,11 @@ struct charset_buffer |
116 | 116 | }; |
117 | 117 | |
118 | 118 | |
119 | -static void save_charset(struct charset_buffer *save) | |
119 | +static void save_charset(H3270 *hSession, struct charset_buffer *save) | |
120 | 120 | { |
121 | 121 | (void) memcpy((char *)save->ebc2cg, (char *)ebc2cg, 256); |
122 | 122 | (void) memcpy((char *)save->cg2ebc, (char *)cg2ebc, 256); |
123 | - (void) memcpy((char *)save->ebc2asc, (char *)ebc2asc, 256); | |
123 | + (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); | |
124 | 124 | (void) memcpy((char *)save->asc2ebc, (char *)asc2ebc, 256); |
125 | 125 | #if defined(X3270_FT) /*[*/ |
126 | 126 | (void) memcpy((char *)save->ft2asc, (char *)ft2asc, 256); |
... | ... | @@ -128,11 +128,11 @@ static void save_charset(struct charset_buffer *save) |
128 | 128 | #endif /*]*/ |
129 | 129 | } |
130 | 130 | |
131 | -static void restore_charset(struct charset_buffer *save) | |
131 | +static void restore_charset(H3270 *hSession, struct charset_buffer *save) | |
132 | 132 | { |
133 | 133 | (void) memcpy((char *)ebc2cg, (char *)save->ebc2cg, 256); |
134 | 134 | (void) memcpy((char *)cg2ebc, (char *)save->cg2ebc, 256); |
135 | - (void) memcpy((char *)ebc2asc, (char *)save->ebc2asc, 256); | |
135 | + (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); | |
136 | 136 | (void) memcpy((char *)asc2ebc, (char *)save->asc2ebc, 256); |
137 | 137 | #if defined(X3270_FT) /*[*/ |
138 | 138 | (void) memcpy((char *)ft2asc, (char *)save->ft2asc, 256); |
... | ... | @@ -189,7 +189,7 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) |
189 | 189 | /* Do nothing, successfully. */ |
190 | 190 | if (csname == CN || !strcasecmp(csname, "us")) |
191 | 191 | { |
192 | - charset_defaults(); | |
192 | + charset_defaults(hSession); | |
193 | 193 | set_cgcsgids(hSession,CN); |
194 | 194 | set_display_charset(hSession, "ISO-8859-1"); |
195 | 195 | return CS_OKAY; |
... | ... | @@ -220,8 +220,8 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) |
220 | 220 | cftcs = lib3270_get_resource_string(hSession,"ftCharset",csname,NULL); |
221 | 221 | |
222 | 222 | /* Save the current definitions, and start over with the defaults. */ |
223 | - save_charset(&save); | |
224 | - charset_defaults(); | |
223 | + save_charset(hSession,&save); | |
224 | + charset_defaults(hSession); | |
225 | 225 | |
226 | 226 | /* Check for auto-keymap. */ |
227 | 227 | ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); |
... | ... | @@ -243,7 +243,7 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) |
243 | 243 | #endif /*]*/ |
244 | 244 | |
245 | 245 | if (rc != CS_OKAY) |
246 | - restore_charset(&save); | |
246 | + restore_charset(hSession,&save); | |
247 | 247 | |
248 | 248 | /* |
249 | 249 | #if defined(X3270_DBCS) |
... | ... | @@ -515,7 +515,7 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop |
515 | 515 | } |
516 | 516 | if (ebc > 0x40) |
517 | 517 | { |
518 | - ebc2asc[ebc] = iso; | |
518 | + hSession->charset.ebc2asc[ebc] = iso; | |
519 | 519 | if (!one_way) |
520 | 520 | asc2ebc[iso] = ebc; |
521 | 521 | } |
... | ... | @@ -548,14 +548,14 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop |
548 | 548 | * and the ISO code that we would normally |
549 | 549 | * use to display that EBCDIC code. |
550 | 550 | */ |
551 | - ft2asc[iso] = ebc2asc[ebc]; | |
552 | - asc2ft[ebc2asc[ebc]] = iso; | |
551 | + ft2asc[iso] = hSession->charset.ebc2asc[ebc]; | |
552 | + asc2ft[hSession->charset.ebc2asc[ebc]] = iso; | |
553 | 553 | } |
554 | 554 | } |
555 | 555 | #endif /*]*/ |
556 | 556 | } else { |
557 | 557 | /* Auto-keymap. */ |
558 | - add_xk(iso, (KeySym)ebc2asc[ebc]); | |
558 | + add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); | |
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
... | ... | @@ -638,7 +638,7 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe |
638 | 638 | for (i = 0; i < 256; i++) { |
639 | 639 | if ((i & 0x7f) > 0x20 && i != 0x7f && |
640 | 640 | asc2ebc[i] != 0 && |
641 | - ebc2asc[asc2ebc[i]] != i) { | |
641 | + hSession->charset.ebc2asc[asc2ebc[i]] != i) { | |
642 | 642 | asc2ebc[i] = 0; |
643 | 643 | } |
644 | 644 | } |
... | ... | @@ -723,7 +723,7 @@ check_charset(void) |
723 | 723 | |
724 | 724 | void set_display_charset(H3270 *session, const char *dcs) |
725 | 725 | { |
726 | - session->charset = strdup(dcs); | |
726 | + session->charset.display = strdup(dcs); | |
727 | 727 | } |
728 | 728 | |
729 | 729 | LIB3270_EXPORT const char * lib3270_get_default_charset(void) |
... | ... | @@ -731,10 +731,10 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void) |
731 | 731 | return "ISO-8859-1"; |
732 | 732 | } |
733 | 733 | |
734 | -LIB3270_EXPORT const char * lib3270_get_charset(H3270 *session) | |
734 | +LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession) | |
735 | 735 | { |
736 | - CHECK_SESSION_HANDLE(session); | |
737 | - return session->charset ? session->charset : lib3270_get_default_charset(); | |
736 | + CHECK_SESSION_HANDLE(hSession); | |
737 | + return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; | |
738 | 738 | } |
739 | 739 | |
740 | 740 | static KeySym StringToKeysym(char *s) | ... | ... |
ft_cut.c
... | ... | @@ -167,7 +167,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) |
167 | 167 | } |
168 | 168 | |
169 | 169 | /* Translate to a quadrant index. */ |
170 | - ixp = strchr(alphas, ebc2asc[c]); | |
170 | + ixp = strchr(alphas, hSession->charset.ebc2asc[c]); | |
171 | 171 | if (ixp == (char *)NULL) |
172 | 172 | { |
173 | 173 | /* Try a different quadrant. */ |
... | ... | @@ -349,7 +349,7 @@ static void cut_control_code(H3270 *hSession) |
349 | 349 | bp = buf = lib3270_malloc(81); |
350 | 350 | |
351 | 351 | for (i = 0; i < 80; i++) |
352 | - *bp++ = ebc2asc[hSession->ea_buf[O_CC_MESSAGE + i].cc]; | |
352 | + *bp++ = hSession->charset.ebc2asc[hSession->ea_buf[O_CC_MESSAGE + i].cc]; | |
353 | 353 | |
354 | 354 | *bp-- = '\0'; |
355 | 355 | |
... | ... | @@ -465,9 +465,11 @@ static void cut_retransmit(H3270 *hSession) |
465 | 465 | static unsigned |
466 | 466 | from6(unsigned char c) |
467 | 467 | { |
468 | + H3270 *hSession = lib3270_get_default_session_handle(); | |
469 | + | |
468 | 470 | char *p; |
469 | 471 | |
470 | - c = ebc2asc[c]; | |
472 | + c = hSession->charset.ebc2asc[c]; | |
471 | 473 | p = strchr(table6, c); |
472 | 474 | if (p == CN) |
473 | 475 | return 0; | ... | ... |
screen.c
... | ... | @@ -337,9 +337,9 @@ 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[ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); | |
340 | + addch(session,baddr,asc2uc[session->charset.ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); | |
341 | 341 | else |
342 | - addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); | |
342 | + addch(session,baddr,session->charset.ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); | |
343 | 343 | } |
344 | 344 | } |
345 | 345 | } | ... | ... |
... | ... | @@ -64,6 +64,7 @@ unknown(unsigned char value) |
64 | 64 | const char * |
65 | 65 | see_ebc(unsigned char ch) |
66 | 66 | { |
67 | + H3270 *hSession = lib3270_get_default_session_handle(); | |
67 | 68 | static char buf[8]; |
68 | 69 | |
69 | 70 | switch (ch) { |
... | ... | @@ -91,8 +92,8 @@ see_ebc(unsigned char ch) |
91 | 92 | return "SO"; |
92 | 93 | } |
93 | 94 | |
94 | - if (ebc2asc[ch]) | |
95 | - (void) sprintf(buf,"%c", ebc2asc[ch]); | |
95 | + if (hSession->charset.ebc2asc[ch]) | |
96 | + (void) sprintf(buf,"%c", hSession->charset.ebc2asc[ch]); | |
96 | 97 | else |
97 | 98 | (void) sprintf(buf, "\\%o", ch); |
98 | 99 | ... | ... |
session.c
... | ... | @@ -84,7 +84,7 @@ void lib3270_session_free(H3270 *h) |
84 | 84 | // Release memory |
85 | 85 | #define release_pointer(x) lib3270_free(x); x = NULL; |
86 | 86 | |
87 | - release_pointer(h->charset); | |
87 | + release_pointer(h->charset.display); | |
88 | 88 | release_pointer(h->paste_buffer); |
89 | 89 | |
90 | 90 | release_pointer(h->ibuf); |
... | ... | @@ -218,7 +218,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
218 | 218 | hSession->unlock_delay = 1; |
219 | 219 | hSession->icrnl = 1; |
220 | 220 | hSession->onlcr = 1; |
221 | - hSession->host_charset = "bracket"; | |
221 | + hSession->charset.host = "bracket"; | |
222 | 222 | hSession->sock = -1; |
223 | 223 | hSession->model_num = -1; |
224 | 224 | hSession->cstate = LIB3270_NOT_CONNECTED; |
... | ... | @@ -300,7 +300,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
300 | 300 | trace("Termtype: %s",hSession->termtype); |
301 | 301 | |
302 | 302 | if (hSession->apl_mode) |
303 | - hSession->host_charset = "apl"; | |
303 | + hSession->charset.host = "apl"; | |
304 | 304 | |
305 | 305 | } |
306 | 306 | |
... | ... | @@ -324,10 +324,10 @@ H3270 * lib3270_session_new(const char *model) |
324 | 324 | if(screen_init(hSession)) |
325 | 325 | return NULL; |
326 | 326 | |
327 | - trace("Charset: %s",hSession->host_charset); | |
328 | - if (charset_init(hSession,hSession->host_charset) != CS_OKAY) | |
327 | + trace("Charset: %s",hSession->charset.host); | |
328 | + if (charset_init(hSession,hSession->charset.host) != CS_OKAY) | |
329 | 329 | { |
330 | - Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->host_charset); | |
330 | + Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->charset.host); | |
331 | 331 | (void) charset_init(hSession,CN); |
332 | 332 | } |
333 | 333 | ... | ... |
tables.c
... | ... | @@ -436,7 +436,7 @@ const unsigned short asc2ft0[256] = { |
436 | 436 | |
437 | 437 | unsigned short ebc2cg[256]; |
438 | 438 | unsigned short cg2ebc[256]; |
439 | -unsigned short ebc2asc[256]; | |
439 | +// unsigned short ebc2asc[256]; | |
440 | 440 | unsigned short asc2ebc[256]; |
441 | 441 | unsigned short asc2ft[256]; |
442 | 442 | unsigned short ft2asc[256]; |
... | ... | @@ -449,7 +449,7 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) |
449 | 449 | /* Go to defaults first. */ |
450 | 450 | memcpy(ebc2cg, ebc2cg0, sizeof(ebc2cg)); |
451 | 451 | memcpy(cg2ebc, cg2ebc0, sizeof(cg2ebc)); |
452 | - memcpy(ebc2asc, ebc2asc0, sizeof(ebc2asc)); | |
452 | + memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); | |
453 | 453 | memcpy(asc2ebc, asc2ebc0, sizeof(asc2ebc)); |
454 | 454 | |
455 | 455 | #ifdef EXTENDED_TABLES | ... | ... |
tablesc.h
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | LIB3270_INTERNAL void initialize_tables(H3270 *hSession); |
20 | 20 | LIB3270_INTERNAL unsigned short ebc2cg[256]; |
21 | 21 | LIB3270_INTERNAL unsigned short cg2ebc[256]; |
22 | -LIB3270_INTERNAL unsigned short ebc2asc[256]; | |
22 | +// LIB3270_INTERNAL unsigned short ebc2asc[256]; | |
23 | 23 | LIB3270_INTERNAL unsigned short asc2ebc[256]; |
24 | 24 | LIB3270_INTERNAL unsigned short ft2asc[256]; |
25 | 25 | LIB3270_INTERNAL unsigned short asc2ft[256]; | ... | ... |