Google
 

Trailing-Edge - PDP-10 Archives - tops20-v7-ft-dist1-clock - 7-sources/reajoutex.bli
There are 10 other files named reajoutex.bli in the archive. Click here to see a list.
 %TITLE 'REAJOUTEX - read a text record from the journal file'
MODULE REAJOUTEX (				! Read a text record from the journal file
		IDENT = '3-004'			! File: REAJOUTEX.BLI Edit: CJG3004
		) =
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:
!
!	Read a text record from the journal file.  All other records are
!	processed in this module.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: John Sauter, CREATION DATE: June 22, 1981
!
! MODIFIED BY:
!
! 1-001	- Original.  JBS 22-Jun-1981
! 1-002	- Change the format of the journal file to make it compatible
!	   with EDT v2.0.  JBS 07-Jul-1981
! 1-003	- Fix the module name and title.  JBS 07-Aug-1981
! 1-004	- Read from the journal file, not the command file.  JBS 16-Aug-1981
! 1-005	- Handle control C records.  JBS 21-Dec-1981
! 1-006	- Debug control C record handling.  JBS 24-Dec-1981
! 1-007	- Revise control C data names.  JBS 29-Dec-1981
! 1-008	- Use two words for control C counters.
! 1-009 - Convert to use EDT$FILEIO. STS 18-Jan-1982
! 1-010 - Pass RHB descriptor to fileio. STS 25-Jan-1982
! 1-011 - Deallocate dynamic descriptors. STS 10-Feb-1982
! 1-012 - Add literals for callable EDT. STS 10-Mar-1982
! 1-013	- Remove reference to EDT$$RD_IFI.  JBS 15-Mar-1982
! 1-014	- Allow 0-length records.  JBS 01-Apr-1982
! 1-015	- Use symbols instead of magic numbers when journaling control C.  JBS 24-May-1982
! 3-001 - Don't need RHB code on TOPS20. CJG 19-Apr-1983
! 3-002 - Remove call to EDT$$CALLFIO. CJG 10-Jun-1983
! 3-003 - Fix journal counters for TOPS-20 operation. CJG 17-Jun-1983
! 3-004 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$RD_JOUTXT;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

REQUIRE 'SYS:JSYS';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!

EXTERNAL LITERAL
    EDT$K_GET,
    EDT$K_JOURNAL_FILE;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$RD_JOUTXT  - read a text record from the journal file'

GLOBAL ROUTINE EDT$$RD_JOUTXT (			! Read a text record from the journal file
    INPUT_BUFFER, 				! Address of input buffer
    INPUT_BUFFER_LEN				! Length of record read
    ) =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Read records from the journal file until we find a text record.  Return that
!	record to the caller.  The other kind of record, the control C record, is
!	processed in this routine by storing its value in CC_CNT2.
!
! FORMAL PARAMETERS:
!
!  INPUT_BUFFER			The address of the input buffer.  The text record is
!				stored in this buffer.
!  INPUT_BUFFER_LEN		The length of the text record read is stored here.
!
! IMPLICIT INPUTS:
!
!	RCOV_MOD
!	CC_CNT1
!	CC_CNT2
!	CC_FLAG
!
! IMPLICIT OUTPUTS:
!
!	CC_CNT1
!	CC_CNT2
!	CC_FLAG
!
! ROUTINE VALUE:
!
!	1 = text record read, 0 = error from reading file
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$FILEIO;

    EXTERNAL
	CC_CNT1,			! Counts number of "no control C's" returned.
	CC_CNT2,			! Loaded with value from control C record
	CC_FLAG,			! 1 = a control C record was read or written
	RCOV_MOD;			! 1 = /RECOVER

    LOCAL
	DUM,
	FILE_DESC : BLOCK [1],
	INPUT_FILE_STATUS,
	LOCAL_INPUT_BUFFER : REF VECTOR,
	LOCAL_INPUT_BUFFER_LEN;


    FILE_DESC [DSC$A_POINTER] = 0;
    FILE_DESC [DSC$W_LENGTH] = 0;
!+
! This routine is only called if we are recovering.
!-
    ASSERT (13, .RCOV_MOD);
!+
! Read from the journal file until we get a text record.
!-

    DO
	BEGIN
	INPUT_FILE_STATUS = EDT$FILEIO (EDT$K_GET, EDT$K_JOURNAL_FILE, FILE_DESC);
	LOCAL_INPUT_BUFFER = .FILE_DESC [DSC$A_POINTER];
	LOCAL_INPUT_BUFFER_LEN = .FILE_DESC [DSC$W_LENGTH];

	IF (.INPUT_FILE_STATUS NEQ 0)
	THEN
	    BEGIN

	    IF (.LOCAL_INPUT_BUFFER_LEN EQL 0)
	    THEN
		BEGIN
!+
! We have a 0-length record.  Treat it as a text record.
!-
		.INPUT_BUFFER_LEN = 0;
		RETURN (.INPUT_FILE_STATUS);
		END
	    ELSE
		BEGIN

		IF (CH$RCHAR (CH$PTR (.LOCAL_INPUT_BUFFER,, BYTE_SIZE)) NEQ JOU_REC_ESC)
		THEN
		    BEGIN
!+
! We have a text record, move the record to the caller's buffer and return.
!-
		    ASSERT (20, .LOCAL_INPUT_BUFFER_LEN LEQ 256);
		    CH$MOVE (.LOCAL_INPUT_BUFFER_LEN,
			CH$PTR (.LOCAL_INPUT_BUFFER,, BYTE_SIZE),
			CH$PTR (.INPUT_BUFFER,, BYTE_SIZE));
		    .INPUT_BUFFER_LEN = .LOCAL_INPUT_BUFFER_LEN;
		    RETURN (.INPUT_FILE_STATUS);
		    END
		ELSE
		    BEGIN
!+
! This must be a control C record.  Arrange for a simulated control C trap
! after the specified number of tests of the control C flag.
!-
		    ASSERT (20, CH$RCHAR (CH$PTR (.LOCAL_INPUT_BUFFER,, BYTE_SIZE))
			    EQL JOU_REC_ESC);
		    ASSERT (20, CH$RCHAR (CH$PTR (.LOCAL_INPUT_BUFFER, 1, BYTE_SIZE))
			    EQL CC_REC_FLAG);
		    ASSERT (20, (.LOCAL_INPUT_BUFFER_LEN) EQL CC_REC_SIZE);
		    ASSERT (20, .CC_CNT1 EQL 0);
		    ASSERT (20, .CC_CNT2 EQL 0);
		    ASSERT (20, .CC_FLAG EQL 0);
		    _NIN (CH$PTR (.LOCAL_INPUT_BUFFER, 2, BYTE_SIZE), 10; DUM, CC_CNT2);
		    ASSERT (20, .CC_CNT2 GEQ 0);
		    ASSERT (20, .CC_CNT2 LEQ CC_CTR_MAX);
		    CC_FLAG = 1;
		    END;

		END;

	    END
	ELSE
!+
! No more records in the journal file, return failure.
!-
	    BEGIN
	    RETURN (.INPUT_FILE_STATUS);
	    END;

	END
    UNTIL 0;

!+
! Control cannot reach this point.
!-
    ASSERT (0, 0);
    RETURN (0);
    END;					! of routine EDT$$RD_JOUTXT


END
ELUDOM