#!/bin/csh
foreach f ( $* )
    set key = "$f.key"
    set flag = "$f.flags"
    set post = "$f.post"
    set html = "$f.html"
    set out = "$f.out"
    set tmp = "$f.tmp"
    rm -f $key $flag $out $post $tmp
    awk 'BEGIN { out = 1 } \
	/^-----BEGIN/ { out = 2 } \
	out == 1 { print $0 >>"'$post'" }' < $f >& /dev/null
    pgp +batchmode -z"eternity" $f -o $out >& /dev/null
    awk 'BEGIN { out = 1 } \
	/^-----BEGIN PGP PUBLIC/ { out = 12; print $0 >>"'$key'" } \
	/^-----END PGP PUBLIC/ { out = 11; print $0 >>"'$key'" } \
	/^-----BEGIN PGP MESSAGE/ { out = 13; print $0 >>"'$tmp'" } \
	/^-----END PGP MESSAGE/ { out = 11; print $0 >>"'$tmp'" } \
	out == 1 { print $0 >>"'$flag'" } \
	out == 2 { print $0 >>"'$key'" } \
	out == 3 { print $0 >>"'$tmp'" } \
	out > 10 { out -= 10 }' < $out
    pgp +batchmode $tmp -o $html >& /dev/null
    rm -f $out $tmp
end
