From 63165a77f95dc9b6099322624331c08cd2ae8429 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 23 Aug 2013 21:03:03 +0000 Subject: [PATCH] Trabalhando nas tabelas de conversao --- ansi.c | 6 +++--- charset.c | 52 ++++++++++++++++++++++++++-------------------------- ft_cut.c | 15 ++++++++------- ft_dft.c | 6 +++--- kybd.c | 2 +- rpq.c | 6 +++--- tables.c | 20 ++++++++++---------- tablesc.h | 10 +++++----- 8 files changed, 59 insertions(+), 58 deletions(-) diff --git a/ansi.c b/ansi.c index 9774c34..ab48269 100644 --- a/ansi.c +++ b/ansi.c @@ -1090,16 +1090,16 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) if (hSession->ansi_ch >= 0x5f && hSession->ansi_ch <= 0x7e) ctlr_add(hSession,hSession->cursor_addr, (unsigned char)(hSession->ansi_ch - 0x5f),CS_LINEDRAW); else - ctlr_add(hSession,hSession->cursor_addr, asc2ebc[hSession->ansi_ch], CS_BASE); + ctlr_add(hSession,hSession->cursor_addr, hSession->charset.asc2ebc[hSession->ansi_ch], CS_BASE); break; case CSD_UK: /* UK "A" */ if (hSession->ansi_ch == '#') ctlr_add(hSession,hSession->cursor_addr, 0x1e, CS_LINEDRAW); else - ctlr_add(hSession,hSession->cursor_addr, asc2ebc[hSession->ansi_ch], CS_BASE); + ctlr_add(hSession,hSession->cursor_addr, hSession->charset.asc2ebc[hSession->ansi_ch], CS_BASE); break; case CSD_US: /* US "B" */ - ebc_ch = asc2ebc[hSession->ansi_ch]; + ebc_ch = hSession->charset.asc2ebc[hSession->ansi_ch]; #if defined(X3270_DBCS) /*[*/ d = ctlr_dbcs_state(cursor_addr); if (dbcs) { diff --git a/charset.c b/charset.c index ddedc00..2eb719f 100644 --- a/charset.c +++ b/charset.c @@ -91,13 +91,13 @@ static KeySym StringToKeysym(char *s); static void charset_defaults(H3270 *hSession) { /* Go to defaults first. */ - (void) memcpy((char *)ebc2cg, (const char *)ebc2cg0, 256); - (void) memcpy((char *)cg2ebc, (const char *)cg2ebc0, 256); + (void) memcpy((char *) hSession->charset.ebc2cg, (const char *)ebc2cg0, 256); + (void) memcpy((char *) hSession->charset.cg2ebc, (const char *)cg2ebc0, 256); (void) memcpy((char *) hSession->charset.ebc2asc, (const char *)ebc2asc0, 256); - (void) memcpy((char *)asc2ebc, (const char *)asc2ebc0, 256); + (void) memcpy((char *) hSession->charset.asc2ebc, (const char *)asc2ebc0, 256); #if defined(X3270_FT) /*[*/ - (void) memcpy((char *)ft2asc, (const char *)ft2asc0, 256); - (void) memcpy((char *)asc2ft, (const char *)asc2ft0, 256); + (void) memcpy((char *)hSession->charset.ft2asc, (const char *)ft2asc0, 256); + (void) memcpy((char *)hSession->charset.asc2ft, (const char *)asc2ft0, 256); #endif /*]*/ clear_xks(); } @@ -118,25 +118,25 @@ struct charset_buffer static void save_charset(H3270 *hSession, struct charset_buffer *save) { - (void) memcpy((char *)save->ebc2cg, (char *)ebc2cg, 256); - (void) memcpy((char *)save->cg2ebc, (char *)cg2ebc, 256); + (void) memcpy((char *)save->ebc2cg, (char *) hSession->charset.ebc2cg, 256); + (void) memcpy((char *)save->cg2ebc, (char *) hSession->charset.cg2ebc, 256); (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); - (void) memcpy((char *)save->asc2ebc, (char *)asc2ebc, 256); + (void) memcpy((char *)save->asc2ebc, (char *) hSession->charset.asc2ebc, 256); #if defined(X3270_FT) /*[*/ - (void) memcpy((char *)save->ft2asc, (char *)ft2asc, 256); - (void) memcpy((char *)save->asc2ft, (char *)asc2ft, 256); + (void) memcpy((char *)save->ft2asc, (char *) hSession->charset.ft2asc, 256); + (void) memcpy((char *)save->asc2ft, (char *) hSession->charset.asc2ft, 256); #endif /*]*/ } static void restore_charset(H3270 *hSession, struct charset_buffer *save) { - (void) memcpy((char *)ebc2cg, (char *)save->ebc2cg, 256); - (void) memcpy((char *)cg2ebc, (char *)save->cg2ebc, 256); + (void) memcpy((char *)hSession->charset.ebc2cg, (char *)save->ebc2cg, 256); + (void) memcpy((char *)hSession->charset.cg2ebc, (char *)save->cg2ebc, 256); (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); - (void) memcpy((char *)asc2ebc, (char *)save->asc2ebc, 256); + (void) memcpy((char *)hSession->charset.asc2ebc, (char *)save->asc2ebc, 256); #if defined(X3270_FT) /*[*/ - (void) memcpy((char *)ft2asc, (char *)save->ft2asc, 256); - (void) memcpy((char *)asc2ft, (char *)save->asc2ft, 256); + (void) memcpy((char *)hSession->charset.ft2asc, (char *)save->ft2asc, 256); + (void) memcpy((char *)hSession->charset.asc2ft, (char *)save->asc2ft, 256); #endif /*]*/ } @@ -503,21 +503,21 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop if (cg2asc[cg] == iso || iso == 0) { /* well-defined */ - ebc2cg[ebc] = cg; + hSession->charset.ebc2cg[ebc] = cg; if (!one_way) - cg2ebc[cg] = ebc; + hSession->charset.cg2ebc[cg] = ebc; } else { /* into a hole */ - ebc2cg[ebc] = CG_boxsolid; + hSession->charset.ebc2cg[ebc] = CG_boxsolid; } } if (ebc > 0x40) { hSession->charset.ebc2asc[ebc] = iso; if (!one_way) - asc2ebc[iso] = ebc; + hSession->charset.asc2ebc[iso] = ebc; } } #if defined(X3270_FT) /*[*/ @@ -537,8 +537,8 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop */ aa = asc2ft0[ebc2asc0[ebc]]; if (aa != ' ') { - ft2asc[aa] = iso; - asc2ft[iso] = aa; + hSession->charset.ft2asc[aa] = iso; + hSession->charset.asc2ft[iso] = aa; } } else if (scope == FT_ONLY) { /* @@ -548,8 +548,8 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop * and the ISO code that we would normally * use to display that EBCDIC code. */ - ft2asc[iso] = hSession->charset.ebc2asc[ebc]; - asc2ft[hSession->charset.ebc2asc[ebc]] = iso; + hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; + hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; } } #endif /*]*/ @@ -637,9 +637,9 @@ static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spe for (i = 0; i < 256; i++) { if ((i & 0x7f) > 0x20 && i != 0x7f && - asc2ebc[i] != 0 && - hSession->charset.ebc2asc[asc2ebc[i]] != i) { - asc2ebc[i] = 0; + hSession->charset.asc2ebc[i] != 0 && + hSession->charset.ebc2asc[hSession->charset.asc2ebc[i]] != i) { + hSession->charset.asc2ebc[i] = 0; } } } diff --git a/ft_cut.c b/ft_cut.c index 0b73552..a7f44c5 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -194,7 +194,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) continue; if (ft->ascii_flag && ft->remap_flag) - c = ft2asc[c]; + c = hSession->charset.ft2asc[c]; *ob++ = c; } @@ -206,6 +206,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) */ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, unsigned char *xobuf) { + H3270 *hSession = ft->host; unsigned char * ob0 = xobuf; unsigned char * ob = ob0; @@ -230,7 +231,7 @@ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, /* Translate. */ if (ft->ascii_flag && ft->remap_flag) - c = asc2ft[c]; + c = hSession->charset.asc2ft[c]; /* Quadrant already defined. */ if (ft->quadrant >= 0) { @@ -238,7 +239,7 @@ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, if (ixp != (unsigned char *)NULL) { ix = ixp - conv[ft->quadrant].xlate; - *ob++ = asc2ebc[(int)alphas[ix]]; + *ob++ = hSession->charset.asc2ebc[(int)alphas[ix]]; continue; } } @@ -256,7 +257,7 @@ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, continue; ix = ixp - conv[ft->quadrant].xlate; *ob++ = conv[ft->quadrant].selector; - *ob++ = asc2ebc[(int)alphas[ix]]; + *ob++ = hSession->charset.asc2ebc[(int)alphas[ix]]; break; } if (ft->quadrant >= NQ) @@ -433,9 +434,9 @@ static void cut_data_request(H3270 *hSession) for (i = 0; i < count; i++) cs ^= hSession->ea_buf[O_UP_DATA + i].cc; - ctlr_add(hSession,O_UP_CSUM, asc2ebc[(int)table6[cs & 0x3f]], 0); - ctlr_add(hSession,O_UP_LEN, asc2ebc[(int)table6[(count >> 6) & 0x3f]], 0); - ctlr_add(hSession,O_UP_LEN+1, asc2ebc[(int)table6[count & 0x3f]], 0); + ctlr_add(hSession,O_UP_CSUM, hSession->charset.asc2ebc[(int)table6[cs & 0x3f]], 0); + ctlr_add(hSession,O_UP_LEN, hSession->charset.asc2ebc[(int)table6[(count >> 6) & 0x3f]], 0); + ctlr_add(hSession,O_UP_LEN+1, hSession->charset.asc2ebc[(int)table6[count & 0x3f]], 0); /* XXX: Change the data field attribute so it doesn't display. */ attr = hSession->ea_buf[O_DR_SF].fa; diff --git a/ft_dft.c b/ft_dft.c index 95f34e7..08e1dbb 100644 --- a/ft_dft.c +++ b/ft_dft.c @@ -304,7 +304,7 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) while (len--) { - *s = ft2asc[*s]; + *s = hSession->charset.ft2asc[*s]; s++; } } @@ -413,7 +413,7 @@ static void dft_get_request(H3270 *hSession) total_read++; } ft->ft_last_cr = (c == '\r') ? 1 : 0; - *bufptr++ = ft->remap_flag? asc2ft[c]: c; + *bufptr++ = ft->remap_flag? hSession->charset.asc2ft[c]: c; numbytes--; total_read++; } else { @@ -427,7 +427,7 @@ static void dft_get_request(H3270 *hSession) int i = numread; while (i) { - *s = asc2ft[*s]; + *s = hSession->charset.asc2ft[*s]; s++; i--; } diff --git a/kybd.c b/kybd.c index f088af4..48f52a9 100644 --- a/kybd.c +++ b/kybd.c @@ -1030,7 +1030,7 @@ void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum lib3270_trace_event(hSession," dropped (control char)\n"); return; } - (void) key_Character(hSession, (int) asc2ebc[c], keytype == KT_GE, False, skipped); + (void) key_Character(hSession, (int) hSession->charset.asc2ebc[c], keytype == KT_GE, False, skipped); } #if defined(X3270_ANSI) /*[*/ else if (IN_ANSI) diff --git a/rpq.c b/rpq.c index 2c458a0..6282347 100644 --- a/rpq.c +++ b/rpq.c @@ -150,7 +150,7 @@ void do_qr_rpqnames(H3270 *hSession) /* Create fixed length portion - program id: x3270 */ for (j = 0; j < 5; j++) { - *hSession->obptr++ = asc2ebc[(int)"x3270"[j]]; + *hSession->obptr++ = hSession->charset.asc2ebc[(int)"x3270"[j]]; remaining--; } @@ -202,7 +202,7 @@ void do_qr_rpqnames(H3270 *hSession) { for (i = 0; i < x; i++) { - *hSession->obptr++ = asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; + *hSession->obptr++ = hSession->charset.asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; } } break; @@ -567,7 +567,7 @@ static int get_rpq_user(H3270 *hSession, unsigned char buf[], const int buflen) if ((*rpqtext == '\\') && (*(rpqtext+1) != '\0')) rpqtext++; - *buf++ = asc2ebc[(int)(*rpqtext & 0xff)]; + *buf++ = hSession->charset.asc2ebc[(int)(*rpqtext & 0xff)]; x++; } return x; diff --git a/tables.c b/tables.c index 8c457bb..bb5c969 100644 --- a/tables.c +++ b/tables.c @@ -434,12 +434,12 @@ const unsigned short asc2ft0[256] = { #endif /*]*/ -unsigned short ebc2cg[256]; -unsigned short cg2ebc[256]; +//unsigned short ebc2cg[256]; +//unsigned short cg2ebc[256]; // unsigned short ebc2asc[256]; -unsigned short asc2ebc[256]; -unsigned short asc2ft[256]; -unsigned short ft2asc[256]; +// unsigned short asc2ebc[256]; +// unsigned short asc2ft[256]; +// unsigned short ft2asc[256]; #ifdef EXTENDED_TABLES unsigned short ebc2asc7[256]; @@ -447,18 +447,18 @@ unsigned short ebc2asc7[256]; LIB3270_INTERNAL void initialize_tables(H3270 *hSession) { /* Go to defaults first. */ - memcpy(ebc2cg, ebc2cg0, sizeof(ebc2cg)); - memcpy(cg2ebc, cg2ebc0, sizeof(cg2ebc)); + memcpy(hSession->charset.ebc2cg, ebc2cg0, sizeof(hSession->charset.ebc2cg)); + memcpy(hSession->charset.cg2ebc, cg2ebc0, sizeof(hSession->charset.cg2ebc)); memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); - memcpy(asc2ebc, asc2ebc0, sizeof(asc2ebc)); + memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc)); #ifdef EXTENDED_TABLES memcpy(ebc2asc7, ebc2asc70, sizeof(ebc2asc7)); #endif // EXTENDED_TABLES #if defined(X3270_FT) /*[*/ - memcpy(ft2asc, ft2asc0, sizeof(ft2asc)); - memcpy(asc2ft, asc2ft0, sizeof(asc2ft)); + memcpy(hSession->charset.ft2asc, ft2asc0, sizeof(hSession->charset.ft2asc)); + memcpy(hSession->charset.asc2ft, asc2ft0, sizeof(hSession->charset.asc2ft)); #endif /*]*/ } diff --git a/tablesc.h b/tablesc.h index 4349e6a..a57beac 100644 --- a/tablesc.h +++ b/tablesc.h @@ -17,12 +17,12 @@ * Global declarations for tables.c. */ LIB3270_INTERNAL void initialize_tables(H3270 *hSession); -LIB3270_INTERNAL unsigned short ebc2cg[256]; -LIB3270_INTERNAL unsigned short cg2ebc[256]; +// LIB3270_INTERNAL unsigned short ebc2cg[256]; +// LIB3270_INTERNAL unsigned short cg2ebc[256]; // LIB3270_INTERNAL unsigned short ebc2asc[256]; -LIB3270_INTERNAL unsigned short asc2ebc[256]; -LIB3270_INTERNAL unsigned short ft2asc[256]; -LIB3270_INTERNAL unsigned short asc2ft[256]; +// LIB3270_INTERNAL unsigned short asc2ebc[256]; +// LIB3270_INTERNAL unsigned short ft2asc[256]; +// LIB3270_INTERNAL unsigned short asc2ft[256]; #ifdef EXTENDED_TABLES LIB3270_INTERNAL unsigned short ebc2asc7[256]; -- libgit2 0.21.2