perm filename MYSEND[PAT,LMM] blob sn#099908 filedate 1974-04-29 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00031 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00004 00002		TITLE READMAIL
C00006 00003		TITLE	SNDMSG
C00008 00004	 MAIN ROUTINE FOR SNDMSG
C00010 00005	 Send message via network FTP MAIL facility
C00012 00006	WATMR2:	AOSE MONITV
C00013 00007	 TRY TO QUEUE THE MESSAGE
C00016 00008	 MAIN GRIPE CODE
C00020 00009	 DO TTY TROUBLE REPORT
C00022 00010	 MAIN CODE FOR SNDMSG FOR NON-LOGGED USERS (IE TIP USERS)
C00024 00011	 ADD A MESSAGE TO A GIVEN FILE.
C00029 00012	 USER NAME INSTRUCTIONS
C00032 00013	 INTERRUPT STUFF
C00034 00014	 INITIALIZE PSI SYSTEM
C00037 00015	 GET USER LIST
C00041 00016	RUL1:	SKPNAT A		 @ TERMINATOR?
C00046 00017	BADUSR:	HRROI A,[ASCIZ / /]
C00047 00018	 GET SUBJECT LINE
C00049 00019	 GET THE TEXT OF A MESSAGE
C00052 00020	 OPEN MESSAGE.TXT FILE
C00055 00021	 OUTPUT USER NAME AT SITE STRING
C00057 00022	HSTSOU - HOST SOUT ROUTINE - COMPLETES HOST NAMES AND DOES SOUT
C00060 00023	 SEND A LINE AND WAIT FOR RESPONSE FROM FTP
C00063 00024	 PUT SUBJECT LINE INTO HEADING
C00066 00025	 FINISH UP HEADING
C00068 00026	 Collect string
C00072 00027	BKWORD:	MOVE A,EPTR
C00074 00028	 BYTE INPUT FROM MULTI-FILES
C00076 00029	 POP FILE STACK
C00079 00030	 INITIAL ENTRY POINT TO SET UP ENTRY VEC AND SSAVE TO
C00081 00031	 MASSIVE RE-ORGANIZATION
C00083 ENDMK
C⊗;
	TITLE READMAIL
; SIMPLE MINDED READMAIL
START:	RESET
	HRLZI 1, 101001
	HRROI 2 , [ASCIZ /MESSAGE.TXT/]
	GTJFN
	JUMPA ERR
	SIZEF
	JUMPA ERR		; GET SIZE IN 2
	MOVE 6,2
	JUMPE 2, RET		; EMPTY FILE
	MOVE 5 , 1		; SAVE JFN IN 5
	MOVE 2 , [XWD 1,24]
	MOVEI 3 , SIZE
	GTFDB			; READ WORD 24 OF FDB (USER WORD)
	CAMN 6 , SIZE		;SKIP IF SIZE}=USERWORD
	 JUMPA RET
	CAMG 6 , SIZE		; SKIP IF SIZE > USERWORD
	SETZM SIZE
	MOVE 2,[070000200000]	; OPEN FILE ASCII, READ
	OPENF
	 JUMPA ERR
	MOVE 2, SIZE
	SFPTR
	 JUMPA ERR
LP:	MOVE 1 , 5
	BIN
	MOVE 3 , 2
	GTSTS
	TLNE 2,1000
	 JUMPA DONE
	MOVE 1 , 3
	PBOUT
	JUMPA LP
DONE:	MOVE 3,6
	HRLI 1,24
	HRROI 2,-1
	CHFDB
RET:	RESET
	HALTF
	JUMPA START
ERR:	HRROI 1,[ASCIZ/Cannot access MESSAGE.TXT
/]
	PSOUT
	JUMPA RET
	JUMPA RET
SIZE:	0
	END START
	TITLE	SNDMSG
	SUBTTL	R.S.Tomlinson
	SEARCH	STENEX

OPDEF	ESOUT[JSYS 313]

; Accumulators

F=0
A=1
B=2
C=3
D=4
X=5
PTR=6
EPTR=7
Y=10
BPTR=11
FLG=12
SF=15
R=16
P=17

; Flags in F

QUIETF==400000
COMMAF==200000
BUFFUL==100000
EOFF==2000
STHSTF==1000
BLANKF==400
NCFRMF==200		; NEED TO CONFIRM GENERAL DELIVERY
FRSTCH==100		; FIRST CHARACTER SEEN BY INSTR
AMBIGF==40		;IN HOST NAME RECOGNIZER
MATCHF==20		; ..
NUMF==10
RAISEF==4
FULLF==2
USEATF==1

; FLAGS IN FLG

NTLOGF==400000
RVRSF==200000
SUBJF==100000
TEXTF== 40000

; Parameters

NFILS==10		; Number of input files open at once
NUSRS==500		; NUMBER OF USERS
NDIST==↑D20		; MAXIMUM NUMBER OF DISTRIBUTION LISTS
NHSTTB==1000		;SPACE FOR HOST NAME TABLES
PDLL==100		;LENGTH OF STACK
MAXMSG==↑D250000	; MAXIMUM MESSAGE SIZE

;MACRO TO SKIP IF CHAR IN AC ARG IS NEITHER "@" NOR, IF NOTLGF IS SET,
; THE CHAR IN SPATCR.
DEFINE	SKPNAT	(ARG)
<	TRNE	FLG,NTLOGF		;;IS NTLOGF SET?
	 CAME	ARG,SPATCR		;;YES.  IS IT THE SPECIAL CHAR?
	CAIN	ARG,"@"			;;IS IT "@"
>


ENTVEC:	JRST SNDMSG
	JRST GRIPE
	JRST TTYTRB
	JRST TPSMSG
	JRST ADDMSG
	JRST TIPGRP
EVECL==.-ENTVEC
;VERSION # INFO
VRSION:	XWD 0,0
	XWD 201,23

; MAIN ROUTINE FOR SNDMSG

SNDMSG:	MOVE P,PDP
	MOVE PTR,[POINT 7,STRING-1,34]
	SETZ	FLG,		;CLEAR  FLG
	SETOM	SPATCR		; SET TO NO SPECIAL AT CHAR.

; JRST TO HERE FROM TPSMSG (WITH NTLOGF SET AND SPATCR SET UP).
SNDMS1:	PUSHJ P,INIPSI		; INITIALIZE PSI SYSTEM
	PUSHJ P,INITIM		; INITIALIZE TIMER FORK
	PUSHJ P,INITTY		; INITIALIZE TTY MODES
	PUSHJ P,INILH		; INITIALIZE LOCAL HOST STUFF
	PUSHJ P,GETUSR		; GET LIST OF USERS
	PUSHJ P,GETSBJ		; GET SUBJECT
	PUSHJ P,GETTXT		; GET TEXT OF MESSAGE
	SKIPL X,NUSERS
	 JRST [	PUSHJ P,GETUSR
		JRST .-1]

; SEND TO ALL USERS

SNDLUP:	SETZM REPLY
	MOVEI A,101
	MOVEI B,37
	BOUT
	PUSHJ P,OUTUSR
	PUSHJ P,MAKHED		; GENERATE HEADING
	SKIPE HOST(X)		; LOCAL?
	 JRST SNDNET		; NO
	PUSHJ P,OPNMSG		; OPEN MESSAGE.TXT
	 JRST QUEUE
	PUSHJ P,OUTMRK		; OUTPUT DATE AND TIME STAMP
	PUSHJ P,OUTMSG		; PUT OUT MESSAGE
	CLOSF
	 JFCL
	HRROI B,[ASCIZ / -- ok/]
	JRST ENDSND

; Send message via network FTP MAIL facility

SNDNET:	TRZ F,NCFRMF
	MOVE A,TIMFRK
	FFORK
	MOVEM P,SAVEP
	MOVEI B,TIMER
	SFORK
	RFORK
	PUSHJ P,DOICP
	 JRST CANT
	 JRST QUEUE
	PUSHJ P,WAITOK
	 JRST QUEUE
REMAIL:	MOVE A,SJFN
	HRROI B,[ASCIZ /MAIL /]
	SETZ C,
	SOUT
	MOVE B,USRTAB(X)
	SOUT
	HRROI B,[ASCIZ /
/]
	SOUT
	MOVEI B,21
	MTOPR
WATMR1:	PUSHJ P,WAITOK
	 JRST WATMRF
	CAMN C,GENDLV
	 JRST [	HRROI A,REPLY
		PSOUT
		TRO F,NCFRMF
		JRST WATMR1]
	CAME C,GOMAIL
	 JRST WATMR1
	TRNE F,NCFRMF
	 JRST [	MOVE A,TIMFRK
		FFORK
		SETZM REPLY
		HRROI A,[ASCIZ /Is general delivery ok for user /]
		PSOUT
		MOVEI A,101
		PUSHJ P,OUTUSR
		HRROI A,[ASCIZ /? /]
		PSOUT
		MOVEI A,100
		RFMOD
		TRO B,77B23
		SFMOD
		PBIN
		CAIE A,"Y"
		CAIN A,"y"
		 JRST WATMRG
		CAIE A,"N"
		CAIN A,"n"
		 JRST DONT
		JRST .]
WATMRG:	MOVE A,TIMFRK
	FFORK
	SETOM MONITV
	MOVEI B,MONITR
	SFORK
	RFORK
	PUSHJ P,OUTMSG
	HRROI B,[ASCIZ /.
/]
	SETZ C,
	SOUT
	MOVEI B,21
	MTOPR
WATMR2:	AOSE MONITV
	 JRST CANT		; MESSAGE REJECTED
	MOVE A,TIMFRK
	WFORK
	FFORK
	SKIPLE MONITV
	 JRST CANT
	MOVE A,SJFN
	CLOSF
	 JFCL
	MOVE A,RJFN
	 CLOSF
	 JFCL
	HRROI B,[ASCIZ / -- ok/]
	SETZM REPLY
	JRST ENDSND

WATMRF:	CAMN C,NEDLOG
	 JRST MITMUL
	HRLZ D,MNQCOD
	JUMPGE D,CANT
WATMRL:	CAMN C,QCODES(D)
	 JRST QUEUE
	AOBJN D,WATMRL
	JRST CANT

MITMUL:	HRROI B,[ASCIZ /USER NETML
/]
	PUSHJ P,SWTOK		; TRY TO LOGIN
	 JFCL
	CAME C,NEDPAS		; SPECIAL REQUEST FOR PASSWORD
	 JRST CANT		; WELL... WE TRIED
	HRROI B,[ASCIZ /PASS NETML
/]
	PUSHJ P,SWTOK
	 JFCL
	CAME C,LOGOK
	 JRST CANT
	JRST REMAIL

; TRY TO QUEUE THE MESSAGE

QUEUE:	MOVE A,TIMFRK
	FFORK
	PUSHJ P,OPNQUE
	 JRST CANT
	PUSHJ P,OUTMSG
	MOVE A,SJFN
	CLOSF
	 JFCL
	PUSHJ	P,MLFLG
	JRST	QUEUE1
	HRROI B,[ASCIZ / -- queued/]
	JRST ENDSND

QUEUE1:	HRROI B,[ASCIZ / -- queued (unable to set flag for immediate processing)/]
	JRST ENDSND

;SET MAILER FLAG
MLFLG:	HRROI B,[ASCIZ /<SYSTEM>MAILER.FLAGS;1/]
	MOVSI A,(1B2)
	GTJFN
	POPJ	P,
	PUSH P,A
	MOVEI B,1B19+1B20+1B25
	OPENF
	 JRST [	POP P,A
		RLJFN
		 JFCL
		POPJ	P,]
	HRLZS A
	MOVE B,[400000,,FLAGPG]
	MOVSI C,140000
	PMAP
	GJINF
	MOVE	C,A	;QUEUE IN LOGIN DIRECTORY
	TRNE	FLG,NTLOGF	;IF NOT LOGGED IN,
	MOVE C,B	; QUEUE IN CONNECTED DIRECTORY
	IDIVI C,44
	MOVSI A,400000
	MOVN D,C+1
	ROT A,(D)
	IORM A,FLAGPG*1000(C)
	SETO A,
	MOVE B,[400000,,FLAGPG]
	PMAP
	POP P,A
	CLOSF
	 JFCL
	AOS	0(P)
	POPJ	P,

; DONT SEND

DONT:	HRROI B,[ASCIZ / -- didn't/]
	JRST ENDSND

; CAN'T SEND MESSAGE

CANT:	MOVE A,TIMFRK
	FFORK
	HRROI B,[ASCIZ / -- can't/]
ENDSND:	MOVEI	A,101
	SETZ C,
	SOUT
	HRROI B,[ASCIZ / --/]
	SETZ C,
	SKIPE REPLY
	SOUT
	HRROI B,REPLY
	SOUT
	SETO A,
	CLOSF
	 SETO A,
	RLJFN
	 JFCL
	AOBJN X,SNDLUP

IFDEF UTAHSW,<
;KEEPS A COPY OF ALL MESSAGES SENT TO SAVED.MESSAGES IF IT EXISTS
	PUSHJ P,OPNSVD	;OPEN SAVED.MESSAGES
	 JRST ENDS.1	;SAVED.MESSAGES DOES NOT EXIST
	PUSHJ P,MAKHED	;MAKE MESSAGE HEADING ("TO" INSTEAD OF "CC")
	PUSHJ P,OUTMRK	;OUTPUT DATE AND SIZE STAMP
	PUSHJ P,OUTMSG	;OUTPUT THE MESSAGE
	CLOSF		;CLOSE SAVED.MESSAGES
	 JFCL
ENDS.1:
>

	HALTF
	JRST SNDMSG
; MAIN GRIPE CODE

GRIPE:	MOVE P,PDP
	MOVE PTR,[POINT 7,STRING-1,34]
	RESET
	SETZ	FLG,		;CLEAR  FLG
	SETOM	SPATCR		; SET TO NO SPECIAL AT CHAR.
	PUSHJ	P,INIPSI
	PUSHJ P,INITTY
GRIPE1:	HRROI A,[ASCIZ /
Griping on subject of /]
	PSOUT
	MOVEI A,[XWD 501000,1
		XWD 100,101
		0

		IFDEF UTAHSW,<POINT 7,[ASCIZ /HELP/]>	;UTAH DIR. FOR
							;GRIPE FILES
		IFNDEF UTAHSW,<POINT 7,[ASCIZ /SYSTEM/]>
		POINT 7,[ASCIZ /GENERAL/]
		POINT 7,[ASCIZ /GRIPES/]
		0
		0
		0
		0]
	SETZ B,
	GTJFN
	 JRST [	HRROI A,[ASCIZ /
No gripe file for that subject, use subsys name or "general"
/]
		PSOUT
		JRST GRIPE1]
	MOVEM A,SJFN
	PUSHJ P,GETTXT
	TRZ	F,USEATF	;MAKIHD-DONT INCLUDE SITE IN "FROM"
	PUSHJ P,MAKIHD
	PUSHJ P,MAKEHD
	MOVE A,SJFN
	MOVE B,[7B5+1B22]
	OPENF
	 JRST [	HRROI A,[ASCIZ /
Can't open that file.  Message saved on MESSAGE.COPY/]
		PSOUT
		HALTF
		JRST GRIPE]
	PUSHJ P,OUTMRK
	PUSHJ P,OUTMSG
	MOVE A,SJFN
	CLOSF
	 JFCL
	HRROI A,[ASCIZ /
Thank you for your constructive criticism./]
	PSOUT
	HALTF
	JRST GRIPE

; MAIN CODE FOR GRIPE FOR NON-LOGGED USERS (I.E.TIP USERS)
; SITE NUMBER IN AC1
; USER NAME IN AC10-14 (UP TO 24 CHARS)

TIPGRP:	MOVE	P,PDP
	MOVE	PTR,[POINT 7,STRING-1,34]
	PUSHJ	P,TIPUSE
	SETZM	SPATCR
	RESET
	PUSHJ	P,INITTY
	SETZM	HOSTN	;SET TO NO HOST TABLES
	SETZM	HSTNAM	;FOR USE BY MAKIHD IN "FROM.."
	HRROI	A,QMSG6
	PSOUT
	SETZ	X,
	MOVE	B,[POINT 7,[ASCIZ /NCC/]]
	MOVEM	B,USRTAB(X)
	MOVE	B,[POINT 7,[ASCIZ /BBN/]]
	MOVEM	B,HOST(X)
	PUSHJ	P,OPNQUE
	JRST	[HRROI	A,[ASCIZ/
CAN'T GET GRIPE FILE.
PLEASE TRY AGAIN LATER.
/]
		 PSOUT
		 HALTF
		 JRST TIPGRP]
	PUSHJ	P,GETSBJ
	PUSHJ	P,GETTXT
	TRO	F,USEATF	;SET FLAG SO MAKIHD WILL
	PUSHJ	P,MAKIHD	;INCLUDE SITE IN "FROM.."
	PUSHJ	P,MAKHSB
	PUSHJ	P,MAKEHD
	PUSHJ	P,OUTMSG
	MOVE	A,SJFN
	CLOSF
	JFCL
	PUSHJ	P,MLFLG	;SET MAILER FLAGS
	JFCL		;IGNORE FAILURE TO SET FLAGS
	HRROI	A,[ASCIZ /
Thank you for your constructive criticism.
/]
	PSOUT
	HALTF
	JRST TIPGRP
; DO TTY TROUBLE REPORT

TTYTRB:	MOVE P,PDP
	MOVE PTR,[POINT 7,STRING-1,34]
	RESET
	SETZ	FLG,		;CLEAR  FLG
	SETOM	SPATCR		; SET TO NO SPECIAL AT CHAR.
	PUSHJ	P,INIPSI
	PUSHJ P,INITTY
	SETZ	X,
	MOVE	B,[POINT 7,TTYMAN]
	MOVEM	B,USRTAB(X)
	PUSHJ P,OPNMSG
	 JRST [	HRROI A,[ASCIZ /
TROUBLE FILE NOT AVAILABLE/]
		ESOUT
		HALTF
		JRST TTYTRB]

IFDEF UTAHSW,<	HRROI A,[ASCIZ /
LOCATION OF TERMINAL & TERMINAL SERIAL # : /]
>

IFNDEF UTAHSW,<	HRROI A,[ASCIZ /
LOCATION OF TERMINAL: /]
>

	MOVEM	A,PROMPT
	PUSHJ P,GETSB
	HRROI A,[ASCIZ /
DESCRIBE TROUBLE: /]
	MOVEM	A,PROMPT
	PUSHJ P,GETTX1
	TRZ	F,USEATF	;MAKIHD-DONT INCLUDE SITE IN "FROM"
	PUSHJ P,MAKIHD
	SETZ C,
	HRROI B,[ASCIZ /
LOC'N:/]
	SOUT
	SKIPN B,SUBJCT
	HRROI B,[ASCIZ /NOT STATED/]
	SOUT
	PUSHJ P,MAKEHD
	PUSHJ P,OUTMRK
	PUSHJ P,OUTMSG
	MOVE A,SJFN
	CLOSF
	 JFCL
	HRROI A,[ASCIZ /
THANK YOU FOR REPORTING YOUR DIFFICULTY.
IT WILL BE INVESTIGATED SHORTLY.
/]
	PSOUT
	HALTF
	JRST TTYTRB

; NAME OF TTY REPAIR MAN

IFDEF UTAHSW,<
TTYMAN: ASCIZ /JENSEN/	;UTAH TTY REPAIR MAN
>

IFNDEF UTAHSW,<
TTYMAN:	ASCIZ /PAIGE/
>
; MAIN CODE FOR SNDMSG FOR NON-LOGGED USERS (IE TIP USERS)
; Site number in AC1
; User name in AC10-AC14 (up to 24 chars)

TPSMSG:	MOVE	P,PDP
	MOVE	PTR,[POINT 7,STRING-1,34]
	PUSHJ	P,TIPUSE
	MOVEI	A,"%"		;USE % AS SPECIAL AT CHAR
	MOVEM	A,SPATCR
	HRROI	A,QMSG5
	PSOUT			; GIVE SPECIAL MESSAGE.
	HRROI	A,QMSG6
	PSOUT
	JRST	SNDMS1		;CONTINUE AS FOR REGULAR ENTRANCE.

TIPUSE:	MOVEM	A,SITEN		;SITE ADDR OF USER IN AC 1
	MOVEM	PTR,FROMNM		;get user name.
	MOVE	A,PTR
	MOVE	B,[POINT 7,10]
	SETZ	C,
	SOUT
	MOVE	PTR,A			;PUT NEW PTR BACK
	IDPB	C,PTR			;AND PUT IN ZERO BYTE.
	PUSHJ	P,GETSIT	; GET SITE NAME
	MOVEI	FLG,NTLOGF		;SET TO "NOT-LOGGED"
	POPJ	P,

;GET SITE NAME

GETSIT:	MOVE	A,PTR
	MOVEM	A,SITE
	MOVE	B,SITEN
	MOVEI	C,10
	CVHST
	 NOUT			;USE NUMBER IF NAME NOT KNOWN
	 JFCL
	MOVEM	A,PTR
	IBP	PTR
	POPJ	P,


; ADD A MESSAGE TO A GIVEN FILE.
; AC1 - OUTPUT JFN (OF MESSAGE FILE).
; AC2 - B(0)=1 => ADD MESSAGE AT FRONT OF FILE.
;     - B(1)=1 => SUBJECT IN AC7-AC16 (UP TO 39 CHARS)
;     - B(2)=1 => TEXT ON FILE - SEE AC3
;AC3 - INPUT JFN OF TEXT IF B(2) IN AC2 SET
; ON SUCCESS HALTS WITH JFN IN AC1 (CLOSED BUT NOT RELEASED).
; ON FAILURE, HALTS WITH AC1 NOT CONTAINING JFN.
ADDMSG:	MOVEM	SAVACS	;SAVE AC0
	MOVE	[XWD 1,SAVACS+1]	;SAVE AC1-AC17
	BLT	SAVACS+17
	MOVE P,PDP
	MOVE PTR,[POINT 7,STRING-1,34]
	MOVEM A,SJFN		;SAVE OUTPUT JFN.
	SETZ FLG,
	TLNE	B,400000		;SKIP IF NORMAL OUTPUT.
	 TRO FLG,RVRSF		;OUTPUT AT FRONT OF FILE.
	TLNE	B,200000	;SUBJECT PASSED?
	JRST	[TRO	FLG,SUBJF	;SET FLAG
		 MOVEM	PTR,SUBJCT	;STORE SUBJECT
		 MOVE	A,PTR		;COPY IT FROM SAVED AC'S
		 MOVE	B,[POINT 7,SAVACS+7]
		 SETZ	C,
		 SOUT
		 CAMN	PTR,A	;INDICATE NULL SUBJECT
		 SETZM	SUBJCT
		 MOVE	PTR,A
		 IDPB	C,PTR
		 JRST	.+1]
	MOVE	B,SAVACS+2	;GET PASSED FLAGS
	TLNE	B,100000	;TEXT PASSED?
	JRST [	TRO FLG,TEXTF	;SET FLAG
		MOVEM	PTR,MSG	;STORE TEXT
		MOVE	A,SAVACS+3 ;JFN
		MOVE	B,[7B5+1B19] ;READ
		OPENF
		 JRST [	SETO	A,	;OPENF SHOULDN'T FAIL
			JRST	ADDHLT ]
		MOVE	B,PTR	;PLACE TO COPY TO
		SETZ	C,
		SIN
		MOVE	PTR,B
		IDPB	C,PTR
		HRLI	A,(1B0)	;DON'T RELEASE JFN
		CLOSF		;CLOSE INPUT FILE
		JFCL
		PUSHJ	P,GTXTE
		JRST	.+1 ]
	SETOM	SPATCR		; SET TO NO SPECIAL AT CHAR.
	TRNE	FLG,SUBJF
	TRNN	FLG,TEXTF
	PUSHJ	P,INIPSI
	PUSHJ P,INITTY		;INITIALIZE TTY PARAMS.
	TRNN	FLG,SUBJF	;SKIP SUBJECT IF GIVEN ALREADY
	PUSHJ P,GETSBJ		;GET SUBJECT.
	TRNN	FLG,TEXTF	;SKIP TEXT IF GIVEN ALREADY
	PUSHJ P,GETTXT		;GET MESSAGE TEXT.
	TRZ	F,USEATF	;MAKIHD-DONT INCLUDE SITE IN "FROM"
	PUSHJ P,MAKIHD		;INITIAL PART OF HEADING.
	PUSHJ P,MAKHSB		;SUBJECT.
	PUSHJ P,MAKEHD		;END OF HEADING.
	MOVE A,SJFN
	MOVE B,[7B5+1B22]
	TRNE FLG,RVRSF
	 MOVE B,[7B5+1B19+1B20+1B26]	;R W AND WAIT IF BUSY.
	OPENF
	 JRST [	HRROI A,[ASCIZ /
CAN'T OPEN THAT FILE.  MESSAGE SAVED ON MESSAGE.COPY./]
		PSOUT
		SETO A,		; MARK FAILURE.
		JRST ADDHLT ]
	TRNN FLG,RVRSF
	 JRST ADDMS1		;APPEND MESSAGE.
	MOVEM PTR,ENDPTR	;ADD MESSAGE AT BEGINNING.
	MOVE A,SJFN
	MOVE B,ENDPTR
	MOVNI C,300000
	SIN			;READ WHAT IS THERE ALREADY.
	MOVEM C,OLDCNT		;SAVE COUNT.
	SETZ B,0
	SFPTR			;BACK TO START.
	 JFCL
ADDMS1:	PUSHJ P,OUTMRK		;OUTPUT TIME STAMP.
	PUSHJ P,OUTMSG		;OUTPUT MESSAGE.
	MOVE A,SJFN
	TRNN FLG,RVRSF
	 JRST ADDMS2		;JUST CLOSE IT.
	MOVE B,ENDPTR		;FIRST WRITE OLD CONTENTS.
	MOVNI C,300000
	SUB C,OLDCNT		;GET NEGATIVE BYTE COUNT.
	SOUT
ADDMS2:	HRLI	A,(1B0)		; DO NOT RELEASE JFN.
	CLOSF
	 JFCL
	MOVE	A,SJFN		; SUCCESS.
ADDHLT:	HALTF
	JRST	.-1

; USER NAME INSTRUCTIONS

QMSG1:	ASCIZ /
Type user names of the form <user name>@<host name>.  Separate names
with comma, end with carriage return.  Typing just @<host name>
causes that host to apply to subsequent users.  Typing @<null string>
refers to the local host.  Each user's message will indicate to whom
else the message was sent unless a named distribution list is
stated by using <distribution name>:.  E.g. TENEX-users:Tomlinson,... .
If one or more distribution list names are specified, they are used
in place of the user names.  Control-B (STX) may be used to substitute
the contents of a file for typed input.
/
; MESSAGE TYPING INSTRUCTIONS

QMSG2:	ASCIZ /
Your message should be typed in and be terminated with control-Z (SUB).
/

QMSG7:	ASCIZ /
A copy of the text of the message will be saved on the file
MESSAGE.COPY;nnn;S if you need to send it again.
/
QMSG3:	ASCIZ /
Use the following control characters to edit:
A (SOH)	character delete
B (STX)	inserts the following file
H (BS)	also character delete
Q (DC1)	line delete
R (DC2)	retype current line or item
S (DC3) retypes entire text or all items
W (ETB) deletes last word
X (CAN)	cancels entire item (start over) - ignored during text input
Z (SUB)	terminates input
/

; Subject instructions

QMSG4:	ASCIZ /
The subject should be a one line summary of the message or a null string
ended with carriage return.
/
QMSG5:	ASCIZ	/
In the following % may be used instead of @ wherever necessary.
/

QMSG6:	ASCIZ /
↑C (Control C) may be used to abort a message.
/

QMSG8:	ASCIZ /
↑O (CONTROL O) WILL SUPPRESS TYPEOUT.
/
; INTERRUPT STUFF

LEVTAB:	RETPC1
	RETPC1
	RETPC1

CHNTAB:	XWD 1,TIMOUT
	XWD	1,SUPOUT
	REPEAT ↑D34,<0>

TIMOUT:	MOVE A,[POINT 7,REPLY]
	HRROI B,[ASCIZ /timed-out/]
	SETZ C,
	SOUT
	MOVE P,[XWD 10000,QUEUE]
	MOVEM P,RETPC1
	MOVE P,SAVEP
	DEBRK

TIMER:	MOVEI A,↑D30000
	DISMS
	MOVEI A,777777
	MOVSI B,(1B0)
	IIC
	HALTF

MONITR:	MOVEI P,PDL2-1
	PUSHJ P,WAITOK
	 JRST MONITF
	 CAIE C,↑D256
	 JRST MONITR
	HALTF

MONITF:	AOSE MONITV
	 HALTF
	PUSHJ P,WAITOK
	JRST .-1
	JRST .-2

;TYPE (OUTPUT TO PRIMARY OUTPUT FILE) THE STRING IN A
TYPOUT:	MOVE	R,[XWD 10000,TYPSKP]
	MOVEM	R,SUPRET
	PSOUT
TYPSKP:	SETZM	SUPRET
	POPJ	P,

;HANDLE ↑O INTERRUPT - SUPPRESS TTY OUTPUT
SUPOUT:	PUSH	P,A	;SAVE A,B
	PUSH	P,B
	MOVEI	A,101	;IF OUTPUT BUFFER EMPTY, DO NOTHING
	SOBE
	SKIPA
	JRST	SUPDON
	MOVEI	A,101	;CLEAR PRIMARY OUTPUT BUFFER
	CFOBF
	MOVEI	A,17	;TYPE ↑O(EOL)
	PBOUT
	MOVEI	A,37
	PBOUT
SUPDON:	SKIPN	SUPRET	;SPECIAL DEBREAK ADDRESS?
	JRST	SUPEND	;NO, JUST DISMISS
	MOVE	R,SUPRET;YES, CLOBBER IT INTO RETURN PC
	MOVEM	R,RETPC1
SUPEND:	POP	P,B	;RESTORE A,B
	POP	P,A
	DEBRK		;DISMISS INTERRUPT
; INITIALIZE PSI SYSTEM

INIPSI:	RESET			; RESET THE WORLD
	MOVEI A,400000		; INITIALIZE INTERRUPT SYSTEM
	MOVE B,[XWD LEVTAB,CHNTAB]
	SIR
	EIR
	MOVSI B,(1B0+1B1)
	AIC			; TURN ON CHANNELS 0&1
	MOVE	A,[XWD 17,1]
	TRNN	FLG,NTLOGF	;IF LOGGED-IN USER,
	ATI			;ASSIGN ↑O TO CHANNEL 1
	SETZM	SUPRET
	POPJ P,

; INITIALIZE TIMER FORK

INITIM:	MOVSI A,(1B0+1B1)
	CFORK			; GET A FORK TO DO TIMING
	 HALTF
	MOVEM A,TIMFRK		; REMEMBER FORK HANDLE
	POPJ P,

; INITIALIZE TTY STUFF

INITTY:	MOVEI A,100		; PRIMARY INPUT
	MOVEM A,INFIL		; IS INITIAL INPUT FILE
	MOVE B,[BYTE (2) 1,0,0,1,1,1,1,2,0,3,3,3,3,3,1,1,1,0]
	MOVE C,[BYTE (2) 0,0,1,1,1,0,0,1,1,0,1,1,1,3]
	SFCOC			; NO ECHO ON CONTROL-A,B,H,Q,R,S,W,X ALT
	TRZ F,QUIETF		; TURN ON RESPONSES
	MOVE SF,[XWD -NFILS,FILSTK-1]	; INIT FILE STACK
	POPJ P,

; INITIALIZE LOCAL HOST THINGS

INILH:	MOVE A,[SIXBIT /LHOSTN/]
	SYSGT			; GET LOCAL HOST NUMBER
	MOVEM A,LHOSTN
	MOVE A,PTR
	MOVEM A,LHOST		; GET STRING FOR LOCAL HOST
	MOVE B,LHOSTN		; NUMBER
	MOVEI C,10
	CVHST			; CONVERT TO STRING
	 NOUT			; IF FAILS, USE NUMERIC HOST
	 JFCL
	MOVEM A,PTR		; REST OF STRINGS GO AFTER THIS
	IBP PTR			; SKIP OVER NULL
	MOVEI A,HSTTAB		;INITIAL FREE SPACE POINTER
	MOVEM A,HSTFRE		; ..
	MOVE A,['HOSTN ']
	MOVEI B,HOSTN
	PUSHJ P,SYSGET		;GET THE NUMBERS OF ALL HOSTS
	MOVE A,['HSTNAM']	;AND THE NAMES IN ASCIZ
	MOVEI B,HSTNAM
	PUSHJ P,SYSGET
	POPJ P,
; GET USER LIST

GETUSR:	HRROI A,[ASCIZ /
Users (? for help): /]
	MOVEM	A,PROMPT
GETUS:	MOVE	A,PROMPT
	PSOUT			; PROMPT
	MOVSI A,-NDIST
	MOVEM A,XDIST		; POINTER FOR STORING DISTRIBUTION NAMES
	MOVSI X,-NUSRS		; ALLOW ONLY NUSRS USERS
	SETZM	DEFHST
	TRO F,FULLF		; BREAK ON PUNCT
	TRO	F,BLANKF	;IGNORE LEADING AND TRAILING BLANKS
	MOVEM PTR,BPTR
RULUP:	MOVEM PTR,USRTAB(X)	; SAVE BEGINNING OF STRING
	TRZ	F,STHSTF
	PUSHJ P,INSTR		; GET USER/HOST NAME
GETUS0:	 JRST [	MOVE PTR,BPTR
		JRST GETUS]
RULUP1:	CAIN A,"?"		; TERMINATOR = ??
	 JRST [	HRROI A,QMSG1	; YES, PRINT INSTRUCTIONS
		PUSHJ	P,TYPOUT
		HRROI A,QMSG3
		PUSHJ	P,TYPOUT
		HRROI	A,QMSG8		;TYPE ↑O MESSAGE
		TRNN	FLG,NTLOGF	;IF APPROPRIATE
		PUSHJ	P,TYPOUT
		JRST RULUP]	; AND DO IT AGAIN
	CAIN A,":"		; DISTRIBUTION LIST?
	 JRST [	SKIPL B,XDIST
		 JRST [	HRROI A,[ASCIZ / Too many group names /]
			JRST BADUS1 ]
		MOVE C,USRTAB(X)
		MOVEM C,DIST(B)
		ADD B,[1,,1]
		MOVEM B,XDIST
		IDPB A,EPTR	; KEEP TERMINATOR
		MOVE PTR,EPTR
		JRST RULUP]
	CAIN A,177		; ABORTED?
RUBOUT:	 JRST [ HRROI A,[ASCIZ /XXX /]
		JRST UFLUSH]	; FLUSH USER
	CAIN	A,0
	 JRST [	CAMN	EPTR,PTR
	 	 JRST	USRMOR
		MOVEI	A,37
		JRST	.+1 ]
	CAMN EPTR,PTR		; NULL STRING TYPED?
	 JRST [	SKPNAT A		; YES, @ TERMINATOR?
		 JRST [	TRO  F,STHSTF	;YES, READ STRING AS
			JRST RUL6 ]	; PERMANENT HOST
		CAIE A,37	; NO, EOL TERMINATOR
		 JRST [	HRROI A,[ASCIZ / [Ignoring null user] /]
			JRST UFLUSH ]
		IDPB A,EPTR
		MOVEM	EPTR,PTR
		JRST USREOL ]	; YES, DONE COLLECTING USER NAMES
	CAIE A,33
	JRST RUL1
	MOVSI A,400000
	MOVE B,USRTAB(X)	; GET BACK TO BEGINNING OF STRING
	STDIR
	 JRST [	SKIPE DEFHST	; IF WE ARE TALKING ABOUT ANOTHER HOST
		 JRST .+1	; JUST CALL IT AMBIGUOUS
		HRROI A,[ASCIZ / No such local user /]
		JRST BADUS1]	; IF THIS HOST, CALL IT BAD
USRAMB:	JRST [	MOVEI A,7
		PBOUT
		JRST USRMOR ]
	MOVE A,EPTR		; POINTER TO TAIL
	MOVEM B,EPTR		; PASS OVER TAIL
	PUSHJ	P,UTAIL		; PRINT TAIL
USRMOR:	PUSHJ P,INSTRC	;GET MORE INPUT
	 JRST GETUS0
	JRST RULUP1

UFLUSH:	PSOUT		;TYPE MSG FROM A
	MOVE	PTR,USRTAB(X)	;BACK UP POINTER
	JRST	RULUP	;LOOP FOR ANOTHER USER
RUL1:	SKPNAT A		; @ TERMINATOR?
	 JRST	RUL6		;YES.  READ FOREIGN SITE NAME.
	SKIPE DEFHST
	 JRST RUL2		; SKIP CHECK IF OTHER HOST
	MOVE B,USRTAB(X)
	MOVEM A,C		; SAVE CHARACTER.
	SETZ A,
	STDIR
	 JRST [	HRROI A,[ASCIZ / No such local user /]
		JRST BADUS1 ]
	 JRST [	HRROI A,[ASCIZ / Ambiguous local user /]
		JRST BADUS1]
	MOVE A,C		; RESTORE CHARACTER.
RUL2:	SKPNAT A		; USER AT FOREIGN SITE WANTED?
	 JRST RUL6		; YES, READ WHERE
	MOVE B,DEFHST
	MOVEM B,HOST(X)		; REMEMBER DEFAULT
RUL63:	IDPB A,EPTR		; STORE THE TERMINATOR FOR RETYPE
	MOVEM EPTR,PTR		; KEEP THE STRING
	CAIE A,","
	CAIN A,37
	SKIPA
	JRST [	HRROI A,[ASCIZ / Bad terminator /]
		JRST BADUS1 ]
	TRZE	F,STHSTF
	JRST [	MOVE	B,HOST(X)	;STORE HOST AS DEFAULT
		MOVEM	B,DEFHST
		JRST	.+2 ]		;RE-USE SAME SLOT
	AOBJP X,RUL3
	CAIN A,","
	JRST	RULUP	;COMMAS - CONTINUE GETTING USERS
USREOL:	MOVE	A,INFIL	;EOL
	CAIE	A,100	;FROM PRIMARY INPUT?
	JRST	RULUP	;NO, DON'T TERMINATE USER LIST
	MOVE	A,EPTR	;DON'T TERMINATE IF EOL PRECEDED BY COMMA
	BKJFN		;BACK UP
	JFCL
	CAMN	A,BPTR	;IF NO PREVIOUS CHARS, EOL TERMINATES
	JRST	RUL3
	LDB	B,A	;GET PREVIOUS CHAR
	CAIN	B,","
	JRST	RULUP	;COMMA PRECEDED EOL
RUL3:	HLRE A,X
	ADDI A,NUSRS
	MOVNS A
	HRLZM A,NUSERS
	HLRE	A,XDIST
	ADDI	A,NDIST
	MOVNS	A
	HRLZM	A,DISTL
	SETZ C,
	MOVE A,BPTR
DPNULL:	ILDB B,A
	SKPNAT B
	 DPB C,A
	CAIN B,","
	 DPB C,A
	CAIE B,12
	CAIN B,15
	 DPB C,A
	CAIE B,":"
	CAIN B,37
	 DPB C,A
	JUMPN B,DPNULL
	POPJ P,

RUL6:	IDPB A,EPTR		; STORE THE TERMINATOR FOR RETYPE
	MOVEM EPTR,PTR		; KEEP THE STRING
	PUSHJ P,GETHST		; GET HOST NAME
	 JRST GETUS0		; ABORT ALL
	 JRST RUBOUT		; FLUSH WHOLE USER SPEC
	 JRST BADUS1		; FAILURE
	MOVEM B,HOST(X)		; SAVE HOST
	JRST RUL63

GETHST:	PUSH P,PTR		; SAVE START POINT
GETHS0:	PUSHJ P,INSTR		; GET STRING
	 JRST POP1		; GET OUT
	SKIPN	A	;REPLACE NULL (EOF)
	 MOVEI	A,37	; BY EOL
	CAIN A,177
	 JRST [	POP P,PTR
		JRST SKPRET]
	CAMN EPTR,PTR
	 JRST [	SETZM 0(P)	; NULL STRING, USE LOCAL
		JRST GETHS1]
	PUSH P,A		; SAVE TERMINATOR
	MOVE A,-1(P)		; WHERE TO WRITE RECOGNIZED STRING
	MOVE B,A		; IS ALSO SOURCE
	SETZ C,
	PUSHJ P,HSTSOU		; PERFORM RECOGNITION
	TRNE F,AMBIGF		; AMBIGUOUS?
	 JRST [	POP P,A		; GET TERMINATOR
		CAIN A,33	; ALTMODE?
		 JRST [	MOVEI A,7
			PBOUT	; DING
			JRST HSTMOR ]
		HRROI A,[ASCIZ / Ambiguous host name /]
		POP P,PTR
		JRST SK2RET]
	TRNN F,MATCHF		; Match found?
	 JRST [	HRROI A,[ASCIZ / No such host /]
		SUB P,[1,,1]
		POP P,PTR
		JRST SK2RET]
	MOVE B,EPTR		; Save where tail starts
	MOVEM A,EPTR		; Update EPTR
	POP P,A			; Get terminator
	CAIE A,33		; ALTMODE?
	 JRST GETHS1
	MOVE	A,B	;START OF TAIL
	PUSHJ	P,UTAIL	;PRINT TAIL
HSTMOR:	PUSHJ	P,INSTRC	;GET MORE INPUT
	JRST	GETHS0+1
	JRST	GETHS0+2
GETHS1:	POP P,B
SK3RET:	AOS 0(P)
SK2RET:	AOS 0(P)
SKPRET:	AOS 0(P)
CPOPJ:	POPJ P,

POP1:	SUB P,[1,,1]
	POPJ P,
BADUSR:	HRROI A,[ASCIZ / /]
BADUS1:	ESOUT
	MOVE A,INFIL
	CAIE A,100
	 JRST [	SETZ C,
		IDPB C,EPTR
		MOVE A,PTR
		PSOUT
		HRROI A,[ASCIZ / -FILE INPUT ABORTED.../]
		PSOUT
		MOVE A,INFIL
		PUSHJ P,ENDFIL
		JRST .+1]
	MOVE PTR,USRTAB(X)
	SETZ C,
	MOVE A,PTR
	IDPB C,A
	MOVE	B,PROMPT
	MOVE C,BPTR
	PUSHJ	P,RETYPE
	JRST RULUP

;PRINT TAIL ADDED ON BY COMPLETION OF USER OR HOST DUE TO ESC
UTAIL:	CAMN	A,EPTR	;A IS TAIL START, EPTR IS END
	HRROI	A,[ASCIZ /[Name already complete]/]	;NO TAIL TO TYPE
	PSOUT
	POPJ	P,
; GET SUBJECT LINE

GETSBJ:	HRROI A,[ASCIZ /
Subject: /]
	MOVEM	A,PROMPT
GETSB:	MOVE	A,PROMPT
	PSOUT
GETSB0:	MOVEM PTR,BPTR
	MOVEM PTR,SUBJCT
	TRO F,FULLF
	TRZ	F,BLANKF	;NO SPECIAL TREATMENT OF BLANKS
	PUSHJ P,INSTR
GETSB2:	 JRST [	MOVE PTR,BPTR
		JRST GETSB]
	CAIN A,"?"
	 JRST [	HRROI A,QMSG4
		PUSHJ	P,TYPOUT
		JRST GETSB]
	CAIN A,177
	 JRST [	HRROI A,[ASCIZ /XXX/]
		PSOUT
		JRST GETSB]
	CAIE	A,33
	CAIN	A,0
	 JRST	SBJMOR	;IGNORE NULL & ALTMODE
	CAIE A,37
	 JRST	SBJSAV
	CAMN PTR,EPTR
	 SETZM SUBJCT		; MARK NULL SUBJECT THIS WAY
	MOVEM EPTR,PTR
	IBP PTR
	POPJ P,

SBJSAV:	IDPB	A,EPTR		;SAVE CHAR
SBJMOR:	PUSH	P,[GETSB2]	;CONTINUE GATHERING STRING
	JRST	INSTRC
; GET THE TEXT OF A MESSAGE

GETTXT:	HRROI A,[ASCIZ /
Message (? for help):
/]
	MOVEM	A,PROMPT
GETTX1:	MOVE	A,PROMPT
	PSOUT
GETTX0:	MOVEM PTR,MSG
	MOVEM	PTR,BPTR
	TRZ	F,FULLF
	TRZ	F,BLANKF	;NO SPECIAL TREATMENT OF BLANKS
	PUSHJ P,INSTR
GETTX:	 JRST GETTXT
	CAIE	A,0
	CAIN A,177
	 JRST [	PUSH P,[GETTX]
		JRST INSTRC]
	CAIN A,"?"
	 JRST [	HRROI A,QMSG2
		PUSHJ	P,TYPOUT
		HRROI A,QMSG7
		TRNN	FLG,NTLOGF
		PUSHJ P,TYPOUT
		HRROI A,QMSG3
		PUSHJ	P,TYPOUT
		HRROI	A,QMSG8		;TYPE ↑O MESSAGE
		TRNN	FLG,NTLOGF	;IF APPROPRIATE
		PUSHJ	P,TYPOUT
		JRST GETTX1]
	MOVEI A,37
	PBOUT
	LDB A,EPTR		; IS THERE A LF
	CAIE A,12		; AT THE END?
	 JRST [	MOVE A,EPTR	; NO
		HRROI B,[ASCIZ /
/]
		SETZ C,
		SOUT		; PUT ONE THERE
		MOVEM A,EPTR
		JRST .+1]
	MOVEM EPTR,PTR
	IBP PTR
	PUSH P,[1]
GMCLP:	MOVSI A,(1B0!1B1!1B5!1B17)
	HRR A,0(P)
	HRROI B,[ASCIZ /MESSAGE.COPY;P770000/]
	GTJFN
	 JRST [	AOS A,0(P)
		CAIG A,100
		 JRST GMCLP
		POP P,A
		JRST NOCOPY]
	MOVEM A,0(P)
	MOVE B,[XWD 70000,100000]
	OPENF
	 JRST [	POP P,A
		RLJFN
		 JFCL
		JRST NOCOPY]
	MOVE B,MSG
	SETZ C,
	SOUT
	POP P,A
	CLOSF
	 JFCL
	JRST	GTXTE
NOCOPY:	HRROI	A,[ASCIZ /
Unable to save message on MESSAGE.COPY -
/]
	PSOUT
	MOVEI	A,101
	HRLOI	B,400000
	SETZ	C,
	ERSTR
	JFCL
	JFCL
GTXTE:	MOVE A,MSG
	PUSHJ P,CNTMSG		; COUNT LENGTH OF MESSAGE
	MOVEM B,MSGLEN		; SAVE
	POPJ P,
; OPEN MESSAGE.TXT FILE

OPNMSG:	MOVE A,PTR
	MOVEI B,"<"
	IDPB B,A
	MOVE B,USRTAB(X)
	SETZ C,
	SOUT
	HRROI B,[ASCIZ />MESSAGE.TXT;1/]
	SOUT
	MOVE	B,PTR
	MOVSI A,501001
	GTJFN
	 JRST ERRPLY
	MOVEM A,SJFN
	MOVE B,[7B5+1B22]
	OPENF
	 JRST [	PUSH	P,A
		MOVE A,SJFN
		RLJFN
		 JFCL
		POP	P,A
		JRST ERRPLY]
	AOS 0(P)
	POPJ P,

;WRITE ERROR STRING FOR ERR CODE IN A INTO REPLY
ERRPLY:	MOVE	B,A		;ERROR CODE
	HRLI	B,400000	;THIS FORK
	HRROI	A,REPLY		;STRING DESTINATION
	SETZ	C,
	ERSTR			;ERROR STRING
	 JFCL			;IGNORE FAILURE
	 JFCL
	IDPB	C,A	; END WITH NULL
	POPJ	P,

IFDEF UTAHSW,<
;OPEN SAVED.MESSAGES FILE
OPNSVD:	HRROI B,[ASCIZ /SAVED.MESSAGES /]
	MOVSI A,(1B2!1B17)
	GTJFN
	 POPJ P,0
	MOVEM A,SJFN
	MOVE B,[7B5!1B22!1B26]
	OPENF
	 JRST [MOVE A,SJFN	;CAN'T OPEN SAVED.MESSAGES
		RLJFN
		 JFCL
		POPJ P,0]
	AOS 0(P)
	POPJ P,0	;SUCCESSFUL, NORMAL RETURN
>

; OPEN UNDELIVERABLE FILE
OPNUND:	MOVE	A,PTR
	HRROI	B,[ASCIZ '/UNDELIVERABLE-MAIL/.']
	JRST	OPNQU2

; OPEN QUEUE FILE

OPNQUE:	GJINF		;QUEUE IN LOGIN DIRECTORY
	TRNN	FLG,NTLOGF ;IF LOGGED IN, OTHERWISE
	MOVE	B,A	;IN CONNECTED DIRECTORY
	MOVE A,PTR
	MOVEI	C,"<"
	IDPB	C,A
	DIRST
	 POPJ	P,
	HRROI B,[ASCIZ />[--UNSENT-MAIL--]./]
OPNQU2:	SETZ C,
	SOUT
	MOVE B,USRTAB(X)
	MOVEI D,"V"-100
OPNQUL:	ILDB C,B
	CAIL C,"A"
	CAILE C,"Z"
	 JRST [	CAIL C,"0"
		CAILE C,"9"
		 IDPB D,A
		JRST .+1]
	IDPB C,A
	JUMPN C,OPNQUL
	MOVEI B,"@"
	DPB B,A
	SKIPE B,HOST(X)
	PUSHJ P,HSTSOU		;COMPLETE HOST NAME THEN SOUT
	HRROI B,[ASCIZ /;P770000/]
	SOUT
	MOVE B,PTR
	MOVSI A,400001
	GTJFN
	 POPJ P,
	MOVEM A,SJFN
	MOVE B,[70000,,100000]
	OPENF
	 JRST [	MOVE A,SJFN
		RLJFN
		 JFCL
		POPJ P,]
	AOS 0(P)
	POPJ P,
; OUTPUT USER NAME AT SITE STRING

OUTUSR:	SETZ C,
	MOVE B,USRTAB(X)
	SOUT
	SKIPN HOST(X)
	 POPJ P,
	HRROI B,[ASCIZ / at /]
	SOUT
	MOVE B,HOST(X)
	PUSHJ P,HSTSOU		;COMPLETE HOST NAME THEN SOUT
	POPJ P,

; DO ICP TO FTP

DOICP:	MOVE A,PTR
	HRROI B,[ASCIZ /NET:0./]
	SETZ C,
	SOUT
	MOVE B,HOST(X)
	PUSHJ P,HSTSOU		;COMPLETE HOST NAME THEN SOUT
	MOVN B,FTPSKT
	MOVEI C,8
	NOUT
	 HALT
	HRROI B,[ASCIZ /;T/]
	SETZ C,
	SOUT
	MOVE B,PTR
	MOVSI A,1
	GTJFN
	 POPJ P,		; NO SKIP -- NO SUCH HOST
	AOS 0(P)		; AT LEAST ONE SKIP FROM HERE
	MOVEM A,SJFN
	MOVE B,[XWD 400000,200000]
	OPENF
	 POPJ P,
	BIN
	MOVEM B,FSKT
	CLOSF
	 JFCL
	MOVE A,PTR
	HRROI B,[ASCIZ /NET:2./]
	SETZ C,
	SOUT
	MOVE B,HOST(X)
	SOUT
	MOVN B,FSKT
	MOVEI C,10
	NOUT
	 JFCL
	HRROI B,[ASCIZ /;T/]
	SETZ C,
	SOUT
	MOVE B,PTR
	MOVSI A,1
	GTJFN
	 POPJ P,
	MOVEM A,SJFN
	MOVE B,PTR
	MOVSI A,1
	GTJFN
	 POPJ P,
	MOVEM A,RJFN
	MOVE B,[XWD 103400,200000]
	OPENF
	 POPJ P,
	MOVE A,SJFN
	MOVE B,[XWD 103400,100000]
	OPENF
	 POPJ P,
	AOS 0(P)
	POPJ P,
;HSTSOU - HOST SOUT ROUTINE - COMPLETES HOST NAMES AND DOES SOUT

HSTSOU:	SKIPE HOSTN		;DID THE TABLES READ OK?
	SKIPN HSTNAM		; ..
	JRST SOUTPJ		;NO. JUST SOUT AS IT STANDS
	PUSH P,A		;DESTINATION STRING
	PUSH P,B		;SOURCE STRING TO RECOGNIZE
	PUSH P,C		;COUPLE AC'S FOR TEMPS
	PUSH P,D		; ..
	PUSH P,X		;WILL USE AS COUNTER THRU TABLE
	TRZ F,AMBIGF!MATCHF	;INITIALIZE NOT AMBIGUOUS OR MATCHED
	MOVE X,HOSTN		;POINTER TO HOST NUMBERS AND NAME OFFSET
HSOUL2:	MOVE B,0(X)		;GET A HOST NAME
	ADD B,HSTNAM		;POINT TO TEXT STRING
	HRLI B,440700		;BYTE PTR
	MOVE A,-3(P)		;USER'S NAME
HSOUL1:	ILDB C,A		;CHAR FROM USER
	ILDB D,B		;CHAR FROM TABLE
	CAIG C,172		;USER MAY BE LOWER CASE
	CAIGE C,141
	SKIPA			;NOT
	TRZ C,40		;LOWER. MAKE UPPER.
	CAME C,D		;CHARACTERS MATCH?
	JRST HSOUT1		;NO
	JUMPN C,HSOUL1		;YES. LOOP UNLESS TO END OF STRINGS
HSOUTM:	TRZ F,AMBIGF		; INDICATE SUCCESS FOR INTERESTED CALLER
	TRO F,MATCHF
	MOVE B,0(X)		;EXACT MATCH
	ADD B,HSTNAM		;POINT TO STRING IN TABLE
	HRLI B,440700
	MOVEM B,-3(P)		;PUT IT IN AC B ON STACK
HSOUTR:	POP P,X			;RESTORE ACS
	POP P,D
	POP P,C
	POP P,B
	POP P,A
SOUTPJ:	SOUT
	POPJ P,0

HSOUT1:	JUMPN C,HSOUT2		;IF NOT END OF USER STRING, NO MATCH.
	SKIPL 0(X)		;SERVER BIT ON FOR THIS HOST?
	JRST HSOUT2		;NO. DONT RECOGNIZE IT.
	TROE F,MATCHF		;YES. IT'S A MATCH. FIRST?
	TRO F,AMBIGF		;NO. LOSES. AMBIGUOUS.
	MOVEM X,HSOUTX		;STASH THE INDEX OF THE MATCH
HSOUT2:	AOBJN X,HSOUL2		;MOVE ON TO NEXT HOST NAME
	MOVE B,HSOUTX		;TRIED ALL. POINT TO ANY MATCH
	MOVE B,0(B)
	ADD B,HSTNAM
	HRLI B,440700		;STRING POINTER, MAYBE TO A NAME.
	TRNE F,MATCHF		;A MATCH?
	TRNE F,AMBIGF		;AND NOT AMBIGUOUS?
	SKIPA			;NOT A WIN
	MOVEM B,-3(P)		;WINS. PUT IT ON STACK FOR SOUT
	JRST HSOUTR		;AND RESTORE ACS, SOUT, RETURN.
; SEND A LINE AND WAIT FOR RESPONSE FROM FTP

SWTOK:	MOVE A,SJFN
	SETZ C,
	SOUT
	MOVEI B,21
	MTOPR
	JRST WAITOK

; GET A RESPONSE FROM FTP

WAITOK:	MOVE A,RJFN
	TRZ F,NUMF
	SETZ C,
NINLP:	BIN
	CAIL B,200
	 JRST NINLP
	CAIG B,"9"
	CAIGE B,"0"
	 JRST NINDUN
	TRO F,NUMF
	IMULI C,↑D10
	ADDI C,-60(B)
	JRST NINLP

NINDUN:	SKIPA D,[POINT 7,REPLY]
NINDU1:	BIN
	JUMPE B,[GTSTS
		TLNE B,1000
		POPJ P,
		JRST NINDU1]
	IDPB B,D
	CAIE B,12
	 JRST NINDU1
	TRNN F,NUMF		; ANY NUMBER INPUT?
	 JRST WAITOK		; NO, GET ANOTHER
	SETZ B,
	IDPB B,D
	CAIL C,↑D400
	CAIL C,↑D600
	AOS 0(P)
	POPJ P,

; GENERATE FIRST PART OF HEADING

MAKIHD:	MOVE A,PTR
	MOVEM A,HEAD
	HRROI B,[ASCIZ /Date: /]
	SETZ C,
	SOUT
	MOVSI C,(1B5!1B7!1B10!1B12!1B13); IN FORM "15 MAY 1973 1346-EDT"
	SETO B,
	ODTIM
	HRROI B,[ASCIZ /
From: /]
	SETZ C,
	SOUT
	TRNE	FLG,NTLOGF	; IS USER LOGGED IN?
	 JRST	MAKIH1		;NO, USE FROM NAME.
	PUSH P,A
	GJINF
	MOVE B,A
	POP P,A
	DIRST
	 JFCL
	JRST	MAKIH2
MAKIH1:	MOVE	B,FROMNM	;USE FROM NAME
	SOUT
MAKIH2:	TRNN	F,USEATF	;INCLUDE "AT..."?
	POPJ	P,		;NO, JUST RETURN
	HRROI B,[ASCIZ / at /]; SAY WHAT HOST IT'S FROM
	SETZ C,
	SOUT
	MOVE B,LHOST
	TRNE	FLG,NTLOGF	;IS USER LOGGED IN?
	 MOVE	B,SITE		;NO, USE SITE NAME.
	PUSHJ P,HSTSOU		;COMPLETE HOST NAME THEN SOUT
	POPJ	P,
; PUT SUBJECT LINE INTO HEADING

MAKHSB:	SKIPN SUBJCT
	 POPJ P,
	HRROI B,[ASCIZ /
Subject: /]
	SETZ C,
	SOUT
	MOVE B,SUBJCT
	SOUT
	POPJ P,

; MAKE HEADING FOR SNDMSG

MAKHED:	TRZ	F,USEATF	;ASSUME NOT USING HOST NAME
	TRNN	FLG,NTLOGF	; IF THIS IS A NON-LOGGED USER OR
	SKIPE HOST(X)		; IF THIS IS TO A DIFFERENT HOST
	TRO	F,USEATF	;USE HOST NAME
	PUSHJ P,MAKIHD		; GENERATE INITIAL PART OF HEADING
	PUSHJ	P,MAKHSB
	SKIPGE Y,DISTL		; PRINT DISTRIBUTION LIST IF ANY
	 JRST DOCC
	MOVE Y,NUSERS

IFDEF UTAHSW,<
	JUMPG X,[HRROI B,[ASCIZ /
TO:   /]
		JRST DOCC1]	;X IS GREATER THAN 0 AFTER MESSAGE HAS
				;BEEN SENT TO ALL USERS AND WE ARE
				;MAKING A COPY FOR SAVED.MESSAGES.
				;MAKE A LIST OF ALL PERSONS RECEIVING
				; THE MESSAGE.
>

	CAML Y,[-1,,0]
	JRST ENDHED
DOCC:	HRROI B,[ASCIZ /
cc:   /]

IFDEF UTAHSW,<
DOCC1:				;OUTPUT 'TO:	' FOLLOWED BY USER LIST
>

	SETZ C,
	SOUT
	PUSH P,A
	TRZ F,COMMAF
CCLUP:	SKIPGE	DISTL
	JRST	CCLUP1
	CAMN Y,X
	JRST CCNXT
CCLUP1:	PUSH P,A
	HRROI B,[ASCIZ /, /]
	TROE F,COMMAF
	SOUT
	SKIPGE DISTL
	 JRST [	MOVE B,DIST(Y)
		SOUT
		JRST CCCHKE]
	EXCH X,Y
	PUSHJ P,OUTUSR
	EXCH X,Y
CCCHKE:	HRRZ B,A
	SUBI B,@-1(P)
	CAILE B,↑D12
	 JRST [	POP P,A
		HRROI B,[ASCIZ /,
cc:   /]
IFDEF UTAHSW,<
	SKIPLE	X
	HRROI	B,[ASCIZ /,
      /]
>
		TRZ F,COMMAF
		SOUT
		MOVEM A,0(P)
		JRST CCLUP]
	SUB P,[XWD 1,1]
CCNXT:	AOBJN Y,CCLUP
	SUB P,[XWD 1,1]
ENDHED:	PUSHJ P,MAKEHD		; DO THE END OF THE HEADING
	POPJ P,
; FINISH UP HEADING

MAKEHD:	HRROI B,[ASCIZ /

- - - -
/]
	SETZ C,
	SOUT
	MOVEM A,PTR
	IBP PTR
	MOVE A,HEAD
	PUSHJ P,CNTMSG		; GET ITS LENGTH
	MOVEM B,HEDLEN
	POPJ P,

; OUTPUT DATE AND SIZE STAMP

OUTMRK:	MOVE A,SJFN
	SETO B,
	MOVSI C,(1B17)
	ODTIM
	MOVEI B,","
	BOUT
	MOVE B,MSGLEN
	ADD B,HEDLEN
	ADDI B,9
	MOVEI C,12
	NOUT
	 JFCL
	MOVEI B,15
	BOUT
	MOVEI B,12
	BOUT
	POPJ P,

; OUTPUT MESSAGE

OUTMSG:	MOVE A,SJFN
	MOVE B,HEAD
	MOVN C,HEDLEN
	SOUT
	MOVE B,MSG
	MOVN C,MSGLEN
	SOUT
	HRROI B,[ASCIZ /-------
/]
	SETZ C,
	SOUT
	POPJ P,

; COUNT LENGTH OF MESSAGE

CNTMSG:	SETZ B,
	ILDB C,A
	JUMPE C,CPOPJ
	AOJA B,.-2
; Collect string
; If fullf = 1, then string is terminated by control-Z
; otherwise it is terminated by any punctuation (@ , eol altmode now)
; Initial ? always returns, rubout always returns

INSTR:	TRZ F,BUFFUL
	MOVE EPTR,PTR
INSTRC:	MOVEI A,100
	RFMOD
	TRZ B,77B23
	TRO B,16B23
	SFMOD
	TRZ F,FRSTCH

RLUP:	PUSHJ P,.BIN
	TRNE	FLG,NTLOGF		;IS USER LOGGED IN?
	 JRST	[ CAIE	A,"C"-100	;NO CHECK FOR ↑C
		   JRST	.+1		;NONE. GO ON.
		  PBOUT
		  HALTF			;FOUND ONE. EXIT.
		  JRST	RLUP		;ON CONT GO ON.
		]
	CAIE A,"H"-100
	CAIN A,"A"-100
	 JRST [	CAMN EPTR,PTR
		 JRST DING
		MOVEI A,"\"
		PBOUT
		LDB A,EPTR
		PBOUT
		PUSH P,A
		MOVE A,EPTR
		BKJFN
		 0
		MOVE EPTR,A
		POP P,A
		CAIN A,12
		 JRST .
		JRST RLUP]
	CAIN A,"Q"-100
	 JRST [	CAMN EPTR,PTR
		JRST DING
		MOVEI A,"←"
		PBOUT
		MOVEI A,37
		PBOUT
		PUSHJ P,BKLIN
		MOVEM A,EPTR
		JRST RLUP]
	CAIN A,"W"-100
	 JRST [	CAMN PTR,EPTR
		 JRST DING
		PUSHJ P,BKWORD
		MOVEI A,"←"
		PBOUT
		JRST RLUP]
	CAIN A,"R"-100
	 JRST [	PUSHJ P,BKLIN
		MOVEM	A,C	;START OF STRING
		SETZ	B,	;NO PROMPT
		PUSHJ	P,RETYPE
		JRST RLUP]
	CAIN A,"S"-100
	 JRST [	SETZ B,
		PUSH P,EPTR
		IDPB B,EPTR
		POP P,EPTR
		MOVE C,BPTR
		MOVE	B,PROMPT
		PUSHJ	P,RETYPE
		JRST RLUP]
	TRNE	F,BLANKF	;IF FLAG ON,
	 JRST [	CAIN A," "	; SKIP LEADING BLANKS
		CAME PTR,EPTR
		JRST .+1
		JRST	RLUP ]
	CAMN PTR,EPTR
	CAIE A,"?"
	CAIN A,177
	 JRST ENDIN
	CAIE	A,0
	CAIN A,"Z"-100
	JRST ENDIN
	TRNE F,FULLF
	 JRST [	CAIN A,15		;FULLF ON
		 JRST RLUP	; IGNORE
		CAIN A,"X"-100
		 JRST [	HRROI A,[ASCIZ /←←←
/]
			PSOUT
			POPJ P,]
		CAIN A,12
		 MOVEI A,37	; LF BECOMES EOL
		CAIE A,","
		CAIN A,37
		 JRST ENDIN
		CAIE A,33
		CAIN A,":"
		 JRST ENDIN
		SKPNAT A
		 JRST ENDIN
		JRST RLUPS]
	CAIE	A,33		;FULLF OFF
	CAIN	A,"X"-100	;IGNORE ALTMODE AND ↑X
	 JRST	RLUP
	TROE F,FRSTCH
	 JRST RLUPS
	PUSH P,A
	MOVEI A,100
	RFMOD
	TRZ B,1B20+1B22		; STOP WAKING ON PUNC AND FORMAT CTRLS
	SFMOD
	POP P,A
RLUPS:	HRRZ B,EPTR
	CAIL B,ESTRING-25
	 JRST [	TROE F,BUFFUL
		 JRST RLUP
		HRROI A,[ASCIZ /
String buffer full.  Finish input soon or you will lose.
/]
		ESOUT
		JRST RLUP]
	CAIL A,140
	CAILE A,177
	 JRST NOTLWR
	TRNE F,RAISEF
	 TRZ A,40
NOTLWR:	CAIN A,37
	 JRST [	MOVEI A,15
		IDPB A,EPTR
		MOVEI A,12
		JRST .+1]
	IDPB A,EPTR
	PUSH P,EPTR
	SETZ A,
	IDPB A,EPTR
	POP P,EPTR
	JRST RLUP
BKWORD:	MOVE A,EPTR
BKWRL1:	LDB B,A
	PUSHJ P,INVCHK
	 JRST BKWRD1
	CAME A,PTR
	BKJFN
	 JRST BKWRDN
	JRST BKWRL1

BKWRD1:	CAME A,PTR
	BKJFN
	 JRST BKWRDN
	LDB B,A
	PUSHJ P,INVCHK
	 JRST BKWRD1
BKWRDN:	MOVEM A,EPTR
	SETZ B,
	IDPB B,A
	POPJ P,

INVCHK:	CAILE B," "
	CAIL B,177
	AOS 0(P)
	POPJ P,
BKLIN:	MOVE A,EPTR
	SETZ B,
	IDPB B,A
	MOVE A,EPTR
BKLINL:	CAMN A,PTR
	 POPJ P,
	BKJFN
	 0
	LDB B,A
	CAIE B,37
	CAIN B,12
	POPJ P,
	JRST BKLINL

BKBLNK:	PUSH	P,A
	MOVE	A,EPTR
BKBL1:	CAMN	A,PTR
	JRST	BKBL2
	LDB	B,A
	CAIN	B," "
	BKJFN
	JRST	BKBL2
	JRST	BKBL1
BKBL2:	MOVEM	A,EPTR
	POP	P,A
	POPJ	P,

DING:	MOVEI A,7
	PBOUT
	JRST RLUP

ENDIN:	TRNE	F,BLANKF	;IF FLAG ON,
	PUSHJ	P,BKBLNK	; BACK UP OVER TRAILING BLANKS
	SETZ B,
	MOVE C,EPTR
	IDPB B,C
	AOS 0(P)
	POPJ P,

;TYPE PROMPT STRING FROM B (NONE IF 0) THEN STRING FROM C -
; STARTS ON NEW LINE - CLOBBERS A
RETYPE:	MOVEI	A,37
	PBOUT
	SKIPE	A,B	;TYPE PROMPT IF ANY
	PSOUT
	MOVE	A,C	;TYPE STRING
	PUSHJ	P,TYPOUT
	POPJ	P,
; BYTE INPUT FROM MULTI-FILES

.BIN:	PUSH P,B
	TRNE	F,EOFF
	 JRST [	PUSHJ P,ENDFIL
		POP P,B
		JRST .BIN]
	MOVE A,INFIL
	BIN
	JUMPE B,[GTSTS
		TLNN B,1000
		 JRST .-1
		SETZ	B,
		TRO	F,EOFF
		JRST	.+1 ]
	CAIN B,"B"-100
	 JRST NEWFIL
	MOVE A,B
	POP P,B
	POPJ P,

SYSGET:	PUSH P,A		;PRESERVE AC'S
	PUSH P,B
	SETZM 0(B)		;IN CASE FAILS, CLEAR ANSWER.
	SYSGT
	JUMPE B,BAPOPJ		;RETURN IF NO TABLE
	MOVE A,HSTFRE		;POINT TO FREE SPACE
	HLL A,B			;PUT IN COUNT
	MOVEM A,@0(P)		;THATS THE ANSWER
	PUSH P,B		;NOW GET DATA. SAVE POINTER
	HLLZ X,B		;AOBJN COUNTER
SYSGTL:	MOVSI A,(X)		;ENTRY NUMBER IN TABLE
	HRR A,0(P)		;TABLE NUMBER
	GETAB
	  JRST SYSGTF		;FAILED!!
	AOS C,HSTFRE		;MOVE ON DOWN THE FREE SPACE
	CAILE C,HSTTAB+NHSTTB	;OVERFLOW TABLE?
	JRST SYSGTF		;YES.
	MOVEM A,-1(C)		;NO. STORE DATUM
	AOBJN X,SYSGTL		;COUNT THRU TABLE
SYSGTY:	POP P,(P)		;PEEL STACK
BAPOPJ:	POP P,B
	POP P,A
	POPJ P,0

SYSGTF:	SETZM @-1(P)		;FAILURE. CLOBBER ANSWER.
	JRST SYSGTY		;AND RETURN
; POP FILE STACK

ENDFIL:	CLOSF
	 JFCL
	POP SF,INFIL
	CAMN SF,[XWD -NFILS,FILSTK-1]
	 TRZ F,QUIETF
	HRROI A,[ASCIZ /EOF)/]
	TRNN F,QUIETF
	 PSOUT
	TRZ	F,EOFF
	POPJ P,

; SET NEW INPUT FILE, PUSH FORMER

NEWFIL:	PUSH SF,INFIL
	TRNE	FLG,NTLOGF		;IS USER LOGGED IN?
	 JRST	[ HRROI	A,[ASCIZ /(File capability not available non-logged-in users.)/]
		  PSOUT
		  JRST	NONEWF  ]
	HRROI A,[ASCIZ /(Insert file: /]
	TRNN F,QUIETF
	PSOUT
	MOVSI A,(1B2!3B17)
	MOVEI B,100
	CAMN	B,INFIL	;REQUIRE CONFIRMATION IF TTY INPUT
	OR	A,[1B4]
	CAME B,INFIL
	 SKIPA B,[377777]
	 MOVEI B,101
	HRL B,INFIL
	GTJFN
	 JRST [	HRROI A,[ASCIZ / ?)/]
		TRNN F,QUIETF
		PSOUT
		JRST NONEWF]
	MOVEM A,INFIL
	MOVE B,[XWD 70000,200000]
	OPENF
	 JRST [	MOVE	B,A
		HRLI	B,400000
		MOVEI	A,101
		SETZ	C,
		TRNN	F,QUIETF
		ERSTR
		 JFCL
		 JFCL
		MOVE A,INFIL
		RLJFN
		 JFCL
		HRROI A,[ASCIZ / can't open)/]
		TRNN F,QUIETF
		PSOUT
		JRST NONEWF]
	HRROI A,[ASCIZ /.../]
	TRNN F,QUIETF
	PSOUT
	TRO F,QUIETF
	POP P,B
	JRST .BIN

NONEWF:	POP SF,INFIL
	POP P,B
	JRST .BIN

NEDLOG:	↑D504	; NEED TO LOG IN
NEDPAS:	↑D330	; NEED PASSWORD
LOGOK:	↑D230	; SUCCESSFUL LOGIN FOR MULTICS
GENDLV:	↑D950
GOMAIL:	↑D350
QCODES:	BLOCK 5	; CODES IMPLYING QUEUEING
MNQCOD:	0	; NEG OF NUMBER OF REPLY CODES THAT IMPLY QUEUEING
FTPSKT:	3
PDP:	IOWD PDLL,PDL

LIT
; INITIAL ENTRY POINT TO SET UP ENTRY VEC AND SSAVE TO
; <SUBSYS>SNDMSG.SAV

IF2, <
PRINTX *****
PRINTX RUN ONCE BEFORE SSAVING TO SET UP ENTRY VECTOR AUTOMTICALLY
PRINTX *****
>

INITIT:	RESET
	HRROI	A,[ASCIZ /
Setting up entry vector./]
	PSOUT
	MOVE	B,[EVECL,,ENTVEC]
	MOVEI	A,400000
	SEVEC
REPEAT 0,<
	HRROI	A,[ASCIZ /
SSAVEing myself as <SUBSYS>SNDMSG.SAV/]
	PSOUT
	HRLZI	A,(1B0+1B1+1B17)	;OUTPUT USE, NEW FILE.
	HRROI	B,[ASCIZ /<SUBSYS>SNDMSG.SAV/]
	GTJFN
	 JRST	[MOVE B,A
		 MOVEI A,37
		 PBOUT
		 MOVEI A,101
		 HRLI B,400000
		 SETZ C,
		 ERSTR
		  JFCL
		  JFCL
		 HRROI A,[ASCIZ /
Can't get JFN for <SUBSYS>SNDMSG.SAV
/]
		 PSOUT
		 HALTF
		 HALTF
		]
	HRLI	A,400000
	MOVE	B,[-1000,,1B18+1B20+1B22+0]	;EVERYTHING.
	SETZ	C,			;  READ, EXECUTE, COPY ON WRITE.
	SSAVE
	HRRZS	A
	CLOSF
	 JFCL
>
	HRROI	A,[ASCIZ /
Done.  Thank you.
/]
	PSOUT
	HALTF
	JRST	.-1

; MASSIVE RE-ORGANIZATION

; VARIABLES

LOC 10000

FLAGPG==./1000
	BLOCK 1000

PROMPT:	BLOCK 1
SAVACS:	BLOCK 20	;TO SAVE ACCUMULATORS
MONITV:	BLOCK 1
PDL2:	BLOCK 4
PDL:	BLOCK PDLL
FILSTK:	BLOCK NFILS
INFIL:	BLOCK 1
MSG:	BLOCK 1
MSGLEN:	BLOCK 1
HEAD:	BLOCK 1
HEDLEN:	BLOCK 1
SUBJCT:	BLOCK 1
DEFHST:	BLOCK 1
XDIST:	BLOCK 1
DISTL:	BLOCK 1
DIST:	BLOCK NDIST
HOST:	BLOCK NUSRS
USRTAB:	BLOCK NUSRS
FILNAM:	BLOCK NFILS
NUSERS:	BLOCK 1
TIMFRK:	BLOCK 1
SAVEP:	BLOCK 1
RETPC1:	BLOCK 1
SUPRET:	BLOCK 1
LHOSTN:	BLOCK 1
LHOST:	BLOCK 1
FSKT:	BLOCK 1
RJFN:	BLOCK 1
SJFN:	BLOCK 1
ENDPTR:	BLOCK 1
OLDCNT:	BLOCK 1
SPATCR:	BLOCK 1
SITEN:	BLOCK 1
SITE:	BLOCK 1
FROMNM:	BLOCK 1
HSTFRE:	BLOCK 1		;SPACE COUNTER INTO HSTTAB
HOSTN:	BLOCK 1		;POINTER TO HOST NUMBERS AND BITS
HSTNAM:	BLOCK 1		;POINTER TO HOST ASCII STRINGS
HSOUTX:	BLOCK 1		;TEMP FOR HSTSOU ROUTINE
REPLY:	BLOCK 100
HSTTAB:	BLOCK NHSTTB	;SPACE FOR HOST NAMES AND NUMBERS
STRING:	BLOCK MAXMSG/5
ESTRING:

RELOC

	END	INITIT