DIRECTORY Ascii USING [Digit], FS USING [Error, StreamOpen], IO USING [Close, EndOf, EndOfStream, Error, GetChar, GetLineRope, GetTokenRope, IDProc, PeekChar, STREAM], IPDefs USING [Address], IPConfig, MessageWindow USING [Append], Rope USING [Cat, Equal, ROPE], RopeList USING [Append]; IPConfigImpl: CEDAR PROGRAM IMPORTS Ascii, FS, IO, MessageWindow, Rope, RopeList EXPORTS IPConfig = BEGIN OPEN IPConfig; ROPE: TYPE = Rope.ROPE; impGatewayName: PUBLIC ROPE _ "Gandalf"; specialGateways: PUBLIC LIST OF IPDefs.Address; -- list of special BBN gateways ourLocalAddress: PUBLIC IPDefs.Address _ [10, 1, 0, 32]; ourLocalName: PUBLIC Rope.ROPE _ "Xerox.COM"; rootServers: PUBLIC LIST OF Rope.ROPE; -- list of ARPA domain servers rootServerAddresses: PUBLIC LIST OF IPDefs.Address; -- list of ARPA domain server addresses specialDomains: PUBLIC LIST OF Rope.ROPE; topLevelDomains: PUBLIC LIST OF Rope.ROPE; validDomains: PUBLIC LIST OF Rope.ROPE; uucpGateway: PUBLIC Rope.ROPE _ "seismo.css.gov"; csnetGateway: PUBLIC Rope.ROPE _ "relay.cs.net"; bitnetGateway: PUBLIC Rope.ROPE _ "WISCVM.WISC.EDU"; mailnetGateway: PUBLIC Rope.ROPE _ "MIT-MULTICS.ARPA"; configFileName: ROPE = "IPConfig.data"; ParseAddress: PROC [s: IO.STREAM] RETURNS [a: IPDefs.Address] = { AToI: PROC [s: IO.STREAM] RETURNS [i: INT _ 0] = { WHILE ~IO.EndOf[s] AND Ascii.Digit[IO.PeekChar[s]] DO i _ i*10 + (s.GetChar[]-'0); ENDLOOP; }; WHILE IO.PeekChar[s] = ' DO [] _ IO.GetChar[s]; ENDLOOP; IF IO.PeekChar[s] = '[ THEN [] _ IO.GetChar[s]; FOR i: INT IN [0..3] DO a[i] _ AToI[s]; IF ~IO.EndOf[s] AND IO.PeekChar[s] = '. THEN [] _ IO.GetChar[s]; ENDLOOP; IF ~IO.EndOf[s] AND IO.PeekChar[s] = '] THEN [] _ IO.GetChar[s]; }; ReadConfigurationFile: PROC ~ { ENABLE { IO.EndOfStream => GO TO GiveUp; IO.Error => { MessageWindow.Append[message: Rope.Cat["Syntax error in ", configFileName], clearFirst: TRUE]; GO TO GiveUp; }; }; f: IO.STREAM; t: Rope.ROPE; SkipWhite: PROC [s: IO.STREAM] ~ { WHILE s.PeekChar[] = ' OR s.PeekChar[] = '\t DO [] _ s.GetChar[]; ENDLOOP; }; ParseRopeList: PROC [s: IO.STREAM] RETURNS [list: LIST OF Rope.ROPE] = { DO SkipWhite[s]; IF s.PeekChar = '\n THEN EXIT; list _ RopeList.Append[list, LIST[s.GetTokenRope[IO.IDProc].token]]; ENDLOOP; }; f _ FS.StreamOpen[configFileName ! FS.Error => { MessageWindow.Append[message: error.explanation, clearFirst: TRUE]; GO TO GiveUp}]; WHILE NOT f.EndOf[] DO [token: t] _ f.GetTokenRope[IO.IDProc]; SkipWhite[f]; IF f.PeekChar[] = ': THEN [] _ f.GetChar[]; SELECT TRUE FROM t.Equal["LocalHost"] => ourLocalAddress _ ParseAddress[f]; t.Equal["SpecialGateways"] => { specialGateways _ NIL; DO addr: LIST OF IPDefs.Address; SkipWhite[f]; IF f.PeekChar = '\n THEN EXIT; addr _ CONS[ParseAddress[f], NIL]; IF specialGateways = NIL THEN specialGateways _ addr ELSE FOR list: LIST OF IPDefs.Address _ specialGateways, list.rest UNTIL list = NIL DO IF list.rest = NIL THEN {list.rest _ addr; EXIT; }; ENDLOOP; ENDLOOP; }; t.Equal["RootServerAddresses"] => { rootServerAddresses _ NIL; DO addr: LIST OF IPDefs.Address; SkipWhite[f]; IF f.PeekChar = '\n THEN EXIT; addr _ CONS[ParseAddress[f], NIL]; IF rootServerAddresses = NIL THEN rootServerAddresses _ addr ELSE FOR list: LIST OF IPDefs.Address _ rootServerAddresses, list.rest UNTIL list = NIL DO IF list.rest = NIL THEN {list.rest _ addr; EXIT; }; ENDLOOP; ENDLOOP; }; t.Equal["ImpGateway"] => [token: impGatewayName] _ f.GetTokenRope[IO.IDProc]; t.Equal["LocalName"] => [token: ourLocalName] _ f.GetTokenRope[IO.IDProc]; t.Equal["UUCPGateway"] => [token: uucpGateway] _ f.GetTokenRope[IO.IDProc]; t.Equal["CSNETGateway"] => [token: csnetGateway] _ f.GetTokenRope[IO.IDProc]; t.Equal["BitnetGateway"] => [token: bitnetGateway] _ f.GetTokenRope[IO.IDProc]; t.Equal["MailnetGateway"] => [token: mailnetGateway] _ f.GetTokenRope[IO.IDProc]; t.Equal["SpecialDomains"] => {specialDomains _ ParseRopeList[f]}; t.Equal["TopLevelDomains"] => {topLevelDomains _ ParseRopeList[f]}; t.Equal["RootServers"] => {rootServers _ ParseRopeList[f]}; ENDCASE => NULL; [] _ f.GetLineRope[]; -- toss text to end of line ENDLOOP; IO.Close[f]; EXITS GiveUp => NULL; }; ReadConfigurationFile[]; validDomains _ RopeList.Append[topLevelDomains, specialDomains]; END. άCopyright (C) 1987 by Xerox Corporation. All rights reserved. The following program was created in 1983 but has not been published within the meaning of the copyright law, is furnished under license, and may not be used, copied and/or disclosed except in accordance with the terms of said license. IPConfigImpl.mesa John Larson, July 12, 1987 3:47:47 pm PDT Read Configuration File Look for a configuration file and use it for some parameter values. Initialization code ΚV– "cedar" style˜Icode2šœ©™©headšœ™Icode™)šΟk ˜ Kšœœ ˜Kšœœ˜KšœœZœ˜jKšœœ ˜Kšœ ˜ Kšœœ ˜Kšœœœ˜Kšœ œ ˜——šΟn œœ˜Kšœœœ˜4Kšœ ˜Kšœœ ˜Kšœœœ˜Kšœ œ ˜(Kšœ œœΟc˜QKšœœ!˜8Kšœœœ˜-Kš œ œœœœŸ˜FKšœœœœŸ'˜\Kš œœœœœ˜)Kš œœœœœ˜*Kš œœœœœ˜'Kšœ œœ˜1Kšœœœ˜0Kšœœœ˜4Kšœœœ˜6Kšœœ˜'—™š ž œœœœœ˜Aš žœœœœœœ ˜2š œœ œ œ˜5K˜Kšœ˜ ——Kš œœœœ œ˜9Kšœœœœ ˜/šœœœ˜K˜Kš œœ œœœœ ˜@Kšœ˜—Kš œœ œœœœ˜CK˜—šžœœ˜K™Cšœ˜Kšœœœ˜šœ ˜ KšΟrXΠkr ˜^Kšœœ˜ K˜—K˜—Kšœœœ˜ Kšœœ˜ K˜šž œœœœ˜"šœœ˜0K˜Kšœ˜—K˜K˜—šž œœœœœœœœ˜Hš˜K˜ Kšœ œ˜Kšœœœ˜DKšœ˜—Kšœ˜K˜K˜K˜—K˜šœœœ ˜0Kš œœ˜CKšœœ ˜—šœœ ˜Kšœœ ˜'K˜ šœ˜K˜—šœœ˜K˜:˜Kšœœ˜š˜Kšœœœ˜K˜ šœ˜Kšœ˜—Kšœœœ˜"Kšœœœ˜4š˜š œœœ-œœ˜QKšœ œœœ˜3Kšœ˜——Kšœ˜—K˜—˜#Kšœœ˜š˜Kšœœœ˜K˜ šœ˜Kšœ˜—Kšœœœ˜"Kšœœœ˜<š˜š œœœ1œœ˜UKšœ œœœ˜3Kšœ˜——Kšœ˜—K˜—KšœBœ ˜MKšœ?œ ˜JKšœ@œ ˜KKšœBœ ˜MKšœDœ ˜OKšœFœ ˜QKšœA˜AKšœC˜CKšœ;˜;Kšœœ˜—KšœŸ˜1Kšœ˜K˜ —š˜Kšœ œ˜—K˜——™K˜K˜@Kšœ˜——…—ŠΌ