#!/bin/sh -f


if [ $# = 0 ]
then
        echo "addVltIncludeHeader: usage  addVltIncludeHeader what file1 file2..."
        echo "e.g.: addVltIncludeHeader "created from slalib source" file1 file2..."
        exit
fi

T_DIR=$VLTROOT/templates/forCoding
TEMPLATE=$T_DIR/h-file.template
AUTHOR=`whoami`
DATE=`date "+%d\/%m\/%y"`

if [ ! -r ${TEMPLATE} ]
then
	echo "Template $TEMPLATE does not exist!!"
	exit 1
fi

WHAT=$1

shift

for file in $*
do
	echo working on $file ...
	grep -v "#%#" $TEMPLATE | grep -v -e "^#.*_H" | sed  -e "1,$ s/NNNNNNNN/$AUTHOR/g" \
	                               -e "1,$ s/dd\/mm\/yy/$DATE/g" \
	                               -e "1,$ s/I>-<d/\Id/g"        \
	                               -e "s/created/${WHAT}/g" | cat - $file > tmp.tmp

	mv tmp.tmp $file

done
echo finished
exit 0
