diff --git a/src/lib3270/ansi.c b/src/lib3270/ansi.c index b6e03cf..20c9c89 100644 --- a/src/lib3270/ansi.c +++ b/src/lib3270/ansi.c @@ -1021,15 +1021,15 @@ ansi_nop(H3270 *hSession, int ig1 unused, int ig2 unused) } #define PWRAP { \ - nc = h3270.cursor_addr + 1; \ - if (nc < h3270.scroll_bottom * h3270.cols) \ - cursor_move(&h3270,nc); \ + nc = hSession->cursor_addr + 1; \ + if (nc < hSession->scroll_bottom * hSession->cols) \ + cursor_move(hSession,nc); \ else { \ - if (h3270.cursor_addr / h3270.cols >= h3270.scroll_bottom) \ - cursor_move(&h3270,h3270.cursor_addr / h3270.cols * h3270.cols); \ + if (hSession->cursor_addr / hSession->cols >= hSession->scroll_bottom) \ + cursor_move(hSession,hSession->cursor_addr / hSession->cols * hSession->cols); \ else { \ - ansi_scroll(&h3270); \ - cursor_move(&h3270,nc - h3270.cols); \ + ansi_scroll(hSession); \ + cursor_move(hSession,nc - hSession->cols); \ } \ } \ } diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 28492cc..d7ab65b 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -463,78 +463,85 @@ void ctlr_erase(H3270 *session, int alt) /* * Interpret an incoming 3270 command. */ -enum pds -process_ds(unsigned char *buf, int buflen) +enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen) { enum pds rv; if (!buflen) return PDS_OKAY_NO_OUTPUT; -// scroll_to_bottom(); - - trace_ds(&h3270,"< "); + trace_ds(hSession,"< "); - switch (buf[0]) { /* 3270 command */ + switch (buf[0]) /* 3270 command */ + { case CMD_EAU: /* erase all unprotected */ case SNA_CMD_EAU: - trace_ds(&h3270,"EraseAllUnprotected\n"); - ctlr_erase_all_unprotected(&h3270); + trace_ds(hSession, "EraseAllUnprotected\n"); + ctlr_erase_all_unprotected(hSession); return PDS_OKAY_NO_OUTPUT; break; + case CMD_EWA: /* erase/write alternate */ case SNA_CMD_EWA: - trace_ds(&h3270,"EraseWriteAlternate"); + trace_ds(hSession,"EraseWriteAlternate"); ctlr_erase(NULL,True); if ((rv = ctlr_write(buf, buflen, True)) < 0) return rv; return PDS_OKAY_NO_OUTPUT; break; + case CMD_EW: /* erase/write */ case SNA_CMD_EW: - trace_ds(&h3270,"EraseWrite"); + trace_ds(hSession,"EraseWrite"); ctlr_erase(NULL,False); if ((rv = ctlr_write(buf, buflen, True)) < 0) return rv; return PDS_OKAY_NO_OUTPUT; break; + case CMD_W: /* write */ case SNA_CMD_W: - trace_ds(&h3270,"Write"); + trace_ds(hSession,"Write"); if ((rv = ctlr_write(buf, buflen, False)) < 0) return rv; return PDS_OKAY_NO_OUTPUT; break; + case CMD_RB: /* read buffer */ case SNA_CMD_RB: - trace_ds(&h3270,"ReadBuffer\n"); - ctlr_read_buffer(&h3270,h3270.aid); + trace_ds(hSession,"ReadBuffer\n"); + ctlr_read_buffer(hSession,hSession->aid); return PDS_OKAY_OUTPUT; break; + case CMD_RM: /* read modifed */ case SNA_CMD_RM: - trace_ds(&h3270,"ReadModified\n"); - ctlr_read_modified(h3270.aid, False); + trace_ds(hSession,"ReadModified\n"); + ctlr_read_modified(hSession->aid, False); return PDS_OKAY_OUTPUT; break; + case CMD_RMA: /* read modifed all */ case SNA_CMD_RMA: - trace_ds(&h3270,"ReadModifiedAll\n"); - ctlr_read_modified(h3270.aid, True); + trace_ds(hSession,"ReadModifiedAll\n"); + ctlr_read_modified(hSession->aid, True); return PDS_OKAY_OUTPUT; break; + case CMD_WSF: /* write structured field */ case SNA_CMD_WSF: - trace_ds(&h3270,"WriteStructuredField"); + trace_ds(hSession,"WriteStructuredField"); return write_structured_field(buf, buflen); break; + case CMD_NOP: /* no-op */ - trace_ds(&h3270,"NoOp\n"); + trace_ds(hSession,"NoOp\n"); return PDS_OKAY_NO_OUTPUT; break; + default: /* unknown 3270 command */ - popup_an_error(&h3270,_( "Unknown 3270 Data Stream command: 0x%X" ),buf[0]); + popup_an_error(hSession,_( "Unknown 3270 Data Stream command: 0x%X" ),buf[0]); return PDS_BAD_CMD; } } diff --git a/src/lib3270/ctlrc.h b/src/lib3270/ctlrc.h index 6190027..70a7175 100644 --- a/src/lib3270/ctlrc.h +++ b/src/lib3270/ctlrc.h @@ -69,7 +69,7 @@ LIB3270_INTERNAL void ctlr_write_sscp_lu(H3270 *session, unsigned char buf[], in LIB3270_INTERNAL void mdt_clear(int baddr); LIB3270_INTERNAL void mdt_set(int baddr); LIB3270_INTERNAL int next_unprotected(H3270 *session, int baddr0); -LIB3270_INTERNAL enum pds process_ds(unsigned char *buf, int buflen); +LIB3270_INTERNAL enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen); LIB3270_INTERNAL void ps_process(void); LIB3270_INTERNAL void update_model_info(H3270 *session, int model, int cols, int rows); diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 3623de1..1f391d1 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -594,7 +594,7 @@ LIB3270_ACTION(break) if (!IN_3270) return 0; - net_break(); + net_break(hSession); return 0; } @@ -607,7 +607,7 @@ LIB3270_ACTION(attn) if (!IN_3270) return 0; - net_interrupt(); + net_interrupt(hSession); return 0; } @@ -1886,7 +1886,7 @@ LIB3270_ACTION( sysreq ) return 0; #if defined(X3270_TN3270E) /*[*/ if (IN_E) { - net_abort(); + net_abort(hSession); } else #endif /*]*/ { diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index c044125..5570199 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -166,7 +166,7 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) /* Compute the color. */ /* Monochrome is easy, and so is color if nothing is specified. */ - if (!h3270.m3279 || + if (!session->m3279 || (!session->ea_buf[baddr].fg && !session->ea_buf[fa_addr].fg && !session->ea_buf[baddr].bg && diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index b3def64..9a92f05 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -1952,8 +1952,7 @@ process_eor(H3270 *hSession) hSession->tn3270e_submode = E_3270; check_in3270(hSession); hSession->response_required = h->response_flag; - rv = process_ds(hSession->ibuf + EH_SIZE, - (hSession->ibptr - hSession->ibuf) - EH_SIZE); + rv = process_ds(hSession, hSession->ibuf + EH_SIZE,(hSession->ibptr - hSession->ibuf) - EH_SIZE); if (rv < 0 && hSession->response_required != TN3270E_RSF_NO_RESPONSE) tn3270e_nak(hSession,rv); @@ -2000,7 +1999,7 @@ process_eor(H3270 *hSession) } else #endif /*]*/ { - (void) process_ds(hSession->ibuf, hSession->ibptr - hSession->ibuf); + (void) process_ds(hSession, hSession->ibuf, hSession->ibptr - hSession->ibuf); } return 0; } @@ -2270,7 +2269,7 @@ static void do_intr(H3270 *hSession, char c) } ansi_process_s(ctl_see((int) c)); cooked_init(hSession); - net_interrupt(); + net_interrupt(hSession); } static void do_quit(H3270 *hSession, char c) @@ -2282,7 +2281,7 @@ static void do_quit(H3270 *hSession, char c) } ansi_process_s(ctl_see((int) c)); cooked_init(hSession); - net_break(); + net_break(hSession); } static void do_cerase(H3270 *hSession, char c) @@ -2688,8 +2687,8 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in (void) gettimeofday(&ts, (struct timezone *)NULL); if (IN_3270) { - tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) + - (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6; + tdiff = ((1.0e6 * (double)(ts.tv_sec - hSession->ds_ts.tv_sec)) + + (double)(ts.tv_usec - hSession->ds_ts.tv_usec)) / 1.0e6; trace_dsn(hSession,"%c +%gs\n", direction, tdiff); } @@ -2990,20 +2989,23 @@ net_linemode(void) } */ -void -net_charmode(void) +void net_charmode(H3270 *hSession) { if (!CONNECTED) return; - if (!hisopts[TELOPT_ECHO]) { + + if (!hisopts[TELOPT_ECHO]) + { do_opt[2] = TELOPT_ECHO; net_rawout(do_opt, sizeof(do_opt)); - trace_dsn(&h3270,"SENT %s %s\n", cmd(DO), opt(TELOPT_ECHO)); + trace_dsn(hSession,"SENT %s %s\n", cmd(DO), opt(TELOPT_ECHO)); } - if (!hisopts[TELOPT_SGA]) { + + if (!hisopts[TELOPT_SGA]) + { do_opt[2] = TELOPT_SGA; net_rawout(do_opt, sizeof(do_opt)); - trace_dsn(&h3270,"SENT %s %s\n", cmd(DO), opt(TELOPT_SGA)); + trace_dsn(hSession,"SENT %s %s\n", cmd(DO), opt(TELOPT_SGA)); } } #endif /*]*/ @@ -3014,14 +3016,13 @@ net_charmode(void) * Send telnet break, which is used to implement 3270 ATTN. * */ -void -net_break(void) +void net_break(H3270 *hSession) { - static unsigned char buf[] = { IAC, BREAK }; + static const unsigned char buf[] = { IAC, BREAK }; /* I don't know if we should first send TELNET synch ? */ - net_rawout(&h3270, buf, sizeof(buf)); - trace_dsn(&h3270,"SENT BREAK\n"); + net_rawout(hSession, buf, sizeof(buf)); + trace_dsn(hSession,"SENT BREAK\n"); } /* @@ -3029,14 +3030,13 @@ net_break(void) * Send telnet IP. * */ -void -net_interrupt(void) +void net_interrupt(H3270 *hSession) { - static unsigned char buf[] = { IAC, IP }; + static const unsigned char buf[] = { IAC, IP }; /* I don't know if we should first send TELNET synch ? */ - net_rawout(&h3270, buf, sizeof(buf)); - trace_dsn(&h3270,"SENT IP\n"); + net_rawout(hSession, buf, sizeof(buf)); + trace_dsn(hSession,"SENT IP\n"); } /* @@ -3045,36 +3045,39 @@ net_interrupt(void) * */ #if defined(X3270_TN3270E) /*[*/ -void -net_abort(void) +void net_abort(H3270 *hSession) { - static unsigned char buf[] = { IAC, AO }; + static const unsigned char buf[] = { IAC, AO }; - if (h3270.e_funcs & E_OPT(TN3270E_FUNC_SYSREQ)) { + if (hSession->e_funcs & E_OPT(TN3270E_FUNC_SYSREQ)) + { /* * I'm not sure yet what to do here. Should the host respond * to the AO by sending us SSCP-LU data (and putting us into * SSCP-LU mode), or should we put ourselves in it? * Time, and testers, will tell. */ - switch (h3270.tn3270e_submode) { + switch (hSession->tn3270e_submode) + { case E_NONE: case E_NVT: break; + case E_SSCP: - net_rawout(&h3270, buf, sizeof(buf)); - trace_dsn(&h3270,"SENT AO\n"); - if (h3270.tn3270e_bound || - !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) { - h3270.tn3270e_submode = E_3270; - check_in3270(&h3270); + net_rawout(hSession, buf, sizeof(buf)); + trace_dsn(hSession,"SENT AO\n"); + if (hSession->tn3270e_bound || !(hSession->e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) + { + hSession->tn3270e_submode = E_3270; + check_in3270(hSession); } break; + case E_3270: - net_rawout(&h3270, buf, sizeof(buf)); - trace_dsn(&h3270,"SENT AO\n"); - h3270.tn3270e_submode = E_SSCP; - check_in3270(&h3270); + net_rawout(hSession, buf, sizeof(buf)); + trace_dsn(hSession,"SENT AO\n"); + hSession->tn3270e_submode = E_SSCP; + check_in3270(hSession); break; } } diff --git a/src/lib3270/telnetc.h b/src/lib3270/telnetc.h index 99fa1b7..6f014ab 100644 --- a/src/lib3270/telnetc.h +++ b/src/lib3270/telnetc.h @@ -29,17 +29,17 @@ struct ctl_char { char value[3]; }; -LIB3270_INTERNAL void net_abort(void); +LIB3270_INTERNAL void net_abort(H3270 *hSession); LIB3270_INTERNAL Boolean net_add_dummy_tn3270e(void); LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len); -LIB3270_INTERNAL void net_break(void); -LIB3270_INTERNAL void net_charmode(void); +LIB3270_INTERNAL void net_break(H3270 *hSession); +LIB3270_INTERNAL void net_charmode(H3270 *hSession); LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *); LIB3270_INTERNAL void net_disconnect(H3270 *session); LIB3270_INTERNAL void net_exception(H3270 *session); // LIB3270_INTERNAL void net_hexansi_out(unsigned char *buf, int len); LIB3270_INTERNAL void net_input(H3270 *session); -LIB3270_INTERNAL void net_interrupt(void); +LIB3270_INTERNAL void net_interrupt(H3270 *hSession); // LIB3270_INTERNAL void net_linemode(void); // LIB3270_INTERNAL struct ctl_char *net_linemode_chars(void); LIB3270_INTERNAL void net_output(H3270 *hSession); -- libgit2 0.21.2