-- File: GCControl.mesa, HGM September 7, 1978 3:37 PM
-- Last modified, L. Stewart December 16, 1978 5:31 PM

DIRECTORY
-- ControlDefs: FROM "<Mesa>ControlDefs" USING [
-- FrameHandle, Lreg, NullFrame],
-- DiskLessDefs: FROM "DiskLessDefs" USING [MakeDiskLessBoot],
DisplayDefs: FROM "DisplayDefs" USING [SetSystemDisplaySize],
GCDefs: FROM "GCDefs" USING [
FixHostAndNet, GateControlMainLoop, GCCommand, GCEcho, GCMisc,
GCLook, GCPrint, GCPR, GCStats, GCVector, SetHost],
ImageDefs: FROM "ImageDefs" USING [MakeImage, StopMesa],
IODefs: FROM "IODefs" USING [
CR, WriteChar, WriteLine, WriteOctal, WriteString],
PupDefs: FROM "PupDefs" USING [PupPackageMake],
SrvrTnDefs: FROM "SrvrTnDefs" USING [SrvrTn],
StreamDefs: FROM "StreamDefs" USING [
DiskHandle, NewByteStream, Read, StreamError];

GCControl: PROGRAM
IMPORTS -- DiskLessDefs, -- DisplayDefs, GCDefs, ImageDefs,
IODefs, PupDefs, SrvrTnDefs, StreamDefs =
BEGIN
OPEN GCDefs, PupDefs;

gcVector: GCVector ← [
remHost: [,,[0,0]],
myHost: ,
myNet: ,
gcSoc: ,
stopFlag: FALSE,
newPartner:
];

START GCCommand[@gcVector];
START GCEcho[@gcVector];
START GCMisc[@gcVector];
START GCLook[@gcVector];
START GCPR[@gcVector];
START GCPrint[@gcVector];
START GCStats[@gcVector];

-- ok, now go to it

DisplayDefs.SetSystemDisplaySize[40,65];
IF FALSE THEN
BEGIN
IODefs.WriteLine["Saving self on GateControl.image..."];
ImageDefs.MakeImage["GateControl.image"];
END;

--IF FALSE THEN
-- BEGIN
-- self: ControlDefs.FrameHandle ← REGISTER[ControlDefs.Lreg];
-- self.returnlink ← [frame[ControlDefs.NullFrame]];
-- IODefs.WriteLine["Saving self on GateControl.boot..."];
-- DiskLessDefs.MakeDiskLessBoot["GateControl.boot"];
-- END;

-- run time initialization

BEGIN OPEN IODefs, StreamDefs;
myCom: DiskHandle;
startServer: BOOLEAN ← FALSE;
c: CHARACTER;

WriteLine["Mesa GateControl"];
BEGIN ENABLE StreamError => GOTO GiveUp;
myCom ← NewByteStream["Com.cm", Read];
WHILE NOT myCom.endof[myCom] DO
c ← myCom.get[myCom];
IF c=CR THEN EXIT;
IF c=’/ THEN
BEGIN
IF myCom.endof[myCom] THEN EXIT;
SELECT myCom.get[myCom] FROM
’S, ’s => startServer ← TRUE;
ENDCASE => NULL;
END;
ENDLOOP;
myCom.destroy[myCom];
EXITS
GiveUp => NULL;
END;

PupDefs.PupPackageMake[];
IF startServer THEN
BEGIN
WriteLine["Starting Server Telnet"];
START SrvrTnDefs.SrvrTn;
END;
END;

FixHostAndNet[];
BEGIN OPEN IODefs;
WriteString["We are host "]; WriteOctal[gcVector.myHost];
WriteString[" on Net "]; WriteOctal[gcVector.myNet];
WriteChar[CR];
END;

SetHost[];
GateControlMainLoop[];
ImageDefs.StopMesa[];

END. -- of GCControl