Google
 

Trailing-Edge - PDP-10 Archives - ap-c796e-sb - queue.mac
There are 9 other files named queue.mac in the archive. Click here to see a list.
	SUBTTL	P.CONKLIN/DAL/PFC	17-NOV-73


;***COPYRIGHT 1970, 1971, 1972, 1973  DIGITAL EQUIPMENT CORP., MAYNARD, MASS.***


DECVER==5		;DEC VERSION
DECMVR==0		;DEC MINOR VERSION
DECEVR==1212		;DEC EDIT NUMBER
CUSTVR==0		;CUSTOMER VERSION


;ASSEMBLY INSTRUCTIONS:
;
IF1,<	..==%%C+%%SCNM
IFNDEF	..,<
PRINTX	?	.LOAD (P,,)C+SCNMAC+QUEUE,QUEUER,SCAN,HELPER,WILD
	PASS2
	END>
	PURGE	..>


;THIS PROGRAM CONSISTS OF TWO PARTS.  THE FIRST IS THE QUEUE MANAGER
;AND IS A SHARABLE HIGH SEGMENT.  IT APPEARS AS FILE QMANGR.MAC.
;THE SECOND IS THE QUEUE COMMAND PROCESSOR AND IS THIS FILE.
;THIS CONSISTS OF TWO SEGMENTS.  THE LOW CONTAINS THE LISTER AND
;TTY CODE.  THE HIGH CONTAINS THE REMAINDER OF THE QUEUE COMMAND
;PROCESSOR.
;FOR A FULL DESCRIPTION, REFER TO THE DETAILED DESIGN
;SPECIFICATION (FILE QUEUE.RNO OR QUEUE.MAN).  THAT FILE IS THE
;ARBITER OF THE SPECIFICATION AND SHOULD BE UPDATED TO REFLECT
;ANY SPEC CHANGES.
	SUBTTL	PARAMETERS AND DEFAULTS


;ASSEMBLY PARAMETERS

ND LN.PDL,60		;LENGTH OF PUSH-DOWN LIST
ND LN.KJL,1700		;RESERVED LOW-CORE AREA FOR KJOB MEMORY
ND DEBUG,1		;1=INCLUDE DEBUGGING FEATURES
ND PURESW,1		;1=REENTRANT VERSION

ND QUEUEN,<SIXBIT /QUEUE/>  ;NAME OF THIS CUSP FOR QUEUER
ND PUNCDP,0		;0=PUNCH COMMAND TO PTP
			;1=PUNCH COMMAND TO CDP
ND FTLSCK,0		;0=ALLOW ANY STATION NUMBER OR DEVICE
			;1=RESTRICT TO LEGAL STATIONS AND DEVICES
;DEFAULTS


	RADIX	^D10
DM AFT,  10080,   0,  10	;AFTER CURRENT TIME IN MINUTES
DM CDP, 100000, -60,2000	;CARD PUNCH LIMIT IN CARDS
DM COP,     63,   1,   0	;NUMBER OF COPIES OF OUTPUT
DM COR,^O777777,25600,40960	;CORE LIMIT FOR JOB
DM DED,  10080,   0,  60	;DEADLINE FROM CURRENT TIME IN MINUTES
DM DPN,  65535,   0,   0	;INITIAL DEPENDENCY COUNT
DM LIM, 100000,  -1,   0	;OUTPUT LIMIT
DM LPT, 100000,  -1,2000	;LINE PRINT LIMIT IN PAGES
DM NHD,      1,   1,   1	;WHETHER TO PRINT FILE HEADERS
DM OUT,      4,   4,   4	;DEGREE OF OUTPUT QUEUEING
DM PLT, 100000,  -1,  60	;PLOT LIMIT IN MINUTES		[1201]
DM PRI,     62,  10,  20	;EXTERNAL PRIORITY
DM PTP, 100000, -10, 100	;PT PUNCH LIMIT IN FEET
DM RST,      1,   0,   1	;INP: RESTARTABLILITY
DM SEQ, 100000,   0,   0	;JOB'S SEQUENCE NUMBER
DM STR, 100000,   1,   1	;STARTING POINT IN FILE
DM TIM,  30000, 300,3600	;TIME LIMIT FOR JOB IN SECONDS
DM UNI,      2,   1,   2	;DEGREE OF FILE NAME UNIQUENESS


ND AB.CDP,80		;/BEGIN TO /START CONVERSION FOR CDP
ND AB.LPT,60		;/BEGIN TO /START CONVERSION FOR LPT
ND AB.PLT,1		;/BEGIN TO /START CONVERSION FOR PLT	[1201]
ND AB.PTP,120		;/BEGIN TO /START CONVERSION FOR PTP
ND AD.LFD,DISPPRESERVE	;LOG FILE DISPOSITION
ND AD.OPN,QO.CRE	;STANDARD OPERATION IS /CREATE
ND AI.CDP,0		;INPUT REQUEST CARD PUNCH LIMIT
ND AI.LPT,200		;INPUT REQUEST PRINT LIMIT
ND AI.PLT,10		;INPUT REQUEST PLOT LIMIT
ND AI.PTP,0		;INPUT REQUEST PAPER TAPE PUNCH LIMIT
ND AO.CDP,100		;ADDON FOR DEFAULT OUTPUT CARDS
ND AO.LPT,20		;ADDON FOR DEFAULT OUTPUT PAGES
ND AO.PLT,5		;ADDON FOR DEFAULT PLOT TIME
ND AO.PTP,20		;ADDON FOR DEFAULT FEET OF PAPER TAPE PUNCH
ND AV.CDP,1		;DIVISOR FOR DEFAULT OUTPUT CARDS	[1201]
ND AV.LPT,1		;DIVISOR FOR DEFAULT OUTPUT PAGES	[1201]
ND AV.PLT,20		;DIVISOR FOR DEFAULT OUTPUT PLOT TIME	[1201]
ND AV.PTP,1		;DIVISOR FOR DEFAULT FEET OF PAPER TAPE	[1201]
ND FL.COP,1		;FORCED NUMBER OF COPIES OF LOG FILE
ND FS.COP,1		;FORCED NUMBER OF COPIES FOR SPOOLED OUTPUT
	RADIX	8
;QUEUES MACRO DEFINES THE LEGAL QUEUES IN ORDER
; RESTRICTION--'INP' MUST BE FIRST
; NOTE--REMOVING A QUEUE WILL NOT REMOVE THE CODE TO SUPPORT
; IT BUT THE CODE WILL NOT BE EXERCISED.  ADDING A QUEUE WILL
; PROBABLY REQUIRE SPECIAL CODE TO SUPPORT IT AS WELL.
; ### NOTE THAT QUEEXT PARALLELS THIS MACRO.

IFNDEF  QUEUES,<DEFINE QUEUES,<X <INP,LPT,CDP,PTP,PLT>>>


;QUEEXT MACRO DEFINES THE DEFAULT EXTENSIONS IN THE SAME ORDER
; AS THE QUEUES MACRO.

IFNDEF  QUEEXT,<DEFINE QUEEXT,<X <CTL,LPT,CDP,PTP,PLT>>>


;VERIFY THAT THESE ARE ROUGHLY COMPATABLE

	DEFINE X(A),<
			..TEMP==0
			IRP(A),<..TEMP==..TEMP+1>>
	QUEUES
	..TEM==..TEMP
	QUEEXT
	IFL	..TEM-..TEMP,<PRINTX	?  QUEUES AND QUEEXT DISAGREE>

	DEFINE	X(A),<
			IRP(A),<
		IFDIF	<A><INP>,< PRINTX ? FIRST QUEUE TYPE MUST BE INP NOT A>
			STOPI>>
	QUEUES

DEFINE	QUETTL(E,V,W),<
IFE W,<	TITLE	QUEUE -- SYSTEM QUEUEING PROGRAM %'V'(E)
>
IFN W,<	TITLE	QUEUE -- SYSTEM QUEUEING PROGRAM %'V'(E)-'W
>>
	QUETTL(\DECEVR,\DECVER,\CUSTVR)
	SUBTTL	REVISION HISTORY

;%4	JUNE 1972

;612	CMCO #1
;613	CMCO #2
;1100	CONVERSION TO USE SCAN AND WILD:
;1101	ADDED 1000 TO THE EDIT NUMBER.
;1102	UPDATED ASSEMBLY INSTRUCTIONS TO INCLUDE SCAN
;1103	CONVERTED TITLE TO A MACRO
;1104	ADDED A TEST FOR C.MAC. QUEUE MUST NOW BE ASSEMBELED WITH
;	BOTH C AND SCNMAC
;1105	BEGAN TO TO CONVERT TO USE SCNMAC'S MACRO DEFINITIONS. THE
;	M.FAI? CHANGED TO N.FAI? TO AVOID CONFUSION WITH SCNMAC
;1106	DELETED AC T5 FROM QUEUE.
;1107	DELETED AC K FROM QUEUE.
;1110	ADDED P1=5 AND P2=6 BUT THE ARE NOT USED ANYPLACE YET.
;1111	CHANGED C FROM 16 TO 7, N FROM 14 TO 10, I FROM 10 TO 11,
;	J FROM 11 TO 12 AND M FROM 15 TO 14. ACS 15 AND 16 HAVE
;	NO NAMES AND ARE NOT USED.
;1112	DEVCHR BITS WERE CHANGED FROM THE DEFINITIONS IN QUEUE TO
;	THOSE IN C AND TEST INSTRUCTIONS WHICH USED THEM WERE CHANGED
;	FROM TL?? TO TX??.
;1113	D.SPOL WAS DELETED AND ALL THE INSTRUCTIONS WHICH
;	USE IT WERE CHANGED TO USE TY.SPL. THE VALUE IS STILL 1B13.
;1114	GETTABS WERE CHANGED TO CONFORM TO C.MAC
;1115	Q.VERS WAS CHANGED TO .QVERS
;1116	JOBDAT DEFINITIONS WERE REMOVED. THIS LEFT .JBHSA UNDEFINED
;	BUT SINCE IT IS ZERO AND WAS ONLY USED IN AN ADDI THE ADDI
;	WAS ALSO DELETED AND REPLACED WITH A COMMENT ABOUT .JBHSA
;1117	INTERN AND EXTERNS WERE FIXED UP TO USE SCAN'S TYPE OUT
;	ROUTINES.
;1120	ALL CALLS TO TYPE OUT ROUTINES WERE MODIFIED TO FOLLOW SCAN'S
;	AC USE CONVENTIONS.
;1121	/NOTE: WAS REMOVED FOR THE TIME BEING. IT WILL BE PUT BACK
;	WHEN SCAN IS USED FOR COMMAND INPUT ALSO.
;1122	SWITCH TABLES WERE MODIFIED TO USE POINTR MACRO.
;1123	A ROUTINE CALLED QMLCHR WAS INVENTED TO MAP OLD ACS INTO NEW
;	ACS WHEN QMANGR WRITES INTO A QUEUE LISTING FILE. SINCE QUEUE
;	INTERACTS WITH KJOB, QMANGR, SCAN, WILD, AND QUEUER AC USAGE
;	MUST BE CHECKED FULLY.
;1124	.TCRLF, .TSIXN, .TSIX, .TXWD, .TDEC, .TRDX
;	.TSTR, .TCHR, GETNOW, AND CNVDAT WERE DELETED IN
;	FAVOR OF SIMILAR (BUT SIGNIFICANTLY DIFFERENT) ROUTINES
;	IN SCAN.
;1125	.ISCAN IS CALLED WHEN KJOB GETSEG'S QUEUE. THIS IS DONE SO
;	QUEUE CAN TELL SCAN WHERE KJOB WANTS THE LOG FILE WRITTEN.
;1126	REMOVE BUILT IN COMMAND SCANNER AND .SCAN; SUPPORT DEFAULT
;	DIRECTORIES, SFDS, ETC.
;1127	ELIMINATE M.
;1130	MOVE I/O CHANNELS TO 1 AND 2.
;1131	SUPPRESS CHECKS FOR LEGAL STATION OR DEVICE
;	TO BE QUEUED TO. (CAN BE RESTORED BY FTLSCK=1)
;1132	RESTORE /NOTE.
;1133	CALL .LKWLD
;1134	TURN ON /FILE:ELEVEN
;1135	(10-7124) ELIMINATE POSSIBLE ILL MEM REF RESULTING FROM
;	BUG IN GET CORE ROUTINE
;1136	(10-8110) ADD AD.LFD TO SPECIFY DEFAULT LOG FILE DISPOSITION
;1137	(10-9131) ADD ERROR MESSAGE IF OUTPUT LIMIT IS 0
;1140	(10-9124) DON'T ALLOW LISTING DEVICE UNLESS
;	LOGGED IN OR CONTROLLED BY A PTY.
;1141	(10-8818) COMMAND NAMES SHOULD ESTABLISH THE QUEUE TYPE
;1142	(10-9395) FORCE /DISP:PRES ON DIRECTORIES.
;1143	MERGE X.LOG AND X.LOGS
;1144	SPEEDUP KJOB PROCESSING BY LOOKING AHEAD TO THE NEXT
;	QUEUE TO DECIDE IF IT IS NEEDED.
;1145	CALL .OSCAN
;	(KJOB QUEUEING USES "KQUE")
;1146	ADD /PATH:[DIRECTORY] TO SPECIFY INPUT QUEUE'S DEFAULT PATH
;1147	ADD /NOXXX FOR /XXX WHERE APPROPRIATE
;1150	(10-9849) IF DEFAULT EXTENSION ON PRINT REQUEST,
;	TRY .LPT THEN .LST THEN NULL.
;1151	(10-8898) FIX /CORE MULTIPLIERS TO BE 1024.  ALLOW P
;	SUFFIX FOR 512.
;1152	(10-10121) FIX HANDLING OF PROTECTED LOG FILE OF
;	EXTENSION .LPT.
;1153	ALLOW QUOTED STRINGS IN /NOTE AND /REPORT.
;1154	ADD /NORESTART/NOHEADER
;1155	LIST AFTER PARAMETER AS +ND HH:MM IF GE 1DAY.
;1156	PROCESS DEFERRED REQUESTS UNLESS K.SDEF=1. STILL
;	DON'T ALLOW /DEF/ZDEFER.
;1157	CHANGE INTERPRETATION OF ".PRINT [A,B]" TO BE LIST
;	PRINT QUEUE FOR USER [A,B].  THE OLD INTERPRETATION
;	WAS PRINT *.LPT[A,B].  THIS CHANGE APPLIES
;	WHENEVER EXACTLY ONE INPUT FILE SPEC IS
;	GIVEN AND NO FILE NAME IS TYPED AND NO OUTPUT SPEC
;	IS GIVEN.
;1160	HANDLE SINGLE VS PLURAL IN TOTAL LINE OF LISTING
;1161	(10-????) ADD /DELETE AS SYNONOMOUS WITH /DISP:RENAME
;1162	ALLOW /SEQUENCE CONSTRAINT ON /LIST.
;1163	CHANGE TO /LIST:WORD.  STILL DON'T INCLUDE THE ACTIONS.
;1164	REQUIRE A VALUE ON /BEGIN.
;1165	(10-7847) MOVE THE ISSUING OF THE TOTAL BLOCKS MESSAGE
;	UNTIL AFTER QMANGR HAS DONE ITS THING.
;1166	HANDLE DEVICE RESTRICTION IN /LIST.  E.G., .PRINT LPT0:/L
;1167	ADD PSEUDO QUEUE ALL: FOR LISTINGS.  THIS MATCHES ALL THE
;	QUEUES.  IT IS ESPECIALLY USEFUL WHEN COMBINED WITH
;	THE PREVIOUS FEATURE, E.G., .QUEUE ALLS3:/L
;	LISTS ALL QUEUES FOR STATION 3.
;1170	AT KJOB TIME, USE RH(SPOOL FILE NAME) TO DETERMINE THE
;	QUEUE. SNN GOES TO STATION NN; NNN GOES TO DEVICE
;	NNN.  JUNK GOES TO THIS STATION.  MAKE ENOUGH PASSES TO
;	GET ALL QUEUES.
;1171	REQUIRE = ON /MODIFY/KILL
;1172	IF UNLOGGED-IN OVER PTY AND COMMAND, USE CONTROLLING
;	JOB'S PPN (RECURSIVE) FOR MYPPN
;1173	REQUIRE OUTPUT NAME OR /SEQUENCE ON /MOD/KILL
;1174	INCLUDE EXTENSION IN "QUEUE LISTING ON FILE" MESSAGE
;1175	CHECK UFD PROTECTION CORRECTLY
;1176	DON'T ALLOW EXT ON .PRINT [P,PN]
;1177	(10-11141) MAKE ILLEGAL TO /MOD/KILL IF NOT LOGGED IN
;1200	FIX RECENT BUG OF .DAT DEFAULTING TO /DELETE
;1201	CHANGE PLOT TIME LIMIT TO BE FUNCTION OF # INCREMENTS
;1202	RESTORE .JBFF, .JBREL EACH PASS
;1203	(10-11063) ALLOW /HEADER ON SPOOLED FILES
;1204	ADD # FILES TO TOTAL MESSAGE WHEN QUEUEING
;1205	(QAR 1401) HANDLE JOB # DEVICE SIGNOUT IN /L
;1206	HANDLE REMOTE STADION KJOB CORRECTLY FOR BATCH
;1207	ELIMINATE BUG OF *.LOG AT KJOB
;1210	(QAR 1446) FIX SECURITY BUG WITH JACCT
;1211	IF KJOB LIMIT IS -1, USE DEFAULT
;1212	FIX BUG IN 1205
	SUBTTL	STANDARD MNEMONICS--REGISTERS, BITS, UUOS

;AC NAMES

F=0		;FLAGS (LH=PERMANENT, RH=TEMPORARY)
T1=1		;TEMPORARIES
T2=2
T3=3
T4=4

P1=5		;PRESERVED BY ONE AND ALL
P2=6		; ..

N=7		;NUMBER/NAME ...  USED BY SCAN
C=10		;CHARACTER FROM COMMAND STRING (READ ONLY AC)

I=11		;POINTS TO INPUT FILE SPEC
J=12		;POINTS TO CURRENT FILE IN QUEUE REQUEST
Q=13		;POINTS TO THE QUEUE REQUEST AREA

M=14		;LISTING MESSAGE POINTER
P=17		;PUSH-DOWN POINTER

;I/O CHANNELS

DC==1		;LOOKUP/RENAME DATA FILES
LC==2		;LISTINGS


..==0		;FLAG FOR FIELDS TO BE FILLED IN LATER
;PERMANENT FLAGS (LH)

L.LOGI==(1B17)	;THIS JOB IS LOGGED IN
L.WIPE==(1B16)	;MONRET AFTER ERROR INSTEAD OF RESTART
L.KJOB==(1B15)	;KJOB ENTRY
L.LEVD==(1B14)	;RUN UNDER LEVEL-D OR LATER
L.KONC==(1B13)	;KJOB EXIT TRIED ONCE ALREADY
L.PHYS==(1B12)	;PHYSICAL I/O REQUESTED FOR ENTIRE CALL
L.PHYP==(1B11)	;PHYSICAL I/O POSSIBLE IN THIS MONITOR
L.HERE==(1B10)	;KJOB WORKING ON QUEUE FOR THIS STATION
L.NEED==(1B9)	;KJOB NEED QUEUES FOR SOME OTHER STATION
L.NSBJ==(1B8)	;NOT LOGGED IN TOP LEVEL			[1177]
L.GSYS==(1B7)	;GOTTEN FROM SYS				[1210]

;TEMPORARY FLAGS (RH)

R.LTAB==1B35	;TAB NEEDED NEXT ON LISTING FILE
R.LPTB==1B34	;LPT BUSY--WAITING
R.OUTO==1B33	;LISTING DEVICE OPEN AND IT IS OUR TTY
R.ODSK==1B32	;LISTING DEVICE OPEN AND IT IS A DISK
R.ISLG==1B31	;THIS REQUEST INCLUDES LOG FILE
R.OUTL==1B30	;LISTING DEVICE NEEDS OUTPUT EACH LINE
R.NEWF==1B29	;SOME SWITCH WAS TYPED WHICH CAUSES US TO WRITE
		; VERSION 1 QUEUE ENTRIES.
R.NSEC==1B28	;SUPPRESS SECONDS LISTING

;KJOB COMMUNICATION FLAGS (RH OF EXT WORD)

K.CMD==1B35	;KJOB COMMAND (HENCE USE PHYSICAL I/O)
K.SLOG==1B34	;SUPPRESS LOG FILE PROCESSING
K.SSPL==1B33	;SUPPRESS SPOOL FILE PROCESSING
K.SLST==1B32	;SUPPRESS *.LST FILE PROCESSING
K.SDEF==1B31	;SUPPRESS DEFERRED REQUEST PROCESSING
K.DSTY==1B30	;DESTROY ALL OUTPUT SPOOLING FILES

K.FLOG==1B19	;FOUND THE LOG FILE
K.LQUE==1B18	;DEVICE QUE IS LOGICAL

;KJOB PARAMETERS

 KJB.DS==7B29	;DEFAULT DISPOSITION
 KJB.PR==77B35	;PRIORITY
;VERSION NUMBER OF QUEUE REQUEST

.QVERS==1	;TYPE 1 DIFFERS FROM TYPE 0 IN THE LOCATION OF
		; MASK WORDS ON /MODIFY. EVERYTHING ELSE IS COMPATABLE.

.QPROG==1	;QUEUE IS PROGRAM #1 IN QUEUE FORMAT


;X.MOD LAYOUT DEFINITIONS

X.REMV==1B0	;/REMOVE
X.LOG==1B1	;THIS FILE IS THE JOB LOG FILE
X.NEW==1B2	;/NEW
X.NOHD==1B5	;/HEADER
X.TITL==1B11	;/TITLE
X.UNP==1B16	;/UNPRESERVED		;LOCAL USE ONLY
X.OKBN==1B17	;/OKBINARY		;LOCAL USE ONLY

X.SPAC==7B20	;/SPACING
X.PAPR==7B23	;/PAPER
X.FILE==7B26	;/FILE
X.DISP==7B29	;/DISPOSE
X.COP==77B35	;/COPIES
	LOC	137
%QUEUE==CUSTVR*1B2+DECVER*1B11+DECMVR*1B17+DECEVR
.JBVER:	EXP	%QUEUE
	RELOC


	IFN	PURESW,<TWOSEG
			RELOC 400000>
	IFE	PURESW,<QUEUEN==0>	;CLOBBER DEFAULT HI-SEG NAME


;COMMUNICATION WITH QMANGR

QUEUEM==QUEUEN_-^D18

	EXTERN	.QUEER
	INTERN	QUEUEM,QUEUEN		;FOR DEBUG MODE IN QUEUER

	ENTRY	QUEUE

;COMMUNICATION WITH .TOUTS

	EXTERN	.TCHAR,.TCRLF,.TDECW,.TOCTW,.TSIXN
	EXTERN	.TSTRG,.POPJ,.POPJ1

;COMMUNICATION WITH .WILD

	INTERN	.TNEWL
;MACROS

;SWSEG		SWITCHES SEGMENTS IF PURESW ON (ALSO FLUSHES LITS)

DEFINE	SWSEG<
IFN PURESW,<
		XLIST
		LIT
		LIST
		RELOC>>


;DEFINE RELOCATABLE 0 FOR HIGH AND LOW SEGS

..STRH==.
	SWSEG
..STRL==.
	SWSEG


;GCORE N	GET N MORE WORDS AT .JBFF

DEFINE	GCORE (A),<
	MOVEI	T1,A
	XLIST
	PUSHJ	P,GCORE.
	LIST
>
;N.FAIL <FOO> SENDS FOO AS A FATAL ERROR

DEFINE	N.FAIL (A),<
	PJSP	T1,FMSG
	XLIST
	ASCIZ	\A\
	LIST
>

;N.FAIN <FOO> SENDS FOO AS A FATAL ERROR WITH N IN SIXBIT

DEFINE	N.FAIN (A),<
	PJSP	T1,FMSGN
	XLIST
	ASCIZ	\A\
	LIST
>

;N.FAIO <FOO> SENDS FOO AS A FATAL ERROR WITH N IN OCTAL

DEFINE	N.FAIO (A),<
	PJSP	T1,FMSGO
	XLIST
	ASCIZ	\A\
	LIST
>

;N.FAID <FOO> SENDS FOO AS A FATAL ERROR WITH N IN DECIMAL

DEFINE	N.FAID (A),<
	PJSP	T1,FMSGD
	XLIST
	ASCIZ	\A\
	LIST
>
	SUBTTL	INITIALIZE

;HERE ON KJOB'S CALL
;MUST BE AT 400010
;CALL:	MOVE	1,XWD LEN,AREA
;	PUSHJ	17,400010
;RETURN WITH AREA UPDATED

KQUEUE:	PORTAL	.+1		;FLAG ENTRY POINT FOR CALL
	HLRZ	2,1		;GET LENGTH OF AREA
	CAIGE	2,EKJBRG-KJBARG+1  ;MAKE SURE IT FITS
	JRST	KQUEF		;TOO SMALL
	HRRZ	2,.JBFF		;SAVE FIRST FREE
	CAILE	2,LOWFWA	;SEE IF ROOM FOR US
	JRST	KQUE1		;NO--GIVE UP
	HRL	2,.JBREL	;AND CORE SIZE
;THIS IS A GOOD BREAKPOINT FOR DEBUGGING CALL FROM KJOB
KQUE:	MOVEI	0,.JBHGH	;GET ADDRESS OF VESTIGIAL JOB DATA AREA
	HLR	0,@0		;GET INITIAL .JBFF AS MINIMUM CORE
	HRRZM	0,.JBFF		;STORE AS FIRST FREE
	CAMG	0,.JBREL	;COMPARE TO SIZE OF CORE
	JRST	KQUE2		;OK--PROCEED BELOW
	CORE	0,		;NOT OK--TRY TO GET IT
	  JRST	.+2		;FAILED
	JRST	KQUE2		;WON--CONTINUE BELOW
KQUE1:	OUTSTR	[ASCIZ /
? Insufficient core for QUEUE
/]
	HRRZM	2,.JBFF		;RESTORE .JBFF TO CORRECT VALUE
	POPJ	17,		;GIVE UP
;HERE WHEN WE HAVE ENOUGH CORE TO PROCEED

KQUE2:	MOVSM	2,KJBDAT	;SAVE CORE SIZES
	MOVSI	2,1-.FXLND	;CLEAR JUNK FROM DIRECTORY BLOCK
	HRRI	2,KJBADR-KJBARG(1)
KQUE3:	SKIPN	(2)		;IF A WORD IS 0,
	SETZM	1(2)		; CLEAR THE NEXT ONE ALSO
	AOBJN	2,KQUE3		;LOOP FOR 5 WORDS
	MOVEM	17,KJOBPC	;SAVE RETURN PC
	MOVEM	1,KJOBPT	;SAVE PARAMETER AREA POINTER
	MOVSI	0,(1)		;SAVE PARAMETER AREA
	HRRI	0,KJBARG	; ..
	BLT	0,EKJBRG	; ..
	MOVE	T1,KJBAEX	;PRESET ANSWER FLAGS TO MATCH
	MOVEM	T1,KJBVEX	; ..
	SETZM	KJBVQU		;CLEAR REST OF ANSWER
	TXNE	T1,K.SDEF	;SEE IF SUPPRESSING DEFERS
	TDZA	T1,T1		;YES--CLEAR OFFSET
	MOVEI	T1,1		;SET CCL START ADDRESS
	MOVEM	T1,STRTOF	; TO HANDLE DFR FILE IF ANY

	MOVE	T1,[KJBTYI,,KJBTYO]  ;SETUP TYPEIN/OUT ROUTINES
	HRRE	T2,KJBTYP	;GET TYPING ADDRESS
	SKIPG	T2		;SEE IF IN LOW SEG
	TRZ	T1,-1		;NO--CLEAR ADDRESS
	MOVEM	T1,TYPER	;SAVE FOR OUTPUT ROUTINES
	HRLZI	F,L.KJOB	;FLAG AS KJOB STYLE CALL
	MOVEI	T1,K.CMD	;SEE IF PHYSICAL I/O REQUESTED
	TDNE	T1,KJBAEX	;IN THE CALL
	TLO	F,L.PHYS	;YES--REMEMBER FOR LATER
	JRST	QUEST		;GO PROCESS AFTER INITIALIZING

KQUEF:	OUTSTR	[ASCIZ /
? Argument list too short for QUEUE
/]
	POPJ	17,		;RETURN
;HERE AFTER START OR RUN OR QUEUE COMMAND OR RUN UUO

QUEUE:	TDZA	T1,T1		;ALLOW FOR CCL ENTRY POINT
	MOVEI	T1,1		;YES--FLAG CCL ENTRY
	MOVEM	T1,STRTOF	;SAVE FOR ISCAN
	SETZB	F,TYPER		;CLEAR TYPEOUT ROUTINE FLAG
	SETZM	KJBTYP		;CLEAR TYPEOUT STUFF
	RESET			;RESET ANY EXTERNAL I/O
QUEST:	HRROI	T1,.GTLIM	;GET JOB LIMIT WORD		[1210]
	GETTAB	T1,		; FROM MONITOR			[1210]
	  MOVEI	T1,0		;(ASSUME NOT SYS)		[1210]
	TXNE	T1,JB.LSY	;SEE IF CAME FROM SYS		[1210]
	TLO	F,L.GSYS	;YES--SET FLAG			[1210]
	MOVSI	T1,'SYS'	;SEE IF PHYS I/O IS POSSIBLE
	DEVCHR	T1,UU.PHY
	TRNE	T1,-1		;SEE IF ANY ANSWER
	TLOA	F,L.PHYP	;YES--POSSIBLE
	TLZ	F,L.PHYS!L.GSYS	;NO--CLEAR REQUEST AND FLAG	[1210]
	SETZM	ZCOR		;CLEAR CORE
	MOVE	T1,[ZCOR,,ZCOR+1]
	BLT	T1,EZCOR
	MOVE	P,[IOWD LN.PDL,PDLST]  ;ESTABLISH PUSH-DOWN LIST
	TLNN	F,L.KJOB	;SKIP IF KJOB CALL
	PUSHJ	P,SETINT	;NO--SET UP ^C INTERCEPT
	GETPPN	T1,		;GET THIS PROJECT-PROGRAMMER NUMBER
	  JFCL			;(IN CASE JACCT IS ON)
	MOVEM	T1,MYPPN	;SAVE FOR FUTURE REFERENCE

	PJOB	T1,		;GET THIS JOB'S NUMBER
	MOVEM	T1,JOBN		;SAVE AWAY FOR LATER ON
	PUSHJ	P,.MKPJN##	;CONVERT TO JOB NUMBER PREFIX
	HRLI	T1,'DFR'	;MAKE DEFERAL FILE NAME
	MOVSM	T1,DFRNAM	;AND STORE IT
	MOVN	T1,JOBN		;GET JOB ARG FOR JOBSTS UUO
	JOBSTS	T1,		;GET THIS JOB'S STATUS
	  JRST	.+2		;FAILED--ASSUME LOGGED IN
	TXNE	T1,JB.ULI	;SEE IF LOGGED IN
	TLO	F,L.LOGI	;YES--SET FLAG
	TLNE	F,L.LOGI!L.KJOB	;SEE IF KJOB OR LOGGED IN	[1172]
	JRST	QUESTS		;YES--PROCEED			[1172]
	TLO	F,L.NSBJ	;INDICATE NOT LOGGED IN		[1177]
	SETOM	T1		;START AT OUR JOB		[1172]
QUESTL:	CTLJOB	T1,		;GET CONTROLLING NUMBER		[1172]
	  JRST	QUESTS		;NONE--ASSUME OK ANYWAY		[1172]
	JUMPL	T1,QUESTS	;IF NONE, ASSUME OK		[1172]
	MOVN	T2,T1		;GET -JOB			[1172]
	JOBSTS	T2,		;GET ITS STATUS			[1172]
	  SETOM	T2		;ASSUME LOGGED IN		[1172]
	TXNE	T2,JB.ULI	;SEE IF LOGGED IN		[1172]
	JRST	QUESTL		;NO--LOOP ON UP CHAIN		[1172]
	HRLZ	T2,T1		;GET THIS JOB'S NUMBER		[1172]
	HRRI	T2,.GTPPN	;POINT TO PPN TABLE		[1172]
	GETTAB	T2,		;GET PPN FROM MONITOR		[1172]
	  JRST	QUESTS		;NONE!--GIVE UP			[1172]
	MOVEM	T2,MYPPN	;OK--USE THAT INSTEAD		[1172]
	TLZ	F,L.NSBJ	;OK AFTER ALL (PROBABLY OPSER CALL)	[1177]

QUESTS:	MOVE	T1,['OPR0  ']	;FIND LOCATION
	WHERE	T1,		; OF CENTRAL STATION
	  MOVEI	T1,0		;NONE
	MOVEM	T1,CENTRL	;SAVE FOR LATER
	MOVSI	T1,'OPR'	;FIND LOCATION
	SKIPE	CENTRL		; ,UNLESS NO REMOTES,
	WHERE	T1,		; OF THIS JOB
	  MOVEI	T1,0		;NONE
	MOVEM	T1,HERE		;SAVE FOR LATER
	LSHC	T1,-3		;SEPARATE DIGITS		[1206]
	LSH	T1,3		;SPACE OUT			[1206]
	LSHC	T1,3		;RECOMBINE			[1206]
	ADDI	T1,'0'		;CONVERT TO SIXBIT		[1206]
	TRNE	T1,700		;SEE IF TWO DIGITS		[1206]
	TROA	T1,'0 '		;YES--CONVERT TO SIXBIT		[1206]
	LSH	T1,6		;NO POSITION AS ONE		[1206]
	ADDI	T1,'S  '	;INCLUDE STATION PREFIX		[1206]
	SKIPN	HERE		;SEE IF REMOTES			[1206]
	MOVEI	T1,0		;NO--CLEAR WORK			[1206]
	MOVEM	T1,HERESX	;STORE FOR KJOB LATER		[1206]
	MOVX	T1,%LDSTP	;GET DEFAULT FILE PROTECTION
	GETTAB	T1,		;  FROM THE MONITOR
	  MOVSI	T1,055000	;  TO BE USED ON A CREATE
	LSH	T1,-^D9		;  POSITION
	HLRZM	T1,DEFPRT	;  SAVE FOR LATER

	MOVE	T1,.JBREL	;SAVE CURRENT CORE
	HRL	T1,.JBFF	;  AND START OF FREE CORE	[1202]
	MOVEM	T1,SAVCOR	;  FOR LATER TO RESTORE

	MOVX	T1,%CNSTS	;GET SYSTEM STATES WORD
	GETTAB	T1,		;FROM THE MONITOR
	  MOVEI	T1,0		;(ASSUME LEVEL C)
	TXNE	T1,ST%TDS	;SEE IF LEVEL D
	TLO	F,L.LEVD	;YES--SET FLAG FOR LATER
	PUSHJ	P,.GTNOW##	;GET CURRENT DATE/TIME
	MOVEM	T1,NOW		;SAVE FOR LATER
	MOVX	T1,%LDMFD	;GET NAME OF MFD
	GETTAB	T1,		;FROM MONITOR
	  MOVE	T1,[1,,1]	;(LEV C)
	MOVEM	T1,MFDPPN	;STORE FOR USE LATER ON

	MOVSI	T1,'QUE'	;SEE IF PRIVATE QUEUES
	DEVCHR	T1,		;ACCORDING TO MONITOR
	MOVEI	T2,K.LQUE	;FLAG SO KJOB WILL KNOW
	TXNE	T1,DV.DSK	;SEE IF DISK
	IORM	T2,KJBVEX	;YES--SET FLAG FOR CALLER

	TLNE	F,L.KJOB	;SEE IF KJOB CALL
	TDZA	T1,T1		;YES--NO RESCAN
	MOVE	T1,[IOWD QCMLEN,QCOMS]  ;NO--RESCAN FOR POSSIBLE COMMANDS
	MOVEM	T1,ISARG	;SET AS FIRST ARG
	MOVE	T1,[STRTOF,,'QUE']  ;SET START ADDRESS AND TMP FILE
	TLNE	F,L.KJOB	;SEE IF KJOB CALL
	HRRI	T1,'DFR'	;YES--CHANGE TO DEFER FILE
	MOVEM	T1,ISARG+1	;STORE AS SECOND ARG
	SETZB	T1,ISARG+3	;CLEAR INDIRECT BLOCK
	TLNE	F,L.KJOB	;SEE IF KJOB CALL
	MOVE	T1,[KJBPRP,,KJBEOF]  ;YES--SET SPECIAL HANDLER FOR EXIT AND PROMPTING
	MOVEM	T1,MONRTR	;STORE AS FIFTH ARG

	MOVE	T1,[5,ISARG]
	PUSHJ	P,.ISCAN##
	SKIPGE	T1		;SEE IF COMMAND
	TDZA	T1,T1		;NO--CLEAR DEFAULT TYPE
	MOVE	T1,QDEVS(T1)	;YES--GET QUEUE NAME
	MOVEM	T1,DQTYPE	;STORE AS DEFAULT TYPE
	SUBTTL	MAIN PROCESSING LOOPS

;HERE WHENEVER * TYPED (IE, MAJOR RESTART)

QUELOP:	IFN  DEBUG,<CAME  P,[IOWD LN.PDL,PDLST]
		    JRST  E.PDL>  ;FAIL IF PDL PHASE ERROR
				;*DELETED 4 LINES*		[1202]
	MOVE	T1,[10,,[IOWD SWTCHL,SWTCHN
			SWTCHD,,SWTCHM
			0,,SWTCHP
			'QUEUE '
			CLRANS,,CLRFIL
			INFIL,,OUTFIL
			FILSTK,,APLSTK
			CLRSTK,,0]  ]
	PUSHJ	P,.TSCAN##
	SKIPE	O.MODM		;SEE IF OUTPUT SPEC
	JRST	SOMCMD		;YES--NORMAL HANDLING
	MOVE	T1,I.NXZR	;SEE IF ANY COMMANDS
	MOVE	T2,I.INZR	;GET FIRST INPUT SPEC
	SUB	T1,T2		;GET NUMBER OF SPECS*I.LZER
	JUMPE	T1,NOCMD	;NONE--NULL COMMAND
	CAIN	T1,I.LZER	;SEE IF JUST ONE
	SKIPE	.FXNAM(T2)	;  WITH NULL FILE NAME
	JRST	SOMCMD		;NO--SOMETHING THERE
	SKIPE	.FXEXT(T2)	;SEE IF EXTENSION		[1176]
	JRST	SOMCMD		;YES--SOME COMMAND		[1176]

;HERE ON A NULL MONITOR COMMAND

NOCMD:	PUSHJ	P,DEFAU1	;GO FILL IN MODIFIED DEFAULTS
	JRST	DOCMD		;THEN GO BELOW TO DO THE WORK

;HERE WHEN A NON-NULL COMMAND IS FOUND

SOMCMD:	PUSHJ	P,DEFAUL	;GO FILL IN DEFAULTS

;HERE AFTER DEFAULTS ARE DONE

DOCMD:	PUSHJ	P,COMAND	;DO THE COMMAND
	JRST	QUELOP		;LOOP BACK FOR MORE WORK

;HERE WHEN AT EOF ON KJOB PROCESSING

KJBEOF:	TLOE	F,L.KONC	;SEE IF THROUGH HERE ONCE
	JRST	KJBRET		;YES--JUST RETURN
;HERE ON KJOB CALL WHEN LOG FILE HAS NOT YET BEEN QUEUED

	SETZM	KJBQUE		;CLEAR POINTER TO SPOOLING QUEUE NAMES
KJBQUL:	PUSHJ	P,CLRANS	;CLEAR SCANNING AREA
	MOVEI	I,0		;SET FLAG FOR LATER TESTING
	MOVEI	T1,QO.CRE	;SEE /CREATE
	MOVEM	T1,S.OPN	;IN CASE OPTION FILE DEFAULTS
	TLNN	F,L.NEED	;SEE IF NEED EXTRA PASSES
	TLOA	F,L.HERE	;NO--SWITCH TO THIS JOB'S STATION
	TLZA	F,L.HERE	;YES--PICK UP SXX AND NNN QUEUES
	JRST	KJBQHR		;NO--PROCEED
;HERE IS NEED TO QUEUE FOR OTHER THAT THIS JOB'S STATION
	MOVE	T1,KJBQUE	;GET SPOOL INDEX
	HLLZ	T1,QUENMT(T1)	;GET GENERIC NAME
	MOVEM	T1,O.DEV	;SET INTO QUEUE NAME
	MOVSI	T1,-<ESTATB-STATAB+1>	;FIND NEXT QUEUE
KJBQN1:	SKIPN	T2,STATAB(T1)	; WHICH APPEARS IN DIRECTORY
	AOBJN	T1,.-1		; ..
	JUMPG	T1,[TLC  F,L.NEED!L.HERE  ;DONE--CLEAR NEED SET HERE
		    JRST KJBQDH]  ;AND PROCEED WITH NEXT QUEUE
	JFFO	T2,.+1		;GET BIT POSITION
	MOVN	T4,T3		;GET COMPLEMENT
	MOVSI	T2,(1B0)	;GET BIT 0
	LSH	T2,(T4)		;POSITION
	ANDCAM	T2,STATAB(T1)	;CLEAR BIT FROM MEMORY
	TLZ	T1,-1		;REMOVE JUNK
	MOVEI	T4,0		;CLEAR EXTRA AC
	CAILE	T1,1		;SEE IF SXX: (TWO WORDS)
	JRST	KJBQND		;NO--DEVICE
	CAIN	T1,1		;IF .GE. 36,
	ADDI	T3,^D36		; ADD TO VALUE
	LSHC	T3,-3		;POSITION DIGITS
	LSH	T3,3		;SPACE OUT
	LSHC	T3,3		;RESTORE DIGITS
	ADDI	T3,'0'		;OFFSET RH DIGIT
	TRNE	T3,700		;SEE IF TWO DIGIT
	TROA	T3,'0 '		;YES--ADD OFFSET
	LSH	T3,6		;NO--POSITION
	ADDI	T3,'S  '	;INCLUDE STATION PREFIX
	JRST	KJBQNF		;GO STORE AWAY
KJBQND:	IMULI	T1,^D36		;HERE IF DEVICE
	ADDI	T3,-^D72(T1)	;GET DEVICE NUMBER
	LSHC	T3,-6		;SPREAD
	LSH	T3,3		; OUT
	LSHC	T3,3		; DIGITS
	LSH	T3,3		; FOR
	LSHC	T3,3		; SIXBIT
	TRNE	T3,70000	;SEE IF THREE DIGITS
	ADDI	T3,'0  '	;YES--ADD OFFSET
	TRNE	T3,70700	;SEE IF TWO DIGITS
	ADDI	T3,'0 '		;YES--ADD OFFSET
	ADDI	T3,'0'		;ADD UNITS OFFSET
	TRNN	T3,770000	;SEE IF THREE DIGITS
	LSH	T3,6		;NO--POSITION
	TRNN	T3,770000	;SEE IF TWO DIGITS
	LSH	T3,6		;NO--POSITION
KJBQNF:	HRRM	T3,O.DEV	;SET INTO QUEUE NAME
	JRST	KJBQUH		;AND PROCEED WITH WORK

;HERE FOR START OF A NEW SPOOLED DEVICE
KJBQHR:	SETZM	STATAB		;CLEAR OUT MEMORY
	MOVE	T1,[STATAB,,STATAB+1]  ; OF ALTERNATE QUEUES
	BLT	T1,ESTATB	; ..

	MOVEI	T1,QUENML	;SET NEXT QUEUE TO END SO THAT NO
	MOVEM	T1,KNXQUE	;  UNNECESSARY PASSES ARE MADE
	AOS	T1,KJBQUE	;ADVANCE TO NEXT QUEUE
	CAIL	T1,QUENML	;SEE IF DONE YET
	JRST	KJBRET		;YES--GO RETURN TO USER
	HLLZ	T4,QUENMT(T1)	;GET DEVICE NAME
	HRR	T4,HERESX	;GET STATION			[1206]
	MOVEM	T4,O.DEV	;STORE IN AREA
KJBQUH:	SKIPE	T2,KJBANM	;GET LOG FILE NAME AS JOB NAME
	SETOM	O.NAMM		; ..
	MOVEM	T2,O.NAM	; ..
	TLNE	F,L.HERE	;SEE IF THIS JOB
	SKIPGE	T1,KJBIDX-1(T1)	;GET SPOOLING INDEX
	JRST	KJBQUM		;NON-STANDARD--IGNORE LIMITS
	ROT	T1,-1		;POSITION TO GET LIMITS
	MOVE	T2,KJBLIM(T1)	;GET PAIR
	TLNN	T1,(1B0)	;SEE IF OTHER HALF
	MOVSS	T2		;YES--SWAP
	TLZ	T2,-1		;CLEAR JUNK
	CAIN	T2,-1		;SEE IF -1			[1210]
	SETOM	T2		;YES--INDICATE DEFAULT		[1211]
	MOVE	T3,KJBLMM(T1)	;GET LIMIT
	TLNN	T1,(1B0)	;SEE IF LINED UP
	MOVSS	T3		;NO--SWAP
	CAILE	T2,(T3)		;SEE IF OVER LIMIT
	HRRZ	T2,T3		;YES--SET TO LIMIT
	TRNE	T2,-1		;SEE IF LIMIT GIVEN
	MOVEM	T2,S.LIM	;YES--STORE IN LIMIT WORD	[1211]
KJBQUM:	LDB	T1,[POINTR (KJBPRM,KJB.PR)]
	MOVEM	T1,S.PRI	;SET PRIORITY
	MOVE	T1,KJBSEQ	;GET SEQUENCE NUMBER
	MOVEM	T1,S.SEQ	;SET INTO REQUEST
	MOVEI	T1,1		;FLAG THAT NO REQUEST
	MOVEM	T1,S.NULL	; IS ALL RIGHT (/NULL)
	MOVEI	T3,K.SSPL	;SEE IF SUPPRESSING AUTOMATIC SPOOLING
	TDNE	T3,KJBVEX	; ..
	JRST	KJBQLS		;YES--SKIP SETTING UP THE REQUEST
	PUSHJ	P,GTCLIK	;GET AN INPUT COMMAND AREA PRESET FOR NONE OK
	MOVE	P1,KJBQUE	;SET LOOP COUNTER TO THIS QUEUE
KJBQOT:	TLNE	F,L.HERE	;SEE IF QUEUE FOR THIS LOCATION
	JRST	KJBQOE		;YES--PROCEED
	HRRZ	T1,O.DEV	;NO--GET QUEUE CODE
	HRLI	T1,'???'	;SET WILD FIRST HALF
	MOVEM	T1,.FXNAM(I)	;IN FILE NAME
	HLLOS	.FXNMM(I)	;DITTO MASK
KJBQOE:	HLLO	T1,QUENMT(P1)	;GET EXTENSION WITH MASK SET
	MOVEM	T1,.FXEXT(I)	;  TO INDICATE NO WILD-CARD
	TLNE	F,L.HERE	;IF NOT THIS STATION, OR
	CAIL	P1,QUENML-1	;SEE IF DONE
	JRST	KJBQLS		;YES--PROCEED
	PUSHJ	P,GTCLIA	;MORE QUEUES, MAKE ROOM
	AOJA	P1,KJBQOT	;LOOP FOR REST OF QUEUES
KJBQLS:	HLLZ	T4,O.DEV	;FIND GENERIC QUEUE		[1206]
	TLNE	F,L.HERE	;SEE IF ALTERNATE QUEUE, AND NOT
	CAME	T4,[SIXBIT /LPT/]  ;SEE IF LPT: QUEUE
	JRST	KJBQDO		;NO--JUST GO DO IT
	MOVEI	T3,K.SLST	;SEE IF SUPPRESSING *.LST
	TDNE	T3,KJBVEX	; ..
	JRST	KJBQLG		;YES--GO TRY .LOG FILE
	PUSHJ	P,GTCLIA	;NO--ADD IN +*.LST
	HRLOI	T1,'LST'	; ..
	MOVEM	T1,.FXEXT(I)	; ..
KJBQLG:	MOVEI	T3,K.SLOG!K.FLOG  ;SEE IF WE STILL NEED LOG FILE
	TDNN	T3,KJBVEX	; ..
	SKIPN	KJBADV		;SEE IF ANY LOG REQUEST
	JRST	KJBQDO		;NO--JUST GO PROCESS
	PUSHJ	P,GTCLIN	;GET A SECOND AREA
	MOVE	I,T1		;POSITION RESULT
	MOVE	T3,KJBADV	;YES--GET DEVICE
	MOVEM	T3,.FXDEV(I)	;STORE IT
	MOVE	T3,KJBANM	;GET LOG FILE
	MOVEM	T3,.FXNAM(I)	;STORE NAME
	SETOM	.FXNMM(I)	;CLEAR WILD CARD
	MOVSI	T1,-.FXLND	;GET LENGTH OF DIRECTORY
	MOVE	T2,I		;POINT TO ENTRY
KJBQLD:	SKIPE	T3,KJBADR(T1)	;GET WORD
	SETOM	.FXDIM(T2)	;INDICATE NOT WILD
	MOVEM	T3,.FXDIR(T2)	;PLACE IN REQUEST
	ADDI	T2,2		;ADVANCE RESULT
	AOBJN	T1,KJBQLD	;ADVANCE FETCH
	HLLO	T3,KJBAEX	;GET EXTENSION W/O WILDCARD
	MOVEM	T3,.FXEXT(I)	;STORE IN REQUEST
	MOVX	T3,FX.PHY	;SET /PHYS
	IORM	T3,.FXMOD(I)	;IN AREA
	IORM	T3,.FXMOM(I)	;AND MASK
	MOVX	T3,X.NEW!X.LOG	;SET NEW AND LOG FLAGS
	LDB	T1,[POINTR (KJBPRM,KJB.DS)]
	SKIPN	T1		;SEE IF DEFAULT
	MOVEI	T1,DISPRENAME	;YES--FILL IN /DIS:REN
	DPB	T1,[POINTR (T3,X.DISP)]  ;SET DISPOSITION
	MOVEM	T3,I.MOD(I)	;IN REQUEST
	TXO	T3,X.DISP	;FLAG THAT DISP. SET
	MOVEM	T3,I.MODM(I)	; ..

KJBQDO:	CAMGE	I,I.INZR	;SEE IF ANYTHING THERE
	JRST	KJBQUL		;NO--JUST LOOP BACK
	PUSHJ	P,DEFAUL	;FILL IN THE DEFAULTS
	PUSHJ	P,COMAND	;DO THE REQUEST
	TLNE	F,L.NEED	;SEE IF NEED ANOTHER SHOT
	JRST	KJBQUL		;YES--REPEAT FOR ALTERNATE LOCATION
KJBQDH:	SOS	T1,KNXQUE	;GET NEXT QUEUE AND BACK UP ONE
	MOVEM	T1,KJBQUE	; TO ALLOW FOR AOS
	JRST	KJBQUL		;LOOP BACK FOR NEXT ONE
;HERE AT END OF KJOB PROCESSING--RETURN TO KJOB

KJBRET:	MOVE	T1,KJOBPT	;GET ANSWER POINTER
	MOVE	T2,KJBVQU	;GET QUEUE NAME OF LOG FILE
	MOVEM	T2,KJOBXX-KJBARG(T1)  ;STORE IN ANSWER
	HRRZ	T2,KJBVEX	;GET FLAGS
	HRRM	T2,KJBAEX-KJBARG(T1)  ;STORE IN ANSWER
	MOVE	0,KJBDAT	;GET CORE SIZES
	MOVE	17,KJOBPC	;GET RETURN PC
	HLRZM	0,.JBFF		;RESTORE ORIGINAL FIRST FREE
	HRRZ	0,0		;GET ORIGINAL CORE SIZE
	CAME	0,.JBREL	;COMPARE WITH CURRENT
	CORE	0,		;NO EQUAL--TRY TO RESTORE
	  JFCL			;DON'T CARE IF CAN'T
	POPJ	17,		;RETURN TO CALLER

;HERE TO GET TTY INPUT ON KJOB CALL

KJBTYI:	HRREI	C,.CHEOF	;GET EOF

;HERE TO PROMPT TTY INPUT ON KJOB CALL

KJBPRP:	POPJ	P,		;RETURN TO CALLER

;HERE TO TYPE OUT ON KJOB CALL

KJBTYO:	PUSH	P,16		;PRESERVE AC 16
	MOVE	16,T1		;COPY CHARACTER
	HRRZ	T1,KJBTYP	;GET ADDRESS OF ROUTINE
	PUSHJ	P,(T1)		;GO TYPE IT
	POP	P,16		;RESTORE AC 16
	POPJ	P,		;RETURN
;LIMITS FOR KJOB QUEUEING

KJBLMM:	XWD	MX.LPT,MX.CDP
	XWD	MX.PTP,MX.PLT

;INDEX TO LIMITS FOR EACH QUEUE

	DEFINE X(LIST),<
IRP LIST,<..TEMP==-1
	  IFIDN <LIST><LPT>,<..TEMP==0>
	  IFIDN <LIST><CDP>,<..TEMP==1>
	  IFIDN <LIST><PTP>,<..TEMP==2>
	  IFIDN <LIST><PLT>,<..TEMP==3>
	  IFDIF <LIST><INP>,<..TEMP>>>
KJBIDX:	QUEUES


;COMMANDS WHICH RUN QUEUE

QCOMS:	SIXBIT	/QUEUE/
	SIXBIT	/CPUNCH/
	SIXBIT	/PLOT/
	SIXBIT	/PRINT/
	SIXBIT	/SUBMIT/
	SIXBIT	/PUNCH/
	SIXBIT	/TPUNCH/
QCMLEN==.-QCOMS

;DEVICES USED BY THOSE COMMANDS

QDEVS:	SIXBIT	/LP/		;QUEUE COMMAND (MUST BE LP NOT LPT) 
	SIXBIT	/CDP/		;CPUNCH COMMAND
	SIXBIT	/PLT/		;PLOT COMMAND
	SIXBIT	/LPT/		;PRINT COMMAND
	SIXBIT	/INP/		;SUBMIT COMMAND
	IFN	PUNCDP,<
	SIXBIT	/CDP/		;PUNCH COMMAND
>
	IFE	PUNCDP,<
	SIXBIT	/PTP/		;PUNCH COMMAND
>
	SIXBIT	/PTP/		;TPUNCH COMMAND
	SUBTTL	ROUTINES TO HANDLE CALLS FROM TSCAN

;HERE TO CLEAR OUT A SINGLE FILE SPEC

CLRFIL:	SETZM	F.ZER
	MOVE	T1,[F.ZER,,F.ZER+1]
	BLT	T1,F.EZER
	SETOM	F.MIN
	MOVE	T1,[F.MIN,,F.MIN+1]
	BLT	T1,F.EMIN
	POPJ	P,

;HERE WHEN A SPECIFICATION FOR OUTPUT SIDE IS FOUND

OUTFIL:	MOVEI	T1,O.ZER	;POINT TO OUTPUT AREA
	MOVEI	T2,O.LZER	;INDICATE LENGTH
	POPJ	P,		;RETURN

;HERE WHEN A SPECIFICATION FOR INPUT SIDE FOUND

INFIL:	PUSHJ	P,GTCLIN	;GET AND CLEAR INPUT AREA
	MOVEI	T3,I.MOD(T1)	;POINT TO OUR PART
	HRLI	T3,F.ZER	;POINT TO OUR F AREA
	BLT	T3,I.LZER(T1)	;COPY OUR PART
	POPJ	P,		;RETURN
;HERE TO CLEAR STICKY DEFAULTS

CLRSTK:	SETZM	P.ZER		;ZERO OUT DEFAULTS
	MOVE	T1,[P.ZER,,P.ZER+1]
	BLT	T1,P.EZER
	SETOM	P.MIN
	MOVE	T1,[P.MIN,,P.MIN+1]
	BLT	T1,P.EMIN
	POPJ	P,

;CLRANS -- CLEAR SCANNING ANSWER AREA
;CALL:	PUSHJ	P,CLRANS
;USES T1

CLRANS:	HLLZS	F		;CLEAR TEMPORARY FLAGS
	SETZM	S.ZER		;ZERO OUT COMMAND ACCUMULATORS
	MOVE	T1,[S.ZER,,S.ZER+1]
	BLT	T1,S.EZER
	SETOM	S.MIN		;PRESET SWITCH PARAMETERS
	MOVE	T1,[S.MIN,,S.MIN+1]
	BLT	T1,S.EMIN
	MOVE	T1,SAVCOR	;GET INITIAL START OF FREE CORE	[1202]
	HLRZM	T1,.JBFF	;SET START OF FREE CORE		[1202]
	HLRZM	T1,I.INZR	;ESTABLISH PARAMETER AREA HERE	[1202]
	HLRZM	T1,I.NXZR	;AND OF ZERO LENGTH		[1202]
	TLZ	T1,-1		;CLEAR JUNK			[1202]
	CORE	T1,		;RESTORE REAL CORE ALSO		[1202]
	  JFCL			;OK IF CAN'T			[1202]
	POPJ	P,		;RETURN
;FILSTK -- MEMORIZE STICKY DEFAULTS
;CALL:	PUSHJ	P,FILSTK
;	RETURNS AFTER NON-ZERO F.XXX COPIED TO P.XXX
;USES T1, T2

FILSTK:	MOVE	T1,F.MOD	;COPY SWITCHES
	MOVE	T2,F.MODM
	ANDCAM	T2,P.MOD
	IORM	T1,P.MOD
	IORM	T2,P.MODM
	SKIPL	T1,F.STRT	;REMEMBER STARTING POINT
	MOVEM	T1,P.STRT	; ..
	SETCM	T1,F.RPT	;MEMORIZE /REPORT
	JUMPE	T1,.POPJ##	;RETURN
	MOVE	T1,F.RPT	;COPY /REPORT
	MOVEM	T1,P.RPT	; ..
	MOVE	T1,F.RPT+1	; ..
	MOVEM	T1,P.RPT+1	; ..
	POPJ	P,

;HERE AT END OF SPECIFICATION TO APPLY USER SUPPLIED DEFAULTS

APLSTK:	MOVE	T1,P.MOD	;APPLY ALL FILE SWITCHES
	ANDCM	T1,F.MODM	;MASK HERE USED TO INDICATE WHICH WERE TYPED
	IORM	T1,F.MOD	; ..
	MOVE	T1,P.MODM	; ..
	IORM	T1,F.MODM	; ..
	MOVE	T1,P.STRT	;GET STARTING POINT
	SKIPGE	F.STRT		;SEE IF SPECIFIED
	MOVEM	T1,F.STRT	;NO--SUPPLY DEFAULT
	SETCM	T1,P.RPT	;GET THE REPORT CODE
	JUMPE	T1,.POPJ##	;DONE IF NOT DEFAULT
	SETCM	T1,F.RPT	;SKIP IF NO REPORT GIVEN
	JUMPN	T1,.POPJ##	;RETURN
	MOVE	T1,P.RPT	;GET /REPORT
	MOVEM	T1,F.RPT	;SAVE FIRST HALF
	MOVE	T1,P.RPT+1	;GET SECOND HALF
	MOVEM	T1,F.RPT+1	;STORE SECOND HALF
	POPJ	P,		;RETURN
	SUBTTL	FILL IN DEFAULTS AFTER COMMAND SCANNING

;DEFAUL -- SUBROUTINE TO FILL IN DEFAULTS AND DETECT
;	INCONSISTENCIES AFTER COMMAND SCANNING
;DEFAU1 -- DITTO EXCEPT DEFAULT OPERATION IS /LIST
;USES EVERYTHING

DEFAUL:	MOVEI	T1,AD.OPN	;FIRST DECIDE WHAT TYPE OF REQUEST
	SKIPGE	S.FAST		;SEE IF /FAST OR
	SKIPL	S.LIST		;SEE IF /LIST SHOWED UP
DEFAU1:	MOVEI	T1,QO.LST	;YES--FORCE /LIST AS DEFAULT
	SKIPGE	S.OPN
	MOVEM	T1,S.OPN
	MOVE	T1,S.OPN	;FETCH ACTUAL OPERATION		[1171]
	MOVE	T2,O.MODM	;GET INDICATOR OF OUTPUT	[1171]
	CAIE	T1,QO.MOD	;SEE IF /MODIFY			[1171]
	CAIN	T1,QO.KIL	;OR IF /KILL			[1171]
	JUMPE	T2,E.SJN	;ERROR IF SO AND NO OUTPUT	[1171]
	MOVE	T1,S.FAST	;IF /FAST
	CAMLE	T1,S.LIST	;AND NOT /LIST
	MOVEM	T1,S.LIST	;USE ITS VALUE IN /LIST

	PUSHJ	P,QUETYP	;IDENTIFY WHAT TYPE OF QUEUE
	MOVE	J,T1		;SAVE AWAY FOR EASY TESTS LATER
	MOVE	P1,I.INZR	;RESET TO START OF INPUT AREA
	ADDI	P1,I.LZER	;FORCE AT LEAST ONE REQUEST
	SKIPN	J		;SEE IF INPUT QUEUE
	ADDI	P1,I.LZER	;YES--THEREFORE, TWO ENTRIES USED
DEFAU2:	CAMG	P1,I.NXZR	;SEE IF NEED MORE THAN GOT
	JRST	DEFAU3		;NO--OK TO PROCEED
	PUSHJ	P,.CLRFL##	;CLEAR FXXX AREAS
	PUSHJ	P,APLSTK	;APPLY STICKY DEFAULTS
	PUSHJ	P,INFIL		;ALLOCATE SPACE
	PUSHJ	P,.GTSPC##	;COPY SPEC
	JRST	DEFAU2		;LOOP BACK TO SEE IF ENOUGH

DEFAU3:	MOVE	I,I.INZR	;START AT BEGINNING OF REQUESTS
	JUMPN	J,DEFAU4	;IF NOT INPUT QUEUE, WE ARE DONE
	CAMN	P1,I.NXZR	;IF INPUT, AND NOT /LIST, SEE IF GT 2 ENTRIES
	JRST	DEFAU4		;NO--OK TO PROCEED
	MOVEI	T1,[ASCIZ /% Warning--input request uses only two entries
/]
	PUSHJ	P,.TSTRG
	MOVEM	P1,I.NXZR	;CHANGE LIMIT TO AGREE
DEFAU4:	MOVE	T1,[5,,[IOWD SWTCHL,SWTCHN
			SWTCHD,,SWTCHM
			0,,SWTCHP
			0
			'KQUE  ']  ]
	TLNN	F,L.KJOB	;SEE IF KJOB TIME
	HRLI	T1,3		;NO--USE SHORTER ARG LIST
	PUSHJ	P,.OSCAN##	;LOOK AT OPTION FILE

	MOVE	I,S.OPN		;MAKE OPERATION AVAILABLE FOR EASY TESTS

	SETOM	PTHFCN		;SET TO READ DEFAULT
	MOVE	T1,[.PTMAX,,PTHFCN]
	PATH.	T1,		;  READ IT
	  SETZM	PTHPPN		;CAN'T--ASSUME DEFAULT
	SKIPN	PTHPPN		;SEE IF SET
	SETZM	PTHPPN+1	;NO--CLEAR SFDS
	MOVE	T1,MYPPN	;GET SELF
	SKIPN	PTHPPN		;SEE IF DEFAULT KNOWN
	MOVEM	T1,PTHPPN	;NO--THEN USE SELF

	SETZM	CREFLG		;CLEAR FLAG FOR /CREATE
	CAIE	I,QO.KIL	;SEE IF /KILL
	CAIN	I,QO.MOD	;SEE IF /MODIFY
	SETOM	CREFLG		;YES--SET FLAG FOR LATER

	HRLOI	T1,'QUE'	;DEFAULT OUTPUT EXTENSION
	CAIN	I,QO.LST
	HRLOI	T1,'LSQ'	;  .. FOR LISTING
	SKIPN	O.EXT
	MOVEM	T1,O.EXT
	CAIE	I,QO.LST	;SEE IF LISTING DEVICE
	JRST	OUDEF1		;NO--NOT A REAL DEVICE
	MOVSI	T1,'TTY'	;SET DEFAULT DEVICE
	SKIPN	P1,O.DEV	;YES--CHECK DEVICE CHARACTERISTICS
	MOVE	P1,T1		;NO DEVICE--USE DEFAULT
	MOVEM	P1,O.DEV	;SAVE FOR LATER
	MOVE	T1,O.MOD	;GET MOD WORD
	TLNN	F,L.PHYP	;SEE IF PHYSICAL POSSIBLE
	TXZ	T1,FX.PHY	;NO--CLEAR FROM REQUEST
	TXNE	T1,FX.PHY	;SEE IF PHYS I/O NEEDED
	DEVCHR	P1,UU.PHY	;YES--TRY IT
	TXNN	T1,FX.PHY	;SEE IF NOT
	DEVCHR	P1,		;NO--USE LOGICAL FROM THE MONITOR
	TXNN	P1,DV.OUT	;SEE IF CAPABLE OF OUTPUT
	JRST	E.NOD		;NO--TELL USER HE BLEW IT
	JRST	OUDEF2		;YES--PROCEED(WARNING--P1 USED BELOW)
OUDEF1:	SKIPE	CREFLG		;SEE IF /MOD OR /KILL
	SKIPE	O.DEV		;YES--SEE IF MISSING QUEUE
	JRST	OUDF1A		;NO--CONTINUE
	HLRZ	N,DQTYPE	;GET DEFAULT QUEUE TYPE
	CAIE	N,'LP '		;QUEUE COMMAND IS 'LP' BUT PRINT IS
				; 'LPT'.
	SKIPN	DQTYPE		;ALSO NEED SOME QUEUE
	JRST	E.NQS		; OR ELSE GIVE ERROR MESSAGE
OUDF1A:	SKIPN	N,O.DEV		;NOT /LIST--GET QUE NAME
	SKIPE	N,DQTYPE	;GET DEFAULT QUEUE TYPE
	SETZM	DQTYPE		;ONLY ONE TIME FOR PRINT TYPE COMMANDS
	CAIN	N,0		;ANYTHING GENERATED?
	MOVSI	N,'LPT'		;NO--USE LPT:
	PUSHJ	P,XPNQUE	;CONVERT ABBREVIATION
	MOVEM	N,O.DEV		;AND STORE
	MOVX	T1,FX.NDV	;CLEAR OUT
	ANDCAM	T1,O.MOD	; NULL DEVICE FLAG

OUDEF2:	CAIN	I,QO.LST	;SEE IF LISTING
	JRST	OUDF2A		;YES--SKIP ONWARD
	MOVE	T1,MYPPN	;GET SELF
	MOVSI	T2,-1		;MASK LEFT HALF
	TDNN	T2,O.DIR	;SEE IF SET
	HRROS	O.DIRM		;NO--PUT ON MASK
	TDNN	T2,O.DIR	; ..
	HLLM	T1,O.DIR	;SET IN SELF PROJECT
	MOVEI	T2,-1		;MASK RIGHT HALF
	TDNN	T2,O.DIR	;SEE IF SET
	HLLOS	O.DIRM		;NO--PUT ON MASK
	TDNN	T2,O.DIR	; ..
	HRRM	T1,O.DIR	;SET IN SELF PROGRAMMER
	SKIPE	O.DIR+2		;CHECK FOR SFDS
	JRST	E.QSFD		;ILLEGAL IN QUEUE USER
	JRST	OUDEF4		;SKIP ON
OUDF2A:	SKIPN	O.NAM
	TXNN	P1,DV.DIR	;YES--SEE IF FILE NAME NEEDED(WARNING--P1 FROM ABOVE)
	JRST	OUDEF4		;NO--GO ON
	MSTIME	T1,		;YES--MANUFACTURE NAME HHMMSS
	IDIVI	T1,^D1000	;GET SECONDS
	MOVE	T4,[POINT 6,O.NAM]  ;SETUP BYTE POINTER
	MOVSI	T3,-6		;INITIALIZE LOOP COUNTER
OUDEF3:	IDIV	T1,[^D36000
		    ^D3600
		    ^D600
		    ^D60
		    ^D10
		    ^D1](T3)	;GET NEXT DIGIT
	ADDI	T1,'0'		;CONVERT TO SIXBIT DIGIT
	IDPB	T1,T4		;STORE INTO NAME
	MOVE	T1,T2		;RESTORE REMAINDER
	AOBJN	T3,OUDEF3	;LOOP
	MOVEI	T1,[ASCIZ /Queue listing on file /]
	PUSHJ	P,.TSTRG
	MOVE	T1,O.NAM	;GET NAME
	PUSHJ	P,.TSIXN
	MOVEI	T1,"."		;OUTPUT SEPARATOR		[1174]
	PUSHJ	P,.TCHAR##	; ..				[1174]
	HLLZ	T1,O.EXT	;GET EXTENSION			[1174]
	PUSHJ	P,.TSIXN##	;OUTPUT IT			[1174]
	PUSHJ	P,.TCRLF
	SETOM	O.NAMM		;CLEAR MASK TO NO WILD-CARDS

OUDEF4:	SETOM	T1		;DON'T ALLOW WILDCARD OUTPUT FILE/DIRECTORY
	SKIPE	CREFLG		;SEE IF MODIFY
	JRST	OUDEF5		;YES--WILD CARDS ARE LEGAL
	CAME	T1,O.NAMM
	SKIPN	O.NAM
	SKIPA
	JRST	E.WCO
	CAME	T1,O.DIRM
	SKIPN	O.DIR
	SKIPA
	JRST	E.WDO
	JRST	OUDEF6		;PROCEED			[1173]
OUDEF5:	SKIPGE	S.SEQ		;SEE IF /SEQ			[1173]
	SKIPE	O.NAM		;NO--SEE IF NAME		[1173]
	SKIPA			;YES--OK			[1173]
	JRST	E.NSR		;NO--ERROR			[1173]
OUDEF6:	XOR	T1,O.EXT
	TRNE	T1,-1
	JRST	E.WXO
;HERE TO SUPPLY INPUT SIDE DEFAULTS

INDEF:	PUSHJ	P,QUETYP	;IDENTIFY TYPE OF QUEUE
	MOVE	J,T1		;SAVE AWAY FOR EASY TESTS
	MOVE	I,I.INZR	;INITIALIZE LOOP

;LOOP HERE TO DEFAULT NEXT INPUT FILE

INDEF1:	SKIPE	CREFLG		;SEE IF /MODIFY
	JRST	INDEFY		;YES--SKIP TO NAME TESTS
	MOVSI	T1,'DSK'	;DEFAULT DEVICE
	JUMPGE	J,INDF1A	;JUMP IF NOT /LIST
	MOVE	T1,DQTYPE	;GET DEFAULT QUEUE
	TLNN	T1,(77B17)	;IS IT FROM QUEUE COMMAND?
	SETZ	T1,		;YES--DEFAULT IS ALL:
INDF1A:	MOVX	T2,FX.NDV	;SEE IF
	TDNN	T2,.FXMOD(I)	;  NULL DEVICE
	SKIPN	.FXDEV(I)
	MOVEM	T1,.FXDEV(I)
	JUMPN	J,INDEFF	;IF NOT INPUT QUEUE, PROCEED
	SETOM	T1		;INPUT NOT /LIST, SO NO WILDCARDS
	CAME	T1,.FXNMM(I)	;TEST NAME WILD
	SKIPN	.FXNAM(I)	;YES--SEE IF NAME THERE
	JRST	.+2		;NO--THEN OK
	JRST	E.WCI		;YES--ILLEGAL
	MOVEI	T1,0		;CLEAR DEFAULT
	CAME	I,I.INZR	;IF NOT FIRST FILE,
	MOVE	T1,.FXNAM-I.LZER(I)  ;  DEFAULT TO PREVIOUS FILE
	SKIPN	T2,O.NAM	;GET JOB NAME
	MOVE	T2,T1		;IF NO JOB NAME, DEFAULT IS CTL FILE
	SKIPN	T1,.FXNAM(I)	;SEE IF NAME SUPPLIED
	MOVE	T1,T2		;NO--GET DEFAULT NAME
	JUMPE	T1,E.NNI	;ERROR IF NONE
	MOVEM	T1,.FXNAM(I)	;AND STORE RESULT
	SETOM	.FXNMM(I)	;REMOVE WILDCARD FROM NAME

INDEFF:	SKIPE	.FXNAM(I)	;DEFAULT FILE NAME
	JRST	INDEFX		;NO DEFAULT NEEDED
	CAME	I,I.INZR	;SEE IF FIRST FILE
	SKIPA	T1,.FXNAM-I.LZER(I)  ;NO--USE PREVIOUS FILE NAME
	MOVSI	T1,'*  '	;YES--SUPPLY WILD DEFAULT
	MOVEM	T1,.FXNAM(I)
	CAME	I,I.INZR	;SEE IF FIRST
	SKIPA	T1,.FXNMM-I.LZER(I)  ;NO--USE PREVIOUS MASK
	MOVEI	T1,0		;YES--USE WILD MASK
	MOVEM	T1,.FXNMM(I)	; ..
INDEFX:	SKIPE	.FXEXT(I)	;DEFAULT EXTENSION
	JRST	INDEFY		;NOT NEEDED
	MOVSI	T1,'*  '	;SET DEFAULT FOR /MODIFY
	SKIPE	CREFLG		;SEE IF /MODIFY
	JRST	INDEF2		;YES--GO STORE DEFAULT
	JUMPL	J,INDEFY
	MOVE	T1,INDFXT(J)	;GET EXTENSION
	CAMN	I,I.INZR	;SEE IF FIRST FILE
	JRST	INDFLG		;YES--PROCEED BELOW
	JUMPN	J,INDFLG	;IF SUBSEQUENT AND INPUT QUEUE,
	MOVSI	T1,'LOG'	;  CHANGE TO LOG
	MOVSI	T2,(X.NEW)	;SET /NEW SWITCH
	IORM	T2,I.MOD(I)	;  INTO REQUEST
INDFLG:	TRO	T1,-1		;SET MASK TO BELIEVE WHOLE EXT
INDEF2:	MOVEM	T1,.FXEXT(I)	;STORE IT
INDEFY:	SKIPE	CREFLG		;SEE IF /MODIFY
	JRST	INDEF3		;YES--SKIP TO DIRECTORY TESTS
	JUMPN	J,INDEF3	;IF NOT INPUT QUEUE, PROCEED
	SETCM	T1,.FXEXT(I)	;INPUT AND NOT /LIST--SEE IF
	TRNE	T1,-1		;  EXTENSION HAS WILDCARD
	JRST	E.WXI		;YES--ILLEGAL

INDEF3:	MOVX	T1,FX.DIR	;GET DIRECTORY BIT
	JUMPGE	J,INDFNL	;JUMP IF NOT /LIST
	SKIPE	.FXDIR+2(I)	;SEE IF LISTING SFDS
	JRST	E.LSFD		;YES--THAT'S WRONG
	SKIPN	T2,O.DIR	;GET OUTPUT DIRECTORY
	MOVE	T2,MYPPN	;OR LOGGED IN NUMBER
	TDNE	T1,.FXMOM(I)	;SEE IF DIRECTORY PRESENT
	JRST	INDFTU		;YES--GO SET USER'S DEFAULTS
	SETOM	.FXDIR(I)	;NO--SET FOR ALL USERS
	JRST	INDFNM		;AND INDICATE DIRECTORY SET
INDFNL:	SKIPE	T2,O.DIR	;ACTION REQUEST--SEE IF
	CAMN	T2,MYPPN	;  FOR SPECIFIC USER
	JRST	INDEFD		;NO--PROCEED
INDFTU:	MOVSI	T3,-1		;YES--USE HIM FOR DEFAULT
	TDNN	T3,.FXDIR(I)	;CHECK FOR PROJECT
	HRROS	.FXDIM(I)	;BLANK--SET IT
	TDNN	T3,.FXDIR(I)	; ..
	HLLM	T2,.FXDIR(I)	; TO QUEUED USER
	MOVEI	T3,-1		;CHECK FOR
	TDNN	T3,.FXDIR(I)	; PROGRAMMER NUMBER
	HLLOS	.FXDIM(I)	;BLANK--SET IT
	TDNN	T3,.FXDIR(I)	; ..
	HRRM	T2,.FXDIR(I)	; TO QUEUED USER
INDFNM:	IORM	T1,.FXMOD(I)	;INDICATE DIRECTORY
	IORM	T1,.FXMOM(I)	; SPECIFIED
INDEFD:	SKIPE	CREFLG		;SEE IF /MODIFY
	JRST	INDNOK		;YES--SKIP TO SWITCH TESTS
	JUMPN	J,INDEF4	;IF NOT INPUT QUEUE, PROCEED
	MOVE	T1,.FXDIR(I)	;GET DIRECTORY
	SETCM	T2,.FXDIM(I)	;AND COMPLEMENT OF MASK
	TLNN	T1,-1		;SEE IF PROJECT DEFAULT
	TLZ	T2,-1		;YES--CLEAR WILD-CARDS
	TRNN	T1,-1		;SEE IF PROGRAMMER DEFAULT
	TRZ	T2,-1		;YES--CLEAR WILD-CARDS
	JUMPN	T2,E.WDI	;ERROR IF WILD UFD
	SETOM	T1		;INPUT--CHECK FOR WILD DIRECTORY
	MOVEI	T2,2(I)		;SET POINTER TO SPEC
	HRLI	T2,1-.FXLND	;COUNT SFD DEPTH
INDFNN:	SKIPN	.FXDIR(T2)	;SEE IF SPECIFIED
	JRST	INDEF4		;NO--ALL DONE
	CAME	T1,.FXDIM(T2)	;SEE IF NOT WILD
	JRST	E.WDI		;ERROR IF SO
	ADDI	T2,1		;ADVANCE COUNT
	AOBJN	T2,INDFNN	;LOOP OVER SFD DEPTH
INDEF4:	MOVE	T1,INDADS	;ABSENT DEFAULTS FOR SWITCHES
	JUMPN	J,INDEFO	;IF NOT INPUT, GO DO IT
	CAME	I,I.INZR	;IF INPUT AND LOG FILE,
	MOVE	T1,INDADI	; USE SPECIAL SET
INDEFO:	CAIL	J,2		;SEE IF PTP, PLT, CDP
	TRZ	T1,X.PAPR	;YES--DEFAULT MODE IS FCTN OF FILE MODE
	HLRZ	T3,.FXEXT(I)
	MOVEI	T2,FILEASCII	;/FILE:ASCII
	CAIN	T3,'DAT'
	MOVEI	T2,FILEFORTRAN	;/FILE:FORTRAN
	CAIN	T3,'CRF'
	MOVEI	T2,FILECREF	;/FILE:CREF
	CAIN	T3,'RNO'
	MOVEI	T2,FILERUNOFF	;/FILE:RUNOFF
	DPB	T2,[POINTR (T1,X.FILE)]

	MOVEI	T2,0		;CLEAR DISPOSITION		[1200]
	MOVX	T4,FX.DIR	;SEE IF
	TDNE	T4,.FXMOD(I)	;DEFAULT DIRECTORY
	SKIPA	T4,.FXDIR(I)	;NO--USE SPECIFIED UFD
	MOVE	T4,PTHPPN	;YES--GET IT'S UFD
	TLNN	T4,-1		;SEE IF PROJECT
	HLL	T4,MYPPN	;NO--USE LOGGED IN ONE
	TRNN	T4,-1		;SEE IF PROGRAMMER
	HRR	T4,MYPPN	;NO--USED LOGGED IN ONE
	CAME	T4,MYPPN	;SEE IF IT IS US
	JRST	INDFND		;NO--LEAVE DEFAULT ALONE
	SETO	T4,		; ..
	CAME	T4,.FXDIM(I)	; ..
	SKIPN	.FXDIR(I)	;(ALLOW FOR NULL)
	SKIPA			; ..
	JRST	INDFND		; ..
	CAIE	T3,'LST'
	CAIN	T3,'CRF'
	MOVEI	T2,DISPRENAME	;/DISPOSE:RENAME
	CAIN	T3,'TMP'
	MOVEI	T2,DISPRENAME	;/DISPOSE:RENAME
INDFND:	SKIPE	J		;IGNORE IF INPUT QUEUE
	SKIPN	T2		;SEE IF DEFAULT SET		[1200]
	SKIPA			;NO DEFAULT--LEAVE ALONE	[1200]
	DPB	T2,[POINTR (T1,X.DISP)]
	MOVX	T2,X.LOG	;SEE IF .LOG
	TDNE	T2,I.MOD(I)	;  FILE SPECIFIED
	TXO	T1,X.NEW	;YES--SET /NEW
	ANDCM	T1,I.MODM(I)	;MASK TO ONLY THE NEEDED ONES
	IORB	T1,I.MOD(I)	;AND INCLUDE
	MOVX	T2,FX.PHY	;GET /PHYS BIT
	TLNE	T2,L.PHYS	;SEE IF PHYS-ONLY POSSIBLE
	IORM	T2,.FXMOD(I)	;YES--SET IT
	TXNN	T1,X.NEW	;SEE IF /NEW
	JRST	INDNOK		;NO--NULL EXT HACK OK
	MOVX	T2,FX.NUL	;YES--CLEAR NULL EXT
	ANDCAM	T2,.FXMOD(I)	; FLAG IN REQUEST

INDNOK:	LDB	T2,[POINTR (I.MOD(I),X.FILE)]
	MOVEI	T1,[ASCIZ \
% RUNOFF AND CREF FILE FORMATS NOT YET SUPPORTED--ASCII ASSUMED
\]
	CAIE	T2,FILECREF	;SEE IF UNSUPPORTED
	CAIN	T2,FILERUNOFF	;  FILE HANDLING
	PUSHJ	P,.TSTRG	;YES--COMPLAIN

	MOVEI	T1,AD.STR	;GET DEFAULT STARTING POINT
	SKIPE	CREFLG		;SEE IF /MODIFY
	MOVEI	T1,0		;YES--CLEAR DEFAULT
	SKIPGE	I.STRT(I)	;SEE IF SOME SPECIFIED
	MOVEM	T1,I.STRT(I)	;NO--USE DEFAULT
	JUMPL	J,INDEF6	;IS LIST REQUEST--DON'T WORRY ABOUT DEVICE
	MOVE	T1,.FXDEV(I)	;NO--VERIFY THAT THE DEVICE IS A DISK
	JUMPE	T1,INDEF7	;JUMP IF NO DEVICE
	MOVE	T2,[DEVCHR T1,]
	MOVX	T3,FX.PHY	;GET /PHYS SWITCH BIT
	TDNE	T3,.FXMOD(I)	;SEE IF /PHYS
	TXO	T2,UU.PHY	;YES--SET PHYSICAL CALLI
	TLNN	F,L.PHYP	;SEE IF PHYSICAL POSSIBLE
	TXZ	T2,UU.PHY	;NO--CLEAR IT AGAIN
	XCT	T2		;DO THE DEVCHR
	TXNN	T1,DV.DSK
	JRST	E.NDD		;NO--FATAL ERROR
	JRST	INDEF7		;YES--PROCEED

INDEF6:	SKIPE	N,.FXDEV(I)	;/LIST--GET QUE NAME
	PUSHJ	P,XPNQUE	;EXPAND ABBREVIATION
	MOVEM	N,.FXDEV(I)	;AND STORE RESULT

INDEF7:	ADDI	I,I.LZER	;ADVANCE POINTER
	CAMGE	I,I.NXZR	;SEE IF DONE YET
	JRST	INDEF1		;NO--LOOP BACK
;HERE TO SUPPLY DEFAULTS FOR GLOBAL SWITCHES

	SKIPE	CREFLG		;SEE IF /MODIFY
	JRST	SWDEF2		;YES--SKIP DEFAULT SWITCHES
	SKIPL	S.COR		;SEE IF /CORE GIVEN
	JRST	SWDEF0		;YES--PROCEED
	MOVX	T1,%NSCMX	;NO--GET SYSTEM
	GETTAB	T1,		;  CORMAX
	  JRST	SWDEF0		;(GIVE UP)
	CAIGE	T1,AD.COR	;SEE IF DEFAULT TOO BIG
	MOVEM	T1,S.COR	;YES--FORCE CORMAX
SWDEF0:	MOVSI	T1,-S.EMIN+S.MIN-1  ;INITIALIZE LOOP
SWDEF1:	MOVE	T2,SWDEFT(T1)	;GET DEFAULT
	MOVE	T3,S.MIN(T1)	;GET VALUE ENTERRED
	CAMN	T3,[-1]		;SEE IF ANYTHING TYPED
	MOVEM	T2,S.MIN(T1)	;YES--STUFF DEFAULT
	AOBJN	T1,SWDEF1	;LOOP BACK FOR MORE

	JUMPLE	J,SWDEF2	;DON'T FUDGE LIMITS IF INPUT QUEUE
	MOVE	T2,@SWLDT(J)	;GET ALTERNATE SWITCH LIMIT VALUE
	SKIPGE	S.LIM
	MOVEM	T2,S.LIM
	SKIPN	S.LIM		;SEE IF /LIMIT
	JRST	E.LIMZ		;ZERO LIMIT IS AN ERROR
SWDEF2:	SKIPGE	S.SEQ		;SEE IF SEQUENCE STILL NOT SET
	SETZM	S.SEQ		; RIGHT--SET IT FOR /MOD/KILL
	MOVE	T1,S.COR	;LOOK AT CORE SIZE
	JUMPL	T1,SWDEF3	;IF DEFAULT, LEAVE ALONE
	CAIGE	T1,^D256	;SEE IF ALREADY IN WORDS
	LSH	T1,^D10		;NO--ADD K FACTOR
	MOVEM	T1,S.COR	;STORE RESULT

	SKIPN	DEFFIL+.FXDEV	;SEE IF /PATH
	JRST	SWDEF3		;NO--PROCEED
	SKIPN	DEFFIL+.FXNAM	;SEE IF /PATH:NAME
	SKIPL	DEFFIL+.FXMOD	; OR /PATH:DEV:
	....==FX.NDV
	JRST	E.PTHN		;ERROR IF SO
	SKIPE	DEFFIL+.FXEXT	; OR /PATH:.EXT
	JRST	E.PTHN		;ERROR IF SO
SWDEF3:	SKIPE	CREFLG		;SEE IF /MODIFY
	POPJ	P,		;YES--RETURN
	JUMPL	J,.POPJ		;GO PROCESS IF /LIST
	JUMPN	J,SWDEF4	;PROCEED IF NOT INPUT
	MOVX	T1,FX.DIR	;GET [] BIT
	TDNE	T1,DEFFIL+.FXMOM  ;SEE IF /PATH:[]
	JRST	SWDPTD		;YES--JUST CHECK NOT WILD
	MOVE	T2,MYPPN	;NO--GET SELF
	SKIPN	O.DIR+2		;SEE IF NOT OUTPUT SFD
	CAME	T2,O.DIR	;SEE IF MATCHES OUTPUT P,PN
	TDNN	T1,O.MODM	;OR NO OUTPUT P,PN
	JRST	SWDPTS		;RIGHT--USE DEFAULT DIRECTORY
	MOVE	T1,[O.DIR,,DEFDIR] ;NO--COPY
	BLT	T1,DEFDIR+2*.FXLND-1  ;OUTPUT DIRECTORY
	JRST	SWDPTD		;THEN CHECK FOR NO WILD-CARDS
SWDPTS:	MOVSI	T2,-.FXLND	;GET LOOP COUNT
	MOVEI	T3,0		;AND STORE INDEX
SWDPTL:	SKIPN	T1,PTHPPN(T2)	;GET DEFAULT PATH
	SOS	T2		;DEFEAT ADVANCE IF DONE
	MOVEM	T1,DEFDIR(T3)	;STORE IN /PATH
	SETOM	DEFDIR+1(T3)	;CLEAR WILDCARDS
	ADDI	T3,2		;ADVANCE STORE
	AOBJN	T2,SWDPTL	;LOOP UNTIL DONE
SWDPTD:	MOVE	T1,DEFDIR	;GET UFD
	SKIPN	T2,O.DIR	;GET OUTPUT DIRECTORY
	MOVE	T2,MYPPN	;DEFAULT TO LOGGED IN DIRECTORY
	TLNN	T1,-1		;SEE IF PROGRAMMER
	HLL	T1,T2		;NO--DEFAULT
	TRNN	T1,-1		;SEE IF PROGRAMMER
	HRR	T1,T2		;NO--DEFAULT
	MOVEM	T1,DEFDIR	;STORE AWAY
	MOVSI	T2,-.FXLND	;SET LOOP COUNT
SWDPTM:	SKIPN	DEFDIR(T2)	;SEE IF NEXT LEVEL SPECIFIED
	JRST	SWDPTX		;NO--ALL OK
	SETCM	T1,DEFDIR+1(T2)	;GET COMPLEMENT OF WILD MASK
	JUMPN	T1,E.PTHW	;ERROR IF WASN'T -1
	ADDI	T2,1		;ADVANCE BY 2
	AOBJN	T2,SWDPTM	;LOOP OVER FULL DEPTH
SWDPTX:	MOVEI	T1,AI.CDP	;GET CARD PUNCH LIMIT
	SKIPGE	S.LCDP
	MOVEM	T1,S.LCDP
	MOVEI	T1,AI.LPT
	SKIPGE	S.LLPT
	MOVEM	T1,S.LLPT
	MOVEI	T1,AI.PLT
	SKIPGE	S.LPLT
	MOVEM	T1,S.LPLT
	MOVEI	T1,AI.PTP
	SKIPGE	S.LPTP
	MOVEM	T1,S.LPTP
	SKIPN	S.LTIM		;SEE IF TIME IS 0
	JRST	E.TMZ		;YES--ERROR

SWDEF4:	MOVE	I,I.INZR	;DEFAULT JOB NAME IS FIRST FILE NAME
	CAIN	J,0		;UNLESS INPUT QUEUE
	ADDI	I,I.LZER	;FOR WHICH IT IS LOG FILE
	SETCM	T1,.FXNMM(I)	;SEE IF WILDCARD IN FILE
	JUMPN	T1,.POPJ	;YES--JUST PROCESS
	HLLZ	T1,.FXEXT(I)	;GET EXTENSION
	PUSHJ	P,ISOUTE	;SEE IF OUTPUT
	  JRST	.+3		;NO--TRY FOR DEFAULT
	  POPJ	P,		;YES--IGNORE DEFAULT NAME
	  POPJ	P,		;YES--IGNORE DEFAULT NAME
	MOVE	T1,.FXNAM(I)	;NO--GET FILE NAME IN CASE
	SKIPN	O.NAM		;SEE IF OUTPUT NAME YET
	MOVEM	T1,O.NAM	;NO--SET THIS ONE
	POPJ	P,		;RETURN
INDADS:	BYTE	(6) AD.NHD (12) 0 (3) SPACSINGLE,PRINARROW,0,DISPPRESERVE (6) AD.COP  ;DEF. FILE SWITCHES
INDADO:	BYTE	(6) AD.NHD (12) 0 (3) SPACSINGLE,0,FILEASCII,DISPRENAME (6) FS.COP  ;FORCED SPOOLING SWITCHES
INDADL:	BYTE	(2) 1 (4) AD.NHD (12) 0 (3) SPACSINGLE,PRINARROW,FILEASCII,.. (6) FL.COP  ;FORCED LOG FILE
INDADI:	BYTE	(3) 1 (3) AD.NHD (12) 0 (3) SPACSINGLE,PRINARROW,FILEASCII,AD.LFD (6) FL.COP  ;INPUT QUEUE LOG FILE

;THIS TABLE MUST PARALLEL S.MIN

SWDEFT:	EXP	AD.AFT,0,AD.COR,AD.DED,AD.DPN,-1
	EXP	0,AD.CDP,AD.LIM,-1,AD.LPT,AD.PLT
	EXP	AD.PTP,AD.TIM,0,0,0,0,AD.OUT,AD.PRI,AD.RST,AD.SEQ,AD.UNI
LN.SM==.-SWDEFT
	XALL
SWLDT==.-1		;LOCATION OF INDIVIDUAL QUEUE LIMITS
	DEFINE X(LIST),<
IRP LIST,<IFDIF <LIST><INP>,<
	S.L'LIST
			>>>
	QUEUES

QLIMOF==.-1		;ADDONS FOR EACH OUTPUT QUEUE
	DEFINE X(LIST),<
IRP LIST,<IFDIF <LIST><INP>,<
	AO.'LIST
			>>>
	QUEUES

QLIMVF==.-1		;DIVISORS FOR EACH OUTPUT QUEUE		[1201]
	DEFINE X(LIST),<	;;				[1201]
IRP LIST,<IFDIF <LIST><INP>,<	;;				[1201]
	AV.'LIST	;;					[1201]
			>>>	;;				[1201]
	QUEUES		;					[1201]

INDFXT:			;DEFAULT EXTENSIONS FOR QUEUES
	DEFINE X(LIST),<
IRP LIST,<
	SIXBIT /LIST/
			>>
	QUEEXT
	SALL
;FILE SCANNING ERRORS

E.NOD:	MOVE	N,O.DEV
	N.FAIN	<Can not do output to device>
E.NDD:	MOVE	N,.FXDEV(I)
	N.FAIN	<Input device not a disk>
E.WCO:	MOVE	N,O.NAM
	N.FAIN	<Wildcard illegal in output name>
E.WDO:	N.FAIL	<Wildcard illegal in output directory>
E.WXO:	HLLZ	N,O.EXT
	N.FAIN	<Wildcard illegal in output extension>
E.WCI:	MOVE	N,.FXNAM(I)
	N.FAIN	<Wildcard illegal in input queue file name>
E.WDI:	N.FAIL	<Wildcard illegal in input queue file directory>
E.WXI:	HLLZ	N,.FXEXT(I)
	N.FAIN	<Wildcard illegal in input queue file extension>
E.NNI:	N.FAIL	<File name required for input queue>
IFN DEBUG,<E.PDL:	TLO	F,L.WIPE	;FLAG TO DIE
			N.FAIL	<PDL phase error>>
E.TMZ:	N.FAIL	<Input queue time limit must be non-zero>
E.NQS:	N.FAIL	<No queue specified in /KILL or /MODIFY>
E.QSFD:	N.FAIL	<Queue user cannot include SFDs>
E.LSFD:	N.FAIL	<Listed queue user cannot include SFDs>
E.LIMZ:	N.FAIL	<Limit cannot be zero>
E.PTHN:	N.FAIL	<File name illegal in default path>
E.PTHW:	N.FAIL	<Wildcard illegal in default path>
E.SJN:	N.FAIL	<Specify job name left of equal sign>
E.NSR:	N.FAIL	<Job name or /SEQUENCE required>		;[1173]
	SUBTTL	COMMAND PROCESSING

;COMAND -- SUBROUTINE TO PROCESS COMMAND
;USES EVERYTHING

;HERE AFTER COMMAND HAS BEEN DECODED AND ALL DEFAULTS SUPPLIED
;DISPATCH TO APPROPRIATE COMMAND PROCESSOR

COMAND:	SKIPLE	I,S.OPN		;FETCH OPERATION CODE, CHECK FOR LEGAL
	CAILE	I,LCDT		;CHECK FOR VALIDITY
	JRST	E.ICMD		;NO--BOMB THE USER
	SETZM	T.ZER		;ZERO OUT TEMPORARIES
	MOVE	T1,[T.ZER,,T.ZER+1]  ; ..
	BLT	T1,T.EZER	; ..
	MOVE	Q,.JBFF		;SETUP POINTER TO QUEUE AREA
	GCORE	Q.EZER		;GRAB MINIMAL AREA AT FIRST
	SETZM	(Q)		;ZERO OUT QUEUE COMMAND AREA
	HRLZI	T1,(Q)		; ..
	HRRI	T1,1(Q)		; ..
	BLT	T1,Q.EZER(Q)	; ..
	MOVE	T1,CDTAB-1(I)	;GET ADDRESS AND CONTROL BITS
	TLNE	F,L.KJOB	;SEE IF KJOB ENTRY POINT
	JUMPL	T1,E.ICMK	;YES--IF ILLEGAL, ABORT
	TLNE	T1,(NNLGSB)	;SEE IF ERROR AS SUBJOB		[1177]
	TLNN	F,L.NSBJ	;NO--SEE IF TOP IS LOGGED IN	[1177]
	SKIPA			;YES--LEAVE ALONE		[1177]
	TLO	T1,(NNLGI)	;NO--INDICATE ERROR		[1177]
	TLNN	F,L.LOGI!L.KJOB  ;SEE IF LOGGED IN
	TLNN	T1,(NNLGI)	;NO--SEE IF LEGAL IF NOT
	JRST	(T1)		;YES--GO DO IT
	MOVE	N,CMDTAB-1(I)	;ILLEGAL--ABORT
	N.FAIN	<LOGIN please to use switch>


;TABLE OF DISPATCH ADDRESSES FOR VARIOUS COMMANDS
NKJOB==1B0		;NOT LEGAL AT KJOB TIME
NNLGI==1B1		;NOT LEGAL UNLESS LOGGED IN
NNLGSB==1B2		;NOT LEGAL UNLESS LOGGED IN AT TOP LEVEL	[1177]

CDTAB:
	EXP	CREATE+NNLGI		;1=CREATE ENTRY
	EXP	DEFER+NKJOB+NNLGI	;2=APPEND TO DEFFERED ENTRY
	EXP	ZDEFER+NKJOB+NNLGI	;3=ZERO DEFERALS, THEN DEFER
	EXP	LIST+NKJOB		;4=LIST QUEUE
	EXP	MODIFY+NNLGSB		;5=MODIFY EXISTING ENTRY	[1177]
	EXP	KILL+NNLGSB		;6=KILL EXISTING ENTRY	[1177]
LCDT==.-CDTAB


;HERE ON FUTURE OPERATIONS  (***TEMP***)
DEFER:
ZDEFER:	MOVE	N,CMDTAB-1(I)
	N.FAIN	<Not yet supported command code>
;HERE ON IMPROPER DISPATCH CODE

E.ICMD:	HRRZ	N,I
	N.FAID	<Improper command code>

;HERE ON ILLEGAL KJOB COMMAND

E.ICMK:	MOVE	N,CMDTAB-1(I)	;GET NAME OF BAD SWITCH
	N.FAIN	<Illegal deferred command>

CMDTAB:	SIXBIT	/CREATE/
	SIXBIT	/DEFER/
	SIXBIT	/ZDEFER/
	SIXBIT	/LIST/
	SIXBIT	/MODIFY/
	SIXBIT	/KILL/
	SUBTTL	COMMAND PROCESSING -- LIST

;HERE TO LIST SOME CROSS-SECTION OF THE QUEUES

LIST:	MOVE	I,I.INZR	;START WITH FIRST REQUEST
	MOVEI	T1,O.ZER	;GET OUTPUT SPEC
	MOVEI	T2,L.OPEN	; AND OUTPUT OPEN BLOCK
	MOVEI	T3,L.LOOK	; AND OUTPUT ENTER BLOCK
	PUSHJ	P,.STOPN##	;CONVERT ARGUMENTS
	  HALT	.		;ALREADY CHECK FOR WILD
	MOVSI	T1,B.LC		;POINT TO BUFFER HEADERS
	MOVEM	T1,L.OPEN+2	;STORE IN OPEN BLOCK
	MOVEI	T1,5		;SET LENGTH OF BLOCK
	MOVEM	T1,L.LOOK	;  INTO LOOKUP BLOCK
	MOVS	T1,L.OPEN+1	;GET OUTPUT DEVICE
	CAIE	T1,'TTY'	;IF TTY:
	TLNE	F,L.LOGI	; OR LOGGED IN,
	JRST	LIST1		;THEN OK TO LIST
	SETOM	T1		;ELSE, CHECK
	CTLJOB	T1,		; IF BEING CONTROLLED
	  SETOM	T1		;(ASSUME NOT)
	JUMPGE	T1,LIST1	;YES--OK TO LIST
	N.FAIN	<LOGIN to list on device>

LIST1:	OPEN	LC,L.OPEN	;INIT THE DEVICE
	  JRST	[MOVE	T2,L.OPEN+1	;FAILED--SEE IF LPT
		 DEVCHR	T2,		;CHECK WITH MONITOR
		 TXNN	T2,DV.LPT	; ..
		 JRST	E.OOF		;NO--GIVE OUTPUT OPEN FAILURE
		 MOVEI	T1,[ASCIZ /LPT busy--waiting
/]					;TELL OPERATOR ABOUT IT
		 TRON	F,R.LPTB	;YES--FLAG WAITING
		 PUSHJ	P,.TSTRG
		 MOVEI	T2,5		;AND SLEEP
		 SLEEP	T2,		;FOR 5 SEC.
		 JRST	LIST1]		;AND TRY AGAIN
	TRZ	F,R.LPTB	;CLEAR FLAG AGAIN
	SKIPN	T1,O.NAM	;GET FILE NAME FOR ENTER
	JRST	LISTST		;GO TO WORK IF NO ENTER NEEDED
	MOVEI	P2,1		;LOOKUP ONCE, THEN ENTER ONCE
	MOVE	P1,L.LOOK+.RBPPN  ;SAVE DIRECTORY
	LOOKUP	LC,L.LOOK	;FIRST LOOKUP TO SEE IF OK
	  SKIPA			;FAILED--TRY CREATE
	JRST	LIST7		;OK--GO CHECK IT OUT
	HRRZ	T1,L.LOOK+.RBEXT  ;GET ERROR CODE
	JUMPN	T1,E.OEFE	;ERROR UNLESS NOT FOUND
	SKIPN	T1,L.LOOK+.RBPPN  ;SEE IF FILSER GAVE UFD
	MOVE	T1,PTHPPN	;NO--USE DEFAULT UFD
	TLNN	T1,-1		;SEE IF SFD POINTER
	MOVE	T1,.PTPPN(T3)	;YES--GET UFD
	MOVSI	T2,'UFD'	;SET TO GET UFD
	MOVEI	T3,0		;CLEAR JUNK
	MOVE	T4,MFDPPN	;SET MFD
	LOOKUP	LC,T1		;GET ITS PROTECTION
	  JRST	E.OEFU		;ERROR IF NON-EXISTENT
	HLRZ	T2,T3		;GET UFD PROTECTION
	ANDI	T2,(RB.PRV)	;REMOVE JUNK
	HRLI	T2,.ACCRE	;SET FOR CREATE
	JRST	LIST8		;GO DO THE CHECK

LIST5:	CLOSE	LC,CL.NMB!CL.ACS!CL.DLL  ;CLOSE LOOKUP
	MOVEM	P1,L.LOOK+.RBPPN  ;RESTORE DIRECTORY
	ENTER	LC,L.LOOK	;ENTER FILE
	  JRST	E.OEFE		;ERROR

LIST7:	LDB	T2,[POINTR (L.LOOK+.RBPRV,RB.PRV)]
	HRLI	T2,.ACWRI	;SET FOR WRITE

LIST8:	SKIPN	T3,L.LOOK+.RBPPN  ;GET TARGET DIRECTORY
	MOVE	T3,PTHPPN	;USE US IF NOT AVAIL.
	TLNN	T3,-1		;SEE IF SFD
	MOVE	T3,.PTPPN(T3)	;YES--GET OWNER
	MOVE	T4,MYPPN	;SETUP CHKACC AS US
	MOVEI	T1,T2		;POINT TO IT
	CHKACC	T1,		;ASK FILSER TO CHECK ACCESS
	  MOVEI	T1,0		;ALLOW IT TO PASS
	MOVEI	T2,ERPRT%	;PRESET PROTECTION
	JUMPL	T1,E.OEF	;ERROR IF NOT ALLOWED
	SOJGE	P2,LIST5	;LOOP FOR ENTER
LISTST:	MOVE	T1,O.DEV	;GET OUTPUT DEVICE
	MOVE	T2,[DEVCHR T1,]  ;GET UUO
	MOVX	T3,FX.PHY	;GET /PHYS BIT
	TLNN	F,L.PHYS	;SEE IF NORMAL
	TDNE	T3,O.MOD	;OR ASKED FOR
	TXO	T2,UU.PHY	;YES--SET BIT
	TLNN	F,L.PHYP	;SEE IF POSSIBLE
	TXZ	T2,UU.PHY	;NO--CLEAR BIT
	XCT	T2		;DO THE UUO
	TXNE	T1,DV.TTA	;  IF CONSOLE TTY
	TRO	F,R.OUTO	;YES--FLAG FOR TTY TO USE LISTER
	TXNE	T1,DV.DSK	;SEE IF A DISK
	TRO	F,R.ODSK	;YES--FLAG
	TXNE	T1,DV.LPT!DV.TTY	;SEE IF LINE MODE OUTPUT DEVICE
	TRO	F,R.OUTL	;YES--SET FLAG TO FORCE OUT EACH LINE
	MOVEI	T1,LC		;BUT ALSO SEE IF SPOOLING IT
	DEVTYP	T1,		;USE CHANNEL CALL
	  MOVEI	T1,0		;BEFORE 5.3, NO SPOOLING
	TXNE	T1,TY.SPL	;SEE IF SPOOLED
	TRZ	F,R.OUTL!R.OUTO  ;YES--CLEAR LINE MODE AND ERROR HACK
	TXNE	T1,TY.SPL	;CHECK AGAIN
	TRO	F,R.ODSK	;YES--SET FOR DISK DEVICE
	OUTBUF	LC,0		;ALLOCATE BUFFERS BEFORE QMANGR MANGLES FREE CORE
	MOVEI	T1,LC		;GET NAME OF LISTING DEVICE
	DEVNAM	T1,		;(PHYSICAL NAME PREFERRED)
	  MOVE	T1,O.DEV	;IF OLD MONITOR, USE LOGICAL NAME
	CAME	T1,[SIXBIT /TTY/]  ;IF USELESS NAME, GIVE UP
	TRNE	F,R.ODSK	;SEE IF A DISK
	MOVEI	T1,0		;YES--NOT A USEFUL PROCESSOR
	MOVEM	T1,PRODEV	;STORE AWAY FOR LATER
	SETZM	LSTZER		;CLEAR OUT THE TEMPS
	MOVE	T1,[LSTZER,,LSTZER+1] ; USED BY THE LISTING ROUTINE
	BLT	T1,LSTEZR-1	; ..
	SKIPL	S.FAST		;FAST MODE?
	SETZM	S.LIST		;YES--FORCE /LIST:0
	HLLZ	T1,.FXDEV(I)	;GET GENERIC QUEUE
	MOVEM	T1,ONEQUE	;SAVE FOR TOTALS TEST
;HERE TO PROCESS ONE INPUT REQUEST

LISTL:	CAML	I,I.NXZR	;SEE IF WE ARE DONE YET
	JRST	LISTE		;YES--CLOSE LISTING FILE
	MOVE	T1,[LISTR,,<.QPROG_6>+QO.LST]	;SET QUEUE REQUEST TO LIST
	SKIPL	S.FAST		;SEE IF /FAST
	HRRI	T1,<.QPROG_6>+QO.FST	;YES--CHANGE REQUEST CODE
	MOVEM	T1,Q.OPR(Q)	; ..
	HLLZ	T1,.FXDEV(I)	;SETUP REQUESTED QUEUE
	CAMN	T1,QUENMA	;SEE IF ALLXXX:
	MOVEI	T1,0		;YES--SET TO NULL FOR QMANGR
	MOVEM	T1,Q.DEV(Q)	; ..
	CAME	T1,ONEQUE	;OR DIFFERENT FROM LAST ONE
	SETZM	ONEQUE		;YES--INDICATE MULT QUEUES
	MOVE	T1,.FXDEV(I)	;GET DEVICE
	PUSHJ	P,CNVSTA	;CONVERT STATION TO INTERNAL FORM
	MOVEM	T1,LSTA		;SAVE FOR LISTER
	MOVE	T1,PRODEV	;GET PROCESSING DEVICE
	MOVEM	T1,Q.PDEV(Q)	;STORE IN REQUEST
	MOVEI	T1,QMLCHR	;GET LISTING ROUTINE
	MOVEM	T1,Q.MEM(Q)	;SET IN REQUEST
	HRLZI	T1,Q.EZER+1	;SETUP POINTER
	HRRI	T1,(Q)		; FOR QMANGR
	MOVEM	F,SAVEF		;SAVE FLAGS FOR LISTR
	MOVEM	I,SAVEI		;SAVE INDEX FOR LISTR
	MOVEM	Q,SAVEQ		;SAVE QUEUE POINTER FOR LISTR
	TLNE	F,L.PHYS!L.GSYS	;SEE IF PHYSICAL OR FROM SYS
	TLO	T1,(1B0)	;YES--PHYSICAL GETSEG		[1210]
	PUSHJ	P,.QUEER	;GO OFF TO QMANGR
	ADDI	I,I.LZER	;ADVANCE TO NEXT REQUEST
	JRST	LISTL		;LOOP BACK TO PROCESS

;HERE AT END OF QUEUE LISTING

LISTE:	SKIPE	S.LIST		;FAST LISTING MODE?
	SKIPN	LISPDF		; OR NO * TYPED?
	JRST	LISTE1		;YES--DO NOT INCLUDE FOOTNOTE
	MOVEI	M,[ASCIZ /* Job being output now
/]
	PUSHJ	P,LSTR		;LIST THAT MESSAGE
LISTE1:	MOVEI	M,[ASCIZ /The queues are empty
/]
	SKIPE	ONEQUE		;SEE IF ALL:
	MOVEI	M,[ASCIZ /The queue is empty
/]
	SKIPN	LSTANY		;ANYTHING IN THE QUEUES?
	JRST	[PUSHJ P,LSTR	;NO--LIST THE LINE
		 JRST  LISTEX]	; AND CLOSE THE FILE.
	SKIPN	S.LIST		;FAST MODE?
	JRST	LISTEX		;YES--ALL DONE.
	MOVEI	M,[ASCIZ /
TOTALS (includes all jobs)
/]
	SKIPE	ONEQUE		;SEE IF ALL:
	MOVEI	M,[ASCIZ /
TOTAL (includes all jobs)
/]
	PUSHJ	P,LSTR		;LIST THAT STUFF
	MOVSI	J,-NUMQS	;MAKE A AOBJN POINTER

;LOOP TO LIST TOTALS

LISTE2:	MOVE	T1,LSJOBN(J)	;GET THE NUMBER OF JOBS
	JUMPLE	T1,LISTE3	;JUMP IF QUEUE EMPTY
	MOVE	T2,QUENMT(J)	;GET THE NAME OF THE QUEUE
	PUSHJ	P,LSIXN		;LIST THE NAME
	MOVEI	C,":"		;GET A BREAK
	PUSHJ	P,LCHR		;AND LIST THAT
	PUSHJ	P,LSPC		;LIST A SPACE
	MOVE	T1,LSJOBN(J)	;GET THE NUMBER OF JOBS IN THE QUEUE
	PUSHJ	P,LDEC3		; AND TELL THE USER HOW MANY EXIST.
	MOVEI	M,[ASCIZ / job/] ;TELL THE USER THE UNITS
	PUSHJ	P,LSTR		;OF THE LAST NUMBER
	MOVEI	C,"s"		;LOAD AN S
	SOSE	LSJOBN(J)	;ONLY 1 JOB?
	PUSHJ	P,LCHR		;NO--ADD THE S
	MOVEI	M,[ASCIZ /;  /]	;SEPERATE THE TWO PARTS
	PUSHJ	P,LSTR		; ..
	MOVE	T1,LSTOTL(J)	;GET THE TOTAL UNITS
	XCT	LSTXCT(J)	;LIST IN CORRECT FORMAT
	PUSHJ	P,LSPC		;PUT IN A SPACE
	MOVE	M,LSTLIM(J)	;GET THE UNITS
	SOSN	LSTOTL(J)	;SEE IF JUST ONE
	MOVE	M,LSTLIS(J)	;YES--USE SINGLE WORD
	PUSHJ	P,LSTR		;TYPE THEM OUT
	PUSHJ	P,LCRLF		;LIST A CRLF
LISTE3:	AOBJN	J,LISTE2	;LOOP FOR ALL THAT EXIST

LISTEX:	CLOSE	LC,		;CLOSE OUTPUT
	STATZ	LC,IO.ERR	;CHECK FOR ERRORS
	PUSHJ	P,LCHRWR	;YES--GO ISSUE MESSAGE
	RELEASE	LC,		;RELEASE DEVICE
	POPJ	P,		;AND RETURN
;HERE FROM QMANGR TO LIST EACH ENTRY IN QUEUE
;MUST PRESERVE ALL ACS EXCEPT T1-4
;ENTRY IS IN Q.XXX AREA

			;SWITCH TO LOW SEGMENT
	SWSEG

LISTR:	PUSH	P,M		; ..
	PUSH	P,C		; ..
	PUSH	P,I		; ..
	PUSH	P,J		; ..
	PUSH	P,Q		; ..
	PUSH	P,F		; ..
	MOVE	I,SAVEI		;RESTORE INDEX TO INPUT REQUEST
	MOVE	Q,SAVEQ		;RESTORE POINTER TO QUEUE AREA
	MOVE	F,SAVEF		;RESTORE FLAGS

	PUSHJ	P,LISTRC	;GO SEE IF LISTABLE AND LIST IT

	POP	P,F		;RESTORE ACS
	POP	P,Q		; ..
	POP	P,J		; ..
	POP	P,I		; ..
	POP	P,C		; ..
	POP	P,M		; ..
	POPJ	P,		;RETURN TO QMANGR FOR NEXT ENTRY
;HERE FROM ABOVE WHAN ACS ARE SETUP AND PRESERVED

LISTRC:	SKIPE	T1,LSTA		;SEE IF SPECIAL QUEUE
	HRRZ	T1,Q.DEV(Q)	;YES--GET QUEUE
	CAME	T1,LSTA		; AND COMPARE FOR MATCH
	POPJ	P,		;REJECT UNSUITABLE ONES
	SETOM	LSTANY		;FLAG THE QUEUE IS NOT EMPTY
	HLRZ	T1,Q.DEV(Q)	;GET QUEUE NAME
	LSH	T1,-6		;SKIFT RIGHT 1 LETTER
	MOVSI	J,-NUMQS	;MAKE AN AOBJN POINTER
LISTRL:	CAME	T1,LSTNMS(J)	;IS THIS THE DESIRED QUEUE?
	AOBJN	J,.-1		;NO--KEEP LOOKING
	JUMPGE	J,LPOPJ		;GIVE UP IF ILLEGAL QUEUE
	HLLZ	T1,QUELNM(J)	;GET 3 CHAR NAME OF QUEUE
	HLLM	T1,Q.DEV(Q)	; AND STORE INTO REQUEST
	HRRZ	J,J		;GET RID OF -VE LEFT HALF
	HRRZ	T1,Q.ILIM(Q)	;ASSUME INP:
	SKIPE	J		;ARE WE RIGHT?
	HLRZ	T1,Q.OSIZ(Q)	;NO--GET OUTPUT LIMIT
	ADDM	T1,LSTOTL(J)	;ADD IN TO TOTAL
	AOS	LSJOBN(J)	;COUNT AS A JOB
	MOVE	T1,.FXNAM(I)	;CHECK TO SEE IF WE WANT TO LIST THIS
	XOR	T1,Q.JOB(Q)	; JOB
	MOVE	T2,.FXDIR(I)	; ..
	XOR	T2,Q.PPN(Q)	; ..
	TDNN	T1,.FXNMM(I)	; ..
	TDNE	T2,.FXDIM(I)	; ..
	POPJ	P,		;NOT A MATCH--RETURN
	SKIPLE	T1,S.SEQ	;SEE IF /SEQUENCE
	CAMN	T1,Q.SEQ(Q)	;YES--TEST THIS ENTRY
	SKIPA			;OK
	POPJ	P,		;FAIL--GIVE UP
	JUMPN	J,LISOUT	;JUMP IF OUTPUT QUEUE
;HERE TO LIST AN INPUT QUEUE ENTRY

	SKIPN	S.LIST		;FAST MODE?
	JRST	LISNIT		;YES--THEN NO TITLE
	MOVEI	M,INPTTL	;POINT TO TITLE
	SKIPN	LSITTF		;TITLE PRINTED?
	PUSHJ	P,LSTR		;NO--GO PRINT
	SETOM	LSITTF		;IT IS NOW
LISNIT:	HLLZ	T2,Q.PDEV(Q)	;GET DEVICE			[1205]
	TLNE	T2,(77B5)	;SEE IF JOB NUMBER		[1205]
	HRLZ	T2,Q.PDEV(Q)	;GET THE PTY NUMBER
	MOVEI	T3,4		;3 CHARS AND A SPACE
	SKIPN	S.LIST		;SKIP IF FAST MODE
	JRST	[MOVEI T3,7	;ELSE MAKE IT LOOK LIKE OUTPUT
		 SKIPN T2,Q.PDEV(Q) ;ANY DEVICE?
		 MOVSI T2,'INP'	;NO--USE INP:
		 JRST  .+1]	;CONTINUE
	PUSHJ	P,PRODV		;GO LIST			[1205]
	PUSHJ	P,LISTSD	;LIST THE COMMON PART
	HRRZ	T1,Q.ILIM(Q)	;GET THE RUN TIME
	PUSHJ	P,LTIME		;LIST AS HH:MM:SS
	PUSHJ	P,LSPC		;FOLLOWED BY 1 SPACE
	HLRZ	T1,Q.ILIM(Q)	;GET THE CORE
	ADDI	T1,1777		;ROUND UP
	LSH	T1,-12		;CONVERT FROM WORDS TO K
	PUSHJ	P,LDEC3		;LIST THE CORE
	PUSHJ	P,LSPC		;GIVE A SPACE
	PUSHJ	P,LISTAP	;LIST THE AFTER SWITCH
	SKIPN	S.LIST		;SKIP IF NOT FAST MODE
	PJRST	LCRLF		;FAST MODE NO SECOND LINE
	PUSHJ	P,LCRLF		;GIVE A CRLF
	HRRE	T1,Q.IDEP(Q)	;GET DEPENDENCY
	JUMPE	T1,LPOPJ	;DONE IF ZERO
	MOVEI	M,[ASCIZ /	Dep=/]
	PUSHJ	P,LSTR		;LIST THE HEADER
	PUSHJ	P,LDEC		;LIST THE DECIMAL SWITCH
	PJRST	LCRLF		;AND GIVE A CRLF
;HERE TO LIST AN OUTPUT QUEUE

LISOUT:	SKIPN	S.LIST		;SKIP IF NO FAST LIST
	JRST	LISNOT		;SLOW LIST GIVE OUTPUT TITLES
	MOVEI	M,OUTTTL	;POINT TO TITLE
	SKIPN	LSOTTF		;SKIP IF TITLE GIVEN
	PUSHJ	P,LSTR		;NO--GIVE THE TITLE
	SETOM	LSOTTF		;FLAG AS GIVEN
LISNOT:	SKIPN	T2,Q.PDEV(Q)	;SKIP IF "ON DEVICE"
	JRST	LRMTDV		;NO--LIST THE QUEUE NAME
	MOVEI	T3,6		;YES--WE WANT ALL 6 CHARS
	PUSHJ	P,PRODV		;LIST THEM			[1205]
	MOVEI	C,"*"		;GIVE A FOOTNOTE
	PUSHJ	P,LCHR		; ..
	SETOM	LISPDF		;FLAG FOOTNOTE NEEDED
LISTOS:	PUSHJ	P,LISTSD	;LIST THE STANDARD STUFF
	HLRZ	T1,Q.OSIZ(Q)	;GET THE LIMIT
	PUSHJ	P,LDEC5		;LIST IT OUT
	PUSHJ	P,LSPC2		;ADD A SPACE
	PUSHJ	P,LISTAP	;LIST THE AFTER SWITCH
	SKIPN	S.LIST		;FAST MODE?
	PJRST	LCRLF		;YES--NO SECOND LINE EVER
	PUSHJ	P,LCRLF		;LIST A CRLF
	MOVEI	T4,LPOPJ	;WHERE TO GO
	SKIPN	T2,Q.OFRM(Q)	;ANY FORMS SWITCH
	JRST	LISTNT		;NO--LOOK FOR NOTE
	MOVEI	M,[ASCIZ /	FORMS=/]
	PUSHJ	P,LSTR		;LIST HEADER
	PUSHJ	P,LSIXN		;LIST FORMS
	MOVEI	T4,LCRLF	;FLAG TO GIVE A CRLF
LISTNT:	SKIPN	T2,Q.ONOT(Q)	;ANY NOTE SWITCH?
	JRST	(T4)		;NO--DONE
	MOVEI	M,[ASCIZ /	NOTE=/]
	PUSHJ	P,LSTR		;YES--GIVE TITLE
	MOVEI	T3,6		;FORCE 6 CHARS
	PUSHJ	P,LSIXC		;AND LIST FIRST WORD
	MOVE	T2,Q.ONOT+1(Q)	;GET SECOND WORD AND LIST THAT
	PUSHJ	P,LSIXN		; ..
	PJRST	LCRLF
;SUBROUTINE TO LIST AFTER SWITCH

LISTAP:	SKIPE	T1,Q.AFTR(Q)	;ANYTHING?
	SKIPN	S.LIST		; OR SLOW MODE?
LPOPJ:	POPJ	P,		;NO--RETURN
	SUB	T1,NOW		;SEE IF IT HAPPENED YET
	JUMPLE	T1,LPOPJ	;YES--RETURN WITH NOTHING DONE
	MOVEI	C,"+"		;LIST A PLUS SIGN
	HLRZ	T2,T1		;GET NUM DAYS
	CAIGE	T2,^D100	;COMPRESS IF 3 DIGITS
	PUSHJ	P,LCHR		; SO IT LOOKS LIKE TIME FROM NOW
	TRO	F,R.NSEC	;SUPPRESS SECONDS
	PJRST	LQTIME		;AND LIST THE TIME IS QUEUE FORMAT

;ROUTINE TO LIST A DEVICE NAME

LRMTDV:	HLLZ	T2,Q.DEV(Q)	;PICK UP THE SIXBIT PART
	PUSHJ	P,LSIXN		;LIST IT.
	HRRZ	T1,Q.DEV(Q)	;PICK UP REMOTE CODE
	MOVEI	T4,LSPC4	;POINT TO AN EXIT ROUTINE
	JUMPE	T1,LRMTXT	;EXIT IF ALL DONE
	AOS	T4		;NEED 1 LESS SPACE
	CAILE	T1,77		;STATION NUMBER?
	JRST	LREMON		;NO--UNIT SPECIFIC
	MOVEI	C,"S"		;TYPE AN S FOR STATION
	PUSHJ	P,LCHR		; ..
	AOSA	T4		;ADVANCE EXIT POINTER
LREMON:	SUBI	T1,1000		;CONVERT TO UNIT NUMBER
	CAIL	T1,100		;THREE DIGITS?
	AOS	T4		;YES--NEED ONLY ONE SPACE
	CAIL	T1,10		;TWO OR THREE DIGITS?
	AOS	T4		;YES--NEED ONE LESS SPACE
	PUSHJ	P,LOCT		;LIST
LRMTXT:	PUSHJ	P,(T4)		;PAD AS NEEDED
	JRST	LISTOS		;LIST THE REST OF THE OUTPUT REQUEST.
;SUBROUTINE TO LIST THE STANDARD PART

LISTSD:	HLRZ	T1,Q.PPN(Q)	;GET PROJECT NUMBER
	PUSHJ	P,LOCT6		;LIST PROJECT
	MOVEI	C,","		;SET UP A COMMA
	PUSHJ	P,LCHR		; AND LIST IT
	HRRZ	T1,Q.PPN(Q)	;GET PROG NUMBER
	PUSHJ	P,LOCT6L	;LIST AS 6 CHARS LEFT JUSTIFIED
	MOVEI	T3,6		;SIX FULL CHARS
	PUSHJ	P,LOUTS		;LIST 2 SPACES
	MOVE	T2,Q.JOB(Q)	;GET JOB NAME
	PUSHJ	P,LSIXC		;LIST A SIX SIXBIT LETTERS
	PUSHJ	P,LSPC		;GIVE A SPACE
	MOVE	T1,Q.SEQ(Q)	;GET THE SEQ. #
	PUSHJ	P,LDEC5		;LIST IN 5 CHARS
	PUSHJ	P,LOUTS		;GIVE 2 SPCAES
	MOVE	T1,Q.PRI(Q)	;GET PRIO WORD
	ANDI	T1,77B35	;MASK OUT JUNK
	PUSHJ	P,LDEC2		;LIST AS 2 DIGITS
	SKIPN	S.LIST		;SKIP IF SLOW MODE
	PJRST	LOUTS		;ELSE NO NAME
	PUSHJ	P,LOUTS		;LIST AS 2 SPACES
	MOVEI	T3,6		;PRINT ALL 6 CHARS OF
	MOVE	T2,Q.USER(Q)	; FIRST NAME
	PUSHJ	P,LSIXC		; ..
	MOVEI	T3,6		;DITTO ON SECOND NAME
	MOVE	T2,Q.USER+1(Q)	; ..
	PUSHJ	P,LSIXC		; ..
;LIST 1 SPACE IF INPUT, 2 IF OUTPUT
LOUTS:	PJUMPN	J,LSPC2		;TWO IF OUTPUT
	PJRST	LSPC		;LIST A SPACE AND RETURN
;LIST DEVICE OR JOB SIGNED OUT					[1205]
;CALL:	MOVE	T2,SIXBIT DEVICE OR JOB,,XXX
;	MOVEI	T3,WIDTH OF FIELD
;	PUSHJ	P,PRODV
;USES T1-4

PRODV:	SKIPE	T2		;SEE IF BLANK			[1212]
	TLNE	T2,(77B5)	;NO--SEE IF JOB NUMBER
	PJRST	LSIXC		;NO--LIST SIXBIT
	HLRZ	T1,T2		;YES--GET NUMBER
	IDIVI	T1,^D100	;GET HUNDREDS
	PUSH	P,T1		;SAVE THAT
	MOVE	T1,T2		;GET REST
	IDIVI	T1,^D10		;GET TENS
	ADDI	T2,'0'	;CONVERT UNITS TO SIXBIT
	LSH	T1,6		;POSITION
	SKIPN	(P)		;SEE IF ANY HUNDREDS
	SKIPE	T1		;OR TENS
	ADDI	T1,'0 '		;YES--CONVERT TENS TO SIXBIT
	IOR	T2,T1		;COMBINE
	POP	P,T1		;RECOVER HUNDREDS
	LSH	T1,^D12		;POSITION HUNDREDS
	SKIPE	T1		;SEE IF ANY HUNDREDS
	ADDI	T1,'0  '	;YES--CONVERT TO SIXBIT
	IOR	T2,T1		;COMBINE
	TLO	T2,'OB'	;INCLUDE SOME OF PREFIX
	CAIGE	T3,6		;SEE IF 6 CHARS
	LSH	T2,^D12		;NO--SHIFT OVER
	TLO	T2,'J  '	;INCLUDE J PREFIX
	PJRST	LSIXC		;GO PRINT
;TITLE LINES

INPTTL:	ASCIZ	/INPUT QUEUE:
PTY      PPN       JOB    SEQ PRIO    NAME       TIME  CORE   AFTER
/

OUTTTL:	ASCIZ	/
OUTPUT QUEUES:
 DEV        PPN        JOB    SEQ  PRIO     NAME      LIMIT   AFTER
/
;TABLE OF 2 CHAR QUEUE NAMES RIGHT ADJUSTED

	DEFINE	X(A)<
	IRP	(A),<
	NUMQS==NUMQS+1		;;NUMQS IS TOTAL NUMBER OF QUEUES
	...TEM==SIXBIT	+A+
	...TEM==...TEM_<-^D24>
	EXP	...TEM
>>
	NUMQS==0
LSTNMS:	QUEUES



;TEMPS USED BY LISTER

LSTZER:!
LSJOBN:	BLOCK	NUMQS		;NUMBER OF JOBS IN EACH QUEUE
LSTOTL:	BLOCK	NUMQS		;TOTAL LIMIT FOR EACH QUEUE
LSOTTF:	BLOCK	1		;-1 IF OUTPUT TITFE PRINTED ELSE 0
LSITTF:	BLOCK	1		;-1 IF INPUT TITLE PRINTED ELSE 0
LISPDF:	BLOCK	1		;-1 IF A REQUEST WAS FOUND INTERLOCKED
				; IN AN OUTPUT QUEUE
LSTANY:	BLOCK	1		;-1 IF SOMETHING TYPED ELSE 0
LSTEZR:!
			;SWITCH TO HIGH SEG
	SWSEG


;ERRORS

E.OOF:	MOVE	N,O.DEV		;GET DEVICE NAME
	N.FAIN	<Listing open failure on device>
E.OEFU:	MOVEI	T2,ERIPP%	;SET PROTECTION ERROR
E.OEF:	HRRM	T2,L.LOOK+.RBEXT  ;SET ERROR IN BLOCK
E.OEFE:	CLOSE	LC,CL.RST!CL.ACS!CL.DLL   ;RESET ENTER
	RELEAS	LC,		;CLEAR CHANNEL
	MOVEI	T1,L.LOOK	;POINT TO LOOKUP BLOCK
	MOVEI	T2,5		;GIVE LENGTH
	MOVEI	T3,O.ZER	;POINT TO SCAN BLOCK
	PUSHJ	P,E.LKEN##	;ISSUE ERROR MESSAGE
	PJRST	FMSGE		;GO ABORT JOB

;ROUTINES TO OUTPUT LIMIT

	DEFINE	X(A)<
	IRP	(A),<
IFIDN	<INP><A><PUSHJ P,LTIME>
IFIDN	<LPT><A><PUSHJ P,LDEC>
IFIDN	<PTP><A><PUSHJ P,LDEC>
IFIDN	<CDP><A><PUSHJ P,LDEC>
IFIDN	<PLT><A><PUSHJ P,LTIMEM>
>>
LSTXCT:	QUEUES
;PLURAL UNITS OF LIMIT

	DEFINE	X(A)<
	IRP	(A),<
IFIDN	<A><INP><[ASCIZ /sec. run time/]>
IFIDN	<A><LPT><[ASCIZ /pages/]>
IFIDN	<A><PTP><[ASCIZ /feet/]>
IFIDN	<A><CDP><[ASCIZ /cards/]>
IFIDN	<A><PLT><[ASCIZ /min. ploting time/]>
>>
LSTLIM:	QUEUES

;SINGLE UNITS OF LIMIT

	DEFINE	X(A)<
	IRP	(A),<
IFIDN	<A><INP><[ASCIZ /sec. run time/]>
IFIDN	<A><LPT><[ASCIZ /page/]>
IFIDN	<A><PTP><[ASCIZ /foot/]>
IFIDN	<A><CDP><[ASCIZ /card/]>
IFIDN	<A><PLT><[ASCIZ /min. ploting time/]>
>>
LSTLIS:	QUEUES
			;SWITCH TO LOW SEG
	SWSEG
SUBTTL	CONTROL-C INTERCEPT

;HERE FROM MONITOR WHEN A CONTROL-C IS TYPED

INTRPT:	PUSH	P,INTBLK+2	;SAVE PC ON STACK
	MONRT.			;TYPE A .

;FALL INTO SETINT

;SUBROUTINE TO SET UP FOR CONTROL-C INTERCEPT
;CALL WITH:
;	PUSHJ	P,SETINT
;	RETURN HERE
;THIS ROUTINE CAN USE NO AC'S SINCE IT IS AN INTERUPT ROUTINE ALSO
;
SETINT:	PUSH	P,T1		;SAVE T1
	MOVEI	T1,INTBLK-1	;POINT TO INTBLK
	PUSH	T1,[4,,INTRPT]	;POINTER TO INTERUPT CODE
	HRRM	T1,.JBINT##	;POINTER TO POINTER
	PUSH	T1,[ER.ICC]	;CLASS OF ERRORS
	SETZM	INTBLK+2	;CLEAR PC
	SETZM	INTBLK+3	;CLEAR BITS
	POP	P,T1		;RESTORE T1
	POPJ	P,		;RETURN

			;SWITCH TO HIGH SEG
	SWSEG
	SUBTTL	COMMAND PROCESSING -- CREATE

;HERE TO CREATE A QUEUE ENTRY
MODIFY:				;MODIFY EXISTING OR FUTURE ENTRY
KILL:	SETOM	CREFLG		;KILL OFF EXISTING ENTRY
CREATE:	ADDI	I,.QPROG_6	;SET QUEUE'S CODE NUMBER INTO REQUEST
	MOVEM	I,Q.OPR(Q)	;STORE REQUEST CODE
	MOVNI	T1,I.LZER	;COMPUTE START
	ADD	T1,I.NXZR	; OF LAST SPEC
	MOVEM	T1,I.LSZR	; FOR WILD
	MOVE	T1,O.DEV	;DESTINATION DEVICE IS OUTPUT PARAMETER
	MOVEM	T1,Q.DEV(Q)	;STORE IT
	MOVE	T3,O.DIR	;GET SPECIFIED PPN
	MOVEM	T3,Q.PPN(Q)	;STORE INTO REQUEST
	SKIPN	CREFLG		;IS THIS MODIFY OR KILL?
	CAMN	T3,MYPPN	;SEE IF FOR THIS USER
	JRST	CREAT1		;YES--PROCEED
	MOVE	T2,[.ACWRI,,055]	;NO--FAKE UP A CHECK ON ACCESS
	MOVE	T4,MYPPN	; TO SEE IF THIS USER HAS
	MOVEI	T1,T2		; FULL FILE ACCESS
	CHKACC	T1,		;(CAN WRITE EVEN IF LOCKED OUT)
	  JRST	CREOTH		;OLD MONITOR--TRY OTHER TEST
	JUMPL	T1,E.ILD	;FAILED--BOMB OUT
	JRST	CREAT1		;OK--PROCEED BELOW
CREOTH:	MOVX	T1,%LDFFA	;SEE IF FULL FILE ACCESS
	GETTAB	T1,		;FROM MONITOR
	  MOVE	T1,[1,,2]	; (FOR LEV C)
	SKIPE	CREFLG		;SEE IF CREATE
	JRST	CREAT1		;NO--QMANGR WILL CHECK FOR US
	CAME	T1,MYPPN	;SEE IF THIS GUY HAS ACCESSES
	JRST	E.ILD		;NO--BOMB
CREAT1:	SKIPE	T1,O.NAM	;GET PROPOSED JOB NAME
	MOVEM	T1,Q.JOB(Q)	;STORE IT
	MOVE	T1,S.SEQ	;GET SEQUENCE NUMBER
	MOVEM	T1,Q.SEQ(Q)	;PLACE INTO REQUEST
	LDB	T1,[POINTR (O.MOD,FX.PRO)]  ;GET USER SPECIFIED PROTECTION
	SKIPN	T1
	MOVE	T1,DEFPRT	;NONE--USE SYSTEM STANDARD FILE PROTECTION
	LSH	T1,^D9		;POSITION
	MOVE	T2,S.PRI	;GET EXTERNAL PRIORITY
	ANDI	T2,77		;MASK TO FIT
	IOR	T1,T2		;COMBINE RESULTS
	MOVEM	T1,Q.PRI(Q)	;STORE
	SKIPN	CREFLG		;SEE IF /CREATE
	JRST	CREAT2		;YES--SKIP WILD CARDS
	MOVE	T1,O.DIRM	;GET DIRECTORY WILDCARD
	MOVEM	T1,Q.TIME(Q)	;STORE FOR QMANGR
	MOVE	T1,O.NAMM	;GET JOB NAME WILDCARD
	MOVEM	T1,Q.CREA(Q)	;STORE
CREAT2:	MOVE	T1,S.AFT	;GET AFTER SWITCH
	MOVEM	T1,Q.AFTR(Q)	;STORE IN REQUEST
	MOVE	T1,S.DED	;GET DEADLINE SWITCH
	MOVEM	T1,Q.DEAD(Q)	;STORE IN REQUEST
	SKIPE	T1,S.CNO	;MOVE CHARGE NUMBER
	JRST	CRECNO		;JUMP IF DEFINED
	HRROI	T1,.GTCNO	;IF NONE--GET FROM MONITOR
	GETTAB	T1,		; ..
	  MOVEI	T1,0		;IF NONE THERE--GIVE UP
CRECNO:	MOVEM	T1,Q.CNO(Q)	;TO REQUEST
	MOVE	T1,Q.PPN(Q)	;SEE IF REQUEST IS FOR ME
	CAME	T1,MYPPN	; ..
	JRST	CREUSR		;NO--LEAVE USER NAME BLANK
	HRROI	T1,.GTNM1	;GET USER'S NAME FROM MONITOR
	GETTAB	T1,		; ..
	  MOVEI	T1,0		; ..
	MOVEM	T1,Q.USER(Q)	; ..
	HRROI	T1,.GTNM2	; .. SECOND HALF
	GETTAB	T1,		; ..
	  MOVEI	T1,0		; ..
	MOVEM	T1,Q.USER+1(Q)	; ..

CREUSR:	HLRZ	T1,Q.DEV(Q)	;SEE WHICH QUEUE WAS REQUESTED
	CAIN	T1,'INP'	;WAS IT INPUT?
	JRST	CREI		;YES--GO PROCESS IT

	MOVE	T1,S.FRM	;GET SPECIAL FORMS REQUEST
	MOVEM	T1,Q.OFRM(Q)	;STORE INTO OUTPUT HEADER
	SETZB	T1,LOGCNT	;SET LOG FILE COUNTER SO NEVER FOUND
	HRROM	T1,Q.OSIZ(Q)	;CLEAR SIZE OF REQUEST, NO LIMIT YET
	HRLZI	T1,S.NOT	;TRANSFER
	HRRI	T1,Q.ONOT(Q)	;  ANNOTATION
	BLT	T1,Q.ONOT+1(Q)	;TO REQUEST
	MOVEI	J,Q.FF(Q)	;J=START OF OUTPUT QUEUE REQUEST AREA
	TRNE	F,R.NEWF	;NEW FORMAT QUEUE ENTRY?
	SKIPA	T1,[BYTE (9)Q.FF-Q.ZER-1,Q.FRPL(18)0] ;YES--BIGGER LENGTH
	MOVSI	T1,(BYTE (9)Q.FF-Q.ZER-1,Q.FLEN(18)0)
	JRST	CREOLP		;GO LOOP OVER REQUEST
;HERE TO SETUP INP REQUEST

CREI:	HRRZ	T1,S.DPN	;GET DEPENDENCY REQUEST
	SKIPN	CREFLG		;SEE IF /MOD OR /KILL
	TRZ	T1,3B19		;NO--CLEAR +- FLAGS
	SKIPN	S.RSTR		;SEE IF /REST:1
	TLO	T1,(1B0)	;YES--SET /REST:1
	SKIPE	CREFLG		;SEE IF /MOD
	SKIPGE	S.RSTR		;YES--SEE IF /REST
	JRST	.+2		;NO--PROCEED
	TLO	T1,(1B3)	;YES--SET CHANGE FLAG
	MOVE	T2,S.UNIQ	;GET UNIQUENESS
	ADDI	T2,1		;SET TO INTERNAL VALUE
	DPB	T2,[POINT 2,T1,2]  ;STORE IN REQUEST
	MOVE	T2,S.OUT	;GET OUTPUT QUEUEING
	DPB	T2,[POINT 3,T1,8]  ;STORE
	MOVEM	T1,Q.IDEP(Q)	;STORE INTO QUEUE REQUEST
	MOVSI	T3,-.FXLND	;SET FOR FULL LOOP COUNT
	HRRI	T3,(Q)		;POINT TO REQUEST
	MOVEI	T2,0		;INITIALIZE FETCH POINTER
CREIDD:	SKIPE	T1,DEFDIR(T2)	;GET /PATH:
	ADDI	T2,2		;ADVANCE FETCH UNLESS AT END
	MOVEM	T1,Q.IDDI(T3)	;STORE IN REQUEST
	AOBJN	T3,CREIDD	;LOOP UNTIL DONE
	HRLZ	T1,S.COR	;FETCH CORE LIMIT
	HRR	T1,S.LTIM	;FETCH CPU TIME LIMIT
	MOVEM	T1,Q.ILIM(Q)	;STORE
	HLRZ	T1,T1		;GET /CORE VALUE
	MOVX	T2,%NSCMX	;GET SYSTEM
	CAIE	T1,-1		;UNLESS NO CHANGE
	GETTAB	T2,		;  CORMAX
	  JRST	CREI1		;(GIVE UP)
	CAMG	T1,T2		;SEE IF /CORE IS .GT.
	JRST	CREI1		;NO--PROCEED
	PUSH	P,T2		;SAVE CORMAX
	PUSH	P,T1		;SAVE ARGUMENT
	MOVEI	T1,[ASCIZ /% Core limit of /]
	PUSHJ	P,.TSTRG	;WARN USER
	POP	P,T1		;GET LIMIT BACK
	PUSHJ	P,.TDECW	;TYPE IT
	MOVEI	T1,[ASCIZ / is greater than cormax of /]
	PUSHJ	P,.TSTRG	;MORE MESSAGE
	POP	P,T1		;RESTORE CORMAX
	PUSHJ	P,.TDECW	;TYPE IT
	PUSHJ	P,.TCRLF	;TYPE A CRLF
CREI1:	HRLZ	T1,S.LLPT	;FETCH PAGE LIMIT
	HRR	T1,S.LCDP	;FETCH CARD PUNCH LIMIT
	MOVEM	T1,Q.ILIM+1(Q)	;STORE
	HRLZ	T1,S.LPTP	;FETCH PAPER TAPE LIMIT
	HRR	T1,S.LPLT	;FETCH PLOT LIMIT
	MOVEM	T1,Q.ILIM+2(Q)	;STORE
	MOVEI	T1,2		;SET LOG FILE COUNTER
	MOVEM	T1,LOGCNT	; TO MATCH ON SECOND REQUEST
	MOVEI	J,Q.II(Q)	;J=START OF INPUT FILE AREA
	MOVSI	T1,(BYTE (9)Q.II-Q.ZER-1,Q.FLEN(18)0)
	TRNE	F,R.NEWF	;NEW FORMAT?
	MOVSI	T1,(BYTE (9)Q.II-Q.ZER-1,Q.FRPL(18)0)
;HERE TO LOOP OVER EACH FILE TO BE QUEUEED AND PREPARE IT

CREOLP:	MOVEI	T2,Q.FLNM	;GET MODIFY PER FILE LENGTH
	SKIPE	CREFLG		;SEE IF CREATE
	DPB	T2,[POINT 9,T1,17]  ;NO--CHANGE LENGTH
	MOVEM	T1,Q.LEN(Q)	;SET PREFIX OF LENGTHS
	MOVEM	J,.JBFF		;RESET .JBFF TO START OF FILE AREA
	SUBI	J,Q.FLEN	;BACK UP TO START RIGHT
	SKIPE	CREFLG		;SEE IF /CREATE
	SUBI	J,Q.FLNM-Q.FLEN  ;NO--BACK UP POINTER SOME MORE
	TRNE	F,R.NEWF	;NEW FORMAT?
	SUBI	J,Q.FRPL-Q.FLEN	;YES--BACK UP EVEN MORE
	MOVEI	I,0		;I=START OF NEXT REQUEST AREA
CREOFL:	MOVEI	T1,Q.FLEN	;GET CREATE PER FILE LENGTH
	TRNE	F,R.NEWF	;NEW FORMAT
	MOVEI	T1,Q.FRPL	;YES--USE NEW LENGTH
	SKIPE	CREFLG		;SEE IF CREATE
	MOVEI	T1,Q.FLNM	;NO--GET MODIFY PER FILE LENGTH
	ADD	J,T1		;ADVANCE POINTER
	PUSHJ	P,GCORE.	;GET ENOUGH CORE
	SOS	LOGCNT		;ADVANCE LOG FILE COUNTER
CREOFR:	SETZM	(J)		;CLEAR NEW AREA
	HRLZI	T1,(J)		; ..
	HRRI	T1,1(J)		; ..
	TRNN	F,R.NEWF	; ..
	BLT	T1,Q.FLEN(J)	; ..
	TRNE	F,R.NEWF	;NEW FORMAT?
	BLT	T1,Q.FRPL(J)	;YES--CLEAR WHOLE THING
	SKIPE	CREFLG		;SEE IF /CREATE
	JRST	CREOMD		;NO--GO BELOW FOR REST OF /MODIFY
	PUSHJ	P,LOOKFL	;LOOK FOR NEXT FILE
	  JRST	CREODN		;IF NO MORE FILES
	JUMPN	T4,CREONS	;IF /NEW, NO RENAME LOGIC, ETC.
	HLRZ	T1,RIBEXT	;SEE IF
	CAIE	T1,'UFD'	; DIRECTORY
	CAIN	T1,'SFD'	; ..
	SKIPA			;YES
	JRST	CREOND		;NO--PROCEED
	MOVX	T1,<DISPPRESERVE_<^D35-POS(X.DISP)>>
	MOVX	T2,-1-X.DISP	;YES--FORCE /DISP:PRES
	JRST	CRELOG		; REGARDLESS OF USER
CREOND:	PUSHJ	P,ISLOG		;SEE IF LOG FILE
	  JRST	CREOUT		;NO--GO SEE IF OUTPUT SPOOL FILE
	MOVE	T1,INDADL	;YES--GET FORCED SWITCHES
	MOVEI	T2,X.DISP	;SET TO ACCEPT DISPOSITION
	JRST	CRELOG		;AND GO DEPOSIT THEM
CREOUT:	PUSHJ	P,ISOUT		;SEE IF OUTPUT SPOOLING
	  JRST	CREONS		;NO--PROCEED BELOW
	  JRST	CREOFR		;PROTECTED OUTPUT--IGNORE IT
	MOVE	T1,INDADO	;YES--GET FORCED SWITCHES
	MOVE	T2,I.MODM(I)	;GET USER'S MASK
	ANDX	T2,X.SPAC!X.COP!X.PAPR!X.DISP!X.NOHD  ;TRUNCATE TO /SPAC/COP/PAP/DI	[1203]
	TDZ	T1,T2		;CLEAR JUNK FROM FORCED SWITCHES
CRELOG:	AND	T2,Q.FMOD(J)	;GET USER'S SWITCHES AS ALLOWED
	IOR	T1,T2		;AND INCLUDE USER STUFF
	MOVEM	T1,Q.FMOD(J)	; ..
	MOVEI	T1,1		;SET TO START AT BEGINNING
	MOVEM	T1,Q.FBIT(J)	; ..
	PUSHJ	P,ISLOG		;SEE IF LOG FILE
	  SKIPA			;NO--MUST BE OUTPUT
	JRST	CREONS		;YES--FINISH UP
	MOVSI	T2,(6B2)	;SET UP MASKS
	MOVSI	T1,(1B2)	; ..
	IORM	T1,RIBPRV	;PRESERVE FILE
	TDNN	T2,RIBPRV	;SKIP IF PROT .GE. 1XX
	RENAME	DC,LKBLK	;PRESERVE FOR GROSS
	  JFCL
	SKIPN	T1,Q.JOB(Q)	;SEE IF JOB HAS A NAME
	SKIPE	T1,RIBSPL	;NO--GET SPOOLED NAME IF ANY
	CAIE	J,Q.FF(Q)	;SEE IF FIRST FILE
	JRST	.+2		;NO--SKIP
	MOVEM	T1,Q.JOB(Q)	;YES--SET NAME AS JOB NAME
	MOVEI	T1,K.DSTY	;SEE IF DESTROY MODE
	TLNE	F,L.KONC	;CALL FROM KJOB
	TDNN	T1,KJBAEX	; ..
	JRST	CREONS		;NO--GO GIVE AWAY FILE
	SETZB	T1,T2		;READY TO DELETE
	SETZB	T3,T4		; ..
	MOVEI	T1,[ASCIZ /
% Could not delete spooled output file
/]
	RENAME	DC,T2		;DELETE IT
	  PUSHJ	P,.TSTRG	;WARN USER
	JRST	CREOFR		;BACK AROUND LOOP

;HERE ON /MODIFY SWITCH

CREOMD:	BLT	T1,Q.FLNM(J)	;CLEAR REST OF AREA
	PUSHJ	P,GETMOD	;GET MODIFY REQUEST PARAMETERS
	  JRST	CREODN		;ALL DONE
	JRST	CREONT

CREONS:	CLOSE	DC,CL.NMB	;KEEP ACCESS TABLE IN CORE
CREONT:	AOS	Q.LEN(Q)	;COUNT OUTPUT FILE
	JRST	CREOFL		;LOOP BACK FOR NEXT FILE
CREODN:	PUSHJ	P,QUETYP	;IDENTIFY QUEUE TYPE
	MOVE	I,T1		;SAVE FOR EASE OF TESTS
	JUMPE	I,CREOGI	;IF INPUT, SKIP SIZE STORE
	SKIPL	T1,S.LIM	;GET OUTPUT LIMIT
	JRST	CRELIM		;PROCEED IF OK
	SETOM	Q.OSIZ(Q)	;DEFAULT SIZE FOR QMANGR
	SKIPE	CREFLG		;SEE IF MODIFYING
	JRST	CRESIZ		;YES--DON'T PLAY AROUND
	MOVNS	T1		;IF NEGATIVE, MULT BY FILE SIZE
	IMUL	T1,NOBLKS	;AS A BEST GUESS
	SUBI	T1,1		;DROP BY ONE			[1201]
	IDIV	T1,QLIMVF(I)	;DIVDE BY DIVSOR		[1201]
	ADDI	T1,1		;ROUND UP			[1201]
	ADD	T1,QLIMOF(I)	;ADD IN OFFSET
CRELIM:	CAILE	T1,777776	;CHECK TO LARGE
	MOVEI	T1,777776	;FORCE OK
	HRLOM	T1,Q.OSIZ(Q)	;SAVE FOR SCHEDULING
CRESIZ:	SKIPE	CREFLG		;SEE IF /CREATE
	JRST	CREOGG		;NO--GO ON
	RELEAS	DC,		;CLEAR DATA CHANNEL
	MOVE	T2,NOBLKS	;GET COUNT OF BLOCKS QUEUED
	ADDI	T2,7		;ROUND UP
	ASH	T2,-3		;CONVERT TO UNITS OF 8
	CAILE	T2,777777	;HANDLE OVERFLOW
	MOVEI	T2,777777	;YES--MAKE MAXIMUM
	HRRM	T2,Q.OSIZ(Q)	;REMEMBER FOR SCHEDULING
	JRST	CREOGO		;GO CONTINUE OUTPUT
CREOGI:	SKIPE	CREFLG		;SEE IF /CREATE
	JRST	CREOGG		;NO--PROCEED
	TRNE	F,R.NEWF	;NEW FORMAT?
	SKIPA	T2,[Q.FSTR-Q.FRPL] ;YES--POINT BACK TO STR NAME
	HRROI	T2,Q.FSTR-Q.FLEN	;NO--USE A DIFFERENT DISTANCE
	ADDI	T2,(J)		;FIX T2 TO POINT TO STR OF LOG
	SKIPE	T1,(T2)		;SEE IF LOG FILE EXISTS YET
	CAMN	T1,[SIXBIT /DSK/]  ;  IE, IS STRUCTURE KNOWN
	MOVE	T1,Q.FSTR+Q.II(Q)  ;NO--USE CTL FILE STRUCTURE
	MOVEM	T1,(T2)		;STORE CONCLUSION
	MOVSI	T1,Q.FSTR-Q.FEXT-1  ;CHECK CTL VS. LOG FOR DISTINCT
	HRRI	T1,Q.FSTR+Q.II(Q)  ; ..
	MOVEI	T2,Q.FLEN(T1)	; ..
	TRNE	F,R.NEWF	;NEW FORMAT
	ADDI	T2,Q.FRPL-Q.FLEN;YES--BUMP POINTER
CREOGJ:	MOVE	T3,(T2)		;GET LOG
	AOS	T2		;ADVANCE LOG POINTER
	CAMN	T3,(T1)		;COMPARE WITH CTL
	AOBJN	T1,CREOGJ	;MATCH--KEEP IT UP
	JUMPL	T1,CREOGO	;DONE--PROCEED IF DISTINCT
	N.FAIL	<Control and log files must be distinct>

CREOGO:	TRNN	F,R.ISLG	;SEE IF LOG FILE IN THIS REQUEST
	JRST	CREOGG		;NO--GO HANDLE
	HRRZ	T1,KJBVEX	;YES--GET FLAGS
	HRLM	T1,Q.OPR(Q)	;PLACE IN REQUEST
	MOVE	T1,JOBN		;GET JOB NUMBER
	MOVE	T2,MYPPN	;GET MY PPN
	HLRZ	T3,T2		;FOLD
	ADDI	T3,(T2)		;  PROJECT
	TLNE	T3,-1		;  AND PROGRAMMER
	AOS	T3		;  TOGETHER
	HRL	T3,T1		;INCLUDE JOB NUMBER
	MOVEM	T3,Q.PDEV(Q)	;STORE IN REQUEST
				;THIS SAVES REQUEST UNTIL KJOB DONE
CREOGG:	HRRZ	T4,Q.LEN(Q)	;GET NUMBER OF FILES
	SKIPE	CREFLG		;SEE IF /CREATE
	JRST	CREOGH		;NO--JUST GO OUTPUT REQUEST
	JUMPE	T4,E.NFLS	;YES--ERROR IF NO FILES
	PUSH	P,T4		;SAVE T4
	PUSHJ	P,QUETYP	;SOME--SEE IF INPUT QUEUE
	POP	P,T4		;GET T4 BACK
	CAIE	T4,2		;SEE IF EXACTLY TWO FILES
	JUMPE	T1,E.NTIN	;NO--IF INPUT QUEUE, BOMB
	LDB	T1,[POINT 9,Q.LEN(Q),8]  ;GET HEADER LENGTH
	ADDI	T1,(Q)		;GET ADDRESS OF FIRST FILE
	MOVE	T1,Q.FNAM+1(T1)	;GET FIRST FILE NAME
	SKIPN	Q.JOB(Q)	;SEE IF JOB HAS A NAME YET
	MOVEM	T1,Q.JOB(Q)	;NO--GIVE IT THE FIRST FILE NAME

CREOGH:	MOVE	T1,KJBTYP	;GET ADDRESS OF TYPEOUT ROUTINE
	MOVEM	T1,Q.MEM(Q)	;STORE FOR QMANGR
	MOVEI	T1,.QVERS	;STORE VERSION NUMBER OF QUEUE
	DPB	T1,[POINT 6,Q.OPR(Q),23] ; REQUEST IN THE REQUEST.
	HRRZ	T1,J		;SET POINTER FOR QMANGR
	SUBI	T1,(Q)		; ..
	HRLZI	T1,1(T1)	; ..
	HRRI	T1,(Q)		; ..
	TLNE	F,L.PHYS!L.GSYS	;SEE IF FORCED PHYSICAL OR FROM SYS	[1210]
	TLO	T1,(1B0)	;YES--SET FLAG FOR QUEUER
	PUSHJ	P,.QUEER	;GO CREATE REQUEST
	PUSHJ	P,PRTBLK	;PRINT BLOCKS
	TRZN	F,R.ISLG	;SEE IF LOG FILE IN THIS REQUEST
	POPJ	P,		;NO--RETURN
	MOVE	T1,Q.OPR(Q)	;YES--GET QUEUE FILE NAME
	MOVEM	T1,KJBVQU	;SAVE AWAY FOR KJOB
	POPJ	P,		;AND RETURN
	SUBTTL	COMMAND PROCESSING -- SUBROUTINES

;ISLOG -- SUBROUTINE TO DETERMINE IF CURRENT FILE IS THE LOG FILE
;CALL:	SETUP Q.FXXX(J)
;	SETUP KJBADV
;	PUSHJ	P,ISLOG
;RETURN .POPJ IF NOT THE LOG FILE
;SKIP RETURN IF IT IS
;USES T1, T2, T3

ISLOG:	MOVEI	T1,K.SLOG	;SEE IF LOG FILE BEING SUPPRESSED
	TDNN	T1,KJBAEX	; ..
	TLNN	F,L.KJOB	;SEE IF KJOB CALL
	POPJ	P,		;NOT LOG FILE WITH KJOB CALL

	MOVE	T3,KJBAEX	;TRY EXTENSION
	XOR	T3,Q.FEXT(J)	;COMPARE WITH THIS ONE
	TLNE	F,L.LEVD	;IF LEVEL C GIVE UP
	TLNE	T3,-1		;TEST JUST LH
	POPJ	P,		;NO MATCH
	MOVEI	T1,KJBAEX-KJBADV  ;PRESET LOOP
	MOVEI	T2,KJBAEX-KJBADV(J)  ; ..
ISLOGL:	MOVE	T3,KJBADV-1(T1)	;GET ARGUMENT WORD
	CAME	T3,Q.FSTR-1(T2)	;COMPARE WITH THIS FILE
	POPJ	P,		;NOT THE SAME--RETURN
	SOS	T2		;ANDVANCE INDEX
	SOJG	T1,ISLOGL	;LOOP BACK FOR MORE

	TRNE	F,R.ISLG	;FOUND IT THIS TIME YET?
	JRST	.POPJ1		;YES--FIND IT AGAIN
	MOVEI	T1,K.FLOG	;MATCH--GET READY
	TDNE	T1,KJBVEX	;SEE IF ALREADY FOUND ONCE
	POPJ	P,		;YES--FORGET THIS ONE
	IORM	T1,KJBVEX	;OK--FLAG FOR KJOB
	TRO	F,R.ISLG	;FLAG TO REMEMBER REQUEST
	JRST	.POPJ1		;RETURN A WINNER
;ISOUT -- SEE IF FILE IS AN OUTPUT SPOOLING FILE
;CALL:	SETUP LOOKUP BLOCK
;	PUSHJ	P,ISOUT
;RETURN .POPJ IF NOT
;SKIP RETURN IF SO BUT PROTECTED AT KJOB CALL
;DOUBLE SKIP RETURN IF SO AND NOT PROTECTED
;USES T1, T2

ISOUT:	MOVE	T1,Q.FDIR(J)	;GET DIRECTORY
	TLNE	F,L.LEVD	;SEE IF LEVEL D
	CAME	T1,Q.PPN(Q)	;SEE IF ME
	  POPJ	P,		;NO--THEREFORE NOT SPOOLED
	HLLZ	T1,RIBEXT	;YES--GET EXTENSION

;ISOUTE -- SEE IF EXTENSION IS A SPOOLED EXTENSION
;CALL:	MOVE	T1,EXTENSION
;RETURN .POPJ IF NOT SPOOLED
;SKIP OR DOUBLE SKIP RETURN IF SPOOLED
;USES T1, T2

ISOUTE:	MOVEI	T2,0		;PRESET LOOP
ISOUTL:	AOS	T2		;ADVANCE TO NEXT FILE
	CAIL	T2,QUENML	;SEE IF AT END
	POPJ	P,		;YES--NOT SPOOLED FILE
	CAME	T1,QUENMT(T2)	;COMPARE EXTENSIONS
	JRST	ISOUTL		;NO--LOOP BACK
	MOVE	T1,RIBPRV	;YES--GET FILE'S PROTECTION
	TLNE	F,L.KONC	;IS IT AUTOMATIC KJOB CALL?
	TLNN	T1,(7B2)	;YES--IS IT PRESERVED?
.POPJ2:	AOS	(P)		;NO--GIVE DOUBLE SKIP
	JRST	.POPJ1		;SKIP RETURN



;ERRORS

E.ILD:	N.FAIL	<Illegal to create request for someone else>
E.NFLS:	SKIPLE	S.NULL		;NO FILES--SEE IF MESSAGE SUPPRESSED
	POPJ	P,		;YES--JUST RETURN
	N.FAIL	<No files in request>
E.NTIN:	N.FAIL	<Incorrect number of files in input queue request>
;LOOKFL -- ROUTINE TO DO A WILD-CARD LOOKUP
;ENTERRED WITH Q.FXXX ZEROED, INTIALLY WITH NOFILF, ETC. ZEROED.
;CALL:(	MOVEI	I,0	INITIALLY)
;	MOVEI	J,ADDR. OF NEXT RESULT BLOCK
;	PUSHJ	P,LOOKFL
;	  ERROR RETURN IF NO MORE (MESSAGE ISSUED IF APPROPRIATE)
;	SKIP RETURN IF FILE FOUND--4-WORD LOOKUP DONE TO T1-4
;	I WILL BE UPDATED IF NECESSARY TO POINT TO THE NEXT BLOCK
;	MFD, UFD FILES WILL BE POSITIONED FOR NEXT TIME IN.
;	THE Q. FILE LIST AREA WILL BE UPDATED
;	RETURNS T4 = 0 IF LOOKUP SUCCEEDED (NOT /NEW)
;USES T1,T2,T3,T4

LOOKFL:!
LOOKFR:	MOVE	T1,[4,,[I.INZR,,I.LSZR
			OPNBLK,,LKBLK
			I.LZER,,LKBLKL
			DC,,I]  ]
	PUSHJ	P,.LKWLD##	;GET NEXT WILD NAME
	  POPJ	P,		;ALL DONE

	TLNN	F,L.KONC	;IS THIS A KJOB CALL?
	JRST	LOOKLK		;NO, PROCEED WITH LOOKUP

;HERE ON KJOB CALL, BECAUSE WE HAVE SET UP THE WILD LOOKUP BLOCK
; TO RETURN ANY SPOOLABLE FILES WHOSE EXT'S ARE LATER IN THE EXT
; LIST (QUENMT) THAN THE SET WE ARE LOOKING FOR ON THIS PASS.
; THUS WE CAN DETERMINE WHETHER LATER PASSES WILL BE BENEFICIAL,
; AND IF SO, THE EXTENSION TO LOOK FOR ON THE NEXT PASS.

	MOVX	T1,X.LOG	;SEE IF /LOG
	TDNN	T1,I.MOD(I)	;  IF SO, THEN OK TO INCLUDE
	TLNN	F,L.HERE	;SEE IF SOME OTHER SITE
	JRST	LOOKLK		;YES--BECAUSE MIGHT BE LOG/ FOO.CDP
	MOVE	T1,KJBQUE	;GET EXT SOUGHT ON THIS PASS
	SUBI	T1,QUENML	; CALCULATE # OF OTHERS LATER IN EXT LIST
	HRLZS	T1		;-# REMAINING IN LH
	HRR	T1,KJBQUE	;THIS IS THE ONE FOR THIS PASS
	HLLZ	T2,RIBEXT	;GET EXTENSION
	CAMN	T2,QUENMT(T1)	;SEE IF SPOOLED FILE
	JRST	LOOKJY		;YES--SPECIAL TEST FOR SITE
LOOKJX:	AOBJP	T1,LOOKLK	;HERE BECAUSE THERE MAY BE NONE
	CAME	T2,QUENMT(T1)	;COMPARE EXT WITH THOSE IN TABLE
	JRST	LOOKJX
	ANDI	T1,-1		;INDEX OF THIS EXT
	CAMGE	T1,KNXQUE	;HAD WE PLANNED TO IGNORE THIS EXT?
	MOVEM	T1,KNXQUE	;YES, PLAN TO PROCESS IT
	JRST	LOOKFR		;BUT FOR NOW, PASS IT BY
;HERE WHEN SPOOLED FILE AT JOB'S STATION
;	CHECK RH(FILE NAME) TO SEE IF ALTERNATE QUEUE
LOOKJY:	HRRZ	T1,RIBNAM	;GET SXX OR NNN CODE
	PUSHJ	P,CNVSTA	;CONVERT TO STATION/DEVICE
	JUMPLE	T1,LOOKLK	;JUNK--INCLUDE IN JOB'S STATION
	CAMN	T1,HERE		;IF AT JOB'S STATION,
	JRST	LOOKLK		; THEN INCLUDE
	TLO	F,L.NEED	;NO--NOTE ANOTHER PASS NEEDED
	CAIL	T1,100		;IF DEVICE,
	SUBI	T1,1000-^D72	;  CHANGE TO 72+ RANGE
	IDIVI	T1,^D36		;CONVERT TO WORD/BIT
	MOVNS	T2		;NEGATE BIT NUMBER
	MOVSI	T3,(1B0)	;GET BIT 0
	LSH	T3,(T2)		;POSITION TO BIT N
	IORM	T3,STATAB(T1)	;SET FLAG THAT THIS ONE NEEDED
	JRST	LOOKFR		;AND SKIP ON TO OTHER WORK


;HERE WHEN LOOKUP BLOCK PREPARED FOR NEXT FILE
; AND IT IS TIME TO OPEN AND LOOK IT UP

LOOKLK:	MOVE	T1,OPNBLK+1	;GET ARGUMENT DEVICE
	MOVEM	T1,Q.FSTR(J)	;STORE AS STRUCTURE
	MOVEM	T1,RIBDEV	;AND IN RIB JUST IN CASE
	MOVE	T1,RIBNAM	;GET FILE NAME
	MOVEM	T1,Q.FNAM(J)	;STORE IN REQUEST
	MOVE	T1,RIBEXT	;GET FILE EXTENSION
	HLLZM	T1,Q.FEXT(J)	;STORE IN REQUEST
	OPEN	DC,OPNBLK	;OPEN CHANNEL
	  JRST	[PUSHJ P,E.DFO##
		 JRST  LOOKFR]

LOOKIE:	MOVEI	T1,LKBLK	;SET FOR LEVEL D BLOCK
	TLNN	F,L.LEVD	;IS IT LEVEL D?
	MOVEI	T1,LKBLK+2	;NO--SET FOR LEVEL C BLOCK
	MOVE	T4,RIBPPN	;PRESERVE A COPY FROM FILSER
	LOOKUP	DC,(T1)		;EXTENDED LOOKUP
	  JRST	LOOKER		;IF FAILURE
	MOVEI	T1,DC		;GET CHANNEL NUMBER
	MOVEM	T1,PTFFCN	;SET IN PATH BLOCK
	MOVE	T1,[.PTMAX,,PTFFCN]
	PATH.	T1,		;GET LOCATION FROM MONITOR
	  SETZM	PTFPPN+1	;CLEAR RESULT
	MOVEI	T1,PTFFCN	;POINT TO BLOCK
	SKIPE	PTFPPN+1	;SEE IF SFDS
	MOVEM	T1,RIBPPN	;YES--POINT FROM LOOKUP
	HLRZ	T2,RIBPRV	;GET FILE'S PROTECTION
	LSH	T2,-^D9		;POSTION IT
	HRLI	T2,.ACRED	;ASK ABOUT READS
	SKIPN	LOGCNT		;SEE IF IT IS LOG FILE
	HRLI	T2,.ACAPP	;YES--SEE IF CAN APPEND
	HLRZ	T3,RIBEXT	;GET FILE'S EXTEN'SION		[1175]
	CAIE	T3,'UFD'	;SEE IF DIRECTORY		[1175]
	CAIN	T3,'SFD'	; ..				[1175]
	JRST	[SKIPN LOGCNT	;YES--SEE IF .LOG		[1175]
		 JRST  LOOKBC	;YES--ERROR			[1175]
		 LSH   T2,^D9	;MOVE PROTECTION		[1175]
		 HRLI  T2,.ACSRC  ;CHANGE REQUEST TYPE		[1175]
		 JRST  .+1]	;RESUME WORK			[1175]
	SKIPN	T3,RIBPPN	;GET TARGET PPN
	MOVEI	T3,PTHFCN	;IF UNKNOWN, POINT TO DEFAULT
	TLNN	T3,-1		;SEE IF PATH POINTER
	MOVE	T3,.PTPPN(T3)	;YES--GET UFD
	MOVE	T4,Q.PPN(Q)	;GET REQUESTOR'S PPN
	MOVEI	T1,T2		;SET UUO POINTER
	CHKACC	T1,		;CHECK ACCESS RIGHTS
	  JRST	LOOKOK		;OK IF OLD MONITOR
	JUMPL	T1,LOOKBC	;GIVE UP IF FAILED

LOOKOK:	MOVSI	T4,(7B2)	;GET LEVEL D UNPROTECTED MASK
	TLNN	F,L.LEVD	; SEE IF LEV C
	MOVSI	T4,(4B2)	; YES--CHANGE
	MOVX	T3,X.UNP	;PREPARE TO TEST /UNPRESERVED
	TDNE	T3,I.MOD(I)	;TEST
	TDNN	T4,RIBPRV	;YES TO SWITCH--CHECK FILE
	JRST	.+2		;NOT UNPRES. OR DON'T CARE
	JRST	LOOKFR		;PRESERVED--LOOP BACK

	PUSHJ	P,.CHKTM##	;CHECK /BEFORE/SINCE
	  JRST	LOOKFR		;BAD--RECYCLE

LOOKGD:	PUSHJ	P,ISBIN		;SEE IF BINARY AND IMPROPER
	  JRST	LOOKBN		;YES--GIVE ERROR
	SKIPE	T4,RIBDEV	;GET UNIT NUMBER
	MOVEM	T4,Q.FSTR(J)	;STORE INTO REQUEST
	MOVE	T4,RIBSIZ	;GET LENGTH IN WORDS
	TLNE	F,L.LEVD	;SEE IF LEVEL D
	JRST	POSWRD		;YES--GO PROCESS IT
	HLRE	T4,T4		;NO--GET FILE LENGTH
	JUMPGE	T4,POSLEN	;IF IN BLOCKS, OK
	MOVNS	T4		;IN NEG WORDS--COMPL.
POSWRD:	ADDI	T4,177		;ROUND UP
	ASH	T4,-7		;CONVERT TO BLOCKS
POSLEN:	TLNE	T4,777770	;CHECK FOR OVERFLOW
	HRLOI	T4,<1B14-1>_-^D18  ;YES--SET MAX
	LDB	T3,[POINTR (I.MOD(I),X.COP)]  ;GET REPEAT COUNT
	SKIPN	T3		;FORCE NON-ZERO
	MOVEI	T3,1		;YES
	IMUL	T3,T4		;COMPUTE COMBINED TOTAL
	ADDB	T3,NOBLKS	;ADD TO ACCUMULATED TOTAL
	HRLOI	T4,<1B14-1>_-^D18  ;GET MAX IN CASE NEEDED
	TLNE	T3,777770	;SEE IF OVERFLOW
	MOVEM	T4,NOBLKS	;YES--SET TO MAX
	MOVE	T3,I.MOD(I)	;GET SWITCHES
	TXZ	T3,X.NEW	;CLEAR /NEW
	MOVEI	T4,0		;FLAG FILE FOUND

LOOKND:	SETZM	Q.FDIR(J)	;CLEAR OUT DIRECTORY
	HRLI	T1,Q.FDIR(J)	; ..
	HRRI	T1,Q.FDIR+1(J)	; ..
	BLT	T1,Q.FDIR+.FXLND-1(J) ; ..
	SKIPN	T1,RIBPPN	;GET LOOKUP DIRECTORY
	MOVEI	T1,PTHFCN	;UNKNOWN--GET DEFAULT
	TLNE	T1,-1		;SEE IF SFD
	SKIPA	T2,T1		;NO--GET UFD
	MOVE	T2,.PTPPN(T1)	;YES--GET UFD
	MOVEM	T2,Q.FDIR(J)	;SAVE IN QUEUE REQUEST
	PUSH	P,T3		;SAVE SWITCHES
	TLNE	T1,-1		;SEE IF SFDS
	JRST	LOOKDD		;NO--DONE WITH DIRECTORY
	MOVEI	T2,Q.FDIR+1(J)	;YES--POINT TO SFDS IN QUEUE REQUEST
	HRLI	T2,1-.FXLND	;COUNT NUMBER OF SFDS
LOOKDL:	SKIPN	T3,.PTPPN+1(T1)	;GET NEXT SFD
	JRST	LOOKDD		;ALL DONE
	MOVEM	T3,(T2)		;STORE IN REQUEST
	AOS	T1		;ADVANCE FETCH
	AOBJN	T2,LOOKDL	;LOOP OVER STORE
LOOKDD:	POP	P,T3		;RESTORE FLAGS
	TXZ	T3,X.UNP!X.OKBN	;CLEAR VARIOUS FLAGS
	MOVEM	T3,Q.FMOD(J)	;PUT INTO REQUEST
	MOVE	T3,I.STRT(I)	;GET STARTING POINT
	MOVEM	T3,Q.FBIT(J)	;SAVE IN REQUEST
	TRNN	F,R.NEWF	;NEW FORMAT?
	JRST	.POPJ1		;NO--ALL DONE
	SETCM	T3,I.RPT(I)	;SEE IF /REPORT
	JUMPE	T3,.POPJ1	;NO--RETURN
	MOVE	T3,I.RPT(I)	;GET REPORT NAME
	MOVEM	T3,Q.FRPT(J)	;STORE
	MOVE	T3,I.RPT+1(I)	;GET SECOND HALF
	MOVEM	T3,Q.FRPT+1(J)	;STORE SECOND HALF.
	JRST	.POPJ1		;IF SUCCESS RETURN
;HERE WHEN LOOKUP FAILS--SEE IF .NULL NEEDED OR /NEW SWITCH

LOOKER:	MOVEM	T4,RIBPPN	;RESTORE DIRECTORY
	HRRZ	T2,RIBEXT	;GET LOOKUP ERROR CODE
	JUMPN	T2,LOOKBD	;GO ISSUE ERROR
	HLLZ	T1,RIBEXT	;NOT FOUND--SEE IF NULL APPROPRIATE
	JUMPE	T1,LOOKNF	;IF ALREADY NULL, TRY BELOW
	MOVX	T1,FX.NUL	;NOT NULL--SEE IF NULL NEEDED
	TDNN	T1,.FXMOD(I)	; ..
	JRST	LOOKNF		;NOT NEEDED--HANDLE ERROR
	MOVSI	T2,'LST'	;PREPARE TO TRY .LST
	HLRZ	T1,RIBEXT	;GET EXTENSION
	CAIE	T1,'LPT'	;SEE IF .LPT
	MOVEI	T2,0		;NO--TRY NULL
	MOVEM	T2,RIBEXT	;CHANGE LOOKUP BLOCK
	MOVEM	T2,Q.FEXT(J)	;AND REQUEST
	JRST	LOOKIE		;AND TRY AGAIN

LOOKNF:	MOVE	T3,I.MOD(I)	;GET SWITCHES
	TXNN	T3,X.NEW	;SEE IF /NEW
	JRST	LOOKBD		;NO--ERROR
	SETO	T4,		;YES--SET FLAG FOR LATER
	SETZM	RIBPRV		;CLEAR PROTECTION, ETC.
	JRST	LOOKND		;AND RETURN RESULTS

LOOKBC:	MOVEI	T1,ERPRT%	;SETUP PROTECTION FAILURE
	HRRM	T1,RIBEXT	; IN EXTENSION
LOOKBD:	PUSHJ	P,E.DFL##	;ISSUE ERROR MESSAGE
	JRST	LOOKFR		;LOOP BACK TO GET NEXT REQUEST

LOOKBN:	MOVEI	T1,[ASCIZ /% Can't print binary/]
	PUSHJ	P,.TSTRG
	PUSHJ	P,.TFILE##
	JRST	LOOKFR		;LOOP FOR NEXT FILE
;ISBIN -- SUBROUTINE TO SEE IF IMPROPERLY TRYING TO PRINT BINARY
;CALL:	PUSHJ	P,ISBIN
;ERROR RETURN IF WRONG
;SKIP RETURN IF OK
;USES T1, T2, T3, T4

ISBIN:	MOVX	T1,X.OKBN	;SEE IF /OKBINARY SWITCH
	TDNE	T1,I.MOD(I)	; ..
	JRST	.POPJ1		;YES--GIVE OK RETURN
	LDB	T1,[POINTR (I.MOD(I),X.PAPR)]  ;GET MODE
	LDB	T2,[POINTR (RIBPRV,RB.MOD)]  ;GET FILE MODE
	CAILE	T2,.IOASL	;IF FILE MODE IS ASCII OR ASCII LINE,
	CAILE	T1,PRINASCII	;OR IF OUTPUT MODE IS NOT ASCII OR ARROW,
	JRST	.POPJ1		;THEN IT IS OK ANYWAY
	PUSHJ	P,QUETYP	;SEE WHICH QUEUE
	CAIE	T1,1		;IF NOT LPT,
	JRST	.POPJ1		; THEN IT IS OK

;HERE WHEN NO SPECIAL CASES, JUST LPT OF RANDOM FILE

	HLRZ	T1,RIBEXT	;GET EXTENSION FOR EASE OF TESTING
	MOVSI	T3,-LENBEX	;GET LENGTH OF BINARY EXTENSION TABLE
ISBIN1:	MOVE	T2,BINEXT(T3)	;GET NEXT PAIR
	CAIN	T1,(T2)		;SEE IF IT MATCHES
	POPJ	P,		;YES--ERROR RETURN
	HLRZS	T2		;TRY OTHER ONE
	CAIN	T1,(T2)		;..
	POPJ	P,		;ERROR RETURN
	AOBJN	T3,ISBIN1	;LOOP UNTIL DONE
	JRST	.POPJ1		;NOT BINARY EXTENSION--MUST BE OK

BINEXT:	'BACBIN'	;BASIC OUTPUT,,BINARY
	'BUGCHN'	;PROGRAM SAVED WITH BUG,,CHAIN FILE
	'DAEDCR'	;DAEMON FILE,,DCORE FILE
	'DMPHGH'	;PDP-6 SAVE,,NON-SHAREABLE HIGH SEG SAVE
	'LOWMSB'	;LOW SEGMENT,,MUSIC PROGRAM OUTPUT
	'OVRQUC'	;COBOL OVERLAY,,QUEUE CHANGE
	'QUDQUE'	;QUEUE DATA,,QUEUE REQUEST
	'QUFREL'	;QUEUED REQUEST,,RELOCATABLE BINARY
	'RIMRMT'	;TWO KINDS OF READ IN MODE FILES
	'RTBSAV'	;ANOTHER RIM,,SAVE FILE
	'SFDSHR'	;SUB-FILE DIRECTORY,,SHAREABLE HIGH SEGMENT SAVE
	'SVESYS'	;10/30 SAVE,,SYSTEM BINARY FILE
	'TMPUFD'	;TEMPORARY FILE,,USER'S FILE DIRECTORY
	'XPNXPN'	;EXPANDED SAVE FILE

;ADD MORE HERE--FILL WITH A DUPLICATE--NEVER FILL WITH 0
LENBEX==.-BINEXT
;GETMOD -- ROUTINE TO GET NEXT MODIFY FILE SPECIFICATION
;THE RESULT IS PLACED IN THE QUEUE REQUEST
;THIS SERVES THE SAME FUNCTION AS LOOKFL
;CALL:	MOVEI	I,0	INITIALLY
;	MOVEI	J,ADDR. OF NEXT RESULT BLOCK
;	PUSHJ	P,GETMOD
;	  ERROR RETURN IF END OF REQUESTS
;	SKIP RETURN IF FILE COPIED
;USES T1, T2, T3

GETMOD:	SKIPN	I		;SEE IF FIRST CALL
	SKIPA	I,I.INZR	;YES--GET START OF REQUESTS
	ADDI	I,I.LZER	;NO--ADVANCE TO NEXT REQUEST
	CAML	I,I.NXZR	;SEE IF DONE YET
	POPJ	P,		;YES--RETURN

	SKIPN	T1,.FXDEV(I)	;GET USER SUPPLIED NAME
	JRST	GETMDS		;NONE--SKIP BELOW
	MOVX	T2,FX.PHY	;GET /PHYSICAL BIT
	TDNN	T2,.FXMOD(I)	;SEE IF PHYSICAL REQUESTED
	DEVNAM	T1,		;NO--CONVERT LOGICAL TO PHYSICAL DEVICE
	  JFCL			;NICE TRY
GETMDS:	MOVEM	T1,Q.FSTR(J)	;STORE PHYSICAL NAME AWAY
	MOVE	T1,MYPPN	;GET LOGGED IN PPN
	MOVSI	T2,-1		;MASK FOR PROJECT
	TDNN	T2,.FXDIR(I)	;SEE IF PROJECT
	HRROS	.FXDIM(I)	;NO--GIVE SELF
	TDNN	T2,.FXDIR(I)	; ..
	HLLM	T1,.FXDIR(I)	; ..
	MOVEI	T2,-1		;MASK FOR PROGRAMMER
	TDNN	T2,.FXDIR(I)	;SEE IF PROGRAMMER
	HLLOS	.FXDIM(I)	;NO--GIVE SELF
	TDNN	T2,.FXDIR(I)	; ..
	HRRM	T1,.FXDIR(I)	; ..
	MOVEI	T2,.FXDIR(I)	;POINT TO INPUT DIRECTORY
	MOVEI	T3,Q.FDIR(J)	;POINT TO QUEUE REQUEST
	HRLI	T3,-.FXLND	;SET COUNT
GETMDL:	SKIPE	T1,(T2)		;GET REQUEST DIRECTORY
	ADDI	T2,2		;ADVANCE FETCH
	MOVEM	T1,(T3)		;STORE RESULT
	AOBJN	T3,GETMDL	;LOOP FOR FULL DEPTH
	MOVE	T1,.FXNAM(I)	;GET FILE NAME
	MOVEM	T1,Q.FNAM(J)	;STORE
	HLLZ	T1,.FXEXT(I)	;GET EXTENSION NAME
	MOVEM	T1,Q.FEXT(J)	;STORE
	MOVE	T1,I.STRT(I)	;GET STARTING POINT
	MOVEM	T1,Q.FBIT(J)	;STORE
	MOVE	T1,I.MOD(I)	;GET SWITCHES
	MOVEM	T1,Q.FMOD(J)	;STORE
	MOVEI	T2,.FXDIM(I)	;POINT TO USER'S DIRECTORY MASKS
	MOVEI	T3,Q.FDRM(J)	;POINT TO QUEUE REQUEST
	HRLI	T3,-.FXLND	;SET COUNT
GETMDM:	MOVE	T1,(T2)		;FETCH MASK
	MOVEM	T1,(T3)		;STORE
	SKIPE	-1(T2)		;SEE IF AT END
	ADDI	T2,2		;NO--ADVANCE POINTER
	AOBJN	T3,GETMDM	;LOOP UNTIL DONE
	MOVE	T1,.FXNMM(I)	;GET NAME MASK
	MOVEM	T1,Q.FNMM(J)	;STORE
	HRLZ	T1,.FXEXT(I)	;GET EXT. MASK
	MOVEM	T1,Q.FEXM(J)	;STORE
	MOVE	T1,I.MODM(I)	;GET SWITCH MASK
	MOVEM	T1,Q.FMDM(J)	;STORE
	JRST	.POPJ1		;RETURN
;PRTBLK -- ROUTINE TO PRINT NUMBER OF BLOCKS IN REQUEST
;CALL:	PUSHJ	P,PRTBLK
;USES T1-4

PRTBLK:	PUSHJ	P,QUETYP	;SEE WHAT TYPE OF QUEUE
	SKIPLE	T1		;IGNORE IF INPUT
	SKIPN	T1,NOBLKS	;GET AGGREGATE BLOCKS
	POPJ	P,		;IF UNKNOWN DON'T REPORT SIZE
	PUSH	P,T1
	MOVEI	T1,[ASCIZ /Total of /]
	PUSHJ	P,.TSTRG
	MOVE	T1,(P)
	PUSHJ	P,.TDECW
	MOVEI	T1,[ASCIZ / block/]
	PUSHJ	P,.TSTRG
	MOVEI	T1,"s"
	SOSE	(P)
	PUSHJ	P,.TCHAR
	POP	P,T1
	MOVEI	T1,[ASCIZ / in /]
	PUSHJ	P,.TSTRG	;				[1204]
	HRRZ	T1,Q.LEN(Q)	;				[1204]
	PUSHJ	P,.TDECW	;				[1204]
	MOVEI	T1,[ASCIZ / file/]
	PUSHJ	P,.TSTRG	;				[1204]
	HRRZ	T2,Q.LEN(Q)	;				[1204]
	MOVEI	T1,"s"		;				[1204]
	SOSE	T2		;				[1204]
	PUSHJ	P,.TCHAR	;				[1204]
	MOVEI	T1,[ASCIZ / in /]
	PUSHJ	P,.TSTRG
	MOVE	T1,O.DEV
	PUSHJ	P,.TSIXN
	MOVEI	T1,[ASCIZ / request
/]
	PJRST	.TSTRG
	SUBTTL	COMMAND SCANNING SUBROUTINES

;GTCLIA -- ADD ANOTHER AREA TO GTCLIK
;GTCLIK -- GET AND CLEAR INPUT PARAM AREA--PRESET TO /OKNONE/UNPRES

;CALL:	PUSHJ	P,GTCLIK
;RETURNS WITH I=START OF AREA, T1=END OF AREA
;USES T2, T3

GTCLIA:	CAMGE	I,I.INZR	;SEE IF FIRST TIME
	PJRST	GTCLIK		;YES--DON'T APPEND
	MOVX	T1,.FXTRC*1B<^L<FX.TRM>+2>  ;GET + FLAG
	IORM	T1,.FXMOD(I)	;ADD TO SWITCHES
	MOVX	T1,FX.TRM	;SET MASK
	IORM	T1,.FXMOM(I)	; IN PREV. REQUEST

GTCLIK:	PUSHJ	P,GTCLIN	;GET AND CLEAR AREA
	MOVE	I,T1		;POINT TO REQUEST
	ADDI	T1,-1(T2)	;POINT AT END
	MOVX	T2,X.UNP  	;GET /UNPRES
	MOVEM	T2,I.MOD(I)	;SET FLAG ON
	MOVEM	T2,I.MODM(I)	;INDICATE FLAG PRESENT
	MOVX	T2,FX.NOM	;GET /OKNONE
	IORM	T2,.FXMOD(I)	;SET FLAG ON
	IORM	T2,.FXMOM(I)	;INDICATE FLAG PRESENT
	SETOM	.FXSNC(I)	;CLEAR /SINCE
	SETOM	.FXBFR(I)	;CLEAR /BEFORE
	MOVSI	T2,'*  '	;SET WILD-CARD
	MOVEM	T2,.FXNAM(I)	;IN REQUEST
	POPJ	P,		;RETURN
;GTCLIN -- GET AND CLEAR ONE INPUT FILE PARAMETER STORAGE AREA
;CALL:	PUSHJ	P,GTCLIN
;RETURNS WITH T1=START OF AREA, T2=LENGTH OF AREA
;USES T3

GTCLIN:	MOVE	T2,.JBFF	;START AT .JBFF
IFN	DEBUG,<
	CAME	T2,I.NXZR	;VERIFY NOONE CHANGED .JBFF
	JRST	E.GCIX		;OOPS!>
	GCORE	I.LZER		;GET ONE AREA
	MOVEI	T1,1(T1)	;ADVANCE ONE AND
	MOVEM	T1,I.NXZR	;SAVE NEW END
	SETZM	(T2)		;CLEAR AREA
	HRLZI	T3,(T2)		; ..
	HRRI	T3,1(T2)		; ..
	BLT	T3,-1(T1)	; ..
	MOVE	T1,T2		;POSITION RESULT
	MOVEI	T2,I.LZER	;GET LENGTH
	POPJ	P,		;RETURN

IFN DEBUG,<E.GCIX:	TLO F,L.WIPE
	N.FAIL	<.JBFF moved from under GTCLIN>>



;GCORE. -- GET CORE STARTING AT .JBFF
;CALL:	GCORE	N
;RETURN WITH T1=END OF AREA

GCORE.:	ADDB	T1,.JBFF	;ADVANCE .JBFF THE SPACE
GCORE1:	MOVE	T1,.JBFF	;GET NEW CORE SIZE
	CAMG	T1,.JBREL	;SEE IF STILL IN CORE
	SOJA	T1,.POPJ	;RETURN POINTING TO LAST
	CORE	T1,		;NO--ASK MONITOR FOR MORE
	  JRST	.+2		;IF FAIL
	JRST	GCORE1		;IF WON, LOOP BACK TO EXIT
	MOVEI	T1,[ASCIZ /
? Insufficient core in QUEUE
/]
	PUSHJ	P,.TSTRG
	CLRBFI			;CLEAR TYPEAHEAD
	TLNE	F,L.KJOB	;SEE IF KJOB CALL
	PJRST	KJBRET		;YES--GO HANDLE SPECIAL CASE
	PUSHJ	P,.MONRT##	;RETURN TO MONITOR
	JRST	GCORE1		;AND LOOP BACK
;HERE TO READ IN SIGNED DECIMAL NUMBER (/DEPENDENCY)

DEPSW:	PUSHJ	P,.TIAUC##	;GET SIGN IF PRESENT
	MOVEI	T2,0		;CLEAR FLAGS
	CAIN	C,"+"		;SEE IF INCREMENT
	TRO	T2,1B19		;YES--SET FLAG
	CAIN	C,"-"		;SEE IF DECREMENT
	TRO	T2,1B18		;YES--SET FLAG
	TRNE	T2,3B19		;SEE IF EITHER SET
	PUSHJ	P,.TIAUC##	;YES--GET ONE MORE CHARACTER
	PUSHJ	P,.DECNC##	;GET NUMBER
	JUMPL	N,E.SVTL	;ERROR IF NEGATIVE
	CAIL	N,3B19		;MAKE SURE IT'S SMALL ENOUGH
	JRST	E.SVTL		;NO--GIVE ERROR
	IOR	N,T2		;COMBINE FLAGS
	PJRST	.SWDPB##	;GO STORE RESULT

E.SVTL:	N.FAID	<Switch value too large>

;HERE TO READ IN 5 CHAR SIXBIT SWITCH (/TAG)

TAGSW:	PUSHJ	P,.SIXSW##	;GET SIXBIT WORD
	LSH	N,-6		;SHIFT OFF 1 CHAR
	PJRST	.SWDPB##	;STORE THE SWITCH

;HERE ON /BEGIN SWITCH

BEGSW:	PUSHJ	P,.DECNW##	;GET DECIMAL ARGUMENT
	PUSHJ	P,QUETYP	;FIND OUT WHICH TYPE OF QUEUE
	PJUMPL	T1,E.BSIL	;ERROR IF /LIST
	IMUL	N,BEGNTB(T1)	;MULTIPLY BY LINES/PAGE
	PJRST	.SWMAX##	;GO STORE AWAY
E.BSIL:	N.FAIL	<BEGIN switch illegal>

;HERE ON /REPORT
RPTSW:	TRO	F,R.NEWF	;FLAG SOME ENTRY HAS /REPORT
	PJRST	.SWSXQ##	;GO HANDLE SIXBIT SWITCH

;HERE WHEN SWITCH VALUE IS A RADIX-60 SPECIFICATION (/TIME)

TIMESW:	PUSHJ	P,RDX60W	;GET RADIX 60 NUMBER
	PJRST	.SWMAX##	;AND STORE ANSWER
;HERE WHEN /PAPER SWITCH -- NEED TO SEE WHAT KIND AND REENTER

PAPRSW:	PUSHJ	P,QUETYP	;FIND OUT WHAT KIND OF QUEUE
	JUMPG	T1,PAPRS1	;IF REASONABLE, GO DO IT
	N.FAIL	<PAPER switch illegal>
PAPRS1:	PUSH	P,FILSPT-1(T1)	;SAVE IOWD TO LIST OF ARGS
	PUSHJ	P,.SIXSW##	;YES--GET IT
	MOVE	T1,(P)		;GET ARG LIST
	PUSHJ	P,.NAME##	;SEE IF LISTED
	  JRST	PAPRS2		;NO--SEE WHY
	SUB	T1,(P)		;GET OFFSET IN LIST
	MOVEI	N,(T1)		;SET AS VALUE
	JRST	PAPRS4		;GO CLEANUP
PAPRS2:	CAME	N,['0     ']	;SEE IF :0
	JUMPN	N,E.UKK##	;NO, IF NOT :, THEN ERROR
PAPRS3:	MOVEI	N,0		;OK--RETURN 0 (DEFAULT)
PAPRS4:	POP	P,(P)		;DISCARD IOWD
	PJRST	.SWDPB##	;GO STORE RESULT

	DEFINE X(LIST),<
IRP LIST,<..TEMP==0
	  IFIDN <LIST><LPT>,<..TEMP==<IOWD PRIN.L,PRIN.T>>
	  IFIDN <LIST><CDP>,<..TEMP==<IOWD PUNC.L,PUNC.T>>
	  IFIDN <LIST><PTP>,<..TEMP==<IOWD TAPE.L,TAPE.T>>
	  IFIDN <LIST><PLT>,<..TEMP==<IOWD PLOT.L,PLOT.T>>
	  IFN ..TMP,<..TEMP>
	  ..TMP==1>>

	..TMP==0
FILSPT:	QUEUES
	DEFINE	SWTCHS,<
SP AFTER,S.AFT,.SWDTF##,AFT,FS.VRQ
SP BEGIN,F.STRT,BEGSW,STR,FS.VRQ
SP CARDS,S.LCDP,.SWDEC##,CDP
SP CHARGE,S.CNO,.SWSIX##,,FS.VRQ
SP COPIES,<POINTR(F.MOD,X.COP)>,.SWDEC##,COP
SP CORE,S.COR,.SWCOR##,COR,FS.LRG
SS CREATE,S.OPN,QO.CRE
SP DEADLINE,S.DED,.SWDTF##,DED,FS.VRQ
SS DEFER,S.OPN,QO.DEF
SS DELETE,<POINTR (F.MOD,X.DISP)>,DISPRENAME
SP DEPENDENCY,S.DPN,DEPSW,DPN
SL DISPOSE,<POINTR(F.MOD,X.DISP)>,DISP,DISPRESERVE
SS ERBINARY,<POINTR(F.MOD,X.OKBN)>,0
SS *FAST,S.FAST,1
SP FEET,S.LPTP,.SWDEC##,PTP
SL FILE,<POINTR(F.MOD,X.FILE)>,FILE,FILEASCII
SP FORMS,S.FRM,.SWSIX##,,FS.VRQ
SP HEADER,<POINTR(F.MOD,X.NOHD)>,.SWDEC##,NHD
SS KILL,S.OPN,QO.KIL
SP LIMIT,S.LIM,.SWDEC##,LIM
SL *LIST,S.LIST,LIST,LISTJOBS
SS LOG,<POINTR(F.MOD,X.LOG)>,1
SS MODIFY,S.OPN,QO.MOD
SS NEW,<POINTR(F.MOD,X.NEW)>,1
SS NOHEADER,<POINTR(F.MOD,X.NOHD)>,0
SS NOLOG,<POINTR(F.MOD,X.LOG)>,0
SS NONEW,<POINTR(F.MOD,X.NEW)>,0
SS NONULL,S.NULL,0
SS NOREMOVE,<POINTR(F.MOD,X.PAPR)>,0
SS NORESTARTABLE,S.RSTR,0
SP NOTES,<POINT 63,S.NOT>,.SWSXQ##,,FS.VRQ
SS NOTITLE,<POINTR(F.MOD,X.TITL)>,0
SS NOUNPRESERVED,<POINTR(F.MOD,X.UNP)>,0
SS NULL,S.NULL,1
SS OKBINARY,<POINTR(F.MOD,X.OKBN)>,1
SP OUTPUT,S.OUT,.SWDEC##,OUT
SP PAGES,S.LLPT,.SWDEC##,LPT
SP *PAPER,<POINTR (F.MOD,X.PAPR)>,PAPRSW,,FS.VRQ
SP PATH,DEFFIL,.SWFIL##,PTH,FS.VRQ
SL PLOT,<POINTR(F.MOD,X.PAPR)>,PLOT,PLOTIMAGE
SL PRINT,<POINTR(F.MOD,X.PAPR)>,PRIN,PRINARROW
SP PRIORITY,S.PRI,.SWDEC##,PRI
SL PUNCH,<POINTR(F.MOD,X.PAPR)>,PUNC,PUNCASCII
SS REMOVE,<POINTR(F.MOD,X.REMV)>,1
SP REPORT,<POINT 63,F.RPT>,RPTSW,,FS.VRQ
SP RESTARTABLE,S.RSTR,.SWDEC##,RST
SP SEQUENCE,S.SEQ,.SWDEC##,SEQ
SL *SPACES,<POINTR(F.MOD,X.SPAC)>,SPAC,SPACSINGLE
SL *SPACING,<POINTR(F.MOD,X.SPAC)>,SPAC,SPACSINGLE
SP START,F.STRT,.SWDEC##,STR
SP TAG,F.STRT,TAGSW,,FS.VRQ
SL TAPE,<POINTR(F.MOD,X.PAPR)>,TAPE,TAPEASCII
SP TIME,S.LTIM,TIMESW,TIM
SS TITLE,<POINTR(F.MOD,X.TITL)>,1
SP TPLOT,S.LPLT,.SWDEC##,PLT
SP UNIQUE,S.UNIQ,.SWDEC##,UNI
SS UNPRESERVED,<POINTR(F.MOD,X.UNP)>,1
SS ZDEFER,S.OPN,QO.ZDF
	PAGE
>
;NOW BUILD THE TABLES FROM THE SWTCHS MACRO

	DOSCAN(SWTCH)


;KEY WORD VALUES

KEYS	DISP,<PRESERVE,RENAME,DELETE>

KEYS	FILE,<ASCII,FORTRAN,COBOL,CREF,RUNOFF,ELEVEN>

KEYS	LIST,<JOBS,DETAIL,FILES,ALL>

KEYS	PLOT,<IMAGE,ASCII,BINARY>

KEYS	PRIN,<ARROW,ASCII,OCTAL,SUPPRESS>

KEYS	PUNC,<ASCII,026,BINARY,D029,IMAGE,MNEMONIC>

KEYS	SPAC,<SINGLE,DOUBLE,TRIPLE>

KEYS	TAPE,<ASCII,IMAGE,IBINARY,BINARY>
;QUETYP -- IDENTIFY WHAT TYPE OF QUEUE HAS BEEN SPECIFIED
;
;CALL:	PUSHJ	P,QUETYP
;	RETURNS T1=-1 IF /LIST REQUEST
;		    0 IF INP:
;		    1+IF OUTPUT QUEUES IN ORDER OF QUEUES MACRO
;USES T2, T3, T4

QUETYP:	MOVEI	T1,QO.LST	;MAY NEED TO SET /LIST
	SKIPGE	S.FAST		;SEE IF /FAST
	SKIPL	S.LIST		;SEE IF /LIST:VALUE
	SKIPLE	S.OPN		;YES--SEE IF SOME OTHER OPERATION
	JRST	.+2		;YES--DO OTHER ONE
	MOVEM	T1,S.OPN	;NO--SET /LIST
	SETOM	T1		;SET ANSWER IF /LIST
	MOVE	T2,S.OPN	;GET OPERATION CODE
	CAIN	T2,QO.LST	;SEE IF /LIST
	JRST	QUTYPX		;YES--RETURN ANSWER

	PUSH	P,N		;SAVE N
	SKIPGE	O.MOD		;SEE IF NULL DEVICE
	SETZM	O.DEV		;YES--CLEAR IT OUT
	....==FX.NDV
	SKIPN	N,O.DEV		;NO--GET OUTPUT DEVICE
	SKIPE	N,DQTYPE	;USE DEFAULT FROM COMMAND
	SKIPA			;OK
	MOVSI	N,'LPT'		;DEFAULT DEVICE
	PUSHJ	P,XPNQUE	;EXPAND AND MATCH QUEUE NAME
	POP	P,N		;RESTORE NAME
	MOVEI	T1,(T1)		;CHANGE TO INDEX
	SUBI	T1,QUENMT	; ..

QUTYPX:	SKIPE	QUTYPF		;SEE IF BEEN HERE BEFORE
	CAMN	T1,QUTYPL	;YES--SEE IF SAME RESULT
	JRST	QUTYPY		;CONSISTENT--PROCEED
	N.FAIL	<Queue type error>
QUTYPY:	MOVEM	T1,QUTYPL	;SAVE THIS RESULT
	SETOM	QUTYPF		;SET FLAG
	POPJ	P,		;RETURN
QUENMA:	SIXBIT	/ALL/	;FOR LISTINGS ONLY
QUENMT:		;LIST OF VALID QUEUE NAMES (INP FIRST)
	DEFINE X(LIST),<
IRP LIST,<IFIDN <LIST><INP>,<IFN ..TEMI,<PRINTX ? INP QUEUE MUST BE FIRST>>
	  IFDIF <LIST><INP>,<IFE ..TEMI,<-1 ;FORCE NO MATCH TO HOLD PLACE>>
	  SIXBIT /LIST/
	..TEMI==..TEMI+1>>
	..TEMI==0	;INITIALIZE LOOP COUNTER
	QUEUES
QUENML==.-QUENMT

;NOW MAKE ANOTHER TABLE FOR THE LIST ROUTINE WHICH NEED IT IN THE
; LOW SEGMENT. CAN NOT USE ONE TABLE SINCE KJOB NEED IT IN THE HISEG.
; WELL IT IS ONLY 5 WORDS.

			;SWITCH TO LOW SEG
	SWSEG
	..TEMI==0	;RESET FLAG
QUELNM:	QUEUES
			;SWITCH TO HIGH SEG
	SWSEG

;TABLE OF FACTORS TO CONVERT FROM /BEGIN TO /START

	DEFINE	X(LIST),<
IRP LIST,<..TEMP==1
	IFIDN <LIST><LPT>,<..TEMP==AB.LPT>
	IFIDN <LIST><CDP>,<..TEMP==AB.CDP>
	IFIDN <LIST><PLT>,<..TEMP==AB.PLT>	;;		[1201]
	IFIDN <LIST><PTP>,<..TEMP==AB.PTP>
	..TEMP>>

BEGNTB:	QUEUES
;XPNQUE -- EXPAND QUEUE NAME ABBREVIATION IF ANY
;CALL:	MOVE	N,NAME IN SIXBIT AS TYPED IN
;	PUSHJ	P,XPNQUE
;RETURN WITH UPDATED N
;	AND WITH T1 = ADDRESS OF ENTRY
;USES M, T2, T3, T4

XPNQUE:	PUSH	P,N		;SAVE ARGUMENT
	TRZ	N,-1		;CLEAR SPECIFICS
	MOVE	T1,[IOWD QUENML+1,QUENMA]  ;POINT TO LEGAL QUEUE NAMES
	PUSHJ	P,.NAME##	;LOOKUP ABBREVIATED NAME
	  JRST	E.IQN		;ILLEGAL IF NOT FOUND
	MOVE	N,(T1)		;IF FOUND, PICK UP REAL NAME
	POP	P,T4		;RECOVER ARGUMENT
	HRR	N,T4		;APPEND SPECIFICS
IFN FTLSCK,<
	TRNN	T4,-1		;SEE IF GENERIC
	POPJ	P,		;YES--RETURN
	MOVE	T4,N		;NO--SEE IF LEGAL DEVICE SPECIFIED
	HLRZ	T3,T4		;GET GENERIC NAME
	CAIN	T3,'INP'	;SEE IF INPUT QUEUE
	HRLI	T4,'LPT'	;YES--TEST FOR AN LPT
	DEVCHR	T4,		;MAKE SURE IT EXISTS
	JUMPE	T4,E.IQDN	;ERROR IF IT DOES NOT
>;END OF IFN FTLSCK
IFE FTLSCK,<
	LDB	T3,[POINT 6,T4,23]  ;GET FOURTH CHAR
	TRNE	T4,7700		;SEE IF FIFTH IS PRESENT
	TRC	T4,'0 '		;YES--REMOVE DIGIT BIAS
	TRNE	T4,77		;SEE IF SIXTH IS PRESENT
	TRC	T4,'0'		;YES--REMOVE DIGIT BIAS
	CAIL	T3,'0'		;SEE IF FOURTH
	CAILE	T3,'7'		;  IS OCTAL
	CAIN	T3,'S'		;OR S (STATION)
	SKIPA			;OK
	JUMPN	T3,E.IQDN	;ERROR IF NOT
	TRNN	T4,7070		;AND REST ARE OCTAL
>;END OF IFE FTLSCK
	POPJ	P,		;RETURN

E.IQDN:	N.FAIN	<Illegal queue device specification>
E.IQN:	N.FAIN	<Illegal queue name>
;CNVSTA -- CONVERT ARGUMENT TO INTERNAL STATION/DEVICE
;CALL:	MOVE	T1,QUEUE DEVICE
;	PUSHJ	P,CNVSTA
;	RETURN WITH T1=-1 IF RH(DEVICE = JUNK)
;			0 IF RH(DEVICE) BLANK (GENERIC)
;			1-77 IF S1 TO S77 (S0 CONVERTED)
;			1000-1777 IF 0: TO 777:
;USES T2

CNVSTA:	TLZ	T1,-1		;CLEAR QUEUE NAME
	JUMPE	T1,CNVSTX	;RETURN IF BLANK
	TRC	T1,'S  '	;SEE IF STATION
	TRNE	T1,77B23	; ..
	JRST	CNVDEV		;NO--MUST BE DEVICE
	TRNN	T1,77		;SEE IF TWO DIGIT
	LSH	T1,-6		;NO--SHIFT TO ONE
	SUBI	T1,'0'		;YES--REMOVE OFFSET
	TRNE	T1,77B29	;SECOND?
	SUBI	T1,'0 '		;YES--REMOVE OFFSET
	TRNE	T1,7070		;SEE IF JUNK
	JRST	CNVSTJ		;YES--RETURN -1
	LSHC	T1,-3		;SAVE RIGHT DIGIT
	LSH	T1,-3		;DISCARD SPACE
	LSHC	T1,3		;RECOVER STATION
	JUMPN	T1,CNVSTX	;RETURN VALUE
	MOVE	T1,CENTRL	;GET CENTRAL STATION
	JRST	CNVSTX		;RETURN CENTRAL NUMBER
;HERE IF DEVICE NUMBER
CNVDEV:	TRC	T1,'S  '	;RECOVER FROM TEST ABOVE
	TRNN	T1,77		;SEE IF THREE DIGITS
	LSH	T1,-6		;NO--REMOVE SPACE
	TRNN	T1,77		;SEE IF TWO DIGITS
	LSH	T1,-6		;NO--REMOVE SPACE
	SUBI	T1,'0'		;YES--REMOVE BIAS
	TRNE	T1,77B29	;SEE IF TWO
	SUBI	T1,'0 '		;YES--REMOVE BIAS
	TRNE	T1,77B23	;SEE IF THREE
	SUBI	T1,'0  '	;YES--REMOVE BIAS
	TRNE	T1,707070	;SEE IF JUNK
	JRST	CNVSTJ		;YES--RETURN -1
	LSHC	T1,-3		;SAVE RIGHT DIGIT
	LSH	T1,-3		;REMOVE PAD
	LSHC	T1,-3		;SAVE SECOND DIGIT
	LSH	T1,-3		;REMOVE PAD
	LSHC	T1,6		;RECOVER VALUE
	ADDI	T1,1000		;INCLUDE OFFSET
;HERE TO RETURN VALUE
CNVSTX:	TLZA	T1,-1		;KILL NOISE
CNVSTJ:	SETOM	T1		;FOR JUNK, RETURN -1
	POPJ	P,		;RETURN VALUE
;RDX60W -- INPUT A RADIX 60 NUMBER FROM COMMAND STRING
;RDX60  -- DITTO (CHARACTER ALREADY IN C)
;FORMATS ARE XXYYZZ OR XX:YY:ZZ
;CALL:	PUSHJ	P,RDX60/RDX60W
;	RETURN WITH WORD IN N
;USES T1, T2, T3	UPDATES C (SEPARATOR)

RDX60W:	PUSHJ	P,.TIAUC##	;PRIME THE PUMP

RDX60:	MOVEI	T2,0		;PRESET TEMPORARY RESULT
RDX601:	IMULI	T2,^D100	;ADVANCE TO NEXT RESULT
	PUSHJ	P,.DECNC##	;GET NEXT SUPER-DIGIT
	JUMPL	N,E.TCTL	;ERROR IF NEGATIVE
	ADD	T2,N		;ADD TO ACCUMULATOR
	CAIE	C,":"		;SEE IF MORE TO COME
	JRST	RDX605		;NO--GO CONVERT RESULT
	TLNE	T2,(777B8)	;DON'T ALLOW OVERFLOW
	JRST	E.TTL		;ERROR IF TIME TOO LARGE
	CAILE	N,^D60		;DON'T ALLOW GARBAGE IN
	JRST	E.TCTL		;ERROR IF DIGIT TOO LARGE
	PUSHJ	P,.TIAUC##	;SKIP SEPARATOR
	JRST	RDX601		;LOOP BACK FOR MORE

RDX605:	MOVEI	N,0		;CLEAR RESULT
RDX606:	IDIVI	T2,^D100	;SEPARATE TYPEIN
	HRLM	T3,(P)		;STORE LEAST DIGIT AWAY
	SKIPE	T2		;SKIP IF ALL DONE
	PUSHJ	P,RDX606	;IF NOT, DO SOME MORE

	HLRZ	T1,(P)		;GET BACK HIGHEST DIGIT
	IMULI	N,^D60		;MAKE ROOM IN RESULT
	ADD	N,T1		;INCLUDE RESULT
	CAILE	T1,^D60		;SEE IF ERROR
	JRST	E.TCTL		;COMPLAIN IF COMPONENT TOO BIG
	POPJ	P,		;RETURN

E.TTL:	MOVE	N,T2		;GET ERROR
	N.FAID	<Time too large>
E.TCTL:	N.FAID	<Time component too large>
	SUBTTL	SUBROUTINES FOR LISTING OUTPUT


			;SWITCH TO LOW SEG
	SWSEG


;LTIMEM/LQTIME/LTIME -- OUTPUT TIME IN FORM HH:MM:SS
;CALL:	MOVE	T1,TIME-IN-MINUTES
;	PUSHJ	P,LTIMEM
;	-OR-
;	MOVE	T1,TIME-IN-QUEUE-FORMAT
;	PUSHJ	P,LQTIME
;		IF GE 1 DAY, NDHH:MM:SS
;	-OR-
;	MOVE	T1,TIME-IN-SECONDS
;	PUSHJ	P,LTIME

;THIS PICTURES THE QUEUE TIME AS A NUMBER OF DAYS WITH THE BINARY
; POINT AT BIT 17. THE OUTPUT IS SECONDS WITH THE BINARY POINT AT BIT
; 35.
LQTIME:	MOVE	T4,T1		;SAVE TIME
	HLRZ	T1,T1		;GET DAYS
	JUMPE	T1,LQTIM1	;OK IF SOON
	PUSHJ	P,LDEC		;LIST DAYS
	MOVEI	C,"d"		;GET DAYS INDICATOR
	PUSHJ	P,LCHR		;LIST IT
	HLRZ	T1,T4		;GET NUM DAYS
	CAIGE	T1,^D1000	;IF OVER 1000, NO SPACE
	PUSHJ	P,LSPC		;SEPARATE FOR READABILITY
LQTIM1:	HRRZ	T1,T4		;RESTORE TIME
	MULI	T1,^D60*^D60*^D24 ;MAKE MUCH LARGER
	LSHC	T1,^D18		;SET TO BE FULL WORD
	JRST	LTIME		;GO LIST AS SECONDS
LTIMEM:	TRO	F,R.NSEC	;SUPPRESS SECONDS
	IMULI	T1,^D60		;CONVERT MINUTES TO SECONDS
LTIME:	TRNE	F,R.NSEC	;SEE IF SECONDS
	ADDI	T1,^D30		;NO--ROUND OFF
	IDIVI	T1,^D3600	;GET HOURS
	IDIVI	T2,^D60		;GET MIN. AND SECS.
	PUSH	P,T3		;SAVE SECONDS
	PUSH	P,T2		;SAVE MIN.
	PUSHJ	P,LDEC2Z	;LIST HOURS
	MOVEI	C,":"		;LIST A COLON
	PUSHJ	P,LCHR		; ..
	POP	P,T1		;LIST MIN.
	PUSHJ	P,LDEC2Z	; ..
	POP	P,T1		;GET SECONDS AND FALL INTO DEC2Z
	TRZE	F,R.NSEC	;SEE IF NO SECONDS
	POPJ	P,		;RIGHT--RETURN
	MOVEI	C,":"		; ADD A COLON
	PUSHJ	P,LCHR		; ..
				;FALL HERE FROM ABOVE
;LDEC2Z -- LIST DECIMAL AT LEAST 2 DIGITS WITH LEADING ZERO
;CALL:	MOVEI	T1,NUMBER
;	PUSHJ	P,LDEC2Z
;USES T1, T2, T3, C

LDEC2Z:	MOVEI	C,"0"		;SETUP TO PRINT 0 IN CASE NEEDED
	CAIGE	T1,^D10		;TEST TO SEE IF NEEDED
	PUSHJ	P,LCHR		;YES--SEND IT
	PJRST	LDEC		;GO FINISH WORK

;LDEC5 -- LIST DECIMAL AT LEAST FIVE DIGITS
;LDEC4 -- LIST DECIMAL AT LEAST FOUR DIGITS
;LDEC3 -- LIST DECIMAL AT LEAST THREE DIGITS
;LDEC2 -- LIST DECIMAL AT LEAST TWO DIGITS
;CALL:	MOVEI	T1,NUMBER
;	PUSHJ	P,LDEC2
;USES T1, T2, T3, C

LDEC5:	CAIGE	T1,^D10000
	PUSHJ	P,LSPC
LDEC4:	CAIGE	T1,^D1000	;SEE IF NEEDED
	PUSHJ	P,LSPC
LDEC3:	CAIGE	T1,^D100
	PUSHJ	P,LSPC
LDEC2:	CAIGE	T1,^D10
	PUSHJ	P,LSPC		;YES
				;FALL INTO LDEC

;LDEC -- LIST DECIMAL NUMBER
;LOCT -- LIST OCTAL NUMBER
;LRDX -- LIST VIA PRESET RADIX
;CALL:	MOVEI	T1,NUMBER
;      (MOVEI	T3,RADIX    LRDX ONLY)
;	PUSHJ	P,LDEC/LOCT/LRDX
;USES T1, T2, T3, C

LDEC:	SKIPA	T3,[^D10]	;INITIALIZE FOR DECIMAL RADIX
LOCT:	MOVEI	T3,10		;INITIALIZE FOR OCTAL RADIX
LRDX:	JUMPGE	T1,LRDX1	;PROCEED IF POSITIVE
	MOVEI	C,"-"		;ELSE, GET NEGATIVE SIGN
	PUSHJ	P,LCHR		;LIST IT

LRDX1:	IDIV	T1,T3		;DIVIDE BY RADIX
	MOVMS	T2		;MAKE POSITIVE
	HRLM	T2,(P)		;SAVE REMAINDER
	SKIPE	T1		;SEE IF ANYTHING LEFT
	PUSHJ	P,LRDX1		;YES--LOOP BACK WITH PD LIST
	HLRZ	C,(P)		;GET BACK A DIGIT
	ADDI	C,"0"		;CONVERT TO ASCII
	PJRST	LCHR		;GO LIST IT
;LOCT6 THRU LOCT2 -- LIST OCTAL AT LEAST N DIGITS
;CALL:	MOVE	T1,NUMBER
;	PUSHJ	P,LOCT6/LOCT5/LOCT4/LOCT3/LOCT2
;USES T1, T2, T3, C

LOCT6:	CAIGE	T1,100000
	PUSHJ	P,LSPC
LOCT5:	CAIGE	T1,10000
	PUSHJ	P,LSPC
LOCT4:	CAIGE	T1,1000
	PUSHJ	P,LSPC
LOCT3:	CAIGE	T1,100
	PUSHJ	P,LSPC
LOCT2:	CAIGE	T1,10
	PUSHJ	P,LSPC
	PJRST	LOCT

;LOCT6L -- LIST 0CTAL 6 DIGITS LEFT JUSTIFIED (EG. PROGRAMMER NUMBER)
;CALL:	MOVE	T1,NUMBER
;	PUSHJ	P,LOCT6L
;USES T1,T2,T3,C

LOCT6L:	PUSH	P,T1		;SAVE T1
	PUSHJ	P,LOCT		;LIST OCTAL
	POP	P,T1		;RESTORE NUMBER
	CAIGE	T1,100000
	PUSHJ	P,LSPC
	CAIGE	T1,10000
	PUSHJ	P,LSPC
	CAIGE	T1,1000
	PUSHJ	P,LSPC
	CAIGE	T1,100
	PUSHJ	P,LSPC
	CAIGE	T1,10
	PJRST	LSPC
	POPJ	P,
;LCRLF - LIST END OF LINE
;CALL:	PUSHJ	P,LCRLF
;USES M, C

LCRLF:	TRZ	F,R.LTAB	;CLEAR TAB MEMORY
	MOVEI	M,[ASCIZ /
/]
				;FALL INTO LSTR

;LSTR - LIST ASCII STRING
;CALL:	MOVEI	M,STRING (END WITH 0 BYTE)
;	PUSHJ	P,LSTR
;USES M, C

LSTR:	TLOA	M,(POINT 7,)	;CONVERT TO BYTE POINTER
LSTR1:	PUSHJ	P,LCHR		;OUTPUT CHARACTER
	ILDB	C,M		;GET NEXT CHARACTER
	JUMPN	C,LSTR1		;LOOP UNLESS NULL
	POPJ	P,		;RETURN
;LSIX  -- LIST SIXBIT WORD (AT LEAST ONE SPACE)
;LSIXN -- SAME EXCEPT 0 GIVES NO SPACES
;CALL:	MOVE	T2,WORD
;	PUSHJ	P,LSIX/LSIXN
;USES T1, T2, C

LSIX:	MOVEI	T1,0		;CLEAR NEXT CHARACTER
	LSHC	T1,6		;FETCH NEXT CHAR
	PUSHJ	P,LCHRS		;LIST IT IN SIXBIT

LSIXN:	JUMPN	T2,LSIX		;LOOP UNTIL ONLY BLANKS LEFT
	POPJ	P,		;RETURN


;LSIXC -- LIST SIXBIT WORD FIXED NUMBER OF CHARACTERS
;CALL:	MOVE	T2,WORD
;	MOVEI	T3,NUM CHARS TO PRINT
;	PUSHJ	P,LSIXC
;USES T1, T2, T3, C

LSIXC:	MOVEI	T1,0		;CLEAR NEXT CHAR
	LSHC	T1,6		;GET NEXT CHAR
	PUSHJ	P,LCHRS		;LIST IT IN SIXBIT
	SOJG	T3,LSIXC	;LOOP UNTIL DONE
	POPJ	P,		;RETURN


;LSPC2 -- LIST TWO SPACES
;CALL:	PUSHJ	P,LSPC2
;USES C

LSPC4:	PUSHJ	P,LSPC
LSPC3:	PUSHJ	P,LSPC
LSPC2:	PUSHJ	P,LSPC		;DO ONE
	PJRST	LSPC		;DO ANOTHER AND RETURN
;SUBROUTINE CALLED FROM QMANGR TO LIST AN ERROR MESSAGE
;CALL WITH:
;	MOVE	16,CHAR.-TO-LIST
;	PUSHJ	P,@Q.MEM(1)
;	RETURN HERE
;
QMLCHR:	PUSH	P,C		;SAVE C
	MOVE	C,16		;COPY 16
	PUSHJ	P,LCHR		;LIST THE THING
	POP	P,C		;RESTORE C
	POPJ	P,		;RETURN


;LTAB -- LIST TAB
;LSPC -- LIST SPACE
;LCHR -- LIST CHARACTER
;LCHRS-- LIST SIXBIT CHARACTER
;CALL:	(MOVEI	C,CHARACTER    IF LCHR)
;	(MOVEI	T1,CHARACTER IF LCHRS)
;	PUSHJ	P,LTAB/LSPC/LCHR
;USES C EXCEPT LCHR USES NO AC'S

LCHRS:	MOVEI	C," "-' '(T1)	;CONVERT TO ASCII AND MOVE TO C
LCHR:	CAIE	C,.CHTAB	;SEE IF A TAB
	JRST	LCHR1		;NO--GO SEND IT

LTAB:	TRON	F,R.LTAB	;SET/TEST TAB
	POPJ	P,		;RETURN IF NOT TWO IN A ROW

LTAB1:	SKIPA	C,[.CHTAB]	;GET THE TAB
LSPC:	MOVEI	C," "		;GET THE SPACE

LCHR1:	TRZE	F,R.LTAB	;CLEAR TAB MEMORY
	JRST	LCHR2		;IF SET, GO ISSUE ONE
	SOSG	B.LC+2		;SEE IF ROOM IN THE BUFFER
	PUSHJ	P,LCHRW		;NO--GO WRITE THIS BUFFER
	IDPB	C,B.LC+1	;YES--SEND CHARACTER
	CAIG	C,.CHFFD	;SEE IF END OF LINE
	PUSHJ	P,LCHRWL	;YES--OUTPUT IT IF DESIRED
	POPJ	P,		;RETURN

LCHR2:	PUSH	P,C		;SAVE REQUESTED CHARACTER
	PUSHJ	P,LTAB1		;SEND A TAB
	POP	P,C		;RESTORE CHARACTER
	JRST	LCHR1		;PROCEED
;LCHRWL -- ROUTINE TO OUTPUT BUFFER AT END OF LINE IF NEEDED
;LCHRW  -- ROUTINE TO OUTPUT BUFFER ALWAYS
;LCHRWR -- ROUTINE TO REPORT ON TRANSFER ERRORS
;CALL:	PUSHJ	P,XXX
;RETURNS WHEN DONE
;USES NO AC

LCHRWL:	TRNE	F,R.OUTL	;SEE IF LINE MODE OUTPUT
LCHRW:	OUT	LC,		;OUTPUT BUFFER
	  POPJ	P,		;OK--RETURN

LCHRWR:	PUSH	P,T1		;ERROR--SAVE SOME ACS
	PUSH	P,T2		; ..
	PUSH	P,T3		; ..
	GETSTS	LC,T1		;GET ERROR STATUS
	MOVE	T2,T1		;PREPARE TO CLEAR
	ANDI	T2,37777	;  BY PRESERVING JUST
	SETSTS	LC,(T2)		;  THE CONTROL BITS
	OUTSTR	[ASCIZ /
% Listing device output error, status /]
	MOVE	T3,[POINT 3,T1,17]  ;SETUP FOR OCTAL TYPEOUT
LCHRWE:	ILDB	T2,T3		;GET DIGIT
	ADDI	T2,"0"		;CONVERT TO ASCII
	OUTCHR	T2		;TYPE IT
	TLNE	T3,(77B5)	;SEE IF DONE YET
	JRST	LCHRWE		;NO--LOOP
	OUTSTR	[ASCIZ /
/]				;NOTE--ALL THIS DONE HERE IN CASE
				;  WRONG SEGMENT IN CORE

	POP	P,T3		;RESTORE ACS
	POP	P,T2		; ..
	POP	P,T1		; ..
	POPJ	P,		;AND RETURN
	SUBTTL	SUBROUTINES FOR TTY OUTPUT

			;SWITCH TO HIGH SEG
	SWSEG


;FMSG -- ISSUE FATAL MESSAGE AND RESTART JOB
;CALL:	N.FAIL	<MESSAGE>
;CHANGES T1
;RESTORES P TO VIRGIN STATE
;JUMPS TO RESART

FMSG:	PUSHJ	P,.TERRP	;TYPE QUESTION MARK AND MESSAGE
	JRST	FMSGE		;GO FINISH UP

;FMSGN -- ISSUE FATAL MESSAGE WITH SIXBIT ARGUMENT FROM N
;CALL:	N.FAIN	<MESSAGE>
;CHANGES T1, T2
;RESTORES P TO VIRGIN STATE
;JUMPS TO RESTART

FMSGN:	MOVEI	T2,.TSIXN	;GET SIXBIT ROUTINE
	JRST	FMSGXE		;GO FINISH UP

;FMSGD -- ISSUE FATAL MESSAGE WITH DECIMAL ARGUMENT FROM N
;CALL:	N.FAID	<MESSAGE>
;CHANGES T1, T2, T3
;RESTORES P TO VIRGIN STATE
;JUMPS TO RESTART

FMSGD:	MOVEI	T2,.TDECW	;GET DECIMAL NUMBER ROUTINE
	JRST	FMSGXE		;GO FINISH UP
;FMSGO -- ISSUE FATAL MESSAGE WITH OCTAL ARGUMENT FROM N
;CALL:	N.FAIO	<MESSAGE>
;CHANGES T1, T2, T3
;RESTORES P TO VIRGIN STATE
;JUMPS TO RESTART

FMSGO:	MOVEI	T2,.TOCTW	;GET OCTAL NUMBER ROUTINE
				;FALL INTO FMSGXE

;HERE TO TYPE QUESTION MARK, TEXT AND ONE WORD (T2=ROUTINE TO DO IT)
FMSGXE:	PUSHJ	P,.TERRP##	;TYPE QUESTION AND TEXT
	MOVE	T1,N		;GET VALUE
	PUSHJ	P,(T2)		;TYPE IT
				;FALL INTO FMSGE


;FMSGE -- FINISH UP FATAL ERROR PROCESSING
;CALL:	JRST	FMSGE
;RESTORES P TO VIRGIN STATE
;JUMPS TO RESTART

FMSGE:	PUSHJ	P,.CLRBF##	;CLEAR OUT ANY TYPE-AHEAD
	PUSHJ	P,.TCRLF	;SEND CR/LF
	PUSHJ	P,.TCRLF	;SEND ANOTHER
	MOVE	P,[IOWD LN.PDL,PDLST]  ;RESTORE PUSH-DOWN LIST
	JRST	QUELOP		;GO START OVER


;.TNEWL -- FORCE NEW LINE
;NOT NEEDED IN THIS PACKAGE

.TNEWL==.POPJ
	SUBTTL	STORAGE

	XLIST		;LITERALS
	LIT
	LIST

			;SWITCH TO LOW SEG
	SWSEG

	IFL	.-LN.KJL,<BLOCK LN.KJL+..STRL-.>  ;MAKE ROOM FOR KJOB
LOWFWA:!		;START OF LOW DATA AREA
MYPPN:	BLOCK	1	;PROJECT PROGRAMMER NUMBER OF THIS JOB
SAVCOR:	BLOCK	1	;INITIAL VALUE OF LOW SEG CORE SIZE
KJBDAT:	BLOCK	1	;KJOB: XWD .JBFF,.JBREL
NOW:	BLOCK	1	;CURRENT SYSTEM DATE/TIME
JOBN:	BLOCK	1	;THIS JOB'S NUMBER
CENTRL:	BLOCK	1	;LOCATION OF CENTRAL STATION (0 IF NO REM CODE)
HERE:	BLOCK	1	;LOCATION OF THIS JOB
HERESX:	BLOCK	1	;SIXBIT SNN				[1206]
STRTOF:	BLOCK	1	;STARTING ADDRESS OFFSET
KJOBPC:	BLOCK	1	;PC TO RETURN TO KJOB (ACTUALLY, PDL POINTER)
KJOBPT:	BLOCK	1	;KJOB CALL ARGUMENT LIST POINTER
KJBVQU:	BLOCK	1	;QUEUE REQUEST FILE NAME CONTAINING LOG FILE
KJBVEX:	BLOCK	1	;EXTENSION AND FLAGS

KJBARG:!		;BLOCK OF KJOB ARGUMENTS
KJOBXX:	BLOCK	1	;FORMAT WORD
KJBADV:	BLOCK	1	;DEVICE FOR LOG FILE
KJBADR:	BLOCK	.FXLND	;DIRECTORY
KJBANM:	BLOCK	1	;NAME
KJBAEX:	BLOCK	1	;EXTENSION AND FLAGS
KJBLIM:	BLOCK	2	;OUTPUT QUEUE LIMITS
KJBPRM:	BLOCK	1	;MISC. PARAMETERS
KJBSEQ:	BLOCK	1	;SEQUENCE NUMBER
KJBTYP:	BLOCK	1	;LH=ADDRESS OF ROUTINE TO NOTIFY OF NEW LOCATION OF LOG FILE
			;RH=ADDRESS OF TYPE CHARACTER ROUTINE
EKJBRG==.-1

DFRNAM:	BLOCK	1	;NAME OF DEFERAL FILE
DEFPRT:	BLOCK	1	;DEFAULT FILE PROTECTION FROM MONITOR
KJBQUE:	BLOCK	1	;COUNTER FOR KJOB'S AUTO QUEUEING
KNXQUE:	BLOCK	1	;INDEX OF NEXT PASS'S AUTO QUEUE
MFDPPN:	BLOCK	1	;LOCATION OF UFDS

ISARG:	BLOCK	2	;FUDGE TO SET UP TYPEOUT ADDRESS   ;;;;;;KEEP
TYPER:	BLOCK	2	;ADDRESS OF TYPE CHARACTER ROUTINE ;;;;;;IN
MONRTR:	BLOCK	1	;ADDRESS OF MONRET ROUTINE	   ;;;;;;ORDER

INTBLK:	BLOCK	4	;BLOCKFOR ^C INTERCEPT

STATAB:	BLOCK	1+<77/^D36>	;BITS FOR STATIONS 0-77
	BLOCK	1+<777/^D36>	;BITS FOR DEVICES 0-777
ESTATB==.-1
ZCOR:!			;START OF AREA TO ZERO ON INITIAL LOAD

PDLST:	BLOCK	LN.PDL+1  ;PUSH-DOWN LIST
OPNBLK:	BLOCK	3	;OPEN BLOCK

LKBLK:	BLOCK	1	;EXTENDED LOOKUP BLOCK
RIBPPN:	BLOCK	1	;DIRECTORY
RIBNAM:	BLOCK	1	;FILE NAME
RIBEXT:	BLOCK	1	;FILE EXTENSION
RIBPRV:	BLOCK	1	;PROTECTION WORD
RIBSIZ:	BLOCK	1	;FILE SIZE
	BLOCK	1	;JUNK
RIBSPL:	BLOCK	1	;SPOOLING NAME
	BLOCK	6	;JUNK
RIBDEV:	BLOCK	1	;LOCATION OF FILE (LOGICAL UNIT)
LKBLKL==.-LKBLK


P.ZER:!			;START OF AREA FOR FILE DEFAULTS
P.MOD:	BLOCK	1	;LAST STICKY FILE SWITCHES TYPED BY USER
P.MODM:	BLOCK	1	;LAST STICKY FILE SWITCHES MASK TYPED BY USER
P.EZER==.-1
P.MIN:!
P.STRT:	BLOCK	1	;LAST STICKY FILE STARTING POINT
P.RPT:	BLOCK	2	;REPORT NAME
P.EMIN==.-1

F.ZER:!			;START OF AREA FOR FILE TYPE-INS
F.MOD:	BLOCK	1	;FILE SWITCHES
F.MODM:	BLOCK	1	;FILE SWITCH MASK (ON IF TYPED)
F.EZER==.-1
F.MIN:!
F.STRT:	BLOCK	1	;FILE STARTING POINT
F.RPT:	BLOCK	2	;/REPOR KEY
F.EMIN==.-1
;WARNING--THIS TABLE IS PARALLELED BY SWDEFT

S.MIN:!			;START OF AREA FOR COMMAND ACCUMULATION
S.AFT:	BLOCK	1	;AFTER PARAMETER
S.CNO:	BLOCK	1	;CHARGE NUMBER
S.COR:	BLOCK	1	;CORE LIMIT
S.DED:	BLOCK	1	;DEADLINE PARAMETER
S.DPN:	BLOCK	1	;INITIAL DEPENDENCY COUNT
S.FAST:	BLOCK	1	;FAST LIST
S.FRM:	BLOCK	1	;FORMS REQUEST
S.LCDP:	BLOCK	1	;CARD PUNCH LIMIT
S.LIM:	BLOCK	1	;OUTPUT LIMIT
S.LIST:	BLOCK	1	;DEGREE OF LISTING
S.LLPT:	BLOCK	1	;PRINTER LIMIT
S.LPLT:	BLOCK	1	;PLOT LIMIT
S.LPTP:	BLOCK	1	;PAPER TAPE LIMIT
S.LTIM:	BLOCK	1	;TIME LIMIT
S.NOT:	BLOCK	2	;ANNOTATION
S.NULL:	BLOCK	1	;NULL REQUEST OK
S.OPN:	BLOCK	1	;REQUESTED OPERATION
QO.CRE==1		;CREATE
QO.DEF==2		;DEFER
QO.ZDF==3		;ZDEFER
QO.LST==4		;LIST
QO.MOD==5		;MODIFY
QO.KIL==6		;KILL
QO.FST==12		;FAST LIST

S.OUT:	BLOCK	1	;DEGREE OF OUTPUT QUEUEING
S.PRI:	BLOCK	1	;EXTERNAL PRIORITY
S.RSTR:	BLOCK	1	;RESTARTABLE
S.SEQ:	BLOCK	1	;SEQUENCE NUMBER OF JOB
S.UNIQ:	BLOCK	1	;DEGREE OF FILE NAME UNIQUENESS NEEDED
S.EMIN==.-1
IFN  .-S.MIN-LN.SM,<PRINTX ? SWDEFT AND S.MIN TABLES DON'T MATCH>

S.ZER:!
QUTYPL:	BLOCK	1	;QUETYP ROUTINE OUTPUT LAST CALL
QUTYPF:	BLOCK	1	;QUETYP ROUTINE FOUND AND ANSWER FLAG

DEFFIL:	BLOCK	.FXLEN		;/PATH:[DIRECTORY]
DEFDIR=DEFFIL+.FXDIR
MX.PTH==.FXLEN
PD.PTH==0
O.ZER:!			;START OF OUTPUT SPEC STORAGE
O.DEV:	BLOCK	1	;DEVICE
O.NAM:	BLOCK	1	;NAME
O.NAMM:	BLOCK	1	;NAME MASK
O.EXT:	BLOCK	1	;EXT,,MASK
O.MOD:	BLOCK	1	;SCAN SWITCHES
O.MODM:	BLOCK	1	;SCAN SWITCH MASK
O.DIR:	BLOCK	1	;DIRECTORY
O.DIRM:	BLOCK	2*.FXLND-1	;DIRECTORY MASK
O.LZER==.-O.ZER

L.OPEN:	BLOCK	3	;OPEN BLOCK
L.LOOK:	BLOCK	6	;LOOKUP BLOCK
PTHFCN:	BLOCK	.PTMAX	;PATH. ARGS
PTHPPN=PTHFCN+.PTPPN

PTFFCN:	BLOCK	.PTMAX		;FILE PATH BLOCK
PTFPPN=PTFFCN+.PTPPN


I.INZR:	BLOCK	1	;INITIAL INPUT SPEC STORAGE
I.NXZR:	BLOCK	1	;POINTER TO NEXT INPUT SPEC STORAGE
I.LSZR:	BLOCK	1	;POINTER TO LAST INPUT SPEC STORAGE
S.EZER==.-1

	LOC	0
	BLOCK	.FXLEN	;SCAN'S AREA
I.MOD:!	BLOCK	1	;SWITCHES
I.MODM:!BLOCK	1	;SWITCH MASK (ON IF USER SUPPLIED)
I.STRT:!BLOCK	1	;FILE STARTING POINT
I.RPT:!	BLOCK	2	;/REPORT SWITCH
I.LZER:!
	RELOC	S.EZER+1
	LOC	0	;DEFINE QUEUE AREA (RELOCATABLE)
Q.ZER:!			;START OF QUEUE PARAMETER AREA
Q.MEM:!	BLOCK	1	;USED FOR CHARACTER TYPER
Q.OPR:!	BLOCK	1	;OPERATION CODE
Q.LEN:!	BLOCK	1	;LENGTHS IN AREA
Q.DEV:!	BLOCK	1	;DESTINATION DEVICE
Q.PPN:!	BLOCK	1	;PPN ORIGINATING REQUEST
Q.JOB:!	BLOCK	1	;JOB NAME
Q.SEQ:!	BLOCK	1	;JOB SEQUENCE NUMBER
Q.PRI:!	BLOCK	1	;EXTERNAL PRIORITY
Q.PDEV:!BLOCK	1	;PROCESSING DEVICE
Q.TIME:!BLOCK	1	;PROCESSING TIME OF DAY  (PPN MASK ON MODIFY)
Q.CREA:!BLOCK	1	;CREATION TIME  (JOB NAME MASK ON MODIFY)
Q.AFTR:!BLOCK	1	;AFTER PARAMETER
Q.DEAD:!BLOCK	1	;DEADLINE TIME
Q.CNO:!	BLOCK	1	;CHARGE NUMBER
Q.USER:!BLOCK	2	;USER'S NAME

Q.I:!			;START OF INPUT QUEUE AREA
Q.IDEP:!BLOCK	1	;DEPENDENCY WORD
			;    0: /RESTARTABLE
			;  1-2: 1+/UNIQUE
			;    3: 1 IF /MODIFY/RESTARTABLE
			;  4-5: (FUTURE)
			;  6-8: /OUTPUT
			; 9-17: (FUTURE)
			;18-19: TYPE OF /DEPENDENCY
			;	0  ABSOLUTE
			;	1  +
			;	2  -
			;	3  NO CHANGE
			;20-35: /DEPENDENCY VALUE
Q.ILIM:!BLOCK	3	;JOB LIMITS
Q.IDDI:!BLOCK	.FXLND	;JOB'S DIRECTORY
Q.II:!			;START OF FILE AREA
Q.ILEN==.-Q.ZER

	LOC	Q.I
Q.O:!			;START OF OUTPUT QUEUE AREA
Q.OFRM:!BLOCK	1	;FORMS REQUEST
Q.OSIZ:!BLOCK	1	;LIMIT WORD
Q.ONOT:!BLOCK	2	;ANNOTATION
Q.FF:!
	PHASE	0
Q.F:!			;DUPLICATED AREA FOR EACH REQUESTED FILE
Q.FSTR:!BLOCK	1	;FILE STRUCTURE
Q.FDIR:!BLOCK	.FXLND	;ORIGINAL DIRECTORY
Q.FNAM:!BLOCK	1	;ORIGINAL NAME
Q.FEXT:!BLOCK	1	;ORIGINAL EXTENSION
Q.FRNM:!BLOCK	1	;RENAMED FILE NAME (0 IF NOT)
Q.FBIT:!BLOCK	1	;BIT 0=PRESERVED BY QUEUE, REST=STARTING BIT
Q.FMOD:!BLOCK	1	;FILE SWITCHES
Q.FLEN==.-Q.F
Q.FRPT:!BLOCK	2	;/REPORT KEY
Q.FRPL==.-Q.F
Q.FDRM:!BLOCK	.FXLND	;DIRECTORY MASK
Q.FNMM:!BLOCK	1	;FILE NAME MASK
Q.FEXM:!BLOCK	1	;FILE EXT MASK
Q.FMDM:!BLOCK	1	;MODIFIER MASK
Q.FLNM==.-Q.F
	DEPHASE
	BLOCK	<30-1>*Q.FRPL
Q.EZER==.-1
	RELOC	S.EZER+1
T.ZER:!			;START OF TEMPORARY DATA AREA
NOBLKS:	BLOCK	1	;ACCUMULATED NUMBER OF BLOCKS TO BE PROCESSED
PRODEV:	BLOCK	1	;PHYSICAL NAME OF PROCESSING DEVICE
CREFLG:	BLOCK	1	;FLAG 0 IF CREATE, -1 IF NOT
DQTYPE:	BLOCK	1	;WORD TO STORE OUTPUT QUEUE TYPE
			; FOR SUBMIT,PUNCH ...
LOGCNT:	BLOCK	1	;COUNT DOWN TO LOG FILE
T.EZER:!


;BUFFER POINTERS
B.LC:	BLOCK	3	;LISTING FILE

SAVEF:	BLOCK	1	;F SAVED HERE DURING LISTING PASSES
SAVEI:	BLOCK	1	;I SAVED HERE DURING LISTING PASSES
SAVEQ:	BLOCK	1	;Q SAVED HERE DURING LISTING PASSES
LSTA:	BLOCK	1	;STATION TO MATCH IN LISTING
ONEQUE:	BLOCK	1	;NAME OF DEVICE IN QUEUE


EZCOR==.-1		;END OF AREA TO ZERO

	END	QUEUE