3 # create message-id / in-reply-to database
5 # $FreeBSD: src/tools/tools/mid/mid-index,v 1.2 1999/08/28 00:54:31 peter Exp $
6 # $DragonFly: src/tools/tools/mid/mid-index,v 1.2 2003/06/17 04:29:11 dillon Exp $
8 sub usage { die "usage: mid-index name < filelist"; }
11 local($name, @files) = @_;
12 local($bytes, $bytes2, $headlen, $file);
17 open(MID, "| sort -u -o $name.mid") || die "open sort > $name.mid: $!\n";
18 open(IRT, "| sort -u -o $name.irt") || die "open sort > $name.irt: $!\n";
25 open(R, $file) || do {
26 warn "open $file:$!\n";
32 $headlen = length($_);
33 $from2 = substr($_, 0, 6);
34 $from = substr($from2, 0, 5);
36 # warn "xxx" . $from . "yyy\n";
37 if ($from eq "From " || $from2 eq "\nFrom ") {
39 if ($from eq "From ") {
42 # One bytes more for "\nFrom "
48 if ($debug && $counter % $speedstep == 0) {
49 print STDERR sprintf("\r%7d", $counter);
52 foreach (split("\n")) {
53 if (/^Message-id:\s+\<([^$idsep]+)/oi) {
54 print MID "$1 $file $bytes2\n";
55 } elsif (/^Resent-Message-id:\s+\<([^$idsep]+)/oi) {
56 print MID "$1 $file $bytes2\n";
57 } elsif (/^References:\s+\<([^$idsep]+)/oi) {
58 print IRT "$1 $file $bytes2\n";
59 } elsif (/^In-Reply-to:\s+[^<]*\<([^$idsep]+)/oi) {
60 print IRT "$1 $file $bytes2\n";
68 close MID || warn "close: MID\n";
69 close IRT || warn "close: IRT\n";
70 print STDERR sprintf("\r%7d", $counter)
71 if $debug && $counter % $speedstep != 0;
72 print STDERR "\n" if $debug;
80 &usage if $#ARGV != 0;
81 $name = $ARGV[0]; shift @ARGV;