Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 4
Getting Message Information
BEGIN
INT PROCESS^HANDLE [0:9]; !process handle of opener
INT RESERVED^HANDLE [0:9]; !reserved, filled with -1; this
! field is required for
OPENER_LOST_
INT FILE^NUMBER; !file number used by opener
INT RESERVED^FILE^NUMBER; !for use with NonStop pairs
END;
An opener table entry can have other fields defined in addition to those shown above.
For example, to support full NonStop operation with opens from process pairs, the
opener table entry would use fields, where the reserved areas are shown, for the
backup open from a process pair; it would also have a field for the sync ID value.
However, if neither NonStop operation nor opener context is to be supported, it is
simpler to use only the two fields defined above, which can support backup opens by
treating them as independent opens. The examples in this section use this simpler
approach.
Getting Message Information
Before referring to your opener table, you first need to analyze the message read from
$RECEIVE to determine what to do:
If the message read from $RECEIVE is an Open message, you need to add the
process handle of the requester to the opener table.
If the message read from $RECEIVE is a Close message, you need to remove the
process handle of the requester from the opener table.
If the message read from $RECEIVE is a user request message, you need to
check that the process handle of the requester is in the opener table before
processing the request.
You can determine whether the received message is a system message or a user
message by calling the FILE_GETINFO_ procedure immediately after reading from
$RECEIVE. If the error number returned by FILE_GETINFO_ is 6, then the message
is a system message. If the error number is 0, then the message is a user message.
CALL READUPDATEX(RECV^NUM,SBUFFER,RCOUNT);
CALL FILE_GETINFO_(RECV^NUM,ERROR);
IF ERROR = 6 THEN... !system message
IF ERROR = 0 THEN... !user message
In addition to checking for a system message, you should also get the process handle
and file number of the process that sent the message. You will use the process handle
and file number for adding an entry to the opener table or for comparing with entries
that already exist in the opener table.
You can determine the process handle and file number of the message sender by
calling the FILE_GETRECEIVEINFO_ procedure. This procedure returns 17 words of