|<\/u>//g;
$rv =~ s/|<\/pre>//g;
$rv =~ s/
/\n/g;
$rv =~ s//\n\n/g;
return $rv;
}
sub open_ftp_file
{
local ($mode) = @_;
# Open passive port
local $pasv = &ftp_command("PASV", 2, \$err);
$pasv || &error_exit("FTP port failed : $err");
$pasv =~ /\(([0-9,]+)\)/;
local @n = split(/,/ , $1);
&open_socket("$n[0].$n[1].$n[2].$n[3]", $n[4]*256 + $n[5],
CON, \$err) ||
&error_exit("FTP port failed : $err");
if ($mode == 0) {
# Read from file
&ftp_command("RETR $file", 1, \$err) ||
&error_exit("FTP read failed : $err");
$opened = 2;
}
elsif ($mode == 1) {
# Create new file if requested by the client, or if
# the touch command was specified by the caller
&ftp_command("STOR $file", 1, \$err) ||
&error_exit("FTP write failed : $err");
$touched = 0;
$opened = 1;
}
elsif ($mode == 2) {
# Otherwise append to the file
&ftp_command("APPE $file", 1, \$err) ||
&error_exit("FTP write failed : $err");
$opened = 1;
}
else {
$opened = 0;
}
}