#! /bin/sh
#
# wrapper nkf filter for cvs-server
#
# Usage: cvswrap [--euc-unix|--sjis-windows] infile outfile
#
# cvswrap.pl by Morikawa Yasuhiro, 2004

NKF=/usr/bin/nkf
# Line Terminator: LF(-Lu), CR/LF(-Lw), CR(-Lm)
# Kanji Code: SJIS(-s), EUC(-e), JIS(-j) including hankaku->zenkaku
TR=/usr/bin/tr
# Cntl-Z=\032(0x1a)

if [ ! $3 ] || [ ! -f $2 ] ; then
    echo "Usage: cvswrap [--euc-unix|--sjis-windows] infile outfile"
    exit 1
fi

opt=$1
infile=$2
outfile=$3

if [ ${opt} = "--euc-unix" ] ; then
    ${NKF} -eLu ${infile} | ${TR} -d '\032' > /tmp/unkf-cvs$$
    mv -f /tmp/unkf-cvs$$ ${outfile}
elif [ ${opt} = "--sjis-windows" ] ; then
    ${NKF} -sLw ${infile} > /tmp/wnkf-cvs$$
    mv -f /tmp/wnkf-cvs$$ ${outfile}
else
    echo "Usage: cvswrap [--euc-unix|--sjis-windows] infile outfile"
    exit 1
fi

exit 0
