;**********************************************************************
;*
;*				SOFAR.LIT
;*         
;**********************************************************************
;
; WHAT:  Creates or appends to a file DAY.LOG in user's account.  DAY.LOG
; will contain today's date,time, the number of disc reads and writes,
; amount of CPU connect and usage for this session.
;
; WHY:  Very simple account usage/billing program.
;
; ORIGINATED AT: Victorex, Inc., 1529 Cypress Street, Suite 103, Walnut
; Creek, California 94596 (415) 943-1023 as BOOTUP.M68
;
; MANGLED AT:  Interstate Communications (504) 383-8695 in an attempt 
; to add CPU usage and CPU connect time to the report by Rhett McMahon.
;
; DATE:  12 June 1986

	SEARCH	SYS
	SEARCH	SYSSYM
	SEARCH	TRM

	EXTERN	$ODTIM,$OTCON,$OTCPU

; Process system date and time (Need LNKLIT to process LIT file)

DDBSIZ=D.DDB		; Define DDB size

VMAJOR=1
VMINOR=0
VSUB=11.		; 
VEDIT=100.		; Revision 0
VWHO=0

	PHDR	-1,0,PH$REU

; Allocate memory module for DDB
	PUSH	#D.DDB		; Size of DDB
	PUSH			; Push 2nd long word for GETMEM
	GETMEM	@SP		; Allocate impure mem module
	JNE	NOMEM
       	POP	A5		; Index mem module
	POP			; Restore SP
	CLEAR	@A5,D.DDB	; Clear memory

	CALL	OPNLOG		; Open output file log
	CLR	D3		; Clr for use with next call
	CLR	D5		; Clear D5 for use as flag
	ORW	#100000,D5	; Set bit for date output
	MOV	A5,A2		; Set up A2 indexing DDB
	CALL	$ODTIM		; Output current date and time
	CLR	D1
	JOBIDX	A0			; job index
;Display Disk reads and writes							[102]
	MOV	JOBDSR(A0),D1		; get number of disk reads performed
	DCVT	12,64			; output it
	CLR	D1
 	MOV	JOBDSW(A0),D1		; get number of disk writes
 	DCVT	12,64			; output it
 	CLR	D1
  	MOV	JOBCPU(A0),D1		; get CPU time used
 	PUSH	A2
	LEA	A2,FAKE
	CALL	$OTCPU			; format CPU time
	LEA	A4,FAKE			; move to A4
	POP	A2
	OUTL	@A4,OT$DDB		; Output CPU time
;
 	CLR	D1
 	MOV	JOBCON(A0),D1		; get connect time
 	PUSH	A2
	LEA	A2,FAKE
 	CALL	$OTCON			; format connect time
	LEA	A4,FAKE			; move to A4
	POP	A2
	OUTL	@A4,OT$DDB		; Output connect time
;
;
;
CLOSE5:	
	LEA	A4,CRLF$	; C/R, L/F
	OUTL	@A4,OT$DDB	; Output CR, LF
	CLOSE	@A5
	EXIT

NOMEM:	TYPECR	<?Insufficient memory>
	EXIT

; Open output file log
OPNLOG:	LEA	A2,FILNAM	; Index name of output file
	FSPEC	@A5		; Put name into DDB
	INIT	@A5		; Initialize a buffer module
	LOOKUP	@A5		; Does the file exist?
	BNE	NEWLOG		; Br to open new file
	OPENA	@A5		; Else open to append to old file
	RTN
NEWLOG:	OPENO	@A5		; Open new file
	RTN

FAKE:	ASCII	$            $
	BYTE	0
	EVEN

FILNAM:	ASCII	$DAY.LOG$
	BYTE	0
	EVEN

CRLF$:	BYTE	15,0		; C/R (L/F is automatic)
	EVEN

	END