/* CheckSign.spot Version 1.0 © 1994 by Chris Dee                           */
/*   (Based on Encrypt.spot Version 1.2 © 1993 by Wim Van Goethem)          */
/*                                                                          */
/* This Arexx script is intended to check the sign of a message that        */
/* previously signed with PGP. You need the public key from the person that */
/* wrote the message. This script uses PGP which has been ported to the     */
/* Amiga by Peter Simons.                                                   */
/*                                                                          */
/* For comments, remarks, bugs, etc. contact:                               */
/* Fidonet: 2:286/407.34 (Chris Dee)                                        */
/* Internet: cd@grafix.wlink.nl                                             */

/* Path were you keep PGP (must end on "/" or ":" or be empty) */
PGPpath = "Mail:Bin/"

address spot
options results

if ~show(Libraries,'rexxsupport.library') then
    if ~addlib("rexxsupport.library",0,-30,0) then exit

'saveascii TO T:pgptemp_a OVERWRITE NOTEARLINE NOORIGIN NOKLUDGES' /* Save the msg */

/* Get all headerinfo */
'getfrom'
from_name = result

/* Do we have a key from this user? */
address command PGPpath"PGP -kv >T:users"
foo = open('file','T:users','R')
ok = 0
do until (ok > 0) | (eof('file'))
    ok = pos(upper(from_name),upper(readln('file')))
end
foo = close('file')
foo = delete('T:users')
address spot
if ok == 0 then /* Key not found! */
do
    foo = delete('T:pgptemp_a')    
    'requestnotify "Public key of 'from_name' missing!"'
    say "Please close window to quit."
    exit
end

/* Check sign with PGP */
options failat 100
address command PGPpath'PGP T:pgptemp_a -o T:pgptemp_b'
if rc ~= 0 then do
    foo = delete('T:pgptemp_a')
    foo = delete('T:pgptemp_b')
    say ""
    say ""
    say "Please close window to quit."
    exit
    end

/* Put the msg back into the message base */
address spot
'edit FILE T:pgptemp_b REFLOW=OFF NOEDIT NOGUI NOSIG NOREQ'

foo = delete('T:pgptemp_a')
foo = delete('T:pgptemp_b')

/* Quit */
say ""
say ""
say "Please close window to quit."
exit
