DIRECTORY BridgeFTPOps USING [StoreFile, RetrieveFile], BridgeSubmit USING [TransferProc, Register], FSExtras USING [GetWDir], IO USING [STREAM], Rope USING [ROPE, Cat], SymTab USING [Ref, Create, Fetch, Store, Delete], TerminalIO USING [PutRope, TOS], TWOps; TWOpsImpl: CEDAR MONITOR IMPORTS BridgeFTPOps, BridgeSubmit, FSExtras, Rope, SymTab, TerminalIO EXPORTS TWOps ~ BEGIN ROPE: TYPE ~ Rope.ROPE; host: ROPE _ "Velantia"; remoteDir: ROPE _ "/usr/guest/"; twCmd: ROPE _ "/usr/guest/timberwolf/TimberWolfSC "; nInExt: NAT = 4; inExt: ARRAY [0..nInExt) OF ROPE _ [".cel", ".net", ".blk", ".par"]; nOutExt: NAT = 3; outExt: ARRAY [0..nOutExt) OF ROPE _ [".out", ".pl1", ".pl2"]; msgStream: IO.STREAM _ TerminalIO.TOS[]; keyTable: SymTab.Ref _ SymTab.Create[]; Key: TYPE = REF KeyRec; KeyRec: TYPE = RECORD [ msg: ROPE, locked: BOOL _ TRUE, unlocked: CONDITION ]; Store: BridgeSubmit.TransferProc ~ { FOR i: NAT IN [0..nInExt) DO localName : ROPE _ Rope.Cat[wDir, id, inExt[i]]; remoteName: ROPE _ Rope.Cat[remoteDir, id, inExt[i]]; msg _ BridgeFTPOps.StoreFile[s, remoteName, localName, msgStream]; IF msg#NIL THEN { OK[id, msg]; RETURN[msg]}; ENDLOOP; }; Retrieve: BridgeSubmit.TransferProc ~ { FOR i: NAT IN [0..nOutExt) DO localName : ROPE _ Rope.Cat[wDir, id, outExt[i]]; remoteName: ROPE _ Rope.Cat[remoteDir, id, outExt[i]]; msg _ BridgeFTPOps.RetrieveFile[s, remoteName, localName, msgStream]; IF msg#NIL THEN { OK[id, msg]; RETURN[msg]}; ENDLOOP; OK[id, NIL]; }; TWIt: PUBLIC PROC [id: ROPE, waitUntilDone: BOOLEAN _ FALSE] RETURNS [msg: ROPE] ~ { wDir: ROPE _ FSExtras.GetWDir[]; key: Key _ GetKey[id]; cmd: ROPE _ Rope.Cat[twCmd, id]; IF key=NIL THEN RETURN[Rope.Cat["TWOps -> The rope: '", id, "' is already in use"]]; msg _ BridgeSubmit.Register[host, id, cmd, wDir, Store, Retrieve, NIL, NIL, remoteDir]; IF msg=NIL AND waitUntilDone THEN msg _ WaitForOk[key]; }; GetKey: PROC [id: ROPE] RETURNS[key: Key] ~ { IF SymTab.Fetch[keyTable, id].found THEN RETURN [NIL]; key _ NEW[KeyRec]; [] _ SymTab.Store[keyTable, id, key]; }; WaitForOk: ENTRY PROC [key: Key] RETURNS [msg: ROPE] ~ { ENABLE UNWIND => NULL; WHILE key.locked DO WAIT key.unlocked ENDLOOP; RETURN [key.msg]; }; OK: PROC [id, msg: ROPE] ~ { key: Key _ NARROW[SymTab.Fetch[keyTable, id].val]; IF key=NIL THEN RETURN; [] _ SymTab.Delete[keyTable, id]; key.msg _ msg; Unlock[key]; }; Unlock: ENTRY PROC [key: Key] ~ { ENABLE UNWIND => NULL; key.locked _ FALSE; BROADCAST key.unlocked; }; TerminalIO.PutRope["TWOps loaded\n"]; END. hTWOpsImpl.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Christian Le Cocq, August 18, 1987 1:07:14 pm PDT Sends and retrieves files to a remote Unix host where TimberWolf is installed. PROC [id, wDir: ROPE, s: IO.STREAM] RETURNS [msg: ROPE] PROC [id, wDir: ROPE, s: IO.STREAM] RETURNS [msg: ROPE] Description of the procedure. Κe˜codešœ™Kšœ<™Kšœ œœ˜(Kšœ'˜'šœœœ˜šœœœ˜Kšœœ˜ Kšœœœ˜Jšœ  ˜J˜——K˜šΟnœ˜$Kš œ œœœœœ™7šœœœ ˜Kšœ œ ˜0Kšœ œ%˜5KšœB˜BKš œœœœ œ˜,Kšœ˜—K˜K™—šŸœ˜'Kš œ œœœœœ™7šœœœ˜Kšœ œ!˜1Kšœ œ&˜6KšœE˜EKš œœœœ œ˜,Kšœ˜—Kšœœ˜ K˜K™—šŸœœœœœœœœ˜TK™Kšœœ˜ Kšœ˜Kšœœ˜ Kšœœœœ>˜TKšœœS˜WKš œœœœœ˜7K˜K˜—šŸœœœœ˜-Kšœ"œœœ˜6Kšœœ ˜Kšœ%˜%K˜K˜—š Ÿ œœœ œœ˜8Kšœœœ˜Kšœ œœœ˜.Kšœ ˜K˜K˜—šΠbkœœ œ˜Kšœ œ!˜2Kšœœœœ˜Kšœ!˜!Kšœ˜Kšœ ˜ K˜K˜—šŸœœœ˜!Kšœœœ˜Kšœ œ˜Kš œ˜K˜K˜—K˜%—Kšœ˜—…— Н