static void query_reply_start(void) { obptr = obuf; space3270out(1); *obptr++ = AID_SF; qr_in_progress = true; }
/* Create a trace file header. */ static char * create_tracefile_header(const char *mode) { char *buf; /* Create a buffer and redirect output. */ buf = Malloc(MAX_HEADER_SIZE); tracef_bufptr = buf; /* Display current status */ wtrace("Trace %s\n", mode); wtrace(" Version: %s\n", build); wtrace(" %s\n", build_options()); save_yourself(); wtrace(" Command: %s\n", command_string); wtrace(" Model %s, %d rows x %d cols", model_name, maxROWS, maxCOLS); #if defined(X3270_INTERACTIVE) && !defined(_WIN32) /*[*/ wtrace(", %s display", appres.mono ? "monochrome" : "color"); #endif /*]*/ if (appres.extended) wtrace(", extended data stream"); wtrace(", %s emulation", appres.m3279 ? "color" : "monochrome"); wtrace(", %s charset", get_charset_name()); if (appres.apl_mode) wtrace(", APL mode"); wtrace("\n"); #if !defined(_WIN32) /*[*/ wtrace(" Locale codeset: %s\n", locale_codeset); #else /*][*/ wtrace(" ANSI codepage: %d\n", GetACP()); # if defined(_WIN32) /*[*/ wtrace(" Local codepage: %d\n", appres.local_cp); # endif /*]*/ #endif /*]*/ wtrace(" Host codepage: %d", (int)(cgcsgid & 0xffff)); #if defined(X3270_DBCS) /*[*/ if (dbcs) wtrace("+%d", (int)(cgcsgid_dbcs & 0xffff)); #endif /*]*/ wtrace("\n"); #if defined(_WIN32) && (defined(C3270) || defined(S3270)) /*[*/ wtrace(" AppData: %s\n", myappdata? myappdata: "(null)"); wtrace(" Install dir: %s\n", instdir? instdir: "(null)"); wtrace(" Desktop: %s\n", mydesktop? mydesktop: "(null)"); #endif /*]*/ if (CONNECTED) wtrace(" Connected to %s, port %u\n", current_host, current_port); /* Snap the current TELNET options. */ if (net_snap_options()) { wtrace(" TELNET state:\n"); trace_netdata('<', obuf, obptr - obuf); } /* Dump the screen contents and modes into the trace file. */ if (CONNECTED) { /* * Note that if the screen is not formatted, we do not * attempt to save what's on it. However, if we're in * 3270 SSCP-LU or NVT mode, we'll do a dummy, empty * write to ensure that the display is in the right * mode. */ if (IN_3270) { wtrace(" Screen contents (%s3270) %sformatted:\n", IN_E? "TN3270E-": "", formatted? "": "un"); obptr = obuf; #if defined(X3270_TN3270E) /*[*/ (void) net_add_dummy_tn3270e(); #endif /*]*/ ctlr_snap_buffer(); space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); obptr = obuf; if (ctlr_snap_modes()) { wtrace(" 3270 modes:\n"); space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); } } #if defined(X3270_TN3270E) /*[*/ else if (IN_E) { obptr = obuf; (void) net_add_dummy_tn3270e(); wtrace(" Screen contents (%s):\n", IN_SSCP? "SSCP-LU": "TN3270E-NVT"); if (IN_SSCP) ctlr_snap_buffer_sscp_lu(); else if (IN_ANSI) ansi_snap(); space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); if (IN_ANSI) { wtrace(" NVT modes:\n"); obptr = obuf; ansi_snap_modes(); trace_netdata('<', obuf, obptr - obuf); } } #endif /*]*/ #if defined(X3270_ANSI) /*[*/ else if (IN_ANSI) { obptr = obuf; wtrace(" Screen contents (NVT):\n"); ansi_snap(); trace_netdata('<', obuf, obptr - obuf); wtrace(" NVT modes:\n"); obptr = obuf; ansi_snap_modes(); trace_netdata('<', obuf, obptr - obuf); } #endif /*]*/ } wtrace(" Data stream:\n"); /* Return the buffer. */ tracef_bufptr = CN; return buf; }
/* Create a trace file header. */ static char * create_tracefile_header(const char *mode) { char *buf; int i; /* Create a buffer and redirect output. */ buf = Malloc(MAX_HEADER_SIZE); tracef_bufptr = buf; /* Display current status */ wtrace(true, "Trace %s\n", mode); wtrace(false, " Version: %s\n", build); wtrace(false, " %s\n", build_options()); save_yourself(); wtrace(false, " Command: %s\n", command_string); wtrace(false, " Model %s, %d rows x %d cols", model_name, maxROWS, maxCOLS); wtrace(false, ", %s display", appres.interactive.mono? "monochrome": "color"); if (appres.extended) { wtrace(false, ", extended data stream"); } wtrace(false, ", %s emulation", appres.m3279 ? "color" : "monochrome"); wtrace(false, ", %s charset", get_charset_name()); if (appres.apl_mode) { wtrace(false, ", APL mode"); } wtrace(false, "\n"); #if !defined(_WIN32) /*[*/ wtrace(false, " Locale codeset: %s\n", locale_codeset); #else /*][*/ wtrace(false, " ANSI codepage: %d\n", GetACP()); # if defined(_WIN32) /*[*/ wtrace(false, " Local codepage: %d\n", appres.local_cp); # endif /*]*/ #endif /*]*/ wtrace(false, " Host codepage: %d", (int)(cgcsgid & 0xffff)); if (dbcs) { wtrace(false, "+%d", (int)(cgcsgid_dbcs & 0xffff)); } wtrace(false, "\n"); #if defined(_WIN32) /*[*/ wtrace(false, " Docs: %s\n", mydocs3270? mydocs3270: "(null)"); wtrace(false, " Install dir: %s\n", instdir? instdir: "(null)"); wtrace(false, " Desktop: %s\n", mydesktop? mydesktop: "(null)"); #endif /*]*/ wtrace(false, " Toggles:"); for (i = 0; toggle_names[i].name != NULL; i++) { if (toggle_supported(toggle_names[i].index) && !toggle_names[i].is_alias && toggled(toggle_names[i].index)) { wtrace(false, " %s", toggle_names[i].name); } } wtrace(false, "\n"); if (CONNECTED) { wtrace(false, " Connected to %s, port %u\n", current_host, current_port); } /* Snap the current TELNET options. */ if (net_snap_options()) { wtrace(false, " TELNET state:\n"); trace_netdata('<', obuf, obptr - obuf); } /* Dump the screen contents and modes into the trace file. */ if (CONNECTED) { /* * Note that if the screen is not formatted, we do not * attempt to save what's on it. However, if we're in * 3270 SSCP-LU or NVT mode, we'll do a dummy, empty * write to ensure that the display is in the right * mode. */ if (IN_3270) { wtrace(false, " Screen contents (%s3270) %sformatted:\n", IN_E? "TN3270E-": "", formatted? "": "un"); obptr = obuf; (void) net_add_dummy_tn3270e(); ctlr_snap_buffer(); space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); obptr = obuf; if (ctlr_snap_modes()) { wtrace(false, " 3270 modes:\n"); space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); } } else if (IN_E) { obptr = obuf; (void) net_add_dummy_tn3270e(); wtrace(false, " Screen contents (%s):\n", IN_SSCP? "SSCP-LU": "TN3270E-NVT"); if (IN_SSCP) { ctlr_snap_buffer_sscp_lu(); } else if (IN_NVT) { nvt_snap(); } space3270out(2); net_add_eor(obuf, obptr - obuf); obptr += 2; trace_netdata('<', obuf, obptr - obuf); if (IN_NVT) { wtrace(false, " NVT modes:\n"); obptr = obuf; nvt_snap_modes(); trace_netdata('<', obuf, obptr - obuf); } } else if (IN_NVT) { obptr = obuf; wtrace(false, " Screen contents (NVT):\n"); nvt_snap(); trace_netdata('<', obuf, obptr - obuf); wtrace(false, " NVT modes:\n"); obptr = obuf; nvt_snap_modes(); trace_netdata('<', obuf, obptr - obuf); } } wtrace(false, " Data stream:\n"); /* Return the buffer. */ tracef_bufptr = NULL; return buf; }
static void do_query_reply(unsigned char code) { size_t len; unsigned i; const char *comma = ""; size_t obptr0 = obptr - obuf; unsigned char *obptr_len; unsigned short num, denom; if (qr_in_progress) { trace_ds("> StructuredField\n"); qr_in_progress = false; } space3270out(4); obptr += 2; /* skip length for now */ *obptr++ = SFID_QREPLY; *obptr++ = code; switch (code) { case QR_CHARSETS: trace_ds("> QueryReply(CharacterSets)\n"); space3270out(64); if (dbcs) *obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ else *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; if (dbcs) *obptr++ = 0x0b; /* DL (11 bytes) */ else *obptr++ = 0x07; /* DL (7 bytes) */ *obptr++ = 0x00; /* SET 0: */ if (dbcs) *obptr++ = 0x00; /* FLAGS: non-load, single- plane, single-bute */ else *obptr++ = 0x10; /* FLAGS: non-loadable, single-plane, single-byte, no compare */ *obptr++ = 0x00; /* LCID 0 */ if (dbcs) { *obptr++ = 0x00; /* SW 0 */ *obptr++ = 0x00; /* SH 0 */ *obptr++ = 0x00; /* SUBSN */ *obptr++ = 0x00; /* SUBSN */ } SET32(obptr, cgcsgid); /* CGCSGID */ if (!standard_font) { /* special 3270 font, includes APL */ *obptr++ = 0x01;/* SET 1: */ *obptr++ = 0x10;/* FLAGS: non-loadable, single-plane, single-byte, no compare */ *obptr++ = 0xf1;/* LCID */ if (dbcs) { *obptr++ = 0x00;/* SW 0 */ *obptr++ = 0x00;/* SH 0 */ *obptr++ = 0x00;/* SUBSN */ *obptr++ = 0x00;/* SUBSN */ } *obptr++ = 0x03;/* CGCSGID: 3179-style APL2 */ *obptr++ = 0xc3; *obptr++ = 0x01; *obptr++ = 0x36; } if (dbcs) { *obptr++ = 0x80; /* SET 0x80: */ *obptr++ = 0x20; /* FLAGS: DBCS */ *obptr++ = 0xf8; /* LCID: 0xf8 */ *obptr++ = char_width * 2; /* SW */ *obptr++ = char_height; /* SH */ *obptr++ = 0x41; /* SUBSN */ *obptr++ = 0x7f; /* SUBSN */ SET32(obptr, cgcsgid_dbcs); /* CGCSGID */ } break; case QR_IMP_PART: 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, 72); /* implicit partition width */ SET16(obptr, 66); /* implicit partition height */ SET16(obptr, maxCOLS); /* alternate height */ SET16(obptr, maxROWS); /* alternate width */ break; case QR_NULL: trace_ds("> QueryReply(Null)\n"); break; case QR_SUMMARY: trace_ds("> QueryReply(Summary("); space3270out(NSR); for (i = 0; i < NSR; i++) { if (dbcs || supported_replies[i] != QR_DBCS_ASIA) { trace_ds("%s%s", comma, see_qcode(supported_replies[i])); comma = ","; *obptr++ = supported_replies[i]; } } trace_ds("))\n"); break; case QR_USABLE_AREA: trace_ds("> QueryReply(UsableArea)\n"); space3270out(19); *obptr++ = 0x01; /* 12/14-bit addressing */ *obptr++ = 0x00; /* no special character features */ SET16(obptr, maxCOLS); /* usable width */ SET16(obptr, maxROWS); /* usable height */ *obptr++ = 0x01; /* units (mm) */ num = /*display_widthMM()*/ 8*5/4; denom = /*display_width()*/ 7 * 72; while (!(num %2) && !(denom % 2)) { num /= 2; denom /= 2; } SET16(obptr, (int)num); /* Xr numerator */ SET16(obptr, (int)denom); /* Xr denominator */ num = /*display_heightMM()*/ 11*5/4; denom = /*display_height()*/ 9*66; 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, 0); /* buffer */ break; case QR_COLOR: trace_ds("> QueryReply(Color)\n"); space3270out(4 + 2*15); *obptr++ = 0x00; /* no options */ *obptr++ = 16; /* report on 16 colors */ *obptr++ = 0x00; /* default color: */ *obptr++ = 0xf0 + HOST_COLOR_GREEN; /* green */ for (i = 0xf1; i <= 0xff; i++) { *obptr++ = i; *obptr++ = i; } break; case QR_HIGHLIGHTING: 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 */ break; case QR_REPLY_MODES: trace_ds("> QueryReply(ReplyModes)\n"); space3270out(3); *obptr++ = SF_SRM_FIELD; *obptr++ = SF_SRM_XFIELD; *obptr++ = SF_SRM_CHAR; break; case QR_DBCS_ASIA: /* XXX: Should we support this, even when not in DBCS mode? */ trace_ds("> QueryReply(DbcsAsia)\n"); space3270out(7); *obptr++ = 0x00; /* flags (none) */ *obptr++ = 0x03; /* field length 3 */ *obptr++ = 0x01; /* SI/SO supported */ *obptr++ = 0x80; /* character set ID 0x80 */ *obptr++ = 0x03; /* field length 3 */ *obptr++ = 0x02; /* input control */ *obptr++ = 0x01; /* creation supported */ break; case QR_ALPHA_PART: trace_ds("> QueryReply(AlphanumericPartitions)\n"); space3270out(4); *obptr++ = 0; /* 1 partition */ SET16(obptr, maxROWS*maxCOLS); /* buffer space */ *obptr++ = 0; /* no special features */ break; case QR_DDM: trace_ds("> QueryReply(DistributedDataManagement)\n"); space3270out(8); SET16(obptr,0); /* set reserved field to 0 */ SET16(obptr,2048); /* set inbound length limit */ SET16(obptr,2048); /* set outbound length limit */ SET16(obptr,0x0101); /* NSS=01, DDMSS=01 */ break; default: return; /* internal error */ } obptr_len = obuf + obptr0; len = (obptr - obuf) - obptr0; SET16(obptr_len, len); }