From f7af7ca6b07710582aa673888bc7ee02e9e80d42 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 22 Aug 2012 11:46:57 +0000 Subject: [PATCH] wip - Reduzindo tamanho da tabela de charsets --- src/include/lib3270/config.h.in | 2 +- src/include/lib3270/log.h | 13 ++++++------- src/include/lib3270/session.h | 8 +++++++- src/lib3270/charset.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------- src/lib3270/host.c | 2 +- src/lib3270/html.c | 22 ---------------------- src/lib3270/kybd.c | 6 +++--- src/lib3270/proxy.c | 2 +- src/lib3270/screen.c | 14 -------------- src/lib3270/session.c | 15 ++++----------- src/lib3270/sf.c | 2 +- src/lib3270/tables.c | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------- src/lib3270/tablesc.h | 33 +++++++++++++++++---------------- src/lib3270/util.c | 14 -------------- 14 files changed, 260 insertions(+), 350 deletions(-) diff --git a/src/include/lib3270/config.h.in b/src/include/lib3270/config.h.in index 2ac3c80..0d7c4a5 100644 --- a/src/include/lib3270/config.h.in +++ b/src/include/lib3270/config.h.in @@ -57,7 +57,7 @@ #ifndef ANDROID #undef HAVE_LIBSSL #define X3270_FT -#endif // ANDROID +#endif // !ANDROID #define X3270_TRACE diff --git a/src/include/lib3270/log.h b/src/include/lib3270/log.h index b7ce70f..a067942 100644 --- a/src/include/lib3270/log.h +++ b/src/include/lib3270/log.h @@ -42,7 +42,6 @@ #define lib3270_write_log(s,m,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ ) #define lib3270_write_rc(s,m,r,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ ) #define lib3270_write_va_log(s,m,f,a) __android_log_vprint(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", a) - #define trace(x, ...) __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "%s(%d):\t" x "\n",__FILE__,__LINE__, __VA_ARGS__) #else @@ -51,14 +50,14 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, const char *fmt, ...) LIB3270_GNUC_FORMAT(4,5); LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg); - #ifdef DEBUG - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); - #else - #define trace(x, ...) // __VA_ARGS__ - #endif - #endif // ANDROID + #ifdef DEBUG + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); + #else + #define trace(x, ...) // __VA_ARGS__ + #endif + #endif // LIB3270_LOG_H_INCLUDED diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 31b4207..54fbb08 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -67,7 +67,9 @@ #define LIB3270_TA void #endif // !LIB3270_TA - #define LIB3270_MB_MAX 16 + #define LIB3270_MB_MAX 16 + #define LIB3270_DEFAULT_CGEN 0x02b90000 + #define LIB3270_DEFAULT_CSET 0x00000025 struct _h3270 { @@ -107,6 +109,7 @@ int trace_skipping : 1; int need_tls_follows : 1; int cut_xfer_in_progress : 1; + int auto_keymap : 1; char * oversize; @@ -264,6 +267,9 @@ // ft_dft.c int dft_buffersize; /**< Buffer size (LIMIN, LIMOUT) */ + // charset.c + unsigned long cgcsgid; + // rpq.c int rpq_complained : 1; #if !defined(_WIN32) diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c index dd9f46c..8520c7b 100644 --- a/src/lib3270/charset.c +++ b/src/lib3270/charset.c @@ -18,7 +18,7 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como charset.c e possui 749 linhas de código. + * Este programa está nomeado como charset.c e possui - linhas de código. * * Contatos: * @@ -26,7 +26,6 @@ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * licinio@bb.com.br (Licínio Luis Branco) * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) * */ @@ -49,12 +48,6 @@ #include #endif // !ANDROID -/* -#if defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) -#include "screenc.h" -#endif -*/ - #include "tablesc.h" #include "utf8c.h" #include "utilc.h" @@ -63,49 +56,31 @@ #include -//#include - -/* -#if !defined(_WIN32) -#include -#endif -*/ - -// #include - #define EURO_SUFFIX "-euro" #define ES_SIZE (sizeof(EURO_SUFFIX) - 1) /* Globals. */ -// static Boolean charset_changed = False; -#define DEFAULT_CGEN 0x02b90000 -#define DEFAULT_CSET 0x00000025 -unsigned long cgcsgid = DEFAULT_CGEN | DEFAULT_CSET; -unsigned long cgcsgid_dbcs = 0L; +// unsigned long cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; +// unsigned long cgcsgid_dbcs = 0L; const char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; -// char *converter_names; -char *encoding; - -/* -#if defined(X3270_DISPLAY) -unsigned char xk_selector = 0; -#endif -*/ +// char *encoding; -unsigned char auto_keymap = 0; +// unsigned char auto_keymap = 0; /* Statics. */ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char *cs, char *ftcs); + typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; -static enum cs_result remap_chars(const char *csname, char *spec, remap_scope scope, int *ne); -static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); + +static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne); +static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); #if defined(DEBUG_CHARSET) /*[*/ static enum cs_result check_charset(void); static char *char_if_ascii7(unsigned long l); #endif /*]*/ -static void set_cgcsgids(const char *spec); +static void set_cgcsgids(H3270 *hSession, const char *spec); static int set_cgcsgid(char *spec, unsigned long *idp); static KeySym StringToKeysym(char *s); @@ -113,54 +88,55 @@ 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(void) { /* Go to defaults first. */ - (void) memcpy((char *)ebc2cg, (char *)ebc2cg0, 256); - (void) memcpy((char *)cg2ebc, (char *)cg2ebc0, 256); - (void) memcpy((char *)ebc2asc, (char *)ebc2asc0, 256); - (void) memcpy((char *)asc2ebc, (char *)asc2ebc0, 256); + (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); #if defined(X3270_FT) /*[*/ - (void) memcpy((char *)ft2asc, (char *)ft2asc0, 256); - (void) memcpy((char *)asc2ft, (char *)asc2ft0, 256); + (void) memcpy((char *)ft2asc, (const char *)ft2asc0, 256); + (void) memcpy((char *)asc2ft, (const char *)asc2ft0, 256); #endif /*]*/ clear_xks(); } -static unsigned char save_ebc2cg[256]; -static unsigned char save_cg2ebc[256]; -static unsigned char save_ebc2asc[256]; -static unsigned char save_asc2ebc[256]; +struct charset_buffer +{ + unsigned char ebc2cg[256]; + unsigned char cg2ebc[256]; + unsigned char ebc2asc[256]; + unsigned char asc2ebc[256]; -#if defined(X3270_FT) /*[*/ -static unsigned char save_ft2asc[256]; -static unsigned char save_asc2ft[256]; -#endif /*]*/ + #if defined(X3270_FT) /*[*/ + unsigned char ft2asc[256]; + unsigned char asc2ft[256]; + #endif /*]*/ +}; -static void -save_charset(void) + +static void save_charset(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_asc2ebc, (char *)asc2ebc, 256); + (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->asc2ebc, (char *)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 *)ft2asc, 256); + (void) memcpy((char *)save->asc2ft, (char *)asc2ft, 256); #endif /*]*/ } -static void -restore_charset(void) +static void restore_charset(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 *)asc2ebc, (char *)save_asc2ebc, 256); + (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 *)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 *)ft2asc, (char *)save->ft2asc, 256); + (void) memcpy((char *)asc2ft, (char *)save->asc2ft, 256); #endif /*]*/ } @@ -207,14 +183,14 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) // const char *ftcs; enum cs_result rc; char *ccs, *cftcs; - const char *ak; - + const char *ak; + struct charset_buffer save; /* Do nothing, successfully. */ if (csname == CN || !strcasecmp(csname, "us")) { charset_defaults(); - set_cgcsgids(CN); + set_cgcsgids(hSession,CN); set_display_charset(hSession, "ISO-8859-1"); return CS_OKAY; } @@ -244,15 +220,15 @@ 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(&save); charset_defaults(); /* Check for auto-keymap. */ ak = lib3270_get_resource_string(hSession,"autoKeymap", csname, NULL); if (ak != NULL) - auto_keymap = !strcasecmp(ak, "true"); + hSession->auto_keymap = strcasecmp(ak, "true") ? 0 : 1; else - auto_keymap = 0; + hSession->auto_keymap = 0; /* Interpret them. */ rc = resource_charset(hSession,csname, ccs, cftcs); @@ -267,7 +243,7 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) #endif /*]*/ if (rc != CS_OKAY) - restore_charset(); + restore_charset(&save); /* #if defined(X3270_DBCS) @@ -291,9 +267,10 @@ enum cs_result charset_init(H3270 *hSession, const char *csname) return rc; } -/* Set a CGCSGID. Return 0 for success, -1 for failure. */ -static int -set_cgcsgid(char *spec, unsigned long *r) +/** + * Set a CGCSGID. Return 0 for success, -1 for failure. + */ +static int set_cgcsgid(char *spec, unsigned long *r) { unsigned long cp; char *ptr; @@ -303,7 +280,7 @@ set_cgcsgid(char *spec, unsigned long *r) ptr != spec && *ptr == '\0') { if (!(cp & ~0xffffL)) - *r = DEFAULT_CGEN | cp; + *r = LIB3270_DEFAULT_CGEN | cp; else *r = cp; return 0; @@ -312,7 +289,7 @@ set_cgcsgid(char *spec, unsigned long *r) } /* Set the CGCSGIDs. */ -static void set_cgcsgids(const char *spec) +static void set_cgcsgids(H3270 *hSession, const char *spec) { int n_ids = 0; char *spec_copy; @@ -327,21 +304,21 @@ static void set_cgcsgids(const char *spec) buf = CN; switch (n_ids) { case 0: - idp = &cgcsgid; + idp = &hSession->cgcsgid; break; #if defined(X3270_DBCS) /*[*/ case 1: - idp = &cgcsgid_dbcs; + idp = &hSession->cgcsgid_dbcs; break; #endif /*]*/ default: - popup_an_error(NULL,"Extra CGCSGID(s), ignoring"); + popup_an_error(hSession,_( "Extra CGCSGID(s), ignoring" )); break; } if (idp == NULL) break; if (set_cgcsgid(token, idp) < 0) { - popup_an_error(NULL,"Invalid CGCSGID '%s', ignoring",token); + popup_an_error(hSession,_( "Invalid CGCSGID '%s', ignoring" ),token); n_ids = -1; break; } @@ -352,9 +329,9 @@ static void set_cgcsgids(const char *spec) return; } - cgcsgid = DEFAULT_CGEN | DEFAULT_CSET; + hSession->cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; #if defined(X3270_DBCS) /*[*/ - cgcsgid_dbcs = 0L; + hSession->cgcsgid_dbcs = 0L; #endif /*]*/ } @@ -385,11 +362,11 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char char * dcs; /* Interpret the spec. */ - rc = remap_chars(csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); + rc = remap_chars(hSession, csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); if (rc != CS_OKAY) return rc; if (ftcs != NULL) { - rc = remap_chars(csname, ftcs, FT_ONLY, &ne); + rc = remap_chars(hSession, csname, ftcs, FT_ONLY, &ne); if (rc != CS_OKAY) return rc; } @@ -449,7 +426,7 @@ static enum cs_result resource_charset(H3270 *hSession, const char *csname, char // set_cgcsgids(get_fresource("%s.%s", "codepage", csname)); { char *ptr = lib3270_get_resource_string(hSession,"codepage", csname, NULL); - set_cgcsgids(ptr); + set_cgcsgids(hSession,ptr); lib3270_free(ptr); } @@ -500,8 +477,7 @@ parse_keysym(char *s, Boolean extended) } /* Process a single character definition. */ -static void -remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) +static void remap_one(H3270 *hSession, unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) { unsigned char cg; @@ -515,7 +491,7 @@ remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) if (iso == 0x20) one_way = True; - if (!auto_keymap || iso <= 0xff) { + if (!hSession->auto_keymap || iso <= 0xff) { #if defined(X3270_FT) /*[*/ unsigned char aa; #endif /*]*/ @@ -524,17 +500,21 @@ remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) if (iso <= 0xff) { cg = asc2cg[iso]; - if (cg2asc[cg] == iso || iso == 0) { + if (cg2asc[cg] == iso || iso == 0) + { /* well-defined */ ebc2cg[ebc] = cg; if (!one_way) cg2ebc[cg] = ebc; - } else { + } + else + { /* into a hole */ ebc2cg[ebc] = CG_boxsolid; } } - if (ebc > 0x40) { + if (ebc > 0x40) + { ebc2asc[ebc] = iso; if (!one_way) asc2ebc[iso] = ebc; @@ -579,9 +559,8 @@ remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) } } -/* - * Parse an EBCDIC character set map, a series of pairs of numeric EBCDIC codes - * and keysyms. +/** + * Parse an EBCDIC character set map, a series of pairs of numeric EBCDIC codes and keysyms. * * If the keysym is in the range 1..255, it is a remapping of the EBCDIC code * for a standard Latin-1 graphic, and the CG-to-EBCDIC map will be modified @@ -592,7 +571,7 @@ remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way) * characters that replace certain standard Latin-1 graphics. The keysym * will be entered into the extended keysym translation table. */ -static enum cs_result remap_chars(const char *csname, char *spec, remap_scope scope, int *ne) +static enum cs_result remap_chars(H3270 *hSession, const char *csname, char *spec, remap_scope scope, int *ne) { char *s; char *ebcs, *isos; @@ -620,7 +599,7 @@ static enum cs_result remap_chars(const char *csname, char *spec, remap_scope sc while ((tok = strtok(s, " \t\n")) != CN) { if (ebc >= 256) { - popup_an_error(NULL,"Charset has more than 256 entries"); + popup_an_error(hSession,_( "Charset has more than 256 entries" )); rc = CS_BAD; break; } @@ -634,20 +613,18 @@ static enum cs_result remap_chars(const char *csname, char *spec, remap_scope sc if (strlen(tok) == 1) iso = tok[0] & 0xff; else { - popup_an_error(NULL,"Invalid charset " - "entry '%s' (#%d)", - tok, ebc); + popup_an_error(hSession,_( "Invalid charset entry '%s' (#%d)" ),tok, ebc); rc = CS_BAD; break; } } - remap_one(ebc, iso, scope, one_way); + remap_one(hSession, ebc, iso, scope, one_way); ebc++; s = CN; } if (ebc != 256) { - popup_an_error(NULL,"Charset has %d entries, need 256", ebc); + popup_an_error(NULL,_( "Charset has %d entries, need 256" ), ebc); rc = CS_BAD; } else { /* @@ -680,12 +657,11 @@ static enum cs_result remap_chars(const char *csname, char *spec, remap_scope sc ((ebc = strtoul(ebcs, &ptr, 0)), ptr == ebcs || *ptr != '\0') || (iso = parse_keysym(isos, True)) == NoSymbol) { - popup_an_error(NULL,"Cannot parse %s \"%s\", entry %d", - ResCharset, csname, *ne); + popup_an_error(hSession,_( "Cannot parse %s \"%s\", entry %d" ), "charset", csname, *ne); rc = CS_BAD; break; } - remap_one(ebc, iso, scope, one_way); + remap_one(hSession, ebc, iso, scope, one_way); } } lib3270_free(spec); diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 9371c71..dd22be3 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -746,7 +746,7 @@ LIB3270_EXPORT void lib3270_register_schange(H3270 *h, LIB3270_STATE_CHANGE tx, /* Signal a state change. */ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) { -#if defined(DEBUG) || defined(ANDROID) +#if defined(DEBUG) static const char * state_name[LIB3270_STATE_USER] = { diff --git a/src/lib3270/html.c b/src/lib3270/html.c index ad12abb..15e0a62 100644 --- a/src/lib3270/html.c +++ b/src/lib3270/html.c @@ -386,11 +386,6 @@ else { append_element(&info,HTML_ELEMENT_LINE_BREAK); -/* -#if defined(DEBUG) || defined(ANDROID) - append_string(&info,"\n"); -#endif // DEBUG -*/ } } @@ -422,23 +417,6 @@ info.text = lib3270_realloc(info.text,strlen(info.text)+2); -/* -#if defined(DEBUG) || defined(ANDROID) - { - char *text = strdup(info.text); - char *save; - char *ptr; - - for(ptr=strtok_r(text,"\n",&save);ptr;ptr = strtok_r(NULL,"\n",&save)) - { - trace("%s",ptr); - } - - free(text); - } -#endif // DEBUG -*/ - return info.text; } diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 7a8c83a..d389415 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -180,7 +180,7 @@ struct ta */ -#if defined(DEBUG) || defined(ANDROID) +#if defined(DEBUG) #define ENQUEUE_ACTION(x) enq_ta(hSession, (void (*)(H3270 *, const char *, const char *)) x, NULL, NULL, #x) #else #define ENQUEUE_ACTION(x) enq_ta(hSession, (void (*)(H3270 *, const char *, const char *)) x, NULL, NULL) @@ -263,7 +263,7 @@ static int enq_chk(H3270 *hSession) /* * Put an action on the typeahead queue. */ -#if defined(DEBUG) || defined(ANDROID) +#if defined(DEBUG) static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char *), const char *parm1, const char *parm2, const char *name) #else static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char *), const char *parm1, const char *parm2) @@ -758,7 +758,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean (void) sprintf(codename, "%d", code |(with_ge ? GE_WFLAG : 0) | (pasting ? PASTE_WFLAG : 0)); -#if defined(DEBUG) || defined(ANDROID) +#if defined(DEBUG) enq_ta(hSession,key_Character_wrapper, codename, CN, "key_Character_wrapper"); #else enq_ta(hSession,key_Character_wrapper, codename, CN); diff --git a/src/lib3270/proxy.c b/src/lib3270/proxy.c index a8d1559..c791b04 100644 --- a/src/lib3270/proxy.c +++ b/src/lib3270/proxy.c @@ -572,7 +572,7 @@ static int proxy_socks4(H3270 *hSession, int fd, char *host, unsigned short port user = getenv("USER"); if (user == CN) user = "nobody"; -#endif +#endif // ANDROID /* Send the request to the server. */ if (use_4a) { diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index eb521e7..da4d7fb 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -613,21 +613,7 @@ void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *tit static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) { -#ifdef ANDROID - - char len = strlen(fmt); - char * mask = malloc(len+5); - strncpy(mask,fmt,len); - mask[len] = '\n'; - mask[len+1] = 0; - __android_log_vprint(ANDROID_LOG_VERBOSE, PACKAGE_NAME, mask, arg); - -#else - lib3270_write_va_log(session,"lib3270",fmt,arg); - -#endif // ANDROID - return 0; } diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 55426ce..b7995ac 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -44,6 +44,7 @@ #include "ftc.h" #include "kybdc.h" #include "3270ds.h" +#include "tablesc.h" /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ @@ -130,20 +131,9 @@ static void set_cursor(H3270 *session, LIB3270_CURSOR id) static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *msg, const char *text) { -#ifdef ANDROID - - __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "%s\n",title); - __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "%s\n",msg); - __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "%s\n",text); - -#else - lib3270_write_log(session,"%s",title); lib3270_write_log(session,"%s",msg); lib3270_write_log(session,"%s",text); - -#endif // ANDROID - } static void update_ssl(H3270 *session, LIB3270_SSL_STATE state) @@ -170,6 +160,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) memset(hSession,0,sizeof(H3270)); hSession->sz = sizeof(H3270); + initialize_tables(hSession); // Default calls hSession->write = lib3270_sock_send; @@ -214,6 +205,8 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->saved_wraparound_mode = 1; hSession->once_cset = -1; hSession->state = LIB3270_ANSI_STATE_DATA; + hSession->cgcsgid = LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET; + for(f=0;f<4;f++) hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c index b703901..827cb3e 100644 --- a/src/lib3270/sf.c +++ b/src/lib3270/sf.c @@ -945,7 +945,7 @@ static void do_qr_charsets(H3270 *hSession) *hSession->obptr++ = 0x00; /* SUBSN */ } #endif /*]*/ - SET32(hSession->obptr, cgcsgid); /* CGCSGID */ + SET32(hSession->obptr, hSession->cgcsgid); /* CGCSGID */ if (!*standard_font) { /* special 3270 font, includes APL */ diff --git a/src/lib3270/tables.c b/src/lib3270/tables.c index ca176f9..f476990 100644 --- a/src/lib3270/tables.c +++ b/src/lib3270/tables.c @@ -42,7 +42,7 @@ #include "globals.h" #include "tablesc.h" -unsigned short asc2cg[256] = { +const unsigned short asc2cg[256] = { /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -76,7 +76,7 @@ unsigned short asc2cg[256] = { /*f0*/ 0xf7, 0x5f, 0x43, 0x5d, 0x58, 0x46, 0x53, 0x9d, /*f8*/ 0x9b, 0x44, 0x5e, 0x59, 0x4e, 0x49, 0xf9, 0x47 }; -unsigned short cg2asc[256] = { +const unsigned short cg2asc[256] = { /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xad, /*08*/ 0x3e, 0x3c, 0x5b, 0x5d, 0x29, 0x28, 0x7d, 0x7b, /*10*/ 0x20, 0x3d, 0x27, 0x22, 0x2f, 0x5c, 0x7c, 0xa6, @@ -110,111 +110,112 @@ unsigned short cg2asc[256] = { /*f0*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xf0, /*f8*/ 0x20, 0xfe, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; -#define EBC2CG \ -/*00*/ 0x00, 0xdf, 0xdf, 0xdf, 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0xaf, +/*d8*/ 0xb0, 0xb1, 0x67, 0x59, 0x4e, 0x44, 0x5e, 0x47, +/*e0*/ 0x15, 0x9d, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, +/*e8*/ 0xb8, 0xb9, 0x68, 0x78, 0x73, 0x63, 0x7d, 0x66, +/*f0*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /*f8*/ 0x28, 0x29, 0x69, 0x79, 0x74, 0x64, 0x7e, 0x06 -unsigned short ebc2cg[256] = { EBC2CG }; -unsigned short ebc2cg0[256] = { EBC2CG }; -#define CG2EBC \ -/*00*/ 0x00, 0x41, 0x0c, 0x0d, 0x15, 0x19, 0xff, 0xca, \ -/*08*/ 0x6e, 0x4c, 0xba, 0xbb, 0x5d, 0x4d, 0xd0, 0xc0, \ -/*10*/ 0x40, 0x7e, 0x7d, 0x7f, 0x61, 0xe0, 0x4f, 0x6a, \ -/*18*/ 0x6f, 0x5a, 0x5b, 0x4a, 0xb1, 0xb2, 0xb6, 0x9f, \ -/*20*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, \ -/*28*/ 0xf8, 0xf9, 0x59, 0xb5, 0x7b, 0x7c, 0x6c, 0x6d, \ -/*30*/ 0x50, 0x60, 0x4b, 0x6b, 0x7a, 0x4e, 0x5f, 0xbc, \ -/*38*/ 0x90, 0xb3, 0xb0, 0xa1, 0xbd, 0x79, 0xbe, 0x9d, \ -/*40*/ 0x44, 0x54, 0x58, 0xcd, 0xdd, 0x46, 0xcf, 0xdf, \ -/*48*/ 0xad, 0x8d, 0x51, 0xb7, 0xb8, 0xb9, 0xdc, 0x48, \ -/*50*/ 0x43, 0x53, 0x57, 0xcc, 0xa0, 0x42, 0x52, 0x56, \ -/*58*/ 0xcb, 0xdb, 0x45, 0xbf, 0x55, 0xce, 0xde, 0x49, \ -/*60*/ 0x64, 0x74, 0x78, 0xed, 0xfd, 0x66, 0xef, 0xda, \ -/*68*/ 0xea, 0xfa, 0x9a, 0x9b, 0x8a, 0x8b, 0xaa, 0xab, \ -/*70*/ 0x63, 0x73, 0x77, 0xec, 0xfc, 0x62, 0x72, 0x76, \ -/*78*/ 0xeb, 0xfb, 0x65, 0x71, 0x75, 0xee, 0xfe, 0x69, \ -/*80*/ 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, \ -/*88*/ 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, \ -/*90*/ 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, \ -/*98*/ 0xa8, 0xa9, 0x9c, 0x70, 0x47, 0xe1, 0x1e, 0x1c, \ -/*a0*/ 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, \ -/*a8*/ 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, \ -/*b0*/ 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, \ -/*b8*/ 0xe8, 0xe9, 0x9e, 0x80, 0x67, 0x68, 0x5e, 0x5c, \ -/*c0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ -/*c8*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ -/*d0*/ 0xb4, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x8f, 0xac, \ -/*d8*/ 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ -/*e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ -/*e8*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ -/*f0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, \ +}; + +const unsigned short cg2ebc0[256] = { +/*00*/ 0x00, 0x41, 0x0c, 0x0d, 0x15, 0x19, 0xff, 0xca, +/*08*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0xc8, +/*a8*/ 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, +/*b0*/ 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, +/*b8*/ 0xe8, 0xe9, 0x9e, 0x80, 0x67, 0x68, 0x5e, 0x5c, +/*c0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*c8*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*d0*/ 0xb4, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x8f, 0xac, +/*d8*/ 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*e8*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +/*f0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, /*f8*/ 0x00, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -unsigned short cg2ebc[256] = { CG2EBC }; -unsigned short cg2ebc0[256] = { CG2EBC }; -#define EBC2ASC \ -/*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20, \ -/*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ -/*40*/ 0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\ -/*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, \ -/*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, \ -/*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, \ -/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, \ +}; + +const unsigned short ebc2asc0[256] = { +/*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20, +/*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +/*40*/ 0x20, 0x20, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, +/*48*/ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, +/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, +/*58*/ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, +/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, +/*68*/ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, +/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, +/*78*/ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, +/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, +/*88*/ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, +/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, +/*98*/ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, +/*a0*/ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, +/*a8*/ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, +/*b0*/ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, +/*b8*/ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, +/*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, +/*c8*/ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, +/*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, +/*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, +/*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, +/*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, +/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /*f8*/ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x20 -unsigned short ebc2asc[256] = { EBC2ASC }; -unsigned short ebc2asc0[256] = { EBC2ASC }; +}; + #define EBC2ASC7 \ /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \ @@ -248,8 +249,9 @@ unsigned short ebc2asc0[256] = { EBC2ASC }; /*e8*/ 0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ /*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, \ /*f8*/ 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 -unsigned short ebc2asc7[256] = { EBC2ASC7 }; -unsigned short ebc2asc70[256] = { EBC2ASC7 }; +const unsigned short ebc2asc7[256] = { EBC2ASC7 }; +const unsigned short ebc2asc70[256] = { EBC2ASC7 }; + #define ASC2EBC \ /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -283,45 +285,9 @@ unsigned short ebc2asc70[256] = { EBC2ASC7 }; /*e8*/ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, \ /*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, \ /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf -unsigned short asc2ebc[256] = { ASC2EBC }; -unsigned short asc2ebc0[256] = { ASC2EBC }; -#if defined(X3270_DISPLAY) /*[*/ -unsigned short cg2uc[256] = { -/*00*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, -/*08*/ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, -/*10*/ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, -/*18*/ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, -/*20*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, -/*28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, -/*30*/ 0x30, 0x31, 0x32, 0x33, 0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xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, -/*d8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, -/*e0*/ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, -/*e8*/ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, -/*f0*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, -/*f8*/ 0xf8, 0xd9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; -#endif /*]*/ -unsigned short ge2asc[256] = { +const unsigned short asc2ebc0[256] = { ASC2EBC }; + +const unsigned short ge2asc[256] = { /*00*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /*08*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /*10*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, @@ -391,7 +357,7 @@ unsigned short ge2cg8[256] = { /*f8*/ 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf }; #endif /*[*/ -unsigned short asc2uc[256] = { +const unsigned short asc2uc[256] = { /*00*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /*08*/ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*10*/ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -425,7 +391,7 @@ unsigned short asc2uc[256] = { /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff }; -unsigned short ebc2uc[256] = { +const unsigned short ebc2uc[256] = { /*00*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /*08*/ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*10*/ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -477,8 +443,7 @@ unsigned short ebc2uc[256] = { 0xa4,0xb5,0xa1,0xbf,0xd0,0xdd,0xde,0xae,0x5e,0xa3,0xa5,0xb7,0xa9,0xa7,0xb6,0xbc, \ 0xbd,0xbe,0x5b,0x5d,0xaf,0xa8,0xb4,0xd7,0xad,0xf4,0xf6,0xf2,0xf3,0xf5,0xb9,0xfb, \ 0xfc,0xf9,0xfa,0xff,0xb2,0xd4,0xd6,0xd2,0xd3,0xd5,0xb3,0xdb,0xdc,0xd9,0xda,0xff -unsigned short ft2asc[256] = { FT2ASC }; -unsigned short ft2asc0[256] = { FT2ASC }; +const unsigned short ft2asc0[256] = { FT2ASC }; #define ASC2FT \ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, \ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, \ @@ -496,6 +461,26 @@ unsigned short ft2asc0[256] = { FT2ASC }; 0xd4,0xb9,0xf7,0xf8,0xf5,0xf9,0xf6,0xe7,0xc3,0xfd,0xfe,0xfb,0xfc,0xd5,0xd6,0xb1, \ 0xa3,0xa4,0xa1,0xa5,0xa2,0xa6,0xcd,0xa7,0xac,0xa9,0xaa,0xab,0xb0,0xad,0xae,0xaf, \ 0xc6,0xa8,0xeb,0xec,0xe9,0xed,0xea,0x9f,0xba,0xf1,0xf2,0xef,0xf0,0xc7,0xc8,0xf3 -unsigned short asc2ft[256] = { ASC2FT }; -unsigned short asc2ft0[256] = { ASC2FT }; +const unsigned short asc2ft0[256] = { ASC2FT }; #endif /*]*/ + +unsigned short ebc2cg[256]; +unsigned short cg2ebc[256]; +unsigned short ebc2asc[256]; +unsigned short asc2ebc[256]; +unsigned short asc2ft[256]; +unsigned short ft2asc[256]; + +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(asc2ebc, asc2ebc0, sizeof(asc2ebc)); +#if defined(X3270_FT) /*[*/ + memcpy(ft2asc, ft2asc0, sizeof(ft2asc)); + memcpy(asc2ft, asc2ft0, sizeof(asc2ft)); +#endif /*]*/ + +} diff --git a/src/lib3270/tablesc.h b/src/lib3270/tablesc.h index f5fcadb..42cf38f 100644 --- a/src/lib3270/tablesc.h +++ b/src/lib3270/tablesc.h @@ -16,25 +16,26 @@ * tablesc.h * Global declarations for tables.c. */ - -LIB3270_INTERNAL unsigned short asc2cg[256]; -LIB3270_INTERNAL unsigned short cg2asc[256]; +LIB3270_INTERNAL void initialize_tables(H3270 *hSession); LIB3270_INTERNAL unsigned short ebc2cg[256]; -LIB3270_INTERNAL unsigned short ebc2cg0[256]; LIB3270_INTERNAL unsigned short cg2ebc[256]; -LIB3270_INTERNAL unsigned short cg2ebc0[256]; LIB3270_INTERNAL unsigned short ebc2asc[256]; -LIB3270_INTERNAL unsigned short ebc2asc0[256]; -LIB3270_INTERNAL unsigned short ebc2asc7[256]; -LIB3270_INTERNAL unsigned short ebc2asc70[256]; LIB3270_INTERNAL unsigned short asc2ebc[256]; -LIB3270_INTERNAL unsigned short asc2ebc0[256]; -LIB3270_INTERNAL unsigned short cg2uc[256]; -LIB3270_INTERNAL unsigned short ge2asc[256]; -LIB3270_INTERNAL unsigned short ge2cg8[256]; -LIB3270_INTERNAL unsigned short asc2uc[256]; -LIB3270_INTERNAL unsigned short ebc2uc[256]; LIB3270_INTERNAL unsigned short ft2asc[256]; -LIB3270_INTERNAL unsigned short ft2asc0[256]; LIB3270_INTERNAL unsigned short asc2ft[256]; -LIB3270_INTERNAL unsigned short asc2ft0[256]; + +LIB3270_INTERNAL const unsigned short asc2cg[256]; +LIB3270_INTERNAL const unsigned short cg2asc[256]; +LIB3270_INTERNAL const unsigned short ebc2cg0[256]; +LIB3270_INTERNAL const unsigned short cg2ebc0[256]; +LIB3270_INTERNAL const unsigned short ebc2asc0[256]; +LIB3270_INTERNAL const unsigned short ebc2asc7[256]; +LIB3270_INTERNAL const unsigned short ebc2asc70[256]; +LIB3270_INTERNAL const unsigned short asc2ebc0[256]; +// LIB3270_INTERNAL const unsigned short cg2uc[256]; +LIB3270_INTERNAL const unsigned short ge2asc[256]; +LIB3270_INTERNAL const unsigned short ge2cg8[256]; +LIB3270_INTERNAL const unsigned short asc2uc[256]; +LIB3270_INTERNAL const unsigned short ebc2uc[256]; +LIB3270_INTERNAL const unsigned short ft2asc0[256]; +LIB3270_INTERNAL const unsigned short asc2ft0[256]; diff --git a/src/lib3270/util.c b/src/lib3270/util.c index 1b8ab41..3392cb0 100644 --- a/src/lib3270/util.c +++ b/src/lib3270/util.c @@ -929,20 +929,6 @@ LIB3270_EXPORT void * lib3270_malloc(int len) return r; } -/* -void * Calloc(size_t nelem, size_t elsize) -{ - int sz = nelem * elsize; - char * r = malloc(sz); - - if(!r) - Error(NULL,"Out of memory in %s",__FUNCTION__); - - memset(r, 0, sz); - return r; -} -*/ - LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...) { #ifdef ANDROID -- libgit2 0.21.2