3 # create message-id / in-reply-to database
7 sub usage { die "usage: mid-index name < filelist"; }
10 local($name, @files) = @_;
11 local($bytes, $bytes2, $headlen, $file);
16 open(MID, "| sort -u -o $name.mid") || die "open sort > $name.mid: $!\n";
17 open(IRT, "| sort -u -o $name.irt") || die "open sort > $name.irt: $!\n";
24 open(R, $file) || do {
25 warn "open $file:$!\n";
31 $headlen = length($_);
32 $from2 = substr($_, 0, 6);
33 $from = substr($from2, 0, 5);
35 # warn "xxx" . $from . "yyy\n";
36 if ($from eq "From " || $from2 eq "\nFrom ") {
38 if ($from eq "From ") {
41 # One bytes more for "\nFrom "
47 if ($debug && $counter % $speedstep == 0) {
48 print STDERR sprintf("\r%7d", $counter);
51 foreach (split("\n")) {
52 if (/^Message-id:\s+\<([^$idsep]+)/oi) {
53 print MID "$1 $file $bytes2\n";
54 } elsif (/^Resent-Message-id:\s+\<([^$idsep]+)/oi) {
55 print MID "$1 $file $bytes2\n";
56 } elsif (/^References:\s+\<([^$idsep]+)/oi) {
57 print IRT "$1 $file $bytes2\n";
58 } elsif (/^In-Reply-to:\s+[^<]*\<([^$idsep]+)/oi) {
59 print IRT "$1 $file $bytes2\n";
67 close MID || warn "close: MID\n";
68 close IRT || warn "close: IRT\n";
69 print STDERR sprintf("\r%7d", $counter)
70 if $debug && $counter % $speedstep != 0;
71 print STDERR "\n" if $debug;
79 &usage if $#ARGV != 0;
80 $name = $ARGV[0]; shift @ARGV;