releasing/cbrtools/perl/Net/NNTP.pm
author jascui
Tue, 16 Nov 2010 15:56:27 +0800
changeset 683 8e0eb519ef53
parent 602 3145852acc89
permissions -rw-r--r--
Solve incorrect handling of ExportName=SymbolName@Ordinal syntax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Net::NNTP.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# Copyright (c) 1995-1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This program is free software; you can redistribute it and/or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# modify it under the same terms as Perl itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
package Net::NNTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
use vars qw(@ISA $VERSION $debug);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
use IO::Socket;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
use Net::Cmd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
use Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
use Time::Local;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
use Net::Config;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
$VERSION = "2.22"; # $Id: //depot/libnet/Net/NNTP.pm#18 $
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
@ISA     = qw(Net::Cmd IO::Socket::INET);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
sub new
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
 my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
 my $type = ref($self) || $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
 my $host = shift if @_ % 2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
 my %arg  = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
 my $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
 $host ||= $ENV{NNTPSERVER} || $ENV{NEWSHOST};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
 my $hosts = defined $host ? [ $host ] : $NetConfig{nntp_hosts};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
 @{$hosts} = qw(news)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
	unless @{$hosts};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
 my $h;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
 foreach $h (@{$hosts})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
   $obj = $type->SUPER::new(PeerAddr => ($host = $h), 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
			    PeerPort => $arg{Port} || 'nntp(119)',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
			    Proto    => 'tcp',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
			    Timeout  => defined $arg{Timeout}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
						? $arg{Timeout}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
						: 120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
			   ) and last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
 return undef
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
	unless defined $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
 ${*$obj}{'net_nntp_host'} = $host;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
 $obj->autoflush(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
 $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
 unless ($obj->response() == CMD_OK)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
   $obj->close;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
   return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
 my $c = $obj->code;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
 my @m = $obj->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
 unless(exists $arg{Reader} && $arg{Reader} == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
   # if server is INN and we have transfer rights the we are currently
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
   # talking to innd not nnrpd
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
   if($obj->reader)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
     # If reader suceeds the we need to consider this code to determine postok
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
     $c = $obj->code;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
   else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
     # I want to ignore this failure, so restore the previous status.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
     $obj->set_status($c,\@m);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
 }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
 ${*$obj}{'net_nntp_post'} = $c == 200 ? 1 : 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
 $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
sub debug_text
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
 my $inout = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
 my $text = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
 if((ref($nntp) and $nntp->code == 350 and $text =~ /^(\S+)/)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    || ($text =~ /^(authinfo\s+pass)/io)) 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
   $text = "$1 ....\n"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
 $text;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
sub postok
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
 @_ == 1 or croak 'usage: $nntp->postok()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
 ${*$nntp}{'net_nntp_post'} || 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
sub article
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
 @_ >= 1 && @_ <= 3 or croak 'usage: $nntp->article( [ MSGID ], [ FH ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
 my @fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
 @fh = (pop) if @_ == 2 || (@_ && ref($_[0]) || ref(\$_[0]) eq 'GLOB');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
 $nntp->_ARTICLE(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
    ? $nntp->read_until_dot(@fh)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
sub articlefh {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
 @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->articlefh( [ MSGID ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
 return unless $nntp->_ARTICLE(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
 return $nntp->tied_fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
sub authinfo
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
 @_ == 3 or croak 'usage: $nntp->authinfo( USER, PASS )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
 my($nntp,$user,$pass) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
 $nntp->_AUTHINFO("USER",$user) == CMD_MORE 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    && $nntp->_AUTHINFO("PASS",$pass) == CMD_OK;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
sub authinfo_simple
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
 @_ == 3 or croak 'usage: $nntp->authinfo( USER, PASS )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
 my($nntp,$user,$pass) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
 $nntp->_AUTHINFO('SIMPLE') == CMD_MORE 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
    && $nntp->command($user,$pass)->response == CMD_OK;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
sub body
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
 @_ >= 1 && @_ <= 3 or croak 'usage: $nntp->body( [ MSGID ], [ FH ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
 my @fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
 @fh = (pop) if @_ == 2 || (@_ && ref($_[0]) || ref(\$_[0]) eq 'GLOB');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
 $nntp->_BODY(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
    ? $nntp->read_until_dot(@fh)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
sub bodyfh
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
 @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->bodyfh( [ MSGID ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
 return unless $nntp->_BODY(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
 return $nntp->tied_fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
sub head
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
 @_ >= 1 && @_ <= 3 or croak 'usage: $nntp->head( [ MSGID ], [ FH ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
 my @fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
 @fh = (pop) if @_ == 2 || (@_ && ref($_[0]) || ref(\$_[0]) eq 'GLOB');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
 $nntp->_HEAD(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
    ? $nntp->read_until_dot(@fh)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
sub headfh
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
 @_ >= 1 && @_ <= 2 or croak 'usage: $nntp->headfh( [ MSGID ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
 return unless $nntp->_HEAD(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
 return $nntp->tied_fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
sub nntpstat
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->nntpstat( [ MSGID ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
 $nntp->_STAT(@_) && $nntp->message =~ /(<[^>]+>)/o
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
    ? $1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
sub group
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->group( [ GROUP ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
 my $grp = ${*$nntp}{'net_nntp_group'} || undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
 return $grp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
    unless(@_ || wantarray);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
 my $newgrp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
 return wantarray ? () : undef
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
	unless $nntp->_GROUP($newgrp || $grp || "")
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
		&& $nntp->message =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\S+)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
 my($count,$first,$last,$group) = ($1,$2,$3,$4);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
 # group may be replied as '(current group)'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
 $group = ${*$nntp}{'net_nntp_group'}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
    if $group =~ /\(/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
 ${*$nntp}{'net_nntp_group'} = $group;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
 wantarray
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
    ? ($count,$first,$last,$group)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
    : $group;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
sub help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
 @_ == 1 or croak 'usage: $nntp->help()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
 $nntp->_HELP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
    ? $nntp->read_until_dot
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
sub ihave
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
 @_ >= 2 or croak 'usage: $nntp->ihave( MESSAGE-ID [, MESSAGE ])';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
 my $mid = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
 $nntp->_IHAVE($mid) && $nntp->datasend(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
    ? @_ == 0 || $nntp->dataend
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
sub last
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
 @_ == 1 or croak 'usage: $nntp->last()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
 $nntp->_LAST && $nntp->message =~ /(<[^>]+>)/o
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
    ? $1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
sub list
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
 @_ == 1 or croak 'usage: $nntp->list()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
 $nntp->_LIST
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
    ? $nntp->_grouplist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
sub newgroups
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
 @_ >= 2 or croak 'usage: $nntp->newgroups( SINCE [, DISTRIBUTIONS ])';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
 my $time = _timestr(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
 my $dist = shift || "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
 $dist = join(",", @{$dist})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
    if ref($dist);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
 $nntp->_NEWGROUPS($time,$dist)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
    ? $nntp->_grouplist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
sub newnews
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
 @_ >= 2 && @_ <= 4 or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
	croak 'usage: $nntp->newnews( SINCE [, GROUPS [, DISTRIBUTIONS ]])';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
 my $time = _timestr(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
 my $grp  = @_ ? shift : $nntp->group;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
 my $dist = shift || "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
 $grp ||= "*";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
 $grp = join(",", @{$grp})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
    if ref($grp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
 $dist = join(",", @{$dist})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
    if ref($dist);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
 $nntp->_NEWNEWS($grp,$time,$dist)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
    ? $nntp->_articlelist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
sub next
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
 @_ == 1 or croak 'usage: $nntp->next()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
 $nntp->_NEXT && $nntp->message =~ /(<[^>]+>)/o
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
    ? $1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
sub post
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
 @_ >= 1 or croak 'usage: $nntp->post( [ MESSAGE ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
 $nntp->_POST() && $nntp->datasend(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
    ? @_ == 0 || $nntp->dataend
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
sub postfh {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
  my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
  return unless $nntp->_POST();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
  return $nntp->tied_fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
sub quit
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
 @_ == 1 or croak 'usage: $nntp->quit()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
 $nntp->_QUIT;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
 $nntp->close;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
sub slave
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
 @_ == 1 or croak 'usage: $nntp->slave()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
 $nntp->_SLAVE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
## The following methods are not implemented by all servers
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
sub active
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->active( [ PATTERN ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
 $nntp->_LIST('ACTIVE',@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
    ? $nntp->_grouplist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
sub active_times
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
 @_ == 1 or croak 'usage: $nntp->active_times()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
 $nntp->_LIST('ACTIVE.TIMES')
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
    ? $nntp->_grouplist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
sub distributions
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
 @_ == 1 or croak 'usage: $nntp->distributions()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
 $nntp->_LIST('DISTRIBUTIONS')
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
    ? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
sub distribution_patterns
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
 @_ == 1 or croak 'usage: $nntp->distributions()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
 my $arr;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
 local $_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
 $nntp->_LIST('DISTRIB.PATS') && ($arr = $nntp->read_until_dot)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
    ? [grep { /^\d/ && (chomp, $_ = [ split /:/ ]) } @$arr]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
sub newsgroups
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->newsgroups( [ PATTERN ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
 $nntp->_LIST('NEWSGROUPS',@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
    ? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
sub overview_fmt
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
 @_ == 1 or croak 'usage: $nntp->overview_fmt()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
 $nntp->_LIST('OVERVIEW.FMT')
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
     ? $nntp->_articlelist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
     : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
sub subscriptions
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   415
 @_ == 1 or croak 'usage: $nntp->subscriptions()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   416
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   417
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   418
 $nntp->_LIST('SUBSCRIPTIONS')
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   419
    ? $nntp->_articlelist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   420
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   421
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   422
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   423
sub listgroup
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   424
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   425
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->listgroup( [ GROUP ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   426
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   427
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   428
 $nntp->_LISTGROUP(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   429
    ? $nntp->_articlelist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   430
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   431
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   432
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   433
sub reader
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   434
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   435
 @_ == 1 or croak 'usage: $nntp->reader()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   436
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   437
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   438
 $nntp->_MODE('READER');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   439
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   440
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   441
sub xgtitle
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   442
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   443
 @_ == 1 || @_ == 2 or croak 'usage: $nntp->xgtitle( [ PATTERN ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   444
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   445
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   446
 $nntp->_XGTITLE(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   447
    ? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   448
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   449
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   450
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   451
sub xhdr
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   452
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   453
 @_ >= 2 && @_ <= 4 or croak 'usage: $nntp->xhdr( HEADER, [ MESSAGE-SPEC ] )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   454
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   455
 my $hdr = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   456
 my $arg = _msg_arg(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   457
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   458
 $nntp->_XHDR($hdr, $arg)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   459
	? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   460
	: undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   461
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   462
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   463
sub xover
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   464
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   465
 @_ == 2 || @_ == 3 or croak 'usage: $nntp->xover( MESSAGE-SPEC )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   466
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   467
 my $arg = _msg_arg(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   468
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   469
 $nntp->_XOVER($arg)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   470
	? $nntp->_fieldlist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   471
	: undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   472
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   473
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   474
sub xpat
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   475
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   476
 @_ == 4 || @_ == 5 or croak '$nntp->xpat( HEADER, PATTERN, MESSAGE-SPEC )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   477
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   478
 my $hdr = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   479
 my $pat = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   480
 my $arg = _msg_arg(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   481
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   482
 $pat = join(" ", @$pat)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   483
    if ref($pat);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   484
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   485
 $nntp->_XPAT($hdr,$arg,$pat)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   486
	? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   487
	: undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   488
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   489
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   490
sub xpath
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   491
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   492
 @_ == 2 or croak 'usage: $nntp->xpath( MESSAGE-ID )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   493
 my($nntp,$mid) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   494
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   495
 return undef
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   496
	unless $nntp->_XPATH($mid);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   497
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   498
 my $m; ($m = $nntp->message) =~ s/^\d+\s+//o;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   499
 my @p = split /\s+/, $m;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   500
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   501
 wantarray ? @p : $p[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   502
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   503
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   504
sub xrover
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   505
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   506
 @_ == 2 || @_ == 3 or croak 'usage: $nntp->xrover( MESSAGE-SPEC )';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   507
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   508
 my $arg = _msg_arg(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   509
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   510
 $nntp->_XROVER($arg)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   511
	? $nntp->_description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   512
	: undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   513
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   514
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   515
sub date
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   516
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   517
 @_ == 1 or croak 'usage: $nntp->date()';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   518
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   519
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   520
 $nntp->_DATE && $nntp->message =~ /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   521
    ? timegm($6,$5,$4,$3,$2-1,$1 - 1900)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   522
    : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   523
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   524
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   525
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   526
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   527
## Private subroutines
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   528
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   529
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   530
sub _msg_arg
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   531
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   532
 my $spec = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   533
 my $arg = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   534
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   535
 if(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   536
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   537
   carp "Depriciated passing of two message numbers, "
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   538
      . "pass a reference"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   539
	if $^W;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   540
   $spec = [ $spec, $_[0] ];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   541
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   542
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   543
 if(defined $spec)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   544
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   545
   if(ref($spec))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   546
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   547
     $arg = $spec->[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   548
     if(defined $spec->[1])
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   549
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   550
       $arg .= "-"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   551
	  if $spec->[1] != $spec->[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   552
       $arg .= $spec->[1]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   553
	  if $spec->[1] > $spec->[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   554
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   555
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   556
   else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   557
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   558
     $arg = $spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   559
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   560
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   561
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   562
 $arg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   563
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   564
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   565
sub _timestr
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   566
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   567
 my $time = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   568
 my @g = reverse((gmtime($time))[0..5]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   569
 $g[1] += 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   570
 $g[0] %= 100;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   571
 sprintf "%02d%02d%02d %02d%02d%02d GMT", @g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   572
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   573
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   574
sub _grouplist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   575
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   576
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   577
 my $arr = $nntp->read_until_dot or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   578
    return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   579
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   580
 my $hash = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   581
 my $ln;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   582
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   583
 foreach $ln (@$arr)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   584
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   585
   my @a = split(/[\s\n]+/,$ln);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   586
   $hash->{$a[0]} = [ @a[1,2,3] ];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   587
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   588
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   589
 $hash;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   590
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   591
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   592
sub _fieldlist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   593
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   594
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   595
 my $arr = $nntp->read_until_dot or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   596
    return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   597
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   598
 my $hash = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   599
 my $ln;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   600
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   601
 foreach $ln (@$arr)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   602
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   603
   my @a = split(/[\t\n]/,$ln);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   604
   my $m = shift @a;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   605
   $hash->{$m} = [ @a ];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   606
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   607
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   608
 $hash;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   609
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   610
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   611
sub _articlelist
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   612
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   613
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   614
 my $arr = $nntp->read_until_dot;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   615
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   616
 chomp(@$arr)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   617
    if $arr;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   618
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   619
 $arr;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   620
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   621
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   622
sub _description
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   623
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   624
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   625
 my $arr = $nntp->read_until_dot or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   626
    return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   627
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   628
 my $hash = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   629
 my $ln;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   630
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   631
 foreach $ln (@$arr)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   632
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   633
   chomp($ln);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   634
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   635
   $hash->{$1} = $ln
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   636
    if $ln =~ s/^\s*(\S+)\s*//o;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   637
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   638
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   639
 $hash;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   640
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   641
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   642
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   643
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   644
## The commands
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   645
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   646
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   647
sub _ARTICLE   { shift->command('ARTICLE',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   648
sub _AUTHINFO  { shift->command('AUTHINFO',@_)->response }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   649
sub _BODY      { shift->command('BODY',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   650
sub _DATE      { shift->command('DATE')->response == CMD_INFO }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   651
sub _GROUP     { shift->command('GROUP',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   652
sub _HEAD      { shift->command('HEAD',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   653
sub _HELP      { shift->command('HELP',@_)->response == CMD_INFO }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   654
sub _IHAVE     { shift->command('IHAVE',@_)->response == CMD_MORE }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   655
sub _LAST      { shift->command('LAST')->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   656
sub _LIST      { shift->command('LIST',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   657
sub _LISTGROUP { shift->command('LISTGROUP',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   658
sub _NEWGROUPS { shift->command('NEWGROUPS',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   659
sub _NEWNEWS   { shift->command('NEWNEWS',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   660
sub _NEXT      { shift->command('NEXT')->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   661
sub _POST      { shift->command('POST',@_)->response == CMD_MORE }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   662
sub _QUIT      { shift->command('QUIT',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   663
sub _SLAVE     { shift->command('SLAVE',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   664
sub _STAT      { shift->command('STAT',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   665
sub _MODE      { shift->command('MODE',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   666
sub _XGTITLE   { shift->command('XGTITLE',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   667
sub _XHDR      { shift->command('XHDR',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   668
sub _XPAT      { shift->command('XPAT',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   669
sub _XPATH     { shift->command('XPATH',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   670
sub _XOVER     { shift->command('XOVER',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   671
sub _XROVER    { shift->command('XROVER',@_)->response == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   672
sub _XTHREAD   { shift->unsupported }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   673
sub _XSEARCH   { shift->unsupported }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   674
sub _XINDEX    { shift->unsupported }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   675
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   676
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   677
## IO/perl methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   678
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   679
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   680
sub DESTROY
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   681
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   682
 my $nntp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   683
 defined(fileno($nntp)) && $nntp->quit
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   684
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   685
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   686
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   687
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   688
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   689
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   690
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   691
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   692
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   693
Net::NNTP - NNTP Client class
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   694
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   695
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   696
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   697
    use Net::NNTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   698
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   699
    $nntp = Net::NNTP->new("some.host.name");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   700
    $nntp->quit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   701
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   702
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   703
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   704
C<Net::NNTP> is a class implementing a simple NNTP client in Perl as described
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   705
in RFC977. C<Net::NNTP> inherits its communication methods from C<Net::Cmd>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   706
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   707
=head1 CONSTRUCTOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   708
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   709
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   710
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   711
=item new ( [ HOST ] [, OPTIONS ])
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   712
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   713
This is the constructor for a new Net::NNTP object. C<HOST> is the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   714
name of the remote host to which a NNTP connection is required. If not
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   715
given two environment variables are checked, first C<NNTPSERVER> then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   716
C<NEWSHOST>, then C<Net::Config> is checked, and if a host is not found
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   717
then C<news> is used.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   718
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   719
C<OPTIONS> are passed in a hash like fashion, using key and value pairs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   720
Possible options are:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   721
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   722
B<Timeout> - Maximum time, in seconds, to wait for a response from the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   723
NNTP server, a value of zero will cause all IO operations to block.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   724
(default: 120)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   725
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   726
B<Debug> - Enable the printing of debugging information to STDERR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   727
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   728
B<Reader> - If the remote server is INN then initially the connection
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   729
will be to nnrpd, by default C<Net::NNTP> will issue a C<MODE READER> command
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   730
so that the remote server becomes innd. If the C<Reader> option is given
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   731
with a value of zero, then this command will not be sent and the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   732
connection will be left talking to nnrpd.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   733
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   734
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   735
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   736
=head1 METHODS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   737
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   738
Unless otherwise stated all methods return either a I<true> or I<false>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   739
value, with I<true> meaning that the operation was a success. When a method
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   740
states that it returns a value, failure will be returned as I<undef> or an
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   741
empty list.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   742
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   743
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   744
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   745
=item article ( [ MSGID|MSGNUM ], [FH] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   746
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   747
Retrieve the header, a blank line, then the body (text) of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   748
specified article. 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   749
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   750
If C<FH> is specified then it is expected to be a valid filehandle
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   751
and the result will be printed to it, on success a true value will be
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   752
returned. If C<FH> is not specified then the return value, on success,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   753
will be a reference to an array containg the article requested, each
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   754
entry in the array will contain one line of the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   755
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   756
If no arguments are passed then the current article in the currently
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   757
selected newsgroup is fetched.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   758
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   759
C<MSGNUM> is a numeric id of an article in the current newsgroup, and
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   760
will change the current article pointer.  C<MSGID> is the message id of
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   761
an article as shown in that article's header.  It is anticipated that the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   762
client will obtain the C<MSGID> from a list provided by the C<newnews>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   763
command, from references contained within another article, or from the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   764
message-id provided in the response to some other commands.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   765
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   766
If there is an error then C<undef> will be returned.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   767
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   768
=item body ( [ MSGID|MSGNUM ], [FH] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   769
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   770
Like C<article> but only fetches the body of the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   771
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   772
=item head ( [ MSGID|MSGNUM ], [FH] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   773
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   774
Like C<article> but only fetches the headers for the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   775
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   776
=item articlefh ( [ MSGID|MSGNUM ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   777
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   778
=item bodyfh ( [ MSGID|MSGNUM ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   779
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   780
=item headfh ( [ MSGID|MSGNUM ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   781
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   782
These are similar to article(), body() and head(), but rather than
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   783
returning the requested data directly, they return a tied filehandle
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   784
from which to read the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   785
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   786
=item nntpstat ( [ MSGID|MSGNUM ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   787
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   788
The C<nntpstat> command is similar to the C<article> command except that no
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   789
text is returned.  When selecting by message number within a group,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   790
the C<nntpstat> command serves to set the "current article pointer" without
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   791
sending text.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   792
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   793
Using the C<nntpstat> command to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   794
select by message-id is valid but of questionable value, since a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   795
selection by message-id does B<not> alter the "current article pointer".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   796
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   797
Returns the message-id of the "current article".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   798
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   799
=item group ( [ GROUP ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   800
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   801
Set and/or get the current group. If C<GROUP> is not given then information
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   802
is returned on the current group.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   803
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   804
In a scalar context it returns the group name.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   805
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   806
In an array context the return value is a list containing, the number
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   807
of articles in the group, the number of the first article, the number
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   808
of the last article and the group name.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   809
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   810
=item ihave ( MSGID [, MESSAGE ])
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   811
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   812
The C<ihave> command informs the server that the client has an article
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   813
whose id is C<MSGID>.  If the server desires a copy of that
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   814
article, and C<MESSAGE> has been given the it will be sent.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   815
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   816
Returns I<true> if the server desires the article and C<MESSAGE> was
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   817
successfully sent,if specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   818
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   819
If C<MESSAGE> is not specified then the message must be sent using the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   820
C<datasend> and C<dataend> methods from L<Net::Cmd>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   821
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   822
C<MESSAGE> can be either an array of lines or a reference to an array.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   823
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   824
=item last ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   825
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   826
Set the "current article pointer" to the previous article in the current
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   827
newsgroup.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   828
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   829
Returns the message-id of the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   830
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   831
=item date ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   832
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   833
Returns the date on the remote server. This date will be in a UNIX time
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   834
format (seconds since 1970)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   835
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   836
=item postok ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   837
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   838
C<postok> will return I<true> if the servers initial response indicated
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   839
that it will allow posting.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   840
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   841
=item authinfo ( USER, PASS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   842
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   843
=item list ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   844
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   845
Obtain information about all the active newsgroups. The results is a reference
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   846
to a hash where the key is a group name and each value is a reference to an
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   847
array. The elements in this array are:- the last article number in the group,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   848
the first article number in the group and any information flags about the group.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   849
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   850
=item newgroups ( SINCE [, DISTRIBUTIONS ])
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   851
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   852
C<SINCE> is a time value and C<DISTRIBUTIONS> is either a distribution
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   853
pattern or a reference to a list of distribution patterns.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   854
The result is the same as C<list>, but the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   855
groups return will be limited to those created after C<SINCE> and, if
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   856
specified, in one of the distribution areas in C<DISTRIBUTIONS>. 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   857
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   858
=item newnews ( SINCE [, GROUPS [, DISTRIBUTIONS ]])
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   859
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   860
C<SINCE> is a time value. C<GROUPS> is either a group pattern or a reference
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   861
to a list of group patterns. C<DISTRIBUTIONS> is either a distribution
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   862
pattern or a reference to a list of distribution patterns.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   863
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   864
Returns a reference to a list which contains the message-ids of all news posted
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   865
after C<SINCE>, that are in a groups which matched C<GROUPS> and a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   866
distribution which matches C<DISTRIBUTIONS>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   867
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   868
=item next ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   869
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   870
Set the "current article pointer" to the next article in the current
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   871
newsgroup.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   872
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   873
Returns the message-id of the article.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   874
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   875
=item post ( [ MESSAGE ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   876
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   877
Post a new article to the news server. If C<MESSAGE> is specified and posting
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   878
is allowed then the message will be sent.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   879
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   880
If C<MESSAGE> is not specified then the message must be sent using the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   881
C<datasend> and C<dataend> methods from L<Net::Cmd>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   882
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   883
C<MESSAGE> can be either an array of lines or a reference to an array.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   884
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   885
The message, either sent via C<datasend> or as the C<MESSAGE>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   886
parameter, must be in the format as described by RFC822 and must
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   887
contain From:, Newsgroups: and Subject: headers.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   888
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   889
=item postfh ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   890
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   891
Post a new article to the news server using a tied filehandle.  If
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   892
posting is allowed, this method will return a tied filehandle that you
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   893
can print() the contents of the article to be posted.  You must
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   894
explicitly close() the filehandle when you are finished posting the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   895
article, and the return value from the close() call will indicate
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   896
whether the message was successfully posted.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   897
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   898
=item slave ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   899
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   900
Tell the remote server that I am not a user client, but probably another
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   901
news server.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   902
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   903
=item quit ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   904
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   905
Quit the remote server and close the socket connection.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   906
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   907
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   908
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   909
=head2 Extension methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   910
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   911
These methods use commands that are not part of the RFC977 documentation. Some
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   912
servers may not support all of them.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   913
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   914
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   915
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   916
=item newsgroups ( [ PATTERN ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   917
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   918
Returns a reference to a hash where the keys are all the group names which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   919
match C<PATTERN>, or all of the groups if no pattern is specified, and
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   920
each value contains the description text for the group.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   921
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   922
=item distributions ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   923
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   924
Returns a reference to a hash where the keys are all the possible
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   925
distribution names and the values are the distribution descriptions.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   926
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   927
=item subscriptions ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   928
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   929
Returns a reference to a list which contains a list of groups which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   930
are recommended for a new user to subscribe to.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   931
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   932
=item overview_fmt ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   933
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   934
Returns a reference to an array which contain the names of the fields returned
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   935
by C<xover>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   936
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   937
=item active_times ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   938
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   939
Returns a reference to a hash where the keys are the group names and each
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   940
value is a reference to an array containing the time the groups was created
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   941
and an identifier, possibly an Email address, of the creator.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   942
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   943
=item active ( [ PATTERN ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   944
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   945
Similar to C<list> but only active groups that match the pattern are returned.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   946
C<PATTERN> can be a group pattern.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   947
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   948
=item xgtitle ( PATTERN )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   949
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   950
Returns a reference to a hash where the keys are all the group names which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   951
match C<PATTERN> and each value is the description text for the group.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   952
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   953
=item xhdr ( HEADER, MESSAGE-SPEC )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   954
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   955
Obtain the header field C<HEADER> for all the messages specified. 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   956
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   957
The return value will be a reference
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   958
to a hash where the keys are the message numbers and each value contains
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   959
the text of the requested header for that message.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   960
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   961
=item xover ( MESSAGE-SPEC )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   962
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   963
The return value will be a reference
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   964
to a hash where the keys are the message numbers and each value contains
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   965
a reference to an array which contains the overview fields for that
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   966
message.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   967
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   968
The names of the fields can be obtained by calling C<overview_fmt>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   969
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   970
=item xpath ( MESSAGE-ID )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   971
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   972
Returns the path name to the file on the server which contains the specified
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   973
message.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   974
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   975
=item xpat ( HEADER, PATTERN, MESSAGE-SPEC)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   976
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   977
The result is the same as C<xhdr> except the is will be restricted to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   978
headers where the text of the header matches C<PATTERN>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   979
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   980
=item xrover
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   981
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   982
The XROVER command returns reference information for the article(s)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   983
specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   984
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   985
Returns a reference to a HASH where the keys are the message numbers and the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   986
values are the References: lines from the articles
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   987
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   988
=item listgroup ( [ GROUP ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   989
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   990
Returns a reference to a list of all the active messages in C<GROUP>, or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   991
the current group if C<GROUP> is not specified.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   992
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   993
=item reader
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   994
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   995
Tell the server that you are a reader and not another server.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   996
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   997
This is required by some servers. For example if you are connecting to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   998
an INN server and you have transfer permission your connection will
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   999
be connected to the transfer daemon, not the NNTP daemon. Issuing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1000
this command will cause the transfer daemon to hand over control
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1001
to the NNTP daemon.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1002
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1003
Some servers do not understand this command, but issuing it and ignoring
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1004
the response is harmless.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1005
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1006
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1007
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1008
=head1 UNSUPPORTED
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1009
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1010
The following NNTP command are unsupported by the package, and there are
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1011
no plans to do so.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1012
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1013
    AUTHINFO GENERIC
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1014
    XTHREAD
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1015
    XSEARCH
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1016
    XINDEX
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1017
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1018
=head1 DEFINITIONS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1019
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1020
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1021
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1022
=item MESSAGE-SPEC
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1023
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1024
C<MESSAGE-SPEC> is either a single message-id, a single message number, or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1025
a reference to a list of two message numbers.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1026
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1027
If C<MESSAGE-SPEC> is a reference to a list of two message numbers and the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1028
second number in a range is less than or equal to the first then the range
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1029
represents all messages in the group after the first message number.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1030
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1031
B<NOTE> For compatibility reasons only with earlier versions of Net::NNTP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1032
a message spec can be passed as a list of two numbers, this is deprecated
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1033
and a reference to the list should now be passed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1034
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1035
=item PATTERN
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1036
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1037
The C<NNTP> protocol uses the C<WILDMAT> format for patterns.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1038
The WILDMAT format was first developed by Rich Salz based on
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1039
the format used in the UNIX "find" command to articulate
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1040
file names. It was developed to provide a uniform mechanism
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1041
for matching patterns in the same manner that the UNIX shell
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1042
matches filenames.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1043
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1044
Patterns are implicitly anchored at the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1045
beginning and end of each string when testing for a match.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1046
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1047
There are five pattern matching operations other than a strict
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1048
one-to-one match between the pattern and the source to be
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1049
checked for a match.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1050
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1051
The first is an asterisk C<*> to match any sequence of zero or more
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1052
characters.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1053
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1054
The second is a question mark C<?> to match any single character. The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1055
third specifies a specific set of characters.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1056
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1057
The set is specified as a list of characters, or as a range of characters
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1058
where the beginning and end of the range are separated by a minus (or dash)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1059
character, or as any combination of lists and ranges. The dash can
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1060
also be included in the set as a character it if is the beginning
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1061
or end of the set. This set is enclosed in square brackets. The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1062
close square bracket C<]> may be used in a set if it is the first
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1063
character in the set.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1064
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1065
The fourth operation is the same as the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1066
logical not of the third operation and is specified the same
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1067
way as the third with the addition of a caret character C<^> at
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1068
the beginning of the test string just inside the open square
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1069
bracket.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1070
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1071
The final operation uses the backslash character to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1072
invalidate the special meaning of an open square bracket C<[>,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1073
the asterisk, backslash or the question mark. Two backslashes in
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1074
sequence will result in the evaluation of the backslash as a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1075
character with no special meaning.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1076
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1077
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1078
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1079
=item Examples
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1080
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1081
=item C<[^]-]>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1082
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1083
matches any single character other than a close square
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1084
bracket or a minus sign/dash.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1085
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1086
=item C<*bdc>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1087
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1088
matches any string that ends with the string "bdc"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1089
including the string "bdc" (without quotes).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1090
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1091
=item C<[0-9a-zA-Z]>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1092
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1093
matches any single printable alphanumeric ASCII character.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1094
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1095
=item C<a??d>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1096
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1097
matches any four character string which begins
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1098
with a and ends with d.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1099
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1100
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1102
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1104
=head1 SEE ALSO
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1106
L<Net::Cmd>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1108
=head1 AUTHOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1110
Graham Barr <gbarr@pobox.com>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1112
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1114
Copyright (c) 1995-1997 Graham Barr. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1115
This program is free software; you can redistribute it and/or modify
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1116
it under the same terms as Perl itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1118
=for html <hr>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1120
I<$Id: //depot/libnet/Net/NNTP.pm#18 $>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1122
=cut