3 # Originally by Simon Tatham
4 # Modified by Richard Kettlewell, Colin Watson, Ian Jackson
6 # Copyright -2011 Simon Tatham
7 # Copyright 2011 Richard Kettlewell
8 # Copyright 2011 Colin Watson
9 # Copyright 2011 Ian Jackson
11 # Permission is hereby granted, free of charge, to any person obtaining a
12 # copy of this software and associated documentation files (the "Software"),
13 # to deal in the Software without restriction, including without limitation
14 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 # and/or sell copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following conditions:
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 # SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 # DEALINGS IN THE SOFTWARE.
32 ($verbose='STDERR', shift @ARGV) if $ARGV[0] eq "-v";
34 my $c = cnntp_connect($verbose);
39 # some servers require a GROUP before an ARTICLE command
40 $c->docmd("GROUP misc.misc");
49 my $item = shift @ARGV;
50 if($item !~ /[\@:]/ and not defined $group) {
51 # maybe a bare group followed by an article number
53 my $number = shift @ARGV;
54 $item = "$item $number";
66 if($mid !~ /\@/ and $mid =~ /^(.*)[: ](\d+)$/) {
67 my ($g, $n) = ($1, $2);
68 $c->docmd("GROUP $g");
69 $c->docmd("ARTICLE $n");
73 $c->docmd("ARTICLE <$mid>");
78 my $lesscmd= $ENV{'NNTPID_PAGER'};
79 $lesscmd= 'less' unless defined $lesscmd;
80 open LESS, "|-", 'sh','-c',$lesscmd or die $!;
85 ($code,$_) = $c->getline();
92 if ($fh ne 'STDOUT') {
93 close $fh or die "$? $!";