Google
 

Trailing-Edge - PDP-10 Archives - bb-d868a-bm - 3-sources/rdmail.mac
There are 20 other files named rdmail.mac in the archive. Click here to see a list.
;<3-UTILITIES>RDMAIL.MAC.7,  9-Nov-77 16:07:39, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<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) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH MONSYM,MACSYM
	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==0			;MINOR VERSION
PRGEDT==6			;EDIT NUMBER
PRGCST==0			;DEC SOFTWARE

;LOCAL STORAGE
INTCAR==5			;INTERRUPT CHARACTER

STKSIZ==20
TXTARG: 6
FLAGS:	0
	100,,101
BUFFER:	0
COUNT:	0
SBUFFER: 0
RBUFF:	0
STACK:	BLOCK STKSIZ
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
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

	RELOC 1000-140
START:	RESET
	MOVEI A,.PRIOU		;DEFAULT OUTPUT JFN
	MOVEM A,OJFN
	MOVE P,[IOWD STKSIZ,STACK]
	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


	HRROI A,[ASCIZ "Date and time  (/H for help) "]
	HRROI B,BIGSTR		;START OF BUFFER AREA
	SETZ C,			;COPY WHOLE STRING
	SIN			;DO IT
	SETZM RLDATE		;NO REAL DATE YET
GETDAT:	SETZM PRUSE		;ASSUME NO PERUSING
	SETZM STOP		; ASSUME NO STOPPING
	SETZM MOD		;NOT DOING MESSAGE OF THE DAY
	SETZM BIGBUF
	HRROI A,BIGSTR
	PSOUT
	HRROI A,BIGBUF		;THE BUFFER
	MOVE B,[RD%BEL!RD%RND+200] ;RDTTY STUFF
	HRROI C,BIGSTR		;^R ECHO
	RDTTY			;GET SOME INPUT
	 JFCL			;CANT HAPPEN
	TLNN B,(RD%BTM)		;SAW A TERMINATOR?
	JRST GETDAT		;NO. REPROMPT
	MOVE A,[POINT 7,BIGBUF] ;START OF INPUT
PURGBL:	ILDB B,A		;GET A BYTE
	CAIE B," "		;BLANK?
	CAIN B,"	"	;OR TAB?
	JRST PURGBL		;YES. KEEP PURGING
	CAIE B,12		;LF?
	CAIN B,15		;OR CR?
	JRST STROFF		;YES. GO ON THEN
	BKJFN			;USE THE LAST BYTE
	 JFCL
	SETZB B,C		;NO. GET READY TO DO DATE ANALYSIS
	SETZ D,			;ALL FOR IDCNV
	MOVSI B,(1B6)		;GET DATE FIRST
	IDTNC			;GET IT
	 JRST [	LDB W,A		;LOOK AT IT
		CAIE W,"?"	;WANT HELP/
		CAIN W,"/"	;OR SPECIFYING HELP?
		JRST SEESWT	;YES. GO DO THE RIGHT THING
		JRST ILLSEP]	;BOMB
	LDB W,A			;LOOK AT THE TERMINATOR
	CAIN W,"/"		;WITCH?
	JRST SEESWT		;YES. GO DO IT THEN
	DMOVE W,B		;SAVE GOOD BITS FROM IDTNC
	MOVSI B,(1B0)		;NOW DO THE TIME
	IDTNC			;SO, DO IT
	 JFCL			;AGAIN, USE WHATEVER WAS GENERATED
SET1:	DMOVE B,W		;GET BACK DATE BITS
	PUSH P,A		;SAVE FINAL STRING POINTER
	IDCNV			;CONVERT TO INTERNAL
	 JRST [	MOVEI A,100
		MOVE B,[400000,,-1]
		SETZ C,
		ERSTR		;REPORT THE ERROR
		 JFCL
		 JFCL
		JRST GETDAT]	;TRY AGAIN
	MOVEM B,TIME		;NEW TIME
	SETOM RLDATE		;A DATE WAS TYPED IN
	POP P,A			;GET BACK STRING POINTER
	LDB B,A			;GET THE TERMINATOR
MORE1:	CAIE B,"/"		;SWITCH?
	JRST STROFF		;NO. FORGET REST OF LINE THEN
	PUSHJ P,DOSWT		;GO DO THE SWITCH
	JRST GETDAT		;CANCEL LINE
	ILDB B,A		;GET NEXT BYTE
	JRST MORE1		;AND GO LOOK AT IT

;READY TO PROCESS THE FILE

STROFF:	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?
	TRO B,1B27		;YES. DONT SET ACCESS DATES OF FILE
	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:	MOVEI A,.PRIOU		;GET OUTPUT JFN
	DOBE			;WAIT ON OUT PUT
	RFMOD			;GET THE MODE WORD
	TXZ B,TT%OSP		;TURN OUTPUT BACK ON
	SFMOD
	HRROI A,[ASCIZ /
[Type <CR> for more] /]
	PSOUT			;TELL HIM
	HRROI A,BIGBUF		;A BUFFER
	MOVEI B,100		;A COUNT
	SETZ C,			;NO ^R
	RDTTY			;WAIT HERE
	 JFCL
	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
	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.
	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
	JRST TXTLP1		;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
	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
	GTSTS			; IF FIND A NULL
	TLNE B,1000		; ..
	JRST DONE		;EOF. QUIT.
	MOVEM B,BEGM		;SAVE IT
	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 TXTLP1		;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
;THIS CODE IS CALLED WHENEVER IDTNC FAILS OR AT THE END OF
;ALL TIME PROCESSING T LOOK FOR AND PROCESS ANY SWITCHES

SEESWT:	DMOVE W,B		;SAVE DATA
	LDB B,A			;LOOK AT TERMINATOT THAT IDTNC FOUND
	CAIN B,"?"		;DOES HE NEED HELP?
	JRST [	PUSHJ P,HLPOUT	;GIVE HIM SOME HELP
		JRST GETDAT]	;CANCEL LINE
	CAIE B,"/"		;SWITCH?
ILLSEP:	JRST [	HRROI A,[ASCIZ "
?Illegal separator in date/time field
"]
		PSOUT		;NO. COMPLAIN
		JRST GETDAT]	;GO START OVER
	PUSHJ P,DOSWT		;YES. GO PROCESS THE SWITCH
	JRST GETDAT		;CANCEL LINE
	TRNN W,600000		;ERROR RETURN FROM IDTNC?
	JRST [	IBP A			;NO.FAKE THE TERMINATOR
		JRST SET1]	;AND GO DO CONVERSIONS
	JRST PURGBL		;AND GO DO THE DATE AGAIN

DOSWT:	ILDB B,A		;GET SWITCH VALUE
	CAIE B,"H"		;WANT HELP?
	CAIN B,"H"+40		;OR IN LOWER CASE?
	JRST HLPOUT		;YES. GO HELP HIM THEN
	CAIE B,"L"		;WANT OUTPUT TO LPT?
	CAIN B,"L"+40		;OR THIS WAY?
	JRST [	AOS (P)		;YES
		PUSH P,A	;SAVE BP
		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
			POP P,A
			RET]	;IGNORE IT
		MOVE B,[070000,,100000]
		OPENF		;OPEN LPT
		 JRST [	HRROI A,[ASCIZ /
?LPT: not available for output
/]
			PSOUT
			POP P,A
			RET]	;GIVE UP
		MOVEM A,OJFN	;NEW OUTPUT JFN
		POP P,A		;RESTORE BP
		RET]		;DONE
	CAIE B,"P"		;WANT TO PERUSE?
	CAIN B,"P"+40		;OR IN LOWER CASE?
	JRST [	SETOM PRUSE	;YES. SET THE FLAG
		AOS (P)
		POPJ P,]	;GOOD RETURN
	CAIE B,"A"		;WANT ALL MESSAGES?
	CAIN B,"A"+40		;OR IN LOWER CASE?
	JRST [	SETZM TIME	;YES.
		SETOM RLDATE	;AND SAY FOUND A REAL TIME
		AOS (P)
		POPJ P,]	;AND GIVE GOOD RETURN
	CAIE B,"S"		; STOP ON EACH MESSAGE?
	CAIN B,"S"+40		; OR IN LOWERCASE?
	JRST [	SETOM STOP	;YES REMEMBER THIS
		AOS (P)		; GOOD RETURN
		POPJ P,]	; AND GO BACK
	CAIE B,"M"		;WANT SYSTEM MESSAGE?
	CAIN B,"M"+40		;""
	JRST [	SETOM MOD	;YES. REMEMBER THIS
		AOS (P)		;GOOD RETURN
		SKIPE RLDATE	;HAVE A REAL DATE YET?
		POPJ P,		;YES. ALL DONE THEN
		PUSH P,A	;SAVE BYTE POINTER
		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
		POP P,A		;RESTORE BYTE POINTER
		POPJ P,]	;GO BACK
	MOVE B,A
	HRROI A,[ASCIZ /
?Illegal switch
/]
	PSOUT
	MOVE A,B
	AOS (P)
	POPJ P,
;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

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 STROFF		;TIME IS ALL SET UP. GO DO IT
;DO SPECIAL PROCESSING

SPAGN:	MOVEI A,.PRIIN
	CFIBF			;CLEAR INPUT ON ERROR
SPCIAL:	HRROI A,[ASCIZ /
Special user (y or n)? /]
	PSOUT			; ASK HIM
	HRROI A,W		; USE A REGISTER
	MOVE B,[RD%BEL+RD%RBF+3] ;ONLY ANSWER
	HRROI C,[ASCIZ /Special user (y or n)? /]
	RDTTY			; READ IT
	 JFCL
	TLNN B,(RD%BTM)		; GOT A BREAK?
	JRST SPAGN		;NO - ERROR
	LDB A,[POINT 7,W,6]	; GET ANSWER
	CAIE A,12		;NULL?
	CAIN A,15		;?
	JRST NOSPC		; YES. ASSUME NO SPECIAL
	TRZ A,40		; RAISE IT
	CAIN A,"N"		; WANT SPECIAL?
	JRST NOSPC		; NO
	CAIE A,"Y"		; WANT IT?
	JRST SPAGN		; MUST SAY SOMETHING

;WANTS SPECIAL DIRECTORY. GO READ IT

	MOVEI A,.PRIIN
	RFCOC			; GET ECHO BITS
	TRZ C,3B19
	SFCOC
GETDIR:	HRROI A,[ASCIZ /
User name: /]
	PSOUT
	MOVE A,[RD%BRK+RD%BEL+RD%RBF+RD%JFN+200]
	MOVEM A,FLAGS
	HRRM A,COUNT
	HRROI A,BIGBUF
	MOVEM A,BUFFER
	MOVEM A,SBUFFER		; START OF BUFFER
	HRROI A,[ASCIZ /Directory name: /]
	MOVEM A,RBUFF		; ^R BUFFER
DOTXT:	MOVEI A,TXTARG	;ARG BLOCK
	TEXTI
	 JFCL
	MOVE B,FLAGS
	TLNN B,(RD%BTM)		; FOUND A BREAK?
	JRST NOSPC		; NO. FORGET IT THEN
	MOVE A,BUFFER
	SETZ D,			; GET A NULL
	LDB W,A			; GET TERM
	DPB D,A			; TIE OFF STRING
	MOVE W1,A		; SAVE A
	CAIN W,33		; WANT RECOG?
	JRST DOIT		; YES. GO DO IT NOW
	BKJFN			; NO. BACK IT UP
	 JFCL
	LDB W,A			; GET PREV
	CAIN W,15		; A CRLF?
	DPB D,A			; YES TIE THIS TOO
	SKIPA A,[RC%EMO]	; NO RECOGNITION
DOIT:	MOVX A,RC%PAR		;ALLOW PARTIAL RECOG
	HRROI B,BIGBUF		; THE STRING
	RCUSR
	 ERJMP AGAIN
	TXNE A,RC%NOM		;NO MATCH?
	JRST AGAIN		;TRY AGAIN
	TXNE A,RC%AMB		;AMBIGUOUS?
	 JRST [	MOVE A,BUFFER
		BKJFN
		 JFCL
		MOVEM B,BUFFER
		PSOUT		;FINISH OUT PARTIAL TEXT
		MOVEI A,""
		PBOUT		; DING HIM
		JRST DOTXT]	;AND TRY SOME MORE
	MOVE D,C		; SAVE NUMBER
	CAIE W,33		; DOING RECOG?
	JRST GETNUM		; NO
	HRROI A,BIGBUF		; WHERE TO FINISH STRING
	MOVE B,C		;COPY NUMBER TO B
	DIRST			; GET FULL STRING
	 JFCL
	MOVE A,W1
	BKJFN
	 JFCL
	PSOUT			; FINISH UP THE STRING
	HRROI A,[ASCIZ /
/]
	PSOUT
GETNUM:	MOVE B,D		;NUMBER TO RETURN
	JRST DOFILE


AGAIN:	HRROI A,[ASCIZ / ?/]
	PSOUT
	JRST GETDIR		;ONCE MORE
;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>