Artifact 0662cc734acc82a0c314572e2628ed78c5e6469db244b20e65302f34d15707bc:
- File
psl-1983/3-1/kernel/open-close.red
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2427) [annotate] [blame] [check-ins using] [more...]
- File
psl-1983/kernel/open-close.red
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2427) [annotate] [blame] [check-ins using]
% % OPEN-CLOSE.RED - File primitives % % Author: Eric Benson % Symbolic Computation Group % Computer Science Dept. % University of Utah % Date: 27 August 1981 % Copyright (c) 1981 University of Utah % % Edit by Cris Perdue, 27 Jan 1983 1700-PST % Close now checks for a legitimate FileDes argument fluid '(SpecialReadFunction!* % These must be set up for special SpecialWriteFunction!* % Open call SpecialCloseFunction!*); on SysLisp; external WArray ReadFunction, % indexed by channel to read a char WriteFunction, % indexed by channel to write a char CloseFunction, % indexed by channel to close channel UnReadBuffer, % indexed by channel for input backup LinePosition, % indexed by channel for Posn() MaxLine; % when to force an end-of-line syslsp procedure Open(FileName, AccessType); %. Get access to file begin scalar FileDes; if AccessType eq 'INPUT then << FileDes := SystemOpenFileForInput FileName; UnReadBuffer[FileDes] := char NULL; WriteFunction[FileDes] := 'ReadOnlyChannel >> else if AccessType eq 'OUTPUT then << FileDes := SystemOpenFileForOutput FileName; LinePosition[FileDes] := 0; MaxLine[FileDes] := 80; ReadFunction[FileDes] := 'WriteOnlyChannel >> else if AccessType eq 'SPECIAL then if IDP LispVar SpecialReadFunction!* and IDP LispVar SpecialWriteFunction!* and IDP LispVar SpecialCloseFunction!* then << FileDes := SystemOpenFileSpecial FileName; LinePosition[FileDes] := 0; MaxLine[FileDes] := 80; UnReadBuffer[FileDes] := char NULL; ReadFunction[FileDes] := IdInf LispVar SpecialReadFunction!*; WriteFunction[FileDes] := IdInf LispVar SpecialWriteFunction!*; CloseFunction[FileDes] := IdInf LispVar SpecialCloseFunction!* >> else IOError "Improperly set-up special IO open call" else IOError "Unknown access type"; return MkINT FileDes; end; syslsp procedure Close FileDes; %. End access to file begin scalar BareFileDes; BareFileDes := IntInf FileDes; if not (0 <= BareFileDes and BareFileDes <= MaxChannels) then NonIOChannelError(FileDes, "Close"); IDApply1(BareFileDes, CloseFunction[BareFileDes]); SystemMarkAsClosedChannel FileDes; ReadFunction[BareFileDes] := 'ChannelNotOpen; WriteFunction[BareFileDes] := 'ChannelNotOpen; CloseFunction[BareFileDes] := 'ChannelNotOpen; return FileDes; end; off SysLisp; END;