#!/afs/athena/contrib/perl/perl

# $Id$

# This uses MH and goes by message numbers. You need the
# environment variable NNTPSERVER set.
#
# The script auto-generates cancel messages, with the username
# of the person cancelling in the body.
#
# This script calls several outside functions found largely in nntp.pl
#
# comments added by PJK

# add some necessary directories for the lib path in @INC
push(@INC, 
     "$ENV{'HOME'}/lib/perl",
     '/afs/athena.mit.edu/user/j/i/jik/lib/perl');

require 'nntp.pl';


$inews = "inews -h";
#$inews = "cat";

$id = shift @ARGV;

&news_open($ENV{'NNTPSERVER'} || "news");

&news_xhdr_init("newsgroups", $id) || die "Cannot find article $id\n";
(($id, $newsgroups) = &news_xhdr_next()) || die;
&news_xhdr_next;

&news_xhdr_init("from", $id) || die;
(($foo, $from) = &news_xhdr_next()) || die;
&news_xhdr_next;

if (&news_xhdr_init("sender",$id)) {
    (($foo, $sender) = &news_xhdr_next());
}
&news_close();

$senderline = "Sender: $sender" if $sender;

open(INEWS, "|$inews") || die "Error opening $inews:$!\n";

print INEWS <<EOF || die;
From: $from
Approved: news-answers-request\@MIT.EDU (the *.answers moderation team)
Newsgroups: $newsgroups
Subject: cmsg cancel $id
Control: cancel $id
$senderline

Article cancelled by $ENV{'USER'}\@MIT.EDU, member of the *.answers
moderation team.
EOF

close(INEWS);
die "Error closing $inews\n" if ($?);
