-- File: GCMisc.mesa, HGM August 15, 1978 12:17 AM -- Last Edit: Ly September 21, 1978 10:46 PM DIRECTORY DisplayDefs: FROM "DisplayDefs" USING [SetSystemDisplaySize], GCDefs: FROM "GCDefs" USING [ GCInterface, maxInform, PrintErrorPup, PrintPupAddress], IODefs: FROM "IODefs" USING [ CR, ReadID, ReadChar, ReadNumber, Rubout, SP, WriteChar, WriteLine, WriteString], PupDefs: FROM "PupDefs" USING [ AppendPupAddress, GetFreePupBuffer, GetLocalPupAddress, GetPupAddress, GetPupContentsBytes, PupBuffer, ReturnFreePupBuffer, MsToTocks, PupAddress, PupNameTrouble, PupSocketMake, PupSocketDestroy, SetPupContentsWords], PupStatsDefs: FROM "PupStatsDefs" USING [ gateControlExamine, gateControlStatsAck, gateControlDeposit], PupTypes: FROM "PupTypes" USING [fillInSocketID]; GCMisc: PROGRAM [gc: GCDefs.GCInterface] IMPORTS DisplayDefs, IODefs, PupDefs, GCDefs EXPORTS GCDefs = BEGIN OPEN gc, IODefs, PupDefs, GCDefs; sysDispPages: CARDINAL _ 40; socketOn: BOOLEAN _ FALSE; GetFailure: PUBLIC SIGNAL = CODE; PutFailure: PUBLIC SIGNAL = CODE; SetDisplay: PUBLIC PROCEDURE = BEGIN WriteString["Display Pages? "L]; sysDispPages _ ReadNumber[sysDispPages,10 ! Rubout => GOTO Reject]; WriteLine[""]; DisplayDefs.SetSystemDisplaySize[sysDispPages,(3*sysDispPages)/2]; EXITS Reject => WriteLine["xxx"]; END; WaitUntilKeyHit: PUBLIC PROCEDURE = BEGIN stopFlag _ FALSE; [] _ ReadChar[]; stopFlag _ TRUE; END; SetHost: PUBLIC PROCEDURE = BEGIN name: STRING _ [50]; who, address: PupAddress; i: CARDINAL; IF socketOn THEN PupSocketDestroy[gcSoc]; DO address _ [myNet,myHost,[0,0]]; AppendPupAddress[name,@address]; WriteString["Host: "L]; ReadID[name ! Rubout => BEGIN WriteLine["xxx"L]; LOOP; END]; GetPupAddress[@address,name ! PupNameTrouble => BEGIN WriteLine[e]; LOOP; END]; EXIT; ENDLOOP; IF address.net=0 THEN address.net_myNet; WriteString["="L]; PrintPupAddress[@address]; remHost_address; who _ [remHost.net,remHost.host,[31415,9265]]; gcSoc _ PupSocketMake[PupTypes.fillInSocketID,who,MsToTocks[3000]]; socketOn _ TRUE; FOR i IN [1..maxInform] DO newPartner[i] _ TRUE; ENDLOOP; WriteLine["."L]; END; FixHostAndNet: PUBLIC PROCEDURE = BEGIN me: PupAddress _ GetLocalPupAddress[[0,0],NIL]; myHost _ me.host; myNet _ me.net; END; YesOrNo: PUBLIC PROCEDURE[s: STRING] RETURNS[b: BOOLEAN] = BEGIN OPEN IODefs; WriteString[s]; WriteChar[SP]; SELECT ReadChar[] FROM 'Y, 'y, CR => b _ TRUE; ENDCASE => b _ FALSE; WriteLine[IF b THEN "Yes" ELSE "No"]; END; Read: PUBLIC PROCEDURE [p: POINTER] RETURNS [x: UNSPECIFIED] = BEGIN Get[to: @x, from: p, size: 1]; END; Get: PUBLIC PROCEDURE [to, from: POINTER, size: CARDINAL] = BEGIN OPEN PupDefs; b: PupBuffer; i,j: CARDINAL _ 0; IF size>250 THEN ERROR; DO -- until we get the answer IF i>2 OR j>6 THEN GetFailure[]; b _ GetFreePupBuffer[]; b.pupID _ [27182,i]; b.pupWords[0] _ LOOPHOLE[from]; b.pupWords[1] _ size; b.pupType _ PupStatsDefs.gateControlExamine; SetPupContentsWords[b,2]; gcSoc.put[b]; b _ gcSoc.get[]; IF b#NIL AND b.pupID=[27182,i] AND b.pupType=PupStatsDefs.gateControlStatsAck AND GetPupContentsBytes[b]=2*(2+size) THEN EXIT; IF b#NIL THEN BEGIN j _ j+1; PrintErrorPup[b]; ReturnFreePupBuffer[b]; END ELSE i _ i+1; ENDLOOP; FOR i IN [0..size) DO (to+i)^_b.pupWords[2+i]; ENDLOOP; ReturnFreePupBuffer[b]; END; Put: PUBLIC PROCEDURE [to, from: POINTER, size: CARDINAL] = BEGIN OPEN PupDefs; b: PupBuffer; i: CARDINAL _ 0; IF size>250 THEN ERROR; DO -- until we get the answer i _ i+1; b _ GetFreePupBuffer[]; b.pupWords[0] _ LOOPHOLE[to]; b.pupWords[1] _ size; b.pupType _ PupStatsDefs.gateControlDeposit; FOR i IN [0..size) DO b.pupWords[2+i] _ (from+i)^; ENDLOOP; SetPupContentsWords[b,size+2]; b.pupID _ [27182,i]; gcSoc.put[b]; b _ gcSoc.get[]; IF b#NIL AND b.pupID=[27182,i] AND b.pupType=PupStatsDefs.gateControlStatsAck AND GetPupContentsBytes[b]=0 THEN EXIT; IF b#NIL THEN ReturnFreePupBuffer[b]; IF i>4 THEN PutFailure[]; ENDLOOP; ReturnFreePupBuffer[b]; END; -- initialization END.(2048)\277t2 8t0 12t2 1t0 654t2 2t0 82b11B24b10B25b10B263b16B95b7B760b13B48t10 18t0 59b7B235b4B108b3B826b3B