#!/bin/csh -f

set progname = `basename $0`
set path = ($path /vol/lab/bin) #for errecho!
setenv HANDIN /vol/vlsi/local/handin

if ($#argv != 2) then
  errecho "$progname : usage: $progname <cadgroup> <exno>"
  exit 1
endif

set cadgroup = $1
set raw_exno = $2

set exercise = $raw_exno #they could be different in a system with names, say

set handin_loc = $HANDIN/$cadgroup
if (!(-d $handin_loc/$exercise) && !(-f $handin_loc/$exercise.CRUSHED)) then
  errecho "$progname : cannot find directory for $cadgroup exercise $exercise"
  exit 1
else if (-f $handin_loc/.lock.$exercise) then
  errecho "$progname : $cadgroup exercise $exercise already locked\!"
  exit 1
else
  date > $handin_loc/.lock.$exercise
  chmod 440 $handin_loc/.lock.$exercise
  show_lockcad_status $cadgroup $raw_exno
endif
