Patch Number

Ticket Number

Change type




1. Description

Fixes and enhancements to telnetd, transcmd and terminal I/O.

2. Previous Release Behavior

In absence of a negotiated binary option, telnet protocol requires any CR to be followed by a LF or NUL. SimpleTranslateOutput() always added CR before LF, making it impossible to send a LF character alone to the client.

Similar to above, the terminal output function in jlibCOUNT_WIN32_UTF8.c sent data to the telnet process (or a pipe) via the CRT _write() function, which is documented to insert a CR before every LF.

The expected output from the following jBC statements is a single LF character, but due to the above, these statements produced CR:LF instead of the expected LF :

OUT 10

3. Current Release Behavior

Telnetd now recognizes the telnet binary option and sets the JBC_CLIENT_BINARY environment variable if the option is negotiated in both directions. This variable is used by Transcmd to indicate that the protocol is running in binary mode.

Transcmd now:

Transcmd ParseProfileFile() implements the "CALL" command, allowing remote.cmd to call another .cmd file to set environment variables. CALLs can be nested up to 10 levels. ParseProfileFile() also accepts (and ignores) the /D option for the CD (Change Directory) command, allowing the same remote.cmd file to be executed by cmd.exe without error.

Transcmd searches for the remote.cmd file in the user's profile, default user directory (C:\users\default), and jBASE release directory (in that order) and executes it if found (reading from jBASE release directory is new behavior).

The jBC OUT, CRT and PRINT statements now call a new "raw" version of terminal output to bypass translation of LF to CR:LF for telnet (and pipe) output. CRT and PRINT call the raw version only if the statement ends with a colon. The following statements all produce the same output, a single LF character:

OUT 10
x = OCONV(@LF, 'U017E')

This allows all 256 8-bit character codes to be output to a telnet client (or pipe).

To better handle binary input, the jConsoleMapKey() function in jlibCOUNT_WIN32_UTF8.c has been modified to translate the following console input events:

Ctrl+Shift+2    NUL
Ctrl+Enter      LF
Ctrl+Backspace  DEL

This allows jBASE programs to accept all control characters for input that the client can produce. In the case of telnet, if the break character is disabled, and binary mode is in effect, all 256 8-bit codes are possible.

The jdiag command has been modified to open stdout in text mode instead of binary mode. Due to the change in transcmd which no longer forces a CR before every LF, output from jdiag was incorrect. Changing to text mode restores the correct output.

The change in "raw" output can be disabled by setting the new JBC_TELNET_OUT_LF_TO_CRLF environment variable.