DIRECTORY Ascii, BridgeDriver, BridgeExec, BridgeSubmit, CedarProcess, IO, Rope, SymTab, UserCredentials; BridgeSubmitImpl: CEDAR PROGRAM IMPORTS Ascii, BridgeExec, BridgeDriver, CedarProcess, Rope, SymTab, UserCredentials EXPORTS BridgeSubmit ~ BEGIN TransferProc: TYPE = BridgeSubmit.TransferProc; ROPE: TYPE = Rope.ROPE; magicString: ROPE _ "RBatch\n"; registationTable: SymTab.Ref _ SymTab.Create[]; Registration: TYPE = REF RegistrationRec; RegistrationRec: TYPE = RECORD [ session: BridgeExec.Session, s: IO.STREAM, id: ROPE, cmd: ROPE, wDir: ROPE, phase1, phase2: TransferProc, curPh: Phase ]; Phase: TYPE = {ph1, ph2, finished}; cmdName: ROPE _ "RFTP"; -- temporary until the Vax side is fixed phasePrompt: ARRAY Phase OF ROPE _ ["-h ", "-H ", "ERR"]; cmdPhase1: ROPE _ Rope.Cat[cmdName, " ", phasePrompt[ph1]]; cmdPhase2: ROPE _ Rope.Cat[cmdName, " ", phasePrompt[ph2]]; retrieveCmd: ROPE _ Rope.Concat[" ;", cmdPhase2]; Register: PUBLIC PROC [id, cmd, wDir: ROPE, phase1, phase2: TransferProc] RETURNS [msg: ROPE] ~ { reg: Registration _ NEW[RegistrationRec _ [ id: id, cmd: cmd, wDir: wDir, phase1: phase1, phase2: phase2, curPh: ph1 ]]; [] _ SymTab.Store[registationTable, id, reg]; msg _ ExecuteUnixShell[Rope.Cat[cmdPhase1, id]]; }; Create: BridgeExec.CreateProc ~ { found: BOOLEAN; val: SymTab.Val; reg: Registration; id: ROPE _ Rope.Substr[base: args, start: 3]; --bad dependance in RFTP -h [found, val] _ SymTab.Fetch[registationTable, id]; IF ~found THEN RETURN[NIL]; reg _ NARROW[val]; IF ~Rope.Equal[Rope.Substr[base: args, len: 2], Rope.Substr[base: phasePrompt[reg.curPh], len: 2]] THEN ERROR; reg.s _ s; reg.session _ session; [] _ CedarProcess.Fork[DoTransfer, reg]; RETURN [reg.id] --reg.id is Rope.Equal to id but not = }; Destroy: BridgeExec.DestroyProc ~ { found: BOOLEAN; val: SymTab.Val; reg: Registration; id: ROPE _ NARROW[instance]; [found, val] _ SymTab.Fetch[registationTable, id]; IF ~found THEN RETURN; reg _ NARROW[val]; IF reg.curPh=finished THEN [] _ SymTab.Delete[registationTable, id]; }; DoTransfer: CedarProcess.ForkableProc ~ { reg: Registration _ NARROW[data]; SELECT reg.curPh FROM ph1 => { msg: ROPE _ reg.phase1[reg.id, reg.wDir, reg.s]; IF msg=NIL THEN [] _ ExecuteUnixShell[Rope.Cat[reg.cmd, retrieveCmd, reg.id]]; reg.curPh _ ph2; }; ph2 => { [] _ reg.phase2[reg.id, reg.wDir, reg.s]; reg.curPh _ finished; }; ENDCASE => ERROR; BridgeExec.DestroyInstance[reg.session, reg.id, NIL]; }; ExecuteUnixShell: PUBLIC PROC [unixCmd: ROPE] RETURNS [errmsg: ROPE] ~ { completeCmd, name, password: ROPE; [name, password] _ UserCredentials.Get[]; name _ Rope.Substr[name, 0, Rope.Index[name, 0, "."]]; -- get rid of the ".pa" name _ Rope.Translate[base: name, translator: MyLower]; completeCmd _ Rope.Cat[magicString, unixCmd]; errmsg _ BridgeDriver.StartSession["vaxc", name, password, completeCmd]; }; MyLower: Rope.TranslatorType ~ {RETURN[Ascii.Lower[old]]}; BridgeExec.Register[cmdName, Create, NIL, Destroy]; END. NBridgeSubmitImpl.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Christian Le Cocq June 23, 1987 1:38:17 pm PDT PROC [s: NetworkStream, args: ROPE, session: Session, clientData: REF] RETURNS [Instance] PROC [instance: Instance, clientData: REF] PROC [data: REF] RETURNS [results: REF _ NIL] kill the instance ΚΎ˜šœ™Jšœ<™