diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index a5f920b..e0dcfca 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -203,6 +203,12 @@ // Widget info void * widget; + // xio + unsigned long ns_read_id; + unsigned long ns_exception_id; + char reading; + char excepting; + /* State change callbacks. */ struct lib3270_state_callback *st_callbacks[N_ST]; struct lib3270_state_callback *st_last[N_ST]; diff --git a/latest/src/lib/host.c b/latest/src/lib/host.c index 6ec3ee0..96abd3b 100644 --- a/latest/src/lib/host.c +++ b/latest/src/lib/host.c @@ -83,8 +83,7 @@ static struct host *last_host = (struct host *)NULL; static void try_reconnect(H3270 *session); -static char * -stoken(char **s) +static char * stoken(char **s) { char *r; char *ss = *s; @@ -598,26 +597,18 @@ static int do_connect(H3270 *hSession, const char *n) /* Attempt contact. */ ever_3270 = False; - hSession->net_sock = net_connect(chost, port, localprocess_cmd != CN, &resolving, - &pending); - if (hSession->net_sock < 0 && !resolving) { -#if defined(X3270_DISPLAY) /*[*/ - if (appres.once) { - /* Exit when the error pop-up pops down. */ - exiting = True; - } - else if ( toggled(RECONNECT) ) { - auto_reconnect_inprogress = True; - (void) AddTimeOut(RECONNECT_ERR_MS, try_reconnect); - } -#endif /*]*/ + hSession->net_sock = net_connect(chost, port, localprocess_cmd != CN, &resolving,&pending); + + if (hSession->net_sock < 0 && !resolving) + { /* Redundantly signal a disconnect. */ lib3270_st_changed(hSession, ST_CONNECT, False); return -1; } /* Still thinking about it? */ - if (resolving) { + if (resolving) + { hSession->cstate = RESOLVING; lib3270_st_changed(hSession, ST_RESOLVING, True); return 0; @@ -633,7 +624,7 @@ static int do_connect(H3270 *hSession, const char *n) // login_macro(ps); /* Prepare Xt for I/O. */ - x_add_input(hSession->net_sock); + x_add_input(hSession,hSession->net_sock); /* Set state and tell the world. */ if (pending) @@ -702,7 +693,7 @@ void host_disconnect(H3270 *h, int failed) h = &h3270; if (CONNECTED || HALF_CONNECTED) { - x_remove_input(); + x_remove_input(h); net_disconnect(); h->net_sock = -1; diff --git a/latest/src/lib/telnet.c b/latest/src/lib/telnet.c index e915e74..9c09927 100644 --- a/latest/src/lib/telnet.c +++ b/latest/src/lib/telnet.c @@ -1261,7 +1261,7 @@ telnet_fsm(unsigned char c) trace_dsn("\n"); if (syncing) { syncing = 0; - x_except_on(h3270.sock); + x_except_on(&h3270,h3270.sock); } telnet_state = TNS_DATA; break; @@ -1937,7 +1937,7 @@ void net_exception(H3270 *session) trace_dsn("RCVD urgent data indication\n"); if (!syncing) { syncing = 1; - x_except_off(); + x_except_off(session); } } } diff --git a/latest/src/lib/xio.c b/latest/src/lib/xio.c index b505a09..a25be97 100644 --- a/latest/src/lib/xio.c +++ b/latest/src/lib/xio.c @@ -45,32 +45,31 @@ #include "xioc.h" /* Statics. */ -static unsigned long ns_read_id; -static unsigned long ns_exception_id; -static Boolean reading = False; -static Boolean excepting = False; +// static unsigned long ns_read_id; +// static unsigned long ns_exception_id; +// static Boolean reading = False; +// static Boolean excepting = False; /* * Called to set up input on a new network connection. */ -void -x_add_input(int net_sock) +void x_add_input(H3270 *h,int net_sock) { - ns_exception_id = AddExcept(net_sock, &h3270, net_exception); - excepting = True; - ns_read_id = AddInput(net_sock, &h3270, net_input); - reading = True; + h->ns_exception_id = AddExcept(net_sock, h, net_exception); + h->excepting = True; + h->ns_read_id = AddInput(net_sock, h, net_input); + h->reading = True; } /* * Called when an exception is received to disable further exceptions. */ -void -x_except_off(void) +void x_except_off(H3270 *h) { - if (excepting) { - RemoveInput(ns_exception_id); - excepting = False; + if(h->excepting) + { + RemoveInput(h->ns_exception_id); + h->excepting = False; } } @@ -79,66 +78,34 @@ x_except_off(void) * This includes removing and restoring reading, so the exceptions are always * processed first. */ -void -x_except_on(int net_sock) +void x_except_on(H3270 *h,int net_sock) { - if (excepting) + if(h->excepting) return; - if (reading) - RemoveInput(ns_read_id); - ns_exception_id = AddExcept(net_sock, &h3270, net_exception); - excepting = True; - if (reading) - ns_read_id = AddInput(net_sock, &h3270, net_input); + + if(h->reading) + RemoveInput(h->ns_read_id); + + h->ns_exception_id = AddExcept(net_sock, h, net_exception); + h->excepting = True; + + if(h->reading) + h->ns_read_id = AddInput(net_sock, h, net_input); } /* * Called to disable input on a closing network connection. */ -void -x_remove_input(void) +void x_remove_input(H3270 *h) { - if (reading) { - RemoveInput(ns_read_id); - reading = False; + if(h->reading) + { + RemoveInput(h->ns_read_id); + h->reading = False; } - if (excepting) { - RemoveInput(ns_exception_id); - excepting = False; - } -} - -/* - * Application exit, with cleanup. - */ - /* -void -x3270_exit(int n) -{ - static Boolean already_exiting = 0; - - // Handle unintentional recursion. - if (already_exiting) - return; - already_exiting = True; - - // Turn off toggle-related activity. - shutdown_toggles(); - - // Shut down the socket gracefully. - host_disconnect(&h3270,False); - - // Tell anyone else who's interested. - st_changed(ST_EXITING, True); - - exit(n); -} - -void -Quit_action(Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - if (!w || !CONNECTED) { - x3270_exit(0); + if(h->excepting) + { + RemoveInput(h->ns_exception_id); + h->excepting = False; } } -*/ diff --git a/latest/src/lib/xioc.h b/latest/src/lib/xioc.h index 7bddaae..b334a6b 100644 --- a/latest/src/lib/xioc.h +++ b/latest/src/lib/xioc.h @@ -35,11 +35,8 @@ * Global declarations for xio.c. */ -// LIB3270_INTERNAL void Quit_action(Widget w, XEvent *event, String *params, Cardinal *num_params) __attribute__ ((deprecated)); -//LIB3270_INTERNAL void x3270_exit(int n) __attribute__ ((deprecated)); - -LIB3270_INTERNAL void x_add_input(int net_sock); -LIB3270_INTERNAL void x_except_off(void); -LIB3270_INTERNAL void x_except_on(int net_sock); -LIB3270_INTERNAL void x_remove_input(void); +LIB3270_INTERNAL void x_add_input(H3270 *h,int net_sock); +LIB3270_INTERNAL void x_except_off(H3270 *h); +LIB3270_INTERNAL void x_except_on(H3270 *h,int net_sock); +LIB3270_INTERNAL void x_remove_input(H3270 *h); -- libgit2 0.21.2