Google
 

Trailing-Edge - PDP-10 Archives - BB-H138A-BM - 3a-sources/conv20.mac
There are 3 other files named conv20.mac in the archive. Click here to see a list.
;<HUIZENGA.CONV20>CONV20.MAC.7, 14-Dec-77 09:55:29, EDIT BY HUIZENGA
;CONSOLE CONNECT TIME IN LOGOUT ENTRY NEEDS TO BE IN MILLISECONDS
;<3-UTILITIES>CONV20.MAC.7,  8-Nov-77 10:46:51, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<3-UTILITIES>CONV20.MAC.6, 26-Oct-77 10:59:38, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3

TITLE CONV20 - USAGE FORMAT TO FACT FORMAT CONVERSION PROGRAM - V3(5)
SUBTTL	BAHUIZENGA/BAH     13-JUN-77



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SALL
;TEMPORARIES

T1=1
T2=2
T3=3
T4=4

;PERMANENT ACS

P1=10
P2=11
P3=12
P4=13

;PUSHDOWN POINTER

P=17

	SEARCH	MONSYM,MACSYM
	.REQUIRE SYS:MACREL

VERS==3				;MAJOR VERSION NUMBER
UPDAT==0			;MINOR VERSION NUMBER
EDIT==5				;EDIT NUMBER
CUST==0				;CUSTOMER/SWS EDIT CODE

	PGVER.	VERS,UPDAT,EDIT,CUST

PDLLEN==50			;PUSHDOWN STACK LENGTH
SUBTTL	EDIT HISTORY

;EDIT 2/BAH	MAKE END OF FILE RETURN REPORT CORRECTLY. FIX SO THAT THE
;	RUNNING JOB'S USER ID NUMBER GETS PUT INTO WORD 2 OF DISK UTILIZATION
;	ENTRIES.  IN ADDITION, SET UP DEFAULT INPUT AND OUTPUT FILE-SPECS.

;EDIT 3/BAH	ONE CALL TO UNSUPP DOES NOT ALLOW FOR SKIP RETURN.

;EDIT 4/BAH	FACT FILE SET DATE-TIME ENTRIES NO BEING CORRECTLY SIMULATED
;	ON A SYSTEM RELOAD. ALSO DATE AND TIME WORD IN SET DATE-TIME ENTRIES
;	WAS ALWAYS ZERO.
SUBTTL	USAGE FILE ENTRY FORMATS

;*********************************
	RADIX	10
;*********************************

;LENGTH OF FIELDS TO BE PICKED UP IN A USAGE FILE RECORD

LENTYP==4			;ENTRY TYPE LENGTH
LENSEQ==1			;RECORD SEQUENCE LENGTH
LENJOB==4			;JOB # LENGTH
LENLIN==4			;LINE # LENGTH
LENUSR==39			;USER/DIRECTORY NAME LENGTH
LENDTM==14			;DATE/TIME LENGTH
LENACT==39			;ACCOUNT STRING LENGTH
LENRUN==9			;RUNTIME LENGTH
LENANO==3			;# OF ACCOUNT STRINGS IN DISK USAGE ENTRY LENGTH
LENPAG==10			;# OF FILE PAGES USED LENGTH
LENSTR==6			;FILE STRUCTURE NAME LENGTH
LENCON==7			;CONSOLE CONNECT TIME LENGTH

;*********************************
	RADIX	8
;*********************************

;BYTE POINTERS TO THE BEGINNING CHARACTER OF EACH FIELD CONTAINING DATA
;	THAT WILL BE CONVERTED AND PUT INTO A BINARY (MIXED MODE)
;	FACT FORMATED FILE.

;HEADER OF ALL USAGE RECORDS - FIRST 20 CHARACTERS (4 WORDS)

USETYP:	POINT 7,USEBLK		;ENTRY TYPE USED FOR BINARY CONVERSIONS
USESEQ:	POINT 7,USEBLK+1,6	;RECORD SEQUENCE NUMBER (WILL BE REFERENCED WITH
				; A LDB INSTEAD OF AN ILDB AS THE OTHERS)


;ENTRY HEADER RECORD - IS ALWAYS THE FIRST RECORD OF ALL ENTRIES

USEJOB:	POINT 7,USEBLK+4	;JOB #
USELDT:	POINT 7,USEBLK+4,27	;DATE/TIME ENTRY WAS MADE
USELIN:	POINT 7,USEBLK+7,27	;LINE #

;USER IDENTFICATION RECORD

USEUSR:	POINT 7,USEBLK+4	;USER/DIRECTORY NAME

;SESSION RECORD #1

USEACT:	POINT 7,USEBLK+4	;ACCOUNT STRING
USERUN:	POINT 7,USEBLK+13,27	;USER'S RUNTIME
USEBDT:	POINT 7,USEBLK+15,20	;DATE/TIME USER BEGAN SESSION
USECON:	POINT 7,USEBLK+32,27	;CONSOLE CONNECT TIME (SECONDS)
;DISK USAGE DIRECTORY RECORD

USEANO:	POINT 7,USEBLK+4	;NUMBER OF ACCOUNT STRINGS (RECORDS) IN ENTRY
USEDUN:	POINT 7,USEBLK+12,27	;POINTER TO USER/DIRECTORY NAME

;DISK USAGE ACCOUNT STRING RECORD

;USEACT:POINT 7,USEBLK+4	;ACCOUNT STRING. ALREADY DEFINED IN SESSION ENTRY
USEDIR:	POINT 7,USEBLK+13,27	;DIRECTORY NAME
USEPAG:	POINT 7,USEBLK+25,20	;NUMBER OF FILE PAGES USED
USESTR:	POINT 7,USEBLK+30,20	;STRUCTURE NAME
SUBTTL	FACT FILE ENTRY FORMATS


;HEADER BLOCK DEFINITIONS (FIRST THREE WORDS OF EVERY ENTRY)
	DEFSTR	HDRTYP,FACTBL,8,9	;TYPE CODE
	DEFSTR	HDRJOB,FACTBL,17,9	;JOB #
	DEFSTR	HDRLIN,FACTBL,29,12	;LINE #
	DEFSTR	HDRCNT,FACTBL,35,6	;WORD COUNT OF ENTRY
	DEFSTR	HDRUSR,FACTBL+1,35,36	;USER #
	DEFSTR	HDRDTM,FACTBL+2,35,36	;DATE/TIME

;LOGIN DEFINITIONS
	DEFSTR	LGIZER,FACTBL+3,35,36	;ZERO WORD
	DEFSTR	LGICHR,FACTBL+4,35,36	;CHAR COUNT OF ACCOUNT STRING
LGIACT:	POINT 7,FACTBL+5		;POINTER TO BEGINNING OF ACCOUNT STRING

;LOGOUT DEFINITIONS
	DEFSTR	LGORUN,FACTBL+3,35,36	;RUNTIME
	DEFSTR	LGOCON,FACTBL+4,35,36	;CONSOLE TIME (MILLISECONDS)

;DISK UTILIZATION DEFINITION
	DEFSTR	SPCPAG,FACTBL+3,35,36	;# OF FILE PAGES USED

;SINCE THE FORMAT AND PLACEMENT OF THE ACCOUNT STRING IN THE DISK
;UTILIZATION ENTRY IS THE SAME AS THE LOGIN ENTRY, LGICHR AND LGIACT, ALONG
;WITH THE ROUTINE LGIWD5 WILL BE USED.  THE CALL, HOWEVER, WILL BE FOR
;SPCWD5 INSTEAD OF LGIWD5.
;
;THE STRUCTURE/DIRECTORY NAME STRING WILL BE BUILT BY HAND WITHOUT THE USE
;OF DEFSTR'S. AFTER THE ACCOUNT STRING, THE NEXT WORD WILL CONTAIN THE WORD
;COUNT OF THE STRUCTURE/DIRECTORY NAME STRING. AFTER THAT WILL BE THE
;ACTUAL STRING.



;MISCELLANEOUS VALUES

SPACE==40			;SPACE ( )
SLASH==57			;SLASH (/)
COLON==72			;COLON (:)
LANGLE==74			;LEFT ANGLE BRACKET
RANGLE==76			;RIGHT ANLGE BRACKET
SUBTTL	TOP LEVEL ROUTINE

START:	RESET
	MOVE	P,[IOWD	PDLLEN,PDL]	;SET UP STACK POINTER
	CALL	GETIN		;GET USAGE FORMAT INPUT FILE SPEC
	CALL	GETOUT		;GET FACT  FORMAT OUTPUT FILE SPEC (NEW OR OLD)
	CALL	GETOPN		;GO OPEN THE FILES
	CALL	CLRTBL		;ZERO THE FACT ENTRY BUILDING TABLE


;HERE TO BEGIN TO READ AN ENTRY

READXX:	CALL	SETRD		;SET UP TO READ ANOTHER RECORD
READX1:	LDB	T1,USESEQ	;GET SEQUENCE # POINTER
	CAIE	T1,"1"		;IS THIS THE FIRST RECORD OF AN ENTRY?
	JRST	READXX		;NO, READ UNTIL WE FIND ONE
	MOVE	T1,USETYP	;GET POINTER TO ENTRY TYPE
	MOVEI	T2,LENTYP	;GET THE LENGTH
	CALL	NUMDEC		;CONVERT FOR DISPATCH TABLE
	MOVEM	T1,SAVTYP	;SAVE THE ENTRY TYPE
	CAIL	T1,DISLEN	;DO WE KNOW ABOUT THIS ENTRY TYPE?
	JRST	[CALL	UNSUPP	;NO REPORT IT AND READ NEXT ENTRY
		 JRST	READX1	;WILL NEVER HAPPEN
		JRST	READXX]
	CALL	@DISPAT(T1)	;GO PROCESS APPROPRIATE ROUTINE
				; THE DISPATCH ROUTINE WILL DO A SKIP RETURN
				; IF NO ERRORS ARE ENCOUNTERED. OTHERWISE,
				; IF A SEQUENCE NUMBER OF 1 IS READ, THE
				; ROUTINE WILL DO A NON-SKIP RETURN
	 JRST	[HRROI [ASCIZ /
%Incomplete entry found/]
		PSOUT
		JRST READX1]	;ERROR RETURN
	JRST	READXX		;GOOD RETURN
SUBTTL	DISPATCH TABLE TO PROCESS USAGE ENTRIES TO FACT ENTRIES

DISPAT:	UNSUPP			;NO ENTRY NUMBERED '0000'
	RESTAR			;SYSTEM RESTART ENTRY '0001' - MAKES AN
				; SYSTEM FROM SCRATCH ENTRY '740'
	SESSIO			;SESSION ENTRY '0002' - MAKES A LOGIN ENTRY
				; '501' AND A LOGOUT ENTRY '141'
	SESSIO			;INCOMPLETE SESSION ENTRY '0003' -
				; MAKES A LOGIN ENTRY '501' AND A CHKPNT
				; ENTRY '201'
	UNSUPP			;UNDEFINED ENTRY '0004'
	CNGDTM			;DATE/TIME CHANGE ENTRY '0005' - MAKES
				; A TIME SET ENTRY '741'
	UNSUPP			;'0006' ENTRY NOT SUPPORTED IN FACT FILE
	UNSUPP			;'0007' ENTRY NOT SUPPORTED IN FACT FILE
	UNSUPP			;'0008' ENTRY NOT SUPPORTED IN FACT FILE
	DISKUS			;DISK USAGE DIRECTORY AND ACCOUNT STRING
				; ENTRY '0009' - MAKES DISK UTILIZATION
				; ENTRIES '540' AND '601'
DISLEN=.-DISPAT			;LENGTH OF DISPATCH TABLE
SUBTTL	SECOND LEVEL ROUTINES

;GETIN - ROUTINE TO GET THE INPUT FILE SPEC FOR THE FILE THAT HAS THE USAGE
;	FORMAT.  THIS FILE'S DATA WILL BE CONVERTED TO FACT FILE FORMAT
;CALL	GETIN

GETIN:	HRROI	T1,[ASCIZ /
Please enter the USAGE file to be read: /]
	PSOUT			;ASK FOR THE INPUT FILE NAME
	MOVEI	T1,USEJTB	;ARGUMENT BLOCK FOR GTJFN LONG FORM
	MOVEI	T2,0
	GTJFN			;GET IT
	 ERJMP	[CALL	INERR	;REPORT ERROR. WILL RETURN TO ASK FOR ANOTHER
		JRST	GETIN]	; USAGE FILE NAME
	HRRZM	T1,USEJFN	;SAVE INPUT JFN
	RET


;GETOUT - ROUTINE TO THE THE OUTPUT FILE SPEC FOR THE FILE THAT WILL
;	HAVE THE FACT FILE FORMAT.
;CALL GETOUT

GETOUT:	HRROI	T1,[ASCIZ /
Please enter file to be written: /]
	PSOUT			;ASK FOR OUTPUT FILE NAME
	MOVEI	T1,FCTJTB	;ARGUMENT BLOCK FOR GTJFN LONG FORM
	MOVEI	T2,0
	GTJFN			;GET IT
	 ERJMP	[CALL	OUTERR	;REPORT ERROR. WILL RETURN TO ASK FOR ANOTHER
		JRST	GETOUT]	; OUTPUT FILE SPEC
	HRRZM	T1,FCTJFN	;SAVE OUTPUT JFN
	RET


;GETOPN - ROUTINE TO OPEN INPUT AND OUTPUT FILES
;CALL	GETOPN

GETOPN:	MOVE	T1,USEJFN	;GET INPUT JFN OF USAGE FILE
	MOVX	T2,7B5!OF%RD	;READ ONLY, ASCII
	OPENF			;OPEN THE FILE
	 ERJMP	[CALL	XERSTR
		HALTF]
	MOVE	T1,FCTJFN	;GET OUTPUT JFN OF FACT FILE
	MOVX	T2,44B5!OF%APP	;APPEND, BINARY (MIXED MODE)
	OPENF			;OPEN THE FILE
	 ERJMP	[CALL	XERSTR
		HALTF]
	RET			;NOW GO PROCESS
;FCTOUT - ROUTINE TO OUTPUT FACT FILE ENTRIES. THE ENTRY IS FOUND IN FACTBL:.
;	THE BYTE COUNT (36-BIT BYTES) IS FOUND BY REFERENCING HDRCNT
;CALL:	CALL	FCTOUT

FCTOUT:	LOAD	P1,HDRCNT	;GET THE WORD COUNT OF ENTRY
	SKIPA	P2,[0]		;ZERO INDEX TO WORD TO BE OUTPUT
FCTOU1:	AOS	P2		;ADJUST INDEX
	MOVE	T1,FCTJFN	;GET FACT FILE JFN
	MOVE	T2,FACTBL(P2)	;GET THE DATA
	BOUT			;OUTPUT THE WORD
	SOJG	P1,FCTOU1	;ARE WE FINISHED?
	CALL	CLRTBL		;YES. ZERO FACT FILE ENTRY BUILDING TABLE
	RET			;AND RETURN


;DONE - ROUTINE TO FINISH UP
;CALL	DONE

DONE:	CALL	CHKEOF		;GO SEE IF INPUT ERROR WAS AN EOF
	 CALL	XERSTR		;NOT AN EOF, REPORT IT
	MOVE	T1,USEJFN	;GET USAGE FILE JFN
	CLOSF			;CLOSE THE USAGE FILE
	 ERCAL	XERSTR		;REPORT THE ERROR
	MOVE	T1,FCTJFN	;GET THE FACT FILE JFN
	CLOSF			;CLOSE THE FACT FILE
	 ERCAL	XERSTR		;REPORT THE ERROR
	HALTF			;ALL DONE WITH PROCESS
	HALTF			;STOP

;CHKEOF - ROUTINE TO SEE IF AN END OF FILE WAS REACHED
;CALL:	CALL CHKEOF

CHKEOF:	MOVEI	T1,.FHSLF	;OUR PROCESS HANDLE
	GETER			;GET THE LAST ERROR
	HRRZS	T2		;ISOLATE THE ERROR
	CAIE	T2,IOX4	;IS IT AN END OF FILE?
	RET			;NO, DO A NON-SKIP RETURN
	HRROI	T1,[ASCIZ /
[USAGE to FACT conversion completed]/]	;YES. REPORT CONVERSION COMPLETE
	PSOUT
	RETSKP
SUBTTL	USAGE DATA TO FACT DATA CONVERSION ROUTINES

;UNSUPP - ROUTINE TO USE IF A USAGE FILE ENTRY HAS NOT BEEN SUPPORTED
;	IN THE FACT FILES PRODUCED BY TOPS20 VERSION 2 AND PREDECESSORS

UNSUPP:	SETZM	FLGDSK		;MAKE SURE DISK ENTRIES WILL BE RIGHT
	HRROI	T1,[ASCIZ /%Not supported in FACT format - /]
	PSOUT
	MOVEI	T1,.PRIOU	;REPORT THE ENTRY TYPE
	MOVE	T2,USETYP
	MOVNI	T3,LENTYP
	MOVEI	T4,0
	SOUT
	HRROI	T1,[ASCIZ /
/]
	PSOUT
	RETSKP


;RESTAR - ROUTINE TO PROCESS SYSTEM RESTART RECORD
;	ALWAYS DOES A SKIP RETURN SINCE ONLY ONE USAGE RECORD HAS TO BE
;	READ TO MAKE A FACT FILE ENTRY

RESTAR:	SETZM	FLGDSK		;MAKE SURE DISK ENTRIES WILL BE RIGHT
	SETZRO	HDRCNT		;ZERO WORD COUNT OF ENTRY

;CREATE THE FIRST WORD OF THE ENTRY (ONLY ONE WORD FOR THIS ONE)

	MOVEI	T1,740		;GET ENTRY TYPE
	STOR	T1,HDRTYP	;FORMAT IT
	INCR	HDRCNT		;FIRST WORD IS DONE
	CALL	FCTOUT		;OUTPUT THE ENTRY
;	RETSKP			;TIME SET ENTRY MUST BE MADE ON RESTARTS
				; SO FALL INTO CNGDTM.



;CNGDTM- ROUTINE TO CONVERT A CHANGE DATE/TIME ENTRY OF A USAGE FILE TO A
;	TIME SET ENTRY OF A FACT FILE.

CNGDTM:	SETZM	FLGDSK		;MAKE SURE DISK ENTRIES WILL BE RIGHT
	SETZRO	HDRCNT		;ZERO THE WORD COUNT
	MOVEI	T1,741		;ENTRY TYPE OF A TIME SET ENTRY
	STOR	T1,HDRTYP	;STORE IT
	MOVE	T1,USEJOB	;GET THE POINTER TO JOB #
	MOVEI	T2,LENJOB	; AND ITS LENGTH
	CALL	NUMDEC		;CONVERT
	STOR	T1,HDRJOB	;STORE IT
	MOVE	T1,USELIN	;GET THE POINTER TO LINE #
	MOVEI	T2,LENLIN	; AND ITS LENGTH
	CALL	NUMOCT		;CONVERT
	STOR	T1,HDRLIN	;STORE IT
	INCR	HDRCNT		;DONE WITH FIRST WORD
	SETZRO	HDRUSR		;NO DIRECTORY/USER INFORMATION AVAILABLE
	INCR	HDRCNT		;DONE WITH SECOND WORD
	MOVE	T1,USELDT	;GET POINTER TO DATE/TIME
	CALL	DATTIM		;CONVERT IT
	STOR	T2,HDRDTM	;STORE IT
	INCR	HDRCNT		;DONE WITH THIRD WORD
	CALL	FCTOUT		;NOW OUTPUT THE ENTRY
	RETSKP			;FINISHED
;DISKUS - ROUTINE TO CONVERT USAGE FILE DISK USAGE DIRECTORY AND ACCOUNT
;	STRING RECORDS TO FACT FILE DISK UTILIZATION ENTRIES.

DISKUS:	SKIPN	FLGDSK		;HAS THE DISK UTILIZATION INITIAL ENTRY BEEN MADE?
	CALL	SPCBEG		;NO. GO MAKE IT
	MOVE	T1,USELDT	;DATE/TIME IS IN THIS RECORD
	CALL	DATTIM		;CONVERT IT TO INTERNAL FORMAT
	MOVEM	T2,SAVDAT	;AND THEN SAVE IT FOR THE REST OF THE ENTRIES
DISKU1:	CALL	SETRD		;READ NEXT RECORD
	MOVE	T1,USETYP	;GET THE ENTRY TYPE TO ENSURE DISK ENTRYS ARE
	MOVEI	T2,LENTYP	; STILL BEING READ
	CALL	NUMDEC		;CONVERT
	CAME	T1,SAVTYP	;IS THIS A DISK ENTRY?
	RET			;NO.  DO A NON-SKIP RETURN.  A NON-SKIP RETURN WILL BE
				; THE ONLY RETURN TO THE MAIN LOOP SINCE THE
				; THE FIRST RECORD OF THE NEXT ENTRY WILL
				; ALREADY HAVE BEEN READ
	LDB	T1,USESEQ	;GET THE SEQUENCE NUMBER
	CAIE	T1,"2"		;IS THIS THE SECOND RECORD?
	RET			;NO. RETURN
	SETOM	T1		;NOW FIND THIS JOB'S 36-BIT USER NUMBER
	MOVE	T2,[-3,,TEMP]
	MOVEI	T3,.JIUNO
	GETJI
	 JRST	[ERCAL XERSTR
		SETZM	SAVUSR
		JRST DISKU2]
	MOVE	T1,TEMP(.JIUNO)
	MOVEM	T1,SAVUSR	;SAVE THE USER NUMBER
DISKU2:	CALL	SETRD		;THIS SECTION PROCESSES THE ACCOUNT STRING RECORDS
	MOVE	T1,USETYP	;GET THE ENTRY TYPE TO ENSURE DISK RECORDS
	MOVEI	T2,LENTYP	;ARE STILL BEING READ
	CALL	NUMDEC		;CONVERT
	CAME	T1,SAVTYP	;IS IT THE SAME TYPE?
	RET			;NO. RETURN TO MAIN LOOP (READX1)
	LDB	T1,USESEQ	;GET THE SEQUENCE NUMBER
	CAIE	T1,"3"		;MAKE SURE THIS IS AN ACCOUNT STRING RECORD
	RET			;RETURN TO THE MAIN LOOP. (READX1)
	CALL	SPCWD1		;WORK ON FIRST WORD OF ENTRY (TYPE,JOB,LINE,COUNT)
	MOVE	T1,SAVUSR	;GET THE USER/DIRECTORY NUMBER
	STOR	T1,HDRUSR	;STORE IT
	INCR	HDRCNT		;DONE WITH SECOND WORD OF ENTRY
	MOVE	T1,SAVDAT	;NOW GET THE DATE/TIME
	STOR	T1,HDRDTM	;STORE IT
	INCR	HDRCNT		;DONE WITH THIRD WORD OF ENTRY
	CALL	SPCWD4		;GET THE NUMBER OF FILE PAGES USED
	CALL	SPCWD5		;GET THE ACCOUNT STRING
	CALL	SPCWDN		;GET THE DIRECTORY NAME
	CALL	FCTOUT		;OUTPUT THE ENTRY
	JRST	DISKU2		;GO PROCESS THE NEXT RECORD
;SPCBEG - ROUTINE TO MAKE THE BEGINNING OF DISK UTILIZATION ENTRY.  THIS
;	ENTRY WILL BE MADE IF 'FLGDSK' IS ZERO.

SPCBEG:	SETZRO	HDRCNT		;ZERO THE WORD COUNT
	MOVEI	T1,540		;SIGNIFY THE BEGINNING OF DISK UTILIZATION
	STOR	T1,HDRTYP	; STATISTICS
	INCR	HDRCNT		;DONE WITH FIRST WORD AND ENTRY
	CALL	FCTOUT		;GO OUTPUT IT NOW
	SETOM	FLGDSK		;SIGNIFY THAT THE ENTRY HAS BEEN MADE
	RET



;SPCWD1 - ROUTINE TO WORK ON FIRST WORD OF DISK UTILIZATION ENTRY

SPCWD1:	MOVEI	T1,601		;ENTRY TYPE
	STOR	T1,HDRTYP	;STORE IT
	SETZRO	HDRJOB		;JOB # AND LINE # ARE ZERO IN THESE
	SETZRO	HDRLIN		; ENTRIES
	INCR	HDRCNT		;DONE WITH FIRST WORD
	RET



;SPCWD4 - ROUTINE TO WORK ON FOURTH WORD OF DISK UTILIZATION ENTRY, NAMELY,
;	THE NUMBER OF FILE PAGES USED.

SPCWD4:	MOVE	T1,USEPAG	;GET POINTER TO THE NUMBER
	MOVEI	T2,LENPAG	;AND ITS FIELD LENGTH
	CALL	NUMDEC		;CONVERT IT
	STOR	T1,SPCPAG	;STORE IT
	INCR	HDRCNT		;DONE WITH WORD FOUR
	RET


;SPCWDN - ROUTINE TO WORK ON THE LAST SET OF WORDS OF THE DISK UTILIZATION ENTRY.
;	THE FIRST WORD OF THIS SET HAS THE WORD COUNT USED BY THE STRUCTURE/DIRECTORY
;	NAME STRING.  THE REST OF THIS SET CONTAINS THE STRUCTURE/DIRECTORY
;	NAME STRING.  IT IS IMPORTANT THAT ALL THE REST OF THE DISK UTILIZATION
;	ENTRY BE DONE BEFORE THIS ROUTINE IS CALLED.

SPCWDN:	STKVAR	<CNTADR>	;DEFINE A WORD WHERE THE ADDRESS OF
				; THE WORD COUNT WILL BE STORED
	LOAD	T1,HDRCNT	;GET THE CURRENT WORD COUNT OF THE ENTRY
	MOVEI	T2,FACTBL(T1)	;GET THE ADDRESS OF THE DIRECTORY WORD COUNT
	MOVEM	T2,CNTADR	;STORE IT FOR FUTURE REFERENCE
	MOVE	T3,[POINT 7,FACTBL+1] ;SET UP POINTER TO FIRST WORD OF DIRECTORY NAME
	ADD	T3,T1
	MOVE	T1,USESTR	;GET THE POINTER TO THE STRUCTURE NAME
	MOVEI	T2,LENSTR	;AND ITS LENGTH
	MOVEI	P1,0		;P1 WILL BE USED TO KEEP THE NUMBER OF CHARACTERS
SPCWN1:	ILDB	T4,T1		;GET A CHARACTER
	CAIN	T4," "		;ARE WE FINISHED?
	JRST	SPCWN2		;YES. NOW GO GET DIRECTORY NAME
	IDPB	T4,T3		;STORE IT
	ADDI	P1,1		;COUNT THE CHARACTER
	SOJG	T2,SPCWN1	;HAVE WE REACHED THE MAXIMUM FIELD LENGTH?
SPCWN2:	MOVEI	T4,COLON	;SIGNIFY END OF STRUCTURE NAME
	IDPB	T4,T3		;NOW WE HAVE 'STRUCTURE:'
	MOVEI	T4,LANGLE	;ALSO SIGNIFY BEGINNING OF DIRECTORY NAME
	IDPB	T4,T3
	ADDI	P1,2		;COUNT THE COLON AND LEFT ANGLE BRACKET
	MOVE	T1,USEDIR	;GET THE POINTER TO THE DIRECTORY NAME
	MOVEI	T2,LENUSR	;AND THE FIELD LENGTH (T3 STILL CONTAINS POINTER
				; TO THE CORRECT PLACE
SPCWN3:	ILDB	T4,T1		;GET A CHARACTER
	CAIN	T4," "		;ARE WE FINISHED?
	JRST	SPCWN4		;YES. FINISH UP.
	IDPB	T4,T3		;STORE IT
	ADDI	P1,1		;COUNT THE CHARACTER
	SOJG	T2,SPCWN3	;HAVE WE REACHED THE MAXIMUM FIELD LENGTH?
SPCWN4:	MOVEI	T4,RANGLE	;YES. NOW SIGNIFY END OF DIRECTORY NAME
	IDPB	T4,T3		;STORE IT
	MOVEI	T4,.CHNUL	;JUST IN CASE BE SURE TO INCLUDE A NULL
	IDPB	T4,T3		;STORE IT
	ADDI	P1,2		;COUNT THE RIGHT ANGLE BRACKET AND NULL
	IDIVI	P1,5		;NOW FIND THE WORD COUNT
	CAIE	P2,0		;ARE THERE ANY CHARACTERS LEFT OVER?
	ADDI	P1,1		;YES. COUNT THE WORD
	MOVEM	P1,@CNTADR	;STORE THE WORD COUNT
	INCR	HDRCNT		;COUNT FOR THE WORD COUNT WORD
	LOAD	T1,HDRCNT	;GET THE ENTRY WORD COUNT
	ADD	T1,P1		;ADJUST IT.
	STOR	T1,HDRCNT	;STORE IT
	RET			;ALL DONE
;SESSIO - ROUTINE TO CONVERT A SESSION ENTRY OF A USAGE FILE
;	TO A LOGIN AND A LOGOUT ENTRY IN FACT FILE FORMAT.  A SESSION
;	ENTRY CONSISTS OF THREE RECORDS.  IF ANY INFORMATION IS MISSING,
;	THE ROUTINE WILL DO A NON-SKIP RETURN. OTHERWISE,
;	IT WILL DO A SKIP RETURN

SESSIO:	SETZRO	HDRCNT		;INITIALIZE THE WORD COUNT OF ENTRY
	CALL	LGIWD1		;WORK ON FIRST WORD OF LOGIN ENTRY (TYPE,JOB,LINE,COUNT)
	CALL	LGOWD3		;LOGOUT DATE/TIME IS IN THIS RECORD.
				; SO CONVERT IT NOW AND SAVE FOR LATER
	CALL	LGIWD4		;WORK ON FOURTH WORD OF LOGIN ENTRY (ALWAYS ZERO)

;NOW ALL DATA HAS BEEN OBTAINED FROM THE FIRST USAGE RECORD.  GO READ ANOTHER ONE.

	CALL	SETRD		;SET UP TO READ ANOTHER RECORD
	LDB	T1,USESEQ	;GET THE RECORD SEQUENCE #
	CAIE	T1,"2"		;IS THIS THE SECOND RECORD?
	RET			;NO GIVE A NON-SKIP ERROR RETURN
	CALL	LGIWD3		;WORK ON WORD THREE OF THE LOGIN ENTRY (DATE/TIME)
	CALL	LGIWD5		;WORK ON WORDS 5-N (ACCOUNT STRING)
	CALL	LGOWD4		;RUNTIME IS IN THIS RECORD. SO GET IT AND
				; SAVE IT FOR LATER (WORD 4, LOGOUT/CHKPNT)

;NOW ALL DATA HAS BEEN OBTAINED FROM THE SECOND USAGE RECORD.
;GO READ THE THIRD TO GET THE USER NAME

	CALL	SETRD		;GO READ ANOTHER RECORD
	LDB	T1,USESEQ	;GET THE RECORD SEQUENCE #
	CAIE	T1,"3"		;IS THIS THE THIRD RECORD?
	RET			;NO, GIVE A NON-SKIP RETURN
	CALL	LGIWD2		;WORK ON WORD 2 OF THE LOGIN ENTRY (USER NUMBER)
	CALL	FCTOUT		;NOW OUTPUT THE LOGIN ENTRY

;NOW MAKE A LOGOUT OR CHECKPOINT ENTRY. THE TWO DIFFERENCES OF THESE
;	ENTRIES ARE: 1)ENTRY TYPE AND 2) CHECKPOINT ENTRY HAS 0 FOR
;	THE CONSOLE TIME.

	CALL	LGOWD1		;WORK ON WORD 1 OF THE LOGOUT/CHECKPOINT ENTRY
	MOVE	T1,SAVUSR	;WORK ON WORD 2 OF THE LOGOUT/CHKPNT ENTRY
	STOR	T1,HDRUSR	;USER NUMBER HAS ALREADY BEEN FOUND
	MOVE	T1,SAVLDT	;WORK ON WORD 3
	STOR	T1,HDRDTM	;DATE/TIME HAS ALREADY BEEN FOUND
	MOVE	T1,SAVRUN	;WORK ON WORD 4
	STOR	T1,LGORUN	;RUNTIME HAS ALREADY BEEN FOUND
	CALL	LGOWD5		;WORK ON WORD 5
	CALL	FCTOUT		;OUTPUT THE ENTRY
	RETSKP			;DONE
;LGIWD1 - ROUTINE TO MAKE THE FIRST WORD OF A LOGIN ENTRY
;	THE ENTRY HEADER RECORD MUST BE IN USEBLK

LGIWD1:	MOVEI	T1,501		;LOGIN TYPE CODE
	STOR	T1,HDRTYP	;STORE IT
	MOVE	T1,USEJOB	;GET POINTER TO JOB #
	MOVEI	T2,LENJOB	; AND ITS LENGTH
	CALL	NUMDEC		;CONVERT
	STOR	T1,HDRJOB	;STORE IT
	MOVEM	T1,SAVJOB	;ALSO SAVE IT FOR THE LOGOUT ENTRY
	MOVE	T1,USELIN	;GET POINTER TO LINE #
	MOVEI	T2,LENLIN	; AND ITS LENGTH
	CALL	NUMOCT		;CONVERT
	STOR	T1,HDRLIN	;STORE IT
	MOVEM	T1,SAVLIN	;ALSO SAVE IT FOR THE LOGOUT ENTRY
	INCR	HDRCNT		;DONE WITH FIRST WORD
	RET


;LGIWD2 - ROUTINE TO MAKE WORD 2 OF A LOGIN ENTRY, A 36-BIT
;	USER NUMBER

LGIWD2:	MOVE	T1,USEUSR	;GET THE POINTER TO THE USER NAME
	CALL	USRNUM		;GET THE USER NUMBER
	STOR	T3,HDRUSR	;STORE IT
	INCR	HDRCNT		;DONE WITH ANOTHER WORD
	MOVEM	T3,SAVUSR	;ALSO SAVE IT
	RET			;AND RETURN


;LGIWD3 - ROUTINE TO MAKE WORD 3 OF THE LOGIN ENTRY.  THE DATE/TIME IS
;	FOUND IN THE SECOND USAGE RECORD OF A SESSION ENTRY.

LGIWD3:	MOVE	T1,USEBDT	;GET POINTER OF LOGIN DATE/TIME
	CALL	DATTIM		;CONVERT
	STOR	T2,HDRDTM	;STORE IT IN FACT FILE BLOCK
	MOVEM	T2,SAVBDT	;ALSO SAVE IT TO COMPUTE CONSOLE TIME IN LOGOUT ENTRY
	INCR	HDRCNT		;DONE WITH WORD 3
	RET

;LGIWD4 - ROUTINE TO MAKE WORD 4 OF LOGIN.  IT IS ALWAYS ZERO.

LGIWD4:	SETZRO	LGIZER		;STORE IT
	INCR	HDRCNT		;DONE WITH WORD 4
	RET
;LGIWD5/SPCWD5 - ROUTINE TO MAKE THE FIFTH THROUGH N WORDS, WHERE N IS THE NUMBER
;	OF WORDS NEEDED TO STORE THE ACCOUNT STRING.  AN ACCOUNT STRING
;	IS LEFT-JUSTIFIED SPACE-FILLED IN THE USAGE FILE

SPCWD5:
LGIWD5:	SETZRO	LGICHR		;MAKE SURE COUNT IS ZERO
	MOVE	T1,USEACT	;GET POINTER TO ACCOUNT STRING
	MOVEI	T2,LENACT	;AND ITS MAXIMUM LENGTH
	MOVE	T3,LGIACT	;SET UP A POINTER TO THE FACT ACCOUNT STRING
LGIW5A:	ILDB	T4,T1		;GET THE A CHARACTER
	CAIN	T4," "		;ARE WE FINISHED?
	JRST	LGIW5B		;GO FINISH UP
	IDPB	T4,T3		;STORE THE CHARACTER
	DECR	LGICHR		;COUNT THE CHARACTER (MUST BE NEGATIVE)
	SOJG	T2,LGIW5A	;HAVE WE REACHED 39 CHARS YET?
LGIW5B:	INCR	HDRCNT		;COUNT THE CHARACTER COUNT WORD
	LOAD	T1,LGICHR	;YES, GET THE CHARACTER COUNT
	MOVNS	T1		;MAKE THE COUNT POSITIVE
	IDIVI	T1,5		;GET THE WORD COUNT OF ACCOUNT STRING
	LOAD	T3,HDRCNT	;GET THE OLD ENTRY WORD COUNT
	ADD	T3,T1		;ADJUST THE COUNT
	CAIE	T2,0		;ARE THERE ANY CHARACTERS LEFT OVER?
	ADDI	T3,1		;YES, INDICATE ONE MORE WORD IN THE ENTRY
	STOR	T3,HDRCNT	;STORE IT
	RET			;AND RETURN


;LGOWD1 - ROUTINE TO MAKE WORD 1 OF A LOGOUT/CHECKPOINT ENTRY. IT
;	CONTAINS THE ENTRY TYPE, JOB #, LINE #, AND WORD COUNT
;	(ALWAYS 5).

LGOWD1:	MOVE	T1,SAVTYPE	;GET THE ENTRY TYPE
	CAIE	T1,2		;IS THIS A COMPLETE SESSION?
	SKIPA	T1,[201]	;NO. HAVE TO MAKE A CHECKPOINT ENTRY
	MOVEI	T1,141		;YES. HAVE TO MAKE A LOGOUT ENTRY
	STOR	T1,HDRTYP	;STORE IT
	MOVE	T1,SAVJOB	;GET THE JOB #
	STOR	T1,HDRJOB	;STORE IT
	MOVE	T1,SAVLIN	;GET THE LINE #
	STO