#!/usr/bin/gawk -f
#this saves off any signed message and checks the signature

BEGIN {
  getline <"/dev/pid";
  fname = "msg"$1;
  print "-----BEGIN PGP SIGNED MESSAGE-----\n";
}

{
#this canonicalizes text (strip trailing spaces, and EOL is forced to crlf)
      gsub( " $","",$0 );
      print $0 "\r" >fname".txt";
      print;
}

END {
  print "";
  system( "./minipgp -t 1 -u 0 <" fname ".txt | ./minipgp -a SIGNATURE" );
  system( "rm " fname ".txt" );
}
