From b7c0601b78df8d09e562961fa2d3f3b1afc4a34f Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 14 May 2012 18:10:28 +0000 Subject: [PATCH] Android - WIP --- XtGlue.c | 15 ++++++++++----- appres.h | 2 +- charset.c | 12 +++++------- charsetc.h | 2 +- glue.c | 22 +++++++++++----------- host.c | 4 ++-- init.c | 25 ++++++++++++++++++++----- sources.mak | 4 ++-- 8 files changed, 52 insertions(+), 34 deletions(-) diff --git a/XtGlue.c b/XtGlue.c index 0dcf729..3c43508 100644 --- a/XtGlue.c +++ b/XtGlue.c @@ -850,7 +850,12 @@ void RemoveInput(unsigned long id) callbacks->RemoveInput(id); } -int LIB3270_EXPORT lib3270_register_handlers(const struct lib3270_callbacks *cbk) +LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void) +{ + return &h3270; +} + +LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk) { if(!cbk) return EINVAL; @@ -937,7 +942,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * if(h->set_timer) h->set_timer(h,1); - lib3270_main_iterate(0); + lib3270_main_iterate(h,0); if(callbacks->callthread) { h->bgthread = 1; @@ -950,7 +955,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * { rc = callback(h,parm); } - lib3270_main_iterate(0); + lib3270_main_iterate(h,0); if(h->set_timer) h->set_timer(h,0); @@ -958,7 +963,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * return rc; } -LIB3270_EXPORT void lib3270_main_iterate(int wait) +LIB3270_EXPORT void lib3270_main_iterate(H3270 *session, int wait) { if(callbacks->RunPendingEvents) callbacks->RunPendingEvents(wait); @@ -976,7 +981,7 @@ LIB3270_EXPORT int lib3270_wait(seconds) while(time(0) < end) { - lib3270_main_iterate(1); + lib3270_main_iterate(&h3270,1); } return 0; diff --git a/appres.h b/appres.h index 50c2245..1699efd 100644 --- a/appres.h +++ b/appres.h @@ -149,7 +149,7 @@ typedef struct { char *model; // char *hostsfile; // char *port; - char *charset; +// char *charset; // char *termname; // char *login_macro; char *macros; diff --git a/charset.c b/charset.c index b7d0003..d9c841a 100644 --- a/charset.c +++ b/charset.c @@ -90,10 +90,9 @@ unsigned char xk_selector = 0; unsigned char auto_keymap = 0; /* Statics. */ -static enum cs_result resource_charset(char *csname, char *cs, char *ftcs); +static enum cs_result resource_charset(const char *csname, char *cs, char *ftcs); typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; -static enum cs_result remap_chars(char *csname, char *spec, remap_scope scope, - int *ne); +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); #if defined(DEBUG_CHARSET) /*[*/ @@ -195,7 +194,7 @@ wide_resource_init(char *csname) /* * Change character sets. */ -enum cs_result charset_init(H3270 *session, char *csname) +enum cs_result charset_init(H3270 *session, const char *csname) { char *cs; const char *ftcs; @@ -370,7 +369,7 @@ set_charset_name(char *csname) */ /* Define a charset from resources. */ -static enum cs_result resource_charset(char *csname, char *cs, char *ftcs) +static enum cs_result resource_charset(const char *csname, char *cs, char *ftcs) { enum cs_result rc; int ne = 0; @@ -586,8 +585,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(char *csname, char *spec, remap_scope scope, int *ne) +static enum cs_result remap_chars(const char *csname, char *spec, remap_scope scope, int *ne) { char *s; char *ebcs, *isos; diff --git a/charsetc.h b/charsetc.h index 3a302bf..b145390 100644 --- a/charsetc.h +++ b/charsetc.h @@ -35,7 +35,7 @@ LIB3270_INTERNAL char *default_display_charset; enum cs_result { CS_OKAY, CS_NOTFOUND, CS_BAD, CS_PREREQ, CS_ILLEGAL }; -LIB3270_INTERNAL enum cs_result charset_init(H3270 *session, char *csname); +LIB3270_INTERNAL enum cs_result charset_init(H3270 *session, const char *csname); // LIB3270_INTERNAL char *get_charset_name(void); LIB3270_INTERNAL void set_display_charset(H3270 *session, const char *dcs); diff --git a/glue.c b/glue.c index 0d31897..b67883d 100644 --- a/glue.c +++ b/glue.c @@ -171,15 +171,15 @@ static void initialize(void) // appres.hostsfile = CN; // appres.port = "telnet"; -#if !defined(_WIN32) /*[*/ - appres.charset = "bracket"; -#else /*][*/ - - if (is_nt) - appres.charset = "bracket"; - else - appres.charset = "bracket437"; -#endif /*]*/ +// #if !defined(_WIN32) /*[*/ +// appres.charset = "bracket"; +// #else /*][*/ +// +// if (is_nt) +// appres.charset = "bracket"; +// else +// appres.charset = "bracket437"; +//#endif /*]*/ // appres.termname = CN; appres.macros = CN; @@ -305,7 +305,7 @@ static const struct lib3270_option options[] = #if defined(HAVE_LIBSSL) /*[*/ { OptCertFile, OPT_STRING, False, ResCertFile, offset(cert_file), NULL }, #endif /*]*/ - { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL }, +// { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL }, { OptClear, OPT_SKIP2, False, NULL, NULL, NULL }, // { OptDefScreen,OPT_STRING, False, ResDefScreen, offset(defscreen), NULL }, //#if defined(X3270_TRACE) @@ -383,7 +383,7 @@ static struct { #if defined(HAVE_LIBSSL) /*[*/ { ResCertFile, offset(cert_file), XRM_STRING }, #endif /*]*/ - { ResCharset, offset(charset), XRM_STRING }, +// { ResCharset, offset(charset), XRM_STRING }, // { ResColor8, offset(color8), XRM_BOOLEAN }, { ResConfDir, offset(conf_dir), XRM_STRING }, // { ResDefScreen, offset(defscreen), XRM_STRING }, diff --git a/host.c b/host.c index 0458b77..441bc83 100644 --- a/host.c +++ b/host.c @@ -615,7 +615,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) CHECK_SESSION_HANDLE(h); - lib3270_main_iterate(0); + lib3270_main_iterate(h,0); if(h->auto_reconnect_inprogress) return EAGAIN; @@ -638,7 +638,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) { while(!IN_ANSI && !IN_3270) { - lib3270_main_iterate(1); + lib3270_main_iterate(h,1); if(!PCONNECTED) { diff --git a/init.c b/init.c index f7c5938..6c94bfc 100644 --- a/init.c +++ b/init.c @@ -32,7 +32,7 @@ #include "globals.h" -#include "appres.h" +// #include "appres.h" #include "charsetc.h" #include "kybdc.h" #include "ansic.h" @@ -142,6 +142,20 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->unlock_delay = 1; hSession->icrnl = 1; hSession->onlcr = 1; + hSession->host_charset = "bracket"; + +/* +#if !defined(_WIN32) + hSession->host_charset = "bracket"; +#else + + if (is_nt) + hSession->host_charset = "bracket"; + else + hSession->host_charset = "bracket437"; +#endif +*/ + // Initialize toggles initialize_toggles(hSession); @@ -223,7 +237,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) Trace("Termtype: %s",hSession->termtype); if (hSession->apl_mode) - appres.charset = "apl"; + hSession->host_charset = "apl"; } @@ -244,15 +258,16 @@ H3270 * lib3270_session_new(const char *model) configured = 1; + lib3270_session_init(hSession, model); if(screen_init(hSession)) return NULL; - Trace("Charset: %s",appres.charset); - if (charset_init(hSession,appres.charset) != CS_OKAY) + Trace("Charset: %s",hSession->host_charset); + if (charset_init(hSession,hSession->host_charset) != CS_OKAY) { - Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), appres.charset); + Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->host_charset); (void) charset_init(hSession,CN); } diff --git a/sources.mak b/sources.mak index 4a3b4b7..ec9bb16 100644 --- a/sources.mak +++ b/sources.mak @@ -27,9 +27,9 @@ # Terminal only sources TERMINAL_SOURCES = bounds.c XtGlue.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \ host.c sf.c ansi.c log.c resolver.c xio.c tables.c proxy.c utf8.c charset.c \ - version.c + version.c init.c # Full library sources -SOURCES = $(TERMINAL_SOURCES) init.c actions.c ft.c ft_cut.c ft_dft.c glue.c resources.c \ +SOURCES = $(TERMINAL_SOURCES) actions.c ft.c ft_cut.c ft_dft.c glue.c resources.c \ rpq.c see.c trace_ds.c paste.c macros.c fallbacks.c -- libgit2 0.21.2