home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / fido / bundler.lha / Defuser / Defuser.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1995-02-20  |  3.1 KB  |  120 lines

  1. /*
  2. **      The New Defuser (3.5) by Mat Bettinson
  3. **      
  4. **      Please read docs. 
  5. **      
  6. */
  7.  
  8. Config     = 'Mail:Defuser.cfg'
  9. LogFile    = 'Mail:Defuser.log'
  10. BadPKT     = 'Mail:Bad/'
  11. ExeDir     = 'C:'
  12.  
  13. MaxPKTSize = 150000
  14. MaxArchive = 5000000
  15.  
  16. MaxNoCRChk = 50000
  17. MaxCRate   = 80
  18.  
  19. CheckName  = 'YES'
  20.  
  21. LZXUnpack = '-X0 -m -q1 x'
  22. LHAUnpack = '-q -m x'
  23. LZXView   = '-X0 l'
  24. LHAView   = 'l'
  25.  
  26. /*
  27. **      
  28. **      Defuser begins...
  29. **      
  30. */
  31.  
  32. If ~Show(l,'rexxsupport.library') then Call AddLib('rexxsupport.library',0,-30)
  33. Parse Arg Archive
  34. Archive = strip(Archive)
  35. Dateline = Date('E') ; Dateline = TIME('N')' 'Dateline
  36. IF EXISTS(logfile) then Call Open(log,logfile,"A")
  37. ELSE Call Open(log,logfile,"W")
  38. IF ~Exists(Archive) then DO
  39.  Call Wog(Dateline' 'Archive' not found.')
  40.  Call Wog('---') ; Call Close(log)
  41.  EXIT 10
  42.  END
  43. Call Open('TLHA',archive,'R')
  44. Arctest = READCH('TLHA',7)
  45. Call Close('TLHA')
  46. If left(Arctest,3) = 'LZX' then Type = 'LZX'
  47. ELSE DO
  48.  Arctest = Right(arctest,5)
  49.  Arctest = Overlay('x',Arctest,4)
  50.  If Arctest = '-lhx-' then Type = 'LHA'
  51.  ELSE Type = 'UNKNOWN'
  52.  END
  53. If Arctest = 'UNKNOWN' then DO
  54.  Call Wog(Dateline' Unrecognised archive type!')
  55.  Call Wog('---') ; Call Close(log)
  56.  EXIT 10
  57.  END
  58. If Type = 'LZX' then opts = LZXView
  59. Else opts = LHAView
  60. Address COMMAND ExeDir||Type' 'opts' 'Archive' >T:Defuser.temp'
  61. Call Open(tst,'T:Defuser.temp','R')
  62. Bname = 0 ; Bsize = 0
  63. Do forever
  64.  Line = ReadLN(tst)
  65.  If EOF(tst) then break
  66.  Parse VAR Line org pack comp date time name
  67.  If datatype(org) = 'NUM' then DO
  68.   If Words(Line) = 6 & right(strip(name),4) ~= '.PKT' then Bname = 1
  69.   If Words(Line) = 6 & org > MaxPKTSize then Bsize = 1
  70.   If Words(Line) = 7 then DO
  71.    UnCSize = strip(org)
  72.    CR = strip(Comp,'T','%')
  73.    CSize = strip(pack)
  74.    END
  75.   END
  76.  END
  77. Call Close(tst)
  78. Call Delete('T:Defuser.temp')
  79. Error = 0
  80. Call Wog(Dateline' Defuser session started:')
  81. If Checkname = 'YES' & Bname then DO
  82.  Call Wog(" PKT *FAILED!* Filename in Archive invalid. Not *.PKT!")
  83.  Error = 1
  84.  END
  85. If Bsize = 1 then DO
  86.  Call Wog(" PKT *FAILED!* Packet in archive larger than "MaxPKTSize" byte maximum!")
  87.  Error = 1
  88.  END
  89. If UnCsize > MaxArchive then DO
  90.  Call Wog(" PKT *FAILED!* Archive total is "UnCsize" bytes which exceeds "MaxArchive" bytes maximum!")
  91.  Error = 1
  92.  END
  93. If UnCsize < MaxNoCRChk then Call Wog(" Packet under CR check size...")
  94. ELSE DO
  95.  If CR > MaxCRate then DO
  96.   Call Wog(" PKT *FAILED!* Archive CR of "CR"% which exceeds "MaxCRate"% maximum!")
  97.   Error = 1
  98.   END
  99.  END
  100. If ~Error then DO
  101.  Call Wog(" "Type" Session OK. Total Comp size: "CSize", Total UnComp size: "UnCsize", CRate: "CR"%")
  102.  If Type = 'LZX' then opts = LZXUnpack
  103.  ELSE opts = LHAUnpack
  104.  Address COMMAND ExeDir||Type' 'opts' 'Archive' #?.PKT'
  105.  Call Wog("---") ; Call Close(log)
  106.  EXIT
  107.  END
  108. Call Wog('Packet rejected. CALL the BOMB SQUAD! Suspect moved to 'BadPKT' ... Phew!')
  109. Dstamp = 'BOMB-'Translate(Date('E'),'-','/')'-'Translate(Time('N'),'.',':')
  110. Address COMMAND ExeDir'Copy 'Archive' TO 'BadPKT||Dstamp
  111. If RC = 0 then Call Delete(Archive)
  112. ELSE Call Wog(" Couldn't move to "BadPKT"!")
  113. Call Wog('---') ; Call Close(log)
  114. EXIT 10
  115.  
  116. Wog:
  117. Parse ARG OutLine
  118. Call WriteLN(log,Outline)
  119. RETURN
  120.