character*3 month,months(12),yesno,filtyp character*9 actuic,loguic,newuic,olduic,uicon(0:40,4),DUIC character*8 acttim,logtim,timeon(0:40,4) character*9 actdat,logdat,dateon(0:40,4),actbgn,logbgn character*9 actend,logend character*2 acttty,logtty character*20 actbil,billng(0:40,4),accnam,accnm2 character*30 filnam character*120 actbuf,logbuf,savbuf integer hr,hron,sec,secon,min,minon integer rltn real hours common /chars/ uicon,timeon,dateon,billng,accnam(30),accnm2(30) common /nums/ accnum,rate(30),hours(30) data months/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG', + 'SEP','OCT','NOV','DEC'/ open(unit=1,name='[1,4]accounts.dat',organization='sequential', + form='formatted',recordtype='variable',type='old', + readonly,carriagecontrol='list',access='sequential') i=1 50 read(1,55,end=60) accnam(i) read(1,55) accnm2(i) read(1,56) rate(i) 55 format(a) 56 format(f5.2) 110 format(a) ! input for character 111 format(q,a) ! input for character with transfer count 115 format(1x,a) ! output for character 1151 format(1x,a,x,a) 116 format(/,'0',a,2x,a,2x,a) ! output for character with triple c space and with multiple outputs 117 format(' ',a,2x,f6.2,' mins') i=i+1 goto 50 60 accnum=i-1 close(unit=1,dispose='save') open(unit=5,name='ti:',recl=250,status='new') type 90 90 format('$What month (3 letters) ? ') accept 110,filtyp type 95 95 format('$Default file assignments (Y/N) ? ') accept 110,yesno if (yesno(1:1) .eq. 'y' .or. yesno(1:1) .eq. 'Y') then filnam(1:17) = '[1,4]acctlog.' filnam(18:20) = filtyp(1:3) filnam(21:30) = ' ' else type 100 100 format('$What is the Billing Account file name? ') accept 110,filnam endif c open syslogin.cmd file to find billing accounts open(unit=1,name=filnam,readonly,type='old') if (yesno(1:1) .eq. 'y' .or. yesno(1:1) .eq. 'Y') then filnam(1:16) = '[1,4]cumlog.' filnam(17:19) = filtyp(1:3) filnam(20:30) = ' ' else type 120 120 format('$What is the Log file name? ') accept 110,filnam endif c open console log file to find login, logout times open(unit=2,name=filnam,readonly,type='old') c c logerr.xxx will hold all tktn and other messages filnam(1:16) = '[1,4]logerr.' filnam(17:19) = filtyp(1:3) filnam(20:30) = ' ' open(unit=3,recl=250,name=filnam,type='new') c logunk.xxx will hold all unknown messages filnam(1:16) = '[1,4]logunk.' filnam(17:19) = filtyp(1:3) filnam(20:30) = ' ' open(unit=4,recl=250,name=filnam,type='new') c smrylg.xxx will list all completed transactions filnam(1:16) = 'sy:[1,4]smrylg.' filnam(17:19) = filtyp(1:3) filnam(20:30) = ' ' type 101 101 format('$Do you want the summary log (Y/N) ? ') accept 110,yesno if (yesno(1:1) .eq. 'y' .or. yesno(1:1) .eq. 'Y') then open(unit=6,recl=250,name=filnam,type='new') else open(unit=6,recl=250,name='nl:dummy.dmp',type='new') endif c billing.xxx will list all the accounts with amount used filnam(1:17) = '[1,4]billing.' filnam(18:20) = filtyp(1:3) filnam(21:30) = ' ' open(unit=7,recl=250,name=filnam,type='new') c c act1st = 1 ! set for first account read log1st = 1 ! set for first log read c c c hldlog=0 ! read logbuf first time through do 125 i=0,40 do 125 j=1,4 ! j = term type , 1-tt 2-ht 3-vt 4-rt uicon(i,j)='idle ttxx' dateon(i,j)='date' timeon(i,j)='time' billng(i,j)='none' 125 continue 130 continue D TYPE *,'READY TO READ ACTBUF' read(1,111,end=150) j,actbuf d TYPE 115,ACTBUF(1:J) if (index(actbuf,'Init').ne.0 + .or. + index(actbuf,'INIT').ne.0 + .or. + index(actbuf,'init').ne.0 + .or. + j.lt.7) goto 130 ! if this is the init mssg or c a blank line, skip it i=index(actbuf,'Login') i1=index(actbuf,'LOGIN') if (i.eq.0 .and. i1.eq.0) then ! this is not a login message i=index(actbuf,'Relog') ! is it a relog message? i1=index(actbuf,'RELOG') if (i.eq.0 .and. i1.eq.0) + stop 'TIMELOG -- ERROR #1 IN ACCOUNT FILE' irelog=1 else ! this is a login message irelog=0 endif i=index(actbuf,'-') actdat=actbuf(i-2:i+6) i=index(actbuf,':') acttim=actbuf(i-2:i+5) i=index(actbuf,'.') acttty=actbuf(i-2:i-1) d TYPE *,'PROCESSING ACTBUF[I-4:I-1] = ',ACTBUF(I-4:I-1) if (acttty(1:1) .eq. 'T') acttty(1:1) = ' ' iterm = 1 if (actbuf(i-4:i-3) .eq. 'VT') iterm = 3 if (actbuf(i-3:i-2) .eq. 'VT') iterm = 3 if (actbuf(i-3:i-2) .eq. 'HT') iterm = 2 if (actbuf(i-4:i-3) .eq. 'HT') iterm = 2 if (actbuf(i-3:i-2) .eq. 'RT') iterm = 4 if (actbuf(i-4:i-3) .eq. 'RT') iterm = 4 d TYPE *,'ITERM',ITERM read(1,111) j,actbuf d TYPE 115,ACTBUF(1:J) i=index(actbuf,'USER IS') i1=index(actbuf,'User is') i2=index(actbuf,'Changing') i3=index(actbuf,'CHANGING') if ( (i.eq.0 .and. i1.eq.0 .and. irelog.eq.0) + .or. + (i2.eq.0 .and. i3.eq.0 .and. irelog.eq.1) ) + stop 'TIMELOG -- ERROR #2 IN ACCOUNT FILE' i=index(actbuf,'[') j=index(actbuf(i:),']') actuic=' ' ! pad with zero's for compatibilty actuic(1:j) = actbuf(i:j+i) ! get named uic or ggg,mmm uic d write(5,3939) i,j,'test','string' d type *,'using actbuf - ' d type 3939,i,j,actbuf(i:i+j),actuic 3939 format(2x,'---------i: ',i2,' j: ',i2 + ,' xxxbuf(i:i+j):',a,': xxxuic:',a,':') c if (irelog.eq.1) then oldi=i olduic=actuic i=index(actbuf(oldi:),'[') j=index(actbuf(i:),']') c actuic='000,000' ! pad with zero's for compatibilty actuic(1:j) = actbuf(i:i+j) ! get named uic or ggg,mmm uic newuic=actuic endif c read(1,111) j,actbuf d TYPE 115,ACTBUF(1:J) if (index(actbuf,'Billing').eq.0 + .and. + index(actbuf,'BILLING').eq.0) + stop 'TIMELOG -- ERROR #3 IN ACCOUNT FILE' i=index(actbuf,'CONTINUE') i1=index(actbuf,'Continue') if (irelog.eq.1 + .and. + (i1.ne.0 .or. i.ne.0) ) then c for 'continue with current billing account' decode(2,135,acttty) itty ! get terminal as an integer 135 format(i2) actbil=billng(itty,iterm) ! get current billing account else ! for new billing accounts i=index(actbuf,'is') if (i.eq.0) i=index(actbuf,'IS') j2=index(actbuf,'.') actbil=actbuf(i+3:j2-1) endif if (irelog.eq.1) then ! relog an account d TYPE 137,'RELOG: ',ACTTTY,ACTDAT,ACTTIM,OLDUIC,ACTBIL 137 FORMAT(1X,A,A,A,A,A,A) call logout(acttty,actdat,acttim,olduic,iterm) call login(acttty,actdat,acttim,newuic,actbil,iterm) if (act1st.eq.1) then actbgn = actdat act1st = 0 endif goto 130 ! back for a new account file entry endif c ! here with a valid new account login c check for saving start if (act1st.eq.1) then actbgn = actdat act1st = 0 endif c c 140 if (hldlog.ne.1) then d type *,'ready to read logbuf' 9140 read(2,111,end=160) j,logbuf ! if new account and d TYPE 141,LOGBUF(1:J) 141 FORMAT(1X,A) if (index(logbuf,'Init').ne.0 + .or. + index(logbuf,'INIT').ne.0 + .or. + index(logbuf,'init').ne.0 + .or. + j.lt.7) goto 9140 ! if this is the init mssg or c a blank line, skip it endif hldlog=0 c same log 145 call type(logbuf,itype) ! find out what type of entry if (itype.eq.0) then ! unknown entry type write(4,115) logbuf(1:j) else if (itype.eq.1) then ! COT -- Date is ... i=index(logbuf,'Date') j=index(logbuf(i:),'-') j=j+i-1 logdat=logbuf(j-2:j+6) if (logdat(1:1).eq.' ') logdat(1:1)='0' logtim=logbuf(1:8) if (log1st.eq.1) then logbgn = logdat log1st = 0 endif call tsttim(acttim,actdat,logtim,logdat,rltn) c rltn = 1 -> log entry is prior to account entry (OK) c rltn = 0 -> log entry is at same time as account c entry (OK) c rltn = -1 -> log entry is after account entry; this c implies no corresponging log entry for c the account entry (ERROR) C*************************** TYPE 69696,'COT',LOGDAT ! ,RLTN 69696 FORMAT(1X,A,' DATE IS ~',A,'~') ! ,2X,'RLTN IS ',I2) C*************************** if (rltn.lt.0) then hldlog=1 ! don't read a new log entry goto 130 ! but get a new account entry endif else if (itype.eq.2 .or. itype.eq.3) then ! ERRLOG or TKTN write(3,9115) logdat,logbuf(1:j) 9115 format(1x,a,2x,a) else if (itype.eq.6) then ! broadcast logtim=logbuf(1:8) i=index(logbuf,'-') logdat=logbuf(i-2:i+6) if (logdat(1:1).eq.' ') logdat(1:1)='0' if (log1st.eq.1) then logbgn = logdat log1st = 0 endif read(2,110) logbuf ! get message call tsttim(acttim,actdat,logtim,logdat,rltn) c rltn = 1 -> log entry is prior to account entry (OK) c rltn = 0 -> log entry is at same time as account c entry (OK) c rltn = -1 -> log entry is after account entry; this c implies no corresponging log entry for c the account entry (ERROR) C*************************** d TYPE 69696,'BRO',LOGDAT,RLTN C*************************** if (rltn.lt.0) then hldlog=1 ! don't read a new log entry goto 130 ! but get a new account entry endif if (index(logbuf,'START-UP').ne.0) then c start everyone off... duic='1,377' call clenup(logdat,logtim,duic) c log on the console user for start-up activities duic='1,377' call login(' 0',logdat,logtim,duic, + 'sys maint ',1) else if (index(logbuf,'SHUT-DOWN').ne.0) then call logout('ff',logdat,logtim,loguic,1) else write(3,115) logbuf(1:j) endif else if (itype.eq.4 .or. itype.eq.-4) then ! login d TYPE *,' STARTING LOGON PROCEDURE' if(itype.eq.4) then logtim=logbuf(1:8) i=index(logbuf,'[') j1=index(logbuf(i:),']') loguic=' ' ! pad with zero's for compatibilty loguic(1:j1) = logbuf(i:i+j1) ! get uic or ggg,mmm d type 3939,i,j1,logbuf(i:i+j1),loguic if ( index(logbuf,'TT') .ne. 0) then i = index(logbuf,'TT') iterml = 1 else if ( index(logbuf,'HT') .ne. 0) then i = index(logbuf,'HT') iterml = 2 else i = index(logbuf,'RT') iterml = 4 endif j1=index(logbuf(i:),':') j1=j1+i-1 logtty=' ' logtty(5-j1+i:2)=logbuf(i+2:j1-1) else logtim=logbuf(1:8) loguic = 'batch job' ! no uic for vt login i=index(logbuf,'VT') j1=index(logbuf(i:),':') j1=j1+i-1 logtty=' ' logtty(5-j1+i:2)=logbuf(i+2:j1-1) iterml = 3 endif d TYPE 153,'LOGGING IN',LOGDAT,LOGTIM,LOGUIC,LOGTTY,iterml call tsttim(acttim,actdat,logtim,logdat,rltn) d IF (ITYPE.LT.0) TYPE *,'BACK FROM TSTTIM RLTN = ',RLTN c rltn = 1 -> log entry is prior to account entry (OK) c rltn = 0 -> log entry is at same time as account c entry (OK) c rltn = -1 -> log entry is after account entry; this c implies no corresponging log entry for c the account entry (ERROR) if (rltn.lt.0) then hldlog=1 ! don't read a new log entry goto 130 ! but get a new account entry endif if (actdat.eq.'00-end-00') then write(6,116) + 'TIMELOG --',logdat, + 'CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' write(6,115) + ' END OF ACCOUNT FILE' type *, + 'TIMELOG -- CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' type *,' END OF ACCOUNT FILE' actbil='LOST REVENUE' call login(logtty,logdat,logtim,loguic,actbil,iterml) else if (actdat.ne.logdat) then ! wrong day.... type *, + 'TIMELOG -- CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' type *,' DATE IS TOO EARLY' write(6,116) + 'TIMELOG --',logdat, + 'CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' write(6,115) + ' DATE IS TOO EARLY' write(6,1151) + ' ACCOUNT DATE: ',ACTDAT actbil='LOST REVENUE' call login(logtty,logdat,logtim,loguic,actbil,iterml) if (isave.eq.1) then ! we have a saved log entry logbuf=savbuf ! pull it out hldlog=1 ! don't read a new log entry jsave=2 ! indicate using saved entry D type *,'TIMELOG -- RESTORING SAVED LOG ENTRY' D type *,' -- ',logbuf else if (isave.eq.2) then ! just used a saved log entry jsave=0 ! indicate no saved entries hldlog=0 ! get a new log entry D type *,'TIMELOG -- USED SAVED LOG ENTRY' D type *,' -- ',logbuf endif c isave=jsave d if (isave.ne.0) TYPE *,'ISAVE:',ISAVE goto 140 endif c c find time difference between logtim and acttim c decode(8,9145,logtim) hron,minon,secon 9145 format(i2,1x,i2,1x,i2) decode(8,9145,acttim) hr,min,sec rlgtim=float(hron)*60.+float(minon)+float(secon)/60. ractim=float(hr)*60.+float(min)+float(sec)/60. delta=ractim-rlgtim c d TYPE *,'LOGON ACTTTY:',ACTTTY,' LOGTTY:',LOGTTY if (acttty.eq.logtty) then ! account entry and log entry c match - same terminal if (delta .gt. 4.01) then type *, + 'TIMELOG -- CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' type *,' TIME IS TOO EARLY:',DELTA type *,logbuf write(6,1161) + 'TIMELOG --',logdat, + 'CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY ON TT',LOGTTY,':' 1161 FORMAT('0',a,2x,a,2x,a,a,a) write(6,117) + ' TIME IS TOO EARLY, DELTA: ',delta Write(6,115) logbuf d type *,hron,minon,secon,hr,min,sec,delta actbil='LOST REVENUE' call login(logtty,logdat,logtim,loguic,actbil,iterml) if (isave.eq.1) then ! we have a saved log entry logbuf=savbuf ! pull it out hldlog=1 ! don't read a new log entry jsave=2 ! indicate using saved entry D type *,'TIMELOG -- RESTORING SAVED LOG ENTRY' D type *,' -- ',logbuf else if (isave.eq.2) then ! just used a saved log entry jsave=0 ! indicate no saved entries hldlog=0 ! get a new log entry D type *,'TIMELOG -- USED SAVED LOG ENTRY' D type *,' -- ',logbuf endif c isave=jsave d if (isave.ne.0) TYPE *,'ISAVE:',ISAVE goto 140 else if (delta.lt.0.0) then stop 'TIMELOG -- ERROR WITH TSTTIM: -''VE DELTA' endif c if (actuic.ne.loguic .and. itype.eq.4) then d type *,'TIMELOG -- MISMATCHED UIC''S ON LOGIN' d type *,' -- loguic: ',loguic,' actuic:', d + actuic d type *,' -- using console log UIC' write(6,116) 'TIMELOG --',logdat, + 'MISMATCHED UIC''S ON LOGIN' write(6,115) + ' -- using console log UIC' endif c i=index(actbuf,'is') if (i.eq.0) i=index(actbuf,'IS') j2=index(actbuf,'.') actbil=actbuf(i+3:j2-1) d TYPE 137,'LOGIN--',ACTTTY,LOGDAT,LOGTIM,LOGUIC,ACTBIL if (itype.eq.-4) loguic=actuic call login(acttty,logdat,logtim,loguic,actbil,iterm) jsave=0 c if (isave.eq.1) then ! we have a saved log entry logbuf=savbuf ! pull it out hldlog=1 ! don't read a new log entry jsave=2 ! indicate using saved entry D type *,'TIMELOG -- RESTORING SAVED LOG ENTRY' D type *,' -- ',logbuf else if (isave.eq.2) then ! just used a saved log entry jsave=0 ! indicate no saved entries hldlog=0 ! get a new log entry D type *,'TIMELOG -- USED SAVED LOG ENTRY' D type *,' -- ',logbuf endif c isave=jsave d if (isave.ne.0) TYPE *,'ISAVE:',ISAVE goto 130 ! used this account entry c go back for a new one c c ! woops, not the same terminal else ! more account entries d TYPE *,'WOOPS......WRONG TERMINAL' if (delta.gt.6.0) then ! only save 6 mins back type *, + 'TIMELOG -- CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' type *,' TOO EARLY TO SAVE' type *,' ',logbuf write(6,116) + 'TIMELOG --',logdat, + 'CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' write(6,117) + ' TOO EARLY FOR SAVE, DELTA: ',delta write(6,115)logbuf d type *,hron,minon,secon,hr,min,sec,delta actbil='LOST REVENUE' call login(logtty,logdat,logtim,loguic,actbil,iterml) if (isave.eq.1) then ! we have a saved log entry logbuf=savbuf ! pull it out hldlog=1 ! don't read a new log entry jsave=2 ! indicate using saved entry D type *,'TIMELOG -- RESTORING SAVED LOG ENTRY' D type *,' -- ',logbuf else if (isave.eq.2) then ! just used a saved log entry jsave=0 ! indicate no saved entries hldlog=0 ! get a new log entry D type *,'TIMELOG -- USED SAVED LOG ENTRY' D type *,' -- ',logbuf endif c isave=jsave d if (isave.ne.0) TYPE *,'ISAVE:',ISAVE else if (isave.eq.0) then savbuf=logbuf isave=1 D type *,'TIMELOG -- SAVING LOG ENTRY' D type *,' ',logbuf goto 140 else if (isave.eq.1) then type *, + 'TIMELOG -- ACCOUNT FILE ENTRY WITHOUT CONSOLE LOGIN' type *,' -- two console logins tried' type *,' -- Current: ',logbuf type *,' -- Saved: ',savbuf write(6,116) + 'TIMELOG --',logdat, + 'ACCOUNT FILE ENTRY WITHOUT CONSOLE LOGIN' write(6,1162)' --','Saved:',savbuf write(6,1162)' --','Current:',logbuf 1162 format(' ',a,x,a,x,a) backspace 1 ! back to current actbuf backspace 1 ! back to last actbuf (user is) backspace 1 ! back to last last one (login) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) backspace 2 ! go back to get current logbuf c ! after retrying saved entry c ! with a new account entry logbuf=savbuf isave=2 hldlog=1 goto 130 else if (isave.eq.2) then type *, + 'TIMELOG -- CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' type *,' AFTER RESTORE FROM SAVE' type *,logbuf write(6,116) + 'TIMELOG --',logdat, + 'CONSOLE LOGIN WITHOUT ACCOUNT FILE ENTRY' write(6,115) + ' AFTER RESTORE FROM SAVE' write(6,115) logbuf actbil='LOST REVENUE' call login(logtty,logdat,logtim,loguic,actbil,iterml) hldlog=0 isave=0 endif d if (isave.ne.0) TYPE *,'ISAVE:',ISAVE endif else if (itype.eq.5 .or. itype.eq.-5) then ! logout d TYPE *,'STARTING LOGOUT PROCEDURE, ITYPE = ',ITYPE if (itype.eq.5) then d TYPE *,'STANDARD LOGOUT PROCEDURE, ITYPE = ',ITYPE logtim=logbuf(1:8) i=index(logbuf,'[') j=index(logbuf(i:),']') loguic=' ' ! pad with zero's for compatibilty loguic(1:j) = logbuf(i:i+j) ! get group number d type 3939,i,j,logbuf(i:i+j),loguic if (index(logbuf,'HT') .ne. 0) then i = index(logbuf,'HT') iterml = 2 else if (index(logbuf,'RT') .ne. 0) then i = index(logbuf,'RT') iterml = 4 else i = index(logbuf,'TT') iterml = 1 endif j=index(logbuf(i:),':') j=j+i-1 logtty=' ' logtty(5-j+i:2)=logbuf(i+2:j-1) else d TYPE *,'VIRTUAL LOGOUT PROCEDURE, ITYPE = ',ITYPE logtim = logbuf(1:8) loguic = 'batch job' i=index(logbuf,'VT') j=index(logbuf(i:),':') j=j+i-1 logtty=' ' logtty(5-j+i:2)=logbuf(i+2:j-1) iterml = 3 endif d TYPE 153,'LOGOUT--',LOGTTY,LOGDAT,LOGTIM,LOGUIC,iterml 153 FORMAT(1X,A,4X,4(':',A,':'),i2) call logout(logtty,logdat,logtim,loguic,iterml) else ! ???? write(4,115) logbuf(1:j) endif goto 140 ! get a new log entry 150 actend = actdat ! save last account date actdat='00-end-00' ! set end of account file acttty='99' hldlog=0 goto 140 ! get a new log entry 160 logend = logdat ! save last log date call date(logdat) write (7,165) logdat,actbgn,actend,logbgn,logend 165 format('0 Summary of Accounts, compiled on ',a,//, + ' Account file from ',a,' to ',a,'.',/, + ' Logging file from ',a,' to ',a,'.',///, + t10,'Account Name',t30,'Hours',t40,'Rate',t50,'Charges',/, + t10,'------------',t30,'-----',t40,'----',t50,'-------',/) do 170 i=1,accnum if (hours(i).eq.0) goto 170 write(7,175) accnam(i),hours(i),rate(i),rate(i)*hours(i) 170 continue 175 format(1x,t10,a,t29,f6.2,t39,f5.2,t49,f8.2) close(unit=1,dispose='save') close(unit=2,dispose='save') close(unit=3,dispose='save') close(unit=4,dispose='save') close(unit=6,dispose='save') close(unit=7,dispose='save') end c c c subroutine login(tty,date,time,uic,accnt,iterm) character*2 tty character*9 uic,uicon(0:40,4) character*8 time,timeon(0:40,4) character*9 date,dateon(0:40,4) character*20 accnt,billng(0:40,4),accnam common /chars/ uicon,timeon,dateon,billng,accnam(30) decode (2,100,tty) itty 100 format(i2) if ( uicon(itty,iterm).ne.'idle ttxx' ) then D type *,'TIMELOG -- LOGIN TO LOGGED IN TERMINAL' call logout(tty,date,time,uic,iterm) endif d TYPE *,'LOGIN: ',ITTY,iterm uicon(itty,iterm)=uic timeon(itty,iterm)=time dateon(itty,iterm)=date billng(itty,iterm)=accnt d TYPE 110,UIC,TIME,DATE,ACCNT d TYPE 110,UICON(ITTY,iterm),TIMEON(ITTY,iterm),DATEON(ITTY,iterm) d + ,BILLNG(ITTY,iterm) 110 FORMAT(1X,4(':',A,':')) return end c c c subroutine clenup(date,time,uic) character*2 tty,dtty character*9 uic,uicon(0:40,4),duic character*8 time,timeon(0:40,4) character*9 date,dateon(0:40,4) character*20 accnt,billng(0:40,4),accnam,accnm2 common /chars/ uicon,timeon,dateon,billng,accnam(30),accnm2(30) common /nums/ accnum,rate(30),hours(30) do 105 i=0,40 do 105 j=1,4 if (uicon(i,j).ne.'idle ttxx') then do 9105 i9105=5,6 write(i9105,9101) + 'TIMELOG -- IMPROPER SHUTDOWN: TERMINAL ',i, + ' STILL ACTIVE.' 9101 format('0',a,i2,a) write(6,9102) dateon(i,j),timeon(i,j),billng(i,j) 9102 format(' ON AT:',2x,a,2x,a,' ; BILLING TO: ',a) 9105 continue if (date.eq.dateon(i,j)) then write(5,9107) write(6,9107) 9107 format(' SYSTEM CRASH ASSUMED: IMPLIED LOGOFF AT' + ,' START-UP') 100 format(i2) encode(2,100,dtty) i duic=uicon(i,j) call logout(dtty,date,time,duic,j) endif endif uicon(i,j)='idle ttxx' dateon(i,j)=date timeon(i,j)=time billng(i,j)='none' 105 continue return end c c c subroutine logout(tty,date,time,uic,iterm) character*2 tty,typ(4) character*3 month,months(12) character*9 uic,uicon(0:40,4) character*8 time,timeon(0:40,4) character*9 date,dateon(0:40,4) character*20 accnt,accnt1,billng(0:40,4),accnam,accnm2 real hours integer hr,hron,sec,secon,min,minon common /chars/ uicon,timeon,dateon,billng,accnam(30),accnm2(30) common /nums/ accnum,rate(30),hours(30) data months/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG', + 'SEP','OCT','NOV','DEC'/ data typ /'TT','HT','VT','RT'/ if (tty.eq.'ff') then istrt = 0 iend = 40 itrms = 1 itrme = 4 else decode (2,100,tty) itty 100 format(i2) istrt=itty iend=itty itrms = iterm itrme = iterm endif d type *,'in logout, tty:',tty do 200 j200=itrms,itrme do 200 i200=istrt,iend if ( uicon(i200,j200).eq.'idle ttxx') then if (tty.ne.'ff') type *,'TIMELOG -- TERMINAL ALREADY IDLE' d type *,' idle on tty: ',i200,' type ',j200 else if ( uic.ne.uicon(i200,j200) .and. uic.ne.'batch job' ) then write(6,110) date,time,uic,uicon(i200,j200) d write(5,110) date,time,uic,uicon(i200,j200) 110 format('0','TIMELOG -- ',a,x,a,x,'LOGOUT FROM ',a, + ':',3x,'LOGIN ONTO ',a,'.') endif uicon(i200,j200)='idle ttxx' acct=0 accnt=billng(i200,j200) accnt1=accnt 115 do 120 i120=1,accnum 120 if ( accnt.eq.accnam(i120) + .or. + accnt.eq.accnm2(i120) ) acct=i120 if (acct.eq.0) then if (index(accnt,'CLASS WORK') .ne. 0) then accnt1=accnt accnt='CLASS WORK' else type *,'TIMELOG -- INVALID BILLING ACCOUNT: ',accnt write(6,116) 'TIMELOG -- INVALID BILLING ACCOUNT:',accnt 116 format('0',a,x,a:,x,a:,x,a:) accnt='unknown account' accnt1=accnt endif goto 115 endif if ( date.ne.dateon(i200,j200) ) then decode(9,125,dateon(i200,j200) ) iday,month,iyear 125 format(i2,1x,a,1x,i2) do 130 i130=1,12 130 if ( month.eq.months(i130) ) imonth=i130 decode(9,125,date) idayx,month,iyearx do 135 i135=1,12 135 if ( month.eq.months(i135) ) imnthx=i135 if ( imonth.ne.imnthx + .or. + iyear.ne.iyearx ) then d TYPE *,IMONTH,IMNTHX,IYEAR,IYEARX type 140,dateon(i200,j200),date 140 format('$TIMELOG -- HOW MANY DAYS', + ' BETWEEN: ',A,' AND ',A,'? ') accept 143,idays 143 format(i3) else idays=iday-idayx endif else idays=0 endif decode(8,145,timeon(i200,j200)) hron,minon,secon 145 format(i2,1x,i2,1x,i2) decode(8,145,time) hr,min,sec rhours=idays*24. rhours=rhours + float(hr-hron) rhours=rhours + (float(min-minon))/60. rhours=rhours + (float(sec-secon))/3600. if (rhours.lt.0.005) rhours=0.0 rcost=rhours * rate(acct) d TYPE *,'LOGOUT: ',i200,j200 d TYPE *,' ON AT: ',HRON,MINON,SECON d TYPE *,' OFF AT: ',HR,MIN,SEC d TYPE *,' DELTA: ',RHOURS write(6,150) dateon(i200,j200),timeon(i200,j200),typ(j200),i200, + date,time, + uic,accnt1, + rhours,rate(acct), + rcost 150 format('0',3x,a,2x,a,2x,'Start of user session on ',a ,i2 + ,/,4x,a,2x,a,2x,'End of user session:' + ,/,25x,' Account number ',a,'; Bill to ',a + ,/,25x,' Connect time: ',f8.4,' @Rate' + ,' of $',f5.2,'/hr.' + ,/,25x,' Total cost: ',f6.2) hours(acct)=hours(acct)+rhours endif 200 continue 210 continue return end c c c subroutine type(logbuf,itype) character*120 logbuf if (index(logbuf,'COT -- Date').ne.0) then itype=1 else if (index(logbuf,'ERRLOG').ne.0) then itype=2 else if (index(logbuf,'***').ne.0) then itype=3 else if (index(logbuf,'terminated').ne.0) then itype=3 else if (index(logbuf,'Login').ne.0) then itype=4 else if (index(logbuf,'Logout').ne.0) then itype=5 else if (index(logbuf,'CBDLAB::').ne.0) then itype=6 else if (index(logbuf,'CEDLAB::').ne.0) then itype=6 else if (index(logbuf,'Batch job').ne.0) then if (index(logbuf,'started').ne.0) then itype = -4 else if (index(logbuf,'comp').ne.0) then itype = -5 endif else itype=0 endif return end c c c subroutine tsttim(acttim,actdat,logtim,logdat,rltn) character*120 actbuf character*9 actdat,logdat character*8 acttim,logtim character*3 month,months(12) integer rltn integer hr,hron,sec,secon,min,minon data months/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG', + 'SEP','OCT','NOV','DEC'/ if (actdat.ne.logdat) then decode(9,125,actdat) iday,month,iyear 125 format(i2,1x,a,1x,i2) do 130 i130=1,12 130 if ( month.eq.months(i130) ) imonth=i130 d TYPE 133,LOGDAT d133 FORMAT('0:',A,':') decode(9,125,logdat) idayx,month,iyearx do 135 i135=1,12 135 if ( month.eq.months(i135) ) imnthx=i135 if ( iyearx.gt.iyear ) then rltn=-1 else if ( iyearx.lt.iyear ) then rltn=1 else if ( imnthx.gt.imonth) then rltn=-1 else if ( imnthx.lt.imonth) then rltn=1 else if ( idayx.gt.iday) then rltn=-1 else if ( idayx.lt.iday) then rltn=1 else type *,'TIMELOG -- TSTTIM - LOGDAT = ACTDAT :' type *,' ',logdat,actdat endif else if (acttim.ne.logtim) then decode(8,145,acttim) hron,minon,secon 145 format(i2,1x,i2,1x,i2) decode(8,145,logtim) hr,min,sec timact=float(secon) + 60. * ( float(minon) + 60. * float(hron) ) timlog=float(sec) + 60. * ( float(min) + 60. * float(hr) ) if (timact.gt.timlog) rltn=1 c if (timact.lt.timlog) then rltn=-1 type *, + 'TIMELOG -- ACCOUNT FILE ENTRY WITHOUT CONSOLE LOGIN' write(6,116) + 'TIMELOG --',logdat, + 'ACCOUNT FILE ENTRY WITHOUT CONSOLE LOGIN' backspace 1 ! back to current actbuf backspace 1 ! back to last actbuf (user is) backspace 1 ! back to last last one (login) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) read(1,111) j,actbuf write(4,115) actbuf(1:j) write(6,115) actbuf(1:j) 110 format(a) ! input for character 111 format(q,a) ! input for character with transfer count 115 format(1x,a) ! output for character 116 format('0',a,2x,a,2x,a) ! output for character with double spacing c and multiple outputs endif c if (timact.eq.timlog) then type *,'TIMELOG -- TSTTIM - LOGTIM = ACTTIM :' type *,' ',logtim,acttim endif c else rltn=0 endif return end