summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1998-05-20 09:20:02 +0000
committerwosch <wosch@FreeBSD.org>1998-05-20 09:20:02 +0000
commita7cd929d78be097050fad4585f3b7d0010507c05 (patch)
treed1d0be92ed8b26d187b917e5c74d6a874aa4df63 /tools
parentef0bb328547d6b6927ca95d893f6318c71aa1b9f (diff)
downloadFreeBSD-src-a7cd929d78be097050fad4585f3b7d0010507c05.zip
FreeBSD-src-a7cd929d78be097050fad4585f3b7d0010507c05.tar.gz
Add mid scripts. Mid is a tool which create a Message-ID database
for mailing lists.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/README3
-rwxr-xr-xtools/tools/mid/mid-build45
-rwxr-xr-xtools/tools/mid/mid-index83
-rwxr-xr-xtools/tools/mid/mid-master33
-rwxr-xr-xtools/tools/mid/mid-master-index21
5 files changed, 184 insertions, 1 deletions
diff --git a/tools/tools/README b/tools/tools/README
index 533a774..373ff6c 100644
--- a/tools/tools/README
+++ b/tools/tools/README
@@ -1,4 +1,4 @@
-# $Id: README,v 1.9 1997/04/25 14:14:31 wosch Exp $
+# $Id: README,v 1.10 1997/11/09 11:23:43 wosch Exp $
This directory is for tools.
@@ -17,3 +17,4 @@ kdrv KernelDriver; add/list/remove third-party kernel driver
scsi-defects Get at the primary or grown defect list of a SCSI disk.
portsinfo Generate list of new ports for last two weeks.
html-mv Rename HTML generated filenames to human readable filenames.
+mid Create a Message-ID database for mailing lists.
diff --git a/tools/tools/mid/mid-build b/tools/tools/mid/mid-build
new file mode 100755
index 0000000..ced5f4c
--- /dev/null
+++ b/tools/tools/mid/mid-build
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Copyright (c) March 1998 Wolfram Schneider <wosch@FreeBSD.org>
+#
+# create an Message-ID, In-Reply-To look(1) index database
+#
+
+
+TMPDIR=/var/tmp; export TMPDIR
+home=/g/www/mid
+
+dbout=$home/index
+archive=$home/archive
+
+PATH=$home/bin:/bin:/usr/bin:/usr/local/bin; export PATH
+
+
+all ()
+{
+ ( cd $archive || exit 1
+ find text/* -type f | mid-master-index 4 mid-index $dbout/mid
+ )
+}
+
+current ()
+{
+ ( cd $archive || exit 1
+ find current/freebsd-* current/cvs-* -type f |
+ mid-master-index 1 mid-index $dbout/mid-current
+ )
+}
+
+if [ $# -le 0 ]; then
+ echo "usage mid-build {current|all}"
+ exit 1
+fi
+
+for db
+do
+ case $db in
+ current) current;;
+ all) all;;
+ *) echo "Huh? $db";;
+ esac
+done
diff --git a/tools/tools/mid/mid-index b/tools/tools/mid/mid-index
new file mode 100755
index 0000000..053c21e
--- /dev/null
+++ b/tools/tools/mid/mid-index
@@ -0,0 +1,83 @@
+#!/usr/local/bin/perl
+#
+# create message-id / in-reply-to database
+#
+# $Id: mid-index,v 1.5 1998/04/13 13:08:47 wosch Exp $
+
+sub usage { die "usage: mid-index name < filelist"; }
+
+sub id {
+ local($name, @files) = @_;
+ local($bytes, $bytes2, $headlen, $file);
+ local($counter);
+ local($from,$from2);
+
+ $counter = 0;
+ open(MID, "| sort -u -o $name.mid") || die "open sort > $name.mid: $!\n";
+ open(IRT, "| sort -u -o $name.irt") || die "open sort > $name.irt: $!\n";
+
+ while(<>) {
+ local($/) = "\n\n";
+ chop;
+ $file = $_;
+
+ open(R, $file) || do {
+ warn "open $file:$!\n";
+ next;
+ };
+ $bytes = 0;
+
+ while(<R>) {
+ $headlen = length($_);
+ $from2 = substr($_, 0, 6);
+ $from = substr($from2, 0, 5);
+
+ # warn "xxx" . $from . "yyy\n";
+ if ($from eq "From " || $from2 eq "\nFrom ") {
+
+ if ($from eq "From ") {
+ $bytes2 = $bytes;
+ } else {
+ # One bytes more for "\nFrom "
+ $bytes2 = $bytes + 1;
+ }
+
+ $counter++;
+ s/\n[ \t]+/ /g;
+ if ($debug && $counter % $speedstep == 0) {
+ print STDERR sprintf("\r%7d", $counter);
+ }
+
+ foreach (split("\n")) {
+ if (/^Message-id:\s+\<([^$idsep]+)/oi) {
+ print MID "$1 $file $bytes2\n";
+ } elsif (/^Resent-Message-id:\s+\<([^$idsep]+)/oi) {
+ print MID "$1 $file $bytes2\n";
+ } elsif (/^References:\s+\<([^$idsep]+)/oi) {
+ print IRT "$1 $file $bytes2\n";
+ } elsif (/^In-Reply-to:\s+[^<]*\<([^$idsep]+)/oi) {
+ print IRT "$1 $file $bytes2\n";
+ }
+ }
+ }
+ $bytes += $headlen;
+ }
+ close R;
+ }
+ close MID || warn "close: MID\n";
+ close IRT || warn "close: IRT\n";
+ print STDERR sprintf("\r%7d", $counter)
+ if $debug && $counter % $speedstep != 0;
+ print STDERR "\n" if $debug;
+}
+
+$idsep = '>';
+$idsep = '>@\s';
+$debug = 0;
+$speedstep = 100;
+
+&usage if $#ARGV != 0;
+$name = $ARGV[0]; shift @ARGV;
+&id($name);
+
+
diff --git a/tools/tools/mid/mid-master b/tools/tools/mid/mid-master
new file mode 100755
index 0000000..5ee531a
--- /dev/null
+++ b/tools/tools/mid/mid-master
@@ -0,0 +1,33 @@
+#!/usr/local/bin/perl
+
+if ($#ARGV < 1) {
+ die "usage master counter command comandargs ... \n";
+}
+
+$count = $ARGV[0]; shift @ARGV;
+@command = @ARGV;
+$file = pop(@command);
+undef @ARGV;
+$debug = 0;
+
+for($i = 0; $i < $count; $i ++) {
+ @c = (@command, "$file.$i");
+ warn "Start process: $i @c\n" if $debug;
+ open("OUT$i", "| @c") || die "open @c\n";
+ select("OUT$i"); $| = 1;
+}
+select(STDOUT);
+
+$n = 0;
+while(<>) {
+ $o = 'OUT' . ($n % $count);
+ print $o $_;
+ warn "$o $_" if $debug;
+ $n++
+}
+
+for($i = 0; $i < $count; $i ++) {
+ warn "Close process $i\n" if $debug;
+ close("OUT$i") || warn "close OUT$i: $!\n";
+}
+
diff --git a/tools/tools/mid/mid-master-index b/tools/tools/mid/mid-master-index
new file mode 100755
index 0000000..8b32acd
--- /dev/null
+++ b/tools/tools/mid/mid-master-index
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $# -le 2 ]; then
+ echo "usage $0 parallel_processes command [comand_options]"
+ exit 1
+fi
+
+count=$1; shift
+command=$1; shift
+file=$1; shift
+filelistmid=`perl -e "for(0 .. $count -1) {print qq{$file.temp.\\$_.mid }}"`
+filelistirt=`perl -e "for(0 .. $count -1) {print qq{$file.temp.\\$_.irt }}"`
+
+if mid-master $count $command $file.temp; then
+ sort -u -m -o $file.temp.mid $filelistmid &&
+ rm -f $filelistmid && mv $file.temp.mid $file.mid || exit 1
+ sort -u -m -o $file.temp.irt $filelistirt &&
+ rm -f $filelistirt && mv $file.temp.irt $file.irt || exit 1
+else
+ exit 1
+fi
OpenPOWER on IntegriCloud