(FILECREATED "14-Feb-85 01:21:02" {ERIS}<LISPCORE>SOURCES>AOFD.;10 26939 changes to: (FNS \BASEBYTES.READP \STRINGSTREAM.INIT) previous date: "15-Jan-85 18:01:22" {ERIS}<LISPCORE>SOURCES>AOFD.;9) (* Copyright (c) 1981, 1982, 1983, 1984, 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT AOFDCOMS) (RPAQQ AOFDCOMS [(* Open file descriptors. This file is shared with VAX.) (COMS (FNS CLOSEALL CLOSEF EOFCLOSEF INPUT OPENP OUTPUT POSITION RANDACCESSP \IOMODEP WHENCLOSE) (FNS STREAMADDPROP) (INITVARS (DEFAULTEOFCLOSE (QUOTE NILL)) (\OPENFILES)) (GLOBALVARS DEFAULTEOFCLOSE \OPENFILES)) (COMS (* STREAM interface to Read and Write to random memory) (DECLARE: DONTCOPY (EXPORT (RECORDS BASEBYTESTREAM))) (FNS \BASEBYTES.IO.INIT \MAKEBASEBYTESTREAM \MBS.OUTCHARFN \BASEBYTES.NAME.FROM.STREAM \BASEBYTES.BOUT \BASEBYTES.SETFILEPTR \BASEBYTES.READP \BASEBYTES.BIN \BASEBYTES.PEEKBIN \BASEBYTES.TRUNCATEFN \BASEBYTES.OPENFN \BASEBYTES.BLOCKIO) (GLOBALVARS \BASEBYTESDEVICE) (DECLARE: DONTEVAL@LOAD (P (\BASEBYTES.IO.INIT))) (FNS OPENSTRINGSTREAM)) [COMS (* STREAM interface for old-style strings) (FNS \STRINGSTREAM.INIT) (DECLARE: DONTEVAL@LOAD DOCOPY (P (\STRINGSTREAM.INIT] [COMS (FNS GETSTREAM \ADDOFD \CLEAROFD \DELETEOFD \GETSTREAM \RESETOFDS \SEARCHOPENFILES) (DECLARE: DONTCOPY (EXPORT (MACROS \INSTREAMARG \OUTSTREAMARG \STREAMARG))) (MACROS GETOFD \GETOFD) (DECLARE: DONTEVAL@LOAD (P (MOVD? (QUOTE GETSTREAM) (QUOTE GETOFD)) (MOVD? (QUOTE \GETSTREAM) (QUOTE \GETOFD] (LOCALVARS . T) (DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS (NLAMA) (NLAML) (LAMA WHENCLOSE]) (* Open file descriptors. This file is shared with VAX.) (DEFINEQ (CLOSEALL [LAMBDA (ALLFLG) (DECLARE (LOCALVARS . T)) (* lmm "18-Sep-84 11:54") (for STREAM in (PROG1 (APPEND \OPENFILES) (* Need to APPEND because CLOSEF will remove things from \OPENFILES) ) when [AND (fetch USERVISIBLE of STREAM) (\IOMODEP STREAM NIL T) (OR ALLFLG (NOT (STREAMPROP STREAM (QUOTE CLOSEALL] collect (CLOSEF STREAM]) (CLOSEF [LAMBDA (FILE) (* lmm " 2-Sep-84 15:51") (PROG ((STREAM (\GETSTREAM FILE))) (COND ((OR (\OUTTERMP STREAM) (NOT (fetch USERCLOSEABLE of STREAM))) (RETURN NIL))) [MAPC (STREAMPROP STREAM (QUOTE BEFORECLOSE)) (FUNCTION (LAMBDA (FN) (APPLY* FN STREAM] (\CLEAROFD) (COND ((EQ STREAM \PRIMIN.OFD) (SETQ \PRIMIN.OFD \LINEBUF.OFD))) (COND ((EQ STREAM \PRIMOUT.OFD) (SETQ \PRIMOUT.OFD \TERM.OFD))) (\DELETEOFD STREAM) (* Logical close before physical close; otherwise, we might have a logically open file with no physically open file behind it. (Device LPT depends on this)) (\CLOSEFILE STREAM) [MAPC (STREAMPROP STREAM (QUOTE AFTERCLOSE)) (FUNCTION (LAMBDA (FN) (APPLY* FN STREAM] (RETURN (fetch FULLNAME of STREAM]) (EOFCLOSEF [LAMBDA (FILE) (* bvm: "15-Jan-85 17:58") (DECLARE (LOCALVARS . T)) (PROG ((STREAM (GETSTREAM FILE))) (APPLY* (OR (STREAMPROP STREAM (QUOTE EOFCLOSE)) DEFAULTEOFCLOSE) STREAM]) (INPUT [LAMBDA (FILE) (* rmk: "14-OCT-83 15:30") (PROG1 (fetch FULLNAME of \PRIMIN.OFD) (COND (FILE (SETQ \PRIMIN.OFD (COND ((EQ FILE T) (* Check explicitly for T to avoid needless creations) \LINEBUF.OFD) (T (\GETSTREAM FILE (QUOTE INPUT]) (OPENP [LAMBDA (FILE ACCESS) (* rmk: "14-OCT-83 15:31") (DECLARE (GLOBALVARS \OPENFILES)) (for STREAM in \OPENFILES first [COND (FILE (RETURN (AND (SETQ STREAM (\GETSTREAM FILE ACCESS T)) (fetch FULLNAME of STREAM] when (AND (fetch USERVISIBLE of STREAM) (\IOMODEP STREAM ACCESS T)) collect (fetch FULLNAME of STREAM]) (OUTPUT [LAMBDA (FILE) (* rmk: "14-OCT-83 15:31") (PROG1 (fetch FULLNAME of \PRIMOUT.OFD) (COND (FILE (SETQ \PRIMOUT.OFD (COND ((EQ FILE T) (* Check for this special so we don't create a tty window needlessly) \TERM.OFD) (T (\GETSTREAM FILE (QUOTE OUTPUT]) (POSITION [LAMBDA (FILE N) (* rmk: "14-OCT-83 15:32") (PROG [(STRM (COND (FILE (\GETSTREAM FILE)) (T \PRIMOUT.OFD] (RETURN (PROG1 (fetch CHARPOSITION of STRM) (COND (N (replace CHARPOSITION of STRM with (COND ((IGREATERP N 0) N) (T (* compatible with PDP-10 version) 0]) (RANDACCESSP [LAMBDA (FILE) (* rmk: "14-OCT-83 15:32") (PROG ((STREAM (\GETSTREAM FILE))) (RETURN (AND (fetch RANDOMACCESSP of (fetch DEVICE of STREAM)) (NEQ STREAM \LINEBUF.OFD) (fetch FULLNAME of STREAM]) (\IOMODEP [LAMBDA (STREAM ACCESS NOERROR) (* rmk: "21-OCT-83 11:10") (* Returns STREAM if it represents a File open with access mode ACCESS) (COND ([COND ((NOT ACCESS) (fetch ACCESS of STREAM)) ((EQ ACCESS (fetch ACCESS of STREAM))) [(EQ (fetch ACCESS of STREAM) (QUOTE BOTH)) (FMEMB ACCESS (QUOTE (INPUT OUTPUT] ((EQ (fetch ACCESS of STREAM) (QUOTE APPEND)) (EQ ACCESS (QUOTE OUTPUT] STREAM) (T (\FILE.NOT.OPEN STREAM NOERROR]) (WHENCLOSE [LAMBDA NARGS (* lmm " 2-Sep-84 16:07") (DECLARE (LOCALVARS . T)) (PROG [(STREAM (AND (IGREATERP NARGS 0) (GETSTREAM (ARG NARGS 1] [for I FN from 2 to NARGS by 2 do [SETQ FN (AND (IGREATERP NARGS I) (ARG NARGS (ADD1 I] (SELECTQ (ARG NARGS I) [CLOSEALL (STREAMPROP STREAM (QUOTE CLOSEALL) (SELECTQ FN (NO T) (YES NIL) (ERRORX (LIST 27 FN] [BEFORE (COND (FN (STREAMADDPROP STREAM (QUOTE BEFORECLOSE) FN T] [AFTER (COND (FN (STREAMADDPROP STREAM (QUOTE AFTERCLOSE) FN T] (STATUS (STREAMPROP STREAM (QUOTE STATUSFN) FN)) (EOF (STREAMPROP STREAM (QUOTE EOFCLOSE) FN)) (ERRORX (LIST 27 (ARG NARGS I] (RETURN STREAM]) ) (DEFINEQ (STREAMADDPROP [LAMBDA (STREAM PROP VAL) (STREAMPROP STREAM PROP (CONS VAL (STREAMPROP STREAM PROP]) ) (RPAQ? DEFAULTEOFCLOSE (QUOTE NILL)) (RPAQ? \OPENFILES ) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS DEFAULTEOFCLOSE \OPENFILES) ) (* STREAM interface to Read and Write to random memory) (DECLARE: DONTCOPY (* FOLLOWING DEFINITIONS EXPORTED) [DECLARE: EVAL@COMPILE (RECORD BASEBYTESTREAM STREAM (SUBRECORD STREAM) [ACCESSFNS ((BIASOFFST (fetch (STREAM FW6) of DATUM) (replace (STREAM FW6) of DATUM with NEWVALUE)) (BBSNCHARS (fetch (STREAM FW7) of DATUM) (replace (STREAM FW7) of DATUM with NEWVALUE)) (WRITEXTENSIONFN (fetch (STREAM F1) of DATUM) (replace (STREAM F1) of DATUM with NEWVALUE]) ] (* END EXPORTED DEFINITIONS) ) (DEFINEQ (\BASEBYTES.IO.INIT (LAMBDA NIL (DECLARE (GLOBALVARS \BASECHARDEVICE)) (* JonL " 8-NOV-83 03:11") (SETQ \BASEBYTESDEVICE (create FDEV DEVICENAME ←(QUOTE BASEBYTES) RESETABLE ← T RANDOMACCESSP ← T PAGEMAPPED ← NIL FDBINABLE ← T FDBOUTABLE ← T FDEXTENDABLE ← NIL CLOSEFILE ←(FUNCTION NILL) DELETEFILE ←(FUNCTION NILL) DIRECTORYNAMEP ←(FUNCTION NILL) EVENTFN ←(FUNCTION NILL) GENERATEFILES ←(FUNCTION \GENERATENOFILES) GETFILEINFO ←(FUNCTION NILL) GETFILENAME ←(FUNCTION \BASEBYTES.NAME.FROM.STREAM) HOSTNAMEP ←(FUNCTION NILL) OPENFILE ←(FUNCTION \BASEBYTES.OPENFN) READPAGES ←(FUNCTION NILL) REOPENFILE ←(FUNCTION (LAMBDA (FILE ACCESS RECOG OTHERINFO FDEV STREAM) STREAM)) SETFILEINFO ←(FUNCTION NILL) TRUNCATEFILE ←(FUNCTION (LAMBDA (STREAM I))) WRITEPAGES ←(FUNCTION \ILLEGAL.DEVICEOP) BIN ←(FUNCTION \BASEBYTES.BIN) BOUT ←(FUNCTION \BASEBYTES.BOUT) PEEKBIN ←(FUNCTION \BASEBYTES.PEEKBIN) READP ←(FUNCTION \BASEBYTES.READP) BACKFILEPTR ←(FUNCTION (LAMBDA (STREAM) (AND (NEQ (fetch COFFSET of STREAM) (fetch BIASOFFST of STREAM)) (\PAGEDBACKFILEPTR STREAM)))) SETFILEPTR ←(FUNCTION \BASEBYTES.SETFILEPTR) GETFILEPTR ←(FUNCTION (LAMBDA (STREAM) (IDIFFERENCE (fetch COFFSET of STREAM) (fetch BIASOFFST of STREAM)))) GETEOFPTR ←(FUNCTION (LAMBDA (STREAM) (IDIFFERENCE (fetch EOFFSET of STREAM) (fetch BIASOFFST of STREAM)))) EOFP ←(FUNCTION (LAMBDA (STREAM) (IGEQ (fetch COFFSET of STREAM) (fetch EOFFSET of STREAM)))) BLOCKIN ←(FUNCTION (LAMBDA (STREAM BASE OFFST N) (\BASEBYTES.BLOCKIO STREAM BASE OFFST N (QUOTE INPUT)))) BLOCKOUT ←(FUNCTION (LAMBDA (STREAM BASE OFFST N) (\BASEBYTES.BLOCKIO STREAM BASE OFFST N (QUOTE OUTPUT)))) RENAMEFILE ←(FUNCTION \ILLEGAL.DEVICEOP))) (\DEFINEDEVICE NIL \BASEBYTESDEVICE))) (\MAKEBASEBYTESTREAM (LAMBDA (BASE OFFST LEN ACCESS WRITEXTENSIONFN OSTREAM) (* JonL " 7-NOV-83 23:50") (* If an error is to occur due to non-numeric arg or range restrictions, then let it happen outside the UNINTERRUPTABLY) (OR BASE (ERROR "Can't use NIL as a BASE")) (OR (AND (SMALLP OFFST) (SMALLP LEN) (SMALLP (add LEN OFFST))) (SHOULDNT "Currently can't support fixp-sized offsets")) (SELECTQ ACCESS (NIL (SETQ ACCESS (QUOTE INPUT))) ((INPUT OUTPUT BOTH)) (\ILLEGAL.ARG ACCESS)) (if (type? STREAM OSTREAM) then (if (EQ (ffetch (STREAM DEVICE) of OSTREAM) \BASEBYTESDEVICE) then (replace ACCESS of OSTREAM with NIL) else (CLOSEF OSTREAM) (SETQ OSTREAM (create BASEBYTESTREAM DEVICE ← \BASEBYTESDEVICE smashing OSTREAM))) else (SETQ OSTREAM (create BASEBYTESTREAM DEVICE ← \BASEBYTESDEVICE))) (UNINTERRUPTABLY (freplace USERCLOSEABLE of OSTREAM with NIL) (freplace USERVISIBLE of OSTREAM with NIL) (freplace BYTESIZE of OSTREAM with BITSPERBYTE) (freplace CPAGE of OSTREAM with (freplace EPAGE of OSTREAM with 0)) (freplace CPPTR of OSTREAM with BASE) (freplace COFFSET of OSTREAM with (freplace BIASOFFST of OSTREAM with OFFST)) (freplace CBUFSIZE of OSTREAM with (freplace EOFFSET of OSTREAM with LEN)) (replace ACCESS of OSTREAM with ACCESS) (* Insures that the BINABLE BOUTABLE and EXTENDABLE bits are setup setup, and that the correct BIN and BOUT fns are "inherited" from the FDEV as well) (freplace FULLFILENAME of OSTREAM with NIL) (freplace OUTCHARFN of OSTREAM with (FUNCTION \MBS.OUTCHARFN)) (freplace LINELENGTH of OSTREAM with 0) (freplace CHARPOSITION of OSTREAM with 0) (freplace WRITEXTENSIONFN of OSTREAM with (SELECTQ ACCESS ((OUTPUT BOTH) WRITEXTENSIONFN) NIL)) (freplace BBSNCHARS of OSTREAM with 0)) OSTREAM)) (\MBS.OUTCHARFN (LAMBDA (STREAM CHAR) (* JonL " 7-NOV-83 21:54") (BOUT (SETQ STREAM (\DTEST STREAM (QUOTE STREAM))) CHAR) (* The BBSNCHARS field *may* just be paralleling the CHARPOSITION field of the stream.) (add (ffetch BBSNCHARS of STREAM) 1))) (\BASEBYTES.NAME.FROM.STREAM (LAMBDA (STREAM) (* JonL " 7-NOV-83 21:38") (* STRING streams have a FULLFILENAME which is just the string itself; other random basebytes streams have this field null) (OR (fetch FULLFILENAME of STREAM) (LIST (fetch CPPTR of STREAM) (fetch BIASOFFST of STREAM) (GETEOFPTR STREAM))))) (\BASEBYTES.BOUT (LAMBDA (STREAM BYTE) (* JonL " 7-NOV-83 21:14") (PROG (CO) A (if (IGEQ (SETQ CO (fetch COFFSET of STREAM)) (fetch EOFFSET of STREAM)) then (if (SETQ CO (fetch (BASEBYTESTREAM WRITEXTENSIONFN) of STREAM)) then (APPLY* CO STREAM) (GO A) else (ERROR "Attempt to write past end of bytes block"))) (RETURN (\PUTBASEBYTE (fetch CPPTR of STREAM) (PROG1 CO (freplace COFFSET of STREAM with (ADD1 CO))) BYTE))))) (\BASEBYTES.SETFILEPTR (LAMBDA (STREAM I) (* JonL " 7-NOV-83 22:56") (PROG ((I' I)) (SELECTQ (SYSTEMTYPE) (VAX (if (fetch FULLFILENAME of STREAM) then (RETURN (replace F2 of STREAM with INDX)))) NIL) (add I'(fetch BIASOFFST of STREAM)) (if (IGREATERP I'(fetch EOFFSET of STREAM)) then (ERROR "Beyond end of byte range" I) else (replace COFFSET of STREAM with I'))))) (\BASEBYTES.READP [LAMBDA (STREAM FLG) (* bvm: "14-Feb-85 00:21") (PROG ((CO (fetch COFFSET of STREAM)) (#LEFT (fetch EOFFSET of STREAM))) (add #LEFT (IMINUS CO)) (RETURN (OR (IGEQ #LEFT 2) (if (EQ #LEFT 0) then NIL elseif FLG else (NEQ (\GETBASEBYTE (fetch CPPTR of STREAM) (fetch COFFSET of STREAM)) (CHARCODE CR]) (\BASEBYTES.BIN (LAMBDA (STREAM) (* JonL " 7-NOV-83 22:49") (* Normally, the microcoded version of BIN will handle this, since the BINABLE flag is set and since the COFFSET etc fields are setup appropriately) (* Remember also that the VAX version installs a different STRMBINFN for the stringstream case) (PROG1 (\BASEBYTES.PEEKBIN STREAM) (add (fetch COFFSET of STREAM) 1)))) (\BASEBYTES.PEEKBIN (LAMBDA (STREAM NOERRORFLG) (* JonL " 7-NOV-83 23:41") (PROG ((CO (fetch COFFSET of STREAM))) (SELECTQ (SYSTEMTYPE) (VAX (if (fetch FULLNAME of STREAM) then (* Aha, it's a string stream) (RETURN (\STRINGPEEKBIN STREAM NOERRORFLG)))) NIL) (RETURN (if (IGEQ CO (fetch EOFFSET of STREAM)) then (if (NOT NOERRORFLG) then (STREAMOP (QUOTE ENDOFSTREAMOP) STREAM STREAM)) else (\GETBASEBYTE (fetch CPPTR of STREAM) CO)))))) (\BASEBYTES.TRUNCATEFN (LAMBDA (STREAM I) (* JonL " 7-NOV-83 22:20") ((LAMBDA (I' BO EO) (add I' BO) (if (ILESSP I 0) then (add I' EO)) (if (OR (ILESSP I BO) (IGREATERP I' EO)) then (ERROR "Beyond end of byte range" I) else (replace EOFFSET of STREAM with I'))) I (fetch BIASOFFST of STREAM) (fetch EOFFSET of STREAM)))) (\BASEBYTES.OPENFN [LAMBDA (NAME ACCESS RECOG OTHERINFO FDEV) (* lmm "16-Aug-84 13:17") (if (fetch FULLFILENAME of NAME) then (OPENSTRINGSTREAM NAME ACCESS) else (\MAKEBASEBYTESTREAM (fetch CPPTR of NAME) (fetch BIASOFFST of NAME) (GETEOFPTR NAME) ACCESS (fetch WRITEXTENSIONFN of NAME) NAME]) (\BASEBYTES.BLOCKIO [LAMBDA (STREAM BASE OFFST N DIRECTION) (* JonL " 8-JUL-83 01:54") (PROG (SBASE CO EO) A (if (ILEQ N 0) then (RETURN)) (SETQ SBASE (fetch CPPTR of STREAM)) (SETQ CO (fetch COFFSET of STREAM)) (SETQ EO (fetch EOFFSET of STREAM)) (if (IGREATERP N (IDIFFERENCE EO (SUB1 CO))) then (if (EQ DIRECTION (QUOTE INPUT)) then (STREAMOP (QUOTE ENDOFSTREAMOP) STREAM STREAM) else (* Do a single BOUT to see if the WRITEXTENSIONFN will fix it up) (BOUT STREAM (\GETBASEBYTE BASE OFFST)) (add OFFST 1) (add N -1) (GO A))) (replace COFFSET of STREAM with (IPLUS CO N)) (if (EQ DIRECTION (QUOTE OUTPUT)) then (swap SBASE BASE) (swap CO OFFST)) (\MOVEBYTES SBASE CO BASE OFFST N]) ) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS \BASEBYTESDEVICE) ) (DECLARE: DONTEVAL@LOAD (\BASEBYTES.IO.INIT) ) (DEFINEQ (OPENSTRINGSTREAM [LAMBDA (STR ACCESS) (* rmk: "21-Mar-84 14:42") (* Does not register the stream on \OPENFILES, nor does it search \OPENFILES for a previously opened stream. Thus, this implementation does not side-effect the string as the 10 does. However, the temporary coercion of strings to open streams in \GETSTREAM does simulate the side-effecting. Note that a string stream is unnamed.) (PROG (STREAM) (OR (STRINGP STR) (\ILLEGAL.ARG STR)) [SETQ STREAM (\MAKEBASEBYTESTREAM (OR (fetch (STRINGP BASE) of STR) T) (fetch (STRINGP OFFST) of STR) (fetch (STRINGP LENGTH) of STR) (SELECTQ ACCESS ((INPUT OUTPUT BOTH) ACCESS) (NIL (QUOTE INPUT)) (\ILLEGAL.ARG ACCESS] (PROGN (* Minor differences between a basebytestream and a stringstream) (freplace USERCLOSEABLE of STREAM with T) (freplace USERVISIBLE of STREAM with T) (SELECTQ (SYSTEMTYPE) (VAX (freplace F2 of STREAM with 0) (freplace STRMBINFN of STREAM with (FUNCTION \STRINGBIN))) NIL)) (RETURN STREAM]) ) (* STREAM interface for old-style strings) (DEFINEQ (\STRINGSTREAM.INIT [LAMBDA NIL (* bvm: "14-Feb-85 00:25") (SETQ \STRINGSTREAM.FDEV (create FDEV DEVICENAME ←(QUOTE STRING) CLOSEFILE ←(FUNCTION NILL) DELETEFILE ←(FUNCTION NILL) DIRECTORYNAMEP ←(FUNCTION NILL) EVENTFN ←(FUNCTION NILL) GENERATEFILES ←(FUNCTION \NULLFILEGENERATOR) GETFILEINFO ←(FUNCTION NILL) GETFILENAME ←(FUNCTION NILL) HOSTNAMEP ←(FUNCTION NILL) OPENFILE ←(FUNCTION NILL) READPAGES ←(FUNCTION \ILLEGAL.DEVICEOP) REOPENFILE ←(FUNCTION [LAMBDA (FILE ACCESS RECOG OTHERINFO FDEV STREAM) STREAM]) SETFILEINFO ←(FUNCTION NILL) TRUNCATEFILE ←(FUNCTION NILL) WRITEPAGES ←(FUNCTION \ILLEGAL.DEVICEOP) BIN ←[FUNCTION (LAMBDA (STREAM) (replace F2 of STREAM with (COND ((fetch F1 of STREAM) (PROG1 (fetch F1 of STREAM) (replace F1 of STREAM with NIL))) ((GNCCODE (fetch FULLFILENAME of STREAM))) (T (\EOF.ACTION STREAM] PEEKBIN ←[FUNCTION (LAMBDA (STREAM NOERRORFLG) (OR (fetch F1 of STREAM) (CHCON1 (fetch FULLFILENAME of STREAM)) (AND (NOT NOERRORFLG) (\EOF.ACTION STREAM] READP ←[FUNCTION (LAMBDA (STREAM) (NOT (EOFP STREAM] BACKFILEPTR ←[FUNCTION (LAMBDA (STREAM) (replace F1 of STREAM with (fetch F2 of STREAM] EOFP ←(FUNCTION (LAMBDA (STREAM) (AND (NOT (fetch F1 of STREAM)) (EQ (NCHARS (fetch FULLFILENAME of STREAM)) 0]) ) (DECLARE: DONTEVAL@LOAD DOCOPY (\STRINGSTREAM.INIT) ) (DEFINEQ (GETSTREAM [LAMBDA (FILE ACCESS) (* rmk: "14-OCT-83 15:27") (* USER ENTRY) (\GETSTREAM FILE ACCESS]) (\ADDOFD [LAMBDA (STREAM) (* rmk: "21-OCT-83 16:32") (* Returns the STREAM it adds to \OPENFILES) (\CLEAROFD) (AND (fetch NAMEDP of STREAM) (push \OPENFILES STREAM)) STREAM]) (\CLEAROFD [LAMBDA NIL (* lmm "30-SEP-80 20:08") (* IF GETOFD CACHES ITS ARGS, THIS CAN CLEAR THE CACHE) ]) (\DELETEOFD [LAMBDA (OFD) (* rmk: "25-OCT-79 08:20") (SETQ \OPENFILES (DREMOVE OFD \OPENFILES]) (\GETSTREAM [LAMBDA (X ACCESS NOERROR) (* lmm "24-Sep-84 17:20") (* \GETSTREAM accepts either a: file name, a file handle, stream, a string, NIL, T, or a partial file name. - ACCESS is INPUT, OUTPUT, APPEND, BOTH or NIL - NOERROR, if non-NIL, means to return NIL if the file is not open in the specified access mode; otherwise, an error is caused) (DECLARE (GLOBALVARS \DEFAULTLINEBUF \DEFAULTTTYDISPLAYSTREAM)) (COND ((NULL X) (SELECTQ ACCESS (INPUT (COND ((EQ \PRIMIN.OFD \DEFAULTLINEBUF) (\CREATE.TTYDISPLAYSTREAM))) \PRIMIN.OFD) (OUTPUT (COND ((AND \DEFAULTTTYDISPLAYSTREAM (EQ \PRIMOUT.OFD \DEFAULTTTYDISPLAYSTREAM)) (\CREATE.TTYDISPLAYSTREAM))) \PRIMOUT.OFD) (\IOMODEP (COND ((NOT (EQ \PRIMIN.OFD \LINEBUF.OFD)) \PRIMIN.OFD) (T \PRIMOUT.OFD)) ACCESS NOERROR))) ((EQ X T) (SELECTQ ACCESS (INPUT (COND ((EQ \LINEBUF.OFD \DEFAULTLINEBUF) (\CREATE.TTYDISPLAYSTREAM))) \LINEBUF.OFD) ((OUTPUT NIL) (COND ((AND \DEFAULTTTYDISPLAYSTREAM (EQ \TERM.OFD \DEFAULTTTYDISPLAYSTREAM)) (\CREATE.TTYDISPLAYSTREAM))) \TERM.OFD) (\FILE.NOT.OPEN X NOERROR))) ((type? STREAM X) (\IOMODEP X ACCESS NOERROR)) ((LITATOM X) (OR (\SEARCHOPENFILES X ACCESS) (\SEARCHOPENFILES (\GETFILENAME X (QUOTE OLD)) ACCESS) (\FILE.NOT.OPEN X NOERROR))) ((STRINGP X) (SELECTQ ACCESS ((NIL INPUT) NIL) (\FILE.NOT.OPEN X NOERROR)) (\SETACCESS (SETQ X (create STREAM DEVICE ← \STRINGSTREAM.FDEV FULLFILENAME ← X)) (QUOTE INPUT)) X) ((type? WINDOW X) (fetch (WINDOW DSP) of X)) (T (\FILE.NOT.OPEN X NOERROR]) (\RESETOFDS [LAMBDA NIL (* rrb "22-JUL-83 15:51") (DECLARE (GLOBALVARS \OPENFILES)) [MAP.PROCESSES (FUNCTION (LAMBDA NIL (\OPENLINEBUF) (SETQ \PRIMOUT.OFD \TERM.OFD) (SETQ \PRIMIN.OFD \LINEBUF.OFD) (SETQ \DRIBBLE.OFD] (for OFD in \OPENFILES do (replace CPPTR of OFD with NIL) (FORGETPAGES OFD) (replace ACCESS of OFD with NIL)) (* Perhaps do the AFTER function ?) (SETQ \OPENFILES]) (\SEARCHOPENFILES [LAMBDA (NAME ACCESS) (* rmk: "14-OCT-83 15:04") (* Returns a stream whose fullname is NAME if it has accessmode ACCESS) (for STREAM in \OPENFILES when (EQ NAME (fetch FULLNAME of STREAM)) do (RETURN (COND (ACCESS (\IOMODEP STREAM ACCESS T)) (T STREAM]) ) (DECLARE: DONTCOPY (* FOLLOWING DEFINITIONS EXPORTED) (DECLARE: EVAL@COMPILE (PUTPROPS \INSTREAMARG MACRO ((STRM NOERRORFLG) (\GETSTREAM STRM (QUOTE INPUT) NOERRORFLG))) (PUTPROPS \OUTSTREAMARG MACRO ((STRM NOERRORFLG) (\GETSTREAM STRM (QUOTE OUTPUT) NOERRORFLG))) (PUTPROPS \STREAMARG MACRO [OPENLAMBDA (STRM NOERRORFLG) (COND (NOERRORFLG (\GETSTREAM STRM NIL T)) (T (\DTEST STRM (QUOTE STREAM]) ) (* END EXPORTED DEFINITIONS) ) (DECLARE: EVAL@COMPILE (PUTPROPS GETOFD MACRO (= . GETSTREAM)) (PUTPROPS \GETOFD MACRO (= . \GETSTREAM)) ) (DECLARE: DONTEVAL@LOAD (MOVD? (QUOTE GETSTREAM) (QUOTE GETOFD)) (MOVD? (QUOTE \GETSTREAM) (QUOTE \GETOFD)) ) (DECLARE: DOEVAL@COMPILE DONTCOPY (LOCALVARS) ) (DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDTOVAR NLAMA ) (ADDTOVAR NLAML ) (ADDTOVAR LAMA WHENCLOSE) ) (PUTPROPS AOFD COPYRIGHT ("Xerox Corporation" 1981 1982 1983 1984 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (1950 7336 (CLOSEALL 1960 . 2470) (CLOSEF 2472 . 3444) (EOFCLOSEF 3446 . 3749) (INPUT 3751 . 4122) (OPENP 4124 . 4588) (OUTPUT 4590 . 4994) (POSITION 4996 . 5491) (RANDACCESSP 5493 . 5813) (\IOMODEP 5815 . 6458) (WHENCLOSE 6460 . 7334)) (7337 7459 (STREAMADDPROP 7347 . 7457)) (8251 18437 ( \BASEBYTES.IO.INIT 8261 . 10461) (\MAKEBASEBYTESTREAM 10463 . 12764) (\MBS.OUTCHARFN 12766 . 13152) ( \BASEBYTES.NAME.FROM.STREAM 13154 . 13660) (\BASEBYTES.BOUT 13662 . 14260) (\BASEBYTES.SETFILEPTR 14262 . 14813) (\BASEBYTES.READP 14815 . 15326) (\BASEBYTES.BIN 15328 . 15888) (\BASEBYTES.PEEKBIN 15890 . 16551) (\BASEBYTES.TRUNCATEFN 16553 . 17019) (\BASEBYTES.OPENFN 17021 . 17423) ( \BASEBYTES.BLOCKIO 17425 . 18435)) (18553 19912 (OPENSTRINGSTREAM 18563 . 19910)) (19964 21854 ( \STRINGSTREAM.INIT 19974 . 21852)) (21910 25870 (GETSTREAM 21920 . 22140) (\ADDOFD 22142 . 22463) ( \CLEAROFD 22465 . 22698) (\DELETEOFD 22700 . 22854) (\GETSTREAM 22856 . 24848) (\RESETOFDS 24850 . 25415) (\SEARCHOPENFILES 25417 . 25868))))) STOP