Trailing-Edge
-
PDP-10 Archives
-
bb-h138f-bm
-
7-sources/fileio.bli
There are 12 other files named fileio.bli in the archive. Click here to see a list.
%TITLE 'IO - Central file I/O module'
MODULE FILEIO ( ! Central file I/O routine for EDT
IDENT = '3-009' ! File: FILEIO.BLI Edit: GB3009
) =
BEGIN
!COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1981, 1988. ALL RIGHTS RESERVED.
!
!THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY
!IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION OF
!THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY
!NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. NO TITLE
!TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
!
!THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
!SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
!
!DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
!SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.
!
!
!++
! FACILITY: EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
! This is the central file i/o routine used by EDT.
!
! ENVIRONMENT: Runs in user mode on VAX/VMS & TOPS and non-privileged PDP-11
!
! AUTHOR: Shelly T. Solomon, CREATION DATE: 07-Dec-1981
!
! MODIFIED BY:
!
! 1-001 - Original. STS 25-Dec-1981
! 1-002 - Change module name to EDT$FILEIO. STS 25-Dec-1981
! 1-003 - Add calls for include file. STS 26-Dec-1981
! 1-004 - Add require files for 11 translations. STS 28-Dec-1981
! 1-005 - Add linkage attribute to routine. STS 30-Dec-1981
! 1-006 - Signal any errors. STS 06-Jan-1982
! 1-007 - Add code for opening output file. STS 13-Jan-1982
! 1-008 - Fix DSC$A_POINTER macro STS 14-Jan-1982
! 1-009 - Add gets and puts STS 15-Jan-1982
! 1-010 - Change opening journal file to open in-out. STS 18-Jan-1982
! 1-011 - Fixed undefined symbol EDT$$opn_inout on 11. STS 19-Jan-1982
! 1-012 - output filenames with error messages. STS 19-Jan-1982
! 1-013 - Change the defaulting of the journal file name. STS 21-Jan-1982
! 1-014 - Add check to see if file is VFC format. STS 22-Jan-1982
! 1-015 - fix journal file name for 11's. STS 26-Jan-1982
! 1-016 - Add dot to sequence parameter passed with journal file.
! STS 28-Jan-1982
! 1-017 - Pass RHB info down to 11 i/o routines. STS 02-Feb-1982
! 1-018 - Take out extra dot in get on 11's, also
! fix include rab. STS 08-Feb-1982
! 1-019 - add flush for journal buffer. STS 11-Feb-1982
! 1-020 - Take out call to edt$$get_fnam. STS 12-Feb-1982
! 1-021 - Pass cler. STS 26-Feb-1982
! 1-022 - Add literals for callable parameters. STS 08-Mar-1982
! 1-023 - Fix status passed on opening write file. STS 10-Mar-1982
! 1-024 - Rearrange interface to EDT$IOMOD to improve the rationality
! of file naming. JBS 25-Mar-1982
! 1-025 - Worry about non-standard input files. JBS 26-Mar-1982
! 1-026 - Correct a typo. JBS 27-Mar-1982
! 1-027 - Make the new file handling logic work on the PDP-11. JBS 29-Mar-1982
! 1-028 - Use temporary file for WRITE and EXIT and then Rename it. SMB 31-Mar-1982
! 1-029 - Add related file names for the PDP-11. JBS 31-Mar-1982
! 1-030 - Distinguish two cases of output open for journal files on the PDP11
! and add a flush counter to improve PDP-11 performance. JBS 01-Apr-1982
! 1-031 - Rearrange file name handling for the journal file. JBS 02-Apr-1982
! 1-032 - Make more modifications for WRITE/EXIT to temp files. SMB 02-Apr-1982
! 1-033 - Cannot use %REF in STRING_DESC. JBS 03-Apr-1982
! 1-034 - Fix bugs in PDP-11 opening of output files. SMB 06-Apr-1982
! 1-035 - Add rename for PDP-11's and CLOSE_DEL for output files. SMB 08-Apr-1982
! 1-036 - Convert PDP-11 filenames to uppercase. SMB 12-Apr-1982
! 1-037 - Take out fix 1-036(move to LWRITE)-fix error message filename for VAX. SMB 13-Apr-1982
! 1-038 - Always return status when closing PDP-11 files. JBS 09-Apr-1982
! 1-039 - Reverse the attributes flag. JBS 12-Apr-1982
! 1-040 - Merge the last four edits, which were done independently. JBS 15-Apr-1982
! 1-041 - Add a parse before opening output files. SMB 15-Apr-1982
! 1-042 - Put back line accidently deleted for filename storage. SMB 16-Apr-1982
! 1-043 - Conditionalize the conversion to uppercase. SMB 22-Apr-1982
! 1-044 - Restrict renaming to disks or DECtapes only. SMB 26-Apr-1982
! 1-045 - Change the ordinals of global literals for file types. SMB 19-May-1982
! 1-046 - Add some comments. STS 19-May-1982
! 1-047 - Clean up the magic numbers. JBS 25-May-1982
! 1-048 - Don't use special linkage on 11's. STS 03-Jun-1982
! 1-049 - On OPEN, use RHB as the default name. Also, don't use special linkages on
! VAX either, since the special linkage used by CALLFIO is compatible with
! the standard VAX/VMS linkage conventions. JBS 15-Jun-1982
! 1-050 - Implement the new file defaulting rules. JBS 17-Jun-1982
! 1-051 - Signal any bad status from flushing the journal file. STS 30-Jun-1982
! 1-052 - Fix bad parameter pass in open for output without related names. SMB 06-Jul-1982
! 1-053 - Add a special check for RSTS disk files. SMB 07-Jul-1982
! 1-054 - Store status on PDP-11 open for output. SMB 19-Jul-1982
! 3-001 - Add support for TOPS20 in conditionals. GB 20-Jan-1983
! 3-002 - Move declaration of OPN_INOUT out of BLISS32 conditionals. GB 20-Jan-1983
! 3-003 - Simplify for TOPS-20. CJG 19-Apr-1983
! 3-004 - Change the way that filespecs are handled. CJG 22-Jun-1983
! 3-005 - Fix bad handling of file descriptor when an output file has been
! specified as part of the CREATE command. CJG 12-Oct-1983
! 3-006 - Fix loss of output file generation number. CJG 9-Dec-1983
! 3-007 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
! 3-008 - Clean up error handling. GB 6-Aug-1984
! 3-009 - Change temporary file type to .EDTTMP to allow .TMP files
! to be editted
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
REQUIRE 'SYS:JSYS';
FORWARD ROUTINE
EDT$FILEIO;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
!+
! Macro for the file type used as a constant. This is defined as a macro
! so we can use %CHARCOUNT to pass the length of the string.
!-
!<BLF/NOFORMAT>
MACRO
TEMP_TYPE = 'EDTTMP' %; ! File type for temporary output files (before being renamed)
!<BLF/FORMAT>
!
! EQUATED SYMBOLS:
!
!+
! These codes need to be defined here because they need to be known at compile
! time in order to be used in case statements
!-
GLOBAL LITERAL
EDT$K_OPEN_INPUT = 1, ! code signifying we wish to open a file for input
EDT$K_OPEN_OUTPUT_SEQ = 2, ! code signifying we wish to open a sequenced file for output
EDT$K_OPEN_OUTPUT_NOSEQ = 3, ! code meaning we wish to open a non-sequenced file for output
EDT$K_OPEN_IN_OUT = 4, ! we wish to open a file for both input and output
EDT$K_GET = 5, ! code signifying we want to get a record from a file
EDT$K_PUT = 6, ! code signifying we want to put a record to a file
EDT$K_CLOSE_DEL = 7, ! we want to close the file and then delete it
EDT$K_CLOSE = 8, ! we want to close the file
EDT$K_COMMAND_FILE = 1, ! code for the startup command file
EDT$K_INPUT_FILE = 2, ! code for the main input file
EDT$K_INCLUDE_FILE = 3, ! code for an include file
EDT$K_JOURNAL_FILE = 4, ! code for the journal file
EDT$K_OUTPUT_FILE = 5, ! code for the output file
EDT$K_WRITE_FILE = 6; ! code for an output file being written
LITERAL
FLUSH_LIMIT = 5; ! Flush the journal file buffer after this many records
!+
! The following symbols are for the interface to EDT$$OPN_OFIDEF. Note that these values
! are hard-coded into the MACRO-11 modules, and into EDT$IOMOD.
!-
LITERAL
DISK_FILE_NO = 0, ! Not a disk file
DISK_FILE_YES = 1, ! Is a disk file
DISK_FILE_RSTS = 2, ! Is a disk file on RSTS
SEQ_NO = 0, ! The file is not to be sequenced
SEQ_YES = 1, ! The file is to be sequenced
RELAT_NONE = 0, ! There is no related file name
RELAT_INPUT = 1, ! The primary input file is used as the related file
ATTR_INPUT = 0, ! Take file attributes from the primary input file
ATTR_DEFAULT = 1, ! Use EDT's default file attributes
ATTR_JOURNAL = 2; ! Use journal file attributes
!
! OWN STORAGE:
!
! in the routine
!
! EXTERNAL REFERENCES:
!
! in the routine
!
%SBTTL 'FILEIO - Central EDT file routine'
GLOBAL ROUTINE EDT$FILEIO ( !
FILECODE, !
FILESTRM, !
FILE_REC !
) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This is the basic file i/o routine for EDT. Callable EDT calls this
! routine to do any i/o if this is the routine passed to it by the calling
! program. This is the routine passed to callable EDT by the "real" EDT.
!
! FORMAL PARAMETERS:
!
! filecode = address of fullword containing function code defining type of i/o
! operation to be performed
! filestream = address of fullword containing stream identifier
! file_rec = address of string descriptor, i.e. the file name or place to store
! record read or place to fetch record to be written
!
!
! Note: the default name is not implemented for WRITE/EXIT/PRINT files
! (because of .TMP logic). Fortunately, EDT does not pass a default
! name on these channels.
!
! IMPLICIT INPUTS:
!
! INP_NAM
! OUT_NAM
! CMD_NAM
! JOU_NAM
! INC_NAM
! WRT_NAM
!
!
! IMPLICIT OUTPUTS:
!
!
! COMPLETION STATUS:
!
! The only error returned, rather than signaled, is EOF.
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
MAP
FILE_REC : REF BLOCK;
EXTERNAL ROUTINE
EDT$$PAR_FNAME, ! parse a file name
EDT$$CNV_UPC, ! convert to uppercase
EDT$$REN_FI, ! renames a file
EDT$$FLUSH_OBUF, ! empties journal buffer
EDT$$OPN_IFIDEF, ! i/o input open file routine
EDT$$OPN_INOUT, ! i/o input & output file routine
EDT$$OPN_OFIDEF, ! i/o open output file routine
EDT$$CLS_FI : NOVALUE, ! i/o close file routine
EDT$$RD_IFI, ! read a record from a file stream
EDT$$WR_OFI; ! Write a record to a file stream
EXTERNAL
INP_NAM : BLOCK, ! Input filespec
OUT_NAM : BLOCK, ! Output filespec
CMD_NAM : BLOCK, ! Command filespec
JOU_NAM : BLOCK, ! Journal filespec
WRT_NAM : BLOCK, ! Write filespec
INC_NAM : BLOCK, ! Include filespec
ERR_NUMBER, ! Last TOPS20 error code
IO_FNAM, ! File name at last error
IOFI_NFND;
MESSAGES ((INPFILOPN, FILNAM, INTERERR, COMFILNEX, COMFILNOP, NOJNLFIL, INPFILNEX, OUTFILCRE));
OWN
TEMP_DESC : BLOCK [6] ! Temporary file
PRESET ( [DSC$A_POINTER] = 0,
[DSC$W_JFN] = 0),
DISK_FI, ! flag indicating opening a renameable file for output
FLUSH_COUNTER : INITIAL (0); ! counts PUTs to journal towards flushing the buffer
LOCAL
DESC_ADDR : REF BLOCK,
IO_STS,
STATUS;
BIND
FILE_DESC = .FILE_REC : BLOCK; ! passed in descriptor for filename or record in or out
IOFI_NFND = 0;
!+
! Point to the correct file descriptor block for the operation.
!-
DESC_ADDR = (CASE .FILESTRM FROM EDT$K_COMMAND_FILE TO EDT$K_WRITE_FILE OF
SET
[EDT$K_COMMAND_FILE] : CMD_NAM;
[EDT$K_INPUT_FILE] : INP_NAM;
[EDT$K_INCLUDE_FILE] : INC_NAM;
[EDT$K_OUTPUT_FILE] : OUT_NAM;
[EDT$K_WRITE_FILE] : WRT_NAM;
[EDT$K_JOURNAL_FILE] : JOU_NAM;
[INRANGE, OUTRANGE] : 0;
TES);
ASSERT (9, .DESC_ADDR NEQ 0);
!+
! Find out first what kind of operation is requested
!-
CASE .FILECODE FROM EDT$K_OPEN_INPUT TO EDT$K_CLOSE OF
SET
!+
! Open a file for input
!-
[EDT$K_OPEN_INPUT] : ! we want to open a file
BEGIN
STATUS = EDT$$OPN_IFIDEF (.DESC_ADDR, IO_STS);
ERR_NUMBER = .IO_STS;
IO_FNAM = .DESC_ADDR;
IF (.STATUS EQL 0) THEN RETURN (0) ELSE RETURN (1);
END;
!+
! Open a file for output
!-
[EDT$K_OPEN_OUTPUT_SEQ, EDT$K_OPEN_OUTPUT_NOSEQ] :
BEGIN
CASE .FILESTRM FROM EDT$K_JOURNAL_FILE TO EDT$K_WRITE_FILE OF
SET
[EDT$K_OUTPUT_FILE, EDT$K_WRITE_FILE] : ! WRITE or OUTPUT file
BEGIN
DISK_FI = 0;
!+
! Parse the output file name - If successful, then do the open; otherwise
! setup error number
!-
STATUS = EDT$$PAR_FNAME (.DESC_ADDR, DISK_FI, IO_STS);
IF ( NOT .STATUS)
THEN
BEGIN
ERR_NUMBER = .STATUS;
IO_FNAM = .DESC_ADDR;
RETURN (0);
END
ELSE
BEGIN
TEMP_DESC [DSC$L_DESC] = .DESC_ADDR [DSC$L_DESC];
!+
! Save description of output file before translation with .TMP extension
! if this is a disk file for rename later
!-
IF (.DISK_FI)
THEN
BEGIN
TEMP_DESC [DSC$A_DEVICE] = .DESC_ADDR [DSC$A_DEVICE];
TEMP_DESC [DSC$A_DIRECT] = .DESC_ADDR [DSC$A_DIRECT];
TEMP_DESC [DSC$A_FNAME] = .DESC_ADDR [DSC$A_FNAME];
TEMP_DESC [DSC$A_FEXTN] = .DESC_ADDR [DSC$A_FEXTN];
TEMP_DESC [DSC$W_JFN] = .DESC_ADDR [DSC$W_JFN];
DESC_ADDR [DSC$A_FEXTN] = CH$PTR (UPLIT (%ASCIZ TEMP_TYPE),, BYTE_SIZE);
DESC_ADDR [DSC$W_JFN] = 0;
DESC_ADDR [DSC$L_DESC] = 0;
END
ELSE
TEMP_DESC [DSC$L_DESC] = 0;
!+
! If this is a disk file, open a temporary file for output, then rename later
! if all goes well. If not a disk file, just open the "given" file.
!-
STATUS = EDT$$OPN_OFIDEF (.DESC_ADDR, IO_STS);
!+
! Report an error
!-
IF (.STATUS EQL 0)
THEN
BEGIN
ERR_NUMBER = .IO_STS;
IO_FNAM = .DESC_ADDR;
RETURN (0);
END;
END;
RETURN (1);
END;
[EDT$K_JOURNAL_FILE] :
BEGIN
STATUS = EDT$$OPN_OFIDEF (JOU_NAM, IO_STS);
ERR_NUMBER = .IO_STS;
IO_FNAM = JOU_NAM;
IF (.STATUS EQL 0) THEN RETURN (0) ELSE RETURN (1);
END;
[INRANGE, OUTRANGE] :
ASSERT (9, 0);
TES;
END;
!+
! Open a file for both input and output
!-
[EDT$K_OPEN_IN_OUT] :
BEGIN
!+
! The journal file is the only file we can open this way
!-
IF (.FILESTRM EQL EDT$K_JOURNAL_FILE)
THEN
BEGIN
STATUS = EDT$$OPN_INOUT (JOU_NAM, IO_STS);
ERR_NUMBER = .IO_STS;
IO_FNAM = JOU_NAM;
IF (.STATUS EQL 0) THEN RETURN (0) ELSE RETURN (1);
END
ELSE
ASSERT (9, 0);
END;
[EDT$K_GET] : ! We wish to get a record from a file
BEGIN
STATUS = EDT$$RD_IFI (.DESC_ADDR, FILE_DESC, IO_STS);
IF (NOT .STATUS)
THEN
IF (.IO_STS AND GS_EOF) NEQ 0
THEN
RETURN (0)
ELSE
BEGIN
_GETER ($FHSLF; ERR_NUMBER);
IO_FNAM = .DESC_ADDR;
RETURN (-1);
END;
RETURN (.STATUS);
END;
[EDT$K_PUT] : ! we wish to put a record to a file
BEGIN
STATUS = EDT$$WR_OFI (.DESC_ADDR, FILE_DESC, IO_STS);
IF ( NOT .STATUS)
THEN
BEGIN
_GETER ($FHSLF; ERR_NUMBER);
IO_FNAM = .DESC_ADDR;
END
ELSE
IF (.FILESTRM EQL EDT$K_JOURNAL_FILE)
THEN ! keep the journal buffer clear
BEGIN
FLUSH_COUNTER = .FLUSH_COUNTER + 1;
IF (.FLUSH_COUNTER EQL FLUSH_LIMIT)
THEN
BEGIN
STATUS = EDT$$FLUSH_OBUF (JOU_NAM);
FLUSH_COUNTER = 0;
END;
END;
RETURN (.STATUS);
END;
[EDT$K_CLOSE] : ! close a file
BEGIN
EDT$$CLS_FI (.DESC_ADDR, 0, IO_STS);
IF ((.FILESTRM EQL EDT$K_OUTPUT_FILE) OR (.FILESTRM EQL EDT$K_WRITE_FILE))
THEN
!+
! Check the status from the close
!-
BEGIN
IF (.IO_STS)
THEN
IF (.DISK_FI)
THEN
IF (NOT EDT$$REN_FI (.DESC_ADDR, TEMP_DESC, IO_STS))
THEN
BEGIN
IO_FNAM = .DESC_ADDR;
ERR_NUMBER = .IO_STS;
IO_STS = 0;
END
ELSE
IO_STS = 1
ELSE
BEGIN
_GETER ($FHSLF; ERR_NUMBER);
IO_FNAM = .DESC_ADDR;
END;
END;
RETURN (.IO_STS);
END;
[EDT$K_CLOSE_DEL] :
BEGIN
CASE .FILESTRM FROM EDT$K_JOURNAL_FILE TO EDT$K_WRITE_FILE OF
SET
[EDT$K_OUTPUT_FILE, EDT$K_WRITE_FILE] :
BEGIN
EDT$$CLS_FI (.DESC_ADDR, 1, IO_STS);
_GETER ($FHSLF; ERR_NUMBER);
IO_FNAM = .DESC_ADDR;
END;
[EDT$K_JOURNAL_FILE] :
BEGIN
EDT$$CLS_FI (JOU_NAM, 2, IO_STS);
_GETER ($FHSLF; ERR_NUMBER);
IO_FNAM = JOU_NAM;
RETURN (.IO_STS);
END;
[INRANGE, OUTRANGE] :
ASSERT (9, 0);
TES;
RETURN (.IO_STS);
END;
[INRANGE, OUTRANGE] :
ASSERT (10, 0);
TES;
ASSERT (0, 0);
RETURN (0);
END; ! End of routine FILEIO
END
ELUDOM