#!/bin/sh

if [ $1 = "-" ]; then
	echo "char ONEW_RKTAB_DATA[1];"        > rktab.c
	echo "int  ONEW_RKTAB_DATA_SIZE = 0;" >> rktab.c
	exit 0
fi


TABS=`./onew -rktab`
RKDIR=onew_rktabs
RKTAR=rktabs.tar

if [ -d "$RKDIR" ]; then rm -rf $RKDIR; fi
mkdir $RKDIR

for TAB in $TABS
do
	TDIR=`echo $TAB|sed "s/:.*//"`
	SDIR=`echo $TAB|sed "s/.*://"`
	DEST=$RKDIR/$TDIR

	echo $TDIR $SDIR
	mkdir $RKDIR/$TDIR

#######	cp -rp $SDIR $DEST
	if [ -d "$SDIR" ]; then
	       (cd $SDIR; tar cfh - .)|(cd $DEST; tar xf -)
	else	cp $SDIR $DEST; fi
done

(cd $RKDIR; tar cf ../$RKTAR .)
compress -f $RKTAR
ls -l $RKTAR.Z
rm -rf $RKDIR
./onew -cdump ONEW_RKTAB_DATA < $RKTAR.Z > rktab.c


syntax highlighted by Code2HTML, v. 0.9.1