(retracted by #17444)
[p5sagit/p5-mst-13.2.git] / lib / Net / NNTP.pm
index 2644397..521ccf1 100644 (file)
@@ -14,7 +14,7 @@ use Carp;
 use Time::Local;
 use Net::Config;
 
-$VERSION = "2.19"; # $Id: //depot/libnet/Net/NNTP.pm#8$
+$VERSION = "2.21"; # $Id: //depot/libnet/Net/NNTP.pm#15 $
 @ISA     = qw(Net::Cmd IO::Socket::INET);
 
 sub new
@@ -60,7 +60,7 @@ sub new
 
  my $c = $obj->code;
  my @m = $obj->message;
+
  unless(exists $arg{Reader} && $arg{Reader} == 0) {
    # if server is INN and we have transfer rights the we are currently
    # talking to innd not nnrpd
@@ -116,6 +116,14 @@ sub article
     : undef;
 }
 
+sub articlefh {
+ @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->articlefh( [ MSGID ] )';
+ my $nntp = shift;
+
+ return unless $nntp->_ARTICLE(@_);
+ return $nntp->tied_fh;
+}
+
 sub authinfo
 {
  @_ == 3 or croak 'usage: $nntp->authinfo( USER, PASS )';
@@ -147,6 +155,14 @@ sub body
     : undef;
 }
 
+sub bodyfh
+{
+ @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->bodyfh( [ MSGID ] )';
+ my $nntp = shift;
+ return unless $nntp->_BODY(@_);
+ return $nntp->tied_fh;
+}
+
 sub head
 {
  @_ >= 1 && @_ <= 3 or croak 'usage: $nntp->head( [ MSGID ], [ FH ] )';
@@ -160,6 +176,14 @@ sub head
     : undef;
 }
 
+sub headfh
+{
+ @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->headfh( [ MSGID ] )';
+ my $nntp = shift;
+ return unless $nntp->_HEAD(@_);
+ return $nntp->tied_fh;
+}
+
 sub nntpstat
 {
  @_ == 1 || @_ == 2 or croak 'usage: $nntp->nntpstat( [ MSGID ] )';
@@ -296,6 +320,12 @@ sub post
     : undef;
 }
 
+sub postfh {
+  my $nntp = shift;
+  return unless $nntp->_POST();
+  return $nntp->tied_fh;
+}
+
 sub quit
 {
  @_ == 1 or croak 'usage: $nntp->quit()';
@@ -514,9 +544,14 @@ sub _msg_arg
   {
    if(ref($spec))
     {
-     $arg = $spec->[0] . "-";
-     $arg .= $spec->[1]
-       if defined $spec->[1] && $spec->[1] > $spec->[0];
+     $arg = $spec->[0];
+     if(defined $spec->[1])
+      {
+       $arg .= "-"
+         if $spec->[1] != $spec->[0];
+       $arg .= $spec->[1]
+         if $spec->[1] > $spec->[0];
+      }
     }
    else
     {
@@ -660,7 +695,7 @@ Net::NNTP - NNTP Client class
 =head1 SYNOPSIS
 
     use Net::NNTP;
-    
+
     $nntp = Net::NNTP->new("some.host.name");
     $nntp->quit;
 
@@ -738,6 +773,16 @@ Like C<article> but only fetches the body of the article.
 
 Like C<article> but only fetches the headers for the article.
 
+=item articlefh ( [ MSGID|MSGNUM ] )
+
+=item bodyfh ( [ MSGID|MSGNUM ] )
+
+=item headfh ( [ MSGID|MSGNUM ] )
+
+These are similar to article(), body() and head(), but rather than
+returning the requested data directly, they return a tied filehandle
+from which to read the article.
+
 =item nntpstat ( [ MSGID|MSGNUM ] )
 
 The C<nntpstat> command is similar to the C<article> command except that no
@@ -799,8 +844,8 @@ that it will allow posting.
 
 Obtain information about all the active newsgroups. The results is a reference
 to a hash where the key is a group name and each value is a reference to an
-array. The elements in this array are:- the first article number in the group,
-the last article number in the group and any information flags about the group.
+array. The elements in this array are:- the last article number in the group,
+the first article number in the group and any information flags about the group.
 
 =item newgroups ( SINCE [, DISTRIBUTIONS ])
 
@@ -837,6 +882,15 @@ C<datasend> and C<dataend> methods from L<Net::Cmd>
 
 C<MESSAGE> can be either an array of lines or a reference to an array.
 
+=item postfh ()
+
+Post a new article to the news server using a tied filehandle.  If
+posting is allowed, this method will return a tied filehandle that you
+can print() the contents of the article to be posted.  You must
+explicitly close() the filehandle when you are finished posting the
+article, and the return value from the close() call will indicate
+whether the message was successfully posted.
+
 =item slave ()
 
 Tell the remote server that I am not a user client, but probably another
@@ -1011,7 +1065,7 @@ the beginning of the test string just inside the open square
 bracket.
 
 The final operation uses the backslash character to
-invalidate the special meaning of the a open square bracket C<[>,
+invalidate the special meaning of an open square bracket C<[>,
 the asterisk, backslash or the question mark. Two backslashes in
 sequence will result in the evaluation of the backslash as a
 character with no special meaning.
@@ -1057,4 +1111,8 @@ Copyright (c) 1995-1997 Graham Barr. All rights reserved.
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
+=for html <hr>
+
+I<$Id: //depot/libnet/Net/NNTP.pm#15 $>
+
 =cut