#
# active.pl - generate a B-news style active file by walking through the
#               news-spool tree directory by directory.
#
# modification log:
#       05-20-91 - vds - original based on Roy Silvernail's expire.pl
#                               posted to USENET in February '91
#       05-22-91 - vds - handle multiple news drive:path combinations
#       05-25-91 - vds - fixes to be arbitron-compatible
#
#
# Waffle-specific notes:
#       This program scans the Waffle news spool(s) and generates a
#       B-news-compatible (actually arbitron-compatible) "active" file.
#       The active file basically contains a listing of all the newsgroups
#       and the corresponding max and min article number.
#
#       why??? so that you can run my edited version of the perl arbitron
#       program (edited to support Waffle) and get your MSDOS Waffle system
#       included in the monthly "usenet sweeps ratings".
#
#       I imagine this is rather slow but you get what you pay for :-)
#
#       Personally, I'd like to see the guys writing the compiled-language
#       expire programs that complement Waffle to write the active file out
#       as part of the expiration (like "real news" does) since they're in
#       the directories anyway...and yes, that's a request...
#
# usage:        perl active.pl > c:\waffle\news\active
#
# Waffle restrictions:
#
#       1. Can't convert newsgroup names from "aliased" names back to
#               the real ones...therefore will generate semi-bogus lines
#               (ie... comp.lang.c++ aliased to comp.lang.cplus)
#
#
# path(s) where news lives
# example -> @news_paths=("c:/waffle/news", "d:/newsdir2", "e:/newsdir3");
 
@news_paths = ( "c:/waffle/news", );
 
select (STDOUT);
$| = 1;
 
sub bynumber { $a <=> $b; }
 
# the hard stuff below is almosts verbatim from Roy Silvernail's expire.pl
# (USENET a.b.w. 2/91) with the loop, sorting, formats thrown in by me...
 
foreach $news_dir (@news_paths)
{
        chdir($news_dir);
        @dirs = ('.');
        foreach (@dirs) {
                opendir (F,$_);
                @this_one = sort bynumber readdir(F);
                closedir (F);
 
                @files=();
                foreach $f (@this_one) {
                        next if ($f eq '.' || $f eq '..');
                        $g = "$_/$f";
                        if (-d $g) {
                             push (@dirs, $g);
                        }
                        elsif (grep(/^1|^2|^3|^4|^5|^6|^7|^8|^9/,$f)) {push(@files,$f);}
                }
 
                ($group = $_) =~ s%/%.%g;
                $group =~ s/\.\.//;
 
                write if defined $files[0];
 
        }
}
 
format =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<< @<<<<<<<
$group,                       $files[$#files], $files[0]
.
 
