        character*24 fdate,cc*25,f1*48,ff(99),cf,f3*17
	character*12 a1,a2,b1,b2
	character*8  mach(99),ma(99)
	character*16 name(99),c1,c2,f2
	real b99(99)
        integer b99i,b99j
	logical logi
	byte bf(24)
	equivalence (cf,bf)

	f3='/var/log/account/'

	if(iargc().eq.0)call tit

	call getarg(1,f2)
	if(f2(1:1).ne.'!')then
	  f2(4:7)='.fee'
	  inquire(file=f3//f2,exist=logi)
          if(logi)then
            call system('cat '//f3//f2)
	  else
	    call tit
	  endif
	  stop
	endif
	    

	open(1,file='/var/named/count.dat',status='old')
	m=0
3	read(1,'(a)',end=4)f1
	m=m+1
	ma(m)=f1(1:8)
	name(m)=f1(12:27)
	goto 3
4	close(1)

	do 5 i=1,99
5	b99(i)=0.
	
	n=0
	open(2,file=f3//'1.1',status='old')
c read update
        cc=fdate()
        if(cc(9:9).eq.' ')cc(9:9)='0'
        f2='account.'//cc(5:7)//cc(9:10)
	goto 105

103	read(2,'(a)',end=101)f2
	if(f2(1:1).eq.'#')goto 103
	if(cc(9:10).eq.f2(12:13))goto 103
105	open(1,file=f3//f2,status='old')
104	read(1,'(a)',end=102)cf
	do 11 j=1,24
11	if(bf(j).le.9)bf(j)=32
	read(cf(1:),*)a1,a2
	if(n.eq.0)goto 20
	do 12 j=1,n
	if(a1.eq.mach(j))then
	nn=j
	goto 21
	endif
12	continue	
20	n=n+1	
	mach(n)=a1(1:8)
	nn=n
21	xm=1
	j=lnblnk(a2)
	if(a2(j:j).eq.'M')xm=1024.*1024.
	if(a2(j:j).eq.'K')xm=1024.
	if(a2(j:j).gt.'9')a2(j:j)=' '
	read(a2(1:),*)k
	b99(nn)=b99(nn)+k*xm
	goto 104
102	close(1)
	goto 103
101	close(2)

c extract
	open(2,file=f3//'2.2',status='old')
	read(2,'(a)')f2
	if(f2(1:1).eq.'#')goto 203
	open(1,file=f3//f2,status='old')
204	read(1,'(a)',end=202)cf
	do 211 j=1,24
211	if(bf(j).le.9)bf(j)=32
	read(cf(1:),*)a1,a2
	do 212 j=1,n
	if(a1.eq.mach(j))then
	nn=j
	goto 221
	endif
212	continue	
	goto 204
221	xm=1
	j=lnblnk(a2)
	if(a2(j:j).eq.'M')xm=1024.*1024.
	if(a2(j:j).eq.'K')xm=1024.
	if(a2(j:j).gt.'9')a2(j:j)=' '
	read(a2(1:),*)k
	b99(nn)=b99(nn)-k*xm
	goto 204
202	close(1)
203	close(2)
c extract_end

	do 40 i=1,n-1
	do 40 j=i+1,n
	if(b99(i).lt.b99(j))then
	x=b99(i)
	b99(i)=b99(j)
	b99(j)=x
	a1=mach(i)
	mach(i)=mach(j)
	mach(j)=a1
	endif
40	continue
 
	k=8
	do 42 i=1,n
	b99(i)=b99(i)/1024./1024.
42	if(b99(i).ge.25.)k=i

41	if(b99(n).eq.0.)then
	  n=n-1
	  goto 41
	endif

	if(iargc().gt.1)then
	  call getarg(2,f1)
	  read(f1(1:),*)n
	  if(n.gt.m)n=m
          if(n.lt.1)n=k
	endif
	
	write(*,*)
	write(*,*)cc(5:7),' 0~~',cc(9:10),'  netware_charge Table'
	write(*,*)
	do 29 i=1,n/2
	j=i+n/2
	call find(mach(i),ma,name,m,c1)
	call find(mach(j),ma,name,m,c2)
        b99i=b99(i)
	b99j=b99(j)
	write(*,'(2(3a,i5,a))')' ',c1,mach(i),b99i,'m',
     *                 '         ',c2,mach(j),b99j,'m'
29	continue
	write(*,*)
        end                  

	subroutine find(a,mach,name,m,c)
	character*8 mach(99),a
	character*16 name(99),c
	c='                '
	do 10 i=1,m
	if(mach(i).eq.a)goto 20
10	continue
	return
20	c=name(i)
	end	

	subroutine tit
	  write(*,*)
	  write(*,*)' ********* Netware_change lookup ********'
	  write(*,*)
	  write(*,*)'   Usage: net Jan   ( net_charge of January...)'
          write(*,*)'          net !     ( net_charge of this Month)'
          write(*,*)'          net ! 10  ( ahead 10 people )'
	  write(*,*)
	  stop
	end
