Google
 

Trailing-Edge - PDP-10 Archives - bb-d868b-bm_tops20_v3a_2020_dist - 3a-sources/rdmail.mac
There are 20 other files named rdmail.mac in the archive. Click here to see a list.
;<3A.UTILITIES>RDMAIL.MAC.8, 27-Jul-78 17:48:07, EDIT BY MILLER
;CHANGE EDIT NUMBER
;<3A.UTILITIES>RDMAIL.MAC.7, 30-May-78 14:14:57, EDIT BY OSMAN
;increase pushdown stack size
;<3A.UTILITIES>RDMAIL.MAC.6, 30-May-78 10:42:07, EDIT BY MILLER
;FIX BUG IN NXTMS1 THAT CLOBBERED BYTE POINTER
;<3A.UTILITIES>RDMAIL.MAC.5, 15-May-78 11:33:57, EDIT BY OSMAN
;PUT /L BACK IN
;USE COMND JSYS
;<4.UTILITIES>RDMAIL.MAC.3, 30-Nov-77 17:55:32, EDIT BY CROSSLAND
;FIX UP ARPA SYSTEM TEST.
;<4.UTILITIES>RDMAIL.MAC.2, 16-Nov-77 20:43:45, EDIT BY MILLER
;FIX TXTFRM TO SET OF%PDT IF /P IS SPECIFIED
;<4.UTILITIES>RDMAIL.MAC.1,  5-Nov-77 18:21:28, EDIT BY MILLER
;FIX SPECIAL USER CODE TO WAIT FOR CRLF
;<3-UTILITIES>RDMAIL.MAC.6, 26-Oct-77 11:15:31, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-UTILITIES>RDMAIL.MAC.5, 29-Sep-77 15:58:56, EDIT BY CROSSLAND
;FIX EOF LOGIC ON NEW FORMAT FILES
;<3-UTILITIES>RDMAIL.MAC.4, 29-Sep-77 15:19:33, EDIT BY CROSSLAND
;FIX SEARCH FOR MESSAGE ON BOUNDRY BETWEEN NEW AND OLD
;<3-UTILITIES>RDMAIL.MAC.3, 28-Sep-77 02:31:00, EDIT BY CROSSLAND
;CONVERT TO UNDERSTAND BOTH NEW AND OLD FORMAT MAIL.TXT FILES
;<3-UTILITIES>RDMAIL.MAC.2, 25-Aug-77 10:47:38, EDIT BY KIRSCHEN
;FIX VERSION NUMBER FOR RELEASE 3
;<3-UTILITIES>RDMAIL.MAC.1, 16-Aug-77 17:56:35, EDIT BY MILLER
;ADD PARTIAL RECOG FOR "SPECIAL" USER
;<2-UTILITIES>RDMAIL.MAC.22, 20-Jan-77 14:18:56, EDIT BY HURLEY
;FIX HELP MESSAGE
;<2-UTILITIES>RDMAIL.MAC.21, 27-Dec-76 17:07:41, EDIT BY HURLEY
;<2-UTILITIES>RDMAIL.MAC.20,  2-Nov-76 12:55:14, EDIT BY MILLER
;<2-UTILITIES>RDMAIL.MAC.19,  2-Nov-76 12:28:14, EDIT BY MILLER
;<2-UTILITIES>RDMAIL.MAC.18,  2-Nov-76 12:19:41, EDIT BY MILLER
;<2-UTILITIES>RDMAIL.MAC.17,  2-Nov-76 12:15:43, EDIT BY MILLER
;FIX UP FOR POST MARK WHICH OVERLAPS PAGE BOUNDARY
;<2-UTILITIES>RDMAIL.MAC.16,  1-Nov-76 18:16:48, EDIT BY MILLER
;CHECK FOR EOF PAGE IN PRE SCAN OF MESSAGES
;<2-UTILITIES>RDMAIL.MAC.15,  1-Nov-76 17:50:58, EDIT BY MILLER
;MORE FIXES FOR SPEED UP
;<2-UTILITIES>RDMAIL.MAC.14,  1-Nov-76 13:42:41, EDIT BY MILLER
;MORE FIXES
;<2-UTILITIES>RDMAIL.MAC.13,  1-Nov-76 13:21:59, EDIT BY MILLER
;<2-UTILITIES>RDMAIL.MAC.12,  1-Nov-76 13:20:13, EDIT BY MILLER
;FIXES FOR SCAN SPEED UP
;<2-UTILITIES>RDMAIL.MAC.11,  1-Nov-76 13:12:46, EDIT BY MILLER
;TCO 1640. IMPROVE SCAN FOR FIRST RELEVANT MESSAGE
;<2-UTILITIES>RDMAIL.MAC.10, 27-Sep-76 09:14:21, EDIT BY MILLER
;FIX FOR 0 LENGTH MAIL FILES
;<2-UTILITIES>RDMAIL.MAC.9, 21-Sep-76 11:43:51, EDIT BY MILLER
;FIX /M AND SPECIAL MESSAGES
;<2-UTILITIES>RDMAIL.MAC.8, 20-Sep-76 12:55:28, EDIT BY MILLER
;<2-UTILITIES>RDMAIL.MAC.7, 20-Sep-76 12:48:52, EDIT BY MILLER
;FIX DATE FOR MESSAGE-OF-THE-DAY
;<2-UTILITIES>RDMAIL.MAC.6, 20-Sep-76 11:35:41, EDIT BY MILLER
;FIX MESSAGE
;<2-UTILITIES>RDMAIL.MAC.5, 14-Sep-76 12:40:31, EDIT BY MILLER
;CHANGE RCDIR TO RCUSR AT DOIT
;<2-UTILITIES>RDMAIL.MAC.4, 14-Sep-76 11:46:18, EDIT BY MILLER
;MORE UPGRADE FIXES
;<2-UTILITIES>RDMAIL.MAC.3, 10-Sep-76 10:09:22, Edit by HESS
;TCO 1522 - UPGRADE FOR VERSION 2 RELEASE
;<1B-UTILITIES>RDMAIL.MAC.5,  9-Jul-76 09:39:42, EDIT BY HURLEY
;INCREASED VERSION NUMBER FOR RELEASE 1B
;<1B-UTILITIES>RDMAIL.MAC.4,  9-JUN-76 14:23:43, EDIT BY MILLER
;<1B-UTILITIES>RDMAIL.MAC.3,  7-JUN-76 17:45:11, EDIT BY HALL
;TCO 1343. CHANGE HELP TEXT TO REFLECT /L
;<1B-UTILITIES>RDMAIL.MAC.2,  3-JUN-76 11:00:46, EDIT BY MILLER
;<1B-UTILITIES>RDMAIL.MAC.1,  3-JUN-76 10:54:56, EDIT BY MILLER
;TCO 1343. ADD /L SWITCH
;<1A-UTILITIES>RDMAIL.MAC.37,  6-MAY-76 11:01:55, EDIT BY HURLEY
;<1A-UTILITIES>RDMAIL.MAC.34,  8-APR-76 16:29:26, EDIT BY HURLEY
;<1A-UTILITIES>RDMAIL.MAC.33,  8-APR-76 11:50:36, EDIT BY HURLEY
;TCO 1244 - ADD .DIRECT .XTABM FOR MACRO 50 ASSEMBLIES
;<V-SOURCES>RDMAIL.MAC.32, 16-MAR-76 15:41:07, EDIT BY KIRSCHEN
;tco 1186 - fix date example in help text
;<V-SOURCES>RDMAIL.MAC.31,  6-FEB-76 09:27:54, EDIT BY MILLER
;MCO 1060
;<V-SOURCES>RDMAIL.MAC.29, 19-DEC-75 10:38:11, EDIT BY MILLER


;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1977 BY DIGITAL EQUIPMENT CORPORATION

	SEARCH MONSYM,MACSYM,CMD
	.REQUIRE SYS:MACREL,SYS:CMD
	TITLE RDMAIL
	SALL
	IFNDEF .PSECT,<
	.DIRECT .XTABM>
	IFDEF .PSECT,<
		.DIRECT FLBLST
		     >

;DEFINE REGISTERS

A==1
B==2
C==3
D==4
W==5
W1==6
W2==7
P==17

;DEFINE VERSION CONSTITUENTS

PRGVER==3			;VERSION 3
PRGMIN==1			;MINOR VERSION
PRGEDT==10			;EDIT NUMBER
PRGCST==0			;DEC SOFTWARE

;LOCAL STORAGE
INTCAR==5			;INTERRUPT CHARACTER

STKSIZ==200
STACK:	BLOCK STKSIZ
CMDSTG			;COMND JSYS STORAGE
ADD1:	Z
LEVTAB:	ADD1
	ADD1
	ADD1			;THE LEVEL TABLE
CHNTAB:	1,,SKPMSG		;TERM INT TO PURGE THIS MESSAGE
JFN:	Z 0			;JFN OF INPUT FILE
OJFN:	BLOCK 1			;OUTPUT JFN
SAVACS:	Z
STOP:	Z			; STOP AFTER EACH MESSAGE
PRUSE:	Z
MOD:	Z 0			;MESSAGE OF THE DAY FLAG
FILFND:	Z 0			;FILE FOUND FLAG
HLPFLG:	0			;SAYS HELP WANTED
RLDATE:	Z 0			;FLAG
TIME:	Z 0			;DATE AND TIME TO BEGIN
MESSNO:	Z 0			;INTERNAL MESSAGE COUNTER
THISDT:	0			;GTAD OF CURRENT TEXT-FORM MSG
BEGM:	0			;CHAR COUNT AT START OF TEXT MSG
FILLEN:	0			;EOF POINTER OF FILE
SKIPCH:	0			;CHAR COUNT OF CURRENT MSG, TEXT FORM
FRMERC:	0			;FORMAT ERROR MESSAGE COUNTER
BIGSTR==5000			;BUFFER AREA
BIGBUF==BIGSTR+6		;START OF BUFFER AREA
BUFSIZ==10000			;SIZE OF BUFFER AREA

;THE ENTER VECTOR

ENTVEC:	JRST START		;MAIN ENTRY
	JRST START		;SAME AS MAIN
	PRGVER_^D24!PRGMIN_^D18!PRGEDT!PRGCST_^D33
	XWD TIME,START2

ENDVEC==.			;END OF ENTRY VECTOR
START:	RESET
	MOVEI A,.PRIOU		;DEFAULT OUTPUT JFN
	MOVEM A,OJFN
	MOVE P,[IOWD STKSIZ,STACK]
	CALL CMDINI		;INITIALIZE FOR COMND JSYS
	CALL CLRSTR		;CLEAR MAP
	MOVEI A,.FHSLF		; SEE IF ENABLED
	RPCAP			; GET THEM
	TRNE C,-1		; ANY SPECIALS SET?
	JRST SPCIAL		; YES. MUST ASK THEN
NOSPC:	GJINF			; GET JOB INFORMATION
	MOVE B,A		; DIRECTORY NUMBER TO B
DOFILE:	MOVE A,[POINT 7,BIGBUF]	;WHERE TO BUILD NAME
	PUSH P,B		;SAVE DIR NUMBER
	HRROI B,[ASCIZ /PS:</]
	SETZ C,
	SOUT			;MAKE IT GO TO PS ALWAYS
	POP P,B			;RESTORE DIR NUMBER
	DIRST			;GET HIS NAME
	 JFCL
	MOVEI C,">"		;GET TERMINATOR
	IDPB C,A		;STORE IT
	HRROI B,[ASCIZ /MAIL.TXT/] ;THE FILE
	SETZ C,
	SOUT			;COPY IT
	MOVX A,GJ%OLD!GJ%SHT+1	;ONLY VERSION 1
	HRROI B,BIGBUF		; THE NAME BUFFER
	GTJFN			;GET IT
	 JRST [	SETOM FILFND	;NO LOCAL MESSAGE FILE FOUND
		JRST SETPS1]	;GO DO SOME PROCESSING
	SETZM FILFND		;INDICATE FILE FOUND
	MOVEM A,JFN		;SAVE JFN
	MOVE B,[1,,.FBREF]	;SAVE LAST READ DTAE
	MOVEI C,D		;WHERE IT GOES
	GTFDB			;GET IT
	MOVEM D,TIME		;SAEV IT IN CASE
SETPS1:	CALL SETPSI		;GO TURN ON PI'S
;FILE IS NOW OPEN. ASK HIM FOR DATE AND TINM TO START PROCESSING


GETDAT:	PROMPT <Date and time  (/H for help) >
	SETZM HLPFLG		;NO HELP REQUEST YET
	SETZM RLDATE		;NO REAL DATE YET
	SETZM PRUSE		;ASSUME NO PERUSING
	SETZM STOP		; ASSUME NO STOPPING
	SETZM MOD		;NOT DOING MESSAGE OF THE DAY
MORE1:	MOVEI A,[FLDDB. .CMCFM,,,,,[FLDDB. .CMTAD,CM%SDH,CM%IDA,,,[FLDDB. .CMTAD,CM%SDH,CM%ITM,,,[FLDDB. .CMTAD,,CM%IDA!CM%ITM,,,[FLDDB. .CMSWI,,SWTAB]]]]]
	CALL RFIELD
	LDB C,[331100,,(C)]	;SEE WHAT WAS INPUT
	CAIE C,.CMTAD		;DATE INPUT?
	JRST NODAT1		;NO
	MOVEM B,TIME		;REMEMBER THE TIME TYPED
	SETOM RLDATE		;MARK THAT DATE TYPED
	JRST MORE1		;GET MORE OF LINE
NODAT1:	CAIE C,.CMSWI		;SWITCH?
	JRST NOSWI		;NO
	MOVE B,(B)		;GET ENTRY FROM TABLE
	CALL (B)		;EXECUTE THE SWITCH
	JRST MORE1		;GET MORE INPUT

SWTAB:	%N,,%N
	T A
	T H
	T L
	T M
	T P
	T S
%N==.-SWTAB-1

.L:	MOVX A,GJ%FOU+GJ%SHT
	HRROI B,[ASCIZ /LPT:RDMAIL.OUT/]
	GTJFN		;GET OUTPUT JFN
	 JRST [	HRROI A,[ASCIZ /
?LPT: not available for output
/]
		PSOUT
		RET]	;IGNORE IT
	MOVE B,[070000,,100000]
	OPENF		;OPEN LPT
	 JRST [	HRROI A,[ASCIZ /
?LPT: not available for output
/]
		PSOUT
		RET]	;GIVE UP
	MOVEM A,OJFN	;NEW OUTPUT JFN
	RET		;DONE

.P:	SETOM PRUSE	;YES. SET THE FLAG
	RET

.A:	SETZM TIME	;YES.
	SETOM RLDATE	;AND SAY FOUND A REAL TIME
	RET

.S:	SETOM STOP	;YES REMEMBER THIS
	RET

.M:	SETOM MOD	;YES. REMEMBER THIS
	SKIPE RLDATE	;HAVE A REAL DATE YET?
	POPJ P,		;YES. ALL DONE THEN
	MOVNI A,5	;GET CONSOLE TIME FOR THE JOB
	RUNTM		;GET IT
	GTAD		;GET NOW
	IDIV C,B	;GET SECONDS
	MUL C,[1B17]
	DIVI C,^D<3600*24> ;COMPUTE FRACTIONS OF A DAY
	SUB A,C		;COMPUTE LOGIN DATE AND TIME
	MOVEM A,TIME	;NEW DEFAULT TIME
	POPJ P,	;GO BACK

;READY TO PROCESS THE FILE

NOSWI:	SKIPN HLPFLG		;HELP WANTED?
	JRST NOSWI1		;NO
	CALL HLPOUT		;YES, PRINT IT
	JRST GETDAT		;FLUSH REST OF LINE
NOSWI1:	SKIPE MOD		;WANT MESSAGE OF THE DAY?
	JRST START2		;YES. GO DO IT
	SKIPE FILFND		;NO. HAVE A LOCAL MESSAGE FILE?
	JRST [	HALTF		;NO. STOP THEN
		JRST START]	
	MOVE B,[440000,,200000]	;OPENF BITS
	MOVE A,JFN		;THE JFN OF THE MESSAGE FILE
	SKIPE PRUSE		;PERUSING?
	TXO B,OF%PDT		;YES. SUPPRESS REFERNCE DATE UPDATE
	OPENF			;OPEN IT
OPNFAL:	 JRST [	MOVE D,A	;SAVE ERROR MESSAGE
		MOVE A,JFN	;GET FILE JFN
		RLJFN		;GET RID OF JFN
		 JFCL
		MOVEI A,101
		MOVE B,[400000,,-1]
		SETZ C,
		CAIE D,OPNX2	;WAS IT A ZERO LENGTH MAIL FILE?
		ERSTR		;NO,LET MONITOR TELL HIM WHAT HAPPENED
		 JFCL
		JFCL
		HALTF		;DIE
		JRST START]	;AND TRY AGAIN

	MOVEI A,.FHSLF
	EIR			;TURN ON THE INTERRUPT SYSTEM
	SETZM MESSNO		;CLEAR INTERNAL COUNTER
	SETOM FRMERC		;NO FORMAT ERROR MESSAGES YET
	MOVE A,JFN		;SELECT WHICH FORMAT FILE IT IS
	BIN			;FIRST WORD OF FILE
	JUMPN B,TXTFRM		;IF NOT ZERO, IT'S TEXT.
LKTOP:	SKIPN TIME		;HAVE A SPECIFIC TIME?
	JRST UPTOP		;NO. DO ALL OF FILE
	MOVE A,JFN		;THE JFN
	MOVE B,[1,,.FBBYV]	;GET # OF FILE PAGES
	MOVEI C,D		;LAST PAGE
	GTFDB			;GET THE LAST PAGE
	MOVEI D,-1(D)		;GET LAST PAGE NUMBER
	CAIG D,2		;MAKE SURE THIS IS WORTHWHILE
	JRST UPTOP		;SHORT FILE. LOOK AT IT ALL
	SETZM BIGSTR		;MAKE FIRST PAGE LOOK EMPTY
LKLOOP:	HRL A,JFN		;THE JFN
	HRR A,D			;THE FILE PAGE TO LOOK AT
	MOVE B,[.FHSLF,,BIGSTR/1000] ;A WORK PAGE
	MOVE C,BIGSTR		;GET FIRST WORD OF OLD PAGE
	MOVEM C,BIGSTR+1000	;MAKE IT NEXT WORD FOR NEW PAGE
	MOVX C,PM%RD		;ACCESS BITS
	PMAP			;GET THE PAGE

	MOVSI C,-1000		;LOOK AT WHOLE PAGE
	SETZ W,			;NO POST MARK FOUND YET
LKLOP1:	SKIPE BIGSTR(C)		;FOUND A NULL?
	JRST LKLOP2		;NO
	SKIPN BIGSTR+1(C)	;ANOTHER NULL?
	JRST LKLOP2		;YES
	HRROI A,BIGSTR+1(C)	;TRY TEXT TIME FIRST
	MOVSI B,(IT%AIS)	;REQUIRE SECONDS IN TIME OF MSG
	IDTIM			;GET TIME STAMP OF MSG
	 JRST [	MOVE B,BIGSTR+1(C) ;GET BINARY TIME STAMP
		JRST .+1]
	SETOM W			;AND IF NON-ZERO, REMEMBER IT
	CAMGE B,TIME		;A MESSAGE TO START WITH?
	MOVEI W,1		;NO. GO ON
	MOVEI B,0(D)		;GET PAGE #
	IMULI B,1000		;GET WORD NUMBER
	ADDI B,1(C)		;WORD TO START WITH
	MOVEM B,MESSNO		;REMEMBER IT
	JUMPG W,LKLOP5		;GO FOUND A MESSAGE BEFORE NOW
	JRST LKLOP3		;NEXT PAGE THEN
LKLOP2:	AOBJN C,LKLOP1		;DO ALL OF PAGE
	JUMPE W,LKLOP3		;IF NO POST MARK FOUND, CHECK ANOTHER PAGE
LKLOP5:	CALL CLRSTR		;CLEAR MAP
	SKIPE MESSNO		;FOUND ONE SOMEWHERE?
	JRST LKLOP4		;YES. GO DO IT THEN
	HALTF			;DONE
	JRST START		;START OVER

LKLOP3:	SOJG D,LKLOOP		;DO PREVIOUS PAGE
	JRST LKLOP5		;DONE. GO CHECK IF FOUND ONE

LKLOP4:	MOVE A,JFN		;THE FILE
	MOVE B,MESSNO		;THE WORD TO START WITH
	SFPTR			;SET FILE POINTER
	 JFCL			;SHOULD WORK
	JRST UPTOP
FIND:	CALL GETWD		;GET ANOTHER WORD
	CAME B,[ASCII /=====/]	;TRAILER SEPERATOR
	JRST FIND		;NO TRY NEXT WORD
	CALL GETWD		;GET ANOTHER WORD
	CAME B,[ASCIZ /=
/]				;LAST OF TRAILER
	JRST FIND		;SOMEBODY MUST HAVE HAD ====== IN MSG.
FIND2:	CALL GETWD		;GET ANOTHER WORD
	JUMPE B,FIND2		;IF NULL LOOK FOR NON-NULL
	BKJFN			;BACK UP TO BEFORE NON-NULL WORD
	 MOVE A,JFN		;IGNORE ERROR SET UP JFN AGAIN
UPTOP:	MOVEI B,7		;CHANGE BYTE SIZE TO 7
	SFBSZ
	 JFCL
	RFPTR			;GET POSITION IN FILE
	 JRST NODSK
	MOVEM B,BEGM		;SAVE IT
	MOVSI B,(IT%AIS)	;REQUIRE SECONDS IN TIME OF MSG
	IDTIM			;GET TIME STAMP OF MSG
	 SKIPA			;FAILED TRY BINARY
	JRST TXTLP1		;TEXT FORMAT FILE GO PROCESS
	HRRZ A,JFN
	MOVE B,BEGM		;GET START OF MESSAGE
	SFPTR			;SET FILE POSITION
	 JRST NODSK
	MOVEI B,44		;THE BYTE SIZE TO LOOK AT POST MARKS
	SFBSZ			;DO IT
	 JFCL			;??
	CALL GETWD		;READ POST MARK
	CAMGE B,TIME		;PRINT IT?
	JRST FIND		;NO

;FOUND ONE TO DO

	SKIPLE STOP		;WANT TO PAUSE?
	CALL STOPW		;WAIT FOR GO AHEAD
NOSTOP:	MOVSI A,(1B0)		
	ANDCAM A,STOP		;MAKE STOP POSITIVE
	SKIPN PRUSE		;PERUSONG?
	JRST MORE		;NO, GO DO NEXT
	HRRZ A,JFN		;THE FILE ID
	MOVEI B,7		;THE DESIRED BYTE SIZE
	SFBSZ			;SET IT TO THIS
	 JFCL			;IT SHOULD WORK
	CALL DOPRSE		;YES. SO GO DO IT
	HRRZ A,JFN
	MOVEI B,44		;THE BYTE SIZE TO LOOK AT POST MARKS
	SFBSZ			;DO IT
	 JFCL			;??
	JRST EMORE		;DO NOT PRINT REST OF MESSAGE


;GET WORD/CHARACTER FROM FILE AND TEST FOR EOF

GETWD:	MOVE A,JFN		;GET INPUT JFN
	BIN			;GET ANOTHER WORD/CHARACTER
	JUMPN B,[ RET]		;GOOD DATA?
	GTSTS			;NO. IS IT EOF?
	TLNE B,1000		;?
	JRST DONE		;YES. WRAP IT UP
	SETZM B			;RESTORE NULL IN B
	RET			;RETURN
;LOOP TO READ IN ENTIRE TEXT OF MESSAGE

MORE:	PUSHJ P,PRNLW		;PRINT UNTIL END OF MSG  FOUND
EMORE:	MOVE A,JFN
	SKIPN PRUSE		;PERUSING?
	JRST UPTOP		;GET NEXT
	JRST FIND		;YES. SYNCH.

;PRINT UNTIL END OF MESSAGE IS FOUND

PRNLW:	CALL GETWD		;GET ANOTHER WORD
	CAMN B,[ASCII /=====/]	;TRAILER SEPERATOR
	JRST PRNLW2		;NO TRY NEXT WORD
PRNLW1:	CALL PUTWD		;PUT WORD ON OUTPUT DEVICE
	JRST PRNLW

PRNLW2:	CALL PUTWD		;PUT WORD ON OUTPUT DEVICE
	CALL GETWD		;GET ANOTHER WORD
	CAME B,[ASCIZ /=
/]				;LAST OF TRAILER
	JRST PRNLW1		;SOMEBODY MUST HAVE HAD ====== IN MSG.
	CALL PUTWD		;PUT WORD ON OUTPUT DEVICE
PRNLW3:	CALL GETWD		;GET ANOTHER WORD
	JUMPE B,PRNLW3		;IF NULL LOOK FOR NON-NULL
	BKJFN			;BACK UP TO BEFORE NON-NULL WORD
	 MOVE A,JFN		;IGNORE ERROR SET UP JFN AGAIN
	POPJ P,			;YES, RETURN

;ROUTINE TO PUT A WORD OUT AS BYTE ON OJFN

PUTWD:	MOVE A,OJFN		;OUTPUT JFN
	MOVE D,B		;MOVE BYTE
	HRROI B,D
	MOVNI C,5		;DO ALL FIVE BYTES
	SOUT			;OUPUT TO TTY
EPRNLW:	RET



;SUBROUTINE TO WAIT FOR GO AHEAD ON STOP

STOPW:	PROMPT <[Type <CR> for more] >
	CONFRM			;WAIT FOR CONFIRMATION
	POPJ P,			;RETURN


;SUBROUTINE TO CLEAR MAP FOR BIGSTR

CLRSTR:	SETO A,
	MOVE B,[.FHSLF,,BIGSTR/1000]
	SETZ C,			;ONLY ONE PAGE PLEASE
	PMAP			;CLEAR MAP
	RET			;AND DONE
;HERE WHEN FIRST WORD OF FILE IS FOUND TO BE NON-ZERO.

TXTFRM:	MOVE A,JFN		;GET JFN BACK
	HRLI A,(1B0)		;HAVE TO CLOSE AND REOPEN IT TO
	CLOSF			; GET THE RIGHT LENGTHS
	 JRST OPNFAL		; CAN'T CLOSE IT?
	HRRZ A,JFN		;RH ONLY
	MOVE B,[070000,,200000]	;RE-OPEN IN SEVEN-BIT BYTES
	SKIPE PRUSE		;DOING PERSUE ONLY?
	TXO B,OF%PDT		;YES. SUPPRESS REFERENCE UPDATE
	OPENF
	 JRST OPNFAL
	SETO B,			;NOW SELECT EOF
	SFPTR			; ..
	 JRST NODSK
	RFPTR			;AND FIND WHERE EOF IS
	 JRST NODSK
	MOVEM B,FILLEN		;UPDATE TO LENGTH OF FILE
	MOVEI B,0		;START OF FILE
	SFPTR			;AND MOVE JFN POINTER BACK WHERE IT WAS
	 JRST NODSK
	SETZM BEGM		;SAY AT BEGINING OF FILE
	MOVSI B,(IT%AIS)	;REQUIRE SECONDS IN TIME OF MSG
	IDTIM			;GET TIME STAMP OF MSG
	 JRST TXTOLY		;NOT TIME STAMP MUST BE TEXT FILE.
	MOVEM B,THISDT		;SAVE DATE/TIME WORD
	HRROI A,BIGBUF		;NOW CHECK TO SEE IF ARPA SYSTEM
	SETZ B,			;BY TRYING ARPA ONLY JSYS
	CVHST			;CONVERT HOST NUMBER TO NAME
	 ERJMP NOARPA		;NOT ARPANET GO FIX UP TO DO BACKWARDS SCAN
	MOVE A,JFN		;THE JFN OF THE MESSAGE FILE
	JRST TXTLP2		;CONTINUE PROCESSING THIS MESSAGE
TXTLP:	MOVSI B,(IT%AIS)	;REQUIRE SECONDS IN TIME OF MSG
	IDTIM			;GET TIME STAMP OF MSG
	 JRST BADFRM		;NOT IN REQUIRED FORMAT
TXTLP1:	MOVEM B,THISDT		;SAVE DATE/TIME WORD
TXTLP2:	MOVEI C,12		;NOW CHARACTERS IN DECIMAL
	NIN
	 JRST BADFRM		;NOT IN REQUIRED FORMAT
	MOVEM B,SKIPCH		;SAVE NUMBER CHARS IN THIS MSG
	HRROI B,BIGSTR		;SCRATCH SPACE
	MOVEI C,100		;MAX OTHER STUFF ON LINE 1
	MOVEI D,12		;QUIT AT END OF LINE
	SIN
	JUMPE C,BADFRM		;IF READ THAT MUCH, IT'S JUNK.
	MOVE B,THISDT		;NOW CHECK THE DATE
	CAMGE B,TIME		;MESSAGE NEW ENOUGH TO PRINT?
	JRST NXTMS1		;NO, SKIP IT.
	PUSHJ P,COPY		;YES, PUT IT ON OUTPUT FILE
				;...
;DO NEXT MESSAGE IF THERE IS ONE

NXTMSG:	MOVE A,OJFN		;WAIT IF ON TTY
	CAIN A,.PRIOU
	DOBE			;WAIT IF ON PRIMARY
NXTMS1:	MOVE A,JFN		;THE MAIL FILE
	RFPTR			;WHERE ARE WE
	 JRST NODSK
	ADD B,SKIPCH		;ADD THE AMOUNT IN MSG
	SFPTR			;MOVE BEYOND THIS MESSAGE
	 JRST NODSK
	MOVEM B,BEGM		;SAVE START OF NEXT MESSAGE
	GTSTS			; IF FIND A NULL
	TLNE B,1000		; ..
	JRST DONE		;EOF. QUIT.
	MOVE B,BEGM		;GET BACK CURRENT POINTER
	IDIVI B,5		;ARE WE ON A WORD BOUNDRY
	JUMPN C,TXTLP		;NOT WORD BOUNDRY, GO PARSE ANOTHER ONE
	MOVEI B,44		;THE BYTE SIZE TO LOOK AT POST MARKS
	SFBSZ			;DO IT
	 JFCL			;??
	JRST FIND2		;IF WORD BOUNDY MAY BE MIXED FORMAT FILE


;GET HERE IF ARAPNET JSYS FAILED

NOARPA:	MOVEI A,.FHSLF		;MAKE SURE IT FAILED FOR RIGHT REASON
	GETER			;GET LAST ERROR FOR SELF
	HRRZS B			;JUST ERROR CONDITION
	MOVE A,JFN		;GET JFN OF FILE BACK
	CAIE B,ILINS2		;WAS IT ILLEGAL JSYS
	JRST TXTLP2		;NO GO BACK TO PROCESSING MESSAGE
	SETZM B
	SFPTR			;SET FILE POINTER BACK TO BEGINING
	 JRST NODSK
	MOVEI B,44		;SET BYTE SIZE BACK TO 36 BITS
	SFBSZ
	 JRST NODSK
	JRST LKTOP		;GO SET UP FOR BACKWARD SCAN
	
;MORE OF TEXT-FORM MAIL FILE PROCESSING

BADFRM:	SETZM SKIPCH		;DON'T TRY TO SKIP THE MSG
	HRROI A,[ASCIZ /
%File contains undated entries or improper format.
/]
	AOSN FRMERC		;PRINT THIS MESSAGE JUST ONCE
	PSOUT
	MOVE A,JFN		;NOW GO BACK TO START OF THE JUNK
	MOVE B,BEGM
	SFPTR
	 JRST NODSK
BADF1:	MOVE A,JFN		;NOW GO A LINE AT A TIME
	BIN			;CHECK FOR EOF FIRST
	JUMPE B,[GTSTS		; IF FIND A NULL
		TLNE B,1000	; ..
		JRST DONE	;EOF. QUIT.
		JRST BADF1]	;NULL. IGNORE IT.
	MOVE A,OJFN		;COPY THE BAD CHAR TO OUTPUT
	BOUT
	CAIN B,12		;LINEFEED?
	JRST NXTMS1		;YES. SEE IF CAN PARSE HERE.
	JRST BADF1		;NO, GO ON IN THE JUNK.


NODSK:	HRROI A,[ASCIZ /
? Input file is not DSK:
/]
	ESOUT
	JRST DONE
COPY:	SKIPLE STOP		;WANT TO PAUSE?
	CALL STOPW		;WAIT FOR GO AHEAD
	MOVSI A,(1B0)		
	ANDCAM A,STOP		;MAKE STOP POSITIVE
	MOVE A,OJFN		;WRITE THE CURRENT MESSAGE ON
	CAIN A,.PRIOU		;THE OUTPUT FILE.
	DOBE
	MOVEI C,0		;GET MESSAGE LENGTH
	EXCH C,SKIPCH		;AS A POSITIVE NUMBER
	MOVE A,JFN		;GET THE JFN
	RFPTR			;GET CURRENT POSITION
	 JRST NODSK
	ADD B,C			;GET END OF MESSAGE
	MOVEM B,BEGM		;SAVE IT
	SKIPE PRUSE		;PERUSING?
	JRST COPYP		;YES
COPY1:	MOVE A,JFN		;INPUT
	BIN			;GET FIRST CHAR
	JUMPE B,COPY4		;CHECK FOR EOF
	MOVE A,OJFN		;PUT THE BYTE ON OUTPUT FILE
	BOUT
COPY2:	SOJG C,COPY1		;LOOP FOR ALL N CHARACTERS
	POPJ P,0		;END OF COPY ROUTINE

;ANY REORGANIZATION OF CODE IN THIS AREA SHOULD BE DONE IN CONSIDERATION
;OF THE SKPMSG ROUTINE.

COPY4:	GTSTS			;CHECK FOR EOF AGAIN
	TLNE B,1000
	JRST [POP P,A		;BYPASS THE RETURN FROM COPY
	      JRST DONE]
	JRST COPY2		;A NULL IN MESSAGE. SKIP IT.


COPYP:	CALL DOPRSE		;GO PERUSE FILE
COPYE:	MOVE A,JFN		;GET THE JFN BACK
	MOVE B,BEGM		;AND BEGINING OF NEXT MESSAGE
	SFPTR
	 JRST NODSK
	POPJ P,0		;END OF COPY ROUTINE


;HERE TO PRINT FILE THAT IS ALL TEST

TXTOLY:	MOVE A,FILLEN		;GET LENGTH OF FILE
	MOVEM A,SKIPCH		;SAVE AS LENGTH TO PRINT
	CALL COPY		;GO PRINT IT
	JRST DONE
;CODE TO DO THE PERUSE OF THE RELEVANT MESSAGES

DOPRSE:	HRROI B,BIGBUF		;WHERE THE DATA SHOULD GO
	HRRZ A,JFN		;THE FILE ID
	MOVEI C,-1		;LOTS OF BYTES
	MOVEI D,12		;UP TO THE END OF THE LINE
	SIN			;DO IT
	LDB A,[POINT 7,BIGBUF,6] ;GET FIRST CHARACTER
	CAIN A,15		;NULL LINE
	JRST DOPRS1		;GO FINISH UP
	MOVE A,OJFN		;GET OUTPUT JFN
	HRROI B,BIGBUF		;WHERE THE DTAT IS
	MOVEI C,-1		;LOTS OF BYTES
	MOVEI D,12		;UP TO THE END OF THE LINE
	DOBE
	SOUT			;DO IT
	JRST DOPRSE		;NO GO DO ANOTHER LINE

DOPRS1:	HRROI A,[ASCIZ /
/]
	PSOUT			;CLEAN UP THE LINE
DOPRSX:	POPJ P,			;RETURN

;INTERRUPT CODE TO STOP PRINITING A MESSAGE

SKPMSG:	MOVEM A,SAVACS		;SAVE SOMRE AC'S FOR WORKING
	HRRZ A,ADD1		;GET INTERRUPTED ADDRESS
	CAIL A,PRNLW		;PRINTING A MESSAGE?
	CAILE A,EPRNLW		;"
	JRST SKPMS1		;CHECK OTHER ROUTINES
	MOVE P,[IOWD STKSIZ,STACK] ;CLEAR STACK
	MOVEI B,FIND
SKPMSE:	MOVEI A,101		;YES. LET'S RID HIM OF THE GARBAGE
	CFOBF			;DO IT
	MOVEM B,ADD1		;NEW START ADDRESS
	RFMOD			;GET THE MODE WORD
	TXZ B,TT%OSP		;TURN OUTPUT BACK ON
	SFMOD
	DEBRK			;AND GO TO IT

SKPMS1:	CAIL A,COPY1		;IN COPY ROUTINE
	CAIL A,COPYE
	JRST SKPMS2		;TRY NEXT ROUTINE
	MOVEI B,COPYE		;GO FIX UP FILE POINTER
	JRST SKPMSE		;AFTER STOPPING OUTPUT

SKPMS2:	CAIL A,DOPRSE		;PERUSEING?
	CAILE A,DOPRSX
	JRST [	MOVE A,SAVACS	;NO. GO BACK IN LINE
		DEBRK]
	MOVEI B,DOPRSX		;GO END IT
	JRST SKPMSE
;THIS IS THE OCDE TO PRINT THE HELP MESSAGE

.H:	SETOM HLPFLG		;SAY HELP WANTED
	RET

HLPOUT:	HRROI A,HLPTXT
	PSOUT
	POPJ P,		;ALL DONE HELPING
HLPTXT:	ASCIZ ^
Type in a date and time in TOPS-20 format as follows:

		MMM DD,YYYY HH:MM
or
		MMM DD,YYYY

	The latter case will assume time 00:01.
	(For example, a valid date and time is MAR 16,1976 15:30)

or	Type an empty line and get all messages since the last
	reading of the message file.

/H Print this text
/A Types all messages in the file
/P For perusing messages only
/S Will cause RDMAIL to pause after each message typed
/M Will use the message of the day file for message type out
/L Will output messages to the line printer

^
;ALL DONE

DONE:	CLOSF			;CLOSE THE FILE
	 JFCL
	MOVE A,OJFN		;GET OUTPUT JFN
	CLOSF			;CLOSE IT
	 JFCL
	HALTF
	JRST START		;START OVER
START2:	RESET
	MOVEI A,.PRIOU		;DEFAULT OUTPUT
	MOVEM A,OJFN
	SETZM MOD		;ALREADY DOING MESSAGE OF THE DAY
	MOVE P,[IOWD STKSIZ,STACK]
	HRROI B,[ASCIZ /PS:<SYSTEM>MAIL.TXT/]
	MOVSI A,100001		;GET MESSAGE OF THE DAY FILE
	GTJFN			;GET JFN FOR IT
	 JRST [	HALTF		;NONE THERE. DIE QUIETLY
		JRST START]	;TRY AGAIN
	MOVEM A,JFN		;SAVE THE HANDLE
	SETZM FILFND		;SAY FOUND A MESSAGE FILE
	CALL SETPSI		;TURN ON PI'S
	JRST NOSWI		;TIME IS ALL SET UP. GO DO IT
;DO SPECIAL PROCESSING

SPAGN:	MOVEI A,.PRIIN
	CFIBF			;CLEAR INPUT ON ERROR
SPCIAL:	PROMPT <Special user (y or n)? >
	MOVEI A,[FLDDB. .CMKEY,CM%SDH,[	2,,2
					T NO,0
					T YES,-1],<YES or NO>,NO]
	CALL CFIELD		;GET ANSWER
	HRRE B,(B)		;GET 0 FOR NO AND -1 FOR YES
	JUMPE B,NOSPC		;NOT SPECIAL

;WANTS SPECIAL DIRECTORY. GO READ IT

	MOVEI A,.PRIIN
	RFCOC			; GET ECHO BITS
	TRZ C,3B19
	SFCOC
GETDIR:	PROMPT <User name: >
	MOVEI A,[FLDDB. .CMUSR]
	CALL CFIELD		;GET SPECIAL USER
	JRST DOFILE
;TURN ON PI'S

SETPSI:	MOVEI A,.FHSLF		;FO ME
	MOVE B,[LEVTAB,,CHNTAB]	;RELEVANT ADDRESSES
	SIR			;TELL MONITOR
	MOVSI B,(1B0)		;TURN ON CHANNEL 0 ONLY
	AIC			;DO IT
	MOVSI A,INTCAR		;GET THE INT CHARACTER
	ATI			;ASSIGN IT TO CHANNEL 0
	RET			;AND DONE
	END <ENDVEC-ENTVEC,,ENTVEC>