diff --git a/android/jni/main.cpp b/android/jni/main.cpp index 23d0a5c..b5e745e 100644 --- a/android/jni/main.cpp +++ b/android/jni/main.cpp @@ -281,7 +281,7 @@ static void autostart(H3270 *session) jint JNI_OnLoad(JavaVM *vm, void *reserved) { - H3270 * session = lib3270_session_new(""); + H3270 * session = lib3270_session_new("","bracket"); __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Initializing %s",PACKAGE_NAME); diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 6323199..1476f17 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -112,7 +112,7 @@ int trace_skipping : 1; int need_tls_follows : 1; int cut_xfer_in_progress : 1; - int auto_keymap : 1; +// int auto_keymap : 1; int formatted : 1; /**< Formatted screen flag */ int starting : 1; /**< Is starting (no first screen)? */ diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c index d54e6c9..4094f42 100644 --- a/src/lib3270/charset.c +++ b/src/lib3270/charset.c @@ -35,6 +35,16 @@ */ #include "globals.h" +#include "X11keysym.h" + +typedef enum +{ + CS_ONLY, + FT_ONLY, + BOTH +} remap_scope; + +static void remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, remap_scope scope, unsigned char one_way); /* * EBCDIC-to-Unicode translation tables. @@ -44,6 +54,7 @@ #define UT_SIZE 190 #define UT_OFFSET 0x41 +/* typedef struct { const char * name; @@ -52,6 +63,7 @@ typedef struct const char * display_charset; unsigned short code[UT_SIZE]; } charset_table; +*/ /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ @@ -197,6 +209,16 @@ static const unsigned short asc2uc[UT_SIZE] = }; + +// +// bracket: "0xad: [ \n 0xba: XK_Yacute \n0xbd: ] \n 0xbb: XK_diaeresis \n" +// +// remap_char(hSession,0xad, '[', BOTH, 0); +// remap_char(hSession,0xba, XK_Yacute, BOTH, 0); +// remap_char(hSession,0xbd, ']', BOTH, 0); +// remap_char(hSession,0xbb, XK_diaeresis, remap_scope scope,0); +// + /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ static void copy_charset(const unsigned short *from, unsigned short *to) @@ -210,11 +232,11 @@ LIB3270_EXPORT struct lib3270_charset * lib3270_load_charset(H3270 *hSession, co { int f; - hSession->charset.host = "bracket"; + hSession->charset.host = "us"; hSession->charset.display = "ISO-8859-1"; - lib3270_write_log(hSession,"charset","host.charset=%s display.charset=%s", - hSession->charset.host,hSession->charset.display); +// lib3270_write_log(hSession,"charset","host.charset=%s display.charset=%s", +// hSession->charset.host,hSession->charset.display); memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc)); @@ -228,6 +250,16 @@ LIB3270_EXPORT struct lib3270_charset * lib3270_load_charset(H3270 *hSession, co memcpy(hSession->charset.asc2ft, asc2ft, sizeof(hSession->charset.asc2ft)); #endif + //if(!(name && strcasecmp(name,hSession->charset.host))) + // return &hSession->charset; + + // Bracket + remap_char(hSession,0xad, '[', BOTH, 0); + remap_char(hSession,0xba, XK_Yacute, BOTH, 0); + remap_char(hSession,0xbd, ']', BOTH, 0); + remap_char(hSession,0xbb, XK_diaeresis, BOTH, 0); + + return &hSession->charset; } @@ -303,6 +335,105 @@ LIB3270_ACTION( charsettable ) return 0; } +// Process a single character definition. +static void remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, remap_scope scope, unsigned char one_way) +{ +// unsigned char cg; + + // Ignore mappings of EBCDIC control codes and the space character. + if (ebc <= 0x40) + return; + + // If they want to map to a NULL or a blank, make it a one-way blank. + if (iso == 0x0) + iso = 0x20; + if (iso == 0x20) + one_way = True; + + if (iso <= 0xff) + { +#if defined(X3270_FT) + unsigned char aa; +#endif + + if (scope == BOTH || scope == CS_ONLY) + { + /* + if (iso <= 0xff) + { + cg = hSession->charset.asc2cg[iso]; + + if (hSession->charset.cg2asc[cg] == iso || iso == 0) + { + // well-defined + hSession->charset.ebc2cg[ebc] = cg; + if (!one_way) + hSession->charset.cg2ebc[cg] = ebc; + } + else + { + // into a hole + hSession->charset.ebc2cg[ebc] = CG_boxsolid; + } + } + */ + + if (ebc > 0x40) + { + hSession->charset.ebc2asc[ebc] = iso; + if (!one_way) + hSession->charset.asc2ebc[iso] = ebc; + } + } +#if defined(X3270_FT) + if (iso <= 0xff && ebc > 0x40) + { + // Change the file transfer translation table. + if (scope == BOTH) + { + // + // We have an alternate mapping of an EBCDIC + // code to an ASCII code. Modify the existing + // ASCII(ft)-to-ASCII(desired) maps. + // + // This is done by figuring out which ASCII + // code the host usually translates the given + // EBCDIC code to (asc2ft0[ebc2asc0[ebc]]). + // Now we want to translate that code to the + // given ISO code, and vice-versa. + // + aa = asc2ft[ebc2asc0[ebc]]; + if (aa != ' ') + { + hSession->charset.ft2asc[aa] = iso; + hSession->charset.asc2ft[iso] = aa; + } + } + else if (scope == FT_ONLY) + { + // + // We have a map of how the host translates + // the given EBCDIC code to an ASCII code. + // Generate the translation between that code + // and the ISO code that we would normally + // use to display that EBCDIC code. + // + hSession->charset.ft2asc[iso] = hSession->charset.ebc2asc[ebc]; + hSession->charset.asc2ft[hSession->charset.ebc2asc[ebc]] = iso; + } + } +#endif + } +/* + else + { + // Auto-keymap. + add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); + } +*/ +} + + /*ISO-8859-1 #include "resources.h" diff --git a/src/lib3270/session.c b/src/lib3270/session.c index f492d45..98586a2 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -177,7 +177,7 @@ static void nop_int(H3270 *session, int width) return; } -static void lib3270_session_init(H3270 *hSession, const char *model) +static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) { int ovc, ovr; char junk; @@ -187,7 +187,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) memset(hSession,0,sizeof(H3270)); hSession->sz = sizeof(H3270); - lib3270_load_charset(hSession,NULL); + lib3270_load_charset(hSession,charset); // Default calls hSession->write = lib3270_sock_send; @@ -321,7 +321,7 @@ H3270 * lib3270_session_new(const char *model) hSession = default_session = lib3270_malloc(sizeof(H3270)); - lib3270_session_init(hSession, model); + lib3270_session_init(hSession, model, "bracket"); if(screen_init(hSession)) return NULL; -- libgit2 0.21.2