chiark / gitweb /
Initial commit as found
[modbot-ulm.git] / stump / local / bin / pmcanon
1 #!/bin/sh
2
3 # @(#)pmcanon   1.9 (PGP Moose) 97/07/10
4 # Canonicalisation script for PGP Moose
5 # (in other words, it takes a news article and turns it
6 # into something we can compute/check a signature on.)
7 # Written by Greg Rose, RoSecure Software, Copyright C 1995.
8
9 # Be neat and tidy.
10 TMP=/tmp
11 TF=$TMP/pgpmt$$
12 trap "rm -f /$TF.?" 0 1 2 3 15
13
14 # Check usage. File must be specified, and result comes out on stdout.
15 if [ $# -gt 1 ]; then
16     echo >&2 "usage: $0 [article]"
17     exit 1
18 fi
19
20 cat $1 >$TF.f
21 sed '/^ *$/q' $TF.f >$TF.h
22
23 # multiple greps so we can guarantee order
24 pmnewsgroups $TF.f
25 {
26     grep -i "^From:" "$TF.h"
27     grep -i "^Subject:" "$TF.h"
28     grep -i "^Message-ID:" "$TF.h"
29 } | sed -e 's/^[^:]*: *//' -e 's/: */:/g' -e 's/[       ]*$//'
30 sed -e '1,/^ *$/d' \
31     -e '/^ *$/d' \
32     -e 's/^--/- --/' \
33     -e 's/^[Ff][Rr][Oo][Mm]/>&/' \
34     -e 's/^[Ss][Uu][Bb][Jj][Ee][Cc][Tt]/>&/' \
35     -e 's/^\.$/../' \
36     -e 's/^\.[^.]/.&/' \
37     -e 's/[     ]*$//' \
38     "$TF.f"