Text preview for : Streams.mesa_Oct77.pdf part of xerox Streams.mesa Oct77 xerox mesa 3.0_1977 listing Streams.mesa_Oct77.pdf



Back to : Streams.mesa_Oct77.pdf | Home

streams.mesa 24-0CT-77 18:44:36 Page 1


-- Streams.Mesa Edited by Sandman on August 23, 1977 10:19 PM
DIRECTORY
AltoDefs: FROM "altodefs",
AltoFileDefs: FROM "altofiledefs",
BFSDefs: FROM "bfsdefs".
DiskDefs: FROM "diskdefs".
InlineDefs: FROM "inlinedefs",
MiscDefs: FROM "miscdefs".
SegmentDefs: FROM "segmentdefs",
StreamDefs: FROM "streamdefs".
SystemDefs: FROM "systemdefs";
DEFINITIONS FROM AltoDefs. AltoFileDefs, StreamDefs;
Streams: PROGRAM
IMPORTS BFSDefs, MiscD~fs, SegmentDefs, SystemDefs
EXPORTS StreamDefs SHARES StreamDefs, SegmentDefs = BEGIN
WindowSize: PageCount = 1;
StreamError: PUBLIC SIGNAL [stream:StreamHandle, error:StreamErrorCode] CODE;
NewByteStream: PUBLIC PROCEDURE [name: STRING, access:AccessOptions]
RETURNS [DiskHandle] =
BEGIN OPEN SegmentDefs;
RETURN[Create[NewFile[name, access, DefaultVersion],bytes,access]]
END;
NewWordStream: PUBLIC PROCEDURE [name: STRING, access:AccessOptions]
RETURNS [DiskHandle] =
BEGIN OPEN SegmentDefs;
RETURN[Create[NewFile[name, access, DefaultVersion],words,access]]
END:
CreateByteStream: PUBLIC PROCEDURE [file:SegmentDefs.FileHandle, access: AccessOptions]
RETURNS [DiskHandle] = BEGIN
RETURN[Create[file,bytes,access]]
END;
CreateWordStream: PUBLIC PROCEDURE [file:SegmentDefs.FileHandle, access: AccessOptions]
RETURNS [DiskHandle] = BEGIN
RETURN[Create[file,words,access]]
END;
Model: Disk StreamObject = StreamObject [
Reset, ReadByte, PutBack,
WriteByte, EndOf, Destroy,
Disk [
FALSE. FALSE, 1, 0, NIL, 0, 0,
Fixup, ReadError, Fixup, WriteByte,
NIL, FALSE, FALSE, FALSE, 0, 0, , ]];
Create: PROCEDURE [file:SegmentDefs.FileHandle, units:{bytes,words}, access; AccessOptions]
RETURNS [stream: DiskHa.ndle] =
BEGIN OPEN SegmentDefs:
fa: FA ~ FA[eofDA,O,O]:
IF access = OefaultAccess THEN access ~ Read:
SetFileAccess[file,access];
stream ~ SystemDefs.AllocateHeapNode[SIZE[Oisk StreamObject]]:
stream~ ~ Model; stream.file ~ file;
stream. read ~ Inl ineDefs .BITAND[access, Read]#O;
stream.write ~ InlineDefs.BTTAND[access.Write]#O;
stream. append .. Inl ineOefs.BTDNO[access,Append]#O;
stream. buffer ~ SystemOefs.AllocatePages[Windo~Size];
IF un its=words TIIEN
BrGIN OprN stream;
get ~ ReadWord; unit ~ 2;
put ~ savedPut ~ WriteWord;
rNO;
IF -stream.read TII[N stream. get ... ReadFrror;
SELrCT InllneDefs.BTTAND[access.Write+Append] FROM
o => stream.put ... str'eam.savedPut ... WriteEI'ror;
Write => stream.savedPut ... WriteError;
Append =) stream.put ~ WI'itefrror;
fNOCASE:
streams.mesa 24-0CT-77 18:44:36 Page 2


LockFile[file]; OpenFile[file];
stream.das[last] ~ stream.das[next] ~ fillinDAj
stream.das[current] ~ file.fp.leaderDA:
IF access = Append
THEN [] ~ FileLength[stream]
ELSE Jump[stream,@fa,l];
RETURN
END:
OpenDiskStream: PUBLIC PROCEDURE [stream:StreamHandle] =
BEGIN fa: FA:
WITH s:stream SELECT FROM
Di sk =)
BEGIN
IF s.buffer=NIL THEN s.buffer ~
SystemDefs.AllocatePages[WindowSize];
fa ~ FA[s.das[current],s.page,Pos[@s]]:
SegmentDefs.OpenFile[s.file]:
JumpToFA[@s,@fa];
END;
ENDCASE =) SIGNAL StreamError[@s,StreamType];
RETURN
END;
ClennupDiskStream: PUBLIC PROCEDURE [stream:StreamHandle] =
BEGIN
WITH s:stream SELECT FROM
Disk =) Cleanup[@s,TRUE];
ENDCASE =) SIGNAL StreamError[@s,StreamType];
RETURN
END;
Reset: PROCEDURE [stream:StreamHandle]
BEGIN fa: FA;
WITH s:stream SELECT FROM
Disk =)
IF s.page