PROGRAM GCCITST;

{ TEST PROGRAM FOR GCCI PROCEDURE. 

FILE: [22,311]GCCITST.PAS
AUTHOR: Jim Bostwick 11-Apr-83
History: JMB 12-APR-83 -- reflect change to login and current UIC fields
  	 JMB  13-SEP-1984 16:38:56 -- Move to P3UTIL
}

{$NOLIST}
{[A+,B+,L-,K+,R+]  PASMAT }
%INCLUDE ex:[22,320]GENERAL3.TYP;
%INCLUDE ex:[22,320]BITS.TYP;
%INCLUDE ex:[22,320]RPOI.TYP;
%INCLUDE ex:[22,320]GCCI.TYP;
%INCLUDE ex:[22,320]GCCI.CON;
%INCLUDE ex:[22,320]RPOI.CON;
%INCLUDE ex:[22,320]DIRERR.EXT;
%INCLUDE ex:[22,320]CR56TA.EXT;
%INCLUDE ex:[22,320]CATR56.EXT;
%INCLUDE ex:[22,320]SPAWN.EXT;

{$LIST}

PROCEDURE GCCI(Var Buff: CH80; Var Len: Integer;
  		Var Info: GCCI_Info_rec);External;

PROCEDURE RPOI(Task:Rad56; CmdPtr:Address; CmdLen: Integer;
  		VAR Info: RPOI_Info_rec);EXTERNAL;

{ This procedure requests a task, and passes all offspring information
  to that task. Used primarily with CLIs, or when spawnning 'through'
  MCR...

  Jim Bostwick 12-Apr-83 }



VAR
  BUFFER:CH80;
  BUFLEN:INTEGER;
  INFO:GCCI_INFO_REC;
  FUBAR:BOOLEAN;
  Tnam:CH6;
  W1, W2: Word;
  I: Integer;   {buffer copy index }
  TAGCH: CHAR; {copy of first buffer char }
  ANSWER: CH80;
{ THESE ARE FOR SPAWN }
  MCRnam:RAD56;
  BufPtr: Address;
STATUS: INTEGER;
{ THESE ARE FOR RPOI }
  RPOI_DOPE:RPOI_INFO_rec;


{ This mindless CLI simply breaks and echos the command line information
  returned by GCCI. You must set up GCCITST as a CLI. You may have
  to set your terminal to GCI and back from another logged in priveleged
  terminal. 

  If the command line begins with '*', it is passed (less the asterisk)
  to MCR via spawn.}


BEGIN
  With RPOI_DOPE DO
    BEGIN 
    RPOI_Device[1] := chr(0);
    RPOI_Device[2] := chr(0);
    RPOI_Unit := 0;
    RPOI_Group := 0;
    RPOI_Member := 0;
    RPOI_RunName[1] := 0;
    RPOI_RunName[2] := 0;
    RPOI_Flags := 0;
    RPOI_Parent := RPOI_RunName;
    RPOI_POCB := 0;
    END;
  CATR56('MCR...', MCRnam);
info.gcci_device := 'NF';
info.gcci_unit := 44;
  INFO.GCCI_NOCOMMAND := 1; { SET EXIT ON NO-COMMAND }
  FUBAR := FALSE;
  REPEAT	{ FOREVER, MORE OR LESS }
    GCCI(BUFFER, BUFLEN, INFO);
    FUBAR := DIRERR('GCCI CALL ',$DSW); 
    IF NOT(FUBAR) THEN
      BEGIN 
  { here, we explore just where (what?) TI: is....}
      Write('who are you?');
      Readln(answer);
      Writeln(answer);
      Writeln('...but then you knew that...':20);
      WRITELN('GCCI RETURNS:');
      WRITELN('|',BUFFER,'|');
      WRITELN('BufLen:',Buflen:4);
      WRITELN('INFO:');
      With INFO DO 
	BEGIN 
	Writeln('Nocommand:':20, GCCI_nocommand:-8,'Device:':20, GCCI_Device);
	Writeln('Unit:':20, GCCI_unit:-8, 'CCL:':20, GCCI_CCL);
	Writeln('Flags:':20, GCCI_flags:-8, 'Term:':20, ORD(GCCI_Term):-8);
	CR56TA( GCCI_Parent, Tnam);
	Writeln('CW2':20, GCCI_CW2:-8, 'Parent:':20, Tnam);
	W1 := Loophole(Word, GCCI_Pocb);
	Writeln('POCB:':20, W1:-8, 'LOGUIC:':20, '[', GCCI_LogGroup:-3,',',
  	  GCCI_LogMember:-3, ']');
	Writeln('CurUIC:':20, '[', GCCI_CurGroup:-3, ',' ,GCCI_CurMEMBER:-3,
  	  ']');
	Writeln('CmdAddr:':20, loophole(word, GCCI_CMDADDR):-8);
	Writeln('DSW: ':20,$DSW:-8)
	END;
      If Buffer[1] IN ['*', '#'] THEN
	BEGIN 
	{ pass it to mcr or RPOI it }
        Tagch := Buffer[1]; {remember controll character }
	For I := 2 to buflen DO Buffer[i-1] := buffer[I];
	Buflen := buflen -1;
        BufPtr := Loophole(Address, Ref(Buffer));
	If Tagch = '*' THEN
	  BEGIN 
	  Writeln('Spawn MCR... With :|',Buffer:Buflen,'|');
	  SPAWN(MCRnam, F1, Bufptr, Buflen, StatUS);
	  Fubar := Direrr('SPAWN MCR ',$dsw)
	  END
	  ELSE BEGIN
	  Writeln('RPOI MCR... With  :|',Buffer:Buflen,'|');
	  RPOI(MCRnam, BufPtr, BufLen, RPOI_DOPE);
	  Fubar := Direrr('RPOI MCR  ', $dsw)
	  end
      end
     end;
      UNTIL FUBAR
end.
	
