Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 55
The Order-Query Server ($SER3)
!------------------------------------------------------------
! Procedure to process a request for an order record. This
! procedure checks that the process that sent the message is
! in the opener table before retrieving the order record from
! the orders file using the key supplied in the order
! number.
!------------------------------------------------------------
PROC PROCESS^USER^REQUEST;
BEGIN
INT POSITIONING^MODE; !used by KEYPOSITION
INT COUNT^READ;
INT COUNT;
INT J;
INT I;
! Check that the process handle of the requester is in the
! opener table:
I := 1;
WHILE I <= MAX^OPENERS DO
BEGIN
J := 0;
COUNT := 0;
WHILE J <= (ZSYS^VAL^PHANDLE^WLEN - 1) DO
BEGIN
IF RECEIVE^INFO[J + 6] =
OPENER^TABLE.OCB[I].PROCESS^HANDLE[J]
THEN COUNT := COUNT + 1;
J := J + 1;
END;
IF COUNT = ZSYS^VAL^PHANDLE^WLEN AND
RECEIVE^INFO[3] = OPENER^TABLE.OCB[I].FILE^NUMBER THEN
BEGIN
! Copy user message from requester into data
! structure:
ORDER^QUERY.ORDER^NUMBER ':=' SBUFFER[0] FOR 28;
! Position pointers to appropriate record, based on
! the key value supplied in the request:
POSITIONING^MODE := EXACT;
CALL KEYPOSITION(ORD^FNUM,
ORDER^QUERY.ORDER^NUMBER,
!key^specifier!,
!length^word!,
POSITIONING^MODE);
IF <> THEN CALL FILE^ERRORS(ORD^FNUM);