/* Xtrude.rexx */

/* Test script for Xtruder. This is pieces taken from a longer
   script which performs various checks on BBS uploads. 'Load_VC'
   is a subroutine in that program. Note: Waitforport times out
   after 10 seconds. I've never found loading Xtruder takes more
   than 2 or 3 seconds, so maybe the 'for' loop is unnecessary.
*/

options results

VCdir =  'work1:utilities.1/xtruder/'    /* Path to your virus checker */
TestDir = 'BBS:test'               /* directory holding files for test */


Load_VC:
  response=0
  if ~show(Ports,'XTRUDER') then do
    if exists(VCdir||'Xtruder') then do
        address command 'run <>nil: '||VCdir||'Xtruder'
        do i=1 to 3
          address command 'waitforport XTRUDER'
          if RC=0 then leave
        end
    end
    if ~show(Ports,'XTRUDER') then response=10
  end

  if response>0 then exit 20  /* ... or whatever you want to do */

  address 'XTRUDER' 'Checkfiles '||TestDir
  vircount = RC

  if vircount < 0 then do
    say 'Unable to do check. Xtruder error code '||vircount
    vircount=0
  end
  if vircount >0 then do
    say 'Found a Virus!'      /* ... or whatever you want to do */
  end
