diff --git a/ansi.c b/ansi.c index 3f2d24f..770457c 100644 --- a/ansi.c +++ b/ansi.c @@ -1706,10 +1706,9 @@ trace_pending_mb(void) * External entry points */ -void -ansi_init(void) +void ansi_init(void) { - register_schange(ST_3270_MODE, ansi_in3270); + lib3270_register_schange(NULL,LIB3270_STATE_3270_MODE,ansi_in3270,NULL); } void @@ -1723,7 +1722,7 @@ ansi_process(unsigned int c) // scroll_to_bottom(); #if defined(X3270_TRACE) /*[*/ - if (toggled(SCREEN_TRACE)) + if (lib3270_get_toggle(&h3270,SCREEN_TRACE)) trace_char((char)c); #endif /*]*/ @@ -1827,7 +1826,7 @@ ansi_send_pa(int nn) void toggle_lineWrap(H3270 *session, struct lib3270_toggle *t unused, LIB3270_TOGGLE_TYPE type unused) { - if (toggled(LIB3270_TOGGLE_LINE_WRAP)) + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_LINE_WRAP)) wraparound_mode = 1; else wraparound_mode = 0; diff --git a/api.h b/api.h index 2fb7d6b..2a759b3 100644 --- a/api.h +++ b/api.h @@ -114,8 +114,8 @@ #define ST_RESOLVING LIB3270_STATE_RESOLVING #define ST_HALF_CONNECT LIB3270_STATE_HALF_CONNECT - #define ST_CONNECT LIB3270_STATE_CONNECT - #define ST_3270_MODE LIB3270_STATE_3270_MODE +// #define ST_CONNECT LIB3270_STATE_CONNECT +// #define ST_3270_MODE LIB3270_STATE_3270_MODE #define ST_LINE_MODE LIB3270_STATE_LINE_MODE #define ST_REMODEL LIB3270_STATE_REMODEL #define ST_PRINTER LIB3270_STATE_PRINTER @@ -159,7 +159,7 @@ #define OIA_FLAG_UNDERA LIB3270_FLAG_UNDERA // #define OIA_FLAG_SECURE LIB3270_FLAG_SECURE #define OIA_FLAG_TYPEAHEAD LIB3270_FLAG_TYPEAHEAD - #define OIA_FLAG_PRINTER LIB3270_FLAG_PRINTER +// #define OIA_FLAG_PRINTER LIB3270_FLAG_PRINTER #define OIA_FLAG_REVERSE LIB3270_FLAG_REVERSE #define OIA_FLAG_USER LIB3270_FLAG_COUNT #define OIA_FLAG LIB3270_FLAG @@ -382,7 +382,7 @@ LOCAL_EXTERN SCRIPT_STATE status_script(SCRIPT_STATE state); - #define Toggled(ix) lib3270_get_toggle(NULL,ix) +// #define Toggled(ix) lib3270_get_toggle(NULL,ix) // #define CallAndWait(c,h,p) lib3270_call_thread(c,h,p) // #define RunPendingEvents(x) lib3270_main_iterate(x) @@ -401,7 +401,7 @@ #define host_connect(n,wait) lib3270_connect(NULL,n,wait) #define host_reconnect(w) lib3270_reconnect(NULL,w) - #define register_schange(tx,func) lib3270_register_schange(NULL,tx,func,NULL) +// #define register_schange(tx,func) lib3270_register_schange(NULL,tx,func,NULL) /* Console/Trace window */ // LOCAL_EXTERN HCONSOLE console_window_new(const char *title, const char *label); diff --git a/appres.h b/appres.h index 6b926a4..50c2245 100644 --- a/appres.h +++ b/appres.h @@ -80,24 +80,24 @@ typedef struct { // char curses_keypad; // char cbreak_mode; //#endif /*]*/ - char apl_mode; +// char apl_mode; // char scripted; - char numeric_lock; - char secure; - char oerr_lock; - char typeahead; +// char numeric_lock; +// char secure; +// char oerr_lock; +// char typeahead; char debug_tracing; char disconnect_clear; char highlight_bold; - char color8; - char bsd_tm; - char unlock_delay; -#if defined(X3270_SCRIPT) /*[*/ - char socket; -#endif /*]*/ -#if defined(C3270) && defined(_WIN32) /*[*/ - char highlight_underline; -#endif /*]*/ +// char color8; +// char bsd_tm; +// char unlock_delay; +// #if defined(X3270_SCRIPT) /*[*/ +// char socket; +// #endif /*]*/ +// #if defined(C3270) && defined(_WIN32) /*[*/ +// char highlight_underline; +//#endif /*]*/ /* Named resources */ /* @@ -108,7 +108,7 @@ typedef struct { #if defined(X3270_DISPLAY) || defined(C3270) // char *key_map; char *compose_map; - char *printer_lu; +// char *printer_lu; #endif /* #if defined(X3270_DISPLAY) @@ -148,10 +148,10 @@ typedef struct { char *conf_dir; char *model; // char *hostsfile; - char *port; +// char *port; char *charset; - char *termname; - char *login_macro; +// char *termname; +// char *login_macro; char *macros; #if defined(X3270_TRACE) /*[*/ #if !defined(_WIN32) /*[*/ @@ -186,7 +186,7 @@ typedef struct { #if defined(HAVE_LIBSSL) /*[*/ char *cert_file; #endif /*]*/ - char *proxy; +// char *proxy; /* Toggles */ // struct toggle toggle[N_TOGGLES]; @@ -198,8 +198,10 @@ typedef struct { Cursor locked_mcursor; #endif */ -#if defined(X3270_ANSI) /*[*/ - /* Line-mode TTY parameters */ + +/* +#if defined(X3270_ANSI) + // Line-mode TTY parameters char icrnl; char inlcr; char onlcr; @@ -211,11 +213,12 @@ typedef struct { char *intr; char *quit; char *eof; -#endif /*]*/ - -#if defined(WC3270) /*[*/ - char *hostname; #endif +*/ + +// #if defined(WC3270) /*[*/ +// char *hostname; +// #endif /* #if defined(WC3270) diff --git a/ctlr.c b/ctlr.c index f11d6bd..f01a0da 100644 --- a/ctlr.c +++ b/ctlr.c @@ -150,8 +150,8 @@ void ctlr_init(H3270 *session, unsigned cmask unused) { /* Register callback routines. */ lib3270_register_schange(session,ST_HALF_CONNECT, ctlr_half_connect, 0); - lib3270_register_schange(session,ST_CONNECT, ctlr_connect, 0); - lib3270_register_schange(session,ST_3270_MODE, ctlr_connect, 0); + lib3270_register_schange(session,LIB3270_STATE_CONNECT, ctlr_connect, 0); + lib3270_register_schange(session,LIB3270_STATE_3270_MODE, ctlr_connect, 0); } /* * Reinitialize the emulated 3270 hardware. @@ -2320,7 +2320,7 @@ ctlr_clear(H3270 *session, Boolean can_snap) /* Snap any data that is about to be lost into the trace file. */ if (ctlr_any_data()) { #if defined(X3270_TRACE) /*[*/ - if (can_snap && !trace_skipping && toggled(SCREEN_TRACE)) + if (can_snap && !trace_skipping && lib3270_get_toggle(session,SCREEN_TRACE)) trace_screen(); #endif /*]*/ // scroll_save(session->maxROWS, ever_3270 ? False : True); @@ -2379,7 +2379,7 @@ void ctlr_add(int baddr, unsigned char c, unsigned char cs) if (trace_primed && !IsBlank(oc)) { #if defined(X3270_TRACE) /*[*/ - if (toggled(SCREEN_TRACE)) + if (lib3270_get_toggle(&h3270,SCREEN_TRACE)) trace_screen(); #endif /*]*/ trace_primed = False; @@ -2739,7 +2739,7 @@ void ticking_start(H3270 *session, Boolean anyway) if(session->set_timer) { - if(toggled(SHOW_TIMING) || anyway) + if(lib3270_get_toggle(&h3270,SHOW_TIMING) || anyway) session->set_timer(session,1); } else @@ -2748,7 +2748,7 @@ void ticking_start(H3270 *session, Boolean anyway) mticking = True; - if (!toggled(SHOW_TIMING) && !anyway) + if (!lib3270_get_toggle(&h3270,SHOW_TIMING) && !anyway) return; status_untiming(session); diff --git a/ft.c b/ft.c index 8ba4347..9c16509 100644 --- a/ft.c +++ b/ft.c @@ -114,8 +114,8 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); void ft_init(H3270 *session) { /* Register for state changes. */ - lib3270_register_schange(session, ST_CONNECT, ( void (*)(H3270 *, int, void *)) ft_connected, NULL); - lib3270_register_schange(session, ST_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, NULL); + lib3270_register_schange(session, LIB3270_STATE_CONNECT, ( void (*)(H3270 *, int, void *)) ft_connected, NULL); + lib3270_register_schange(session, LIB3270_STATE_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, NULL); } // enum ft_state QueryFTstate(void) diff --git a/globals.h b/globals.h index 8c09ccd..99d87a3 100644 --- a/globals.h +++ b/globals.h @@ -307,22 +307,6 @@ LIB3270_INTERNAL struct trans_list *trans_list; /* input key type */ // enum keytype { KT_STD, KT_GE }; -/* state changes */ /* -enum state_change -{ - ST_RESOLVING, - ST_HALF_CONNECT, - ST_CONNECT, - ST_3270_MODE, - ST_LINE_MODE, - ST_REMODEL, - ST_PRINTER, - ST_EXITING, - ST_CHARSET, - - N_ST // Always the last one -}; */ - /* Naming convention for private actions. */ #define PA_PFX "PA-" diff --git a/glue.c b/glue.c index 7771f4f..dd03147 100644 --- a/glue.c +++ b/glue.c @@ -141,7 +141,7 @@ static void initialize(void) #endif /*]*/ // appres.modified_sel = False; - appres.apl_mode = False; +// appres.apl_mode = False; /* #if defined(C3270) || defined(TCL3270) @@ -151,16 +151,16 @@ static void initialize(void) #endif */ - appres.numeric_lock = False; +// appres.numeric_lock = False; // appres.secure = False; #if defined(C3270) /*[*/ - appres.oerr_lock = True; +// appres.oerr_lock = True; #else /*][*/ - appres.oerr_lock = False; +// appres.oerr_lock = False; #endif /*]*/ - appres.typeahead = True; +// appres.typeahead = True; appres.debug_tracing = True; #if defined(C3270) /*[*/ @@ -169,7 +169,7 @@ static void initialize(void) appres.model = ""; // appres.hostsfile = CN; - appres.port = "telnet"; +// appres.port = "telnet"; #if !defined(_WIN32) /*[*/ appres.charset = "bracket"; @@ -181,7 +181,7 @@ static void initialize(void) appres.charset = "bracket437"; #endif /*]*/ - appres.termname = CN; +// appres.termname = CN; appres.macros = CN; #if defined(X3270_TRACE) /*[*/ @@ -206,21 +206,21 @@ static void initialize(void) // appres.cbreak_mode = False; #endif /*]*/ -#if defined(X3270_ANSI) /*[*/ - appres.icrnl = True; - appres.inlcr = False; - appres.onlcr = True; - appres.erase = "^H"; - appres.kill = "^U"; - appres.werase = "^W"; - appres.rprnt = "^R"; - appres.lnext = "^V"; - appres.intr = "^C"; - appres.quit = "^\\"; - appres.eof = "^D"; +#if defined(X3270_ANSI) +// appres.icrnl = True; +// appres.inlcr = False; +// appres.onlcr = True; +// appres.erase = "^H"; +// appres.kill = "^U"; +// appres.werase = "^W"; +// appres.rprnt = "^R"; +// appres.lnext = "^V"; +// appres.intr = "^C"; +// appres.quit = "^\\"; +// appres.eof = "^D"; #endif /*]*/ - appres.unlock_delay = True; +// appres.unlock_delay = True; #if defined(X3270_FT) /*[*/ appres.dft_buffer_size = DFT_BUF; @@ -296,7 +296,7 @@ static const struct lib3270_option options[] = // { OptAllBold, OPT_BOOLEAN, True, ResAllBold, offset(all_bold_on), NULL }, // { OptAltScreen,OPT_STRING, False, ResAltScreen, offset(altscreen), NULL }, //#endif /*]*/ - { OptAplMode, OPT_BOOLEAN, True, ResAplMode, offset(apl_mode), NULL }, +// { OptAplMode, OPT_BOOLEAN, True, ResAplMode, offset(apl_mode), NULL }, #if defined(C3270) /*[*/ // { OptCbreak, OPT_BOOLEAN, True, ResCbreak, offset(cbreak_mode), NULL }, #endif /*]*/ @@ -323,11 +323,11 @@ static const struct lib3270_option options[] = // #endif /*]*/ // { OptOnce, OPT_BOOLEAN, True, ResOnce, offset(once), NULL }, // { OptOversize, OPT_STRING, False, ResOversize, offset(oversize), N_( "Sets the screen dimensions to be larger than the default for the chosen model (COLSxROWS)." ) }, - { OptPort, OPT_STRING, False, ResPort, offset(port), N_( "The name of the default TCP port to connect" ) }, +// { OptPort, OPT_STRING, False, ResPort, offset(port), N_( "The name of the default TCP port to connect" ) }, #if defined(C3270) && !defined(LIB3270) /*[*/ - { OptPrinterLu,OPT_STRING, False, ResPrinterLu, offset(printer_lu), NULL }, +// { OptPrinterLu,OPT_STRING, False, ResPrinterLu, offset(printer_lu), NULL }, #endif /*]*/ - { OptProxy, OPT_STRING, False, ResProxy, offset(proxy), N_( "Proxy server (type:host[:port])" ) }, +// { OptProxy, OPT_STRING, False, ResProxy, offset(proxy), N_( "Proxy server (type:host[:port])" ) }, #if defined(S3270) /*[*/ { OptScripted, OPT_NOP, False, ResScripted, NULL, NULL }, #endif /*]*/ @@ -339,7 +339,7 @@ static const struct lib3270_option options[] = { OptSocket, OPT_BOOLEAN, True, ResSocket, offset(socket), NULL }, #endif /*]*/ - { OptTermName, OPT_STRING, False, ResTermName, offset(termname), N_( "Specifies the terminal name to be transmitted over the telnet connection." ) }, +// { OptTermName, OPT_STRING, False, ResTermName, offset(termname), N_( "Specifies the terminal name to be transmitted over the telnet connection." ) }, #if defined(WC3270) /*[*/ { OptTitle, OPT_STRING, False, ResTitle, offset(title), NULL }, @@ -377,17 +377,17 @@ static struct { } resources[] = { { ResAllBold, offset(all_bold), XRM_STRING }, // { ResAltScreen, offset(altscreen), XRM_STRING }, - { ResBsdTm, offset(bsd_tm), XRM_BOOLEAN }, +// { ResBsdTm, offset(bsd_tm), XRM_BOOLEAN }, #if defined(HAVE_LIBSSL) /*[*/ { ResCertFile, offset(cert_file), XRM_STRING }, #endif /*]*/ { ResCharset, offset(charset), XRM_STRING }, - { ResColor8, offset(color8), XRM_BOOLEAN }, +// { ResColor8, offset(color8), XRM_BOOLEAN }, { ResConfDir, offset(conf_dir), XRM_STRING }, // { ResDefScreen, offset(defscreen), XRM_STRING }, #if defined(X3270_ANSI) /*[*/ - { ResEof, offset(eof), XRM_STRING }, - { ResErase, offset(erase), XRM_STRING }, +// { ResEof, offset(eof), XRM_STRING }, +// { ResErase, offset(erase), XRM_STRING }, #endif /*]*/ // { ResExtended, offset(extended), XRM_BOOLEAN }, #if defined(X3270_FT) /*[*/ @@ -399,10 +399,10 @@ static struct { #endif /*]*/ // { ResHostsFile, offset(hostsfile), XRM_STRING }, #if defined(X3270_ANSI) /*[*/ - { ResIcrnl, offset(icrnl), XRM_BOOLEAN }, - { ResInlcr, offset(inlcr), XRM_BOOLEAN }, - { ResOnlcr, offset(onlcr), XRM_BOOLEAN }, - { ResIntr, offset(intr), XRM_STRING }, +// { ResIcrnl, offset(icrnl), XRM_BOOLEAN }, +// { ResInlcr, offset(inlcr), XRM_BOOLEAN }, +// { ResOnlcr, offset(onlcr), XRM_BOOLEAN }, +// { ResIntr, offset(intr), XRM_STRING }, #endif /*]*/ #if defined(X3270_SCRIPT) /*[*/ { ResPluginCommand, offset(plugin_command), XRM_STRING }, @@ -422,31 +422,31 @@ static struct { // { ResCbreak, offset(cbreak_mode), XRM_BOOLEAN }, #endif /*]*/ #if defined(X3270_ANSI) /*[*/ - { ResKill, offset(kill), XRM_STRING }, - { ResLnext, offset(lnext), XRM_STRING }, +// { ResKill, offset(kill), XRM_STRING }, +// { ResLnext, offset(lnext), XRM_STRING }, #endif /*]*/ - { ResLoginMacro,offset(login_macro), XRM_STRING }, +// { ResLoginMacro,offset(login_macro), XRM_STRING }, // { ResM3279, offset(m3279), XRM_BOOLEAN }, // { ResModel, offset(model), XRM_STRING }, // { ResModifiedSel, offset(modified_sel), XRM_BOOLEAN }, //#if defined(C3270) && !defined(_WIN32) /*[*/ // { ResMono, offset(mono), XRM_BOOLEAN }, //#endif /*]*/ - { ResNumericLock, offset(numeric_lock), XRM_BOOLEAN }, - { ResOerrLock, offset(oerr_lock), XRM_BOOLEAN }, +// { ResNumericLock, offset(numeric_lock), XRM_BOOLEAN }, +// { ResOerrLock, offset(oerr_lock), XRM_BOOLEAN }, // { ResOversize, offset(oversize), XRM_STRING }, - { ResPort, offset(port), XRM_STRING }, +// { ResPort, offset(port), XRM_STRING }, #if defined(C3270) /*[*/ - { ResPrinterLu, offset(printer_lu), XRM_STRING }, +// { ResPrinterLu, offset(printer_lu), XRM_STRING }, { ResPrintTextCommand, NULL, XRM_STRING }, #endif /*]*/ - { ResProxy, offset(proxy), XRM_STRING }, +// { ResProxy, offset(proxy), XRM_STRING }, #if defined(X3270_ANSI) /*[*/ - { ResQuit, offset(quit), XRM_STRING }, - { ResRprnt, offset(rprnt), XRM_STRING }, +// { ResQuit, offset(quit), XRM_STRING }, +// { ResRprnt, offset(rprnt), XRM_STRING }, #endif /*]*/ // { ResSecure, offset(secure), XRM_BOOLEAN }, - { ResTermName, offset(termname), XRM_STRING }, +// { ResTermName, offset(termname), XRM_STRING }, #if defined(WC3270) /*[*/ { ResTitle, offset(title), XRM_STRING }, #endif /*]*/ @@ -460,10 +460,10 @@ static struct { { ResTraceMonitor,offset(trace_monitor),XRM_BOOLEAN }, #endif /*]*/ #endif /*]*/ - { ResTypeahead, offset(typeahead), XRM_BOOLEAN }, - { ResUnlockDelay,offset(unlock_delay), XRM_BOOLEAN }, +// { ResTypeahead, offset(typeahead), XRM_BOOLEAN }, +// { ResUnlockDelay,offset(unlock_delay), XRM_BOOLEAN }, #if defined(X3270_ANSI) /*[*/ - { ResWerase, offset(werase), XRM_STRING }, +// { ResWerase, offset(werase), XRM_STRING }, #endif /*]*/ { CN, 0, XRM_STRING } diff --git a/host.c b/host.c index 8ae74a4..8a6a395 100644 --- a/host.c +++ b/host.c @@ -39,7 +39,7 @@ */ #include "globals.h" -#include "appres.h" +// #include "appres.h" #include "resources.h" #include "actionsc.h" @@ -477,7 +477,7 @@ static int do_connect(H3270 *hSession, const char *n) char nb[2048]; /* name buffer */ char *s; /* temporary */ const char *chost; /* to whom we will connect */ - char *ps = CN; +// char *ps = CN; char *port = CN; Boolean resolving; Boolean pending; @@ -522,7 +522,7 @@ static int do_connect(H3270 *hSession, const char *n) /* Default the port. */ if (port == CN) - port = appres.port; + port = "telnet"; } /* @@ -566,8 +566,8 @@ static int do_connect(H3270 *hSession, const char *n) /* Success. */ /* Set pending string. */ - if (ps == CN) - ps = appres.login_macro; +// if (ps == CN) +// ps = appres.login_macro; // if (ps != CN) // login_macro(ps); @@ -656,7 +656,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) static void try_reconnect(H3270 *session) { lib3270_write_log(session,"3270","Starting auto-reconnect (Host: %s)",session->full_current_host ? session->full_current_host : "-"); - session->auto_reconnect_inprogress = False; + session->auto_reconnect_inprogress = 0; lib3270_reconnect(session,0); } @@ -686,11 +686,11 @@ void host_disconnect(H3270 *h, int failed) net_disconnect(h); - Trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,toggled(RECONNECT),h->auto_reconnect_inprogress); - if (toggled(RECONNECT) && !h->auto_reconnect_inprogress) + trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,lib3270_get_toggle(h,LIB3270_TOGGLE_RECONNECT),h->auto_reconnect_inprogress); + if (lib3270_get_toggle(h,LIB3270_TOGGLE_RECONNECT) && !h->auto_reconnect_inprogress) { /* Schedule an automatic reconnection. */ - h->auto_reconnect_inprogress = True; + h->auto_reconnect_inprogress = 1; (void) AddTimeOut(failed ? RECONNECT_ERR_MS: RECONNECT_MS, h, try_reconnect); } @@ -699,7 +699,7 @@ void host_disconnect(H3270 *h, int failed) * in sync. */ #if defined(X3270_TRACE) /*[*/ - if (IN_ANSI && toggled(SCREEN_TRACE)) + if (IN_ANSI && lib3270_get_toggle(h,LIB3270_TOGGLE_SCREEN_TRACE)) trace_ansi_disc(); #endif /*]*/ @@ -716,13 +716,13 @@ void host_in3270(H3270 *session, LIB3270_CSTATE new_cstate) session->cstate = new_cstate; session->ever_3270 = now3270; - lib3270_st_changed(session, ST_3270_MODE, now3270); + lib3270_st_changed(session, LIB3270_STATE_3270_MODE, now3270); } void host_connected(H3270 *session) { session->cstate = CONNECTED_INITIAL; - lib3270_st_changed(session, ST_CONNECT, True); + lib3270_st_changed(session, LIB3270_STATE_CONNECT, True); if(session->update_connect) session->update_connect(session,1); } @@ -731,7 +731,7 @@ void host_disconnected(H3270 *session) { session->cstate = NOT_CONNECTED; set_status(session,OIA_FLAG_UNDERA,False); - lib3270_st_changed(session,ST_CONNECT, False); + lib3270_st_changed(session,LIB3270_STATE_CONNECT, False); status_changed(session,LIB3270_MESSAGE_DISCONNECTED); if(session->update_connect) session->update_connect(session,0); @@ -758,15 +758,35 @@ LIB3270_EXPORT void lib3270_register_schange(H3270 *h,LIB3270_STATE_CHANGE tx, v } /* Signal a state change. */ -void lib3270_st_changed(H3270 *h, int tx, int mode) +void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) { +#if defined(DEBUG) + + static const char * state_name[LIB3270_STATE_USER] = + { + "LIB3270_STATE_RESOLVING", + "LIB3270_STATE_HALF_CONNECT", + "LIB3270_STATE_CONNECT", + "LIB3270_STATE_3270_MODE", + "LIB3270_STATE_LINE_MODE", + "LIB3270_STATE_REMODEL", + "LIB3270_STATE_PRINTER", + "LIB3270_STATE_EXITING", + "LIB3270_STATE_CHARSET", + + }; + +#endif // DEBUG + struct lib3270_state_callback *st; CHECK_SESSION_HANDLE(h); + trace("%s is %d",state_name[tx],mode); + for (st = h->st_callbacks[tx];st != (struct lib3270_state_callback *)NULL;st = st->next) { - (*st->func)(h,mode,st->data); + st->func(h,mode,st->data); } } @@ -817,7 +837,7 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) if(rc) { - h->auto_reconnect_inprogress = False; + h->auto_reconnect_inprogress = 0; return rc; } diff --git a/hostc.h b/hostc.h index 9caf86e..f50713f 100644 --- a/hostc.h +++ b/hostc.h @@ -21,7 +21,7 @@ #define st_changed(tx,mode) lib3270_st_changed(NULL,tx,mode) - LIB3270_INTERNAL void lib3270_st_changed(H3270 *h, int tx, int mode); + LIB3270_INTERNAL void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode); LIB3270_INTERNAL void host_connected(H3270 *session); LIB3270_INTERNAL void host_disconnected(H3270 *session); LIB3270_INTERNAL void host_in3270(H3270 *session, LIB3270_CSTATE); diff --git a/init.c b/init.c index 7b19e9f..56b2918 100644 --- a/init.c +++ b/init.c @@ -134,7 +134,12 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->sz = sizeof(H3270); // Set the defaults. - hSession->extended = 1; + hSession->extended = 1; + hSession->typeahead = 1; + hSession->oerr_lock = 1; + hSession->unlock_delay = 1; + hSession->icrnl = 1; + hSession->onlcr = 1; // Initialize toggles initialize_toggles(hSession); @@ -208,14 +213,14 @@ static void lib3270_session_init(H3270 *hSession, const char *model) } ctlr_set_rows_cols(hSession, model_number, ovc, ovr); - if (appres.termname != CN) - hSession->termtype = appres.termname; + if (hSession->termname != CN) + hSession->termtype = hSession->termname; else hSession->termtype = hSession->full_model_name; Trace("Termtype: %s",hSession->termtype); - if (appres.apl_mode) + if (hSession->apl_mode) appres.charset = "apl"; } diff --git a/kybd.c b/kybd.c index 36f3bd5..9b77abd 100644 --- a/kybd.c +++ b/kybd.c @@ -48,7 +48,7 @@ #include #include "3270ds.h" -#include "appres.h" +// #include "appres.h" // #include "ctlr.h" #include "resources.h" @@ -195,7 +195,7 @@ static int enq_chk(void) } /* If typeahead disabled, complain and drop it. */ - if (!appres.typeahead) + if (!h3270.typeahead) { trace_event(" dropped (no typeahead)\n"); return -1; @@ -439,8 +439,8 @@ kybd_in3270(H3270 *session, int in3270 unused, void *dunno) void kybd_init(void) { /* Register interest in connect and disconnect events. */ - register_schange(ST_CONNECT, kybd_connect); - register_schange(ST_3270_MODE, kybd_in3270); + lib3270_register_schange(NULL,LIB3270_STATE_CONNECT,kybd_connect,NULL); + lib3270_register_schange(NULL,LIB3270_STATE_3270_MODE,kybd_in3270,NULL); } /* @@ -464,12 +464,15 @@ operator_error(int error_type) // if (sms_redirect()) // popup_an_error("Keyboard locked"); - if(appres.oerr_lock) { // || sms_redirect()) { + if(h3270.oerr_lock) + { status_oerr(NULL,error_type); mcursor_locked(&h3270); kybdlock_set((unsigned int)error_type, "operator_error"); - (void) flush_ta(); - } else { + flush_ta(); + } + else + { lib3270_ring_bell(NULL); } } @@ -652,7 +655,7 @@ static Boolean ins_prep(int faddr, int baddr, int count) while (need && (xaddr != next_faddr)) { if (h3270.ea_buf[xaddr].cc == EBC_null) need--; - else if (toggled(LIB3270_TOGGLE_BLANK_FILL) && + else if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_BLANK_FILL) && ((h3270.ea_buf[xaddr].cc == EBC_space) || (h3270.ea_buf[xaddr].cc == EBC_underscore))) { if (tb_start == -1) @@ -770,7 +773,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean operator_error(KL_OERR_PROTECTED); return False; } - if (appres.numeric_lock && FA_IS_NUMERIC(fa) && + if (h3270.numeric_lock && FA_IS_NUMERIC(fa) && !((code >= EBC_0 && code <= EBC_9) || code == EBC_minus || code == EBC_period)) { operator_error(KL_OERR_NUMERIC); @@ -795,7 +798,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean /* Add the character. */ if (h3270.ea_buf[baddr].cc == EBC_so) { - if (toggled(LIB3270_TOGGLE_INSERT)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) { if (!ins_prep(faddr, baddr, 1)) return False; } else { @@ -832,7 +835,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean /* fall through... */ case DBCS_LEFT: if (why == DBCS_ATTRIBUTE) { - if (toggled(LIB3270_TOGGLE_INSERT)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) { if (!ins_prep(faddr, baddr, 1)) return False; } else { @@ -849,7 +852,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean } else { Boolean was_si; - if (toggled(LIB3270_TOGGLE_INSERT)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) { /* * Inserting SBCS into a DBCS subfield. * If this is the first position, we @@ -906,7 +909,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean break; default: case DBCS_NONE: - if (toggled(LIB3270_TOGGLE_INSERT) && !ins_prep(faddr, baddr, 1)) + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT) && !ins_prep(faddr, baddr, 1)) return False; break; } @@ -916,7 +919,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean INC_BA(baddr); /* Replace leading nulls with blanks, if desired. */ - if (h3270.formatted && toggled(BLANK_FILL)) { + if (h3270.formatted && lib3270_get_toggle(&h3270,LIB3270_TOGGLE_BLANK_FILL)) { register int baddr_fill = baddr; DEC_BA(baddr_fill); @@ -1047,7 +1050,7 @@ key_WCharacter(unsigned char code[], Boolean *skipped) } /* Numeric? */ - if (appres.numeric_lock && FA_IS_NUMERIC(fa)) { + if (h3270.numeric_lock && FA_IS_NUMERIC(fa)) { operator_error(KL_OERR_NUMERIC); return False; } @@ -1250,7 +1253,7 @@ retry: if (done) { /* Implement blank fill mode. */ - if (toggled(BLANK_FILL)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_BLANK_FILL)) { xaddr = faddr; INC_BA(xaddr); while (xaddr != baddr) { @@ -1505,7 +1508,7 @@ do_reset(Boolean explicit) #if defined(X3270_FT) /*[*/ || lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE #endif /*]*/ - || (!appres.unlock_delay) // && !sms_in_macro()) + || (!h3270.unlock_delay) // && !sms_in_macro()) || (unlock_delay_time != 0 && (time(NULL) - unlock_delay_time) > 1)) { kybdlock_clr(-1, "do_reset"); } else if (kybdlock & @@ -3010,7 +3013,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p return len-1; /* wrapped */ /* Jump cursor over left margin. */ - if (toggled(MARGINED_PASTE) && + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(session->cursor_addr) < orig_col) { if (!remargin(orig_col)) return len-1; @@ -3291,7 +3294,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p switch (state) { case BASE: - if (toggled(MARGINED_PASTE) && + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(session->cursor_addr) < orig_col) { (void) remargin(orig_col); } @@ -3300,7 +3303,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p case HEX: key_ACharacter((unsigned char) literal, KT_STD, ia, &skipped); state = BASE; - if (toggled(MARGINED_PASTE) && + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(session->cursor_addr) < orig_col) { (void) remargin(orig_col); } diff --git a/paste.c b/paste.c index 0b7c0eb..52a5e2e 100644 --- a/paste.c +++ b/paste.c @@ -107,7 +107,7 @@ int faddr; unsigned char fa; - if(toggled(MARGINED_PASTE)) + if(lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE)) { baddr = session->cursor_addr; while(BA_TO_COL(baddr) < lmargin) @@ -138,7 +138,7 @@ static int paste_char(H3270 *session, PASTE_DATA *data, unsigned char c) { - if(toggled(SMART_PASTE)) + if(lib3270_get_toggle(session,SMART_PASTE)) { int faddr = find_field_attribute(session,session->cursor_addr); if(FA_IS_PROTECTED(session->ea_buf[faddr].fa)) @@ -226,7 +226,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) } str++; - if(IN_3270 && toggled(MARGINED_PASTE) && BA_TO_COL(h->cursor_addr) < data.orig_col) + if(IN_3270 && lib3270_get_toggle(h,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(h->cursor_addr) < data.orig_col) { if(!remargin(h,data.orig_col)) last = 0; diff --git a/proxy.c b/proxy.c index fb3ca9d..958436d 100644 --- a/proxy.c +++ b/proxy.c @@ -35,35 +35,39 @@ * proxy.c * This module implements various kinds of proxies. */ + #ifdef _WIN32 #include #include #endif // _WIN32 #include "globals.h" -#if !defined(PR3287) /*[*/ + #include "appres.h" #include "resources.h" -#endif /*]*/ #ifndef ANDROID #include #endif #if defined(_WIN32) + #include + #else -#include -#include -#include -#include -#include -#include -#if defined(HAVE_SYS_SELECT_H) /*[*/ -#include /* fd_set declaration */ -#endif /*]*/ -#endif /*]*/ + #include + #include + #include + #include + #include + #include + +// #if defined(HAVE_SYS_SELECT_H) +// #include +// #endif + +#endif #include "api.h" @@ -76,30 +80,32 @@ #include "w3miscc.h" #include "screen.h" -#if defined(PR3287) /*[*/ -extern char *proxy_spec; -#endif /*]*/ +// #if defined(PR3287) +// extern char *proxy_spec; +// #endif /* * Supported proxy types. * * At some point we will add SOCKS. */ -enum { - PT_NONE, - PT_PASSTHRU, /* Sun telnet-passthru */ - PT_HTTP, /* RFC 2817 CONNECT tunnel */ - PT_TELNET, /* 'connect host port' proxy */ - PT_SOCKS4, /* SOCKS version 4 (or 4A if necessary) */ - PT_SOCKS4A, /* SOCKS version 4A (force remote name resolution) */ - PT_SOCKS5, /* SOCKS version 5 (RFC 1928) */ - PT_SOCKS5D, /* SOCKS version 5 (force remote name resolution) */ +enum +{ + PT_NONE, + PT_PASSTHRU, /**< Sun telnet-passthru */ + PT_HTTP, /**< RFC 2817 CONNECT tunnel */ + PT_TELNET, /**< 'connect host port' proxy */ + PT_SOCKS4, /**< SOCKS version 4 (or 4A if necessary) */ + PT_SOCKS4A, /**< SOCKS version 4A (force remote name resolution) */ + PT_SOCKS5, /**< SOCKS version 5 (RFC 1928) */ + PT_SOCKS5D, /**< SOCKS version 5 (force remote name resolution) */ PT_MAX } proxytype_t; /* proxy type names -- keep these in sync with proxytype_t! */ -char *type_name[] = { - "unknown", +char *type_name[] = +{ + "unknown", "passthru", "HTTP", "TELNET", @@ -138,8 +144,7 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a); static int proxy_socks5(int fd, char *host, unsigned short port, int force_d); -char * -proxy_type_name(int type) +char * proxy_type_name(int type) { if (type < 1 || type >= PT_MAX) return "unknown"; @@ -151,38 +156,35 @@ proxy_type_name(int type) * Resolve the type, hostname and port for a proxy. * Returns -1 for failure, 0 for no proxy, >0 (the proxy type) for success. */ -int -proxy_setup(char **phost, char **pport) +int proxy_setup(H3270 *session, char **phost, char **pport) { - char *proxy; - char *colon; - int sl; + char * proxy = session->proxy; + char * colon; + int sl; -#if defined(PR3287) /*[*/ - proxy = proxy_spec; -#else /*][*/ - proxy = appres.proxy; -#endif /*]*/ - if (proxy == CN) - return PT_NONE; + if(!proxy) + return PT_NONE; - if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) { - popup_an_error(NULL,"Invalid proxy syntax"); + if ((colon = strchr(proxy, ':')) == CN || (colon == proxy)) + { + popup_an_error(session,_( "Invalid proxy syntax" ) ); return -1; } sl = colon - proxy; - if (sl == strlen(PROXY_PASSTHRU) && - !strncasecmp(proxy, PROXY_PASSTHRU, sl)) { - + if (sl == strlen(PROXY_PASSTHRU) && !strncasecmp(proxy, PROXY_PASSTHRU, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) - return -1; + return -1; + if (*pport == CN) - *pport = NewString(PORT_PASSTHRU); + *pport = NewString(PORT_PASSTHRU); + return PT_PASSTHRU; } - if (sl == strlen(PROXY_HTTP) && - !strncasecmp(proxy, PROXY_HTTP, sl)) { + + if (sl == strlen(PROXY_HTTP) && !strncasecmp(proxy, PROXY_HTTP, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) return -1; @@ -190,54 +192,66 @@ proxy_setup(char **phost, char **pport) *pport = NewString(PORT_HTTP); return PT_HTTP; } - if (sl == strlen(PROXY_TELNET) && - !strncasecmp(proxy, PROXY_TELNET, sl)) { + + if (sl == strlen(PROXY_TELNET) && !strncasecmp(proxy, PROXY_TELNET, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) return -1; - if (*pport == CN) { - popup_an_error(NULL,"Must specify port for telnet proxy"); + if (*pport == CN) + { + popup_an_error(session,_( "Must specify port for telnet proxy" ) ); return -1; } return PT_TELNET; } - if (sl == strlen(PROXY_SOCKS4) && - !strncasecmp(proxy, PROXY_SOCKS4, sl)) { + if (sl == strlen(PROXY_SOCKS4) && !strncasecmp(proxy, PROXY_SOCKS4, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) - return -1; + return -1; + if (*pport == CN) - *pport = NewString(PORT_SOCKS4); + *pport = NewString(PORT_SOCKS4); + return PT_SOCKS4; } - if (sl == strlen(PROXY_SOCKS4A) && - !strncasecmp(proxy, PROXY_SOCKS4A, sl)) { + if (sl == strlen(PROXY_SOCKS4A) && !strncasecmp(proxy, PROXY_SOCKS4A, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) - return -1; + return -1; + if (*pport == CN) - *pport = NewString(PORT_SOCKS4A); + *pport = NewString(PORT_SOCKS4A); + return PT_SOCKS4A; } - if (sl == strlen(PROXY_SOCKS5) && - !strncasecmp(proxy, PROXY_SOCKS5, sl)) { + if (sl == strlen(PROXY_SOCKS5) && !strncasecmp(proxy, PROXY_SOCKS5, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) - return -1; + return -1; + if (*pport == CN) - *pport = NewString(PORT_SOCKS5); + *pport = NewString(PORT_SOCKS5); + return PT_SOCKS5; } - if (sl == strlen(PROXY_SOCKS5D) && - !strncasecmp(proxy, PROXY_SOCKS5D, sl)) { + if (sl == strlen(PROXY_SOCKS5D) && !strncasecmp(proxy, PROXY_SOCKS5D, sl)) + { if (parse_host_port(colon + 1, phost, pport) < 0) - return -1; + return -1; + if (*pport == CN) - *pport = NewString(PORT_SOCKS5D); + *pport = NewString(PORT_SOCKS5D); + return PT_SOCKS5D; } - popup_an_error(NULL,"Invalid proxy type '%.*s'", sl, proxy); + + popup_an_error(session,"Invalid proxy type '%.*s'", sl, proxy); + return -1; } diff --git a/proxyc.h b/proxyc.h index 6e1a947..c2c6094 100644 --- a/proxyc.h +++ b/proxyc.h @@ -17,6 +17,6 @@ * Declarations for proxy.c. */ -LIB3270_INTERNAL int proxy_setup(char **phost, char **pport); -LIB3270_INTERNAL int proxy_negotiate(int type, int fd, char *host, unsigned short port); -LIB3270_INTERNAL char *proxy_type_name(int type); +LIB3270_INTERNAL int proxy_setup(H3270 *session, char **phost, char **pport); +LIB3270_INTERNAL int proxy_negotiate(int type, int fd, char *host, unsigned short port); +LIB3270_INTERNAL char * proxy_type_name(int type); diff --git a/rpq.c b/rpq.c index e06ab4e..44d52ba 100644 --- a/rpq.c +++ b/rpq.c @@ -48,7 +48,9 @@ #include #endif /*]*/ -#include +#ifndef ANDROID + #include +#endif // !ANDROID #include "api.h" @@ -202,8 +204,7 @@ do_qr_rpqnames(void) } break; - case RPQ_TIMESTAMP: /* program build time - (yyyymmddhhmmss bcd) */ + case RPQ_TIMESTAMP: /* program build time (yyyymmddhhmmss bcd) */ x = strlen(build_rpq_timestamp); omit_due_space_limit = ((x+1)/2 > remaining); if (!omit_due_space_limit) { @@ -220,8 +221,7 @@ do_qr_rpqnames(void) } if (omit_due_space_limit) - rpq_warning("RPQ %s term omitted due to insufficient " - "space", rpq_keywords[j].text); + rpq_warning("RPQ %s term omitted due to insufficient space", rpq_keywords[j].text); /* * The item is built, insert item length as needed and * adjust space remaining. @@ -367,8 +367,7 @@ select_rpq_terms(void) } /* Utility function used by the RPQNAMES query reply. */ -static int -get_rpq_timezone(void) +static int get_rpq_timezone(void) { /* * Return the signed number of minutes we're offset from UTC. @@ -402,8 +401,7 @@ get_rpq_timezone(void) x = strtol(p1, &p2, 10); if (errno != 0) { - rpq_warning("RPQ TIMEZONE term is invalid - " - "use +/-hhmm"); + rpq_warning("RPQ TIMEZONE term is invalid - use +/-hhmm"); return 4; } if ((*p2 != '\0') && (*p2 != ':') && (!isspace(*p2))) @@ -412,8 +410,7 @@ get_rpq_timezone(void) hhmm = ldiv(x, 100L); if (hhmm.rem > 59L) { - rpq_warning("RPQ TIMEZONE term is invalid - " - "use +/-hhmm"); + rpq_warning("RPQ TIMEZONE term is invalid - use +/-hhmm"); return 4; } @@ -424,15 +421,16 @@ get_rpq_timezone(void) * No override specified, try to get information from the * system. */ - if ((here = time(NULL)) == (time_t)(-1)) { - rpq_warning("RPQ: Unable to determine workstation " - "local time"); + if ((here = time(NULL)) == (time_t)(-1)) + { + rpq_warning("RPQ: Unable to determine workstation local time"); return 1; } memcpy(&here_tm, localtime(&here), sizeof(struct tm)); - if ((utc_tm = gmtime(&here)) == NULL) { - rpq_warning("RPQ: Unable to determine workstation UTC " - "time"); + + if ((utc_tm = gmtime(&here)) == NULL) + { + rpq_warning("RPQ: Unable to determine workstation UTC time"); return 2; } @@ -502,15 +500,13 @@ get_rpq_user(unsigned char buf[], const int buflen) if (isspace(c)) continue; /* skip white space */ if (!isxdigit(c)) { - rpq_warning("RPQ USER term has non-hex " - "character"); + rpq_warning("RPQ USER term has non-hex character"); break; } x = (p_h - hexstr)/2; if (x >= buflen) { x = buflen; - rpq_warning("RPQ USER term truncated after %d " - "bytes", x); + rpq_warning("RPQ USER term truncated after %d bytes", x); break; /* too long, truncate */ } @@ -529,8 +525,7 @@ get_rpq_user(unsigned char buf[], const int buflen) */ is_first_hex_digit = ((strlen(hexstr) % 2) == 0); if (!is_first_hex_digit) - rpq_warning("RPQ USER term has odd number of hex " - "digits"); + rpq_warning("RPQ USER term has odd number of hex digits"); *buf = 0; /* initialize first byte for possible implied leading zero */ for (p_h = &hexstr[0]; *p_h; p_h++) { @@ -555,8 +550,7 @@ get_rpq_user(unsigned char buf[], const int buflen) if ( x >= buflen) { x = buflen; - rpq_warning("RPQ USER term truncated after %d " - "characters", x); + rpq_warning("RPQ USER term truncated after %d characters", x); break; } @@ -630,8 +624,7 @@ get_rpq_address(unsigned char *buf, const int maxlen) len = sizeof(struct in6_addr); break; default: - rpq_warning("RPQ ADDRESS term has " - "unrecognized family %u", + rpq_warning("RPQ ADDRESS term has unrecognized family %u", res->ai_family); break; } @@ -640,8 +633,7 @@ get_rpq_address(unsigned char *buf, const int maxlen) x += len; (void) memcpy(buf, src, len); } else { - rpq_warning("RPQ ADDRESS term incomplete due " - "to space limit"); + rpq_warning("RPQ ADDRESS term incomplete due to space limit"); } /* Give back storage obtained by getaddrinfo */ freeaddrinfo(res); @@ -670,8 +662,7 @@ get_rpq_address(unsigned char *buf, const int maxlen) (void) memcpy(buf, &ia, sizeof(in_addr_t)); x += sizeof(in_addr_t); } else { - rpq_warning("RPQ ADDRESS term incomplete due to " - "space limit"); + rpq_warning("RPQ ADDRESS term incomplete due to space limit"); } #endif /*]*/ free(rpqtext); @@ -704,16 +695,14 @@ get_rpq_address(unsigned char *buf, const int maxlen) break; #endif /*]*/ default: - rpq_warning("RPQ ADDRESS term has unrecognized " - "family %u", u.sa.sa_family); + rpq_warning("RPQ ADDRESS term has unrecognized family %u", u.sa.sa_family); break; } if (x + len <= maxlen) { (void) memcpy(buf, src, len); x += len; } else { - rpq_warning("RPQ ADDRESS term incomplete due to space " - "limit"); + rpq_warning("RPQ ADDRESS term incomplete due to space limit"); } } return x; @@ -721,38 +710,46 @@ get_rpq_address(unsigned char *buf, const int maxlen) #endif /*]*/ #define RPQ_WARNBUF_SIZE 1024 -static char *rpq_warnbuf = CN; -static int rpq_wbcnt = 0; +static char * rpq_warnbuf = CN; +static int rpq_wbcnt = 0; -static void -rpq_warning(const char *fmt, ...) +static void rpq_warning(const char *fmt, ...) { va_list a; - /* Only accumulate RPQ warnings if they + va_start(a, fmt); + lib3270_write_va_log(&h3270,"RPQ",fmt,a); + va_end(a); + + /* + * Only accumulate RPQ warnings if they * have not been displayed already. */ - if (!rpq_complained) { + if (!rpq_complained) + { va_start(a, fmt); if (rpq_warnbuf == CN) rpq_warnbuf = Malloc(RPQ_WARNBUF_SIZE); - if (rpq_wbcnt < RPQ_WARNBUF_SIZE) { + + if (rpq_wbcnt < RPQ_WARNBUF_SIZE) + { *(rpq_warnbuf + rpq_wbcnt++) = '\n'; *(rpq_warnbuf + rpq_wbcnt) = '\0'; } - if (rpq_wbcnt < RPQ_WARNBUF_SIZE) { - rpq_wbcnt += vsnprintf(rpq_warnbuf + rpq_wbcnt, - RPQ_WARNBUF_SIZE - rpq_wbcnt, fmt, a); + + if (rpq_wbcnt < RPQ_WARNBUF_SIZE) + { + rpq_wbcnt += vsnprintf(rpq_warnbuf + rpq_wbcnt,RPQ_WARNBUF_SIZE - rpq_wbcnt, fmt, a); } va_end(a); } } -static void -rpq_dump_warnings(void) +static void rpq_dump_warnings(void) { /* If there's something to complain about, only complain once. */ - if (!rpq_complained && rpq_wbcnt) { + if (!rpq_complained && rpq_wbcnt) + { popup_an_error(NULL,rpq_warnbuf); rpq_wbcnt = 0; rpq_complained = True; diff --git a/screen.c b/screen.c index d05c62c..93e2f2e 100644 --- a/screen.c +++ b/screen.c @@ -83,7 +83,7 @@ enum ts { TS_AUTO, TS_ON, TS_OFF }; static void screen_update(H3270 *session, int bstart, int bend); static void status_connect(H3270 *session, int ignored, void *dunno); static void status_3270_mode(H3270 *session, int ignored, void *dunno); -static void status_printer(H3270 *session, int on, void *dunno); +// static void status_printer(H3270 *session, int on, void *dunno); static unsigned short color_from_fa(unsigned char fa); /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -131,9 +131,9 @@ int screen_init(H3270 *session) CHECK_SESSION_HANDLE(session); /* Set up callbacks for state changes. */ - lib3270_register_schange(session,ST_CONNECT, status_connect,0); - lib3270_register_schange(session,ST_3270_MODE, status_3270_mode,0); - lib3270_register_schange(session,ST_PRINTER, status_printer,0); + lib3270_register_schange(session,LIB3270_STATE_CONNECT, status_connect,0); + lib3270_register_schange(session,LIB3270_STATE_3270_MODE, status_3270_mode,0); +// lib3270_register_schange(session,ST_PRINTER, status_printer,0); /* Set up the controller. */ ctlr_init(session,-1); @@ -338,7 +338,7 @@ static void screen_update(H3270 *session, int bstart, int bend) } else { - if (toggled(MONOCASE)) + if (lib3270_get_toggle(session,MONOCASE)) addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); else addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); @@ -579,10 +579,12 @@ static void status_3270_mode(H3270 *session, int ignored unused, void *dunno) } +/* static void status_printer(H3270 *session, int on, void *dunno) { set_status(session,OIA_FLAG_PRINTER,on); } +*/ void status_timing(H3270 *session, struct timeval *t0, struct timeval *t1) { diff --git a/sf.c b/sf.c index 5599693..2dea6d8 100644 --- a/sf.c +++ b/sf.c @@ -43,7 +43,7 @@ #include #endif /*]*/ #include "3270ds.h" -#include "appres.h" +// #include "appres.h" #include "screen.h" // #include "ctlr.h" #include "resources.h" @@ -772,7 +772,7 @@ do_qr_color(void) trace_ds("> QueryReply(Color)\n"); - color_max = appres.color8? 8: 16; /* report on 8 or 16 colors */ + color_max = h3270.color8 ? 8: 16; /* report on 8 or 16 colors */ space3270out(4 + 2*15); *obptr++ = 0x00; /* no options */ @@ -904,7 +904,7 @@ do_qr_charsets(void) if (!*standard_font) { /* special 3270 font, includes APL */ *obptr++ = 0x01;/* SET 1: */ - if (appres.apl_mode) + if (h3270.apl_mode) *obptr++ = 0x00;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ else diff --git a/telnet.c b/telnet.c index 73d0360..fda624e 100644 --- a/telnet.c +++ b/telnet.c @@ -83,7 +83,7 @@ #include "tn3270e.h" #include "3270ds.h" -#include "appres.h" +// #include "appres.h" #include "ansic.h" #include "ctlrc.h" @@ -521,7 +521,18 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo netrbuf = (unsigned char *)Malloc(BUFSZ); #if defined(X3270_ANSI) /*[*/ - if (!t_valid) { + if (!t_valid) + { + vintr = parse_ctlchar("^C"); + vquit = parse_ctlchar("^\\"); + verase = parse_ctlchar("^H"); + vkill = parse_ctlchar("^U"); + veof = parse_ctlchar("^D"); + vwerase = parse_ctlchar("^W"); + vrprnt = parse_ctlchar("^R"); + vlnext = parse_ctlchar("^V"); + +/* vintr = parse_ctlchar(appres.intr); vquit = parse_ctlchar(appres.quit); verase = parse_ctlchar(appres.erase); @@ -530,6 +541,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo vwerase = parse_ctlchar(appres.werase); vrprnt = parse_ctlchar(appres.rprnt); vlnext = parse_ctlchar(appres.lnext); +*/ t_valid = 1; } #endif /*]*/ @@ -540,7 +552,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo Replace(session->hostname, NewString(host)); /* get the passthru host and port number */ - if (session->passthru_host) { + if (session->passthru_host) + { const char *hn = CN; #ifndef ANDROID @@ -563,27 +576,35 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo passthru_port = sp->s_port; else passthru_port = htons(3514); - } else if (appres.proxy != CN && !proxy_type) { - proxy_type = proxy_setup(&proxy_host, &proxy_portname); - if (proxy_type > 0) { - unsigned long lport; + } + else if(session->proxy != CN && !proxy_type) + { + proxy_type = proxy_setup(session, &proxy_host, &proxy_portname); + + if (proxy_type > 0) + { + unsigned long lport; char *ptr; struct servent *sp; lport = strtoul(portname, &ptr, 0); - if (ptr == portname || *ptr != '\0' || lport == 0L || - lport & ~0xffff) { - if (!(sp = getservbyname(portname, "tcp"))) { - popup_an_error(NULL,"Unknown port number " - "or service: %s", portname); + if (ptr == portname || *ptr != '\0' || lport == 0L || lport & ~0xffff) + { + if (!(sp = getservbyname(portname, "tcp"))) + { + popup_an_error(session, _( "Unknown port number or service: %s" ), portname); return -1; } session->current_port = ntohs(sp->s_port); - } else + } + else + { session->current_port = (unsigned short)lport; + } } + if (proxy_type < 0) - return -1; + return -1; } /* fill in the socket address of the given host */ @@ -679,9 +700,9 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo } /* set up temporary termtype */ - if (appres.termname == CN && session->std_ds_host) + if (session->termname == CN && session->std_ds_host) { - (void) sprintf(ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); + sprintf(ttype_tmpval, "IBM-327%c-%d",session->m3279 ? '9' : '8', session->model_num); session->termtype = ttype_tmpval; } @@ -932,7 +953,7 @@ void net_disconnect(H3270 *session) trace_dsn("SENT disconnect\n"); /* Restore terminal type to its default. */ - if (appres.termname == CN) + if (session->termname == CN) session->termtype = session->full_model_name; /* We're not connected to an LU any more. */ @@ -1216,7 +1237,7 @@ telnet_fsm(unsigned char c) } trace_dsn("%s",see_chr); if (!syncing) { - if (linemode && appres.onlcr && c == '\n') + if (linemode && h3270.onlcr && c == '\n') ansi_process((unsigned int) '\r'); ansi_process((unsigned int) c); // sms_store(c); @@ -1375,7 +1396,7 @@ telnet_fsm(unsigned char c) #endif /*]*/ if (c == TELOPT_TN3270E && h3270.non_tn3270e_host) goto wont; - if (c == TELOPT_TM && !appres.bsd_tm) + if (c == TELOPT_TM && !h3270.bsd_tm) goto wont; if (!myopts[c]) { @@ -1383,8 +1404,7 @@ telnet_fsm(unsigned char c) myopts[c] = 1; will_opt[2] = c; net_rawout(will_opt, sizeof(will_opt)); - trace_dsn("SENT %s %s\n", cmd(WILL), - opt(c)); + trace_dsn("SENT %s %s\n", cmd(WILL), opt(c)); check_in3270(); check_linemode(False); } @@ -2078,7 +2098,7 @@ net_hexansi_out(unsigned char *buf, int len) #if defined(X3270_TRACE) /*[*/ /* Trace the data. */ - if (toggled(DS_TRACE)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) { int i; trace_dsn(">"); @@ -2114,7 +2134,7 @@ static void net_cookedout(const char *buf, int len) { #if defined(X3270_TRACE) /*[*/ - if (toggled(DS_TRACE)) { + if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) { int i; trace_dsn(">"); @@ -2147,9 +2167,9 @@ net_cookout(const char *buf, int len) c = buf[i]; /* Input conversions. */ - if (!lnext && c == '\r' && appres.icrnl) + if (!lnext && c == '\r' && h3270.icrnl) c = '\n'; - else if (!lnext && c == '\n' && appres.inlcr) + else if (!lnext && c == '\n' && h3270.inlcr) c = '\r'; /* Backslashes. */ @@ -2637,7 +2657,7 @@ void trace_netdata(char direction, unsigned const char *buf, int len) struct timeval ts; double tdiff; - if (!toggled(DS_TRACE)) + if (!lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) return; (void) gettimeofday(&ts, (struct timezone *)NULL); if (IN_3270) { diff --git a/toggle.h b/toggle.h index 32ed14d..ba2cfa9 100644 --- a/toggle.h +++ b/toggle.h @@ -49,10 +49,10 @@ #define DS_TRACE LIB3270_TOGGLE_DS_TRACE #define SCROLL_BAR LIB3270_TOGGLE_SCROLL_BAR #define LINE_WRAP LIB3270_TOGGLE_LINE_WRAP - #define BLANK_FILL LIB3270_TOGGLE_BLANK_FILL +// #define BLANK_FILL LIB3270_TOGGLE_BLANK_FILL #define SCREEN_TRACE LIB3270_TOGGLE_SCREEN_TRACE #define EVENT_TRACE LIB3270_TOGGLE_EVENT_TRACE - #define MARGINED_PASTE LIB3270_TOGGLE_MARGINED_PASTE +// #define MARGINED_PASTE LIB3270_TOGGLE_MARGINED_PASTE #define RECTANGLE_SELECT LIB3270_TOGGLE_RECTANGLE_SELECT #define CROSSHAIR LIB3270_TOGGLE_CROSSHAIR // #define VISIBLE_CONTROL LIB3270_TOGGLE_VISIBLE_CONTROL diff --git a/trace_ds.c b/trace_ds.c index 67b6e54..787dd61 100644 --- a/trace_ds.c +++ b/trace_ds.c @@ -142,7 +142,7 @@ trace_ds_s(char *s, Boolean can_break) int len = strlen(s); Boolean nl = False; - if (!toggled(DS_TRACE) || !len) + if (!lib3270_get_toggle(&h3270,DS_TRACE) || !len) return; if (s && s[len-1] == '\n') { @@ -177,7 +177,7 @@ trace_ds(const char *fmt, ...) char tdsbuf[4096]; va_list args; - if (!toggled(DS_TRACE)) + if (!lib3270_get_toggle(&h3270,DS_TRACE)) return; va_start(args, fmt); @@ -194,7 +194,7 @@ trace_ds_nb(const char *fmt, ...) char tdsbuf[4096]; va_list args; - if (!toggled(DS_TRACE)) + if (!lib3270_get_toggle(&h3270,DS_TRACE)) return; va_start(args, fmt); @@ -211,7 +211,7 @@ trace_event(const char *fmt, ...) { va_list args; - if (!toggled(EVENT_TRACE)) + if (!lib3270_get_toggle(&h3270,EVENT_TRACE)) return; /* print out message */ @@ -226,7 +226,7 @@ trace_dsn(const char *fmt, ...) { va_list args; - if (!toggled(DS_TRACE)) + if (!lib3270_get_toggle(&h3270,DS_TRACE)) return; /* print out message */ @@ -760,14 +760,14 @@ static void tracefile_off(void) void toggle_dsTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) { - if (toggled(DS_TRACE) && tracef == NULL) + if (lib3270_get_toggle(&h3270,DS_TRACE) && tracef == NULL) tracefile_on(DS_TRACE, tt); // If turning off trace and not still tracing events, close the trace file. - else if (!toggled(DS_TRACE) && !toggled(EVENT_TRACE)) + else if (!lib3270_get_toggle(&h3270,DS_TRACE) && !lib3270_get_toggle(&h3270,EVENT_TRACE)) tracefile_off(); - if (toggled(DS_TRACE)) + if (lib3270_get_toggle(&h3270,DS_TRACE)) (void) gettimeofday(&ds_ts, (struct timezone *)NULL); } */ @@ -777,11 +777,11 @@ void toggle_eventTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_T { // If turning on event debug, and no trace file, open one. - if (toggled(EVENT_TRACE) && tracef == NULL) + if (lib3270_get_toggle(&h3270,EVENT_TRACE) && tracef == NULL) tracefile_on(EVENT_TRACE, tt); // If turning off event debug, and not tracing the data stream, close the trace file. - else if (!toggled(EVENT_TRACE) && !toggled(DS_TRACE)) + else if (!lib3270_get_toggle(&h3270,EVENT_TRACE) && !lib3270_get_toggle(&h3270,DS_TRACE)) tracefile_off(); } */ @@ -815,14 +815,14 @@ void trace_screen(void) { trace_skipping = False; - if (!toggled(SCREEN_TRACE)) + if (!lib3270_get_toggle(&h3270,SCREEN_TRACE)) do_screentrace(); } /* Called from ANSI emulation code to log a single character. */ void trace_char(char c) { - if (toggled(SCREEN_TRACE)) + if (lib3270_get_toggle(&h3270,SCREEN_TRACE)) wtrace("%c",c); return; } @@ -924,7 +924,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_ char *tracefile_buf = NULL; char *tracefile; - if (toggled(SCREEN_TRACE)) { + if (lib3270_get_toggle(&h3270,SCREEN_TRACE)) { if (appres.screentrace_file) tracefile = appres.screentrace_file; else { -- libgit2 0.21.2