diff --git a/charset.c b/charset.c index 976c793..ddedc00 100644 --- a/charset.c +++ b/charset.c @@ -88,16 +88,16 @@ static KeySym StringToKeysym(char *s); // static void set_charset_name(char *csname); // static char *charset_name = CN; -static void charset_defaults(void) +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 *)ebc2asc, (const char *)ebc2asc0, 256); - (void) memcpy((char *)asc2ebc, (const char *)asc2ebc0, 256); + (void) memcpy((char *)ebc2cg, (const char *)ebc2cg0, 256); + (void) memcpy((char *)cg2ebc, (const char *)cg2ebc0, 256); + (void) memcpy((char *) hSession->charset.ebc2asc, (const char *)ebc2asc0, 256); + (void) memcpy((char *)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 *)ft2asc, (const char *)ft2asc0, 256); + (void) memcpy((char *)asc2ft, (const char *)asc2ft0, 256); #endif /*]*/ clear_xks(); } @@ -116,11 +116,11 @@ struct charset_buffer }; -static void save_charset(struct charset_buffer *save) +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->ebc2asc, (char *)ebc2asc, 256); + (void) memcpy((char *)save->ebc2asc, (char *) hSession->charset.ebc2asc, 256); (void) memcpy((char *)save->asc2ebc, (char *)asc2ebc, 256); #if defined(X3270_FT) /*[*/ (void) memcpy((char *)save->ft2asc, (char *)ft2asc, 256); @@ -128,11 +128,11 @@ static void save_charset(struct charset_buffer *save) #endif /*]*/ } -static void restore_charset(struct charset_buffer *save) +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 *)ebc2asc, (char *)save->ebc2asc, 256); + (void) memcpy((char *)hSession->charset.ebc2asc, (char *)save->ebc2asc, 256); (void) memcpy((char *)asc2ebc, (char *)save->asc2ebc, 256); #if defined(X3270_FT) /*[*/ (void) memcpy((char *)ft2asc, (char *)save->ft2asc, 256); @@ -189,7 +189,7 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) /* Do nothing, successfully. */ if (csname == CN || !strcasecmp(csname, "us")) { - charset_defaults(); + charset_defaults(hSession); set_cgcsgids(hSession,CN); set_display_charset(hSession, "ISO-8859-1"); return CS_OKAY; @@ -220,8 +220,8 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) cftcs = lib3270_get_resource_string(hSession,"ftCharset",csname,NULL); /* Save the current definitions, and start over with the defaults. */ - save_charset(&save); - charset_defaults(); + save_charset(hSession,&save); + charset_defaults(hSession); /* Check for auto-keymap. */ ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); @@ -243,7 +243,7 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) #endif /*]*/ if (rc != CS_OKAY) - restore_charset(&save); + restore_charset(hSession,&save); /* #if defined(X3270_DBCS) @@ -515,7 +515,7 @@ static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scop } if (ebc > 0x40) { - ebc2asc[ebc] = iso; + hSession->charset.ebc2asc[ebc] = iso; if (!one_way) asc2ebc[iso] = ebc; } @@ -548,14 +548,14 @@ 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] = ebc2asc[ebc]; - asc2ft[ebc2asc[ebc]] = iso; + ft2asc[iso] = hSession->charset.ebc2asc[ebc]; + asc2ft[hSession->charset.ebc2asc[ebc]] = iso; } } #endif /*]*/ } else { /* Auto-keymap. */ - add_xk(iso, (KeySym)ebc2asc[ebc]); + add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); } } @@ -638,7 +638,7 @@ 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 && - ebc2asc[asc2ebc[i]] != i) { + hSession->charset.ebc2asc[asc2ebc[i]] != i) { asc2ebc[i] = 0; } } @@ -723,7 +723,7 @@ check_charset(void) void set_display_charset(H3270 *session, const char *dcs) { - session->charset = strdup(dcs); + session->charset.display = strdup(dcs); } LIB3270_EXPORT const char * lib3270_get_default_charset(void) @@ -731,10 +731,10 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void) return "ISO-8859-1"; } -LIB3270_EXPORT const char * lib3270_get_charset(H3270 *session) +LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession) { - CHECK_SESSION_HANDLE(session); - return session->charset ? session->charset : lib3270_get_default_charset(); + CHECK_SESSION_HANDLE(hSession); + return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; } static KeySym StringToKeysym(char *s) diff --git a/ft_cut.c b/ft_cut.c index c9baa15..0b73552 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -167,7 +167,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) } /* Translate to a quadrant index. */ - ixp = strchr(alphas, ebc2asc[c]); + ixp = strchr(alphas, hSession->charset.ebc2asc[c]); if (ixp == (char *)NULL) { /* Try a different quadrant. */ @@ -349,7 +349,7 @@ static void cut_control_code(H3270 *hSession) bp = buf = lib3270_malloc(81); for (i = 0; i < 80; i++) - *bp++ = ebc2asc[hSession->ea_buf[O_CC_MESSAGE + i].cc]; + *bp++ = hSession->charset.ebc2asc[hSession->ea_buf[O_CC_MESSAGE + i].cc]; *bp-- = '\0'; @@ -465,9 +465,11 @@ static void cut_retransmit(H3270 *hSession) static unsigned from6(unsigned char c) { + H3270 *hSession = lib3270_get_default_session_handle(); + char *p; - c = ebc2asc[c]; + c = hSession->charset.ebc2asc[c]; p = strchr(table6, c); if (p == CN) return 0; diff --git a/screen.c b/screen.c index 4f412b5..fa9aca2 100644 --- a/screen.c +++ b/screen.c @@ -337,9 +337,9 @@ void screen_update(H3270 *session, int bstart, int bend) else { if(lib3270_get_toggle(session,LIB3270_TOGGLE_MONOCASE)) - addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); + addch(session,baddr,asc2uc[session->charset.ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); else - addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); + addch(session,baddr,session->charset.ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); } } } diff --git a/see.c b/see.c index 927e3b1..f05fd7e 100644 --- a/see.c +++ b/see.c @@ -64,6 +64,7 @@ unknown(unsigned char value) const char * see_ebc(unsigned char ch) { + H3270 *hSession = lib3270_get_default_session_handle(); static char buf[8]; switch (ch) { @@ -91,8 +92,8 @@ see_ebc(unsigned char ch) return "SO"; } - if (ebc2asc[ch]) - (void) sprintf(buf,"%c", ebc2asc[ch]); + if (hSession->charset.ebc2asc[ch]) + (void) sprintf(buf,"%c", hSession->charset.ebc2asc[ch]); else (void) sprintf(buf, "\\%o", ch); diff --git a/session.c b/session.c index 6e0405b..12a2816 100644 --- a/session.c +++ b/session.c @@ -84,7 +84,7 @@ void lib3270_session_free(H3270 *h) // Release memory #define release_pointer(x) lib3270_free(x); x = NULL; - release_pointer(h->charset); + release_pointer(h->charset.display); release_pointer(h->paste_buffer); release_pointer(h->ibuf); @@ -218,7 +218,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->unlock_delay = 1; hSession->icrnl = 1; hSession->onlcr = 1; - hSession->host_charset = "bracket"; + hSession->charset.host = "bracket"; hSession->sock = -1; hSession->model_num = -1; hSession->cstate = LIB3270_NOT_CONNECTED; @@ -300,7 +300,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) trace("Termtype: %s",hSession->termtype); if (hSession->apl_mode) - hSession->host_charset = "apl"; + hSession->charset.host = "apl"; } @@ -324,10 +324,10 @@ H3270 * lib3270_session_new(const char *model) if(screen_init(hSession)) return NULL; - trace("Charset: %s",hSession->host_charset); - if (charset_init(hSession,hSession->host_charset) != CS_OKAY) + trace("Charset: %s",hSession->charset.host); + if (charset_init(hSession,hSession->charset.host) != CS_OKAY) { - Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->host_charset); + Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->charset.host); (void) charset_init(hSession,CN); } diff --git a/tables.c b/tables.c index b9f88a1..8c457bb 100644 --- a/tables.c +++ b/tables.c @@ -436,7 +436,7 @@ const unsigned short asc2ft0[256] = { unsigned short ebc2cg[256]; unsigned short cg2ebc[256]; -unsigned short ebc2asc[256]; +// unsigned short ebc2asc[256]; unsigned short asc2ebc[256]; unsigned short asc2ft[256]; unsigned short ft2asc[256]; @@ -449,7 +449,7 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession) /* Go to defaults first. */ memcpy(ebc2cg, ebc2cg0, sizeof(ebc2cg)); memcpy(cg2ebc, cg2ebc0, sizeof(cg2ebc)); - memcpy(ebc2asc, ebc2asc0, sizeof(ebc2asc)); + memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); memcpy(asc2ebc, asc2ebc0, sizeof(asc2ebc)); #ifdef EXTENDED_TABLES diff --git a/tablesc.h b/tablesc.h index 16562a5..4349e6a 100644 --- a/tablesc.h +++ b/tablesc.h @@ -19,7 +19,7 @@ LIB3270_INTERNAL void initialize_tables(H3270 *hSession); LIB3270_INTERNAL unsigned short ebc2cg[256]; LIB3270_INTERNAL unsigned short cg2ebc[256]; -LIB3270_INTERNAL unsigned short ebc2asc[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]; -- libgit2 0.21.2