#!/usr/bin/perl

$include = "N";
$post = "N";

print "HTTP/1.0 200 OK\n";
print "Content-type: application/none\n";
print "Content-length: 9\n\n";
print "Post Done\n";

while (<>)
{
	chop;
	
	($type,$value) = split ( '\s*:\s+' , $_, 2);

	if ( $type eq "X-filename" ) {
		($group, $number, $posttype) = $value =~ m|/*([^/]+)/([0-9]*)?(.*)|;
		if ( $group eq "" ) {
			exit 1;
		}
		$include = "Y"  if ( $posttype =~ /include/ );
		$post = "Y"     if ( $posttype =~ /post/ );

                if ($number == 0) {
			$cmds = "-f \*{news/nntp}$group -I C";
		} else {
			$cmds = "-f \*{news/nntp}$group -n $number ";
			$cmds .= "-I I,R,$include,$post";
		}
		system ("/usr/X11R6/bin/xterm -e /root/usr/bin/pine $cmds >/dev/null 2>/dev/null");
		last;
	}
}
