Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 41
The Process-Order Server ($SER2)
!------------------------------------------------------------
! Procedure to process an Open system message (-103). It
! places the process handle of the requester in the opener
! table, if there is room. If the table is full, it
! rejects the open.
!------------------------------------------------------------
PROC PROCESS^OPEN^MESSAGE;
BEGIN
INT I;
INT J;
INT COUNT;
! Check if opener table full. Return "file in use" error if
! it is full:
IF OPENER^TABLE.CURRENT^COUNT >= MAX^OPENERS THEN
BEGIN
REPLY^LEN := 0;
REPLY^ERROR := 12;
RETURN;
END;
! Put the process handle into the opener table at the first
! empty location and increment the count of openers:
I := 1;
WHILE I <= MAX^OPENERS DO
BEGIN
J := 0;
COUNT := 0;
WHILE J <= (ZSYS^VAL^PHANDLE^WLEN - 1) DO
BEGIN
IF OPENER^TABLE.OCB[I].PROCESS^HANDLE[J] = -1
THEN COUNT := COUNT + 1;
J := J + 1;
END;
IF COUNT = ZSYS^VAL^PHANDLE^WLEN THEN
BEGIN
OPENER^TABLE.OCB[I] ':='
RECEIVE^INFO[6] FOR ZSYS^VAL^PHANDLE^WLEN;
OPENER^TABLE.OCB[I].FILE^NUMBER := RECEIVE^INFO[3];
OPENER^TABLE.CURRENT^COUNT :=
OPENER^TABLE.CURRENT^COUNT + 1;
REPLY^LEN := 0;
REPLY^ERROR := 0;
RETURN;
END;
I := I + 1;
END;
END;