#!/bin/csh -f 

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

set topdir = $argv[1]

set file = `basename $topdir`

echo '<?php include "@HTDOCS@/www-util/dvodist.page.php"; ?>' >  $topdir/index.mkd

echo "$file : plain : title  : Title" >> $topdir/index.mkd
echo "..             : dir   : dir2  : parent directory" >> $topdir/index.mkd

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

  if (-d $entry) then
    echo "@ $file : dir : dir$N : directory" >> $topdir/index.mkd
  endif

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

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