-- File: PtMisc.mesa, Last Edit: -- MAS April 21, 1980 6:36 PM -- HGM November 8, 1979 11:02 PM DIRECTORY DisplayDefs: FROM "DisplayDefs" USING [SetSystemDisplaySize], IODefs: FROM "IODefs" USING [ CR, Rubout, ReadID, ReadNumber, WriteChar, WriteDecimal, WriteLine, WriteString], KeyDefs: FROM "KeyDefs" USING [Keys], OsStaticDefs: FROM "OsStaticDefs" USING [OsStatics], ProcessDefs: FROM "ProcessDefs" USING [Yield], StringDefs: FROM "StringDefs" USING [InvalidNumber], PupStream: FROM "PupStream" USING [SetMaxAllocation], StatsDefs: FROM "StatsDefs" USING [StatReady, StatSince], PupDefs: FROM "PupDefs" USING [ AppendPupAddress, PupNameTrouble, GetLocalPupAddress, GetPupAddress, ParsePupAddressConstant, PupAddressLookup, PupNameLookup, EnumeratePupAddresses, PupPackageDestroy, PupPackageMake, AdjustBufferParms, defaultPupsToAllocate, PupAddress, PrintPupAddress, SetLocalOnly], BufferDefs: FROM "BufferDefs" USING [defaultBufferPoolSize], PtDefs: FROM "PtDefs" USING [ clock, msPerTick, PtInterface, UnListen, PtEchoOff, PtEchoOn, PtStatsOff, PtStatsOn]; PtMisc: PROGRAM [pt: PtDefs.PtInterface] IMPORTS DisplayDefs, IODefs, ProcessDefs, StringDefs, StatsDefs, PupStream, PupDefs, PtDefs EXPORTS PtDefs = BEGIN OPEN pt, IODefs, StatsDefs, PupDefs, PtDefs; bufferPoolSize: CARDINAL _ BufferDefs.defaultBufferPoolSize; pupsToAllocate: CARDINAL _ defaultPupsToAllocate; PtBuffers: PUBLIC PROCEDURE = BEGIN bps: CARDINAL _ bufferPoolSize; dwpp: CARDINAL _ dataWordsPerPup; pta: CARDINAL _ pupsToAllocate; WriteString["bufferPoolSize: "L]; bps _ ReadNumber[bps,10 ! StringDefs.InvalidNumber, Rubout => GOTO Reject]; WriteChar[CR]; WriteString["dataWordsPerPup: "L]; dwpp _ ReadNumber[dwpp,10 ! StringDefs.InvalidNumber, Rubout => GOTO Reject]; WriteChar[CR]; WriteString["maxAllocate: "L]; pta _ ReadNumber[pta,10 ! StringDefs.InvalidNumber, Rubout => GOTO Reject]; WriteChar[CR]; bufferPoolSize _ bps; dataWordsPerPup _ dwpp; pupsToAllocate _ pta; UnListen[]; PtStatsOff[]; PtEchoOff[]; PupPackageDestroy[]; AdjustBufferParms[bufferPoolSize,dataWordsPerPup]; PupStream.SetMaxAllocation[pupsToAllocate]; PupPackageMake[]; PtStatsOn[]; PtEchoOn[]; EXITS Reject => WriteLine["xxx"L]; END; PtHost: PUBLIC PROCEDURE = BEGIN name: STRING _ [50]; address: PupAddress _ [myNet,myHost,[0,0]]; AppendPupAddress[name,address]; ReadID[name ! Rubout => GOTO Reject]; GetPupAddress[@address,name ! PupNameTrouble => BEGIN WriteLine[e]; GOTO Error; END]; IF address.net=0 THEN address.net_myNet; WriteString["="L]; PrintPupAddress[address]; pullHim.host _ pushHim.host_address.host; pullHim.net _ pushHim.net_address.net; IF address.socket#[0,0] THEN pullHim.socket_pushMe.socket_address.socket; WriteLine["."L]; EXITS Error => NULL; Reject => WriteLine["xxx"L]; END; PtNames: PUBLIC PROCEDURE = BEGIN PtLookerReady[]; NameTester["3#200#"L]; NameTester["MAXC"L]; NameTester["Maxc"L]; NameTester["Maxc+FTP"L]; NameTester["Portola"L]; NameTester[" P o r t o l a "L]; NameTester["UnknownName"L]; NameTester["illegal**character"L]; NameTester["200"L]; NameTester["200#"L]; NameTester["3#200"L]; NameTester["3#200#"L]; NameTester["3#200#7"L]; NameTester["3#200#0|6"L]; NameTester["3#200#12|34"L]; NameTester["3#200#1234567"L]; NameTester["Portcullis"L]; NameTester["ADL-Gateway"L]; NameTester[""L]; -- NameTester[NIL ! ANY => BEGIN WriteLine["Rejected."L]; CONTINUE END ]; NameTester["ME"L]; NameTester["IFS"L]; AddressTester[[[3],[200B],[0,0]]]; AddressTester[[[3],[200B],[0,3]]]; AddressTester[[[3],[200B],[0,12345]]]; AddressTester[[[3],[200B],[123,123]]]; AddressTester[pullMe]; AddressTester[[[0],[0],[0,3]]]; AddressTester[[[0],[0],[0,0]]]; ListNames["WikiWiki"]; ListNames["Twinkle"]; ListNames["PA"]; ListNames["Foo"]; PtLookerSince[]; END; NameTester: PROCEDURE [s: STRING] = BEGIN t: INTEGER; locally: BOOLEAN; a1, a2: PupAddress _ [[7B],[77B],[777B,7777B]]; SELECT TRUE FROM (s=NIL) => WriteString["**NIL**"L]; (s.length=0) => WriteString["**EMPTY**"L]; ENDCASE => WriteString[s]; WriteString[" => "L]; IF (locally_ParsePupAddressConstant[@a1,s]) THEN PrintPupAddress[a1] ELSE WriteString["--"L]; WriteString[" "L]; t _ clock^; PupNameLookup[@a2,s ! PupNameTrouble => BEGIN WriteLine[e]; GOTO Error; END]; t _ clock^-t; PrintPupAddress[a2]; WriteString[" "L]; IF locally AND a1#a2 THEN WriteString[" ***** "L]; WriteDecimal[msPerTick*t]; WriteLine["ms."L]; EXITS Error => NULL; END; AddressTester: PROCEDURE [a: PupAddress] = BEGIN t: INTEGER; s: STRING = [100]; PrintPupAddress[a]; WriteString[" => "L]; t _ clock^; PupAddressLookup[s,a ! PupNameTrouble => BEGIN WriteLine[e]; GOTO Error; END]; t _ clock^-t; WriteString[s]; WriteString[" "L]; WriteDecimal[msPerTick*t]; WriteLine["ms."L]; EXITS Error => NULL; END; ListNames: PROCEDURE [name: STRING] = BEGIN n: CARDINAL _ 0; PrintOne: PROCEDURE [a: PupAddress] RETURNS [BOOLEAN] = BEGIN IF n#0 THEN WriteString[", "L]; WriteDecimal[n_n+1]; WriteString[") "L]; PrintPupAddress[a]; RETURN[FALSE]; END; WriteString[name]; WriteString[" => "L]; [] _ EnumeratePupAddresses[name,PrintOne ! PupNameTrouble => BEGIN WriteLine[e]; GOTO Error; END]; WriteLine["."L]; EXITS Error => NULL; END; PtOnOff: PUBLIC PROCEDURE = BEGIN i: CARDINAL _ 0; UnListen[]; PtLookerReady[]; UNTIL KeyDefs.Keys.Space=down DO PtStatsOff[]; PtEchoOff[]; PupPackageDestroy[]; SetLocalOnly[localOnly_~localOnly]; PupPackageMake[]; PtFixHostAndNet[]; IF myHost#OsStaticDefs.OsStatics^.SerialNumber THEN WriteString["Bad myHost"L]; IF localOnly THEN BEGIN IF myNet#0 THEN WriteChar['?] END ELSE IF myNet ~IN[1..25) THEN WriteChar['?]; PtStatsOn[]; PtEchoOn[]; IF (i_i+1)=1--00-- THEN BEGIN i_0; WriteChar['!]; END; ENDLOOP; PtLookerSince[]; END; PtFixHostAndNet: PUBLIC PROCEDURE = BEGIN me: PupAddress _ GetLocalPupAddress[socNum,NIL]; myHost _ me.host; myNet _ me.net; pullMe.host _ pushMe.host _ pullHim.host _ pushHim.host _ myHost; pullMe.net _ pushMe.net _ pullHim.net _ pushHim.net _ myNet; END; pages: CARDINAL _ 0; PtDisplay: PUBLIC PROCEDURE = BEGIN WriteString["pagesForBitmap: "L]; pages _ ReadNumber[pages,10 ! StringDefs.InvalidNumber, Rubout => GOTO Reject]; WriteChar[CR]; DisplayDefs.SetSystemDisplaySize[2*pages,pages]; -- two lines/page seems ok EXITS Reject => WriteLine["xxx"L]; END; PtSched: PUBLIC PROCEDURE = BEGIN WriteLine["Timing StatSince"L]; THROUGH [0..10) DO StatSince[]; ENDLOOP; WriteLine["Timing 10,000 Yields and StatSince"L]; THROUGH [0..10) DO THROUGH [0..10000) DO ProcessDefs.Yield[]; ENDLOOP; StatSince[]; ENDLOOP; END; PtLookerStart: PUBLIC PROCEDURE = BEGIN END; PtLookerReady: PUBLIC PROCEDURE = BEGIN StatReady[]; END; PtLookerSince: PUBLIC PROCEDURE = BEGIN StatSince[]; END; PtLookerStop: PUBLIC PROCEDURE = BEGIN END; -- initialization END.(2048)\188t2 8t0 6t2 1t0 104t2 8t0 7t2 1t0 211t10 16t0 599t7 4t0 7t7 11t0 130t7 2t2 2t0 36b1B113b9B733t10 16t0 112b6B605b7B1044b10B691b13B351b9B462b7B592b15B48t10 18t0 213b9B288b7B294b13B37b13B52b13B52b12B