#!/bin/sh
##  $Revision: 1.10 $
##  Ihave control-message handler
. /usr/lib/news/lib/innshellvars

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
