#!/bin/csh -f 

if ($#argv != 1) then
  echo "USAGE: mkindex.sh (dir)"
  exit 2
endif

set topdir = $argv[1]

# this is weak: depends on root location
ln -s /export/ipp002.0/www/localhost/htdocs/ippData/index.php $topdir/

set file = `basename $topdir`
echo "$file : $file : plain : title  : Title" > $topdir/index.txt
echo "..    : ..    : dir   : dir2   : parent directory" >> $topdir/index.txt

set N = 1
foreach entry ($topdir/*)
  set file = `basename $entry`
  if ("$file" == "index.php") continue
  if ("$file" == "index.txt") continue

  if (-d $entry) then
    echo "$file : $file : dir : dir$N : directory" >> $topdir/index.txt
    /export/ipp002.0/www/localhost/scripts/mkindex.sh $entry
  endif

  if (-f $entry) then
    echo "$file : $file : file : file$N : database file" >> $topdir/index.txt
  endif

  if ($N == 1) then
    set N = 2
  else
    set N = 1
  endif
end
