Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 47
Sample $CMON Program
!------------------------------------------------------------
! Procedure to process a Logoff^msg message. The message is
! always accepted except during the shutdown phase. The
! display text returned to the TACL process can be changed at
! run time.
!------------------------------------------------------------
PROC PROCESS^LOGOFF^MSG;
BEGIN
STRUCT MSG(*); !template for LOGOFF^MSG message
BEGIN
INT MSGCODE;
INT USERID;
INT CIPRI;
INT CIINFILE[0:11];
INT CIOUTFILE[0:11];
END;
INT .EXT LOGOFF^MSG(MSG) := $XADR(BUFFER); !structure
! pointer to I/O buffer
STRUCT .LOGOFF^REPLY; !structure for the reply
BEGIN
INT REPLYCODE;
STRING REPLYTEXT[0:63];
END;
! Blank the reply text buffer:
LOGOFF^REPLY.REPLYTEXT[0] ':=' " ";
LOGOFF^REPLY.REPLYTEXT[1] ':='
LOGOFF^REPLY.REPLYTEXT[0] FOR 63;
! Extract the group ID of the requesting process:
REQUESTING^GROUPID := LOGOFF^MSG.USERID.<0:7>;
! If shutting the system down, allow only operator group
! requests:
IF REFUSE^ALL AND (REQUESTING^GROUPID <> 255) THEN
BEGIN
LOGOFF^REPLY.REPLYCODE := 1;
LOGOFF^REPLY.REPLYTEXT ':=' SHUTDOWN^TEXT FOR 64;
END
ELSE
! Otherwise accept the request and return the logoff text:
BEGIN
LOGOFF^REPLY.REPLYCODE := 0;
LOGOFF^REPLY.REPLYTEXT ':=' LOGOFF^TEXT FOR 64;
END;
! Send the reply back to the TACL process: