Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 36
Writing a $CMON Program: An Example
Writing a $CMON Program: An Example
The example presented here contains the code for two different processes:
A $CMON process
A command-interface program, CMONCOM
The $CMON process responds to all requests from a TACL process as well as to
requests made by the command-interface program. The command-interface program
makes requests for run-time control over how $CMON responds to requests made by a
TACL process. Specifically, the command-interface program allows run-time control of:
The logon text
The logoff text
Rejection of all requests that are not operator requests made while the system is
shutting down
Choice of CPU in which to run new processes
Sample $CMON Program
The $CMON program is made up the procedures described below. Apart from the
main procedure, all $CMON procedures fall into two categories: procedures that
respond to requests from the command-interface program and procedures that
respond to requests from a TACL process.
The CMON^MAIN procedure reads messages from the $RECEIVE file.
Depending on the message code in the first word of each message, the
CMON^MAIN procedure calls the specific procedure for processing that message.
Positive message codes indicate messages from the command-interface program.
Negative message codes indicate messages from a TACL process.
The INIT and SAVE^STARTUP^MESSAGE procedures open the IN file and
$RECEIVE and initialize some variables.
The FILE^ERRORS and FILE^ERRORS^NAME procedures provide for file-system
error handling. When a file-system error is encountered, these procedures attempt
to display the name of the file that the error occurred against, as well as the file-
system error number itself.
Note. This example is written in TAL. However, you could write the same programs using any
supported programming language: for example, COBOL, C, or Pascal.
Note. Each procedure that handles a command-interpreter request uses a structure template
t
o gain access to fields of information within the received message. Although most of these
procedures make little use of buffered information, writing the code this way makes it easier for
future modification. A structure pointer maps the structure template to the I/O buffer.