Google
 

Trailing-Edge - PDP-10 Archives - bb-x130a-sb - sed1jo.mac
There are 10 other files named sed1jo.mac in the archive. Click here to see a list.
TITLE	SED1JO - SED JOURNALING ROUTINES
SUBTTL	A CHRISTOPHER HALL FECIT

;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1979,1983.

;NOTE: THIS ENTIRE MODULE IS UNDER SWITCH FTJOUR.
;IF FTJOUR==0 SED CAN BE ASSEMBLED WITHOUT THIS MODULE

	SEARCH	SEDSYM
	SALL

IFN TOPS10,<
	SEARCH	UUOSYM
	TWOSEG
	RELOC	400000
>
IFE TOPS10,<
	SEARCH	MONSYM
>

IFN FTJOUR,<

;SUBROUTINES TO MANIPULATE THE JOURNAL FILE
;(CONTROLLED BY THE /JOURN AND /RECOV SWITCHES

;SUBROUTINE TO START UP THE JOURNAL FILE (SEDJRN.TMP)
;T1 T2 PRESERVED; FRAGS T3

JRNSTT::MOVEM	TY,JRNPTR	;SAVE TYPE-OUT POINTER; POINT TO JRN BUFFER
	MOVE	TY,[POINT 7,JOURNL]
	MOVEI	T1,FILSPC	;GET CURRENT FILE SPECS
	MOVE	T4,DISPTR	;AND DISPLAY POINTER
	PUSHJ	P,EXIFIL	;OUTPUT THE STATUS OF THE ACTIVE FILE
	SKIPN	OLDSPC		;IS THERE AN ALTERNATE FILE?
	JRST	JRNST0		;NO - DON'T OUTPUT ITS STATUS
IFE TOPS10,<
	MOVE	T2,TY		;SEE IF THE FILESPEC WAS LONG
	HRRZS	TY
	CAILE	TY,JOURNL+<JRNSIZ_-1>
	PUSHJ	P,JRNSVO	;OUTPUT IF BUFFER IS MORE THAN HALF FULL
	MOVE	TY,T2
>
	MOVEI	T1,OLDSPC	;GET ALTERNATE FILE SPECS
	MOVE	T4,SAVEDP	;AND DISPLAY POINTER
	DMOVEM	RW,SAVEAC+2
	HRRZ	RW,SAVERW
	HLRZ	CM,SAVERW
	EXCH	SL,SAVESL
	PUSHJ	P,EXIFIL	;OUTPUT THE STATUS OF THE ALTERNATE FILE
	DMOVE	RW,SAVEAC+2
	EXCH	SL,SAVESL
JRNST1:	SKIPE	OUTFLG		;IS THERE AN /OUTPUT: SWITCH IN EFFECT?
	PUSHJ	P,JRNOSW	;YES  - OUTPUT IT, TOO
	EXCH	TY,JRNPTR	;SAVE JOURNAL BUFFER PTR; GET TYPE-OUT PTR
	SETOM	JRNBIT		;NOTE THAT FIRST FILE WRITE HAS NOT BEEN DONE
	MOVE	T1,[POINT 7,JOURNL+JRNSIZ-1,34]
	MOVEM	T1,JRNENP	;SAVE POINTER TO END OF JOURNAL
IFN TOPS10,<
	TLZ	TM,JRO		;NOTE THAT JOURNAL FILE IS CLOSED
	SETZM	JRNDSK		;SAY WRITING DISK BLOCK 1
>
	POPJ	P,		;FINISH OFF AND RETURN

JRNST0:	PUSHJ	P,EXIFL1	;NO ALTERNATE FILE - OUTPUT A CRLF
	JRST	JRNST1		;AND FINISH OFF

;SUBROUTINE TO OUTPUT THE /OUTPUT: SWITCH WITH THE CURRENT FILE

JRNOSW:	MOVE	T1,[ASCII ?$OUT:?]
	PUSHJ	P,PUTSQ1	;OUTPUT THE /OUTPUT: SWITCH
	MOVEI	T1,NEWSPC	;GET THE NEW FILE SPECS
	PUSHJ	P,PUTSTG	;PUT FILESPECS IN BUFFER
	MOVE	T1,[ASCII ?^SW
?]
	JRST	PUTSQ1		;END WITH THE SWITCH COMMAND AND A CRLF

;SUBROUTINE TO SAVE A CHARACTER IN THE JOURNAL BUFFER & OUTPUT IT IF FULL
;CALL WITH CHARACTER IN T1; T3 IS FRAGGED

JRNSVA::MOVEM	T1,SAVEAC	;PRESERVE THE CHARACTER
	CAIE	T1,"^"		;GOT A REAL UP-ARROW,
	CAIN	T1,"$"		;  OR A REAL DOLLAR SIGN?
	JRST	JRSVA1		;YES - PREPEND AN UP-ARROW
	ROT	T1,-7		;LEFT-JUSTIFY IT
	JRST	JRSVC0		;OUTPUT	THE CHARACTER AND RETURN

JRSVA1:	ROT	T1,-^D14	;LEFT-JUSTIFY TWO CHARACTERS
	TLO	T1,570000	;PRECEDE THE CHARACTER WITH AN UP-ARROW
	JRST	JRSVC0		;OUTPUT THEM AND RETURN

;SUBROUTINE TO SAVE A COMMAND IN THE JOURNAL BUFFER & OUTPUT IT IF FULL
;CALL WITH COMMAND INDEX IN AC DO; T1, T3 FRAGGED

JRNSVC::CAIN	DO,$ABORT	;GOT AN ABORT COMMAND?
	POPJ	P,		;YES - DON'T SAVE IT (IN CASE OF REENTER)
	CAIN	DO,$HELP	;GOT A HELP OR RECOVER COMMAND?
	TLNE	F,ENT		;YES - IN A PARAMETER?
	SKIPA	T1,CMDNAM(DO)	;NOT HELP (MAY BE RECOVER) - GET COMMAND NAME
	POPJ	P,		;HELP - IGNORE THE HELP COMMAND
	CAMN	T1,CMDNAM+$RETRN ;IS IT A RETURN COMMAND?
	TRO	T1,6424		;YES - FOLLOW IT WITH A REAL CRLF
JRSVC0:	TRNE	F,XCT!XBN	;EXECUTING OR RESTORING A JOURNAL?
	JRST	JRSVC2		;YES - DON'T DO ANY SAVING
	EXCH	T2,JRNPTR	;NO - SAVE T2 AND GET PTR TO JOURNAL BUFFER
JRSVC1:	LSHC	T0,7		;SHIFT IN A CHARACTER
	IDPB	T0,T2		;SAVE IT IN THE JOURNAL BUFFER
	CAMN	T2,JRNENP	;IS BUFFER FULL?
	PUSHJ	P,JRNSVO	;YES - OUTPUT IT
	JUMPN	T1,JRSVC1	;LOOP THROUGH COMMAND NAME
	EXCH	T2,JRNPTR	;SAVE JOURNAL POINTER AND GET T2 BACK
JRSVC2:	MOVE	T1,SAVEAC	;RESTORE AC T1
	POPJ	P,		;DONE

;SUBROUTINE TO SAVE AN EXECUTE CALL IN THE JOURNAL BUFFER & OUTPUT IT IF FULL
;CALL WITH EXECUTE INDEX IN DO;  T1, T3 FRAGGED

JRNSVX::MOVE	T1,DO		;GET EXECUTE INDEX
	OR	T1,[5,,726140]	;PRECEDE INDEX WITH "^X" AND LIGHT 140 (REALLY)
	LSH	T1,^D15		;LEFT-JUSTIFY THE STRING
	JRST	JRSVC0		;OUTPUT THE STRING AND RETURN

;SUBROUTINE TO WRITE OUT THE JOURNAL BUFFER

JRNSVO:	MOVEM	T1,SAVEAC+1	;OUTPUT BUFFER: SAVE T1
	SETZ	T3,		;END THE BUFFER WITH A NULL
	SKIPN	T1,T2		;(BUT DON'T HURT THE POINTER IN T2)
	POPJ	P,		;DONE IT NOT A POINTER (EDITING CHEERY MSG)
	IDPB	T3,T1
IFN TOPS10,<
	TLOE	TM,JRO		;IS THE JOURNAL ALREADY OPEN?
	JRST	JRSVO1		;YES - SKIP THIS
	MOVEI	T3,.FOAPP	;NO - ASSUME THIS IS NOT THE FIRST TIME
	SKIPE	JRNBIT		;HAS THE FILE BEEN WRITTEN TO?
	MOVEI	T3,.FOWRT	;OF COURSE NOT - OPEN FOR THE FIRST TIME
	HRRM	T3,JRNFIL+.FOFNC
	SETZM	JRNBIT		;MARK JOURNAL FILE AS OPEN
	MOVE	T3,USRPPN	;OPEN IT IN THE USER'S TOP-LEVEL DIR
	MOVEM	T3,JRNLKB+3
	MOVE	T3,[6,,JRNFIL]	;OPEN OR APPEND TO THE FILE
	FILOP.	T3,
	  JRST	JRSERR		;OOPS - CAN'T DO IT
	HLLZS	JRNLKB+1	;CLEAN UP THE BLOCK FOR NEXT TIME
	SETZM	JRNLKB+2

JRSVO1:	MOVE	T1,JRNDSK	;GET NUMBER OF CURRENT DISK BLOCK
	MOVE	T3,JRNENP	;IF NOT FIRST OUTPUT TO THIS BLOCK,
	CAME	T3,[POINT 7,JOURNL+JRNSIZ-1,34]
	USETO	11,1(T1)	;  SET TO THE BLOCK'S START
	OUTPUT	11,JRNCCL	;OUTPUT THE JOURNAL RECORD
	CAME	T3,[POINT 7,JOURNL+JRNSIZ-1,34]
	JRST	JRSVO2		;IF FIRST OUTPUT TO BLOCK, DO CHECKPOINT
	MOVEI	T1,.FOURB	;GET THE CHECKPOINT FILE FUNCTION
	HRRM	T1,JRNFIL+.FOFNC
	MOVE	T1,[1,,JRNFIL]	;POINT TO THE ARGUMENT BLOCK
	FILOP.	T1,		;CHECKPOINT THE FILE
	  CAIA			;COULDN'T - DO IT THE OLD WAY
	JRST	JRSVO2		;SUCCESS - CONTINUE
	TLZ	TM,JRO		;(OLD WAY) MARK FILE AS CLOSED
	RELEAS	11,		;CLOSE AND RELEASE THE FILE
JRSVO2:	CAMN	T3,[POINT 7,JOURNL+177,34]	;AT END OF BUFFER?
	JRST	[AOS   JRNDSK			;YES - BUMP DISK BLOCK NUMBER
		 SETZM JOURNL+JRNSIZ-1 		;CLEAN OUT THE JOURNAL BUFFER
		 MOVE  T3,[JOURNL+JRNSIZ-1,,JOURNL+JRNSIZ]
		 BLT   T3,JOURNL+177
		 MOVE  T2,[POINT 7,JOURNL]	;WRITE FROM START OF BUFFER
		 MOVE  T3,[POINT 7,JOURNL+JRNSIZ-1,34]
		 JRST  JRSVO3]			;RE-START EO-BUFFER PTR; FLOW
	ADDI	T3,JRNSIZ			;NOT AT END - BUMP END POINTER
	CAMLE	T3,[POINT 7,JOURNL+177,34]	;BEYOND END NOW?
	MOVE	T3,[POINT 7,JOURNL+177,34]	;YES - POINT AT THE END
JRSVO3:	MOVEM	T3,JRNENP	;SAVE END-OF-JOURNAL POINTER
>
IFE TOPS10,<
	SKIPN	JRNBIT		;WRITING THE FILE FOR THE FIRST TIME?
	JRST	JRSVO1		;NO - GO APPEND TO THE FILE
	SETZM	INIJFN		;SAY JOURNAL FILE DOESN'T HAVE TO EXIST
	MOVEI	T1,INIJFN	;CREATE JOURNAL IN USER'S LOGGED-IN AREA
	HRROI	T2,JRNFIL	;POINT TO THE JOURNAL NAME
	GTJFN
	  JRST	JRSERR
	HRRZM	T1,JRNJFN	;SAVE JFN FOR LATER
	MOVSI	T1,(GJ%OLD)	;PATCH UP THE GTJFN BLOCK
	MOVEM	T1,INIJFN
	SETZM	JRNBIT		;SAY IT'S NO LONGER THE FIRST WRITE
	SKIPA	T2,[7B5+OF%WR]	;SET TO OPEN UP A NEW JOURNAL FILE
JRSVO1:	MOVE	T2,[7B5+OF%APP]	;SET TO APPEND TO THE EXISTING FILE
	MOVE	T1,JRNJFN	;GET THE JOURNAL'S JFN
	OPENF
	  JRST	JRSERR

	HRROI	T2,JOURNL	;OUTPUT THE JOURNAL BUFFER
	SETZ	T3,
	SOUT
	HRLI	T1,(CO%NRJ)	;CLOSE THE JOURNAL BUT DON'T RELEASE THE JFN
	CLOSF
	  JRST	JRSERR		;(IT REALLY OUGHT TO WORK)
	MOVE	T2,[POINT 7,JOURNL] ;RESET JOURNAL BUFFER POINTER
>
	MOVE	T1,SAVEAC+1	;RESTORE THE SAVED T1
	POPJ	P,		;DONE

;HERE TO READ FROM JOURNAL - FROM XCTGET, WHEN JRC (AND XCT OR XBN) IS SET

LOPJRN::PUSHJ	P,SRCIPT	;DOES THE USER WANT TO ABORT RECOVERY?
	  JRST	JABERR		;YES - ABORT IT
	PUSHJ	P,LOPJRR	;GET A REAL CHARACTER FROM THE JOURNAL
	CAIN	T1,"$"		;GOT AN ESCAPE COMMAND?
	JRST	[MOVEI T1,33	;YES - GET ITS INDEX
		 JRST  LOOP2]	;AND USE IT
	CAIE	T1,"^"		;GOT A TYPE-IN CHARACTER?
	JRST	LOPJRA		;NO - JUST PUT IT IN FILE OR BUFFER
	PUSHJ	P,LOPJRR	;YES - GET FIRST CHARACTER OF COMMAND
	CAIE	T1,"$"		;REALLY WANT A REAL DOLLAR SIGN,
	CAIN	T1,"^"		;  OR AN UP-ARROW?
	JRST	LOPJRA		;YES - HANDLE IT LIKE A CHARACTER

	MOVEI	PT,"^"		;NO - GET AN UP-ARROW
	PUSHJ	P,LOPJC1	;PUT NEW CHARACTER IN WITH IT
	PUSHJ	P,LOPJRC	;GET REST OF COMMAND NAME
	CAME	PT,["^RF"]	;GOT A ROLL FORWARD
	CAMN	PT,["^RB"]	;  OR BACKWARD?
	JRST	LOPJR2		;YES - NEED TO GET ANOTHER CHARACTER
IFE TOPS10,<
	CAMN	PT,["^PU"]	;PUSH COMMAND?
	JRST	LOPJRN		;YES - IGNORE IT
>
;	CAMN	PT,["^RW"]	;RE-WRITE COMMAND?
;	JRST	LOPJRN		;YES - IGNORE IT
	LSH	PT,^D15		;NO - LEFT-JUSTIFY COMMAND NAME
LOPJR1:	MOVEI	T1,CMDLEN-1	;LOOK FOR COMMAND AMONG NAMES
	CAME	PT,CMDNAM(T1)	;IS THIS IT?
	SOJGE	T1,.-1		;NO - KEEP LOOKING
	JUMPGE	T1,LOOP2	;PROCESS COMMAND, IF THAT'S WHAT IT IS

	MOVE	T1,PT		;ELSE LOOK AT FIRST TWO CHARACTERS OF NAME
	SETZ	T0,
	LSHC	T0,^D14
	CAIE	T0,"^X"		;GOT AN EXECUTE BUFFER?
	JRST	JRRERR		;NO - IT'S AN ERROR
	ROT	T1,7		;YES - GET EXECUTE INDEX (+ 140) IN RH
	JRST	ILCER0		;GO PROCESS THE EXECUTE

LOPJR2:	PUSHJ	P,LOPJRC	;GET REST OF COMMAND NAME
	LSH	PT,^D8		;LEFT-JUSTIFY COMMAND NAME
	JRST	LOPJR1		;GO FIND THE COMMAND

LOPJRA:
IFE TOPS10,<
IFN FTECHO,<
	TRNN	F,XBN		;DOES THE USER WANT TO SEE THE ACTION?
	JRST	ALPNUM		;NO - GO HANDLE IT LIKE A CHARACTER
	TLNN	F,ENT		;IN A PARAMETER?
	TYPCHA			;NO - DISPLAY THE CHARACTER
>>
	JRST	ALPNUM		;GO HANDLE IT LIKE A CHARACTER

LOPJRC:	PUSHJ	P,LOPJRR	;GET CHARACTER FROM THE JOURNAL
LOPJC1:	LSH	PT,7		;SHIFT OVER ALREADY-GOTS
	OR	PT,T1		;PUT NEW CHARACTER IN WITH THEM
	POPJ	P,		;DONE

LOPJRR:	ILDB	T1,JRNPTR	;GET CHARACTER FROM THE JOURNAL
	CAIL	T1," "		;CONTROL CHARACTER OR NULL?
	POPJ	P,		;NO - RETURN
	JUMPN	T1,LOPJRR	;YES - IGNORE CONTROL CHARACTERS
	PUSHJ	P,JRNRED	;IF NULL READ ANOTHER PIECE OF THE JOURNAL
	JRST	LOPJRR		;GET A CHARACTER FROM IT AND CONTINUE

;SUBROUTINE FOR RECOVERING THE JOURNAL:
;OPEN THE JOURNAL, READ THE FIRST BUFFERFUL OF COMMANDS,
;AND SET UP THE FILE AND ALTERNATE

JRNGET::SETZM	JRNFLG		;SAY THERE'S MORE FILE TO COME
	SETZM	RSCANF		;FORGET FILE GIVEN IN RESCAN
IFN TOPS10,<
	MOVEI	T1,.FORED	;SET UP THE FILE FOR READING
	HRRM	T1,JRNFIL+.FOFNC
	MOVE	T1,USRPPN	;LOOP FOR THE FILE IN THE USER'S DIRECTORY
	MOVEM	T1,JRNLKB+3
	MOVE	T1,[6,,JRNFIL]	;LOOP UP THE FILE
	FILOP.	T1,
	  JRST	JRNERR		;ERROR
	HLLZS	JRNLKB+1	;CLEAN UP THE BLOCK FOR NEXT TIME
	SETZM	JRNLKB+2
	SETOM	JRNDSK		;NOTE WILL BE READING THE FIRST DISK BLOCK
>
IFE TOPS10,<
	MOVEI	T1,INIJFN	;LOOK FOR THE JOURNAL IN THE LOGGED-IN AREA
	HRROI	T2,JRNFIL
	GTJFN
	  JRST	JRNERR
	HRRZ	T1,T1		;CLEAR FLAGS OUT OF LH OF T1
	MOVEM	T1,JRNJFN	;SAVE JFN FOR LATER
	MOVE	T2,[7B5+OF%RD]
	OPENF
	  JRST	JRNERR
>
	PUSHJ	P,JRNRED	;READ FIRST BLOCK OF THE JOURNAL
	MOVE	T2,[POINT 7,JOURNL]
	MOVEI	T3,FILSPC	;READ OLD FILESPECS
	PUSHJ	P,JRNCPY
	MOVEI	T3,OLDSPC	;AND CURRENT FILESPECS
	PUSHJ	P,JRNCPY
	MOVEM	T2,JRNPTR	;SAVE THE POINTER INTO THE JOURNAL
	POPJ	P,		;DONE

JRNRED::SKIPE	JRNFLG		;IS THERE MORE FILE TO READ?
	JRST	JRNEND		;NO - DONE
	MOVE	T2,[POINT 7,JOURNL]
	MOVEM	T2,JRNPTR	;YES - RESET POINTER INTO BUFFER
IFN TOPS10,<
	INPUT	11,JRNCCL	;READ THE NEXT BUFFERFUL OF COMMANDS
	STATZ	11,760000	;REACHED END OF FILE (OR AN ERROR)?
	JRST	JRNDUN		;YES - NOTE THAT END OF FILE HAS BEEN REACHED
	AOS	JRNDSK		;NO - BUMP NUMBER OF DISK BLOCK JUST READ
>
IFE TOPS10,<
	MOVE	T1,JRNJFN	;GET JFN
	HRROI	T2,JOURNL	;AND A BUFFERFUL OF COMMANDS
	MOVNI	T3,5*JRNSIZ
	SIN
	  ERJMP	JRNDUN		;ON END OF FILE GIVE A NON-SKIP RETURN
>
	POPJ	P,		;READ SUCCEEDED - DONE

;SUBROUTINE TO COPY FILESPECS FROM (T2) TO (T3) UNTIL A CARRIAGE RETURN

JRNCPY:	HRLI	T3,440700	;MAKE TARGET ADDRESS A POINTER
JRNCP0:	ILDB	T1,T2		;GET A CHARACTER
	CAIN	T1,15		;CARRIAGE RETURN?
	JRST	JRNCP1		;YES - FINISH OFF
	IDPB	T1,T3		;NO - SAVE THE CHARACTER
	JRST	JRNCP0		;AND GET MORE

JRNCP1:	ILDB	T1,T2		;SKIP OVER THE LINEFEED
	SETZ	T1,		;END FILESPECS WITH A NULL
	IDPB	T1,T3
	POPJ	P,		;DONE

;HERE WHEN RECOVERING, WHEN END OF JOURNAL FILE IS REACHED

JRNDUN:	SETOM	JRNFLG		;SAY END OF FILE HAS BEEN REACHED
IFN TOPS10,<
	RELEAS	11,		;CLOSE AND RELEASE THE JOURNAL FILE
				;FALL INTO THE CODE AT JRNEND
>
IFE TOPS10,<
	MOVE	T1,JRNJFN	;THROW AWAY THE JOURNAL FILE
	CLOSF			;CLOSE IT
	  POPJ	P,		;IT BETTER WORK
	POPJ	P,		;DONE
>

JRNEND:	MOVE	T2,[POINT 7,JOURNL]
	MOVEM	T2,JRNPTR	;INITIALIZE THE JOURNAL BUFFER POINTER
	SKIPN	JRNBIT		;WANT TO KEEP APPENDING TO THIS JOURNAL?
	JRST	JRNEN1		;NO - DON'T INITIALIZE
	TLO	TM,JRW		;YES - NOTE THAT JOURNAL IS NOW BEING WRITTEN
IFN TOPS10,<
	SETZM	JOURNL+JRNSIZ-1 ;CLEAN OUT THE JOURNAL BUFFER
	MOVE	T3,[JOURNL+JRNSIZ-1,,JOURNL+JRNSIZ]
	BLT	T3,JOURNL+177
>
	MOVE	T1,[POINT 7,JOURNL+JRNSIZ-1,34]
	MOVEM	T1,JRNENP	;SAVE POINTER TO END OF JOURNAL BUFFER
	SETZM	JRNBIT
JRNEN1:	SKIPA	T1,[[ASCIZ /#########File recovered/]]
JRNERR:	MOVEI	T1,[ASCIZ /#####Can't find journal file/]
JRNER1:	TRZ	F,XCT!XBN	;END THE JOURNAL RESTORE
IFN TOPS10,<
	TLZ	TM,JRC!JRO	;CLEAR RECOVERY BIT; NOTE FILE IS NOT OPEN
>
IFE TOPS10,<
	TLZ	TM,JRC		;CLEAR RECOVERY BIT
>
	SETZM	JRNFLG
	JRST	STFER1		;TELL USER THAT RECOVERY IS DONE

JABERR:	SKIPA	T1,[[ASCIZ /#####Journal recovery aborted/]]
JRRERR:	MOVEI	T1,[ASCIZ /######Bad command in journal/]
	JRST	JRNER1

JRSERR:	MOVEI	T1,[ASCIZ /#####Can't write journal file/]
	TLZ	TM,JRW		;DON'T DO JOURNALING
IFE TOPS10,<
	MOVSI	T2,(GJ%OLD)	;PATCH UP THE GTJFN BLOCK
	MOVEM	T2,INIJFN
>
	JRST	STFER1		;TELL USER THAT RECOVERY IS DONE

> ;END FTJOUR

	END