Skip to content

Commit

Permalink
ftpserver.pl: Added support for POP3 TOP command
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-caveman2k committed Sep 9, 2013
1 parent ae60964 commit 313c38c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/ftpserver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ sub protocolsetup {
'QUIT' => \&QUIT_pop3,
'RETR' => \&RETR_pop3,
'STAT' => \&STAT_pop3,
'TOP' => \&TOP_pop3,
'UIDL' => \&UIDL_pop3,
);
%displaytext = (
Expand Down Expand Up @@ -1400,6 +1401,52 @@ sub UIDL_pop3 {
return 0;
}

sub TOP_pop3 {
my ($args) = @_;
my ($msg, $lines) = split(/ /, $args, 2);

logmsg "TOP_pop3 got $args\n";

if (($msg eq "") || ($lines eq "")) {
sendcontrol "-ERR Protocol error\r\n";
}
else {
my @data;

if ($lines == "0") {
logmsg "retrieve header of mail\n";
}
else {
logmsg "retrieve top $lines lines of mail\n";
}

my $testno = $msg;
$testno =~ s/^([^0-9]*)//;
my $testpart = "";
if ($testno > 10000) {
$testpart = $testno % 10000;
$testno = int($testno / 10000);
}

loadtest("$srcdir/data/test$testno");

@data = getpart("reply", "data$testpart");

sendcontrol "+OK Mail transfer starts\r\n";

# Send mail content
for my $d (@data) {
sendcontrol $d;
}

# End with the magic 3-byte end of mail marker, assumes that the
# mail body ends with a CRLF!
sendcontrol ".\r\n";
}

return 0;
}

sub QUIT_pop3 {
sendcontrol "+OK byebye\r\n";

Expand Down

0 comments on commit 313c38c

Please sign in to comment.