#! /bin/sh
# fixscript will replace this line with code to load innshellvars

##  $Revision: 1.11 $
##  Ihave control-message handler

PROG=ihave
##  Some shells don't pass in $* unless we explicitly pass it in here.
. ${PATHBIN}/parsecontrol "$@"

case ${ACTION} in
mail)
    ${SM} ${ARTICLE} | sed -e 's/^~/~~/' \
	| ${MAILCMD} -s "ihave by ${FROM}" ${NEWSMASTER}
    ;;
doit)
    ##  Scan the message body for articles we don't have.
    ${SM} ${ARTICLE} | ${SED} -e '1,/^$/d' | grephistory -i >${TEMP}
    if [ -s ${TEMP} ] ; then
	export PATHHOST TEMP
	(
	    echo Newsgroups: to.${PATHHOST}
	    echo Subject: cmsg sendme `innconfval pathhost`
	    echo Control: sendme `innconfval pathhost`
	    echo ''
	    cat ${TEMP}
	) | ${INEWS} -h
    fi
    rm -f ${TEMP}
    ;;
esac

exit
