diff --git a/Makefile.in b/Makefile.in index 65b74e2..3e94f43 100644 --- a/Makefile.in +++ b/Makefile.in @@ -344,9 +344,9 @@ doc: #---[ Debug Targets ]-------------------------------------------------------------------- Debug: \ - $(BINDBG)/$(LIBNAME)@EXEEXT@ + $(BINDBG)/lib3270@EXEEXT@ -$(BINDBG)/$(LIBNAME)@EXEEXT@: \ +$(BINDBG)/lib3270@EXEEXT@: \ $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ $(BINDBG)/$(SONAME) @@ -361,19 +361,19 @@ $(BINDBG)/$(LIBNAME)@EXEEXT@: \ $(LIBS) run: \ - $(BINDBG)/$(LIBNAME)@EXEEXT@ + $(BINDBG)/lib3270@EXEEXT@ ifeq ($(VALGRIND),no) @LD_LIBRARY_PATH=$(BINDBG) \ - $(BINDBG)/$(LIBNAME)@EXEEXT@ + $(BINDBG)/lib3270@EXEEXT@ else @touch valgrind.suppression @LD_LIBRARY_PATH=$(BINDBG) \ $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \ - $(BINDBG)/$(LIBNAME)@EXEEXT@ + $(BINDBG)/lib3270@EXEEXT@ endif $(BINDBG)/$(SONAME): \ diff --git a/src/core/ctlr.c b/src/core/ctlr.c index 1607c45..075e5d8 100644 --- a/src/core/ctlr.c +++ b/src/core/ctlr.c @@ -685,9 +685,9 @@ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, return; *currentp = value; space3270out(hSession,3); - *hSession->obptr++ = ORDER_SA; - *hSession->obptr++ = attr; - *hSession->obptr++ = value; + *hSession->output.ptr++ = ORDER_SA; + *hSession->output.ptr++ = attr; + *hSession->output.ptr++ = value; if (*anyp) trace_ds(hSession,"'"); trace_ds(hSession, " SetAttribute(%s)", see_efa(attr, value)); @@ -763,16 +763,16 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) #endif /*]*/ trace_ds(hSession,"> "); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; switch (aid_byte) { case AID_SYSREQ: /* test request */ space3270out(hSession,4); - *hSession->obptr++ = 0x01; /* soh */ - *hSession->obptr++ = 0x5b; /* % */ - *hSession->obptr++ = 0x61; /* / */ - *hSession->obptr++ = 0x02; /* stx */ + *hSession->output.ptr++ = 0x01; /* soh */ + *hSession->output.ptr++ = 0x5b; /* % */ + *hSession->output.ptr++ = 0x61; /* / */ + *hSession->output.ptr++ = 0x02; /* stx */ trace_ds(hSession,"SYSREQ"); break; @@ -793,13 +793,13 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) if (!IN_SSCP) { space3270out(hSession,3); - *hSession->obptr++ = aid_byte; + *hSession->output.ptr++ = aid_byte; trace_ds(hSession,"%s",see_aid(aid_byte)); if (short_read) goto rm_done; - ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); + ENCODE_BADDR(hSession->output.ptr, hSession->cursor_addr); trace_ds(hSession,"%s",rcba(hSession,hSession->cursor_addr)); } else @@ -829,8 +829,8 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) INC_BA(baddr); space3270out(hSession,3); - *hSession->obptr++ = ORDER_SBA; - ENCODE_BADDR(hSession->obptr, baddr); + *hSession->output.ptr++ = ORDER_SBA; + ENCODE_BADDR(hSession->output.ptr, baddr); trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->view.cols, hSession->view.rows); while (!hSession->ea_buf[baddr].fa) { @@ -841,14 +841,14 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) if (hSession->ea_buf[baddr].cs & CS_GE) { space3270out(hSession,1); - *hSession->obptr++ = ORDER_GE; + *hSession->output.ptr++ = ORDER_GE; if (any) trace_ds(hSession,"'"); trace_ds(hSession," GraphicEscape"); any = False; } space3270out(hSession,1); - *hSession->obptr++ = hSession->ea_buf[baddr].cc; + *hSession->output.ptr++ = hSession->ea_buf[baddr].cc; if (!any) trace_ds(hSession," '"); @@ -890,7 +890,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) if (hSession->ea_buf[baddr].cs & CS_GE) { space3270out(hSession,1); - *hSession->obptr++ = ORDER_GE; + *hSession->output.ptr++ = ORDER_GE; if (any) trace_ds(hSession,"' "); trace_ds(hSession," GraphicEscape "); @@ -898,7 +898,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) } space3270out(hSession,1); - *hSession->obptr++ = hSession->ea_buf[baddr].cc; + *hSession->output.ptr++ = hSession->ea_buf[baddr].cc; if (!any) trace_ds(hSession,"%s","'"); trace_ds(hSession,"%s",see_ebc(hSession, hSession->ea_buf[baddr].cc)); @@ -949,11 +949,11 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) #endif /*]*/ trace_ds(hSession,"> "); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,3); - *hSession->obptr++ = aid_byte; - ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); + *hSession->output.ptr++ = aid_byte; + ENCODE_BADDR(hSession->output.ptr, hSession->cursor_addr); trace_ds(hSession,"%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); baddr = 0; @@ -963,18 +963,18 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) if (hSession->reply_mode == SF_SRM_FIELD) { space3270out(hSession,2); - *hSession->obptr++ = ORDER_SF; + *hSession->output.ptr++ = ORDER_SF; } else { space3270out(hSession,4); - *hSession->obptr++ = ORDER_SFE; - attr_count = hSession->obptr - hSession->obuf; - *hSession->obptr++ = 1; /* for now */ - *hSession->obptr++ = XA_3270; + *hSession->output.ptr++ = ORDER_SFE; + attr_count = hSession->output.ptr - hSession->output.buf; + *hSession->output.ptr++ = 1; /* for now */ + *hSession->output.ptr++ = XA_3270; } fa = hSession->ea_buf[baddr].fa & ~FA_PRINTABLE; - *hSession->obptr++ = code_table[fa]; + *hSession->output.ptr++ = code_table[fa]; if (any) trace_ds(hSession,"'"); @@ -986,32 +986,32 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) { if (hSession->ea_buf[baddr].fg) { space3270out(hSession,2); - *hSession->obptr++ = XA_FOREGROUND; - *hSession->obptr++ = hSession->ea_buf[baddr].fg; + *hSession->output.ptr++ = XA_FOREGROUND; + *hSession->output.ptr++ = hSession->ea_buf[baddr].fg; trace_ds(hSession,"%s", see_efa(XA_FOREGROUND, hSession->ea_buf[baddr].fg)); - (*(hSession->obuf + attr_count))++; + (*(hSession->output.buf + attr_count))++; } if (hSession->ea_buf[baddr].bg) { space3270out(hSession,2); - *hSession->obptr++ = XA_BACKGROUND; - *hSession->obptr++ = hSession->ea_buf[baddr].bg; + *hSession->output.ptr++ = XA_BACKGROUND; + *hSession->output.ptr++ = hSession->ea_buf[baddr].bg; trace_ds(hSession,"%s", see_efa(XA_BACKGROUND, hSession->ea_buf[baddr].bg)); - (*(hSession->obuf + attr_count))++; + (*(hSession->output.buf + attr_count))++; } if (hSession->ea_buf[baddr].gr) { space3270out(hSession,2); - *hSession->obptr++ = XA_HIGHLIGHTING; - *hSession->obptr++ = hSession->ea_buf[baddr].gr | 0xf0; + *hSession->output.ptr++ = XA_HIGHLIGHTING; + *hSession->output.ptr++ = hSession->ea_buf[baddr].gr | 0xf0; trace_ds(hSession,"%s", see_efa(XA_HIGHLIGHTING, hSession->ea_buf[baddr].gr | 0xf0)); - (*(hSession->obuf + attr_count))++; + (*(hSession->output.buf + attr_count))++; } if (hSession->ea_buf[baddr].cs & CS_MASK) { space3270out(hSession,2); - *hSession->obptr++ = XA_CHARSET; - *hSession->obptr++ = host_cs(hSession->ea_buf[baddr].cs); + *hSession->output.ptr++ = XA_CHARSET; + *hSession->output.ptr++ = host_cs(hSession->ea_buf[baddr].cs); trace_ds(hSession,"%s", see_efa(XA_CHARSET,host_cs(hSession->ea_buf[baddr].cs))); - (*(hSession->obuf + attr_count))++; + (*(hSession->output.buf + attr_count))++; } } any = False; @@ -1019,14 +1019,14 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) insert_sa(hSession,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); if (hSession->ea_buf[baddr].cs & CS_GE) { space3270out(hSession,1); - *hSession->obptr++ = ORDER_GE; + *hSession->output.ptr++ = ORDER_GE; if (any) trace_ds(hSession,"'"); trace_ds(hSession," GraphicEscape"); any = False; } space3270out(hSession,1); - *hSession->obptr++ = hSession->ea_buf[baddr].cc; + *hSession->output.ptr++ = hSession->ea_buf[baddr].cc; if (hSession->ea_buf[baddr].cc <= 0x3f || hSession->ea_buf[baddr].cc == 0xff) { if (any) diff --git a/src/core/ft/ft_dft.c b/src/core/ft/ft_dft.c index 55d2490..d3e331d 100644 --- a/src/core/ft/ft_dft.c +++ b/src/core/ft/ft_dft.c @@ -201,12 +201,12 @@ static void dft_open_request(H3270 *hSession, unsigned short len, unsigned char /* Acknowledge the Open. */ trace_ds(hSession,"> WriteStructuredField FileTransferData OpenAck\n"); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,6); - *hSession->obptr++ = AID_SF; - SET16(hSession->obptr, 5); - *hSession->obptr++ = SF_TRANSFER_DATA; - SET16(hSession->obptr, 9); + *hSession->output.ptr++ = AID_SF; + SET16(hSession->output.ptr, 5); + *hSession->output.ptr++ = SF_TRANSFER_DATA; + SET16(hSession->output.ptr, 9); net_output(hSession); } @@ -338,14 +338,14 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) /* Send an acknowledgement frame back. */ trace_ds(hSession,"> WriteStructuredField FileTransferData DataAck(rec=%lu)\n", ft->recnum); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,12); - *hSession->obptr++ = AID_SF; - SET16(hSession->obptr, 11); - *hSession->obptr++ = SF_TRANSFER_DATA; - SET16(hSession->obptr, TR_NORMAL_REPLY); - SET16(hSession->obptr, TR_RECNUM_HDR); - SET32(hSession->obptr, ft->recnum); + *hSession->output.ptr++ = AID_SF; + SET16(hSession->output.ptr, 11); + *hSession->output.ptr++ = SF_TRANSFER_DATA; + SET16(hSession->output.ptr, TR_NORMAL_REPLY); + SET16(hSession->output.ptr, TR_RECNUM_HDR); + SET32(hSession->output.ptr, ft->recnum); ft->recnum++; net_output(hSession); } @@ -378,7 +378,7 @@ static void dft_get_request(H3270 *hSession) set_dft_buffersize(hSession); space3270out(hSession,hSession->dft_buffersize); numbytes = hSession->dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ - bufptr = hSession->obuf + 17; + bufptr = hSession->output.buf + 17; while (!ft->dft_eof && numbytes) { @@ -456,22 +456,22 @@ static void dft_get_request(H3270 *hSession) } /* Set up SF header for Data or EOF. */ - hSession->obptr = hSession->obuf; - *hSession->obptr++ = AID_SF; - hSession->obptr += 2; /* skip SF length for now */ - *hSession->obptr++ = SF_TRANSFER_DATA; + hSession->output.ptr = hSession->output.buf; + *hSession->output.ptr++ = AID_SF; + hSession->output.ptr += 2; /* skip SF length for now */ + *hSession->output.ptr++ = SF_TRANSFER_DATA; if (total_read) { trace_ds(hSession,"> WriteStructuredField FileTransferData Data(rec=%lu) %d bytes\n",(unsigned long) ft->recnum, (int) total_read); - SET16(hSession->obptr, TR_GET_REPLY); - SET16(hSession->obptr, TR_RECNUM_HDR); - SET32(hSession->obptr, ft->recnum); + SET16(hSession->output.ptr, TR_GET_REPLY); + SET16(hSession->output.ptr, TR_RECNUM_HDR); + SET32(hSession->output.ptr, ft->recnum); ft->recnum++; - SET16(hSession->obptr, TR_NOT_COMPRESSED); - *hSession->obptr++ = TR_BEGIN_DATA; - SET16(hSession->obptr, total_read + 5); - hSession->obptr += total_read; + SET16(hSession->output.ptr, TR_NOT_COMPRESSED); + *hSession->output.ptr++ = TR_BEGIN_DATA; + SET16(hSession->output.ptr, total_read + 5); + hSession->output.ptr += total_read; ft->ft_length += total_read; @@ -484,26 +484,26 @@ static void dft_get_request(H3270 *hSession) else { trace_ds(hSession,"> WriteStructuredField FileTransferData EOF\n"); - *hSession->obptr++ = HIGH8(TR_GET_REQ); - *hSession->obptr++ = TR_ERROR_REPLY; - SET16(hSession->obptr, TR_ERROR_HDR); - SET16(hSession->obptr, TR_ERR_EOF); + *hSession->output.ptr++ = HIGH8(TR_GET_REQ); + *hSession->output.ptr++ = TR_ERROR_REPLY; + SET16(hSession->output.ptr, TR_ERROR_HDR); + SET16(hSession->output.ptr, TR_ERR_EOF); ft->dft_eof = 1; } /* Set the SF length. */ - bufptr = hSession->obuf + 1; - SET16(bufptr, hSession->obptr - (hSession->obuf + 1)); + bufptr = hSession->output.buf + 1; + SET16(bufptr, hSession->output.ptr - (hSession->output.buf + 1)); /* Save the data. */ - ft->dft_savebuf_len = hSession->obptr - hSession->obuf; + ft->dft_savebuf_len = hSession->output.ptr - hSession->output.buf; if (ft->dft_savebuf_len > ft->dft_savebuf_max) { ft->dft_savebuf_max = ft->dft_savebuf_len; Replace(ft->dft_savebuf, (unsigned char *)lib3270_malloc(ft->dft_savebuf_max)); } - (void) memcpy(ft->dft_savebuf, hSession->obuf, ft->dft_savebuf_len); + (void) memcpy(ft->dft_savebuf, hSession->output.buf, ft->dft_savebuf_len); hSession->aid = AID_SF; /* Write the data. */ @@ -520,12 +520,12 @@ static void dft_close_request(H3270 *hSession) */ trace_ds(hSession," Close\n"); trace_ds(hSession,"> WriteStructuredField FileTransferData CloseAck\n"); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,6); - *hSession->obptr++ = AID_SF; - SET16(hSession->obptr, 5); /* length */ - *hSession->obptr++ = SF_TRANSFER_DATA; - SET16(hSession->obptr, TR_CLOSE_REPLY); + *hSession->output.ptr++ = AID_SF; + SET16(hSession->output.ptr, 5); /* length */ + *hSession->output.ptr++ = SF_TRANSFER_DATA; + SET16(hSession->output.ptr, TR_CLOSE_REPLY); net_output(hSession); } @@ -543,15 +543,15 @@ static void dft_abort(H3270 *hSession, unsigned short code, const char *fmt, ... trace_ds(hSession,"> WriteStructuredField FileTransferData Error\n"); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,10); - *hSession->obptr++ = AID_SF; - SET16(hSession->obptr, 9); /* length */ - *hSession->obptr++ = SF_TRANSFER_DATA; - *hSession->obptr++ = HIGH8(code); - *hSession->obptr++ = TR_ERROR_REPLY; - SET16(hSession->obptr, TR_ERROR_HDR); - SET16(hSession->obptr, TR_ERR_CMDFAIL); + *hSession->output.ptr++ = AID_SF; + SET16(hSession->output.ptr, 9); /* length */ + *hSession->output.ptr++ = SF_TRANSFER_DATA; + *hSession->output.ptr++ = HIGH8(code); + *hSession->output.ptr++ = TR_ERROR_REPLY; + SET16(hSession->output.ptr, TR_ERROR_HDR); + SET16(hSession->output.ptr, TR_ERR_CMDFAIL); net_output(hSession); /* Update the pop-up and state. */ @@ -581,10 +581,10 @@ void dft_read_modified(H3270 *hSession) if(ft->dft_savebuf_len) { trace_ds(hSession,"> WriteStructuredField FileTransferData\n"); - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,ft->dft_savebuf_len); - memcpy(hSession->obptr, ft->dft_savebuf, ft->dft_savebuf_len); - hSession->obptr += ft->dft_savebuf_len; + memcpy(hSession->output.ptr, ft->dft_savebuf, ft->dft_savebuf_len); + hSession->output.ptr += ft->dft_savebuf_len; net_output(hSession); } } diff --git a/src/core/rpq.c b/src/core/rpq.c index cf75f94..0ee36b3 100644 --- a/src/core/rpq.c +++ b/src/core/rpq.c @@ -146,14 +146,14 @@ void do_qr_rpqnames(H3270 *hSession) */ space3270out(hSession,4+4+1+remaining); /* Maximum space for an RPQNAME item */ - SET32(hSession->obptr, 0); /* Device number, 0 = All */ - SET32(hSession->obptr, 0); /* Model number, 0 = All */ + SET32(hSession->output.ptr, 0); /* Device number, 0 = All */ + SET32(hSession->output.ptr, 0); /* Model number, 0 = All */ - rpql = hSession->obptr++; /* Save address to place data length. */ + rpql = hSession->output.ptr++; /* Save address to place data length. */ /* Create fixed length portion - program id: x3270 */ for (j = 0; j < 5; j++) { - *hSession->obptr++ = hSession->charset.asc2ebc[(int)"x3270"[j]]; + *hSession->output.ptr++ = hSession->charset.asc2ebc[(int)"x3270"[j]]; remaining--; } @@ -168,9 +168,9 @@ void do_qr_rpqnames(H3270 *hSession) term_id = rpq_keywords[j].id; - p_term = hSession->obptr; /* save starting address (to insert length later) */ - hSession->obptr++; /* skip length of term, fill in later */ - *hSession->obptr++ = term_id; /* identify this term */ + p_term = hSession->output.ptr; /* save starting address (to insert length later) */ + hSession->output.ptr++; /* skip length of term, fill in later */ + *hSession->output.ptr++ = term_id; /* identify this term */ /* * Adjust remaining space by the term prefix size so each case @@ -183,18 +183,18 @@ void do_qr_rpqnames(H3270 *hSession) switch (term_id) /* build the term based on id */ { case RPQ_USER: /* User text from env. vars */ - hSession->obptr += get_rpq_user(hSession,hSession->obptr, remaining); + hSession->output.ptr += get_rpq_user(hSession,hSession->output.ptr, remaining); break; case RPQ_TIMEZONE: /* UTC time offset */ omit_due_space_limit = (remaining < 2); if (!omit_due_space_limit) - SET16(hSession->obptr, get_rpq_timezone(hSession)); + SET16(hSession->output.ptr, get_rpq_timezone(hSession)); break; case RPQ_ADDRESS: /* Workstation address */ #if !defined(_WIN32) /*[*/ - hSession->obptr += get_rpq_address(hSession, hSession->obptr, remaining); + hSession->output.ptr += get_rpq_address(hSession, hSession->output.ptr, remaining); #endif /*]*/ break; @@ -205,7 +205,7 @@ void do_qr_rpqnames(H3270 *hSession) { for (i = 0; i < x; i++) { - *hSession->obptr++ = hSession->charset.asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; + *hSession->output.ptr++ = hSession->charset.asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; } } break; @@ -217,7 +217,7 @@ void do_qr_rpqnames(H3270 *hSession) { for (i=0; i < x; i+=2) { - *hSession->obptr++ = ((*(build_rpq_timestamp+i) - '0') << 4) + *hSession->output.ptr++ = ((*(build_rpq_timestamp+i) - '0') << 4) + (*(build_rpq_timestamp+i+1) - '0'); } } @@ -239,14 +239,14 @@ void do_qr_rpqnames(H3270 *hSession) * adjust space remaining. * obptr now points at "next available byte". */ - x = hSession->obptr-p_term; + x = hSession->output.ptr-p_term; if (x > TERM_PREFIX_SIZE) { *p_term = x; remaining -= x; /* This includes length and id fields, correction below */ } else { /* We didn't add an item after all, reset pointer. */ - hSession->obptr = p_term; + hSession->output.ptr = p_term; } /* * When we calculated the length of the term, a few lines @@ -268,7 +268,7 @@ void do_qr_rpqnames(H3270 *hSession) } /* Fill in overall length of RPQNAME info */ - *rpql = (hSession->obptr - rpql); + *rpql = (hSession->output.ptr - rpql); rpq_dump_warnings(hSession); } diff --git a/src/core/session.c b/src/core/session.c index 56735e6..be4cfe3 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -140,7 +140,7 @@ void lib3270_session_free(H3270 *h) release_pointer(h->text); release_pointer(h->zero_buf); - release_pointer(h->obuf_base); + release_pointer(h->output.base); release_pointer(h->sbbuf); release_pointer(h->tabs); diff --git a/src/core/sf.c b/src/core/sf.c index 96af413..d962d70 100644 --- a/src/core/sf.c +++ b/src/core/sf.c @@ -93,12 +93,19 @@ static void query_reply_start(H3270 *hSession); static void do_query_reply(H3270 *hSession, unsigned char code); static void query_reply_end(H3270 *hSession); -typedef Boolean qr_multi_fn_t(H3270 *hSession, unsigned *subindex, Boolean *more); - -static qr_single_fn_t do_qr_summary, do_qr_usable_area, do_qr_alpha_part, - do_qr_charsets, do_qr_color, do_qr_highlighting, do_qr_reply_modes, - do_qr_imp_part, do_qr_null; +//static void qr_single_fn_t(H3270 *hSession); + +static void do_qr_summary(H3270 *hSession); +static void do_qr_usable_area(H3270 *hSession); +static void do_qr_alpha_part(H3270 *hSession); +static void do_qr_charsets(H3270 *hSession); +static void do_qr_color(H3270 *hSession); +static void do_qr_highlighting(H3270 *hSession); +static void do_qr_reply_modes(H3270 *hSession); +static void do_qr_imp_part(H3270 *hSession); +static void do_qr_null(H3270 *hSession); +typedef Boolean qr_multi_fn_t(H3270 *hSession, unsigned *subindex, Boolean *more); #if defined(X3270_DBCS) /*[*/ static qr_single_fn_t do_qr_dbcs_asia; @@ -692,9 +699,9 @@ static enum pds sf_outbound_ds(H3270 *hSession, unsigned char buf[], int buflen) static void query_reply_start(H3270 *hSession) { - hSession->obptr = hSession->obuf; + hSession->output.ptr = hSession->output.buf; space3270out(hSession,1); - *hSession->obptr++ = AID_SF; + *hSession->output.ptr++ = AID_SF; qr_in_progress = True; } @@ -721,13 +728,13 @@ static void do_query_reply(H3270 *hSession, unsigned char code) do { - int obptr0 = hSession->obptr - hSession->obuf; + int obptr0 = hSession->output.ptr - hSession->output.buf; Boolean full = True; space3270out(hSession,4); - hSession->obptr += 2; /* skip length for now */ - *hSession->obptr++ = SFID_QREPLY; - *hSession->obptr++ = code; + hSession->output.ptr += 2; /* skip length for now */ + *hSession->output.ptr++ = SFID_QREPLY; + *hSession->output.ptr++ = code; more = False; if (replies[i].single_fn) @@ -741,12 +748,12 @@ static void do_query_reply(H3270 *hSession, unsigned char code) unsigned char *obptr_len; /* Fill in the length. */ - obptr_len = hSession->obuf + obptr0; - len = (hSession->obptr - hSession->obuf) - obptr0; + obptr_len = hSession->output.buf + obptr0; + len = (hSession->output.ptr - hSession->output.buf) - obptr0; SET16(obptr_len, len); } else { /* Back over the header. */ - hSession->obptr -= 4; + hSession->output.ptr -= 4; } } while (more); } @@ -771,7 +778,7 @@ static void do_qr_summary(H3270 *hSession) #endif /*]*/ trace_ds(hSession,"%s%s", comma, see_qcode(replies[i].code)); comma = ","; - *hSession->obptr++ = replies[i].code; + *hSession->output.ptr++ = replies[i].code; #if defined(X3270_DBCS) /*[*/ } #endif /*]*/ @@ -785,11 +792,11 @@ static void do_qr_usable_area(H3270 *hSession) trace_ds(hSession,"> QueryReply(UsableArea)\n"); space3270out(hSession,19); - *hSession->obptr++ = 0x01; /* 12/14-bit addressing */ - *hSession->obptr++ = 0x00; /* no special character features */ - SET16(hSession->obptr, hSession->max.cols); /* usable width */ - SET16(hSession->obptr, hSession->max.rows); /* usable height */ - *hSession->obptr++ = 0x01; /* units (mm) */ + *hSession->output.ptr++ = 0x01; /* 12/14-bit addressing */ + *hSession->output.ptr++ = 0x00; /* no special character features */ + SET16(hSession->output.ptr, hSession->max.cols); /* usable width */ + SET16(hSession->output.ptr, hSession->max.rows); /* usable height */ + *hSession->output.ptr++ = 0x01; /* units (mm) */ num = display_widthMM(); denom = display_width(); while (!(num %2) && !(denom % 2)) @@ -797,8 +804,8 @@ static void do_qr_usable_area(H3270 *hSession) num /= 2; denom /= 2; } - SET16(hSession->obptr, (int)num); /* Xr numerator */ - SET16(hSession->obptr, (int)denom); /* Xr denominator */ + SET16(hSession->output.ptr, (int)num); /* Xr numerator */ + SET16(hSession->output.ptr, (int)denom); /* Xr denominator */ num = display_heightMM(); denom = display_height(); while (!(num %2) && !(denom % 2)) @@ -806,11 +813,11 @@ static void do_qr_usable_area(H3270 *hSession) num /= 2; denom /= 2; } - SET16(hSession->obptr, (int)num); /* Yr numerator */ - SET16(hSession->obptr, (int)denom); /* Yr denominator */ - *hSession->obptr++ = *char_width; /* AW */ - *hSession->obptr++ = *char_height; /* AH */ - SET16(hSession->obptr, hSession->max.cols * hSession->max.cols); /* buffer, questionable */ + SET16(hSession->output.ptr, (int)num); /* Yr numerator */ + SET16(hSession->output.ptr, (int)denom); /* Yr denominator */ + *hSession->output.ptr++ = *char_width; /* AW */ + *hSession->output.ptr++ = *char_height; /* AH */ + SET16(hSession->output.ptr, hSession->max.cols * hSession->max.cols); /* buffer, questionable */ } static void do_qr_color(H3270 *hSession) @@ -823,17 +830,17 @@ static void do_qr_color(H3270 *hSession) color_max = (hSession->colors == 8) ? 8: 16; /* report on 8 or 16 colors */ space3270out(hSession,4 + 2*15); - *hSession->obptr++ = 0x00; /* no options */ - *hSession->obptr++ = color_max; /* report on 8 or 16 colors */ - *hSession->obptr++ = 0x00; /* default color: */ - *hSession->obptr++ = 0xf0 + COLOR_GREEN; /* green */ + *hSession->output.ptr++ = 0x00; /* no options */ + *hSession->output.ptr++ = color_max; /* report on 8 or 16 colors */ + *hSession->output.ptr++ = 0x00; /* default color: */ + *hSession->output.ptr++ = 0xf0 + COLOR_GREEN; /* green */ for (i = 0xf1; i < 0xf1 + color_max - 1; i++) { - *hSession->obptr++ = i; + *hSession->output.ptr++ = i; if (hSession->m3279) - *hSession->obptr++ = i; + *hSession->output.ptr++ = i; else - *hSession->obptr++ = 0x00; + *hSession->output.ptr++ = 0x00; } /* @@ -841,10 +848,10 @@ static void do_qr_color(H3270 *hSession) // Add background color. if (hSession->m3279) { space3270out(4); - *hSession->obptr++ = 4; // length - *hSession->obptr++ = 0x02; // background color - *hSession->obptr++ = 0x00; // attribute - *hSession->obptr++ = 0xf0; // default color + *hSession->output.ptr++ = 4; // length + *hSession->output.ptr++ = 0x02; // background color + *hSession->output.ptr++ = 0x00; // attribute + *hSession->output.ptr++ = 0xf0; // default color } #endif */ @@ -854,26 +861,26 @@ static void do_qr_highlighting(H3270 *hSession) { trace_ds(hSession,"> QueryReply(Highlighting)\n"); space3270out(hSession,11); - *hSession->obptr++ = 5; /* report on 5 pairs */ - *hSession->obptr++ = XAH_DEFAULT; /* default: */ - *hSession->obptr++ = XAH_NORMAL; /* normal */ - *hSession->obptr++ = XAH_BLINK; /* blink: */ - *hSession->obptr++ = XAH_BLINK; /* blink */ - *hSession->obptr++ = XAH_REVERSE; /* reverse: */ - *hSession->obptr++ = XAH_REVERSE; /* reverse */ - *hSession->obptr++ = XAH_UNDERSCORE; /* underscore: */ - *hSession->obptr++ = XAH_UNDERSCORE; /* underscore */ - *hSession->obptr++ = XAH_INTENSIFY; /* intensify: */ - *hSession->obptr++ = XAH_INTENSIFY; /* intensify */ + *hSession->output.ptr++ = 5; /* report on 5 pairs */ + *hSession->output.ptr++ = XAH_DEFAULT; /* default: */ + *hSession->output.ptr++ = XAH_NORMAL; /* normal */ + *hSession->output.ptr++ = XAH_BLINK; /* blink: */ + *hSession->output.ptr++ = XAH_BLINK; /* blink */ + *hSession->output.ptr++ = XAH_REVERSE; /* reverse: */ + *hSession->output.ptr++ = XAH_REVERSE; /* reverse */ + *hSession->output.ptr++ = XAH_UNDERSCORE; /* underscore: */ + *hSession->output.ptr++ = XAH_UNDERSCORE; /* underscore */ + *hSession->output.ptr++ = XAH_INTENSIFY; /* intensify: */ + *hSession->output.ptr++ = XAH_INTENSIFY; /* intensify */ } static void do_qr_reply_modes(H3270 *hSession) { trace_ds(hSession,"> QueryReply(ReplyModes)\n"); space3270out(hSession,3); - *hSession->obptr++ = SF_SRM_FIELD; - *hSession->obptr++ = SF_SRM_XFIELD; - *hSession->obptr++ = SF_SRM_CHAR; + *hSession->output.ptr++ = SF_SRM_FIELD; + *hSession->output.ptr++ = SF_SRM_XFIELD; + *hSession->output.ptr++ = SF_SRM_CHAR; } #if defined(X3270_DBCS) /*[*/ @@ -882,13 +889,13 @@ static void do_qr_dbcs_asia(H3270 *hSession) /* XXX: Should we support this, even when not in DBCS mode? */ trace_ds(hSession,"> QueryReply(DbcsAsia)\n"); space3270out(hSession,7); - *hSession->obptr++ = 0x00; /* flags (none) */ - *hSession->obptr++ = 0x03; /* field length 3 */ - *hSession->obptr++ = 0x01; /* SI/SO supported */ - *hSession->obptr++ = 0x80; /* character set ID 0x80 */ - *hSession->obptr++ = 0x03; /* field length 3 */ - *hSession->obptr++ = 0x02; /* input control */ - *hSession->obptr++ = 0x01; /* creation supported */ + *hSession->output.ptr++ = 0x00; /* flags (none) */ + *hSession->output.ptr++ = 0x03; /* field length 3 */ + *hSession->output.ptr++ = 0x01; /* SI/SO supported */ + *hSession->output.ptr++ = 0x80; /* character set ID 0x80 */ + *hSession->output.ptr++ = 0x03; /* field length 3 */ + *hSession->output.ptr++ = 0x02; /* input control */ + *hSession->output.ptr++ = 0x01; /* creation supported */ } #endif /*]*/ @@ -896,9 +903,9 @@ static void do_qr_alpha_part(H3270 *hSession) { trace_ds(hSession,"> QueryReply(AlphanumericPartitions)\n"); space3270out(hSession,4); - *hSession->obptr++ = 0; /* 1 partition */ - SET16(hSession->obptr, hSession->max.cols * hSession->max.rows); /* buffer space */ - *hSession->obptr++ = 0; /* no special features */ + *hSession->output.ptr++ = 0; /* 1 partition */ + SET16(hSession->output.ptr, hSession->max.cols * hSession->max.rows); /* buffer space */ + *hSession->output.ptr++ = 0; /* no special features */ } static void do_qr_charsets(H3270 *hSession) @@ -907,79 +914,79 @@ static void do_qr_charsets(H3270 *hSession) space3270out(hSession,64); #if defined(X3270_DBCS) /*[*/ if (dbcs) - *hSession->obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ + *hSession->output.ptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ else #endif /*]*/ - *hSession->obptr++ = 0x82; /* flags: GE, CGCSGID present */ - - *hSession->obptr++ = 0x00; /* more flags */ - *hSession->obptr++ = *char_width; /* SDW */ - *hSession->obptr++ = *char_height; /* SDW */ - *hSession->obptr++ = 0x00; /* no load PS */ - *hSession->obptr++ = 0x00; - *hSession->obptr++ = 0x00; - *hSession->obptr++ = 0x00; + *hSession->output.ptr++ = 0x82; /* flags: GE, CGCSGID present */ + + *hSession->output.ptr++ = 0x00; /* more flags */ + *hSession->output.ptr++ = *char_width; /* SDW */ + *hSession->output.ptr++ = *char_height; /* SDW */ + *hSession->output.ptr++ = 0x00; /* no load PS */ + *hSession->output.ptr++ = 0x00; + *hSession->output.ptr++ = 0x00; + *hSession->output.ptr++ = 0x00; #if defined(X3270_DBCS) /*[*/ if (dbcs) - *hSession->obptr++ = 0x0b; /* DL (11 bytes) */ + *hSession->output.ptr++ = 0x0b; /* DL (11 bytes) */ else #endif /*]*/ - *hSession->obptr++ = 0x07; /* DL (7 bytes) */ + *hSession->output.ptr++ = 0x07; /* DL (7 bytes) */ - *hSession->obptr++ = 0x00; /* SET 0: */ + *hSession->output.ptr++ = 0x00; /* SET 0: */ #if defined(X3270_DBCS) /*[*/ if (dbcs) - *hSession->obptr++ = 0x00; /* FLAGS: non-load, single- + *hSession->output.ptr++ = 0x00; /* FLAGS: non-load, single- plane, single-bute */ else #endif /*]*/ - *hSession->obptr++ = 0x10; /* FLAGS: non-loadable, + *hSession->output.ptr++ = 0x10; /* FLAGS: non-loadable, single-plane, single-byte, no compare */ - *hSession->obptr++ = 0x00; /* LCID 0 */ + *hSession->output.ptr++ = 0x00; /* LCID 0 */ #if defined(X3270_DBCS) /*[*/ if (dbcs) { - *hSession->obptr++ = 0x00; /* SW 0 */ - *hSession->obptr++ = 0x00; /* SH 0 */ - *hSession->obptr++ = 0x00; /* SUBSN */ - *hSession->obptr++ = 0x00; /* SUBSN */ + *hSession->output.ptr++ = 0x00; /* SW 0 */ + *hSession->output.ptr++ = 0x00; /* SH 0 */ + *hSession->output.ptr++ = 0x00; /* SUBSN */ + *hSession->output.ptr++ = 0x00; /* SUBSN */ } #endif /*]*/ - SET32(hSession->obptr, hSession->charset.cgcsgid); /* CGCSGID */ + SET32(hSession->output.ptr, hSession->charset.cgcsgid); /* CGCSGID */ if (!*standard_font) { /* special 3270 font, includes APL */ - *hSession->obptr++ = 0x01;/* SET 1: */ + *hSession->output.ptr++ = 0x01;/* SET 1: */ if (hSession->apl_mode) - *hSession->obptr++ = 0x00;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ + *hSession->output.ptr++ = 0x00;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ else - *hSession->obptr++ = 0x10;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ - *hSession->obptr++ = 0xf1;/* LCID */ + *hSession->output.ptr++ = 0x10;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ + *hSession->output.ptr++ = 0xf1;/* LCID */ #if defined(X3270_DBCS) /*[*/ if (dbcs) { - *hSession->obptr++ = 0x00;/* SW 0 */ - *hSession->obptr++ = 0x00;/* SH 0 */ - *hSession->obptr++ = 0x00;/* SUBSN */ - *hSession->obptr++ = 0x00;/* SUBSN */ + *hSession->output.ptr++ = 0x00;/* SW 0 */ + *hSession->output.ptr++ = 0x00;/* SH 0 */ + *hSession->output.ptr++ = 0x00;/* SUBSN */ + *hSession->output.ptr++ = 0x00;/* SUBSN */ } #endif /*]*/ - *hSession->obptr++ = 0x03;/* CGCSGID: 3179-style APL2 */ - *hSession->obptr++ = 0xc3; - *hSession->obptr++ = 0x01; - *hSession->obptr++ = 0x36; + *hSession->output.ptr++ = 0x03;/* CGCSGID: 3179-style APL2 */ + *hSession->output.ptr++ = 0xc3; + *hSession->output.ptr++ = 0x01; + *hSession->output.ptr++ = 0x36; } #if defined(X3270_DBCS) /*[*/ if (dbcs) { - *hSession->obptr++ = 0x80; /* SET 0x80: */ - *hSession->obptr++ = 0x20; /* FLAGS: DBCS */ - *hSession->obptr++ = 0xf8; /* LCID: 0xf8 */ - *hSession->obptr++ = *char_width * 2; /* SW */ - *hSession->obptr++ = *char_height; /* SH */ - *hSession->obptr++ = 0x41; /* SUBSN */ - *hSession->obptr++ = 0x7f; /* SUBSN */ - SET32(hSession->obptr, cgcsgid_dbcs); /* CGCSGID */ + *hSession->output.ptr++ = 0x80; /* SET 0x80: */ + *hSession->output.ptr++ = 0x20; /* FLAGS: DBCS */ + *hSession->output.ptr++ = 0xf8; /* LCID: 0xf8 */ + *hSession->output.ptr++ = *char_width * 2; /* SW */ + *hSession->output.ptr++ = *char_height; /* SH */ + *hSession->output.ptr++ = 0x41; /* SUBSN */ + *hSession->output.ptr++ = 0x7f; /* SUBSN */ + SET32(hSession->output.ptr, cgcsgid_dbcs); /* CGCSGID */ } #endif /*]*/ } @@ -991,10 +998,10 @@ static void do_qr_ddm(H3270 *hSession) trace_ds(hSession,"> QueryReply(DistributedDataManagement)\n"); space3270out(hSession,8); - SET16(hSession->obptr,0); /* set reserved field to 0 */ - SET16(hSession->obptr, hSession->dft_buffersize); /* set inbound length limit INLIM */ - SET16(hSession->obptr, hSession->dft_buffersize); /* set outbound length limit OUTLIM */ - SET16(hSession->obptr, 0x0101); /* NSS=01, DDMSS=01 */ + SET16(hSession->output.ptr,0); /* set reserved field to 0 */ + SET16(hSession->output.ptr, hSession->dft_buffersize); /* set inbound length limit INLIM */ + SET16(hSession->output.ptr, hSession->dft_buffersize); /* set outbound length limit OUTLIM */ + SET16(hSession->output.ptr, 0x0101); /* NSS=01, DDMSS=01 */ } #endif /*]*/ @@ -1002,15 +1009,15 @@ static void do_qr_imp_part(H3270 *hSession) { trace_ds(hSession,"> QueryReply(ImplicitPartition)\n"); space3270out(hSession,13); - *hSession->obptr++ = 0x0; /* reserved */ - *hSession->obptr++ = 0x0; - *hSession->obptr++ = 0x0b; /* length of display size */ - *hSession->obptr++ = 0x01; /* "implicit partition size" */ - *hSession->obptr++ = 0x00; /* reserved */ - SET16(hSession->obptr, 80); /* implicit partition width */ - SET16(hSession->obptr, 24); /* implicit partition height */ - SET16(hSession->obptr, hSession->max.cols); /* alternate height */ - SET16(hSession->obptr, hSession->max.rows); /* alternate width */ + *hSession->output.ptr++ = 0x0; /* reserved */ + *hSession->output.ptr++ = 0x0; + *hSession->output.ptr++ = 0x0b; /* length of display size */ + *hSession->output.ptr++ = 0x01; /* "implicit partition size" */ + *hSession->output.ptr++ = 0x00; /* reserved */ + SET16(hSession->output.ptr, 80); /* implicit partition width */ + SET16(hSession->output.ptr, 24); /* implicit partition height */ + SET16(hSession->output.ptr, hSession->max.cols); /* alternate height */ + SET16(hSession->output.ptr, hSession->max.rows); /* alternate width */ } static void query_reply_end(H3270 *hSession) diff --git a/src/core/telnet.c b/src/core/telnet.c index 82d933b..784d100 100644 --- a/src/core/telnet.c +++ b/src/core/telnet.c @@ -2144,20 +2144,20 @@ void space3270out(H3270 *hSession, int n) unsigned nc = 0; /* amount of data currently in obuf */ unsigned more = 0; - if (hSession->obuf_size) - nc = hSession->obptr - hSession->obuf; + if (hSession->output.length) + nc = hSession->output.ptr - hSession->output.buf; - while ((nc + n + EH_SIZE) > (hSession->obuf_size + more)) + while ((nc + n + EH_SIZE) > (hSession->output.length + more)) { more += BUFSIZ; } if (more) { - hSession->obuf_size += more; - hSession->obuf_base = (unsigned char *)Realloc((char *) hSession->obuf_base,hSession->obuf_size); - hSession->obuf = hSession->obuf_base + EH_SIZE; - hSession->obptr = hSession->obuf + nc; + hSession->output.length += more; + hSession->output.base = (unsigned char *)Realloc((char *) hSession->output.base,hSession->output.length); + hSession->output.buf = hSession->output.base + EH_SIZE; + hSession->output.ptr = hSession->output.buf + nc; } } @@ -2342,7 +2342,7 @@ void net_output(H3270 *hSession) unsigned char *nxoptr, *xoptr; #if defined(X3270_TN3270E) - #define BSTART ((IN_TN3270E || IN_SSCP) ? hSession->obuf_base : hSession->obuf) + #define BSTART ((IN_TN3270E || IN_SSCP) ? hSession->output.base : hSession->output.buf) #else #define BSTART obuf #endif @@ -2351,7 +2351,7 @@ void net_output(H3270 *hSession) /* Set the TN3720E header. */ if (IN_TN3270E || IN_SSCP) { - tn3270e_header *h = (tn3270e_header *) hSession->obuf_base; + tn3270e_header *h = (tn3270e_header *) hSession->output.base; /* Check for sending a TN3270E response. */ if (hSession->response_required == TN3270E_RSF_ALWAYS_RESPONSE) @@ -2374,7 +2374,7 @@ void net_output(H3270 *hSession) #endif /*]*/ /* Reallocate the expanded output buffer. */ - while (xobuf_len < (hSession->obptr - BSTART + 1) * 2) + while (xobuf_len < (hSession->output.ptr - BSTART + 1) * 2) { xobuf_len += BUFSZ; need_resize++; @@ -2388,7 +2388,7 @@ void net_output(H3270 *hSession) /* Copy and expand IACs. */ xoptr = xobuf; nxoptr = BSTART; - while (nxoptr < hSession->obptr) + while (nxoptr < hSession->output.ptr) { if ((*xoptr++ = *nxoptr++) == IAC) { diff --git a/src/include/lib3270-internals.h b/src/include/lib3270-internals.h index 7f08a8b..cd3951b 100644 --- a/src/include/lib3270-internals.h +++ b/src/include/lib3270-internals.h @@ -488,8 +488,6 @@ struct _h3270 // Telnet.c unsigned char * ibuf; int ibuf_size; /**< @brief size of ibuf */ - unsigned char * obuf; /**< @brief 3270 output buffer */ - unsigned char * obptr; time_t ns_time; int ns_brcvd; int ns_rrcvd; @@ -529,8 +527,15 @@ struct _h3270 // 3270 input buffer unsigned char * ibptr; - unsigned char * obuf_base; - int obuf_size; + + // Output buffer. + struct + { + unsigned char * buf; ///< @brief 3270 output buffer */ + unsigned char * base; + int length; ///< @brief Length of the output buffer. + unsigned char * ptr; + } output; // network input buffer unsigned char * sbbuf; -- libgit2 0.21.2