program LOCKMGR_CHECK;
uses
  testlib;

var
  wa: boolean;
  wm: string;
  souf, sans: string;

procedure FastCompress (var s: string);
var i, j: integer;
begin
   i := 1; while (i<=length(s)) and (s [i] = ' ') do inc (i);
   if i > length (s) then s := ''
   else begin
     j := length (s); while s [j] = ' ' do dec (j);
     s := copy (s, i, j-i+1);
  end;
end;

function Compress (s: string): string;
begin
   FastCompress (s);
   Compress := s;
end;


begin
  wa:= false;
  while not ans.seekeof do begin
    sans:= compress(ans.readString);
    souf:= compress(ouf.readString);
    if (souf <> 'GRANTED') and
       (souf <> 'DENIED') and
       (souf <> 'IGNORED') then
      Quit(_PE, 'Unknown response: ' + souf);
    if not wa and (sans <> souf) then begin
      wa:= true;
      wm:= 'Wrong response: ' + souf + ' <> ' + sans;
    end;
  end;

  if not ouf.seekeof then Quit(_PE, 'Extra data in file');
  if wa then Quit(_WA, wm);
  Quit(_OK, 'Ok');
end.
