Beispiel #1
0
/* 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;
}
Beispiel #2
0
/* 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;
}