-- NewSTPImpl.Mesa, last edit February 9, 1983 3:14 pm DIRECTORY ConvertUnsafe: TYPE USING[ToRope], Heap: TYPE USING[systemZone], NewSTP, Rope: TYPE USING[ROPE, Text], RopeInline: TYPE USING[InlineFlatten], Stream: TYPE USING[Handle, InputOptions], System: TYPE USING[GreenwichMeanTime], UnsafeSTP; NewSTPImpl: CEDAR PROGRAM IMPORTS ConvertUnsafe, Heap, RopeInline, UnsafeSTP EXPORTS NewSTP = { Create: PUBLIC PROC RETURNS [stp: NewSTP.Handle] = TRUSTED { stp _ NEW[NewSTP.Object _ [UnsafeSTP.Create[]]]; }; Destroy: PUBLIC PROC [stp: NewSTP.Handle] RETURNS [NewSTP.Handle] = TRUSTED { stp.stp _ UnsafeSTP.Destroy[stp.stp]; FREE[@stp]; RETURN[NIL]; }; Open: PUBLIC PROC [stp: NewSTP.Handle, host: Rope.ROPE] RETURNS [herald: Rope.ROPE] = TRUSTED { flathost: Rope.Text _ RopeInline.InlineFlatten[host]; h: LONG STRING _ UnsafeSTP.Open[stp.stp, LOOPHOLE[flathost]]; herald _ ConvertUnsafe.ToRope[h]; Heap.systemZone.FREE[@h]; }; Close: PUBLIC PROC [stp: NewSTP.Handle] = TRUSTED { UnsafeSTP.Close[stp.stp]; }; -- set credentials Login: PUBLIC PROC [stp: NewSTP.Handle, name, password: Rope.ROPE] = TRUSTED { flatname: Rope.Text _ RopeInline.InlineFlatten[name]; flatpass: Rope.Text _ RopeInline.InlineFlatten[password]; UnsafeSTP.Login[stp.stp, LOOPHOLE[flatname], LOOPHOLE[flatpass]]; }; Connect: PUBLIC PROC [stp: NewSTP.Handle, name, password: Rope.ROPE] = TRUSTED { flatname: Rope.Text _ RopeInline.InlineFlatten[name]; flatpass: Rope.Text _ RopeInline.InlineFlatten[password]; UnsafeSTP.Connect[stp.stp, LOOPHOLE[flatname], LOOPHOLE[flatpass]]; }; -- set various properties SetHost: PUBLIC PROC [stp: NewSTP.Handle, host: Rope.ROPE] = TRUSTED { flathost: Rope.Text _ RopeInline.InlineFlatten[host]; UnsafeSTP.SetHost[stp.stp, LOOPHOLE[flathost]]; }; SetDirectory: PUBLIC PROC [stp: NewSTP.Handle, directory: Rope.ROPE] = TRUSTED { flatdirectory: Rope.Text _ RopeInline.InlineFlatten[directory]; UnsafeSTP.SetDirectory[stp.stp, LOOPHOLE[flatdirectory]]; }; SetDesiredProperties: PUBLIC PROC [stp: NewSTP.Handle, props: NewSTP.DesiredProperties] = TRUSTED { UnsafeSTP.SetDesiredProperties[stp.stp, props]; }; -- query various properties IsOpen: PUBLIC PROC [stp: NewSTP.Handle] RETURNS [yes: BOOL] = TRUSTED { RETURN[UnsafeSTP.IsOpen[stp.stp]]; }; GetFileInfo: PUBLIC PROC [stp: NewSTP.Handle] RETURNS [fi: NewSTP.FileInfo] = TRUSTED { u: UnsafeSTP.FileInfo _ UnsafeSTP.GetFileInfo[stp.stp]; fi _ NEW[NewSTP.FileInfoObject]; fi.directory _ ConvertUnsafe.ToRope[u.directory]; fi.body _ ConvertUnsafe.ToRope[u.body]; fi.version _ ConvertUnsafe.ToRope[u.version]; fi.author _ ConvertUnsafe.ToRope[u.author]; fi.create _ ConvertUnsafe.ToRope[u.create]; fi.read _ ConvertUnsafe.ToRope[u.read]; fi.write _ ConvertUnsafe.ToRope[u.write]; fi.size _ u.size; fi.type _ u.type; }; GetProperty: PUBLIC PROC [stp: NewSTP.Handle, prop: NewSTP.ValidProperties] RETURNS [Rope.ROPE] = TRUSTED { s: LONG STRING _ UnsafeSTP.GetProperty[stp.stp, prop]; RETURN[ConvertUnsafe.ToRope[s]]; }; GetDesiredProperties: PUBLIC PROC [stp: NewSTP.Handle] RETURNS [props: NewSTP.DesiredProperties] = TRUSTED { RETURN[UnsafeSTP.GetDesiredProperties[stp.stp]]; }; -- retrieve, store, etc. CreateRemoteStream: PUBLIC PROC [ stp: NewSTP.Handle, file: Rope.ROPE, access: NewSTP.Access, fileType: NewSTP.Type, options: Stream.InputOptions, creation: System.GreenwichMeanTime] RETURNS[stream: Stream.Handle] = TRUSTED { flatfile: Rope.Text _ RopeInline.InlineFlatten[file]; RETURN[UnsafeSTP.CreateRemoteStream[stp.stp, LOOPHOLE[flatfile], access, fileType, options, creation]]; }; NextFileName: PUBLIC PROC [remoteStream: Stream.Handle] RETURNS [file: Rope.ROPE] = TRUSTED { s: LONG STRING _ UnsafeSTP.NextFileName[remoteStream]; file _ ConvertUnsafe.ToRope[s]; Heap.systemZone.FREE[@s]; }; Delete: PUBLIC PROC [ stp: NewSTP.Handle, name: Rope.ROPE, confirm: NewSTP.ConfirmProcType, complete: NewSTP.CompletionProcType] = TRUSTED { flatname: Rope.Text _ RopeInline.InlineFlatten[name]; UnsafeSTP.Delete[stp.stp, LOOPHOLE[flatname], confirm, complete]; }; Enumerate: PUBLIC PROC [stp: NewSTP.Handle, name: Rope.ROPE, proc: NewSTP.NoteFileProcType] = TRUSTED { flatname: Rope.Text _ RopeInline.InlineFlatten[name]; UnsafeSTP.Enumerate[stp.stp, LOOPHOLE[flatname], proc]; }; Rename: PUBLIC PROC [stp: NewSTP.Handle, old, new: Rope.ROPE] = TRUSTED { flatold: Rope.Text _ RopeInline.InlineFlatten[old]; flatnew: Rope.Text _ RopeInline.InlineFlatten[new]; UnsafeSTP.Rename[stp.stp, LOOPHOLE[flatold], LOOPHOLE[flatnew]]; }; Retrieve: PUBLIC PROC [ stp: NewSTP.Handle, file: Rope.ROPE, confirm: NewSTP.ConfirmProcType, complete: NewSTP.CompletionProcType] = TRUSTED { flatfile: Rope.Text _ RopeInline.InlineFlatten[file]; UnsafeSTP.Retrieve[stp.stp, LOOPHOLE[flatfile], confirm, complete]; }; Store: PUBLIC PROC [ stp: NewSTP.Handle, file: Rope.ROPE, stream: Stream.Handle, noteFile: NewSTP.NoteFileProcType, fileType: NewSTP.Type, creation: System.GreenwichMeanTime] = TRUSTED { flatfile: Rope.Text _ RopeInline.InlineFlatten[file]; UnsafeSTP.Store[stp.stp, LOOPHOLE[flatfile], stream, noteFile, fileType, creation]; }; }. "J))