/* YAMandPGP V1.0 -- Roberto Ragusa 1997 */
/* open mailpacket */

windowfilename = 'CON:50/50/600/200/YAM-REXX/CLOSE'

pgppath    = 'pgp'

tempfile   = 't:yammacrotempfile'

CALL CLOSE 'STDOUT'
CALL CLOSE 'STDIN'
CALL OPEN 'STDIN',windowfilename
CALL PRAGMA '*','STDIN'
CALL OPEN 'STDOUT','*'

options results

address COMMAND

call pragma('D','MAILPACKETS:')

'delete >nil: oldmessage/#? all force'

call pragma('D','oldmessage')
'assign MW: ""'

address YAM

'GetMailInfo filename'
fname=result

address command

'munpack' fname '-C MW:'

'list >'||tempfile 'p #?(.asc)|(.pgp) lformat "'||pgppath '%n"'
'execute' tempfile

'echo >'||tempfile '""'
'list >>'||tempfile 'p #?.lzx lformat "makedir %n_*Ncd %n_*Nlzx -x -a x /%n*Ncd /*N"'
'list >>'||tempfile 'p #?(.lha)|(.lzh) lformat "makedir %n_*Ncd %n_*Nlha x -a -M /%n*Ncd /*N"'
'list >>'||tempfile 'p #?.zip lformat "makedir %n_*Ncd %n_*Nunzip x /%n*Ncd /*N"'
'list >>'||tempfile 'p #?(.tar.(gz|gzip))|(.tgz) lformat "makedir %n_*Ncd %n_*Nuntgz /%n*Ncd /*N"'
'execute' tempfile

'delete >nil:' tempfile

address YAM

'Request "Read your mail in Mold:" "OK"'

'assign MW:'