
C******************************************************************************
	SUBROUTINE AK$GET_REC(ISTAT)
C******************************************************************************
C  AKGETREC.FOR
C
C  written by:  M. Serrer
C  date:        March 1984
C
	INCLUDE 'AK.INC/NOLIST'
	INCLUDE 'MK.INC/NOLIST'
C
	TOTAL_RECORDS=0
	PRCDEL_COUNT=0
	IMGDEL_COUNT=0
	SYSINIT_COUNT=0
	LOGFAIL_COUNT=0
	PRINT_COUNT=0
	USER_COUNT=0
C
  10	CONTINUE
C
C_Get record from VAX Accounting file  'SYS$ACCOUNT:ACCOUNTNG.OLD'
C
	READ(RAW_FIL,'(Q,256A1)',END=999) N,(AK$ACC_REC(I),I=1,N)
	TOTAL_RECORDS=TOTAL_RECORDS+1
C
C_Extract information fields from record
C
	CALL MK$GET_INFO(AK$ACC_REC,MK$REC_TYP,RET_STATUS)
C
	IF (.NOT.RET_STATUS) THEN
	  IF (MK$REC_TYP.EQ.ACR$K_FILE_BL) THEN
	    AK$START_DATE(1)=MK$SYS_TIM(1)
	    AK$START_DATE(2)=MK$SYS_TIM(2)
	    ISTAT=SYS$ASCTIM(,START_STR,AK$START_DATE,)
	    GOTO 10
	  ELSE IF (MK$REC_TYP.EQ.ACR$K_FILE_FL) THEN
	    AK$END_DATE(1)=MK$SYS_TIM(1)
	    AK$END_DATE(2)=MK$SYS_TIM(2)
	    ISTAT=SYS$ASCTIM(,END_STR,AK$END_DATE,)
	    GOTO 10
	  ELSE
	    TYPE*,'*** ERROR, Problem in MK$GET_INFO'
	    GOTO 10
	  END IF
	END IF
C
C_Find entry in AK$SUMMARY for owner of current record
C
	DO USER=1,TOT_USR
	  AK$RECORD=AK$SUMMARY(USER)
	  CALL STRIP(AK$USR_NAM,N1)
	  CALL STRIP(MK$USR_NAM,N2)
	  IF (AK$USR_NAM(1:N1).EQ.MK$USR_NAM(1:N2)) GOTO 20
	END DO

C
C_No match found for this user so add a record for him
C_Probably old USERNAME, blown away since the last time
C_AKCOUNT was run.
C
	IF (MK$USR_NAM(1:N2).EQ.'JOB_CONTROL') GOTO 10
	IF (MK$USR_ACC(1:7).EQ.'<login>') GOTO 20
C
	TYPE*,'*** INFO, No match found for user ',MK$USR_NAM(1:N2),
     &	      ' in SYSUAF.DAT'
C
	TOT_USR=TOT_USR+1
	USER=TOT_USR
	AK$RECORD=AK$SUMMARY(USER)
	AK$USR_NAM=MK$USR_NAM(1:N2)
	AK$USR_GRP=MK$USR_GRP
	AK$USR_MEM=MK$USR_MEM
	DO L=1,8
	  IF(MK$USR_ACC(L:L).EQ.CHAR(0)) MK$USR_ACC(L:L)=' '
	END DO
	AK$USR_ACC=MK$USR_ACC
C
C_Insert extracted fields in new format into the array AK$SUMMARY
C
  20	CONTINUE
C
	IF (MK$REC_TYP.EQ.ACR$K_PRCDEL) THEN
	  CALL DO_PRCDEL
	ELSE IF (MK$REC_TYP.EQ.ACR$K_IMGDEL) THEN
	  CALL DO_IMGDEL
	ELSE IF (MK$REC_TYP.EQ.ACR$K_PRINT) THEN
	  CALL DO_PRINT
	ELSE IF (MK$REC_TYP.EQ.ACR$K_SYSINIT) THEN
	  CALL DO_SYSINIT
	ELSE IF (MK$REC_TYP.EQ.ACR$K_LOGFAIL) THEN
	  CALL DO_LOGFAIL
	ELSE IF (MK$REC_TYP.EQ.ACR$K_USER) THEN
	  CALL DO_USER
	ELSE
	  TYPE*,'*** ERROR, Invalid record type in ACCOUNTNG.OLD'
	END IF
C
	AK$SUMMARY(USER)=AK$RECORD
C
	GOTO 10

C
C  Print summary of work done on ACCOUNTNG.OLD
C
 999	CONTINUE
	TYPE 200,START_STR,END_STR,MORN_HR,MORN_MIN,AFT_HR,AFT_MIN,
     &	         TOTAL_RECORDS
 200	FORMAT(/,T12,'SUMMARY OF RECORDS READ FROM ACCOUNTNG.OLD',
     &	       /,T12,'------------------------------------------',
     &	      //,T10,'START date ....... ',A24,
     &	       /,T10,'END date ......... ',A24,
     &	      //,T10,'PRIME time is .... ',I2,':'I2.2,
     &	             ' to ',I2,':',I2.2
     &	      //,T10,'TOTAL records read = ',I7)
C
	CALL DO_TOTALS
	TYPE*,' '
C
	RETURN
	END
C
C
C
C******************************************************************************
	SUBROUTINE STRIP(IN_OUT_STRING,STR_LEN)
C******************************************************************************
C
C	  Strip non printing characters from the string IN_OUT_STRING
C	and return the number of printing characters in STR_LEN.
C
C------------------------------------------------------------------------------
C
	CHARACTER*12 IN_OUT_STRING,CHR_STRING
	LOGICAL*1 LOG_STRING(12)
	INTEGER*4 STR_LEN
	EQUIVALENCE (CHR_STRING,LOG_STRING)
C
	CHR_STRING=IN_OUT_STRING
C
	STR_LEN=0
	DO I=1,12
	  IF (LOG_STRING(I).GT.32) THEN
	    STR_LEN=STR_LEN+1
	    IN_OUT_STRING(STR_LEN:STR_LEN)=CHR_STRING(I:I)
	  END IF
	END DO
C
	RETURN
	END
