User guide

128 CHAPTER 4. THE COMMAND LANGUAGE
resulting file. Either FILE or LIST or both must be supplied. If given FILE is the first
filename to be encoded followed by those given in LIST file, if present. If BIN is set,
files are read using binrdch so that carriage return characters (’*c’) are not ignored.
Each encoded file is preceeded by a separator of the form:
#####filename#
followed by the encoded file in which all charac t er s with ASCII codes in the range 33
to 126 ex c e pt for ’#’, ’=’ and ’.’ are copied, spaces are replaced by dots (’.’) and
all other characters (including ’#’ ’=’ and ’.’) are encoded by #hh where hh is the
ASCII code in hex. The encode d files are broken into lines of about 50 characters. The
last file to be encoded is terminated by ######+#.
Such xencode’d files can be decoded by the xdecode command.
4.4 cli.b and cli
init.b
The Command Language Interpreter is a simple program implemented in BCPL whose
source code can be found in the files sysb/cli.b and sysb/cli
init.b. This section
mainly describes the Cintpos version. The CLI is the first program the interacts with
after starting the system. Under Cintpos it runs as task one (named Root
Cli). It
uses variables in the global vector to hold its state during command execution. These
variables have reserved global numbers typically in the range 133 to 149. They are
declared in g/clihdr.b. Since running commands use the same global vector they can
access (and even modify) these variables a feature that is both dangerous and useful.
Commands such as run and c rely on thi s feature. The CLI global variables are as
follows.
cli
init CIN:y, POS:y, NAT:y
This holds the function used to initi al i s e the CLI, and depends on which context
the CLI is to r un in. It is called when the CLI is first enter ed using the following code.
{ LET f = cli_init(parm.pkt)
IF f DO f(result2) // Must get result2 after calling cli_init
}
As can be seen cli
init must either return zero or a function that can be applied
to result2. The function is typically deletetask or unloadseg with result2 being
suitably set.
cli
returncode, cli result2 CIN:y, POS:y, NAT:y
These hold the return code and the value of result2 of the most recently executed
command.