#!/usr/bin/perl5
#
# From: Ken Lalonde <ken@uunet.ca>
# with mods from Landon Curt Noll <chongo@toad.com>.
# Generate new low article count numbers.
# For each newsgroup, we calculate the low article number
# by scanning the spool.  If this isn't the same as the
# value in the active file, we print the newsgroup name and new low value.


## =()<require '@<_PATH_PERL_SHELLVARS>@' ;>()=
require '/var/news/etc/innshellvars.pl' ;

$active = $inn::active ;
$spool = $inn::spool ;

open(A, $active) or warn 'Cannot read $active: $!';
while (<A>) {
        ($g,$HI,$LO,$f) = split;
        $lo = $HI+1;
        $d = $g; $d =~ y/./\//;
	$dir = "$spool/$d" ;
	chdir ($dir) or next ;
        opendir(D, ".") or next;
        while ($f = readdir(D)) {
                next unless ($f =~ /^\d+$/ && -f $f) ;
                $l = int($f);
                if ($l < $lo) { 
		    $lo = $l; 
		}
        }
        closedir(D);
        print "$g $lo\n" if $lo != $LO;
}
close(A);

