!Program scans all directories and lists files over the specified threshhold
!size.  System password will have to be quoted if all files are to be checked.
!J. Butler Sep 85

%begin
   %include "inc:ssi.imp"
   %include "inc:fsutil.imp"

   %ownstring(255)s="", outfile="",eventmess=""
   %integer threshhold, no of dirs, i, part
   %string (255) File,a,b
   %string (7) %array dirs(0:511)
   

%routine get dirs(%integer partition,
%string (255) mask, %integername No of Dirs, %string (7) %arrayname dirs)
  !Get the list of directories on the specified partition

%integerfn  part enquiry(%integer part, bit, address, %integername size)
   %integer blockno
   %string (255) blk

   blockno = part<<1+bit
   blk = tostring((blockno&255)+'0')
   size = fcommr('\'<<8,blk, byteinteger(address), 532)
!t!printstring("SI "); phex(size); newline
   %result=0
%end

%routine move(%integer bytes, %bytename from, to)
   *Subq.l #1, d0
f loop:
   *move.b (a0)+, (a1)+
   *dbra   d0, f loop
%end

%recordformat DINFO FM(%string (7) name, %shortinteger partno, dirno)

  %routine do bit(%integer bit)
     %string (7) dir
     %integer i, len
     %bytearray buff(0:511)

     len = 512
     i = part enquiry(partition, bit, addr(buff(0)), len)
!t!  printstring("PE"); write(i, 1); newline
     %if i = 0 %start
!t!     write(len, 3); newline
!t!     %for i = 0, 1, len-1 %cycle; printsymbol(buff(i)); %repeat
!t!     newline
        %for i = 0, 1, len>>3-1 %cycle
           move(7, buff(i<<3), charno(dir, 1)); length(dir) = 7
           length(dir) = length(dir) - 1 %while dir # "" %and %c
           charno(dir, length(dir)) = ' '
!t!        printstring(dir); newline
           %if dir # "---" %and (mask = "" %or matches(dir, mask)) %start
              dirs(no of dirs) = dir; no of dirs = no of dirs + 1
           %finish
        %repeat
     %finish
!t!  printstring("DI"); write(no of dirs, 1); newline
  %end

  do bit(0); do bit(1)
%end

   %routine check files(%string (15) directory, %integer threshhold)
      %string (127) Line, Temp, s
      %integer i, Index
      %record (finfof) fr

      temp = finfo(directory, 0)
      %if temp -> temp.("blocks: ").s %and s -> s.("/").temp %start
         i = stoi(temp)
         %return %if i < threshhold
      %finish

      index=1
      %cycle
         temp = finfo(directory, index)
         unpack finfo(temp, fr)
         %if fr_blocks>threshhold %start
            printstring(directory); spaces(8-length(directory))
            printline(temp)
         %finish
         index=index+1
      %repeatuntil fr_name = ""

   %end


   file = ""; outfile = ""; threshhold = 100
   define param("DIR", file, pam major)
   define int param("Threshhold", threshhold, 0)
   define param("OUT", outfile, 0)
   process parameters(cli param)

   %if file -> a.("*").b %start
      no of dirs=0
      %for part=0,1,7 %cycle
      get dirs(part, file, no of dirs, dirs)
      %repeat
   %else
      dirs(0) = file; no of dirs = 1
   %finish

   open output(1, outfile) %and selectoutput(1) %if outfile # ""

   %for i=0,1,no of dirs-1 %cycle
!t!   printline(dirs(i)."...")
      checkfiles(dirs(i), threshhold)
   %repeat

   New Line

%endofprogram
