From 07fe2293fc7c9d349d1d1fb97195880834ea0a4f Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 6 Jun 2012 11:20:45 +0000 Subject: [PATCH] Ajustes para multi-sessão --- src/include/lib3270/session.h | 3 +++ src/lib3270/ctlr.c | 78 +++++++++++++++++++++++++++++++++++++++--------------------------------------- src/lib3270/ft_dft.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------ src/lib3270/rpq.c | 32 +++++++++++++++----------------- src/lib3270/sf.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------- src/lib3270/telnet.c | 84 +++++++++++++++++++++++++++++++++++++++++------------------------------------------- src/lib3270/telnetc.h | 4 ++-- 7 files changed, 232 insertions(+), 232 deletions(-) diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index aeac6e1..32913bc 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -182,6 +182,9 @@ // Telnet.c unsigned char * ibuf; int ibuf_size; /**< size of ibuf */ + unsigned char * obuf; /**< 3270 output buffer */ + unsigned char * obptr; + unsigned char myopts[LIB3270_TELNET_N_OPTS]; unsigned char hisopts[LIB3270_TELNET_N_OPTS]; diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index e97a813..39a0d89 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -549,9 +549,9 @@ insert_sa1(unsigned char attr, unsigned char value, unsigned char *currentp, Boo return; *currentp = value; space3270out(3); - *obptr++ = ORDER_SA; - *obptr++ = attr; - *obptr++ = value; + *h3270.obptr++ = ORDER_SA; + *h3270.obptr++ = attr; + *h3270.obptr++ = value; if (*anyp) trace_ds("'"); trace_ds(" SetAttribute(%s)", see_efa(attr, value)); @@ -626,16 +626,16 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) #endif /*]*/ trace_ds("> "); - obptr = obuf; + h3270.obptr = h3270.obuf; switch (aid_byte) { case AID_SYSREQ: /* test request */ space3270out(4); - *obptr++ = 0x01; /* soh */ - *obptr++ = 0x5b; /* % */ - *obptr++ = 0x61; /* / */ - *obptr++ = 0x02; /* stx */ + *h3270.obptr++ = 0x01; /* soh */ + *h3270.obptr++ = 0x5b; /* % */ + *h3270.obptr++ = 0x61; /* / */ + *h3270.obptr++ = 0x02; /* stx */ trace_ds("SYSREQ"); break; @@ -655,11 +655,11 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) default: /* ordinary AID */ if (!IN_SSCP) { space3270out(3); - *obptr++ = aid_byte; + *h3270.obptr++ = aid_byte; trace_ds("%s",see_aid(aid_byte)); if (short_read) goto rm_done; - ENCODE_BADDR(obptr, h3270.cursor_addr); + ENCODE_BADDR(h3270.obptr, h3270.cursor_addr); trace_ds("%s",rcba(&h3270,h3270.cursor_addr)); } else { space3270out(1); /* just in case */ @@ -682,8 +682,8 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) INC_BA(baddr); space3270out(3); - *obptr++ = ORDER_SBA; - ENCODE_BADDR(obptr, baddr); + *h3270.obptr++ = ORDER_SBA; + ENCODE_BADDR(h3270.obptr, baddr); trace_ds(" SetBufferAddress%s (Cols: %d Rows: %d)", rcba(&h3270,baddr), h3270.cols, h3270.rows); while (!h3270.ea_buf[baddr].fa) { @@ -697,14 +697,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) &any); if (h3270.ea_buf[baddr].cs & CS_GE) { space3270out(1); - *obptr++ = ORDER_GE; + *h3270.obptr++ = ORDER_GE; if (any) trace_ds("'"); trace_ds(" GraphicEscape"); any = False; } space3270out(1); - *obptr++ = h3270.ea_buf[baddr].cc; + *h3270.obptr++ = h3270.ea_buf[baddr].cc; if (!any) trace_ds(" '"); trace_ds("%s",see_ebc(h3270.ea_buf[baddr].cc)); @@ -742,14 +742,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) &any); if (h3270.ea_buf[baddr].cs & CS_GE) { space3270out(1); - *obptr++ = ORDER_GE; + *h3270.obptr++ = ORDER_GE; if (any) trace_ds("' "); trace_ds(" GraphicEscape "); any = False; } space3270out(1); - *obptr++ = h3270.ea_buf[baddr].cc; + *h3270.obptr++ = h3270.ea_buf[baddr].cc; if (!any) trace_ds("%s","'"); trace_ds("%s",see_ebc(h3270.ea_buf[baddr].cc)); @@ -797,11 +797,11 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) #endif /*]*/ trace_ds("> "); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(3); - *obptr++ = aid_byte; - ENCODE_BADDR(obptr, hSession->cursor_addr); + *h3270.obptr++ = aid_byte; + ENCODE_BADDR(h3270.obptr, hSession->cursor_addr); trace_ds("%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); baddr = 0; @@ -809,16 +809,16 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) if (hSession->ea_buf[baddr].fa) { if (hSession->reply_mode == SF_SRM_FIELD) { space3270out(2); - *obptr++ = ORDER_SF; + *h3270.obptr++ = ORDER_SF; } else { space3270out(4); - *obptr++ = ORDER_SFE; - attr_count = obptr - obuf; - *obptr++ = 1; /* for now */ - *obptr++ = XA_3270; + *h3270.obptr++ = ORDER_SFE; + attr_count = h3270.obptr - h3270.obuf; + *h3270.obptr++ = 1; /* for now */ + *h3270.obptr++ = XA_3270; } fa = hSession->ea_buf[baddr].fa & ~FA_PRINTABLE; - *obptr++ = code_table[fa]; + *h3270.obptr++ = code_table[fa]; if (any) trace_ds("'"); trace_ds(" StartField%s%s%s", @@ -827,32 +827,32 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) if (hSession->reply_mode != SF_SRM_FIELD) { if (hSession->ea_buf[baddr].fg) { space3270out(2); - *obptr++ = XA_FOREGROUND; - *obptr++ = hSession->ea_buf[baddr].fg; + *h3270.obptr++ = XA_FOREGROUND; + *h3270.obptr++ = hSession->ea_buf[baddr].fg; trace_ds("%s", see_efa(XA_FOREGROUND, hSession->ea_buf[baddr].fg)); - (*(obuf + attr_count))++; + (*(h3270.obuf + attr_count))++; } if (hSession->ea_buf[baddr].bg) { space3270out(2); - *obptr++ = XA_BACKGROUND; - *obptr++ = hSession->ea_buf[baddr].bg; + *h3270.obptr++ = XA_BACKGROUND; + *h3270.obptr++ = hSession->ea_buf[baddr].bg; trace_ds("%s", see_efa(XA_BACKGROUND, hSession->ea_buf[baddr].bg)); - (*(obuf + attr_count))++; + (*(h3270.obuf + attr_count))++; } if (hSession->ea_buf[baddr].gr) { space3270out(2); - *obptr++ = XA_HIGHLIGHTING; - *obptr++ = hSession->ea_buf[baddr].gr | 0xf0; + *h3270.obptr++ = XA_HIGHLIGHTING; + *h3270.obptr++ = hSession->ea_buf[baddr].gr | 0xf0; trace_ds("%s", see_efa(XA_HIGHLIGHTING, hSession->ea_buf[baddr].gr | 0xf0)); - (*(obuf + attr_count))++; + (*(h3270.obuf + attr_count))++; } if (hSession->ea_buf[baddr].cs & CS_MASK) { space3270out(2); - *obptr++ = XA_CHARSET; - *obptr++ = host_cs(hSession->ea_buf[baddr].cs); + *h3270.obptr++ = XA_CHARSET; + *h3270.obptr++ = host_cs(hSession->ea_buf[baddr].cs); trace_ds("%s", see_efa(XA_CHARSET,host_cs(hSession->ea_buf[baddr].cs))); - (*(obuf + attr_count))++; + (*(h3270.obuf + attr_count))++; } } any = False; @@ -865,14 +865,14 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) &any); if (hSession->ea_buf[baddr].cs & CS_GE) { space3270out(1); - *obptr++ = ORDER_GE; + *h3270.obptr++ = ORDER_GE; if (any) trace_ds("'"); trace_ds(" GraphicEscape"); any = False; } space3270out(1); - *obptr++ = hSession->ea_buf[baddr].cc; + *h3270.obptr++ = hSession->ea_buf[baddr].cc; if (hSession->ea_buf[baddr].cc <= 0x3f || hSession->ea_buf[baddr].cc == 0xff) { if (any) diff --git a/src/lib3270/ft_dft.c b/src/lib3270/ft_dft.c index 3baf003..a5f31c6 100644 --- a/src/lib3270/ft_dft.c +++ b/src/lib3270/ft_dft.c @@ -191,12 +191,12 @@ dft_open_request(unsigned short len, unsigned char *cp) /* Acknowledge the Open. */ trace_ds("> WriteStructuredField FileTransferData OpenAck\n"); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(6); - *obptr++ = AID_SF; - SET16(obptr, 5); - *obptr++ = SF_TRANSFER_DATA; - SET16(obptr, 9); + *h3270.obptr++ = AID_SF; + SET16(h3270.obptr, 5); + *h3270.obptr++ = SF_TRANSFER_DATA; + SET16(h3270.obptr, 9); net_output(); } @@ -316,14 +316,14 @@ dft_data_insert(struct data_buffer *data_bufr) /* Send an acknowledgement frame back. */ trace_ds("> WriteStructuredField FileTransferData DataAck(rec=%lu)\n", recnum); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(12); - *obptr++ = AID_SF; - SET16(obptr, 11); - *obptr++ = SF_TRANSFER_DATA; - SET16(obptr, TR_NORMAL_REPLY); - SET16(obptr, TR_RECNUM_HDR); - SET32(obptr, recnum); + *h3270.obptr++ = AID_SF; + SET16(h3270.obptr, 11); + *h3270.obptr++ = SF_TRANSFER_DATA; + SET16(h3270.obptr, TR_NORMAL_REPLY); + SET16(h3270.obptr, TR_RECNUM_HDR); + SET32(h3270.obptr, recnum); recnum++; net_output(); } @@ -356,7 +356,7 @@ dft_get_request(void) set_dft_buffersize(); space3270out(dft_buffersize); numbytes = dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ - bufptr = obuf + 17; + bufptr = h3270.obuf + 17; while (!dft_eof && numbytes) { if (ascii_flag && cr_flag) { int c; @@ -416,22 +416,22 @@ dft_get_request(void) } /* Set up SF header for Data or EOF. */ - obptr = obuf; - *obptr++ = AID_SF; - obptr += 2; /* skip SF length for now */ - *obptr++ = SF_TRANSFER_DATA; + h3270.obptr = h3270.obuf; + *h3270.obptr++ = AID_SF; + h3270.obptr += 2; /* skip SF length for now */ + *h3270.obptr++ = SF_TRANSFER_DATA; if (total_read) { trace_ds("> WriteStructuredField FileTransferData Data(rec=%lu) %d bytes\n", (unsigned long) recnum, (int) total_read); - SET16(obptr, TR_GET_REPLY); - SET16(obptr, TR_RECNUM_HDR); - SET32(obptr, recnum); + SET16(h3270.obptr, TR_GET_REPLY); + SET16(h3270.obptr, TR_RECNUM_HDR); + SET32(h3270.obptr, recnum); recnum++; - SET16(obptr, TR_NOT_COMPRESSED); - *obptr++ = TR_BEGIN_DATA; - SET16(obptr, total_read + 5); - obptr += total_read; + SET16(h3270.obptr, TR_NOT_COMPRESSED); + *h3270.obptr++ = TR_BEGIN_DATA; + SET16(h3270.obptr, total_read + 5); + h3270.obptr += total_read; ft_length += total_read; @@ -442,25 +442,25 @@ dft_get_request(void) } else { trace_ds("> WriteStructuredField FileTransferData EOF\n"); - *obptr++ = HIGH8(TR_GET_REQ); - *obptr++ = TR_ERROR_REPLY; - SET16(obptr, TR_ERROR_HDR); - SET16(obptr, TR_ERR_EOF); + *h3270.obptr++ = HIGH8(TR_GET_REQ); + *h3270.obptr++ = TR_ERROR_REPLY; + SET16(h3270.obptr, TR_ERROR_HDR); + SET16(h3270.obptr, TR_ERR_EOF); dft_eof = True; } /* Set the SF length. */ - bufptr = obuf + 1; - SET16(bufptr, obptr - (obuf + 1)); + bufptr = h3270.obuf + 1; + SET16(bufptr, h3270.obptr - (h3270.obuf + 1)); /* Save the data. */ - dft_savebuf_len = obptr - obuf; + dft_savebuf_len = h3270.obptr - h3270.obuf; if (dft_savebuf_len > dft_savebuf_max) { dft_savebuf_max = dft_savebuf_len; Replace(dft_savebuf, (unsigned char *)lib3270_malloc(dft_savebuf_max)); } - (void) memcpy(dft_savebuf, obuf, dft_savebuf_len); + (void) memcpy(dft_savebuf, h3270.obuf, dft_savebuf_len); h3270.aid = AID_SF; /* Write the data. */ @@ -478,12 +478,12 @@ dft_close_request(void) */ trace_ds(" Close\n"); trace_ds("> WriteStructuredField FileTransferData CloseAck\n"); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(6); - *obptr++ = AID_SF; - SET16(obptr, 5); /* length */ - *obptr++ = SF_TRANSFER_DATA; - SET16(obptr, TR_CLOSE_REPLY); + *h3270.obptr++ = AID_SF; + SET16(h3270.obptr, 5); /* length */ + *h3270.obptr++ = SF_TRANSFER_DATA; + SET16(h3270.obptr, TR_CLOSE_REPLY); net_output(); } @@ -501,15 +501,15 @@ static void dft_abort(unsigned short code, const char *fmt, ...) trace_ds("> WriteStructuredField FileTransferData Error\n"); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(10); - *obptr++ = AID_SF; - SET16(obptr, 9); /* length */ - *obptr++ = SF_TRANSFER_DATA; - *obptr++ = HIGH8(code); - *obptr++ = TR_ERROR_REPLY; - SET16(obptr, TR_ERROR_HDR); - SET16(obptr, TR_ERR_CMDFAIL); + *h3270.obptr++ = AID_SF; + SET16(h3270.obptr, 9); /* length */ + *h3270.obptr++ = SF_TRANSFER_DATA; + *h3270.obptr++ = HIGH8(code); + *h3270.obptr++ = TR_ERROR_REPLY; + SET16(h3270.obptr, TR_ERROR_HDR); + SET16(h3270.obptr, TR_ERR_CMDFAIL); net_output(); /* Update the pop-up and state. */ @@ -535,10 +535,10 @@ dft_read_modified(void) { if (dft_savebuf_len) { trace_ds("> WriteStructuredField FileTransferData\n"); - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(dft_savebuf_len); - memcpy(obptr, dft_savebuf, dft_savebuf_len); - obptr += dft_savebuf_len; + memcpy(h3270.obptr, dft_savebuf, dft_savebuf_len); + h3270.obptr += dft_savebuf_len; net_output(); } } diff --git a/src/lib3270/rpq.c b/src/lib3270/rpq.c index d250f46..a938afe 100644 --- a/src/lib3270/rpq.c +++ b/src/lib3270/rpq.c @@ -142,14 +142,14 @@ void do_qr_rpqnames(void) */ space3270out(4+4+1+remaining); /* Maximum space for an RPQNAME item */ - SET32(obptr, 0); /* Device number, 0 = All */ - SET32(obptr, 0); /* Model number, 0 = All */ + SET32(h3270.obptr, 0); /* Device number, 0 = All */ + SET32(h3270.obptr, 0); /* Model number, 0 = All */ - rpql = obptr++; /* Save address to place data length. */ + rpql = h3270.obptr++; /* Save address to place data length. */ /* Create fixed length portion - program id: x3270 */ for (j = 0; j < 5; j++) { - *obptr++ = asc2ebc[(int)"x3270"[j]]; + *h3270.obptr++ = asc2ebc[(int)"x3270"[j]]; remaining--; } @@ -164,11 +164,9 @@ void do_qr_rpqnames(void) term_id = rpq_keywords[j].id; - p_term = obptr; /* save starting address (to insert - length later) */ - obptr++; /* skip length of term, fill in - later */ - *obptr++ = term_id; /* identify this term */ + p_term = h3270.obptr; /* save starting address (to insert length later) */ + h3270.obptr++; /* skip length of term, fill in later */ + *h3270.obptr++ = term_id; /* identify this term */ /* * Adjust remaining space by the term prefix size so each case @@ -180,18 +178,18 @@ void do_qr_rpqnames(void) switch (term_id) { /* build the term based on id */ case RPQ_USER: /* User text from env. vars */ - obptr += get_rpq_user(obptr, remaining); + h3270.obptr += get_rpq_user(h3270.obptr, remaining); break; case RPQ_TIMEZONE: /* UTC time offset */ omit_due_space_limit = (remaining < 2); if (!omit_due_space_limit) - SET16(obptr, get_rpq_timezone()); + SET16(h3270.obptr, get_rpq_timezone()); break; case RPQ_ADDRESS: /* Workstation address */ #if !defined(_WIN32) /*[*/ - obptr += get_rpq_address(obptr, remaining); + h3270.obptr += get_rpq_address(h3270.obptr, remaining); #endif /*]*/ break; @@ -200,7 +198,7 @@ void do_qr_rpqnames(void) omit_due_space_limit = (x > remaining); if (!omit_due_space_limit) { for (i = 0; i < x; i++) { - *obptr++ = asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; + *h3270.obptr++ = asc2ebc[(int)(*(build_rpq_version+i) & 0xff)]; } } break; @@ -210,7 +208,7 @@ void do_qr_rpqnames(void) omit_due_space_limit = ((x+1)/2 > remaining); if (!omit_due_space_limit) { for (i=0; i < x; i+=2) { - *obptr++ = ((*(build_rpq_timestamp+i) - '0') << 4) + *h3270.obptr++ = ((*(build_rpq_timestamp+i) - '0') << 4) + (*(build_rpq_timestamp+i+1) - '0'); } } @@ -228,14 +226,14 @@ void do_qr_rpqnames(void) * adjust space remaining. * obptr now points at "next available byte". */ - x = obptr-p_term; + x = h3270.obptr-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. */ - obptr = p_term; + h3270.obptr = p_term; } /* * When we calculated the length of the term, a few lines @@ -257,7 +255,7 @@ void do_qr_rpqnames(void) } /* Fill in overall length of RPQNAME info */ - *rpql = (obptr - rpql); + *rpql = (h3270.obptr - rpql); rpq_dump_warnings(); } diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c index cf4619e..e83d93f 100644 --- a/src/lib3270/sf.c +++ b/src/lib3270/sf.c @@ -653,9 +653,9 @@ sf_outbound_ds(unsigned char buf[], int buflen) static void query_reply_start(void) { - obptr = obuf; + h3270.obptr = h3270.obuf; space3270out(1); - *obptr++ = AID_SF; + *h3270.obptr++ = AID_SF; qr_in_progress = True; } @@ -681,13 +681,13 @@ do_query_reply(unsigned char code) } do { - int obptr0 = obptr - obuf; + int obptr0 = h3270.obptr - h3270.obuf; Boolean full = True; space3270out(4); - obptr += 2; /* skip length for now */ - *obptr++ = SFID_QREPLY; - *obptr++ = code; + h3270.obptr += 2; /* skip length for now */ + *h3270.obptr++ = SFID_QREPLY; + *h3270.obptr++ = code; more = False; if (replies[i].single_fn) @@ -700,12 +700,12 @@ do_query_reply(unsigned char code) unsigned char *obptr_len; /* Fill in the length. */ - obptr_len = obuf + obptr0; - len = (obptr - obuf) - obptr0; + obptr_len = h3270.obuf + obptr0; + len = (h3270.obptr - h3270.obuf) - obptr0; SET16(obptr_len, len); } else { /* Back over the header. */ - obptr -= 4; + h3270.obptr -= 4; } } while (more); } @@ -730,7 +730,7 @@ do_qr_summary(void) #endif /*]*/ trace_ds("%s%s", comma, see_qcode(replies[i].code)); comma = ","; - *obptr++ = replies[i].code; + *h3270.obptr++ = replies[i].code; #if defined(X3270_DBCS) /*[*/ } #endif /*]*/ @@ -745,30 +745,30 @@ do_qr_usable_area(void) trace_ds("> QueryReply(UsableArea)\n"); space3270out(19); - *obptr++ = 0x01; /* 12/14-bit addressing */ - *obptr++ = 0x00; /* no special character features */ - SET16(obptr, h3270.maxCOLS); /* usable width */ - SET16(obptr, h3270.maxROWS); /* usable height */ - *obptr++ = 0x01; /* units (mm) */ + *h3270.obptr++ = 0x01; /* 12/14-bit addressing */ + *h3270.obptr++ = 0x00; /* no special character features */ + SET16(h3270.obptr, h3270.maxCOLS); /* usable width */ + SET16(h3270.obptr, h3270.maxROWS); /* usable height */ + *h3270.obptr++ = 0x01; /* units (mm) */ num = display_widthMM(); denom = display_width(); while (!(num %2) && !(denom % 2)) { num /= 2; denom /= 2; } - SET16(obptr, (int)num); /* Xr numerator */ - SET16(obptr, (int)denom); /* Xr denominator */ + SET16(h3270.obptr, (int)num); /* Xr numerator */ + SET16(h3270.obptr, (int)denom); /* Xr denominator */ num = display_heightMM(); denom = display_height(); while (!(num %2) && !(denom % 2)) { num /= 2; denom /= 2; } - SET16(obptr, (int)num); /* Yr numerator */ - SET16(obptr, (int)denom); /* Yr denominator */ - *obptr++ = *char_width; /* AW */ - *obptr++ = *char_height;/* AH */ - SET16(obptr, h3270.maxCOLS * h3270.maxROWS); /* buffer, questionable */ + SET16(h3270.obptr, (int)num); /* Yr numerator */ + SET16(h3270.obptr, (int)denom); /* Yr denominator */ + *h3270.obptr++ = *char_width; /* AW */ + *h3270.obptr++ = *char_height;/* AH */ + SET16(h3270.obptr, h3270.maxCOLS * h3270.maxROWS); /* buffer, questionable */ } static void @@ -782,16 +782,16 @@ do_qr_color(void) color_max = h3270.color8 ? 8: 16; /* report on 8 or 16 colors */ space3270out(4 + 2*15); - *obptr++ = 0x00; /* no options */ - *obptr++ = color_max; /* report on 8 or 16 colors */ - *obptr++ = 0x00; /* default color: */ - *obptr++ = 0xf0 + COLOR_GREEN; /* green */ + *h3270.obptr++ = 0x00; /* no options */ + *h3270.obptr++ = color_max; /* report on 8 or 16 colors */ + *h3270.obptr++ = 0x00; /* default color: */ + *h3270.obptr++ = 0xf0 + COLOR_GREEN; /* green */ for (i = 0xf1; i < 0xf1 + color_max - 1; i++) { - *obptr++ = i; + *h3270.obptr++ = i; if (h3270.m3279) - *obptr++ = i; + *h3270.obptr++ = i; else - *obptr++ = 0x00; + *h3270.obptr++ = 0x00; } /* @@ -813,17 +813,17 @@ do_qr_highlighting(void) { trace_ds("> QueryReply(Highlighting)\n"); space3270out(11); - *obptr++ = 5; /* report on 5 pairs */ - *obptr++ = XAH_DEFAULT; /* default: */ - *obptr++ = XAH_NORMAL; /* normal */ - *obptr++ = XAH_BLINK; /* blink: */ - *obptr++ = XAH_BLINK; /* blink */ - *obptr++ = XAH_REVERSE; /* reverse: */ - *obptr++ = XAH_REVERSE; /* reverse */ - *obptr++ = XAH_UNDERSCORE; /* underscore: */ - *obptr++ = XAH_UNDERSCORE; /* underscore */ - *obptr++ = XAH_INTENSIFY; /* intensify: */ - *obptr++ = XAH_INTENSIFY; /* intensify */ + *h3270.obptr++ = 5; /* report on 5 pairs */ + *h3270.obptr++ = XAH_DEFAULT; /* default: */ + *h3270.obptr++ = XAH_NORMAL; /* normal */ + *h3270.obptr++ = XAH_BLINK; /* blink: */ + *h3270.obptr++ = XAH_BLINK; /* blink */ + *h3270.obptr++ = XAH_REVERSE; /* reverse: */ + *h3270.obptr++ = XAH_REVERSE; /* reverse */ + *h3270.obptr++ = XAH_UNDERSCORE; /* underscore: */ + *h3270.obptr++ = XAH_UNDERSCORE; /* underscore */ + *h3270.obptr++ = XAH_INTENSIFY; /* intensify: */ + *h3270.obptr++ = XAH_INTENSIFY; /* intensify */ } static void @@ -831,9 +831,9 @@ do_qr_reply_modes(void) { trace_ds("> QueryReply(ReplyModes)\n"); space3270out(3); - *obptr++ = SF_SRM_FIELD; - *obptr++ = SF_SRM_XFIELD; - *obptr++ = SF_SRM_CHAR; + *h3270.obptr++ = SF_SRM_FIELD; + *h3270.obptr++ = SF_SRM_XFIELD; + *h3270.obptr++ = SF_SRM_CHAR; } #if defined(X3270_DBCS) /*[*/ @@ -858,9 +858,9 @@ do_qr_alpha_part(void) { trace_ds("> QueryReply(AlphanumericPartitions)\n"); space3270out(4); - *obptr++ = 0; /* 1 partition */ - SET16(obptr, h3270.maxROWS * h3270.maxCOLS); /* buffer space */ - *obptr++ = 0; /* no special features */ + *h3270.obptr++ = 0; /* 1 partition */ + SET16(h3270.obptr, h3270.maxROWS * h3270.maxCOLS); /* buffer space */ + *h3270.obptr++ = 0; /* no special features */ } static void @@ -870,35 +870,36 @@ do_qr_charsets(void) space3270out(64); #if defined(X3270_DBCS) /*[*/ if (dbcs) - *obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ + *h3270.obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ else #endif /*]*/ - *obptr++ = 0x82; /* flags: GE, CGCSGID present */ - *obptr++ = 0x00; /* more flags */ - *obptr++ = *char_width; /* SDW */ - *obptr++ = *char_height; /* SDW */ - *obptr++ = 0x00; /* no load PS */ - *obptr++ = 0x00; - *obptr++ = 0x00; - *obptr++ = 0x00; + *h3270.obptr++ = 0x82; /* flags: GE, CGCSGID present */ + + *h3270.obptr++ = 0x00; /* more flags */ + *h3270.obptr++ = *char_width; /* SDW */ + *h3270.obptr++ = *char_height; /* SDW */ + *h3270.obptr++ = 0x00; /* no load PS */ + *h3270.obptr++ = 0x00; + *h3270.obptr++ = 0x00; + *h3270.obptr++ = 0x00; #if defined(X3270_DBCS) /*[*/ if (dbcs) - *obptr++ = 0x0b; /* DL (11 bytes) */ + *h3270.obptr++ = 0x0b; /* DL (11 bytes) */ else #endif /*]*/ - *obptr++ = 0x07; /* DL (7 bytes) */ + *h3270.obptr++ = 0x07; /* DL (7 bytes) */ - *obptr++ = 0x00; /* SET 0: */ + *h3270.obptr++ = 0x00; /* SET 0: */ #if defined(X3270_DBCS) /*[*/ if (dbcs) - *obptr++ = 0x00; /* FLAGS: non-load, single- + *h3270.obptr++ = 0x00; /* FLAGS: non-load, single- plane, single-bute */ else #endif /*]*/ - *obptr++ = 0x10; /* FLAGS: non-loadable, + *h3270.obptr++ = 0x10; /* FLAGS: non-loadable, single-plane, single-byte, no compare */ - *obptr++ = 0x00; /* LCID 0 */ + *h3270.obptr++ = 0x00; /* LCID 0 */ #if defined(X3270_DBCS) /*[*/ if (dbcs) { *obptr++ = 0x00; /* SW 0 */ @@ -907,17 +908,17 @@ do_qr_charsets(void) *obptr++ = 0x00; /* SUBSN */ } #endif /*]*/ - SET32(obptr, cgcsgid); /* CGCSGID */ + SET32(h3270.obptr, cgcsgid); /* CGCSGID */ if (!*standard_font) { /* special 3270 font, includes APL */ - *obptr++ = 0x01;/* SET 1: */ + *h3270.obptr++ = 0x01;/* SET 1: */ if (h3270.apl_mode) - *obptr++ = 0x00;/* FLAGS: non-loadable, single-plane, + *h3270.obptr++ = 0x00;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ else - *obptr++ = 0x10;/* FLAGS: non-loadable, single-plane, + *h3270.obptr++ = 0x10;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ - *obptr++ = 0xf1;/* LCID */ + *h3270.obptr++ = 0xf1;/* LCID */ #if defined(X3270_DBCS) /*[*/ if (dbcs) { *obptr++ = 0x00;/* SW 0 */ @@ -926,10 +927,10 @@ do_qr_charsets(void) *obptr++ = 0x00;/* SUBSN */ } #endif /*]*/ - *obptr++ = 0x03;/* CGCSGID: 3179-style APL2 */ - *obptr++ = 0xc3; - *obptr++ = 0x01; - *obptr++ = 0x36; + *h3270.obptr++ = 0x03;/* CGCSGID: 3179-style APL2 */ + *h3270.obptr++ = 0xc3; + *h3270.obptr++ = 0x01; + *h3270.obptr++ = 0x36; } #if defined(X3270_DBCS) /*[*/ if (dbcs) { @@ -953,10 +954,10 @@ do_qr_ddm(void) trace_ds("> QueryReply(DistributedDataManagement)\n"); space3270out(8); - SET16(obptr,0); /* set reserved field to 0 */ - SET16(obptr, dft_buffersize); /* set inbound length limit INLIM */ - SET16(obptr, dft_buffersize); /* set outbound length limit OUTLIM */ - SET16(obptr, 0x0101); /* NSS=01, DDMSS=01 */ + SET16(h3270.obptr,0); /* set reserved field to 0 */ + SET16(h3270.obptr, dft_buffersize); /* set inbound length limit INLIM */ + SET16(h3270.obptr, dft_buffersize); /* set outbound length limit OUTLIM */ + SET16(h3270.obptr, 0x0101); /* NSS=01, DDMSS=01 */ } #endif /*]*/ @@ -965,15 +966,15 @@ do_qr_imp_part(void) { trace_ds("> QueryReply(ImplicitPartition)\n"); space3270out(13); - *obptr++ = 0x0; /* reserved */ - *obptr++ = 0x0; - *obptr++ = 0x0b; /* length of display size */ - *obptr++ = 0x01; /* "implicit partition size" */ - *obptr++ = 0x00; /* reserved */ - SET16(obptr, 80); /* implicit partition width */ - SET16(obptr, 24); /* implicit partition height */ - SET16(obptr, h3270.maxCOLS); /* alternate height */ - SET16(obptr, h3270.maxROWS); /* alternate width */ + *h3270.obptr++ = 0x0; /* reserved */ + *h3270.obptr++ = 0x0; + *h3270.obptr++ = 0x0b; /* length of display size */ + *h3270.obptr++ = 0x01; /* "implicit partition size" */ + *h3270.obptr++ = 0x00; /* reserved */ + SET16(h3270.obptr, 80); /* implicit partition width */ + SET16(h3270.obptr, 24); /* implicit partition height */ + SET16(h3270.obptr, h3270.maxCOLS); /* alternate height */ + SET16(h3270.obptr, h3270.maxROWS); /* alternate width */ } static void diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 82697ef..80c22f3 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -121,8 +121,8 @@ int ns_brcvd; int ns_rrcvd; int ns_bsent; int ns_rsent; -unsigned char *obuf; /* 3270 output buffer */ -unsigned char *obptr = (unsigned char *) NULL; +// unsigned char *obuf; /* 3270 output buffer */ +// unsigned char *obptr = (unsigned char *) NULL; int linemode = 1; /* @@ -2520,7 +2520,7 @@ void space3270out(int n) unsigned more = 0; if (obuf_size) - nc = obptr - obuf; + nc = h3270.obptr - h3270.obuf; while ((nc + n + EH_SIZE) > (obuf_size + more)) { more += BUFSIZ; @@ -2530,8 +2530,8 @@ void space3270out(int n) obuf_size += more; obuf_base = (unsigned char *)Realloc((char *)obuf_base, obuf_size); - obuf = obuf_base + EH_SIZE; - obptr = obuf + nc; + h3270.obuf = obuf_base + EH_SIZE; + h3270.obptr = h3270.obuf + nc; } } @@ -2669,7 +2669,7 @@ net_output(void) unsigned char *nxoptr, *xoptr; #if defined(X3270_TN3270E) /*[*/ -#define BSTART ((IN_TN3270E || IN_SSCP) ? obuf_base : obuf) +#define BSTART ((IN_TN3270E || IN_SSCP) ? obuf_base : h3270.obuf) #else /*][*/ #define BSTART obuf #endif /*]*/ @@ -2701,7 +2701,7 @@ net_output(void) #endif /*]*/ /* Reallocate the expanded output buffer. */ - while (xobuf_len < (obptr - BSTART + 1) * 2) { + while (xobuf_len < (h3270.obptr - BSTART + 1) * 2) { xobuf_len += BUFSZ; need_resize++; } @@ -2712,7 +2712,7 @@ net_output(void) /* Copy and expand IACs. */ xoptr = xobuf; nxoptr = BSTART; - while (nxoptr < obptr) { + while (nxoptr < h3270.obptr) { if ((*xoptr++ = *nxoptr++) == IAC) { *xoptr++ = IAC; } @@ -2802,7 +2802,7 @@ net_add_dummy_tn3270e(void) return False; space3270out(EH_SIZE); - h = (tn3270e_header *)obptr; + h = (tn3270e_header *)h3270.obptr; switch (tn3270e_submode) { case E_NONE: @@ -2821,7 +2821,7 @@ net_add_dummy_tn3270e(void) h->response_flag = TN3270E_RSF_NO_RESPONSE; h->seq_number[0] = 0; h->seq_number[1] = 0; - obptr += EH_SIZE; + h3270.obptr += EH_SIZE; return True; } #endif /*]*/ @@ -3085,7 +3085,7 @@ net_snap_options(void) if (!CONNECTED) return False; - obptr = obuf; + h3270.obptr = h3270.obuf; /* Do TTYPE first. */ if (h3270.myopts[TELOPT_TTYPE]) { @@ -3093,7 +3093,7 @@ net_snap_options(void) space3270out(sizeof(ttype_str)); for (j = 0; j < sizeof(ttype_str); j++) - *obptr++ = ttype_str[j]; + *h3270.obptr++ = ttype_str[j]; } /* Do the other options. */ @@ -3102,15 +3102,15 @@ net_snap_options(void) if (i == TELOPT_TTYPE) continue; if (h3270.hisopts[i]) { - *obptr++ = IAC; - *obptr++ = WILL; - *obptr++ = (unsigned char)i; + *h3270.obptr++ = IAC; + *h3270.obptr++ = WILL; + *h3270.obptr++ = (unsigned char)i; any = True; } if (h3270.myopts[i]) { - *obptr++ = IAC; - *obptr++ = DO; - *obptr++ = (unsigned char)i; + *h3270.obptr++ = IAC; + *h3270.obptr++ = DO; + *h3270.obptr++ = (unsigned char)i; any = True; } } @@ -3124,50 +3124,48 @@ net_snap_options(void) ((h3270.connected_type != CN) ? strlen(h3270.connected_type) : 0) + ((h3270.connected_lu != CN) ? + strlen(h3270.connected_lu) : 0) + 2); - *obptr++ = IAC; - *obptr++ = SB; - *obptr++ = TELOPT_TN3270E; - *obptr++ = TN3270E_OP_DEVICE_TYPE; - *obptr++ = TN3270E_OP_IS; + *h3270.obptr++ = IAC; + *h3270.obptr++ = SB; + *h3270.obptr++ = TELOPT_TN3270E; + *h3270.obptr++ = TN3270E_OP_DEVICE_TYPE; + *h3270.obptr++ = TN3270E_OP_IS; if (h3270.connected_type != CN) { - (void) memcpy(obptr, h3270.connected_type, - strlen(h3270.connected_type)); - obptr += strlen(h3270.connected_type); + (void) memcpy(h3270.obptr, h3270.connected_type,strlen(h3270.connected_type)); + h3270.obptr += strlen(h3270.connected_type); } if (h3270.connected_lu != CN) { - *obptr++ = TN3270E_OP_CONNECT; - (void) memcpy(obptr, h3270.connected_lu, - strlen(h3270.connected_lu)); - obptr += strlen(h3270.connected_lu); + *h3270.obptr++ = TN3270E_OP_CONNECT; + (void) memcpy(h3270.obptr, h3270.connected_lu,strlen(h3270.connected_lu)); + h3270.obptr += strlen(h3270.connected_lu); } - *obptr++ = IAC; - *obptr++ = SE; + *h3270.obptr++ = IAC; + *h3270.obptr++ = SE; space3270out(38); - (void) memcpy(obptr, functions_req, 4); - obptr += 4; - *obptr++ = TN3270E_OP_IS; + (void) memcpy(h3270.obptr, functions_req, 4); + h3270.obptr += 4; + *h3270.obptr++ = TN3270E_OP_IS; for (i = 0; i < 32; i++) { if (e_funcs & E_OPT(i)) - *obptr++ = i; + *h3270.obptr++ = i; } - *obptr++ = IAC; - *obptr++ = SE; + *h3270.obptr++ = IAC; + *h3270.obptr++ = SE; if (tn3270e_bound) { tn3270e_header *h; space3270out(EH_SIZE + 3); - h = (tn3270e_header *)obptr; + h = (tn3270e_header *)h3270.obptr; h->data_type = TN3270E_DT_BIND_IMAGE; h->request_flag = 0; h->response_flag = 0; h->seq_number[0] = 0; h->seq_number[1] = 0; - obptr += EH_SIZE; - *obptr++ = 1; /* dummy */ - *obptr++ = IAC; - *obptr++ = EOR; + h3270.obptr += EH_SIZE; + *h3270.obptr++ = 1; /* dummy */ + *h3270.obptr++ = IAC; + *h3270.obptr++ = EOR; } } #endif /*]*/ diff --git a/src/lib3270/telnetc.h b/src/lib3270/telnetc.h index f2cb1f9..06d1f20 100644 --- a/src/lib3270/telnetc.h +++ b/src/lib3270/telnetc.h @@ -20,8 +20,8 @@ */ /* Output buffer. */ -extern unsigned char *obuf; -extern unsigned char *obptr; +// extern unsigned char *obuf; +// extern unsigned char *obptr; /* Spelled-out tty control character. */ struct ctl_char { -- libgit2 0.21.2