Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 31
Refusing Command-Interpreter Requests
Refusing Command-Interpreter Requests
You can write your $CMON and command-interface programs to set a flag that
$CMON will check before replying to any command-interpreter message. If the flag is
on, then $CMON rejects all requests. If the flag is off, then requests are processed
normally.
To enable operator requests to continue to be accepted when requests from other
users are rejected, $CMON should check the group number of the requesting process
and allow the request if the group number is 255 (the group number for the operations
group). If the group number is not 255, it should reject the request.
The following code fragments show the logic required in the control and $CMON
processes to accomplish selective rejection of requests. The logic shown in $CMON is
for the logon request but is the same for any other request.
In the command-interface program:
STRUCT RT^SHUTDOWN^MSG; !structure for run-time logon
BEGIN ! message
INT MSGCODE; !value (plus) 61
STRING SHUTDOWN^MSG[0:n]; !the reply text for subsequent
! command-interpreter requests;
END; ! 132 bytes maximum
.
.
!Prompt operator for new logon text:
SBUFFER ':=' "Type 'x' to reject users: " -> @S^PTR;
WCOUNT := @S^PTR '-' @SBUFFER;
RCOUNT := 2;
CALL WRITEREADX(TERM^NUM,SBUFFER,WCOUNT,RCOUNT,BYTES^READ);
IF SBUFFER[0] = "x" THEN
BEGIN
! Prompt operator for shutdown text:
SBUFFER ':=' "Enter message text: " -> @S^PTR;;
WCOUNT := S^PTR '-' @SBUFFER;
CALL WRITEREADX(TERM^NUM,SBUFFER,WCOUNT,RCOUNT,
BYTES^READ);
! Fill in RT^SHUTDOWN^MSG data structure and send it to
! $CMON:
RT^SHUTDOWN^MSG.MSG^CODE := 61;
RT^SHUTDOWN^MSG.SHUTDOWN^MSG ':=' SBUFFER[0] FOR
BYTES^READ;
WCOUNT := BYTES^READ + 2;
CALL WRITEREADX(CMON^NUM,RT^SHUTDOWN^MSG,WCOUNT,RCOUNT,
BYTES^READ);
END;