#!/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 /data/ippc17.0/www/dvodist/www-root/index.php $topdir/

set file = `basename $topdir`
echo "$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 : dir : dir$N : directory" >> $topdir/index.txt
  endif

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

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