Guardian Programmer's Guide

Table Of Contents
Writing a Terminal Simulator
Guardian Programmer’s Guide 421922-014
24 - 6
Processing I/O Requests
6 indicates that a file-system message was received, so the message should be
processed as a system message.
The following code fragment checks the message read from $RECEIVE to determine
whether it is a system message or a user message:
CALL READUPDATE(RECV^NUM,BUFFER,RCOUNT);
CALL FILE_GETINFO_(RECV^NUM,ERROR);
IF ERROR = 6 THEN... !system message
IF ERROR = 0 THEN... !user message
If the condition code is normal, the process must determine whether the received
message is an I/O request and, if so, the type of I/O request. You can accomplish this
by calling the FILE_GETRECEIVEINFO_ procedure.
The FILE_GETRECEIVEINFO_ procedure returns information about the last message
read from $RECEIVE. The following values returned by the
FILE_GETRECEIVEINFO_ procedure are particularly important to a terminal-
simulation process:
The process handle of the process that sent the message.
The terminal-simulation process might use the process handle to communicate
with the requester process. For example, the terminal-simulation process might
need to send a BREAK message to the requester process. The process handle of
the requester is required in the BREAKMESSAGE_SEND_ procedure call.
A message tag associated with this message.
If the terminal-simulation process reads several messages before issuing a reply,
then the simulation process can use the message tag to specify the message to
which it is replying.
The maximum number of bytes the requester expects to read.
The terminal-simulation process can use this value to determine the maximum
number of bytes to return to the requester in response to a READ[X] or
WRITEREAD[X] request.
A value indicating the type of I/O request received.
The terminal-simulation process can use this value to determine whether the most
recently received message is an I/O request and, if so, whether it is a READ[X]
request, a WRITE[X] request, or a WRITEREAD[X] request.
The FILE_GETRECEIVEINFO_ procedure returns other parameters in addition to
these; see the Guardian Procedure Calls Reference Manual for a complete description
of the FILE_GETRECEIVEINFO_ procedure.