/* 
   $VER: MagicFile 3 Xtruder Virus Checker AREXX ©1997 Steve Clack 1.0
   
   This may be freely distributed and mutated!
      
   Template: XtruderFileCheck.rx <no arguments yet>
        
   If Xtruder is not running, it will be started from the script.
*/

Prog_Xtruder = "SYS:System/Xtruder/Xtruder" /* << Change this to where your Xtruder is! */

options results
options failat 99

if ~show(ports,XTRUDER) then do
     address command Prog_Xtruder
     StartTime = time(seconds)
     do while ~show(ports,XTRUDER)
          if time(seconds) - StartTime > 20 then do
               address command 'Echo >>BBS:Logfiles/MFVirusLog.text "'Time()' 'Date()' serious problem occoured:"'
               address command 'Echo >>BBS:Logfiles/MFVirusLog.text "Failed to load Xtruder! Files have been untouched!*n"'
               exit
          end
     end
end

address XTRUDER HIDE

call open(checkfile,'T:MFCheckQueue',R)
DO UNTIL EOF(checkfile)
  Line = READLN(checkfile)
  IF UPPER(WORD(Line,1)) = "%" THEN DO
   USERNAME = READLN(checkfile)
   DESTPATH = READLN(checkfile)
   Line = READLN(checkfile)
  END

  IF Line ~= "" then do
   address XTRUDER CHECKFILES Line
   status = rc
   
   if status<0 then do
      address command 'Echo >>BBS:Logfiles/MFVirusLog.text "'Time()' 'Date()' serious problem occoured:"'
      address command 'Echo >>BBS:Logfiles/MFVirusLog.text "Failed to virus check >'Line'< uploaded by 'USERNAME'!*n"'
      address command 'Copy >nil: 'Line' 'DESTPATH
   end
   
   if status=0 then do
      address command 'Copy >nil: 'Line' 'DESTPATH
   end

   if status>0 then do
      address command 'Echo >>BBS:Logfiles/MFVirusLog.text "'Time()' 'Date()' incident occoured:"'
      address command 'Echo >>BBS:Logfiles/MFVirusLog.text "'USERNAME' uploaded virus infected >'Line'< - 'status' viruses found!*n"'
   end

  address command 'Delete >nil: 'Line
  END
END
call close checkfile
address command 'Delete >nil: T:MFCheckQueue'
exit
