diff --git a/latest/src/gtk2/gui.h b/latest/src/gtk2/gui.h index 7b42aee..477142e 100644 --- a/latest/src/gtk2/gui.h +++ b/latest/src/gtk2/gui.h @@ -333,7 +333,7 @@ void ReloadPixmaps(void); void Reselect(void); void set_rectangle_select(int value, enum toggle_type reason); - void SetStatusCode(STATUS_CODE id); + void SetStatusCode(H3270 *session, LIB3270_STATUS id); void SetTerminalFont(const gchar *fontname); void init_gui_toggles(void); diff --git a/latest/src/gtk2/main.c b/latest/src/gtk2/main.c index e6daed9..ec1530f 100644 --- a/latest/src/gtk2/main.c +++ b/latest/src/gtk2/main.c @@ -88,7 +88,7 @@ static void connect_main(H3270 *session, int status, void *dunno) } else { - SetStatusCode(STATUS_CODE_DISCONNECTED); + SetStatusCode(session,LIB3270_STATUS_DISCONNECTED); cMode &= ~CURSOR_MODE_ENABLED; // ctlr_erase(1); online = FALSE; diff --git a/latest/src/gtk2/oia.c b/latest/src/gtk2/oia.c index b295342..fdc604d 100755 --- a/latest/src/gtk2/oia.c +++ b/latest/src/gtk2/oia.c @@ -106,7 +106,7 @@ #define OIAROW (view.top+4+(terminal_font_info.spacing*view.rows)) gboolean oia_flag[OIA_FLAG_USER]; - STATUS_CODE terminal_message_id = (STATUS_CODE) -1; + LIB3270_STATUS terminal_message_id = (LIB3270_STATUS) -1; SCRIPT_STATE oia_script_state = SCRIPT_STATE_NONE; @@ -811,65 +811,65 @@ #endif int color; const gchar * string; - } message[STATUS_CODE_USER] = + } message[LIB3270_STATUS_USER] = { - OIA_MESSAGE( STATUS_CODE_BLANK, + OIA_MESSAGE( LIB3270_STATUS_BLANK, TERMINAL_COLOR_OIA_STATUS_OK, "" ), - OIA_MESSAGE( STATUS_CODE_SYSWAIT, + OIA_MESSAGE( LIB3270_STATUS_SYSWAIT, TERMINAL_COLOR_OIA_STATUS_OK, N_( "X System" ) ), - OIA_MESSAGE( STATUS_CODE_TWAIT, + OIA_MESSAGE( LIB3270_STATUS_TWAIT, TERMINAL_COLOR_OIA_STATUS_OK, N_( "X Wait" ) ), - OIA_MESSAGE( STATUS_CODE_CONNECTED, + OIA_MESSAGE( LIB3270_STATUS_CONNECTED, TERMINAL_COLOR_OIA_STATUS_OK, NULL ), - OIA_MESSAGE( STATUS_CODE_DISCONNECTED, + OIA_MESSAGE( LIB3270_STATUS_DISCONNECTED, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X Not Connected" ) ), - OIA_MESSAGE( STATUS_CODE_AWAITING_FIRST, + OIA_MESSAGE( LIB3270_STATUS_AWAITING_FIRST, TERMINAL_COLOR_OIA_STATUS_OK, N_( "X" ) ), - OIA_MESSAGE( STATUS_CODE_MINUS, + OIA_MESSAGE( LIB3270_STATUS_MINUS, TERMINAL_COLOR_OIA_STATUS_OK, N_( "X -f" ) ), - OIA_MESSAGE( STATUS_CODE_PROTECTED, + OIA_MESSAGE( LIB3270_STATUS_PROTECTED, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X Protected" ) ), - OIA_MESSAGE( STATUS_CODE_NUMERIC, + OIA_MESSAGE( LIB3270_STATUS_NUMERIC, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X Numeric" ) ), - OIA_MESSAGE( STATUS_CODE_OVERFLOW, + OIA_MESSAGE( LIB3270_STATUS_OVERFLOW, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X Overflow" ) ), - OIA_MESSAGE( STATUS_CODE_INHIBIT, + OIA_MESSAGE( LIB3270_STATUS_INHIBIT, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X Inhibit" ) ), - OIA_MESSAGE( STATUS_CODE_KYBDLOCK, + OIA_MESSAGE( LIB3270_STATUS_KYBDLOCK, TERMINAL_COLOR_OIA_STATUS_INVALID, NULL ), - OIA_MESSAGE( STATUS_CODE_X, + OIA_MESSAGE( LIB3270_STATUS_X, TERMINAL_COLOR_OIA_STATUS_INVALID, N_( "X" ) ), - OIA_MESSAGE( STATUS_CODE_RESOLVING, + OIA_MESSAGE( LIB3270_STATUS_RESOLVING, TERMINAL_COLOR_OIA_STATUS_WARNING, N_( "X Resolving" ) ), - OIA_MESSAGE( STATUS_CODE_CONNECTING, + OIA_MESSAGE( LIB3270_STATUS_CONNECTING, TERMINAL_COLOR_OIA_STATUS_WARNING, N_( "X Connecting" ) ), diff --git a/latest/src/gtk2/oia.h b/latest/src/gtk2/oia.h index 01c01f6..edf3041 100755 --- a/latest/src/gtk2/oia.h +++ b/latest/src/gtk2/oia.h @@ -83,7 +83,7 @@ LOCAL_EXTERN gboolean oia_caps_state; #endif // HAVE_CAPS_STATE - LOCAL_EXTERN STATUS_CODE terminal_message_id; + LOCAL_EXTERN LIB3270_STATUS terminal_message_id; LOCAL_EXTERN SCRIPT_STATE oia_script_state; LOCAL_EXTERN gboolean oia_script_blink; diff --git a/latest/src/gtk2/screen.c b/latest/src/gtk2/screen.c index 118117a..0494604 100644 --- a/latest/src/gtk2/screen.c +++ b/latest/src/gtk2/screen.c @@ -505,19 +505,19 @@ charset = g_strdup(dcs); } - void SetStatusCode(STATUS_CODE id) + void SetStatusCode(H3270 *session, LIB3270_STATUS id) { if(id == terminal_message_id) return; terminal_message_id = id; - if(id == STATUS_CODE_BLANK) + if(id == LIB3270_STATUS_BLANK) { set_cursor(CURSOR_MODE_NORMAL); update_cursor_pixmap(); } - else if(id >= STATUS_CODE_USER) + else if(id >= LIB3270_STATUS_USER) { Log("Unexpected status code %d",(int) id); return; diff --git a/latest/src/gtk2/terminal.c b/latest/src/gtk2/terminal.c index 9d96b3b..84b9431 100644 --- a/latest/src/gtk2/terminal.c +++ b/latest/src/gtk2/terminal.c @@ -371,7 +371,7 @@ static gboolean mouse_scroll(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { - if(query_3270_terminal_status() != STATUS_CODE_BLANK || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) + if(query_3270_terminal_status() != LIB3270_STATUS_BLANK || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) return 0; Trace("Scroll: %d Action: %p",event->direction,action_scroll[event->direction]); diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index efcf8b6..6410bbe 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -272,13 +272,15 @@ int LIB3270_EXPORT lib3270_register_io_handlers(const struct lib3270_io_callbacks *cbk); - LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *h); - LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); - LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); + LIB3270_EXPORT LIB3270_STATUS lib3270_get_oia_status(H3270 *h); + LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); + LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); #define lib3270_has_printer_session(h) (h->oia_flag[LIB3270_FLAG_PRINTER] != 0) #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) + #define lib3270_get_undera(h) (h->oia_flag[LIB3270_FLAG_UNDERA] != 0) + #define lib3270_get_oia_box_solid(h) (h->oia_flag[LIB3270_FLAG_BOXSOLID] != 0) LIB3270_EXPORT int lib3270_pconnected(H3270 *h); LIB3270_EXPORT int lib3270_half_connected(H3270 *h); diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index aab0cc6..c29049a 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -160,28 +160,28 @@ CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */ }; - typedef enum _STATUS_CODE + typedef enum _LIB3270_STATUS { - STATUS_CODE_BLANK, - STATUS_CODE_SYSWAIT, - STATUS_CODE_TWAIT, - STATUS_CODE_CONNECTED, - STATUS_CODE_DISCONNECTED, - STATUS_CODE_AWAITING_FIRST, - STATUS_CODE_MINUS, - STATUS_CODE_PROTECTED, - STATUS_CODE_NUMERIC, - STATUS_CODE_OVERFLOW, - STATUS_CODE_INHIBIT, - STATUS_CODE_KYBDLOCK, - - STATUS_CODE_X, - STATUS_CODE_RESOLVING, - STATUS_CODE_CONNECTING, - - STATUS_CODE_USER - - } STATUS_CODE; + LIB3270_STATUS_BLANK, + LIB3270_STATUS_SYSWAIT, + LIB3270_STATUS_TWAIT, + LIB3270_STATUS_CONNECTED, + LIB3270_STATUS_DISCONNECTED, + LIB3270_STATUS_AWAITING_FIRST, + LIB3270_STATUS_MINUS, + LIB3270_STATUS_PROTECTED, + LIB3270_STATUS_NUMERIC, + LIB3270_STATUS_OVERFLOW, + LIB3270_STATUS_INHIBIT, + LIB3270_STATUS_KYBDLOCK, + + LIB3270_STATUS_X, + LIB3270_STATUS_RESOLVING, + LIB3270_STATUS_CONNECTING, + + LIB3270_STATUS_USER + + } LIB3270_STATUS; #define OIA_FLAG_BOXSOLID LIB3270_FLAG_BOXSOLID #define OIA_FLAG_UNDERA LIB3270_FLAG_UNDERA @@ -226,7 +226,7 @@ char * qualified_host; char auto_reconnect_inprogress; - STATUS_CODE oia_status; + LIB3270_STATUS oia_status; unsigned char oia_flag[LIB3270_FLAG_COUNT]; @@ -256,6 +256,7 @@ char ssl_host; char ever_3270; + // Widget info void * widget; @@ -274,6 +275,8 @@ void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr); void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col); void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); + void (*update_luname)(H3270 *session, const char *name); + void (*update_status)(H3270 *session, LIB3270_STATUS id); }; @@ -505,7 +508,7 @@ int (*set_suspended)(int state); void (*set_script)(SCRIPT_STATE state); void (*reset)(int lock); - void (*status)(STATUS_CODE id); + void (*status)(H3270 *session, LIB3270_STATUS id); void (*cursor)(CURSOR_MODE mode); void (*lu)(const char *lu); void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); diff --git a/latest/src/lib/macros.c b/latest/src/lib/macros.c index f5a019f..931b8cc 100644 --- a/latest/src/lib/macros.c +++ b/latest/src/lib/macros.c @@ -180,7 +180,7 @@ { const char *str = NULL; - if(query_3270_terminal_status() != STATUS_CODE_BLANK) + if(query_3270_terminal_status() != LIB3270_STATUS_BLANK) { errno = EBUSY; return NULL; diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index 17b8ced..bcb0af5 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -138,6 +138,12 @@ int screen_init(H3270 *session) if(callbacks->set_viewsize) session->configure = callbacks->set_viewsize; + if(callbacks->lu) + session->update_luname = callbacks->lu; + + if(callbacks->status) + session->update_status = callbacks->status; + if(callbacks->init()) { popup_an_error("Can't initialize terminal."); @@ -503,20 +509,20 @@ void status_ctlr_done(H3270 *session) void status_oerr(H3270 *session, int error_type) { - STATUS_CODE sts = STATUS_CODE_USER; + LIB3270_STATUS sts = LIB3270_STATUS_USER; CHECK_SESSION_HANDLE(session); switch (error_type) { case KL_OERR_PROTECTED: - sts = STATUS_CODE_PROTECTED; + sts = LIB3270_STATUS_PROTECTED; break; case KL_OERR_NUMERIC: - sts = STATUS_CODE_NUMERIC; + sts = LIB3270_STATUS_NUMERIC; break; case KL_OERR_OVERFLOW: - sts = STATUS_CODE_OVERFLOW; + sts = LIB3270_STATUS_OVERFLOW; break; default: @@ -532,7 +538,7 @@ void status_resolving(H3270 *session, Boolean on) if(callbacks && callbacks->cursor) callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); - status_changed(session, on ? STATUS_CODE_RESOLVING : STATUS_CODE_BLANK); + status_changed(session, on ? LIB3270_STATUS_RESOLVING : LIB3270_STATUS_BLANK); } void status_connecting(H3270 *session, Boolean on) @@ -540,7 +546,7 @@ void status_connecting(H3270 *session, Boolean on) if(callbacks && callbacks->cursor) callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); - status_changed(session, on ? STATUS_CODE_CONNECTING : STATUS_CODE_BLANK); + status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); } void status_reset(H3270 *session) @@ -548,11 +554,11 @@ void status_reset(H3270 *session) CHECK_SESSION_HANDLE(session); if (kybdlock & KL_ENTER_INHIBIT) - status_changed(session,STATUS_CODE_INHIBIT); + status_changed(session,LIB3270_STATUS_INHIBIT); else if (kybdlock & KL_DEFERRED_UNLOCK) - status_changed(session,STATUS_CODE_X); + status_changed(session,LIB3270_STATUS_X); else - status_changed(session,STATUS_CODE_BLANK); + status_changed(session,LIB3270_STATUS_BLANK); screen_disp(session); @@ -564,22 +570,20 @@ void status_reset(H3270 *session) } -// static STATUS_CODE current_status_code = -1; - /** * Query the updated terminal status. * * @return status-code. * - * @see STATUS_CODE + * @see LIB3270_STATUS */ -LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *session) +LIB3270_EXPORT LIB3270_STATUS lib3270_get_oia_status(H3270 *session) { CHECK_SESSION_HANDLE(session); return session->oia_status; } -void status_changed(H3270 *session, STATUS_CODE id) +void status_changed(H3270 *session, LIB3270_STATUS id) { CHECK_SESSION_HANDLE(session); @@ -588,15 +592,15 @@ void status_changed(H3270 *session, STATUS_CODE id) session->oia_status = id; - if(callbacks && callbacks->status) - callbacks->status(id); + if(session->update_status) + session->update_status(session,id); } void status_twait(H3270 *session) { CHECK_SESSION_HANDLE(session); set_status(session,OIA_FLAG_UNDERA,False); - status_changed(session,STATUS_CODE_TWAIT); + status_changed(session,LIB3270_STATUS_TWAIT); } void set_viewsize(H3270 *session, int rows, int cols) @@ -616,13 +620,16 @@ void set_viewsize(H3270 *session, int rows, int cols) void status_lu(H3270 *session, const char *lu) { - if(callbacks && callbacks->lu) - callbacks->lu(lu); + CHECK_SESSION_HANDLE(session); + + if(session->update_luname) + session->update_luname(session,lu); + } static void status_connect(H3270 *session, int connected, void *dunno) { - STATUS_CODE id = STATUS_CODE_USER; + LIB3270_STATUS id = LIB3270_STATUS_USER; ctlr_erase(session,1); @@ -631,9 +638,9 @@ static void status_connect(H3270 *session, int connected, void *dunno) set_status(session,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP); if (kybdlock & KL_AWAITING_FIRST) - id = STATUS_CODE_AWAITING_FIRST; + id = LIB3270_STATUS_AWAITING_FIRST; else - id = STATUS_CODE_CONNECTED; + id = LIB3270_STATUS_CONNECTED; #if defined(HAVE_LIBSSL) /*[*/ set_status(session,OIA_FLAG_SECURE,session->secure_connection); @@ -645,7 +652,7 @@ static void status_connect(H3270 *session, int connected, void *dunno) set_status(session,OIA_FLAG_BOXSOLID,False); set_status(session,OIA_FLAG_SECURE,False); - id = STATUS_CODE_DISCONNECTED; + id = LIB3270_STATUS_DISCONNECTED; } status_changed(session,id); diff --git a/latest/src/lib/statusc.h b/latest/src/lib/statusc.h index 15be677..8189c84 100644 --- a/latest/src/lib/statusc.h +++ b/latest/src/lib/statusc.h @@ -29,15 +29,15 @@ LIB3270_INTERNAL void status_twait(H3270 *session); -LIB3270_INTERNAL void status_changed(H3270 *session, STATUS_CODE id); +LIB3270_INTERNAL void status_changed(H3270 *session, LIB3270_STATUS id); LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on); #define status_typeahead(on) set_status(NULL,OIA_FLAG_TYPEAHEAD,on) -#define status_kybdlock() status_changed(NULL,STATUS_CODE_KYBDLOCK) -#define status_syswait() status_changed(NULL,STATUS_CODE_SYSWAIT) -#define status_minus() status_changed(NULL,STATUS_CODE_MINUS) +#define status_kybdlock() status_changed(NULL,LIB3270_STATUS_KYBDLOCK) +#define status_syswait() status_changed(NULL,LIB3270_STATUS_SYSWAIT) +#define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS) extern int lib3270_event_counter[COUNTER_ID_USER]; diff --git a/latest/src/lib/telnet.c b/latest/src/lib/telnet.c index b3ad502..c536a0b 100644 --- a/latest/src/lib/telnet.c +++ b/latest/src/lib/telnet.c @@ -111,10 +111,12 @@ int ns_rsent; unsigned char *obuf; /* 3270 output buffer */ unsigned char *obptr = (unsigned char *) NULL; int linemode = 1; -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) Boolean local_process = False; -#endif /*]*/ +#endif // char *termtype; +*/ /* Externals */ extern struct timeval ds_ts; @@ -194,7 +196,7 @@ static void check_in3270(void); static void store3270in(unsigned char c); static void check_linemode(Boolean init); static int non_blocking(Boolean on); -static void net_connected(void); +static void net_connected(H3270 *session); #if defined(X3270_TN3270E) /*[*/ static int tn3270e_negotiate(void); #endif /*]*/ @@ -526,14 +528,16 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving status_resolving(&h3270,0); } } else { -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) if (ls) { local_process = True; } else { -#endif /*]*/ -#if defined(LOCAL_PROCESS) /*[*/ +#endif +#if defined(LOCAL_PROCESS) local_process = False; -#endif /*]*/ +#endif +*/ status_resolving(&h3270,1); if (resolve_host_and_port(host, portname, &h3270.current_port, &haddr.sa, &ha_len, @@ -543,13 +547,15 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving return -1; status_resolving(&h3270,0); } -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) } -#endif /*]*/ - +#endif +*/ } -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) if (local_process) { int amaster; struct winsize w; @@ -560,10 +566,10 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving w.ws_ypixel = 0; switch (forkpty(&amaster, NULL, NULL, &w)) { - case -1: /* failed */ + case -1: // failed popup_an_errno(errno, "forkpty"); close_fail; - case 0: /* child */ + case 0: // child putenv("TERM=xterm"); if (strchr(host, ' ') != CN) { (void) execlp("/bin/sh", "sh", "-c", host, @@ -580,17 +586,18 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving #warning Notify User _exit(1); break; - default: /* parent */ + default: // parent sock = amaster; -#if !defined(_WIN32) /*[*/ +#if !defined(_WIN32) (void) fcntl(sock, F_SETFD, 1); -#endif /*]*/ +#endif net_connected(); host_in3270(CONNECTED_ANSI); break; } } else { -#endif /*]*/ +#endif +*/ /* create the socket */ if ((h3270.sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) { popup_a_sockerr( N_( "socket" ) ); @@ -656,11 +663,13 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving } else { if (non_blocking(False) < 0) close_fail; - net_connected(); + net_connected(&h3270); } -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) } -#endif /*]*/ +#endif +*/ /* set up temporary termtype */ if (appres.termname == CN && h3270.std_ds_host) { @@ -752,41 +761,41 @@ setup_lus(void) try_lu = *curr_lu; } -static void -net_connected(void) +static void net_connected(H3270 *session) { - if (proxy_type > 0) { - + if (proxy_type > 0) + { /* Negotiate with the proxy. */ - trace_dsn("Connected to proxy server %s, port %u.\n", - proxy_host, proxy_port); + trace_dsn("Connected to proxy server %s, port %u.\n",proxy_host, proxy_port); - if (proxy_negotiate(proxy_type, h3270.sock, h3270.hostname, - h3270.current_port) < 0) { - host_disconnect(&h3270,True); + if (proxy_negotiate(proxy_type, session->sock, session->hostname,session->current_port) < 0) + { + host_disconnect(session,True); return; } } - trace_dsn("Connected to %s, port %u%s.\n", h3270.hostname, h3270.current_port,h3270.ssl_host? " via SSL": ""); + trace_dsn("Connected to %s, port %u%s.\n", session->hostname, session->current_port,session->ssl_host? " via SSL": ""); #if defined(HAVE_LIBSSL) /*[*/ /* Set up SSL. */ - if (h3270.ssl_host && !h3270.secure_connection) { - if (SSL_set_fd(ssl_con, h3270.sock) != 1) { + if(session->ssl_host && !session->secure_connection) + { + if (SSL_set_fd(ssl_con, session->sock) != 1) + { trace_dsn("Can't set fd!\n"); } - if (SSL_connect(ssl_con) != 1) { + if (SSL_connect(ssl_con) != 1) + { /* * No need to trace the error, it was already * displayed. */ - host_disconnect(&h3270,True); + host_disconnect(session,True); return; } - h3270.secure_connection = True; - trace_dsn("TLS/SSL tunneled connection complete. " - "Connection is now secure.\n"); + session->secure_connection = True; + trace_dsn("TLS/SSL tunneled connection complete. Connection is now secure.\n"); /* Tell everyone else again. */ host_connected(); @@ -827,12 +836,13 @@ net_connected(void) check_linemode(True); /* write out the passthru hostname and port nubmer */ - if (h3270.passthru_host) { + if (session->passthru_host) + { char *buf; - buf = Malloc(strlen(h3270.hostname) + 32); - (void) sprintf(buf, "%s %d\r\n", h3270.hostname, h3270.current_port); - (void) send(h3270.sock, buf, strlen(buf), 0); + buf = Malloc(strlen(session->hostname) + 32); + (void) sprintf(buf, "%s %d\r\n", session->hostname, session->current_port); + (void) send(session->sock, buf, strlen(buf), 0); Free(buf); } } @@ -853,7 +863,7 @@ connection_complete(void) } #endif /*]*/ host_connected(); - net_connected(); + net_connected(&h3270); } #if !defined(_WIN32) /*[*/ @@ -940,7 +950,7 @@ void net_input(H3270 *session) #if defined(_WIN32) /*[*/ if (HALF_CONNECTED) { - if (connect(h3270.sock, &haddr.sa, sizeof(haddr)) < 0) { + if (connect(session->sock, &haddr.sa, sizeof(haddr)) < 0) { int err = GetLastError(); switch (err) { @@ -966,20 +976,21 @@ void net_input(H3270 *session) #endif /*]*/ #if defined(_WIN32) /*[*/ - (void) ResetEvent(h3270.sock_handle); + (void) ResetEvent(session->sock_handle); #endif /*]*/ -#if defined(HAVE_LIBSSL) /*[*/ +#if defined(HAVE_LIBSSL) if (ssl_con != NULL) nr = SSL_read(ssl_con, (char *) netrbuf, BUFSZ); else -#else /*][*/ -#endif /*]*/ -#if defined(LOCAL_PROCESS) /*[*/ +#endif // HAVE_LIBSSL +/* +#if defined(LOCAL_PROCESS) if (local_process) nr = read(sock, (char *) netrbuf, BUFSZ); else -#endif /*]*/ +#endif +*/ nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0); if (nr < 0) { if (socket_errno() == SE_EWOULDBLOCK) { @@ -999,7 +1010,7 @@ void net_input(H3270 *session) err_buf); popup_an_error("SSL_read:\n%s", err_buf); - host_disconnect(&h3270,True); + host_disconnect(session,True); return; } #endif /*]*/ @@ -1007,25 +1018,27 @@ void net_input(H3270 *session) connection_complete(); return; } -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) / if (errno == EIO && local_process) { trace_dsn("RCVD local process disconnect\n"); - host_disconnect(False); + host_disconnect(session,False); return; } -#endif /*]*/ +#endif +*/ trace_dsn("RCVD socket error %d\n", errno); if (HALF_CONNECTED) { popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); } else if (socket_errno() != SE_ECONNRESET) { popup_a_sockerr( N_( "Socket read error" ) ); } - host_disconnect(&h3270,True); + host_disconnect(session,True); return; } else if (nr == 0) { /* Host disconnected. */ trace_dsn("RCVD disconnect\n"); - host_disconnect(&h3270,False); + host_disconnect(session,False); return; } @@ -1035,11 +1048,11 @@ void net_input(H3270 *session) { if (non_blocking(False) < 0) { - host_disconnect(&h3270,True); + host_disconnect(session,True); return; } host_connected(); - net_connected(); + net_connected(session); } #if defined(X3270_TRACE) /*[*/ @@ -1067,9 +1080,11 @@ void net_input(H3270 *session) host_disconnect(&h3270,True); return; } -#if defined(LOCAL_PROCESS) /*[*/ +/* +#if defined(LOCAL_PROCESS) } -#endif /*]*/ +#endif +*/ } #if defined(X3270_ANSI) /*[*/ -- libgit2 0.21.2