Google
 

Trailing-Edge - PDP-10 Archives - BB-H311C-RM - swskit-utilities/swserr.mac
There are 4 other files named swserr.mac in the archive. Click here to see a list.
	TITLE	SWSERR	PRODUCE COMPACT LISTING OF BUGXXX ERRORS
	SUBTTL	J. G. ZIMA/JGZ   MAY 1980

	SEARCH	MACSYM,MONSYM	;GET SYMBOLS
	SEARCH	SERCOD		;GET SYSERR SYMBOLS
	SEARCH	ZSUBS		;GET THE SUBROUTINE PACKAGE
	.REQUIRE ZSUBS.REL	;GET THE ZSUBS CODE
	SALL			;NICE LOOKING MACROS
	.DIRECT	FLBLST		;AND NICE LISTING


;VERSION INFORMATION:


	VMAJOR==1		;MAJOR VERSION LEVEL
	VMINOR==0		;MINOR VERSION LEVEL
	VEDIT==33		;EDIT LEVEL
	VWHO==0			;WHO LAST EDITED




;SWSERR IS A PRODUCT OF THE MONITOR SUPPORT GROUP OF SOFTWARE SERVICES,
;PRIMARILY FOR INCLUSION ON THE TOPS-20 MONITOR SWSKIT.  THE PURPOSE
;OF THE PROGRAM IS TO PROVIDE A "CONCISE" LISTING OF SYSTEM SOFTWARE
;ERRORS, IN LIEU OF SYSERR.
;
;RELATED FILES:
;	SWSERR.MAC	THIS FILE
;	ZSUBS.UNV	COMND/LUUO PACKAGE UNIVERSAL
;	ZSUBS.REL	COMND/LUUO PACKAGE CODE
;	SERCOD.UNV	SYSERR SYMBOLS UNIVERSAL
	SUBTTL	TABLE OF CONTENTS


;	TABLE OF CONTENTS					  PAGE
;	-----------------					  ----
;
;  1. J. G. ZIMA/JGZ   MAY 1980. . . . . . . . . . . . . . . . . .   1
;  2. TABLE OF CONTENTS. . . . . . . . . . . . . . . . . . . . . .   2
;  3. REVISION HISTORY . . . . . . . . . . . . . . . . . . . . . .   3
;  4. COMMAND SCANNER AND INITIALIZATION . . . . . . . . . . . . .   6
;  5. HELP COMMAND TEXT. . . . . . . . . . . . . . . . . . . . . .   8
;  6. WHAT COMMAND TO SHOW PARAMETER SETTINGS. . . . . . . . . . .   9
;  7. INCLUDE COMMAND TO VARY LISTING. . . . . . . . . . . . . . .  11
;  8. IGNORE COMMAND TO MODIFY LISTING FORMAT. . . . . . . . . . .  12
;  9. TIME COMMAND TO SET TIME RANGE . . . . . . . . . . . . . . .  13
; 10. READ COMMAND TO SPECIFY ALTERNATE INPUT FILE . . . . . . . .  14
; 11. LIST COMMAND TO DO IT. . . . . . . . . . . . . . . . . . . .  15
; 12. THE MAIN PROCESSING LOOP . . . . . . . . . . . . . . . . . .  16
; 13. ENTRY INPUT AND VALIDATION ROUTINES. . . . . . . . . . . . .  20
; 14. OUTPUT CONVERSION ROUTINES . . . . . . . . . . . . . . . . .  26
; 15. PAGE HEADER PRINTING ROUTINE . . . . . . . . . . . . . . . .  27
; 16. SUMMARY PRINTING ROUTINE . . . . . . . . . . . . . . . . . .  28
; 17. THE DATA AREA. . . . . . . . . . . . . . . . . . . . . . . .  31
	SUBTTL	REVISION HISTORY

;REVISION HISTORY:
;
;   1	JGZ	7-MAY-80
;		BEGIN KEEPING REVISION HISTORY FROM NOW ON.
;
;   2	JGZ	7-MAY-80
;		ADD "YES" AND "NO" TABLES AND THEIR INITIALIZATION, SO
;		THAT THEY CAN BE USED TO "INCLUDE J0NRUN", OR TO DO A
;		"INCLUDE NO DN20ST" WITH A FEW MORE EDITS.
;		ADD ROUTINES TO SEARCH BOTH THE TABLES FOR A MATCH
;		AND CALL THEM FROM THE PROCESSING LOOP.  STILL HAVE TO
;		CHANGE THE COMMAND PARSING AND FILL THE TABLES.
;
;   3	JGZ	7-MAY-80
;		ADD A SINGLE LEVEL JFN STACK TO KEEP UNUSED JFNS FROM
;		PILING UP ON REPARSE ERRORS.
;
;   4	JGZ	8-MAY-80
;		PUT IN THE CODE TO PARSE SPECIFIC BUGNAMES IN THE
;		INCLUDE COMMAND.
;
;   5	JGZ	8-MAY-80
;		DISCOVERED A V4 COMND BUG.  WON'T PARSE THE STRING
;		"INCLUDE NO BUGNAME" UNLESS YOU ESC AFTER THE NO.
;		DECIDES TO DO INCLUDE OF "NO BUG".  HAS SOMETHING
;		TO DO WITH DEFAULT STRING ALSO.  SO CHANGED TO HAVE
;		NO DEFAULT STRING, AND TO REQUIRE BUGNAME BE QUOTED
;		UNTIL COMND FIXED AT LEAST.
;
;   6	JGZ	10-MAY-80
;		DECIDED TO ALLOW POSSIBLY WILD BUGNAMES IN INCLUDE
;		COMMAND, WHICH MEANS REWRITE OF ALL THE INCLUDE
;		STUFF.  GO ASCIZ ALL THE WAY WITH THE NON-INCLUDE PARTS.
;
;   7	JGZ	11-MAY-80
;		PRETTY UP LISTING, ADD TABLE OF CONTENTS, IMPROVE HELP
;		TEXT.
;
;  10	JGZ	14-MAY-80
;		PRETTY UP WHAT COMMAND OUTPUT BY PADDING IGNORE OUTPUT
;		WITH BLANKS IN "NO" POSITION.
;
;  11	JGZ	16-MAY-80
;		ON SECOND THOUGHT, TRAP AND NOTE ALL DIRST ERRORS IN PROCLP.
;
;  12	JGZ	26-JUN-80
;		TIME TO SUMMARY LINE, DO IGNORE COMMAND TO GET RID OF
;		QUOTED BUG NAMES, CLEANUP HELP TEXT, BEGIN CODE TO READ
;		BUGSTRINGS.TXT.
;
;  13	JGZ	26-JUN-80
;		COMPLETE CODE FOR READING SYSTEM:BUGSTRINGS.TXT FOR THOSE
;		BUG MESSAGES NOT IN SYSERR BLOCK: SLOW BUT EFFECTIVE.
;
;  14	JGZ	26-JUN-80
;		"FINAL" LISTING CLEANUP AND NEW TABLE OF CONTENTS.
;
;  15	JGZ	28-JUN-80
;		BETTER ERROR HANDLING FOR GETMSG ROUTINE, BKJFN STUFF
;		TO PROCLP CODE TOO...
;
;  16	JGZ	16-JAN-81
;		MAKE IT TYPE OUT THE VERSION NUMBER ON STARTUP.
;
;  17	JGZ	22-MAR-81
;		CONVERT FOR USE WITH THE ZSUBS PACKAGE.
;
;  20	JGZ	23-MAR-81
;		ADJUST SOME FOR THE POINT AFTER DECIMAL NUMBERS.
;
;  21	JGZ	31-MAY-81
;		REMOVE WIDTH PARAMETER FROM PAGE NUMBER OUTPUT; SOMETIMES
;		THERE ARE REALLY LOTS OF PAGES...
;
;  22	JGZ	23-JUN-81
;		PUT IN A .REQUIRE FOR THE ZSUBS CODE.
;
;  23	JGZ	23-JUN-81
;		FOR RELEASE 5 ERROR.SYS MOVES TO PS:<SYSTEM-ERROR>.
;
;  24	JGZ	24-JUN-81
;		CHANGE SUMMARY FORMAT LINES TO INCLUDE BUG TYPE.
;
;  25	JGZ	26-JUL-81
;		CHANGE DEFSTR FOR HDRVER, RELEASE 5 REDEFINES THE FIELD.
;
;  26	JGZ	29-JUL-81
;		JFNTMP IS IN ZSUBS NOW.
;
;  27	JGZ	9-AUG-81
;		"NO MESSAGE AVAILABLE..." NEEDS ADJUSTING.
;
;  30	JGZ	25-NOV-81
;		USE WARN AND ERROR UUOS A FEW PLACES WHERE APPROPRIATE
;
;  31	JGZ	4-JAN-82
;		CHANGE LIST PROCESSING USE OF OJFN SOME TO GIVE BETTER
;		ERRORS WHEN TROUBLE OCCURS.
;
;  32	JGZ	24-JAN-82
;		TEXT MACRO HAS MOVED TO ZSUBS.
;
;  33	JGZ	28-JAN-82
;		USE NEW ZSUBS FILESPEC OUTPUT LUUO, TYPJFN.
;
;DEFAULT PARAMETERS:


	PAGSIZ==^D54		;NUMBER OF LINES/PAGE
	SUMSIZ==^D100		;NUMBER OF ENTRIES ALLOWED IN SUMMARY TABLE



;CONSTANTS:


	HF.ERR==377		;ENTRY TYPE INDICATION ERROR IN FILE
	HF.EOF==777		;ENTRY TYPE INDICATING END-OF-FILE
	HF.T20==1B17		;ENTRY HEADER BIT FOR TOPS-20
	HF.VER==1		;SYSERR VERSION WE KNOW ABOUT
	HDRDAT==1		;OFFSET TO DATE-TIME WORD



	.CHSPC==40		;**;SPACE CHARACTER UNTIL IN MACSYM


;FLAGS:


	FL%TIM==1B0		;CHECK ENTRIES FOR TIME RANGE
	FL%CHK==1B1		;INCLUDE BUGCHKS
	FL%INF==1B2		;INCLUDE BUGINFS
	FL%HLT==1B3		;INCLUDE BUGHLTS
	FL%IFS==1B4		;INPUT FILE SPECIFIED
	FL%FDO==1B7		;FORCE DATE OUTPUT AT START OF PAGE
	FL%OFO==1B8		;OUTPUT FILE IS OPEN
	FL%NOF==1B9		;"NO" FLAG FOR "NO" SEEN


;MACROS, OPDEFS, AND DEFSTRS:



	DEFSTR	HDRLEN,HDRWRD,26,3	;HEADER LENGTH FIELD
	DEFSTR	ENTLEN,HDRWRD,35,9	;ENTRY LENGTH FIELD
	DEFSTR	HDRCOD,HDRWRD,8,9	;ENTRY TYPE CODE
	DEFSTR	HDRVER,HDRWRD,23,3	;VERSION LEVEL

	DEFSTR	BUGPI,BUGPIS,27,7	;PI LEVEL IN CONI PI, WORD
	SUBTTL	COMMAND SCANNER AND INITIALIZATION




EVEC:	JRST	SWSERR		;START
	JRST	REEN		;REENTER
	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT	;VERSION


SWSERR:	RESET			;CLEAR EVERYTHING
	$INIT			;INIT THE ZSUBS PACKAGE
	TYPE	<SWSERR BUGxxx LISTER %>
	SETZM	OJFN		;NO OUTPUT JFN YET
	VERSIO	EVEC+2		;OUTPUT THE VERSION NUMBER
	TYPE	<

>				;AND SPACE DOWN
REEN:	MOVE	P,[IOWD PDLSIZ,PDL]	;SET UP A STACK
	TXZ	F,FL%FDO!FL%OFO	;INITIALIZE FLAGS
	TXO	F,FL%HLT!FL%CHK!FL%INF ;INCLUDE EVERYTHING
	SETZM	NAMTAB		;CLEAR INCLUDE NAME TABLE


NEWCMD:	HRROI	T1,[ASCIZ/SWSERR>/] ;PROMPT
	MOVEM	T1,CMDBLK+.CMRTY ;SET IT UP
	MOVEI	T1,NEWPAR	;SETUP REPARSE ADDRESS
	HRRM	T1,CMDBLK+.CMFLG ;IN THE COMND BLOCK
	PARSE	[FLDDB. .CMINI]	;INITIALIZATION FUNCTION
	MOVEM	P,SAVEP		;SAVE STACK FOR REPARSING
	JRST	NEWPAR		;AND PARSE A NEW COMMAND


PARERR:	JRST	REEN		;REENTER ON LOSE-TYPE ERROR
NEWPAR:	MOVE	P,SAVEP		;RESTORE THE STACK TO KNOWN STATE
	SKIPE	T1,JFNTMP	;CLEAN UP ANY STACKED JFNS
	RLJFN			; FROM REPARSING
	 ERJMP	.+1		;IGNORE THIS CASE
	SETZM	JFNTMP		;AND MARK JFN FREED
	PARSE	[FLDDB. (.CMKEY,,CMDTAB)] ;PARSE FROM COMMAND TABLE
	MOVE	T2,(T2)		;GET ADDRESS OF ROUTINE
	CALL	(T2)		;CALL IT
	JRST	NEWCMD		;AND GET A NEW COMMAND

;TABLE OF COMMANDS:


CMDTAB:	CMDLEN,,CMDLEN			;HEADER
	AA	EXIT,.EXIT		;EXIT COMMAND
	AA	HELP,.HELP		;TYPE HELP MESSAGE
	AA	IGNORE,.IGNOR		;IGNORE STUFF
	AA	INCLUDE,.INCLU		;INCLUDE STUFF
	AA	LIST,.LIST		;SET UP OUTPUT SPEC
	AA	PUSH,.PUSH		;PUSH TO A NEW EXEC
	AA	READ,.READ		;SET UP INPUT SPEC
	AA	TAKE,.TAKE		;TAKE COMMANDS FROM FILE
	AA	TIME,.TIME		;SET BEGIN AND END TIMES
	AA	WHAT,.WHAT		;WHAT ARE SWITCH SETTINGS

	CMDLEN==.-CMDTAB-1		;NUMBER OF COMMANDS
	SUBTTL	HELP COMMAND

.HELP:	NOISE	(WITH COMMANDS)	;GUIDEWORDS
	CONFRM			;CONFIRM THE COMMAND
	TYPE.	HLPTXT		;OUTPUT THE MESSAGE
	RET			;AND ALL DONE


HLPTXT:TEXT	<


     SWSERR is a program designed to produce a compact  listing  of  the
BUGxxx   errors   recorded  in  a  SYSERR-format  ERROR.SYS  file.   The
information provided is date and time,  bug-type,  bug-name,  fork,  job
and  user  number,  program  name,  PI levels active, and username.  The
listing format can include or suppress the various bug-types.  The input
file  may be specified if desired, and a time range selected.  The final
summary  counts  the  occurances  of  each  BUGxxx  and   includes   the
informational bug-string if available.

     The commands are:

        EXIT            Exit from the program
        HELP            Type this text
        INCLUDE         Specify inclusion of BUGHLTs, BUGCHKs,
				and BUGINFs or specific,
				possibly wild, BUG names
        IGNORE          Specify exclusion of BUGHLTs, BUGCHKs,
				and BUGINFs or specific,
				possibly wild, BUG names
        LIST            Specify output file and begin processing
                                May be aborted with ^E
        PUSH            Push command level to a new EXEC
        READ            Specify alternate input ERROR.SYS format file
        TAKE            Take commands from specified file
        TIME            Set begin and end times for searching input
        WHAT            Tell current parameter settings

[End of SWSERR.HLP]

>
	SUBTTL	WHAT COMMAND TO SHOW PARAMETER SETTINGS

;WHAT COMMAND TO TELL SWITCH SETTINGS


.WHAT:	NOISE	(ARE PARAMETER SETTINGS)	;DO GUIDEWORDS
	CONFRM			;CONFIRM IT
CMDWH3:	TXNN	F,FL%TIM	;RANGES OF TIME?
	 JRST	CMDWH4		;NOT SET
	TYPE	<
Time Settings:	Begin: >	;SET--TYPE THEM
	MOVEI	T1,.PRIOU
	MOVE	T2,BGNTIM
	SETZ	T3,
	ODTIM
	 ERJMP	LOSE
	TYPE	<
		End:   >	;AND END VALUE
	MOVEI	T1,.PRIOU
	MOVE	T2,ENDTIM
	SETZ	T3,
	ODTIM
	 ERJMP	LOSE
	JRST	CMDWH5		;AND CONTINUE

CMDWH4:	TYPE	<
No Time Range Set>		;SAY NONE SET
CMDWH5:	TXNE	F,FL%IFS	;CHECK INPUT FILE SETUP
	 JRST	CMDWH6		;ONE SPECIFIED
	TYPE	<
Default Input Error File>	;NOT SET UP
	JRST	CMDWH7		;AND CONTINUE

CMDWH6:	TYPE	<
Input Error File Specified: >	;PREFIX
	HRROI	T1,JFNSTR	;POINT TO FILENAME STRING
	PSOUT			;TYPE IT
	 ERJMP	LOSE

	;...
CMDWH7:	TYPE	<
Listing includes:>		;FIRST PART
	TXNE	F,FL%HLT	;HLTS?
	 TYPE	<  BUGHLTs>	;YUP
	TXNE	F,FL%CHK	;CHKS?
	 TYPE	<  BUGCHKs>	;YES
	TXNE	F,FL%INF	;INFS?
	 TYPE	<  BUGINFs>	;YES
	TXNN	F,FL%HLT!FL%CHK!FL%INF ;SEE IF ANY
	 TYPE	<  Summary listing> ;JUST THE SUMMARY
	SKIPN	NAMTAB		;IF NO NAMES SET, THEN
	 RET			;RETURN
	MOVN	P1,NAMTAB	;BUILD AN
	HRLZ	P1,P1		;AOBJN POINTER
	HRRI	P1,NAMTAB+1	;TO INCLUDE STRINGS
CMDWLP:	MOVEI	T2,1		;CHECK "NO" FLAG
	TDNE	T2,0(P1)	; IN B35 OF FIRST WORD OF STRING
	TYPE	<
  INCLUDE >			;"YES"
	TDNN	T2,0(P1)	; IN B35 OF FIRST WORD OF STRING
	TYPE	<
  IGNORE  >			;NO FLAG IS SET
	TYPE.	0(P1)		;OUTPUT THE STRING
	AOS	P1		;BUMP FOR TWO WORD ENTRY
	AOBJN	P1,CMDWLP	;LOOP TIL DONE
	RET			;DONE
	SUBTTL	INCLUDE COMMAND TO VARY LISTING

;INCLUDE COMMAND TO MODIFY LISTING FORMAT FOR INCLUSION


.INCLU:	NOISE	(IN LISTING)	;PROCESS GUIDEWORDS
	TXZ	F,FL%NOF	;CLEAR "NO" FLAG
CMDINL:	PARSE	[FLDDB. (.CMKEY,,INCTAB,,,[
		FLDDB. (.CMTXT,CM%SDH,,<Specific BUG name>)])]
	TSC	T3,T3		;SEE WHICH BLOCK WAS USED
	JUMPN	T3,GETSTR	;IT WAS THE SPECIFIC NAME ONE...
	HRRZ	P1,(T2)		;GET CODE RETURNED
	CONFRM			;CONFIRM THE COMMAND
	TXNE	F,FL%NOF	;"NO" FLAG SET?
	ADDI	P1,4		;YUP, ADJUST TABLE INDEX
	XCT	INCXCT(P1)	;ADJUST LISTING BITS
	RET			; AND ALL DONE HERE


;HERE TO PICK UP A SPECIFIC BUGNAME AND STORE IN NAMTAB

GETSTR:	MOVE	T2,[POINT 7,ATMBUF]	;POINTER TO INPUT
	MOVE	T1,NAMTAB	;GET FIRST FREE
	IMULI	T1,2		;FOR TWO WORD ENTRIES
	ADDI	T1,NAMTAB+1		;AND OFFSET FOR COUNT
	MOVE	T4,T1		;COPY TO T4 FOR LATER
	HRLI	T1,(POINT 7,)	;FINALLY BUILD BYTE POINTER
	MOVEI	P1,6		;COUNTER, SIX CHARS MAX
STRL:	ILDB	T3,T2		;GET NEXT BYTE
	JUMPE	T3,STRFIN	;GO ON ENDING NULL
	CAIE	T3,.CHSPC	;SPACE?
	CAIN	T3,.CHTAB	; OR TAB?
	 JRST	STRL		;YUP, SKIP IT
	IDPB	T3,T1		;STORE
	SOJG	P1,STRL		;ONLY TAKE SIX
STRFIN:	SETZ	T3,		;TERMINATE WITH NULL
	IDPB	T3,T1		;TO END STRING
	MOVEI	T2,1		;USING 1B35 TO HOLD YES/NO
	ANDCAM	T2,0(T4)	;CLEAR
	TXNE	F,FL%NOF	;TEST FLAG
	IORM	T2,0(T4)	;"NO", SET NO FLAG
	CONFRM			;CONFIRM THE LINE
	AOS	NAMTAB		;ALLOCATE THE ENTRY, IT'S REAL
	RET			;AND RETURN
	SUBTTL	IGNORE COMMAND TO MODIFY LISTING FORMAT

;IGNORE COMMAND TO EXCLUDE CATEGORIES OR SPECIFICS FROM LISTING

.IGNOR:	NOISE	(IN LISTING)	;DO GUIDEWORDS
	TXO	F,FL%NOF	;SET "NO" FLAG
	CALLRET	CMDINL		;AND DO THE WORK IN COMMON CODE WITH INCLUDE



INCTAB:	INCLEN,,INCLEN
	AA	ALL,0		;INCLUDE EVERYTHING
	AA	BUGCHKS,1
	AA	BUGHLTS,2
	AA	BUGINFS,3
	INCLEN==.-INCTAB-1


INCXCT:	CALL [	TXO	F,FL%HLT!FL%CHK!FL%INF	;INCLUDE ALL
		SETZM	NAMTAB	;CLEAR INCLUDE TABLE
		RET]		;DONE
	TXO	F,FL%CHK
	TXO	F,FL%HLT
	TXO	F,FL%INF
	CALL [	TXZ	F,FL%HLT!FL%CHK!FL%INF	;EXCLUDE ALL
		SETZM	NAMTAB	;CLEAR INCLUDE TABLE
		RET]		;DONE
	TXZ	F,FL%CHK
	TXZ	F,FL%HLT
	TXZ	F,FL%INF
	SUBTTL	TIME COMMAND TO SET TIME RANGE

;TIME COMMAND TO SET BEGIN AND END THRESHOLDS


.TIME:	NOISE	(TO START LISTING ENTRIES) ;PROCESS GUIDEWORDS
	PARSE	[FLDDB.(.CMCFM,,,,,[FLDDB.(.CMTAD,,CM%IDA+CM%ITM,,,[
		FLDDB.(.CMTAD,,CM%IDA,,,[FLDDB.(.CMTAD,,CM%ITM)])])])]
	TSC	T3,T3		;CHECK FOR JUST A CRLF
	JUMPE	T3,[	TXZ	F,FL%TIM	;YES--CLEAR TIME CHECKING
			RET]			; AND DONE HERE
	MOVEM	T2,BGNTIM	;SAVE IT
	NOISE	(AND END AT)	;MORE NOISE
	PARSE	[FLDDB.(.CMCFM,,,,,[FLDDB.(.CMTAD,,CM%IDA+CM%ITM,,,[
		FLDDB.(.CMTAD,,CM%IDA,,,[FLDDB.(.CMTAD,,CM%ITM)])])])]
	TXO	F,FL%TIM	;REMEMBER
	MOVEM	T2,ENDTIM	;SAVE AWAY
	TSC	T3,T3		;CHECK FOR JUST CRLF (FIRST FLDDB.)
	JUMPE	T3,[GTAD	; IF SO, USE NOW
		    MOVEM T1,ENDTIM	; AS ENDING TIME
		    RET]		;AND DONE
	CONFRM			;OTHERWISE CONFIRM THE LINE
	RET			;AND RETURN
	SUBTTL	READ COMMAND TO SPECIFY ALTERNATE INPUT FILE

;READ COMMAND TO SET ALTERNATE INPUT FILE


.READ:	NOISE	(ERROR DATA FROM)
	MOVX	T2,GJ%OLD	;FILE MUST EXIST
	MOVEM	T2,JFNBLK	;SET FLAGS
	PARSE	[FLDDB. (.CMIFI,,,,<PS:<SYSTEM-ERROR>ERROR.SYS>)] ;PARSE INPUT FILENAME
	MOVEM	T2,JFNTMP	;SAVE THE INPUT JFN FOR LATER
	CONFRM			;CONFIRM THE LINE
	TXO	F,FL%IFS	;FILE SPECIFIED
	HRROI	T1,JFNSTR	;WHERE TO PUT THE STRING
	MOVE	T2,JFNTMP	;GET BACK THE JFN
	MOVEM	T2,IJFN		;AND SAVE IN IJFN
	SETZB	T3,T4		;DEFAULT STRING
	JFNS			;PUT IT IN STRING BLOCK
	 ERJMP	LOSE		;FAILED
	MOVE	T1,IJFN		;AND PROCEED TO
	RLJFN			; UNLOAD JFN, SAVING STRING
	 ERJMP	LOSE		;FAILED
	RET			;AND RETURN
	SUBTTL	LIST COMMAND TO DO IT

;LIST COMMAND TO SET OUTPUT FILE AND BEGIN


.LIST:	NOISE	(OUTPUT ON FILE) ;PROCESS GUIDEWORDS
	PARSE	[FLDDB. (.CMOFI,,,,<TTY:>)] ;GET OUTPUT SPEC
	MOVEM	T2,JFNTMP		;STORE JFN FOR OUTPUT
	NOISE	(AND BEGIN PROCESSING) ;FINAL NOISE
	CONFRM			;CONFIRM THE LINE
	SETABT	LSTABT		;SETUP ABORT TO LSTABT ON CONTROL-E
	CALL	PROCES		;DO THE JOB
LSTDON:	CLRABT			;CLEAR CONTROL-E ABORT
	RET			;AND RETURN FOR ANOTHER COMMAND




;DEBRK TRANSFERS CONTROL TO HERE TO ABORT THE LIST COMMAND

LSTABT:	MOVEI	T1,.PRIOU	;PRESUME TO CLEAR
	CFOBF			; THE OUTPUT IN CASE GOING TO TTY
	 ERJMP	LOSE
	WARN	Listing Aborted
	TXZ	F,FL%OFO	;ABORT CLOSE THE FILES
	MOVX	T1,CZ%ABT+.FHSLF; FOR THE JOB
	CLZFF
	 ERJMP	LOSE
	SETZM	OJFN		;MARK OJFN CLOSED
	MOVE	P,SAVPSI	;ADJUST STACK BACK FOR ABORT
	JRST	LSTDON		; AND FINISH UP THE COMMAND
	SUBTTL	THE MAIN PROCESSING LOOP


PROCES:	MOVX	T1,GJ%OLD+GJ%SHT	;GETJFN BITS
	HRROI	T2,[ASCIZ/PS:<SYSTEM-ERROR>ERROR.SYS/]	;ASSUME DEFAULT
	TXNE	F,FL%IFS	;SPECIAL FILE SPECIFIED?
	HRROI	T2,JFNSTR	;YES--POINT TO IT
	GTJFN			;TRY TO GET IT
	 ERJMP	LOSE		;FAILED
	MOVEM	T1,IJFN		;SAVE JFN

PROC1:	MOVE	T1,IJFN		;GET INPUT JFN
	MOVX	T2,^D36B5+OF%RD+OF%PLN ;TO READ
	OPENF			;OPEN IT
	 ERJMP	LOSE		;FAILED

	MOVE	T1,JFNTMP	;OUTPUT JFN STILL IN TEMP SLOT
	MOVEM	T1,OJFN		;NOW TRY OUTPUT JFN
	MOVX	T2,^D7B5+OF%WR	;TO WRITE IN ASCII
	OPENF			;OPEN IT
	 ERJMP LOSE		;FAILED
	TXO	F,FL%OFO	;MARK AS OPEN

	TYPE	<
[ PROCESSING >			;SAY WHO
	TYPJFN	IJFN		;OUTPUT THE FILESPEC
	TYPE	< ]

>				;AND A CRLF
	SETOM	LINENO		;INIT LINE COUNTER
	SETZM	PAGENO		;INIT PAGE NUMBER
	TXO	F,FL%FDO	;FORCE DATE OUTPUT
	SETZB	T1,T2		;ZERO SOME STUFF
	SETZ	T3,		;TO INDICATE MIDNIGHT
	IDCNV			;GET LOCAL MIDNITE
	 ERJMP	LOSE		;FAILED
	HRROM	T2,LSTDAT	;SET DATE PRINTING THRESHOLD

	MOVEI	T1,POOL		;INITIALIZE
	MOVEM	T1,FREPTR	; FREE POOL POINTER
	MOVEI	T1,SUMSIZ	;SIZE OF SUMMARY TBLUK TABLE
	MOVEM	T1,SUMTAB	;INIT THE TABLE TO EMPTY
	CALL	FILINI		;INIT INPUT FILE POINTERS

	;...
PROCLP:	CALL	NXTENT		;GET NEXT ENTRY TO BUFFER
	 JRST	PROCFN		;END OF FILE OR OTHER TERMINATION
	MOVE	P1,HDRTIM	;MAKE
	CALL	TIMCHK		; CHECK OF TIME
	 JRST	PROCSM		;UNWANTED--BUT SUMMARIZE
	MOVE	P1,[POINT 7,BUGNAM]	;GET THE PARTICULAR NAME
	CALL	NMYCHK		;REALLY WANT THIS ONE?
	 SKIPA			;NOT ESPECIALLY
	JRST	PROCLY		;YES, DO IT.
	MOVE	P1,[POINT 7,BUGNAM]	;GET THE PARTICULAR NAME
	CALL	NMNCHK		;REALLY WANT TO FORGET THIS ONE?
	 JRST	PROCSM		;YES, FORGET IT
	MOVE	P1,BUGFLG	;GET TYPE FLAGS
	CALL	TYPCHK		;SEE IF INCLUDING
	 JRST	PROCSM		;UNWANTED, BUT SUMMARIZE

;HERE WE REALLY WANT TO PRINT THIS ENTRY, SO DO SO

PROCLY:	CALL	TSTPAG		;WANT THIS ONE--
	SKIPGE	P1,BUGDAT	;GET BUG TIME IF SET
	MOVE	P1,HDRTIM	; ELSE USE ENTRY WRITTEN TIME
	CALL	DATOUT
	PSPACE	1
	MOVE	P1,BUGFLG	;GET THE BUG TYPE
	CAIN	P1,BG%HLT	;HLT?
	 PRINT	<HLT    >	;YES, SAY SO
	CAIN	P1,BG%CHK	;CHK?
	 PRINT	<  CHK  >	;YES
	CAIN	P1,BG%INF	;INF?
	 PRINT	<    INF>	;YES
PROCL1:	PSPACE	1
	HRROI	T2,BUGNAM	;POINT TO THE NAME
	MOVEI	T3,7		;SIX CHARACTERS
	SETZM	T4		;ASCIZ
	SOUT			;OUTPUT IT
	 ERJMP	LOSE
	AOS	P1,T3		;ACCOUNT FOR THE REMAINING
	DVCHR			;SEE IF OUTPUT TO TTY
	 ERJMP	LOSE
	MOVE	T1,OJFN		;SETUP JFN AGAIN
	LOAD	T2,DV%TYP,T2	;DEVICE TYPE
	CAIE	T2,.DVTTY	;IF TTY OR
	CAIN	T2,.DVPTY	;PTY THEN
	 SKIPA			;DON'T BKJFN
	BKJFN			;BACK OVER NULL (FOR FILES)
	 ERJMP	.+1		;IGNORE ANY ERROR (LIKE TTYS)
	PSPACE	0(P1)		; SPACES NEEDED
	;...
	HLRE	T2,BUGJOB	;GET FORK NUMBER
	JUMPL	T2,[PRINT < ---> ;FORK NOT GIVEN
		    JRST PROCL2];CONTINUE
	OCTOUT	T2,4		;4 DIGIT OCTAL FORK NUMBER
PROCL2:	HRRE	T2,BUGJOB	;GET JOB NUMBER
	JUMPL	T2,[PRINT < --->	;JOB NOT GIVEN
		    JRST PROCL3];CONTINUE
	DECOUT	T2,3		;3 DIGIT DECIMAL JOB NUMBER
PROCL3:	PSPACE	1
	HRRZ	T2,BUGUSR	;USER NUMBER
	JUMPE	T2,[PRINT < ---> ;NONE APPROPRIATE
		    JRST PROCL4];CONTINUE
	OCTOUT	T2,4		;4 DIGIT OCTAL USER NUMBER
PROCL4:	PSPACE	2
	SKIPN	P1,BUGPNM	;PROGRAM NAME
	MOVE	P1,[SIXBIT/  --  /] ;CHANGE IF NOT GIVEN
	CALL	SIXOUT		;OUTPUT SIXBIT PROGRAM NAME
PROCL6:	PSPACE	1
	LOAD	T3,BUGPI	;GET THE CURRENT PI LEVEL
	ROT	T3,-7		;MOVE TO BITS 0-6
	MOVSI	T4,-7		;NUMBER OF LEVELS
PROCL7:	MOVEI	T2,.CHSPC	;SPACE
	SKIPGE	T3		;PI LEVEL IN PROGRESS?
	MOVEI	T2,"1"(T4)	;YES, GET THE DIGIT
	BOUT			;OUTPUT SPACE OR LEVEL
	 ERJMP	LOSE
	LSH	T3,1		;AND SHIFT UP A BIT
	AOBJN	T4,PROCL7	; THEN LOOP

	PSPACE	4
	SKIPE	T2,BUGUSR	;USER NUMBER AGAIN
	DIRST			;PRINT IT
	 ERJMP [PRINT	<(DIRST Error)> ;NOTE
		JRST	.+1]	;CONTINUE IN LINE WITHOUT A NAME
	PRINT	<
>				;OUTPUT CRLF
	;...

PROCSM:	MOVEI	T1,SUMTAB	;SETUP THE TBLUK TABLE
	MOVE	T2,[POINT 7,BUGNAM] ;POINT TO THE NAME
	TBLUK			;SEE IF IT'S THERE
	TXNE	T2,TL%EXM	;EXACT MATCH?
	 JRST [	HRRZ	T1,0(T1) ;FETCH RH POINTER TO COUNT, MSG BLOCK
		AOS	0(T1)	;COUNT UP ANOTHER REFERENCE
		JRST	PROCS2]	;AND CONTINUE TO LOOP

;HERE WE HAVE A NEW ENTRY, SO BUILD THE COUNT, MESSAGE BLOCK AND DO
;A TBADD TO PUT IT INTO THE TABLE.

	MOVEI	T1,2		;NUMBER OF WORDS FOR BUG NAME STRING
	ADDB	T1,FREPTR	;ALLOCATE THE SPACE
	DMOVE	T3,BUGNAM	;PICK UP THE NAME
	DMOVEM	T3,-2(T1)	; AND STORE IN FREE POOL
	MOVE	P4,FREPTR	;SAVE THE START OF THE BLOCK
	MOVEI	T1,1		;INITIAL REFERENCE COUNT
	MOVEM	T1,0(P4)	;SET IT
	MOVE	T1,BUGFLG	;GET THE BUG TYPE
	HRLM	T1,0(P4)	; AND SAVE THE CODE
	HRLI	T1,BUGMSG	;SOURCE OF MESSAGE
	HRRI	T1,1(P4)	;DESTINATION
	BLT	T1,MSGSIZ+1(P4)	;BLT MESSAGE
	MOVEI	T1,MSGSIZ+1	; AND FINALLY ALLOCATE
	ADDM	T1,FREPTR	; THE SPACE

	MOVEI	T1,SUMTAB	;POINT TO THE TABLE
	HRLI	T2,-2(P4)	;BUGNAME POINTER IN LH
	HRR	T2,P4		;COUNT, MESSAGE POINTER IN RH
	TBADD			;ADD THE ENTRY
	 ERJMP	LOSE		;AWFUL ERROR LIKE TABLE FULL
PROCS2:	JRST	PROCLP		;AND LOOP


;HERE AFTER PROCESSING THE INPUT FILE

PROCFN:	CALL	SUMOUT		;PRINT THE SUMMARY
	MOVE	T1,IJFN		;INPUT JFN
	CLOSF			;CLOSE
	 ERJMP	LOSE
	MOVE	T1,OJFN		;OUTPUT JFN
	CLOSF			;SAME
	 ERJMP	LOSE
	SETZM	OJFN		;AND MARK IT CLOSED
	TXZ	F,FL%OFO	;MARK AS NOT OPEN
	RET			;AND DONE
	SUBTTL	ENTRY INPUT AND VALIDATION ROUTINES


;ALL ROUTINES HERE RETSKP IF VALID AND RET IF ENTRY IS UNWANTED


;TIMCHK	VERIFY ENTRY TIME IN P1 IN RANGE

TIMCHK:	TXNN	F,FL%TIM	;DO WE CARE?
	RETSKP			;NO
	CAML	P1,BGNTIM	;TOO EARLY
	CAMLE	P1,ENDTIM	; OR TOO LATE?
	RET			;YUP
	RETSKP			;IN RANGE


;TYPCHK - VERIFY ENTRY TYPE WANTED (HLT/CHK/INF) AGAINST TYPE IN P1

TYPCHK:	MOVE	T1,[FL%CHK	;GET BIT CORRESPONDING TO TYPE
		    FL%INF
		    FL%HLT]-1(P1)
	TDNE	F,T1		;SEE IF WE WANT IT
	RETSKP			;WANT IT
	RET			;SUPPRESSING


;NMYCHK - VERIFY PARTICULAR NAME WANTED, POINTER TO NAME IN P1

NMYCHK:	CALL	NAMCHK		;CALL THE REAL ROUTINE
	JUMPG	T1,RSKP		;T1 POSITIVE MEANS "YES" MATCH
	RET			;ELSE NO OR DON'T CARE


;NMNCHK - VERIFY PARTICULAR NAME NOT WANTED, POINTER TO NAME IN P1

NMNCHK:	CALL	NAMCHK		;CALL THE REAL ROUTINE
	JUMPL	T1,R		;T1 NEGATIVE MEANS "NO" MATCH
	RETSKP			;ELSE YES OR DON'T CARE
;NAMCHK - DO WILD NAME MATCHING LOOKUP.
;CALL WITH POINTER TO NAME IN P1.
;RETURNS WITH T1/  -1 ON A "NO" MATCH
;		    0 ON A "DON'T CARE"
;		   +1 ON A "YES" MATCH
;MAKES ALL CHECKS, IN ORDER, USES T1-T4.

NAMCHK:	SETZM	T4		;SET SENSE FLAG TO DON'T CARE
	MOVE	T3,P1		;STRING TO CHECK
	SKIPN	P1,NAMTAB	;GET COUNT IN P1
	 JRST [	MOVE	P1,T3	;NONE, RESTORE P1,
		SETZM	T1	; SET "DON'T CARE"
		RET]		; AND RETURN
	MOVN	P1,P1		;BUILD UP AN
	HRLZ	P1,P1		; AOBJN POINTER IN P1
NMCHLP:	HRROI	T2,NAMTAB+1(P1)	;POINT TO WILD STRING
	MOVX	T1,.WLSTR	;STRING CHECK FUNCTION
	WILD%			;MAKE THE CHECK
	 ERJMP	LOSE
	JUMPN	T1,NMCHLX	;CONTINUE ON NO MATCH
	MOVEI	T1,1		;WE ARE USING 1B35 AS THE YES/NO FLAG
	MOVEM	T1,T4		;ASSUME "YES" MATCH
	TDNE	T1,NAMTAB+1(P1)	;BUT CHECK ANYWAY
	SETOM	T4		;IT WAS A "NO" MATCH
NMCHLX:	AOS	P1		;BUMP FOR TWO WORD ENTRY
	AOBJN	P1,NMCHLP	; AND LOOP TIL DONE
	MOVE	P1,T3		;RESTORE P1
	MOVE	T1,T4		;AND SET SENSE FLAG IN T1
	RET			;THEN RETURN
;FILINI	INITIALIZE INPUT FILE...


FILINI:	MOVEI	T1,1		;ADDRESS OF FIRST HEADER WORD
	MOVEM	T1,HDRADR	;INIT HDRADR
	SETZM	HDRWRD		;AND FAKE HDRWRD SO WILL BEGIN AT START
	RET			;AND RETURN



;NXTENT	READ IN THE NEXT ENTRY.  RETSKP OK, RET ON EOF.

NXTENT:	LOAD	T2,HDRLEN	;HEADER LENGTH
	LOAD	T1,ENTLEN	;ENTRY LENGTH
	ADD	T2,T1		;COMBINE
	CALL	GETWRD		;READ NEXT HEADER
	 RET			;EOF???
	LOAD	T1,HDRCOD	;GET TYPE CODE
	CAIE	T1,HF.ERR	;IS IT AN ERROR MARKER
	CAIN	T1,HF.EOF	; OR THE NORMAL EOF MARKER?
	 RET			;YES
	MOVEM	T3,HDRADR	;SET NEW HEADER ADDRESS
	MOVEM	T2,HDRWRD	;SET NEW HEADER WORD
	LOAD	T1,HDRVER	;GET VERSION
	CAIE	T1,HF.VER	;ONE WE KNOW?
	 JRST	LOST		;NO--SANITY CHECK LOSES
	MOVE	T1,HDRWRD	;WORD
	TXNN	T1,HF.T20	;TOPS-20 ENTRY?
	 JRST	LOST		;NO--SANITY CHECK LOSES
	LOAD	T1,HDRCOD	;GET TYPE CODE
	CAIE	T1,SEC%BG	;BUGXXX ENTRY?
	JRST	NXTENT		;NO--LOOP
	CALL	RDENT		;OK, SO READ VALUES
	RETSKP			;AND RETURN SKIP

LOST:	WARN	LOST SYNCHRONIZATION--ATTEMPTING TO CONTINUE

	MOVE	T1,HDRADR	;GET CURRENT ADDRESS
	ADDI	T1,^D128	;MOVE TO NEXT BLOCK
	TRZ	T1,177		;AND ROUND BACK TO BEGINNING
	MOVEM	T1,HDRADR	;THEN STORE BACK
	MOVEI	T2,0		;ZERO OFFSET
	CALL	GETWRD		;READ THE POINTER WORD AT START OF BLOCK
	 RET			;APPARENTLY END OF FILE...
	HRRZS	T2		;OFFSET IS IN THE RIGHT HALF
	ADDM	T2,HDRADR	;POINT TO START OF NEXT ENTRY
	SETZM	HDRWRD		;NO FURTHER OFFSETS
	JRST	NXTENT		; AND TRY THE NEXT ENTRY
;RDENT - READ IN THE DATA FOR THE CURRENT ENTRY

RDENT:	MOVEI	T2,HDRDAT	;GET DATE-TIME
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,HDRTIM	;SAVE IT

	LOAD	T2,HDRLEN
	ADDI	T2,BG%FLG	;GET FLAGS TYPE WORD
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGFLG	;STORE

	LOAD	T2,HDRLEN
	ADDI	T2,BG%JOB	;GET FORK,,JOB WORD
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGJOB	;STORE

	LOAD	T2,HDRLEN
	ADDI	T2,BG%USR	;USER NUMBER
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGUSR	;STORE

	LOAD	T2,HDRLEN
	ADDI	T2,BG%PNM	;USER PROGRAM NAME
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGPNM	;STORE

	SETZB	T1,T2		;PRE-CLEAR
	DMOVEM	T1,BUGNAM	;THE NAME WORDS
	LOAD	T2,HDRLEN
	ADDI	T2,BG%NAM	;GET BUG NAME
	CALL	GETWRD
	 JRST	OOPS
	MOVE	T3,[POINT 7,BUGNAM] ;WHERE TO PUT THE STRING
RDENTN:	SETZ	T1,		;ZERO
	LSHC	T1,6		;THEN SHIFT UP A BYTE
	ADDI	T1," "		;MAKE ASCII
	IDPB	T1,T3		;STASH IT IN NAME STRING
	JUMPN	T2,RDENTN	; AND LOOP TIL DONE
	;...
	;...
	LOAD	T2,HDRLEN
	ADDI	T2,BG%DAT	;GET DATE/TIME OF BUG
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGDAT	;STORE

	LOAD	T2,HDRLEN
	ADDI	T2,BG%PIS	;CONI PI, WORD
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGPIS	;STORE

	LOAD	T2,HDRLEN
	ADDI	T2,BG%MSG	;POINTER TO MESSAGE
	CALL	GETWRD
	 JRST	OOPS
	JUMPE	T2,[SETZM BUGMSG ;NO POINTER MEANS NO MESSAGE
		    JRST  NMSGDN] ;CONTINUE
	MOVE	P1,T2		;SAVE THE POINTER
	SETZ	P2,0		;OFFSET IN BUGMSG STORE
NMSGLP:	LOAD	T2,HDRLEN
	ADD	T2,P1		;NEXT WORD OF MESSAGE
	CALL	GETWRD
	 JRST	OOPS
	MOVEM	T2,BUGMSG(P2)	;SAVE IT
	AOS	P2
	TXNE	T2,177B34	;TRAILING NULL?
	AOJA	P1,NMSGLP	;NOPE, GET NEXT

NMSGDN:	RET			;AND RETURN


OOPS:	ERROR	UNEXPECTED END-OF-FILE ON INPUT
;GETWRD - ROUTINE TO RETURN DESIRED WORD FROM INPUT FILE
;CALLED WITH OFFSET FROM THE BEGINNING OF THE HEADER IN T2.
;RETURNS THE DESIRED WORD IN T2 RETSKP.  NONSKIP FOR END-OF-FILE.
;RETURNS WORD ADDRESS IN T3.
;COMPUTES THE ADJUSTMENTS NEEDED TO ACCOMODATE THE SYNCH WORD AT
;THE START OF EVERY 128-WORD BLOCK.


GETWRD:	MOVE	T1,HDRADR	;HEADER ADDRESS
	ADD	T2,T1		;PLUS OFFSET
	LSH	T1,-7		;DIVIDE BY BLOCKSIZE
	MOVE	T3,T2		;COPY FOR ADJUST
	LSH	T3,-7		;DIVIDE BY BLOCKSIZE
	SUB	T3,T1		;COUNT BLOCK CROSSINGS
	ADD	T3,T2		;UPDATE ADDRESS FOR PROPER ADJUSTMENT
	XOR	T2,T3		;AND CHECK TO SEE IF THE ADJUSTMENT
	TRNE	T2,200		; PUSHED US ACROSS ANOTHER BOUNDARY
	AOS	T3		;IT DID, ADD THE (FINAL!) ADJUSTMENT.
	MOVE	T1,IJFN		;INPUT JFN
	RIN			;READ THE WORD
	 ERJMP	CHKEOF		;WATCH FOR EOF
	RETSKP			;RETURN

CHKEOF:	GTSTS			;GET STATUS BITS
	TXNN	T2,GS%EOF	;END OF FILE?
	JRST	LOSE		;NO--SOME ERROR
	RET			;YES--NONSKIP
	SUBTTL	OUTPUT CONVERSION ROUTINES


;DATOUT	OUTPUT THE DATE-TIME PASSED IN P1.


DATOUT:	MOVE	T1,OJFN		;JFN
	MOVE	T2,P1		;THE DATE-TIME
	SETZ	T3,		;DEFAULT FORMAT
	TXNE	F,FL%FDO	;FORCED?
	JRST	DATOU1		;YES--MAKE SURE THRESHOLD OK
	CAMGE	T2,LSTDAT	;PAST THRESHOLD?
	 JRST [	PUSH	P,T2	;SAVE ACROSS CALL
		PSPACE	12	; DO SPACING
		POP	P,T2	;RESTORE
		JRST	DATOU2]	;AND CONTINUE
	TXO	F,FL%FDO	;YES, FORCE DATE OUT
DATOU1:	HLLM	T2,LSTDAT	;UPDATE THE THRESHOLD
	MOVSI	T4,1		; AND ADJUST IT
	CAML	T2,LSTDAT	; TO BE CORRECT
	ADDM	T4,LSTDAT	; FOR NEXT DAY
DATOU2:	TXZN	F,FL%FDO	;FORCING?
	TXO	T3,OT%NDA	;NO--SUPPRESSING
	ODTIM			;DO IT
	 ERJMP	LOSE		;FAILED
	RET			;DONE



;SIXOUT - ROUTINE TO OUTPUT A WORD IN SIXBIT TO THE SELECTED JFN
;ACCEPTS
;  P1/	VALUE TO BE OUTPUT
;	CALL	SIXOUT
;RETURNS  +1:	ALWAYS.  ALWAYS OUTPUTS SIX CHARACTERS
;USES T1-T4.

SIXOUT:	MOVE	T1,OJFN		;GET THE SELECTED JFN
SIXWRD:	MOVE	T3,P1		;COPY THE WORD
	MOVEI	T4,6		;NUMBER OF CHARACTERS TO DO
SIXWRL:	SETZ	T2,		;CLEAR T2
	LSHC	T2,6		;SHIFT UP A BYTE
	ADDI	T2," "-' '	;MAKE INTO ASCII
	BOUT			;OUTPUT THE CHARACTER
	SOJG	T4,SIXWRL	;AND LOOP FOR SIX
	RET			; THEN RETURN
	SUBTTL	PAGE HEADER PRINTING ROUTINE


;TSTPAG	ROUTINE CALLED PRIOR TO OUTPUTTING A LINE.  TESTS LINENO AND
;	PUTS OUT A NEW PAGE HEADER WHEN THE COUNTER EXPIRES.


TSTPAG:	AOSE	LINENO		;HEADER TIME
	 RET			;NOT YET
	AOS	PAGENO		;NEW PAGE
	PRINT.	[BYTE(7) 14,0,0,0,0] ;FORMFEED
	PRINT	<
SWSERR %>
	VERSIO	EVEC+2		;OUTPUT OUR VERSION NUMBER
	PRINT	<	>	;TAB
	MOVE	T1,OJFN		;GET OUTPUT JFN
	SETO	T2,		;-1=NOW
	ODTIM			;DATE AND TIME
	 ERJMP	LOSE
	PRINT	<						   PAGE  >
	DECOUT	PAGENO		;AND FINALLY THE PAGE NUMBER
	PRINT	<

   Date     Time     Type   Name  Fork Job User Program PIs-Active Username

>				;COLUMN HEADER

	MOVNI	T1,PAGSIZ	;RESET COUNTER
	MOVEM	T1,LINENO	; FOR NEXT TIME
	TXO	F,FL%FDO	;FORCE THE DATE ON FIRST LINE
	RET			;AND RETURN
	SUBTTL	SUMMARY PRINTING ROUTINE

;SUMOUT - ROUTINE TO OUTPUT THE SUMMARY LISTING

SUMOUT:	MOVE	T1,OJFN		;LOAD UP THE OUTPUT JFN
	HLRZ	P2,SUMTAB	;GET THE IN-USE COUNT OF THE TABLE
	JUMPE	P2,[WARN	No entries to summarize
		    RET]	; AND RETURN
	MOVNS	P2		;NEGATE COUNT
	HRLZI	P2,0(P2)	; AND PUT IN LH FOR AOBJN COUNTER
	PRINT.	[BYTE(7) 14,0,0,0,0] ;FORMFEED
	PRINT	<

Summary of BUG Occurances at >
	SETOM	T2		;CURRENT TIME
	SETZM	T3		;DEFAULT WAY
	ODTIM			;DO THE DATE TIME
	 ERJMP	LOSE
	PRINT	<

Number  Type  BUG Name  Bug Message

>				;HEADER
	MOVX	T1,GJ%SHT+GJ%OLD ;GET A HANDLE ON BUGSTRINGS FILE
	HRROI	T2,[ASCIZ/SYSTEM:BUGSTRINGS.TXT/]
	GTJFN			;TRY TO GET IT
	 ERJMP [SETZM	T1	;FAILED, TOUGH...
		JRST	.+1]	;CONTINUE IN LINE...
	MOVEM	T1,BUGJFN	;SAVE JFN
	MOVX	T2,7B5+OF%RD	;READ IN ASCII BYTES
	OPENF			;OPEN THE FILE
	 ERJMP [MOVE	T1,BUGJFN ;GET BACK JFN
		SETZM	BUGJFN	;MARK NOT IN USE
		RLJFN		;TRY TO UNLOAD
		 ERJMP	.+1	;IGNORE FAILURE HERE
		JRST	.+1]	;CONTINUE IN LINE...
	;...
SUMOLP:	HRRZ	P3,SUMTAB+1(P2)	;GET THE NEXT TABLE ENTRY RH
	MOVE	T1,OJFN		;LOAD UP OUTPUT JFN
	HRRZ	T2,0(P3)	;GET NUMBER OF OCCURANCES
	DECOUT	T2,5		;OUTPUT FIVE DIGIT DECIMAL OCCURANCE COUNT
	PSPACE	^D2		;...
	HLRZ	T2,0(P3)	;GET BUG TYPE FLAGS
	CAIN	T2,BG%HLT	;HLT?
	 PRINT	<HLT    >	;YES, SAY SO
	CAIN	T2,BG%CHK	;CHK?
	 PRINT	< CHK   >	;YES
	CAIN	T2,BG%INF	;INF?
	 PRINT	<  INF  >	;YES
	HLRO	T2,SUMTAB+1(P2)	;-1,,[ASCIZ/BUGNAME/]
	MOVEI	T3,7		;SIX CHARS MAX
	SETZM	T4		;ASCIZ
	SOUT			;OUTPUT THE STRING
	 ERJMP	LOSE
	MOVEI	P1,3(T3)	;MAKE JUSTIFICATION
	DVCHR			;SEE IF OUTPUT TO TTY
	 ERJMP	LOSE
	MOVE	T1,OJFN		;SETUP JFN AGAIN
	LOAD	T2,DV%TYP,T2	;DEVICE TYPE
	CAIE	T2,.DVTTY	;IF TTY OR
	CAIN	T2,.DVPTY	;PTY THEN
	 SKIPA			;DON'T BKJFN
	BKJFN			;BACK OVER NULL (FOR FILES)
	 ERJMP	.+1		;IGNORE ANY ERROR (LIKE TTYS)
	PSPACE	0(P1)		;AND DO SPACING
	HRRO	T2,SUMTAB+1(P2)	;POINT TOWARDS MESSAGE
	AOS	T2		;WHICH IS ACTUALLY IN NEXT WORD
	SKIPN	0(T2)		;SEE IF ANYTHING THERE
	CALL	GETMSG		;TRY TO GET THE MESSAGE FROM BUGSTRINGS.TXT
	SETZM	T3		;ASCIZ
	SOUT			;OUTPUT THE STRING
	 ERJMP	LOSE
	HRRO	T2,SUMTAB+1(P2)	;POINT TOWARDS MESSAGE FROM SYSERR BLOCK
	SKIPE	1(T2)		;SEE IF ANYTHING THERE
	PRINT	<
>				;END THE LINE IF MESSAGE FROM SYSERR BLOCK
	AOBJN	P2,SUMOLP	; AND LOOP TIL DONE
	MOVE	T1,BUGJFN	;JFN ON FILE
	CLOSF			;GET RID OF IT
	 ERJMP	.+1		;IGNORE ERRORS HERE
	RET			; THEN RETURN

;GETMSG - ATTEMPT TO READ THE BUG MESSAGE FOR THIS BUG FROM BUGSTRINGS.TXT

GETMSG:	SAVEAC	<T1>		;SAVE CALLER'S DESIGNATOR
	SKIPN	T1,BUGJFN	;SEE IF ANY FILE TO USE
	 JRST	NOBGMS		;BIG LOSE MESSAGE
	SETZM	T2		;RESET TO BEGINNING
	SFPTR			;OF BUGSTRINGS FILE
	 ERJMP	NOBGMS		;FLICK IT...

BGMSLP:	MOVE	T1,BUGJFN	;GET JFN AGAIN
	HRROI	T2,BUGBUF	;WHERE TO READ IT
	MOVX	T3,100*5-1	;MAX NUMBER OF BYTES
	MOVX	T4,.CHLFD	;TERMINATE ON LINEFEEDS
	SIN			;READ A LINE
	 ERJMP	NOBGMS		;FLICK IT IF DIDN'T WORK OR EOF...
	SETZM	T1		;GET A NULL
	IDPB	T1,T2		;AND FINISH LINE WITH IT
	HLRO	T1,SUMTAB+1(P2)	;POINT TO BUG NAME
	HRROI	T2,BUGBUF	;POINT TO BUGSTRINGS LINE
	STCMP			;SEE IF STRINGS MATCH
	 ERJMP	NOBGMS		;FLICK IT IF ERRORS...
	TXNN	T1,SC%SUB	;SUBSTRING MATCH?
	 JRST	BGMSLP		;NO, LOOP MORE
	MOVX	T3,7		;YES! NUMBER OF BYTES TO
	ADJBP	T3,T2		;ADJUST BY
	MOVE	T2,T3		;PUT POINTER IN T2
	RET			;AND RETURN


NOBGMS:	HRROI	T2,[ASCIZ/        (No message available for this BUG)
/]
	RET			;RETURN WITH LOSER MESSAGE
	SUBTTL	THE DATA AREA

	XLIST			;DUMP THE LITERALS
	LIT
	LIST

BUGJFN:	BLOCK	1		;JFN ON SYSTEM:BUGSTRINGS.TXT

SAVEP:	BLOCK	1		;STORAGE OF STACK

JFNSTR:	BLOCK	100		;STORAGE FOR INPUT FILENAME
IJFN:	BLOCK	1		;INPUT FILE JFN
PAGENO:	BLOCK	1		;PAGE NUMBER
LINENO:	BLOCK	1		;LINE NUMBER
BGNTIM:	BLOCK	1		;BEGIN TIME
ENDTIM:	BLOCK	1		;END TIME
LSTDAT:	BLOCK	1		;LAST DATE OUTPUT WORD

;ENTRY DATA

HDRADR:	BLOCK	1		;ADDRESS OF CURRENT HEADER WORD
HDRWRD:	BLOCK	1		;CURRENT HEADER WORD
HDRTIM:	BLOCK	1		;DATE-TIME

BUGNAM:	BLOCK	2		;ASCIZ BUG NAME
BUGDAT:	BLOCK	1		;DATE/TIME OF BUG
BUGJOB:	BLOCK	1		;FORK,,JOB
BUGPIS:	BLOCK	1		;CONI PI, WORD FOR PI LEVEL
BUGUSR:	BLOCK	1		;USER NUMBER
BUGPNM:	BLOCK	1		;PROGRAM NAME
BUGFLG:	BLOCK	1		;BUG TYPE FLAG
BUGMSG:	BLOCK	<MSGSIZ==^D80/5> ;SPACE FOR THE BUGSTRING

;STORAGE FOR PARTICULAR NAME TABLES

NAMTAB:	BLOCK	200		;BUG INCLUDE NAME TABLE, WORD 0
				;HAS COUNT, TWO WORD ASCIZ ENTRIES

;TBLUK TABLE FOR SUMMARY STUFF

SUMTAB:	BLOCK	1		;ALLOCATE SPACE
	BLOCK	SUMSIZ		; FOR TABLE OF POINTERS INTO FREE SPACE

;BUFFER FOR READING BUGSTRINGS.TXT

BUGBUF:	BLOCK	100		;LINE BUFFER

;FREE POOL FOR STRING STORAGE

FREPTR:	BLOCK	1		;FREE POINTER
POOL:	BLOCK	2000		;SOME FREE SPACE

	END	<3,,EVEC>