Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 19
The Part-Query Server ($SER1)
!------------------------------------------------------------
! Procedure to process a request for a part record. This
! procedure checks that the process that sent the message is
! in the opener table before retrieving the part record from
! the inventory file using the key supplied in the part
! 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:
PART^REQUEST.PART^NUMBER ':=' SBUFFER[0] FOR 10;
! Position pointers to appropriate record, based on
! the key value supplied in the request:
POSITIONING^MODE := EXACT;
CALL KEYPOSITION(INV^FNUM,
PART^REQUEST.PART^NUMBER,
!key^specifier!,
!length^word!,
POSITIONING^MODE);
IF <> THEN CALL FILE^ERRORS(INV^FNUM);
! Read the record from the inventory file:
CALL READUPDATEX(INV^FNUM,SBUFFER,BUFSIZE,COUNT^READ);