Leser: 1
7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
sub _toporretr
{
my($self, %args) = @_;
my $msgidx = $args{MSGID} || 1;
my $lines = $args{LINES} || 0;
my $cmd = $args{CMD};
my $fh = $args{FH};
my $nohead = $args{NOHEAD};
$lines =~ /\d+/ or $lines = 0;
if($cmd eq POP3CMD_TOP) { $self->print(POP3CMD_TOP." $msgidx $lines", $self->eol()); }
else { $self->print(POP3CMD_RETR." $msgidx", $self->eol()); }
my $line = $self->getline();
chomp $line;
my $buflen = 0;
$line =~ /^\+OK/ or $self->message("Bad return from $cmd: $line") and return;
$line =~ /^\+OK (\d+) / and $buflen = $1;
my $retval = '';
while(defined($line = $self->getline()))
{
unless($nohead)
{
$line =~ /^\.\s*$/ and last;
$line =~ s/^\.\././;
$fh ? (print $fh $line) : ($retval .= $line);
}
$nohead and $line =~ /^\s*$/ and $nohead = 0;
}
return $fh ? 1 : wantarray ? split(/\r?\n/, $retval) : $retval;
}
sub header
{
my($self, $msgid, $lines, $fh) = @_;
return $self->_toporretr(CMD => POP3CMD_TOP, MSGID => $msgid, LINES => $lines, FH => $fh);
}
sub header_body
{
my($self, $msgid, $fh) = @_;
return $self->_toporretr(CMD => POP3CMD_RETR, MSGID => $msgid, FH => $fh);
}
sub body
{
my($self, $msgid, $fh) = @_;
return $self->_toporretr(CMD => POP3CMD_RETR, MSGID => $msgid, FH => $fh, NOHEAD => 1);
}
1
2
3
4
5
6
7
8
9
10
sub _write2file {
my($self, %args) = @_;
my $content = $args{CONTENT};
my $fh = $args{FH};
print FH $content or return;
return 1;
}
1
2
3
4
5
6
7
8
9
sub foo {
# ...
my $content = $self->header($msgid, $lines);
$self->_write2file(CONTENT => $content,
FH => $fh);
# ...
}
1
2
3
4
5
6
7
unless($nohead)
{
$line =~ /^\.\s*$/ and last;
$line =~ s/^\.\././;
$fh ? (print $fh $line) : ($retval .= $line);
}
$nohead and $line =~ /^\s*$/ and $nohead = 0;
1
2
3
4
5
6
7
8
9
10
if ($nohead) {
last if $line =~ /^\.\s*$/;
$line =~ s/^\.\././;
$fh ? (print $fh $line)
: ($retval .= $line);
}
else {
$line =~ /^\s*$/;
$nohead = 0;
}
1
2
3
4
5
6
7
sub _toporretr {
my(%defaultargs) = (MSGID => 1,
LINES => 0);
my($self)= shift;
my(%args) = (%defaultargs, @_);
$self->print(POP3CMD_TOP." $msgidx $lines", $self->eol());
7 Einträge, 1 Seite |