home *** CD-ROM | disk | FTP | other *** search
- /*
- ** The New Defuser (3.5) by Mat Bettinson
- **
- ** Please read docs.
- **
- */
-
- Config = 'Mail:Defuser.cfg'
- LogFile = 'Mail:Defuser.log'
- BadPKT = 'Mail:Bad/'
- ExeDir = 'C:'
-
- MaxPKTSize = 150000
- MaxArchive = 5000000
-
- MaxNoCRChk = 50000
- MaxCRate = 80
-
- CheckName = 'YES'
-
- LZXUnpack = '-X0 -m -q1 x'
- LHAUnpack = '-q -m x'
- LZXView = '-X0 l'
- LHAView = 'l'
-
- /*
- **
- ** Defuser begins...
- **
- */
-
- If ~Show(l,'rexxsupport.library') then Call AddLib('rexxsupport.library',0,-30)
- Parse Arg Archive
- Archive = strip(Archive)
- Dateline = Date('E') ; Dateline = TIME('N')' 'Dateline
- IF EXISTS(logfile) then Call Open(log,logfile,"A")
- ELSE Call Open(log,logfile,"W")
- IF ~Exists(Archive) then DO
- Call Wog(Dateline' 'Archive' not found.')
- Call Wog('---') ; Call Close(log)
- EXIT 10
- END
- Call Open('TLHA',archive,'R')
- Arctest = READCH('TLHA',7)
- Call Close('TLHA')
- If left(Arctest,3) = 'LZX' then Type = 'LZX'
- ELSE DO
- Arctest = Right(arctest,5)
- Arctest = Overlay('x',Arctest,4)
- If Arctest = '-lhx-' then Type = 'LHA'
- ELSE Type = 'UNKNOWN'
- END
- If Arctest = 'UNKNOWN' then DO
- Call Wog(Dateline' Unrecognised archive type!')
- Call Wog('---') ; Call Close(log)
- EXIT 10
- END
- If Type = 'LZX' then opts = LZXView
- Else opts = LHAView
- Address COMMAND ExeDir||Type' 'opts' 'Archive' >T:Defuser.temp'
- Call Open(tst,'T:Defuser.temp','R')
- Bname = 0 ; Bsize = 0
- Do forever
- Line = ReadLN(tst)
- If EOF(tst) then break
- Parse VAR Line org pack comp date time name
- If datatype(org) = 'NUM' then DO
- If Words(Line) = 6 & right(strip(name),4) ~= '.PKT' then Bname = 1
- If Words(Line) = 6 & org > MaxPKTSize then Bsize = 1
- If Words(Line) = 7 then DO
- UnCSize = strip(org)
- CR = strip(Comp,'T','%')
- CSize = strip(pack)
- END
- END
- END
- Call Close(tst)
- Call Delete('T:Defuser.temp')
- Error = 0
- Call Wog(Dateline' Defuser session started:')
- If Checkname = 'YES' & Bname then DO
- Call Wog(" PKT *FAILED!* Filename in Archive invalid. Not *.PKT!")
- Error = 1
- END
- If Bsize = 1 then DO
- Call Wog(" PKT *FAILED!* Packet in archive larger than "MaxPKTSize" byte maximum!")
- Error = 1
- END
- If UnCsize > MaxArchive then DO
- Call Wog(" PKT *FAILED!* Archive total is "UnCsize" bytes which exceeds "MaxArchive" bytes maximum!")
- Error = 1
- END
- If UnCsize < MaxNoCRChk then Call Wog(" Packet under CR check size...")
- ELSE DO
- If CR > MaxCRate then DO
- Call Wog(" PKT *FAILED!* Archive CR of "CR"% which exceeds "MaxCRate"% maximum!")
- Error = 1
- END
- END
- If ~Error then DO
- Call Wog(" "Type" Session OK. Total Comp size: "CSize", Total UnComp size: "UnCsize", CRate: "CR"%")
- If Type = 'LZX' then opts = LZXUnpack
- ELSE opts = LHAUnpack
- Address COMMAND ExeDir||Type' 'opts' 'Archive' #?.PKT'
- Call Wog("---") ; Call Close(log)
- EXIT
- END
- Call Wog('Packet rejected. CALL the BOMB SQUAD! Suspect moved to 'BadPKT' ... Phew!')
- Dstamp = 'BOMB-'Translate(Date('E'),'-','/')'-'Translate(Time('N'),'.',':')
- Address COMMAND ExeDir'Copy 'Archive' TO 'BadPKT||Dstamp
- If RC = 0 then Call Delete(Archive)
- ELSE Call Wog(" Couldn't move to "BadPKT"!")
- Call Wog('---') ; Call Close(log)
- EXIT 10
-
- Wog:
- Parse ARG OutLine
- Call WriteLN(log,Outline)
- RETURN
-