Google
 

Trailing-Edge - PDP-10 Archives - BB-H137A-BM - uetp/lib/sender.mac
There are 3 other files named sender.mac in the archive. Click here to see a list.
TITLE SENDER


;COPYRIGHT (C) 1977 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
	SEARCH MONSYM, MACSYM
	.REQUIRE SYS:MACREL
	SALL

; ACCUMULATOR DEFINITIONS

	T1=1		;TEMPORARY
	T2=2		;TEMPORARY
	T3=3		;TEMPORARY
	T4=4		;TEMPORARY
	Q1=5		;PRESERVED
	Q2=6		;PRESERVED
	Q3=7		;PRESERVED
	P1=10		;PRESERVED
	P2=11		;PRESERVED
	P3=12		;PRESERVED
	P4=13		;PRESERVED
	P5=14		;PRESERVED
	P6=15		;PRESERVED (CAUTION, USED BY SOME MACROS IN MACSYM)
	CX=16		;RESERVED FOR SUPPORT CODE
	P=17		;PUSH-DOWN POINTER

; VERSION NUMBER DEFINITIONS

VMAJOR==1		;MAJOR VERSION OF SENDER
VMINOR==0		;MINOR VERSION NUMBER
VEDIT==1		;EDIT NUMBER
VWHO==0			;GROUP WHO LAST EDITED PROGRAM (0=DEC DEVELOPMENT)

VSENDER== <VWHO>B2+<VMAJOR>B11+<VMINOR>B17+VEDIT

NCHPW==5		;NUMBER OF ASCII CHARACTERS PER WORD
BUFSIZ==200		;SIZE OF INPUT TEXT BUFFER
ATMSIZ==BUFSIZ		;SIZE OF ATOM BUFFER FOR COMND JSYS
MSGBL==ATMSIZ
GJFSIZ==.GJRTY+2	;SIZE OF GTJFN BLOCK USED BY COMND JSYS
FDBSIZ==.CMDEF+2	;SIZE OF FUNCTION DESCRIPTOR BLOCK
PDLEN==50		;PUSH-DOWN STACK LENGTH
RETRY==2000		;COUNT OF NUMBER OF MSEND RETRIES
IPCFPG=6000		;PAGE AT 600000 FOR IPCF TRAFFIC

DEFINE TXT(TEXT) <POINT 7,[ASCIZ\TEXT\]>
SUBTTL	MAIN ENTRY POINT AND INITIALIZATION

START:	RESET			;RESET THE UNIVERSE
	MOVE	T1,[JRST BADSTR]	;IN CASE STARTED A SECOND TIME...
	MOVEM	T1,ENTVEC	; WE WILL COMPLAIN HEAVILY
	MOVEM	T1,ENTVEC+1	;JUST TO BE SURE
	MOVE P,[IOWD PDLEN,PDL]	;SET UP STACK
	SETZM TAKFLG		;MARK THAT TAKE FILE NOT BEING PROCESSED

;INITIALIZE OUR PID

	MOVEI	T1,.MUCRE	;PARM FOR THE PID CREATE
	MOVEM	T1,IPCOM	;PLACE IN CONTROL BLOCK
	MOVE	T1,[.FHSLF]	;MAKE OUT PID JOB WIDE
	MOVEM	T1,IPCOM+1		;PLACE IN CONTROL BLOCK
	MOVEI	T1,3			;TWO WORD PARM
	MOVEI	T2,IPCOM		;ADDR OF PARM CONTROL BLOCK
	MUTIL				; JSYS-IPCF UTILITY- UP PID
	 JRST	[HRROI	T1,[ASCIZ/?ERROR IN ASSIGNING A PID AT START:, (FROM SENDER)/]
		 CALL	ERABRT]		;SEND MESSAGE AND ABORT
	MOVE	T1,IPCOM+2		;LOAD THE JUST CREATED PID
	MOVEM	T1,OURPID		;AND SAVE PERMANENTLY
;	GET <SYSTEM>INFO PID

	MOVEI	T1,.MUGTI		;FUNCTION TO GET <SYSTEM>INFO PID
	MOVEM	T1,IPCOM		;PLACE IN CONTROL BLOCK
	MOVE	T1,OURPID		;GET OUR PID FOR IDENTIFICATION
	MOVEM	T1,IPCOM+1
	MOVEI	T1,3			;TWO WORD PARM
	MOVEI	T2,IPCOM		;ADDRESS OF PARM CONTROL BLOCK
	MUTIL				;JSYS- GET <SYSTEM>INFO PID
	 JRST	[HRROI	T1,[ASCIZ/?ERROR IN ASSIGNING SYSTEM PID AT START:, (FROM SENDER)/]
		 CALL	ERABRT]		;SEND MSG AND ABORT
	MOVE	T1,IPCOM+2		;LOAD THE <SYSTEM>INFO PID
	MOVEM	T1,SYSPID		;SAVE IN PERMANENT STORAGE

;	GET PID OF THE SWITCH ROUTINE ("UETP-SWITCH-DIRECOTRY")

	MOVEI	Q1,IPCOM		;POINT TO BASE IPCF BLOCK
	MOVE	T1,[1234,,.IPCIW]	;IDENTITY CODE,,GET PID CODE
	MOVEM	T1,.IPCI0(Q1)		;INTO IPCF COMMUNICATION BLOCK
	SETZM	.IPCI1(Q1)		;NO ONE ELSE TO GET THIS RESPONSE
	HRROI	T1,.IPCI2(Q1)		;PLACE STRING IN THERE
	HRROI	T2,[ASCIZ/UETP-SWITCH-/]	;NAME WE WANT PID FOR
	SETZ	T3,			;WRITE ASCIZ STRING
	SOUT
	MOVE	Q2,T1			;SAVE THE STRING POINTER
	HRROI	T1,-1			;NOW GET DIRECTORY NUMBER WHICH
	MOVE	T2,[-1,,4]		;WILL GIVE US THE DIRECTORY NAME
	MOVEI	T3,.JIDNO
	GETJI
	 JRST	[HRROI	T1,[ASCIZ/GETJI JSYS PROBLEMS AT STEXEC:/]
		 CALL	ERABRT]
	MOVE	T1,Q2			;POINTER FOR WHERE IT'S GOING IN MSGBUF
	MOVE	T2,T4			;T4 HAS DIRECTORY NUMBER IN IT
	DIRST				;GO TRANSLATE DIRECTORY NUM TO DIR NAME
	 JRST	[HRROI	T1,[ASCIZ/ERROR IN DIRST JSYS AT STEXEC:/]
		 CALL	ERABRT]
; <SYSTEM>INFO CHECKS FOR A DIRECTORY STRING - THIS CAUSES PROBLEMS ON
;	MULTIPLE STRUCTURES.  GET RID OF THE < OR [

	MOVE	T2,[POINT 7,IPCOM+.IPCI2]	;POINT TO STRING
CHKMOR:	ILDB	T1,T2			;GET BYTE
	CAIN	T1,"<"			;START OF DIRECTORY?
	JRST	CHKDON			;YES - GET RID OF IT
	CAIE	T1,"["			;THIS IS A LEGAL DIRECTORY STARTER
	JRST	CHKMOR			;NOT YET - KEEP LOOKING
CHKDON:	MOVEI	T1,"-"			;TAKE SOME RANDOM CHARACTER
	DPB	T1,T2			;AND DEPOSIT IT

	MOVE	T1,[IPCOML,,IPCOM]	;LENGTH,,ADDRESS TO SUBROUTINE
	CALL	SYSEND			;SEND REQUEST TO <SYSTEM>INFO
	CALL	SYSRCV			;GO GET REPLY
	MOVE	T1,PDB			;GET <SYSTEM>INFO RESPONSE FLAGS
	TXNE	T1,IP%CFE		;SKIP IF NO ERRORS
	JRST	[HRROI	T1,[ASCIZ/?ERROR IN GETTING PID FOR "UETP-SWITCH"
	(PROBABLY THE UETP IS NOT RUNNING IN THIS DIRECTORY)/]
		 CALL	ERABRT]		;SEND THE MESSAGE AND ABORT
	MOVE	T1,IPCOM+.IPCI1		;GET THE PID
	MOVEM	T1,UETPID		;AND SAVE FOR LATER USE

		;..
SUBTTL	COMMAND PARSER AND DISPATCH

	;..

	HRROI T1,PROMPT		;GET POINTER TO PROMPT STRING
	MOVEM T1,CMDBLK+.CMRTY	;PUT RE-TYPE PROMPT POINTER IN STATE BLOCK
	HRROI T1,BUFFER		;GET POINTER TO INPUT TEXT BUFFER
	MOVEM T1,CMDBLK+.CMPTR	;SAVE POINTER TO COMMAND STRING
	MOVEM T1,CMDBLK+.CMBFP	;SAVE POINTER TO START-OF-BUFFER
	MOVE T1,[.PRIIN,,.PRIOU] ;GET PRIMARY INPUT,, OUTPUT JFN'S
	MOVEM T1,CMDBLK+.CMIOJ	;SAVE PRIMARY JFN'S
	MOVEI T1,PARSE1		;GET RE-PARSE ADDRESS
	MOVEM T1,CMDBLK+.CMFLG	;SAVE RE-PARSE ADDRESS
	SETZM CMDBLK+.CMINC	;INITIALIZE # OF CHARACTERS AFTER POINTER
	MOVEI T1,BUFSIZ*NCHPW	;GET # OF CHARACTERS IN BUFFER AREA
	MOVEM T1,CMDBLK+.CMCNT	;SAVE INITIAL # OF FREE CHARACTER POSITIONS
	HRROI T1,ATMBFR		;GET POINTER TO ATOM BUFFER
	MOVEM T1,CMDBLK+.CMABP	;SAVE POINTER TO LAST ATOM INPUT
	MOVEI T1,ATMSIZ*NCHPW	;GET # OF CHARACTERS IN ATOM BUFFER
	MOVEM T1,CMDBLK+.CMABC	;SAVE COUNT OF SPACE LEFT IN ATOM BUFFER
PARSE:	HRROI T1,PROMPT		;GET POINTER TO PROGRAM'S PROMPT STRING
	CALL CMDINI		;OUTPUT THE PROMPT

PARSE1:	MOVE P,[IOWD PDLEN,PDL]	;SET UP STACK AGAIN
	SETOM T1		;INDICATE ALL JFN'S SHOULD BE RELEASED
	RLJFN			;RELEASE ALL JFN'S
	JRST	[HRROI	T1,[ASCIZ/?ERROR IN RLJFN AT PARSE1/]
		 CALL	ERSEND	;SEND MESSAGE TO SWITCH AN TTY
		 JRST	PARSE]	;RE-INITIALIZE AND CONTINUE
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK

	MOVEI T1,GJFBLK		;GET ADDRESS OF GTJFN BLOCK
	MOVEM T1,CMDBLK+.CMGJB	;STORE POINTER TO GTJFN BLOCK
	MOVEI T1,CMDBLK		;GET POINTER TO COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMKEY,,CMDTAB)] ;GET FUNCTION BLOCK
	COMND			;DO INITIAL PARSE
	 erjmp cmderr		;error, go check for eof on take file
	TXNN T1,CM%NOP		;VALID COMMAND ENTERED ?
	JRST PARSE5		;YES, GO DISPATCH TO PROCESSING ROUTINE
	HRROI T1,[ASCIZ/? SENDER: No such ****** command /]
	CALL	ERSEND		;GO SEND ERROR TO TTY AND SWITCH
	JRST PARSE		;GO TRY TO GET A COMMAND AGAIN

PARSE5:	HRRZ T1,(T2)		;GET DISPATCH ADDRESS
	CALL (T1)		;PERFORM REQUESTED FUNCTION
	JRST PARSE		;GO PARSE NEXT COMMAND
SUBTTL	TAKE (COMMANDS FROM) FILE-SPEC (LOGGING OUTPUT ON) FILE-SPEC

.TAKE:	HRROI T2,[ASCIZ/COMMANDS FROM/] ;GET NOISE TEXT
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK
	MOVX T1,GJ%OLD		;GET EXISTING FILE FLAG
	MOVEM T1,GJFBLK+.GJGEN	;STORE GTJFN FLAGS
	HRROI T1,[ASCIZ/CMD/]	;GET DEFAULT FILE TYPE FIELD
	MOVEM T1,GJFBLK+.GJEXT	;STORE DEFAULT EXTENSION
	MOVEI T1,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMFIL)] ;GET FUNCTION DESCRIPTOR BLOCK ADDRESS
	COMND			;PARSE INPUT FILE SPEC
	 erjmp cmderr		;error, go check for eof on take file
	TXNN T1,CM%NOP		;PARSED FILE-SPEC OK ?
	JRST TAKE10		;YES, GO ON AND SAVE INPUT JFN
	HRROI T1,[ASCIZ/? SENDER: Invalid file specification. /]
	CALLRET ERSEND		;OUTPUT ERROR STRING TO TERMINAL

; HERE ON A GOOD INPUT FILE SPEC

TAKE10:	MOVEM T2,INJFN		;SAVE INPUT JFN FOR COMMANDS
	HRROI T2,[ASCIZ/LOGGING OUTPUT ON/] ;GET NOISE TEXT
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK USED BY COMND JSYS
	MOVX T1,GJ%FOU		;GET FLAG SAYING FILEIS FOR OUTPUT USE
	MOVEM T1,GJFBLK+.GJGEN	;SAVE GTJFN FLAGS
	SETZM NAMBUF		;INITIALIZE FILENAME BUFFER
	HRROI T1,NAMBUF		;GET POINTER TO WHERE FILENAME IS TO GO
	MOVE T2,INJFN		;GET INPUT JFN
	MOVX T3,<FLD(.JSAOF,JS%NAM)> ;GET FLAG BITS SAYING OUTPUT NAME ONLY
	JFNS			;GET FILE NAME OF INPUT FILE
	SKIPE NAMBUF		;ANY FILENAME ?
	HRROI T1,NAMBUF		;YES, GET A POINTER TO THE FILE NAME FOR INPUT
	MOVEM T1,GJFBLK+.GJNAM	;STORE DEFAULT NAME OF OUTPUT FILE
	HRROI T1,[ASCIZ/LOG/]	;GET DEFAULT FILE TYPE OF OUTPUT FILE
	MOVEM T1,GJFBLK+.GJEXT	;STORE DEFAULT EXTENSION
	MOVEI T1,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMFIL)] ;GET FILE-SPEC FUNCTION BLOCK ADDRESS
	COMND			;PARSE OUTPUT FILE SPEC
	 erjmp cmderr		;error, go check for eof on take file
	TXNN T1,CM%NOP		;FILE SPEC PARSED OK ?
	JRST TAKE20		;YES, GO ON TO SAVE JFN
	HRROI T1,[ASCIZ/? SENDER: Invalid file specification. /]
	CALLRET ERSEND		;GO OUTPUT CORRECT MESSAGE AND RETURN

; HERE TO SAVE OUTPUT JFN AND GET COMMAND CONFIRMATION

TAKE20:	MOVEM T2,OUTJFN		;SAVE LOGGIN FILE JFN
	CALL ENDCOM		;GO PARSE COMMAND CONFIRMATION
	 RET			;RETURN, BAD CONFIRMATION

; OPEN INPUT AND OUTPUT FILES

	MOVE T1,INJFN		;GET INPUT JFN
	MOVE T2,[7B5+OF%RD]	;7 BIT BYTES, READ ACCESS
	OPENF			;OPEN INPUT FILE
	 JRST [	HRROI T1,[ASCIZ/? SENDER: Cannot OPEN command file. /]
		CALLRET ERSEND]	;GO ISSUE REST OF MESSAGE AND RETURN

	MOVE T1,OUTJFN		;GET OUTPUT JFN
	CAIN T1,.PRIOU		;STILL PRIMARY OUTPUT JFN ?
	JRST TAKE30		;NO OUTPUT JFN, GO ON
	MOVE T2,[7B5+OF%WR]	;7 BIT BYTES, WRITE ACCESS
	OPENF			;OPEN OUTPUT FILE
	 JRST [	CALL TSTCOL	;ERROR, ISSUE NEW LINE IF NEEDED
		MOVE T1,INJFN	;GET INPUT JFN AGAIN
		CLOSF		;CLOSE INPUT FILE
		 JFCL		;IGNORE ERRORS HERE
		HRROI T1,[ASCIZ/? SENDER: cannot OPEN logging file. /]
		CALLRET ERSEND]	;GO OUTPUT REST OF MESSAGE

; NOW SAVE NEW JFN'S AND RETURN TO PARSER

TAKE30:	HRLZ T1,INJFN		;GET INPUT JFN
	HRR T1,OUTJFN		;GET OUTPUT JFN
	MOVEM T1,CMDBLK+.CMIOJ	;SAVE NEW JFN'S
	SETOM TAKFLG		;MARK THAT COMMANDS ARE COMING FROM FILE
	RET			;RETURN TO PARSER
			SUBTTL BLABEL - COMMAND DO DEFINE DEFAULT TEST LABEL
.BLABE:	MOVE	T1,[POINT 7,TSTLBL]	;WHERE DEFAULT BATCH LABEL GOES
	MOVEI	T2,^D10			;LABEL IS 6 CHARS LONG
	HRROI	T3,[ASCIZ/?ERROR IN TLABEL COMMAND (FROM SENDER)/] ; ERROR MSG
	CALL	TXTFIL			;GO GET THE DEFAULT
	JRST	PARSE			;GET NEXT COMMAND
				SUBTTL  EXTRACT - ROUTINE TO EXTRACT DISK RECORDS

.EXTRA:	HRROI	T2,[ASCIZ/MESSAGES FROM/]	;NOISE FOR EXTRACT COMMAND
	CALL	SKPNOI			;GO PARSE NOISE FIELD
	 RET				;RETURN IF PROBLEM
	CALL	CLRGJF			;CLEAR THE GTJFN BLOCK FOR COMND USE
	MOVX	T1,GJ%OLD		;GETTING JFN FOR AN OLD FILE
	MOVEM	T1,GJFBLK+.GJGEN	;STUFF IN GTJFN BLOCK
	HRROI	T1,[ASCIZ/LOG/]		;DEFAULT FILE TYPE
	MOVEM	T1,GJFBLK+.GJEXT	;INTO GTJFN BLOCK
	MOVEI	T1,CMDBLK		;POINT TO COMND STATUS BLOCK
	MOVEI	T2,[FLDDB. (.CMFIL)]	;FDB FOR PARSING FILE SPEC
	COMND				;GO PARSE THE FILE SPED
	 ERJMP	CMDERR			;ERROR IN COMMAND - GO HANDLE
	TXNN	T1,CM%NOP		;WAS THIS A GOOD PARSE(I.E.GOOD JFN)
	JRST	EXTDAT			;YES - THEN GO EXTRACT DATA
	HRROI	T1,[ASCIZ/?ERROR IN EXTRACT COMMAND(FROM SENDER)./]
	CALL	ERSEND			;SEND ERROR MSG'S TO  SWITCH AND TTY
	JRST	PARSE			; AND GET NEW COMMAND
; HERE TO EXTRACT RECORDS FROM FILE AND SHIP TO SWITCH

EXTDAT:	MOVEM	T2,EXTJFN		;STORE THE JFN
	CALL	ENDCOM			;GO GET CONFIRMATION (CR,LF) FROM USER
	 RET				;SOMETHING WENT WRONG
;   NOW OPEN THE FILE
	MOVE	T1,EXTJFN		;GET THAT JFN FOR OPENING
	MOVE	T2,[7B5+OF%RD]		;READ THE FILE ONLY
	OPENF				;NOW OPEN IT
	 JRST	[HRROI	T1,[ASCIZ/?ERROR IN OPEN FOR EXTRACT (FROM SENDER)/]
		 CALL	ERSEND		;SEND ERROR TO SWITCH AND TTY
		 JRST	PARSE]		;GET NEXT COMMAND
; READ-SHIP LOOP
EXTRD:	MOVE	T1,EXTJFN		;JFN FOR THE READING
	HRROI	T2,MSGBUF		;WHERE RECORD WILL BE STORED
	MOVEI	T3,MSGBL		;MAXIMUM LENGTH OF RECORD
	MOVEI	T4,.CHLFD		;END OF RECORD CHARACTER
	SIN				;READ THE RECORD
	 ERJMP	[MOVE	T1,EXTJFN	;JFN FOR WHICH WE'RE EOF TESTING
		 GTSTS			;GET CURRENT STATUS
		 TXNE	T2,GS%EOF	;SKIP IF NOT EOF
		 JRST	EXTEOF		;YES EOF - THEN HANDLE IT
		 HRROI	T1,[ASCIZ/?ERROR IN SIN IN EXTRACT (FROM SENDER)/]
		 CALL	ERSEND		;SEND MESSAGE TO SWITCH AND TTY
		 JRST	PARSE]		;READ MORE COMMANDS
	MOVEI	T2,MSGBL		;COMPUTE NUMBER OF BYTES READ
	SUB	T2,T3			;(MAX LENGTH)-RESIDUAL COUNT
	HRROI	T1,MSGBUF		;POINT TO START OF AREA.
	CALL	SHIP			;AND SHIP IT
	JRST	EXTRD			;KEEP READING TO EOF

EXTEOF:	HRRZ	T1,EXTJFN		;CLOSE FILE RELEASE JFN
	CLOSF				;CLOSE IT
	 JFCL
	SETZM	EXTJFN			;CLEAN-UP AS A PRECAUTION
	RET				;RETURN TO CALLER
			SUBTTL  TEST - TEST NAME DEFAULT COMMAND
.TEST:	HRROI	T2,[ASCIZ/NAME/]	;NOISE FIELD FOR PARSER SUBROUTINE
	CALL	SKPNOI			;GO PARSE THE NOISE
	 RET				;FAILURE - RETURN
	MOVE	T1,[POINT 7,TNAME]	;POINT TO WHERE DEFAULT NAME GOES
	MOVEI	T2,^D6			;6 CHARACTER DEFAULT
	HRROI	T3,[ASCIZ/?ERROR IN TEST NAME COMMAND (FROM SENDER)/] ;ERROR  MSG
	CALL	TXTFIL			;GO PARSE DEFAULT NAME
	JRST	PARSE			;CONTINUE PARSING
		SUBTTL TYPE - TYPE OF MESSAGE DEFAULT COMMAND
.TYPE:	HRROI	T2,[ASCIZ/TYPE OF MESSAGE/]	;NOISE FIELD
	CALL	SKPNOI			;GO PARSE THE NOISE
	 RET
	MOVEI	T1,CMDBLK		;GO PARSE MESSAGE TYPE KEYWORD
	MOVEI	T2,[FLDDB.	(.CMKEY,,MTYPES)]	;MTYPES IS KEYWORD TABLE
	COMND				;GO PARSE
	 ERJMP	CMDERR			;ERROR COULD BE EOF ON TAKE FILE
	TXNN	T1,CM%NOP		;BAD PARSE?
	JRST	TYPCNF			;NO - GO GET CR,LF (CONFIRMATION)
	HRROI	T1,[ASCIZ/?*****: INVALID OPTION FOR TYPE COMMAND/] ;YES - ERROR
	CALL	ERSEND			;SEND MESSAGE TO TTY AND SWITCH
	JRST	PARSE			;GET NEXT COMMAND

TYPCNF:	HLRZ	P1,(T2)			;GET ADDRESS OF CHOSEN KEYWORD
	CALL	ENDCOM			;GET THE CR,LF
	 RET				;ERROR - TOO BAD
	HRROI	T1,DEFTYP		;POINT TO DESTINATION FOR SOUT
	HRRO	T2,P1			;POINT TO SOURCE
	HRROI	T3,-5			;MOVE WHOLE STRING
	SOUT				;MOVE IT
	JRST	PARSE			;GET NEXT COMMAND
; 			SUBTTL SEND - COMMAND TO SEND MESSAGE TO "SWITCH"
;
.SEND:	MOVE	T1,[POINT 7,ATMBFR]	;WE'LL USE THE BUFFER IT COMES IN
	MOVEI	T2,ATMSIZ		;FO THE FULL LENGTH
	HRROI	T3,[ASCIZ/?ERROR IN SEND COMMAND (FROM SENDER)/] ;ERROR MSG
	CALL	TXTFIL			;CALL THE TEXT GETTER
	MOVEI	T1,.NULIO		;GETTING LENGTH SO WRITE TO VOID SPACE
	HRROI	T2,ATMBFR		;POINT TO STRING TO BE MEASURED
	MOVEI	T3,ATMSIZ		;MAX LENGTH
	SETZ	T4,			;LOOKING FOR ASCIZ STRING
	SOUT				;GO FIND OUT HOW MANY BYTES LONG
	MOVEI	T2,ATMSIZ		;FULL LENGTH MINUS
	SUB	T2,T3			;    RESIDUAL COUNT EQUALS LENGTH
	HRROI	T1,ATMBFR		;POINT TO THE BUFFER
	CALL	SHIP			;SEND THE MESSAGE
	RET
SUBTTL	HELP AND EXIT COMMANDS

	; HELP COMMAND

.HELP:	HRROI T2,[ASCIZ/WITH SENDER/] ;GET NOISE WORDS
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL ENDCOM		;GO PARSE END OF COMMAND
	 RET			;BAD CONFIRMATION, RETURN
	HRROI T1,HLPMSG		;GET POINTER TO HELP MESSAGE
	PSOUT			;OUTPUT HELP MESSAGE
	RET			;GO PARSE NEXT COMMAND

; EXIT COMMAND

.EXIT:	HRROI T2,[ASCIZ/TO MONITOR/] ;GET NOISE PHRASE
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL ENDCOM		;GO PARSE END OF COMMAND
	 RET			;BAD CONFIRMATION, RETURN
	SETOM T1		;INDICATE ALL FILES SHOULD BE CLOSED
	CLOSF			;CLOSE ALL OPEN FILES
	 JSERR			;UNEXPECTED ERROR
	RESET			;RESET THE WORLD
	HALTF			;RETURN TO MONITOR
	JRST START		;IF CONTINUE'D, START OVER
SUBTTL	COMMAND ERROR SUBROUTINES

; INVALID END-OF-COMMAND

CFMERR:	HRROI T1,[ASCIZ/? SENDER: Garbage at end-of-command/]
	CALL	ERSEND		;SEND MSG TO SWITCH AND TTY
	RET			;RETURN TO WHENCE WE CAME ...


; SUBROUTINE TO TEST COLUMN POSITION AND OUTPUT CRLF IF NEEDED

TSTCOL:	MOVEI T1,.PRIOU		;GET PRIMARY OUTPUT DESIGNATOR
	RFPOS			;READ FILE POSITION
	HRRZ T2,T2		;KEEP JUST THE COLUMN POSITION
	JUMPE T2,R		;IF AT COLUMN 1 DO NOT OUTPUT CRLF
	TMSG <
>				;NO, OUTPUT A CRLF
	RET			;RETURN TO WHENCE WE CAME ...


; ROUTINE TO OUTPUT THE JSYS MESSAGE ON AN ERROR FROM A GTJFN OR OPENF
;
; CALL:		CALL PUTERR
; RETURNS: +1 ALWAYS

PUTERR:	MOVX T1,.PRIOU		;GET PRIMARY OUTPUT JFN
	HRLOI T2,.FHSLF		;OUR FORK, LAST ERROR CODE
	SETZM T3		;
	ERSTR			;OUTPUT ERROR STRING
	 JFCL			;IGNORE
	 JFCL			;IGNORE
	TMSG <
>				;OUTPUT NEW LINE
	RET			;RETURN TO WHENCE WE CAME ...
;BADSTR - BAD START - ROUTINE TO TELL USER PROGRAM WAS STARTED
;			FOR SECOND TIME ILLEGALLY.

BADSTR:	MOVE	T1,[ASCIZ/ERROR/]	;GET NEW MSG TYPE
	MOVEM	T1,DEFTYP		;AND SAVE
	HRROI	T1,[ASCIZ/?SENDER STARTED ILLEGALLY.BATCH CONTROL ERROR/]
	MOVEI	T2,^D49
	PUSH	P,T1
	CALL	SHIP
	POP	P,T1
	PSOUT
	HALTF
	HALTF
;PUTATM - ROUTINE TO TYPE THE CONTENTS OF THE ATOM BUFFER
;
;ACCEPTS IN T1/	POINTER TO ASCIZ PREFIX STRING TO BE TYPED
;		CALL TYPATM
;RETURNS: +1 ALWAYS

TYPATM:	STKVAR <ATOMPT>
	MOVEM T1,ATOMPT		;SAVE ATOM POINTER
	CALL TSTCOL		;ISSUE NEW LINE IF NEEDED
	TMSG <? SENDER: >	;OUTPUT INITIAL PART OF MESSAGE
	MOVE T1,ATOMPT		;RESTORE ATOM POINTER
	PSOUT			;OUTPUT THE STRING
	TMSG < ">		;OUTPUT PUNCTUATION
	HRROI T1,ATMBFR		;GET POINTER TO THE ATOM BUFFER
	PSOUT			;OUTPUT THE TEXT ENTERED
	TMSG <"
>				;OUTPUT END OF LINE
	RET			;RETURN
; ROUTINE TO SHIP ERROR MESSAGES TO TERMINAL AND TO SWITCH
;
;CALL:	T1/POINTER TO USER DEFINED ERROR MESSAGE
;
;RETURNS:	+1, ALWAYS

ERSEND:	SAVEAC	<P1,P2,P3,P4,P5,P6>	;SAVE THE AC'S
	MOVEM	T1,P1			;SAVE THE POINTER
	PSOUT				;TYPE USER MSG ON TTY
	CALL	TSTCOLL			;ADJUST CURSOR
	JSERR				;TYPE OUT LAST MESSAGE
	MOVE	P4,DEFTYP		;SAVE CURRENT MSG TYPE
	MOVE	T1,[ASCIZ/ERROR/]	;GET NEW MSG TYPE
	MOVEM	T1,DEFTYP		;AND SAVE
	HRROI	T1,MSGBUF		;WHERE TO PUT THE STRING
	MOVE	T2,P1			;STRING WHOSE LENGTH WE WANT
	MOVEI	T3,MSGBL		;MAXIMUM LENGTH
	SETZ	T4,			;END ON ZERO BYTE
	SOUT				;PUT STRING IN IPCF PAD
	 ERJMP	.+1			;IGNORE ERRORS
	MOVEI	T2,MSGBL		;NOW COM