Google
 

Trailing-Edge - PDP-10 Archives - BB-D868C-BM - 4-sources/mail.mac
There are 20 other files named mail.mac in the archive. Click here to see a list.
;<4.UTILITIES>MAIL.MAC.30,  3-Jan-80 15:25:56, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<4.UTILITIES>MAIL.MAC.29, 29-Oct-79 14:56:42, EDIT BY OSMAN
;SSAY => SAY
;<4.UTILITIES>MAIL.MAC.28,  2-Jul-79 12:37:40, EDIT BY R.ACE
;FIX SPELLING OF "OCCURRED"
;<4.UTILITIES>MAIL.MAC.27, 10-Mar-79 14:04:03, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.UTILITIES>MAIL.MAC.26, 26-Feb-79 16:47:31, EDIT BY DBELL
;ON A BUSY MAIL.CPY, REDO THE GTJFN SINCE OTHERWISE OPENF CAN ALWAYS FAIL.
;<4.UTILITIES>MAIL.MAC.25, 20-Feb-79 16:30:55, EDIT BY DBELL
;TCO 4.2194 - HANDLE BUSY MAIL.CPY FILES
;<4.UTILITIES>MAIL.MAC.24, 24-Jan-79 12:38:16, Edit by KONEN
;REQUIRE CMD.REL TO BE IN DSK:
;<4.UTILITIES>MAIL.MAC.23,  5-Oct-78 16:15:41, EDIT BY HALL
;IN RETRY, CALL COMND WITH FUNCTION .CMIFI INSTEAD OF .CMOFI FOR
; MAIL.CPY
;<4.UTILITIES>MAIL.MAC.22, 30-Aug-78 09:55:20, EDIT BY COWER
;FIXED PROBLEM WHERE MAIL CAN FIND MAILER NOT RUNNING WHEN IT IS
;IN AGAIN:
;<4.UTILITIES>MAIL.MAC.20,  4-Aug-78 16:57:42, EDIT BY OSMAN
;DON'T KEEP SAYING "TYPE MESSAGE..." ON EVERY ^R OF FIRST MESSAGE LINE
;<OSMAN>MAIL.MAC.1,  3-Aug-78 11:33:57, EDIT BY OSMAN
;ALLOW CR WITHOUT COMMA IN INDIRECT FILE LIST OF USER NAMES (USED TO WORK)
;<4.UTILITIES>MAIL.MAC.13, 24-May-78 14:33:21, EDIT BY OSMAN
;STORE USERS RIGHT IN BIGBUF, NO NEED TO BLT FROM USRBLK
;<4.UTILITIES>MAIL.MAC.2, 18-May-78 15:40:55, EDIT BY OSMAN
;USE COMND JSYS
;<4.UTILITIES>MAIL.MAC.1, 12-Nov-77 18:02:58, EDIT BY MILLER
;MAKE SURE MESSAGE ENDS WITH CRLF. AT SALUTATION FILE




;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,1979,1980 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

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

;PROGRAM VERSION DEFINITIONS

PRGVER==4			;VERSION
PRGEDT==6			;EDIT
PRGMIN==0			;MINOR VERSION
PRGCST==0			;CUSTOMER ID


DEFINE ASSIGN(A,B,C)
<A=B
B==B+C
>
;DEFINE REGISTERS

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

;DEFINE VALUES IN F

S.PRF==1
S.END==2
S.SAW==4
S.BLA==10
S.ERR==20

NACK1==2			;TOATL WIPEOUT FORM MAILER
NACK2==3			;QUOTA EXCEEDED

;LOCAL STORAGE

CMDSTG				;COMND JSYS STORAGE
DATA==100000
USERS==^D100
PDSL==^D200			;SIZE OF PDL
SPTR:	0			;BYTE POINTER TO END OF MESSAGE AREA SO FAR
SAVW:	Z 0
PARTRM:	Z 0
SAVCNT:	Z 0
SYSCOD==-2			;SPECIAL SYSTEM CODE
NOACKB==0			;DEFAULT MESSAGE TYPE
MINMSG==1			;FIRST ERROR MESSAGE
MSGTBL:	[ASCIZ / Quota exceeded/]
MAXMSG==.-MSGTBL+MINMSG		;LAST MESSAGE +1

PIDGET:	IP%CPD			;GET PID
	0
	0			;TO INFO
	ENDMSG-.,,.+1		;FOR INFO
	1,,1			;GET PID FOR NAME
	0			;NO COPY
	ASCIZ /[SYSTEM]MAILER/
ENDMSG:
CPYJFN:	BLOCK 1
BUSYCT:	BLOCK 1			;BUSY COUNTER FOR OPENF
PDL:	BLOCK PDSL
SIZE==1000*^D50			;STRING AREA
ASSIGN BIGBUF,DATA,SIZE
USRBLK=BIGBUF+1
CURR:	Z 0			;SAVE CURRENT STRING POINTRE
DIRSTR:	BLOCK ^D32		;FOR FILE NAME
ASSIGN HOLD,DATA,100000		;FOR OLD MESSAGES

;DEFINE ENTRY VECTOR

ENTVEC:	JRST START		;MAIN ENTRY
	JRST RETRY		;REENTER POINT
	PRGVER_^D24+PRGMIN_^D18+PRGEDT+PRGCST_^D33

;CODE

START:	RESET			;CLEAR THE WORLD
	MOVE P,[IOWD PDSL,PDL]	;STACK
	CALL CMDINI		;INITIALIZE COMND JSYS
	MOVE A,[ASCII /PS:</]	;GET DEVICE STRING
	MOVEM A,BIGBUF		;PUT IT IN THE BUFFER
	GJINF			;GET LOGGED IN DIRECTORY
	MOVE B,A		;GET USER NUMBER
	MOVE A,[POINT 7,BIGBUF,27] ;WHERE TO PUT USER NAME
	DIRST			;GET THE NAME
	 JFCL
	HRROI B,[ASCIZ />MAIL.CPY/] ;THE FILE NAME
	SETZ C,
	SOUT			;MAKE NAME
	SETOM BUSYCT		;INITIALIZE BUSY COUNT
OPNLOP:	MOVX A,GJ%FOU!GJ%SHT
	HRROI B,BIGBUF		;WHERE NAME IS
	GTJFN			;GET A JFN
	 JRST CANT		;OOPS. FAILED
	MOVEM A,CPYJFN		;SAVE IT FOR LATER
	MOVX B,OF%RD+OF%WR	;WANT READ AND WRITE
	OPENF			;MAKE SURE IT WILL OPEN
	 JRST [	CAIE A,OPNX9	;ERROR, IS IT INVALID SIMULTANEOUS ACCESS?
		JRST CANT	;NO, GO LOSE
		HRROI A,[ASCIZ/
File MAIL.CPY is opened by another job, waiting.../]
		AOSN BUSYCT	;FIRST TIME?
		PSOUT		;YES, SAY WE'RE WAITING
		MOVEI A,^D1000	;GET SLEEP TIME
		DISMS		;WAIT A BIT
		MOVE A,CPYJFN	;RESTORE JFN
		RLJFN		;RELEASE IT
		JFCL
		JRST OPNLOP]	;AND TRY AGAIN
	HRROI A,[ASCIZ/OK
/]				;GET FINAL TEXT
	SKIPL BUSYCT		;DID WE EVER WAIT?
	PSOUT			;YES, SAY ALL DONE
	MOVX A,CM%WKF!CM%XIF	;NO SPECIAL WAKEUP, AND ALLOW STANDARD INDIRECT FILES UNTIL MESSAGE ITSELF
	ANDCAM A,SBK+.CMFLG	;TURN OFF CM%XIF IN FLAGS WORD
	PROMPT <To: >
	MOVSI W,-USERS		;AOBJN POINTER TO LIST
	MOVEI A,1		;READING TO'S
	PUSHJ P,REAL		;CONVERT TO NUMBERS
	PROMPT <CC: >
	MOVEI A,0		;NOT READING TO'S NOW
	PUSHJ P,REAL		;YES. CONVERT EM
	MOVEI B,USRBLK(W)	;WHERE TO START IN BIGBUF
	SETZM BIGBUF		;NO FLAGS BY DEFAULT
	HRLI B,440700		;SP FOR TEXT
	MOVEM B,SPTR		;REMEMBER POINTER
	JRST DOSTUF		;AND GO DI IT
REAL:	STKVAR <LLEN,LLEN2,MPTR,PPTR,SELF,ITEM,TWOFLG,COMFLG>
	SETZM COMFLG		;NO COMMA SEEN YET
	MOVEM A,TWOFLG		;REMEMBER WHETHER READING TO'S OR NOT
	GJINF			;GET USER NUMBER
	MOVEM A,SELF		;REMEMBER USER NUMBER
LOOP:	MOVEI A,[FLDDB. .CMCFM,,,,,[FLDDB. .CMUSR,CM%SDH,,<
Type user names separated by commas. The list is terminated
by a <CR>. The entire list may be read from a file by typing:

	@FILESPEC

Typing a "?" gives this message.
>,,[FLDDB. .CMTOK,CM%SDH,<-1,,[ASCIZ /./]>,,,[FLDDB. .CMKEY,CM%SDH,[
		1,,1
		T SYSTEM,0]]]]]
	SKIPN COMFLG		;COMMA WAS LAST?
	SKIPE TWOFLG		;OR DOING THE TO'S?
	MOVE A,(A)		;YES, SO REQUIRE AT LEAST ONE NAME
	CALL RFLDE		;READ NAME
	 JRST NAMER		;FAILED, GO TRY TO PRINT GOOD ERROR
	LDB C,[331100,,(C)]	;SEE IF DOT TYPED
	ADJSP W,-1		;SO W POINTS AT LAST NAME IF WE GO TO FINNAM
	CAIN C,.CMCFM		;END OF LINE?
	JRST FINNAM		;YES
	ADJSP W,1		;UNCLOBBER W TO POINT AT NEW SLOT
	CAIN C,.CMTOK
	MOVE B,SELF		;YES, USE SELF
	cain c,.cmkey		;user typed "system"?
	move b,[syscod]		;yes, use special code
	MOVEM b,USRBLK(W)	;STORE NUMBER
	MOVEI A,[FLDDB. .CMCFM,,,,,[FLDDB. .CMCMA]]
	CALL RFLDE		;GET COMMA OR END OF LINE
	 JRST R00		;NEITHER, MIGHT BE INDIRECT FILE WITH CR IN MIDDLE OF LIST!
	LDB C,[331100,,(C)]	;SEE WHICH
	CAIN C,.CMCFM		;END OF LINE?
	JRST FINNAM		;YES
R00:	SETOM COMFLG		;NO, SET COMMA FLAG
	AOBJN W,LOOP		;GET MORE
	HRROI A,[ASCIZ /
%Too many user names. 100 is maximum.
/]
	PSOUT			;TOO MANY. SAY SO
FINNAM:		MOVEI A,1(W)		;GET NUMBER OF ENTRIES IN LIST
	MOVEM A,LLEN		;REMEMBER
	SETZB A,MPTR		;POINTER TO ITEM BEING CHECKED
MLUP:	CAML A,LLEN		;ANY MORE TO CHECK?
	JRST CLENUP		;NO
	MOVE A,USRBLK(A)	;YES, GET NEXT ONE TO BE CHECKED
	MOVEM A,ITEM		;APPROACH THE BENCH!
	SETZB B,PPTR		;YES, RESET POINTER TO WHAT TO COMPARE IT TO
MLUP1:	CAML B,MPTR		;ABOUT TO COMPARE ITEM WITH ITSELF?
	JRST IOK		;YES, SO ITEM IS O.K.
	MOVE A,USRBLK(B)	;NO, GET NEXT ITEM FOR COMPARISON
	CAMN A,ITEM		;FOUND A DUPLICATE?
	JRST PURGE		;YES, GO GET RID OF IT
	AOS B,PPTR		;NO, KEEP SEARCHING
	JRST MLUP1

IOK:	AOS A,MPTR		;ITEM IS O.K., PROCEED WITH NEXT
	JRST MLUP

;GET HERE ON USER NAME ERROR

NAMER:	HRROI A,[ASCIZ /Invalid user name/]
	ESOUT			;TYPE ERROR MESSAGE
	JRST CMDER1		;GO BACK AND ALLOW ERROR CORRECTION

PURGE:	TMSG <%Duplicate name purged - >
	MOVE A,MPTR		;GET POINTER TO ITEM BEING PURGED
	MOVE B,USRBLK(A)	;GET USER NUMBER
	MOVEI A,.PRIOU
	DIRST			;PRINT NAME
	 JSERR			;SHOULDN'T FAIL
	TMSG <
>
	MOVE A,MPTR		;GET POINTER AGAIN
	SETOM USRBLK(A)		;SET NAME TO -1 TO REMEMBER IT'S BEEN PURGED
	JRST IOK		;CONTINUE SCANNING NAMES

CLENUP:	SETZB B,MPTR		;PREPARE TO REMOVE -1'S
	SETZM LLEN2		;INITIALIZE OTHER LENGTH (AFTER CLEANUP)
CLEN1:	CAML B,LLEN		;DONE CLEANING UP?
	JRST CLEN2		;YES
	MOVE A,USRBLK(B)	;NO, GET ENTRY
	AOJE A,CLEN3		;JUMP IF THIS ENTRY NEEDS REMOVING
	AOS B,LLEN2		;ENTRY O.K., COUNT IT
	SOJ A,			;FIX CLOBBERED NAME
	MOVEM A,USRBLK-1(B)
CLEN3:	AOS B,MPTR		;STEP TO NEXT ENTRY
	JRST CLEN1		;LOOP

CLEN2:	MOVE A,LLEN2
	SUB A,LLEN		;SEE HOW MUCH LIST SHRUNK BY
	ADJSP W,2(A)		;UPDATE LIST POINTER BUT LEAVE ROOM FOR NULL, AND INCREMENT TO NEXT FREE SLOT
	SETZM USRBLK-1(W)	;MARK END OF LIST WITH NULL
	RET			;ALL DONE
;DO MESSAGE STUFF

DOSTUF:	HRROI A,[ASCIZ /Subject: /]
	MOVE B,SPTR		;GET POINTER TO TEXT BUFFER
	SETZ C,
	SIN			;PUT IT IN
	MOVEM B,SPTR		;REMEMBER POINTER
	PROMPT <Subject: >
	MOVEI A,[FLDDB. .CMTXT,CM%SDH,,<
Type a single line terminated with a <CR> which summarizes
the message you are sending.
>]
	CALL CFIELD		;READ SUBJECT LINE AND CRLF
	MOVE A,SPTR		;STORE SUBJECT LINE
	HRROI B,ATMBUF
	MOVEI C,0
	SOUT
	HRROI B,[ASCIZ /

/]
	SOUT
	MOVEM A,SBK+.CMBFP	;USE LARGE BUFFER FOR MESSAGE
	MOVEM A,SBK+.CMPTR
	MOVEI A,SIZE*5		;LARGE NUMBER OF CHARACTERS ALLOWED IN MESSAGE
	MOVEM A,SBK+.CMCNT
	MOVX A,CM%WKF!CM%XIF	;WE WANT CONTROL ON ^Z, AND WE WANT TO INTERPRET @ OURSELF
	IORM A,SBK+.CMFLG
ONEMOR:	TMSG <Message (Terminate with ESC or CTRL/Z):

>
	PROMPT <>
	MOVEI A,[FLDDB. .CMTOK,CM%SDH,<-1,,[ASCIZ /@/]>,<
Type message and terminate with a CTRL/Z or an ESC. The message
may be read from a file by typing:

	@FILESPEC

Typing a "?" gives this message.
>,,[FLDDB. .CMUQS,,[EXP 1B<"">!1B<"">,0,0,0]]]
	CALL RFIELD		;READ @ OR THE MESSAGE ITSELF
	LDB C,[331100,,(C)]	;SEE WHAT WAS TYPED
	CAIN C,.CMTOK		;AN ATSIGN?
	JRST ATSIGN		;YES, GO GOBBLE INDIRECT FILE
READY5:	CALL READY4		;GO ALIGN THE FILE
	JRST READY		;AND GO DO IT

ATSIGN:	CALL GETFIL		;READ MESSAGE FROM FILE INTO BUFFER
	 JRST ONEMOR		;GIVE USER ONE MORE CHANCE
	JRST READY5		;FINISH AS THOUGH MESSAGE WERE TYPED

GETFIL:	STKVAR <FJFN,FPTR>
	MOVNI A,1		;WE WANT CONTENTS TO OVERWRITE "@"
	ADJBP A,SBK+.CMPTR	;GET POINTER TO WHERE FILE CONTENTS GOES
	MOVEM A,FPTR		;REMEMBER
	MOVEI A,[FLDDB. .CMIFI,CM%SDH,,<Name of message file>]
	CALL CFIELD		;GET FILESPEC
	MOVEM B,FJFN		;SAVE JFN
	MOVE A,B		;JFN IN A
	MOVE B,[070000,,200000]
	OPENF
	 JRST [	MOVE A,FJFN
		RLJFN
		 JFCL
		JRST NOFIL]	;COULDNT GET IT
	MOVNI B,1		;SET FILE POINTER TO EOF
	SFPTR			;DO IT
	 JFCL			;IT BETTER DO IT!
	RFPTR			;NOW SEE WHAT THE BYTE VALUE IS
	 JFCL			;AGAIN, NO QUARTER FOR SLAGGARDS
	MOVN C,B		;GET NEGATIVE OF BYTE COUNT
	SETZ B,			;GET IT BACK TO THE BEGINNING
	SFPTR			;AT LAST. WHAT A HACK.
	 JFCL
	MOVE B,FPTR		;GET PLACE TO PUT FILE
	SIN			;RAED IN WHOLE FILE
	MOVEM B,SBK+.CMPTR	;SAVE UPDATED POINTER
	CLOSF			;CLOSE THE FILE
	 JFCL
	RETSKP			;GIVE SKIP RETURN FOR SUCCESS

NOFIL:	HRROI A,[ASCIZ /
?Could not find file
/]
	PSOUT
	JSERR			;SAY WHY NOT
	POPJ P,			;RETURN BAD

;ALIGN THE END-OF-MESSAGE

READY4:	LDB A,SBK+.CMPTR	;GET TERMINATOR
	CAIE A,.CHLFD		;A LINE-FEED?
	JRST [	HRROI A,[ASCIZ /
/]
		SETZM C
		MOVE B,SBK+.CMPTR
		SIN
		MOVEM B,SBK+.CMPTR
		JRST .+1]
	MOVEI A,0
READY2:	MOVE B,SBK+.CMPTR
	TLNN B,700000		;AT THE END OF A WORD?
	RET			;DONE
	IDPB A,SBK+.CMPTR	;NO. PAD
	JRST READY2		;GO TEST SOME MORE

;MESSAGE IS IN BIGBUF. NOW SEND IT

READY:	MOVX A,GJ%OLD!GJ%SHT
	HRROI B,[ASCIZ /MAIL-SALUTATION:/]
	GTJFN			;HAVE AN APPEND FILE?
	 JRST RDYY		;NO. PROCEED
	MOVX B,<07B5+OF%RD>	;OPEN IT UP
	OPENF			;""
	 JRST RDYY		;COULDN'T.
	MOVE B,SBK+.CMPTR	;GET POINTER TO MESSAGE END SO FAR
	SETZM C			;GET ALL OF THE FILE
	SIN			;DO IT
	MOVEM B,SBK+.CMPTR	;UPDATE END OF MESSAGE POINTER
	CLOSF			;DONE WITH THE FILE
	 JFCL
	CALL READY4		;ALIGN IT
RDYY:	MOVE B,SBK+.CMPTR	;GET POINTER TO END OF MESSAGE
	SUBI B,BIGBUF		;BEGINNING OF MESSAGE
	MOVNI C,1(B)		;COUNT OF WORDS TO MOVE
	MOVE B,[POINT ^D36,BIGBUF] ;WRITE BY WORDS
	MOVE A,CPYJFN		;THE FILE TO PUT IT IN
	SOUT			;WRITE THE FILE
	TLO A,(1B0)
	CLOSF			;CLOSE THE FILE TO PRESERVE IT
	 JFCL
	MOVE B,A		;JFN IN B

;NOW SEND IPCF MESSAGE TO MAILER

;GET PID OF MAILER

RDYN:	PUSH P,B		;SAVE JFN
	SETZ W1,		;RETRY FLAG
	MOVSI A,(IP%CPD)	;CREATE PID
	MOVEM A,PIDGET		;REQUEST THIS FUNCTION
MALER:	SETZM PIDGET+1		;NO SENDER'S PID
RDYN1:	MOVEI B,PIDGET		;GET MAILER'S PID
	SETZM PIDGET+2		;NO RECEIVER'S PID
	MOVEI A,4		;THE COUNT
	MSEND
	 JRST [	SKIPN W1	;FIRST TRY?
		PUSHJ P,[MOVEI A,101 ;YES. PRINT SOME STUFF
			MOVE B,[400000,,-1] ;LAST ERROR
			SETZ C, ;NO FLAGS
			ERSTR	;TELL HIM
			 JFCL
			 JFCL
			HRROI A,[ASCIZ /  Waiting...
/]
			PSOUT	;TELL HIM WE ARE STILL HANGING IN THERE
			POPJ P,] ;GO BACK IN LINE
		AOS W1		;COUNT TRIES
		MOVEI A,^D500	;SLEEP TIME
		DISMS
		JRST MALER]	;GO TRY IT AGAIN
	MOVSI B,(IP%CPD)	;CREATE PID BIT
	ANDCAM B,PIDGET		;NOW HAVE A PID
GETAGN:	SETZB W,W1		;NO FLAGS,NO SENDER
	MOVE W2,PIDGET+1	;MY TEMP ID
	MOVE W3,[10,,BIGBUF]	;USE BUFFER
	MOVEI B,W		;WHERE RECIVE WILL BE
	MRECV			;GET IT PLEASE
	 JFCL			;HOW CAN THIS HAPPEN PMH?
	MOVE W1,W		;SAVE HEADER
	ANDI W,7B32		;ISOLATE FILED
	CAIE W,1B32		;SENT BY MONITOR?
	CAIN W,2B32		;SENT BY INFO?
	SKIPA
	JRST GETAGN		;NO GET IT AGAIN
	TRNE W1,7		;WAS THE PACKET UNDELIVERABLE?
	JRST RDYN1		;YES. SO SEND IT AGAIN
	ANDI W1,77B29		;ISOLATE THE ERROR FIELD
	JUMPE W1,GETAS1		;GOT IT.
	CAIN W1,<.IPCSN>B29	;DID INFO CRASH AND RESTART?
	JRST GETAGN		;YES. WAIT FOR SOME OTHER NEWS THEN
	HRROI A,[ASCIZ /
?Could not send to MAILER
/]
	PSOUT
	HALTF			;GIVE UP
GETAS1:	MOVE W2,BIGBUF+1	;SAVE MAILER'S PID
	MOVEM W2,PIDGET+2	;FOR LATER
	SETZM BIGBUF		;TO GET FILE NAME
	POP P,B
	HRRZS B			;JFN
	HRROI A,BIGBUF+1	;WHERE NAME IS GOING
	MOVE C,[1B2!1B5!1B8!1B11!1B14+1] ;GET FULL NAME
	JFNS			;GET THE NAME
	SETZ C,
	IDPB C,A		;TIE IT OFF
	MOVEI W3,(A)
	SUBI W3,BIGBUF		;SIZE OF STRING
	HRLZS W3		;TO THE LEFT HALF
	HRRI W3,BIGBUF+1	;WHERE IT IS
	SETZ W,			;NO BITS
	MOVE W1,PIDGET+1	;WHERE INFO PUT IT
SENDIT:	MOVEI A,4
	MOVEI B,W		;FOR MAILER
	MSEND			;SEND IT OFF
	 JRST [	MOVEI A,^D500	;SLEEP FOR A WHILE
		DISMS
		JRST SENDIT]	;TRY AGAIN
	HRROI	A,[ASCIZ /
Processing mail.../]
	PSOUT
AGAIN:	MOVEI A,4
	MOVEI B,W		;SET UP FOR MAILER'S REPLY
	SETZB W,W1
	MOVE W2,PIDGET+1	;MY PID
	MOVE W3,[1000,,BIGBUF+1000] ;MESSAGE SPACE
	MRECV			;GET IT
	 JFCL			;?????
	TRNN W,7B32		;FROM INFO OR THE MONITIOR?
	JRST OK			;NO. MUST BE FROM AMILER
	MOVE B,W		;THE HEADER
	ANDI B,7B32		;SEE WHO IT IS
	CAIE B,2B32		;FROM INFO?
	CAIN B,3B32		;OR PRIVATE INFO?
	JRST AGAIN		;YES. GET ANOTHER MESSAGE
	HRROI A,[ASCIZ /
?MAILER is not running. Messages not sent.
/]
	PSOUT			;WAS FROM MONITOR
	HALTF
OK:	CAME W1,PIDGET+2	;FROM MAILER?
	JRST AGAIN		;NO. OGNOTR IT
	TRNE W,77B29		;ANY ERRORS?
	JRST ERRORS		;YES. GO ANALYZE THEM
	HRROI A,[ASCIZ /
No errors.
-DONE-
/]
	PSOUT
	HALTF
ERRORS:	ANDI W,77B29
	CAIE W,<NACK1>B29	;TOTAL WIPEOUT?
	JRST SOME		;NO. PRINT ERRORS
	HRROI A,[ASCIZ /
?Processing errors occurred. No mail sent.
/]
	PSOUT			;YES. COULDNT DO IT
	HALTF
SOME:	HLRZS W3		;GET COUNT
	IMUL W3,[-1,,0]
	HRRI W3,BIGBUF+1000	;BUFFER
SOME1:	MOVE B,1(W3)		;BAD GUY
	CAMN B,[SYSCOD]		;IS THIS SYSTEM?
	JRST [	HRROI A,[ASCIZ /SYSTEM/]
		PSOUT
		JRST SOME2]
	MOVEI A,.PRIOU
	DIRST			;PRINT HIS ID
	 JFCL
SOME2:	HRROI A,[ASCIZ /  not sent /]
	PSOUT
	HLRZ B,0(W3)		;GET MACRO CODE
	CAIN B,NOACKB		;DEFAULT ERROR CONDITION?
	JRST [	HRRZ B,0(W3)	;YES. GET MONITOR CODE
		JUMPE B,NSTRNG	;IF ZERO, NO MORE INFORMATION
		HRLI B,.FHSLF
		HRROI A,[ASCIZ /BECAUSE:
/]
		PSOUT
		MOVEI A,.PRIOU	;OUTPUT REASON
		SETZ C,
		ERSTR		;PRODUCE MONITOR ERROR
		 JFCL
		 JFCL
		JRST NSTRNG]	;AND DONE
	CAIL B,MINMSG		;HAVE A STRING FOR THIS?
	CAIL B,MAXMSG		;STILL?
	JRST NSTRNG		;NO. GO ON
	HRRO A,MSGTBL-MINMSG(B)	;YES. GET THE STRING
	PSOUT			;AND PRINT IT
NSTRNG:	HRROI A,[ASCIZ /
/]
	PSOUT			;CLEAN UP THE LINE
	AOBJN W3,.+1		;ADVANCE TWICE
	AOBJN W3,SOME1		;DO ALL BADDIES
	HRROI A,[ASCIZ /

-Done-
/]
	PSOUT			;TELL HIM IT'S OVER
	HALTF
CANT:	RESET			;CLEAN UP
	HRROI A,[ASCIZ /
?MAIL.CPY Failure
/]
	PSOUT
	MOVEI A,101
	MOVE B,[400000,,-1]
	SETZ C,
	ERSTR			;LET MONITOR TELL HIM WHAT
	 JFCL
	 JFCL
	HALTF
	JRST .-1		;DON'T CONTINUE
;THIS CODE IS GOTTEN TO BY THE REENTER COMMAND. IT IS USED
;EXCLUSIVELY TO TRY TO SEND A MESSAGE.COPY FILE WHICH ALREADY EXISTS
;BUT WHICH COULD NOT BE SENT PREVIOUSLY.
RETRY:	RESET			;CLEAR CONTEXT
	MOVE P,[IOWD PDSL,PDL]	;STACK
	CALL CMDINI		;INITIALIZE FOR COMND JSYS
	PROMPT <File name of message file:>
	MOVEI A,[FLDDB. .CMIFI]
	CALL CFIELD		;READ NAME OF MESSAGE FILE
	JRST RDYN		;ALL SET
	END <3,,ENTVEC>		;ESTABLISH THE ENTRY VECTOR