Hello, this is Jun-ichiro ITOH, from Japan.
It's my first post to this list.
I'm using majordomo 1.62 for about a month at my site.
It works really fine. It's really great!
I've added a small script that does a subject-search for 'index'
command. Feel free to use/modify it.
itojun@mt.cs.keio.ac.jp(Jun-ichiro ITOH)
---sample output
>>>> index dist-test
3 94/01/09 Jun-ichiro ITOH (dist-test 3) test
4 94/01/09 Jun-ichiro ITOH (dist-test 4) test
5 94/01/09 Jun-ichiro ITOH (dist-test 5) test
6 94/01/09 Jun-ichiro ITOH (dist-test 6) test
7 94/01/09 Jun-ichiro ITOH (distrubute test 7) test
8 94/01/09 Jun-ichiro Itoh (dist-test 8) distribute test
9 94/01/09 Jun-ichiro Itoh (dist-test 9) Re: distribute test
10 94/01/09 Koichi Moriyama (dist-test 10) test
---majordomo.cf
# $index_command = "/bin/ls -lRL";
$index_command = "$homedir/indexer";
---indexer
#! /usr/local/bin/perl
# output index, with caching
# by itojun@mt.cs.keio.ac.jp (Jun-ichiro ITOH)
# $Header$
$version = '1.0';
$versionString = '***VERSION***';
$cache = '.cache';
# for News, Sun
$cachefile = "$cache.pag";
# for BSD/386
# $cachefile = "$cache.db";
if (-e $cachefile) {
$cacheDate = (-M $cachefile);
} else {
$cacheDate = -1;
}
dbmopen(fileCache, $cache, 0644);
# version check
if ($fileCache{$versionString} < $version) {
$cacheDate = -1;
}
# search flles below here, updating fileCache
&printDir('.', 'DIR000');
# delete removed files from fileCache
foreach $file (keys %fileCache) {
delete $fileCache{$file} if (!$mark{$file});
}
# output names, with some ordering
foreach $file (sort sortstring grep(!/[0-9]+/, keys %fileCache)) {
print $fileCache{$file};
}
foreach $file (sort sortnumber grep(/[0-9]+/, keys %fileCache)) {
print $fileCache{$file};
}
$fileCache{$versionString} = $version;
dbmclose(fileCache);
exit 0;
#------------------------------------------------------------
sub printDir {
local($directory) = $_[0];
local($handle) = $_[1];
local(@allfiles);
local($file, $shortfile);
$handle++;
opendir($handle, $directory);
@allfiles = grep(!/^\./, readdir($handle));
foreach $file (@allfiles) {
if (-B $file) {
next;
} elsif (-d $file) {
&printDir("$directory/$file", $handle);
} else {
$shortfile = "$directory/$file";
$shortfile =~ s/^\.\///;
$mark{$shortfile} = 1;
# update not needed if cache is newer than target
next if (0 < $cacheDate && -M $file > $cacheDate);
&printFile($shortfile);
}
}
closedir($handle);
}
sub printFile {
local($file) = $_[0];
local($from, $subject) = ('', '');
local($time, $year, $month, $day);
# binary files: will never fall into here
# if (-B $file) {
# $fileCache{$file} = "$file\n";
# return;
# }
# text files: assume mail or news
open(FILE, $file);
while (<FILE>) {
chop;
$from = $1 if /^From:\s+(\S.*)$/;
$subject = $1 if /^Subject:\s+(\S.*)$/;
last if ($from && $subject);
}
close(FILE);
$time = (stat($file))[9];
($year, $month, $day) = (gmtime($time))[5,4,3];;
$month++;
$subject = '(no subject)' if ($subject eq '');
$from = $1 if ($from =~ /^([^<]+)\s+<[^>]+>$/);
$from = '(no name)' if ($from eq '');
if (length($file) <= 7) {
$fileCache{$file} = sprintf("%-7s\t%8s %-20s %-40s\n",
$file, &formatdate($year, $month, $day),
substr($from, 0, 20), substr($subject, 0, 40));
} else {
$fileCache{$file} = sprintf("%s\n\t%8s %-20s %-40s\n",
$file, &formatdate($year, $month, $day),
substr($from, 0, 20), substr($subject, 0, 40));
}
}
sub formatdate {
local($year, $month, $day) = @_[0,1,2];
return sprintf("%02d/%02d/%02d", $year, $month, $day);
}
#------------------------------------------------------------
sub sortstring {
$a cmp $b;
}
sub sortnumber {
$a <=> $b;
}
|
|