summaryrefslogtreecommitdiff
path: root/lib/Net/FTP
diff options
context:
space:
mode:
authorChris Williams <chris@bingosnet.co.uk>2009-09-08 13:25:04 +0100
committerChris Williams <chris@bingosnet.co.uk>2009-09-08 13:25:04 +0100
commitcb82353cb54730fb7ae6fdbe92841cc51a6af7a8 (patch)
tree25c3d58cea955a177fd7f04daf10a34bb784094c /lib/Net/FTP
parent087f1bf3a29bd837d3103a3637ea69e4499ca06b (diff)
downloadperl-cb82353cb54730fb7ae6fdbe92841cc51a6af7a8.tar.gz
Moved libnet from lib/ to ext/
Diffstat (limited to 'lib/Net/FTP')
-rw-r--r--lib/Net/FTP/A.pm111
-rw-r--r--lib/Net/FTP/E.pm8
-rw-r--r--lib/Net/FTP/I.pm80
-rw-r--r--lib/Net/FTP/L.pm8
-rw-r--r--lib/Net/FTP/dataconn.pm124
5 files changed, 0 insertions, 331 deletions
diff --git a/lib/Net/FTP/A.pm b/lib/Net/FTP/A.pm
deleted file mode 100644
index 427d02b19e..0000000000
--- a/lib/Net/FTP/A.pm
+++ /dev/null
@@ -1,111 +0,0 @@
-##
-## Package to read/write on ASCII data connections
-##
-
-package Net::FTP::A;
-use strict;
-use vars qw(@ISA $buf $VERSION);
-use Carp;
-
-require Net::FTP::dataconn;
-
-@ISA = qw(Net::FTP::dataconn);
-$VERSION = "1.18";
-
-
-sub read {
- my $data = shift;
- local *buf = \$_[0];
- shift;
- my $size = shift || croak 'read($buf,$size,[$offset])';
- my $timeout = @_ ? shift: $data->timeout;
-
- if (length(${*$data}) < $size && !${*$data}{'net_ftp_eof'}) {
- my $blksize = ${*$data}{'net_ftp_blksize'};
- $blksize = $size if $size > $blksize;
-
- my $l = 0;
- my $n;
-
- READ:
- {
- my $readbuf = defined(${*$data}{'net_ftp_cr'}) ? "\015" : '';
-
- $data->can_read($timeout)
- or croak "Timeout";
-
- if ($n = sysread($data, $readbuf, $blksize, length $readbuf)) {
- ${*$data}{'net_ftp_bytesread'} += $n;
- ${*$data}{'net_ftp_cr'} =
- substr($readbuf, -1) eq "\015"
- ? chop($readbuf)
- : undef;
- }
- else {
- return undef
- unless defined $n;
-
- ${*$data}{'net_ftp_eof'} = 1;
- }
-
- $readbuf =~ s/\015\012/\n/sgo;
- ${*$data} .= $readbuf;
-
- unless (length(${*$data})) {
-
- redo READ
- if ($n > 0);
-
- $size = length(${*$data})
- if ($n == 0);
- }
- }
- }
-
- $buf = substr(${*$data}, 0, $size);
- substr(${*$data}, 0, $size) = '';
-
- length $buf;
-}
-
-
-sub write {
- my $data = shift;
- local *buf = \$_[0];
- shift;
- my $size = shift || croak 'write($buf,$size,[$timeout])';
- my $timeout = @_ ? shift: $data->timeout;
-
- my $nr = (my $tmp = substr($buf, 0, $size)) =~ tr/\r\n/\015\012/;
- $tmp =~ s/([^\015])\012/$1\015\012/sg if $nr;
- $tmp =~ s/^\012/\015\012/ unless ${*$data}{'net_ftp_outcr'};
- ${*$data}{'net_ftp_outcr'} = substr($tmp, -1) eq "\015";
-
- # If the remote server has closed the connection we will be signal'd
- # when we write. This can happen if the disk on the remote server fills up
-
- local $SIG{PIPE} = 'IGNORE'
- unless ($SIG{PIPE} || '') eq 'IGNORE'
- or $^O eq 'MacOS';
-
- my $len = length($tmp);
- my $off = 0;
- my $wrote = 0;
-
- my $blksize = ${*$data}{'net_ftp_blksize'};
-
- while ($len) {
- $data->can_write($timeout)
- or croak "Timeout";
-
- $off += $wrote;
- $wrote = syswrite($data, substr($tmp, $off), $len > $blksize ? $blksize : $len);
- return undef
- unless defined($wrote);
- $len -= $wrote;
- }
-
- $size;
-}
-
-1;
diff --git a/lib/Net/FTP/E.pm b/lib/Net/FTP/E.pm
deleted file mode 100644
index d480cd7295..0000000000
--- a/lib/Net/FTP/E.pm
+++ /dev/null
@@ -1,8 +0,0 @@
-package Net::FTP::E;
-
-require Net::FTP::I;
-
-@ISA = qw(Net::FTP::I);
-$VERSION = "0.01";
-
-1;
diff --git a/lib/Net/FTP/I.pm b/lib/Net/FTP/I.pm
deleted file mode 100644
index 449bb99eab..0000000000
--- a/lib/Net/FTP/I.pm
+++ /dev/null
@@ -1,80 +0,0 @@
-##
-## Package to read/write on BINARY data connections
-##
-
-package Net::FTP::I;
-
-use vars qw(@ISA $buf $VERSION);
-use Carp;
-
-require Net::FTP::dataconn;
-
-@ISA = qw(Net::FTP::dataconn);
-$VERSION = "1.12";
-
-
-sub read {
- my $data = shift;
- local *buf = \$_[0];
- shift;
- my $size = shift || croak 'read($buf,$size,[$timeout])';
- my $timeout = @_ ? shift: $data->timeout;
-
- my $n;
-
- if ($size > length ${*$data} and !${*$data}{'net_ftp_eof'}) {
- $data->can_read($timeout)
- or croak "Timeout";
-
- my $blksize = ${*$data}{'net_ftp_blksize'};
- $blksize = $size if $size > $blksize;
-
- unless ($n = sysread($data, ${*$data}, $blksize, length ${*$data})) {
- return undef unless defined $n;
- ${*$data}{'net_ftp_eof'} = 1;
- }
- }
-
- $buf = substr(${*$data}, 0, $size);
-
- $n = length($buf);
-
- substr(${*$data}, 0, $n) = '';
-
- ${*$data}{'net_ftp_bytesread'} += $n;
-
- $n;
-}
-
-
-sub write {
- my $data = shift;
- local *buf = \$_[0];
- shift;
- my $size = shift || croak 'write($buf,$size,[$timeout])';
- my $timeout = @_ ? shift: $data->timeout;
-
- # If the remote server has closed the connection we will be signal'd
- # when we write. This can happen if the disk on the remote server fills up
-
- local $SIG{PIPE} = 'IGNORE'
- unless ($SIG{PIPE} || '') eq 'IGNORE'
- or $^O eq 'MacOS';
- my $sent = $size;
- my $off = 0;
-
- my $blksize = ${*$data}{'net_ftp_blksize'};
- while ($sent > 0) {
- $data->can_write($timeout)
- or croak "Timeout";
-
- my $n = syswrite($data, $buf, $sent > $blksize ? $blksize : $sent, $off);
- return undef unless defined($n);
- $sent -= $n;
- $off += $n;
- }
-
- $size;
-}
-
-1;
diff --git a/lib/Net/FTP/L.pm b/lib/Net/FTP/L.pm
deleted file mode 100644
index f7423cb9f9..0000000000
--- a/lib/Net/FTP/L.pm
+++ /dev/null
@@ -1,8 +0,0 @@
-package Net::FTP::L;
-
-require Net::FTP::I;
-
-@ISA = qw(Net::FTP::I);
-$VERSION = "0.01";
-
-1;
diff --git a/lib/Net/FTP/dataconn.pm b/lib/Net/FTP/dataconn.pm
deleted file mode 100644
index e7645cbd93..0000000000
--- a/lib/Net/FTP/dataconn.pm
+++ /dev/null
@@ -1,124 +0,0 @@
-##
-## Generic data connection package
-##
-
-package Net::FTP::dataconn;
-
-use Carp;
-use vars qw(@ISA $timeout $VERSION);
-use Net::Cmd;
-use Errno;
-
-$VERSION = '0.11';
-@ISA = qw(IO::Socket::INET);
-
-
-sub reading {
- my $data = shift;
- ${*$data}{'net_ftp_bytesread'} = 0;
-}
-
-
-sub abort {
- my $data = shift;
- my $ftp = ${*$data}{'net_ftp_cmd'};
-
- # no need to abort if we have finished the xfer
- return $data->close
- if ${*$data}{'net_ftp_eof'};
-
- # for some reason if we continously open RETR connections and not
- # read a single byte, then abort them after a while the server will
- # close our connection, this prevents the unexpected EOF on the
- # command channel -- GMB
- if (exists ${*$data}{'net_ftp_bytesread'}
- && (${*$data}{'net_ftp_bytesread'} == 0))
- {
- my $buf = "";
- my $timeout = $data->timeout;
- $data->can_read($timeout) && sysread($data, $buf, 1);
- }
-
- ${*$data}{'net_ftp_eof'} = 1; # fake
-
- $ftp->abort; # this will close me
-}
-
-
-sub _close {
- my $data = shift;
- my $ftp = ${*$data}{'net_ftp_cmd'};
-
- $data->SUPER::close();
-
- delete ${*$ftp}{'net_ftp_dataconn'}
- if exists ${*$ftp}{'net_ftp_dataconn'}
- && $data == ${*$ftp}{'net_ftp_dataconn'};
-}
-
-
-sub close {
- my $data = shift;
- my $ftp = ${*$data}{'net_ftp_cmd'};
-
- if (exists ${*$data}{'net_ftp_bytesread'} && !${*$data}{'net_ftp_eof'}) {
- my $junk;
- $data->read($junk, 1, 0);
- return $data->abort unless ${*$data}{'net_ftp_eof'};
- }
-
- $data->_close;
-
- $ftp->response() == CMD_OK
- && $ftp->message =~ /unique file name:\s*(\S*)\s*\)/
- && (${*$ftp}{'net_ftp_unique'} = $1);
-
- $ftp->status == CMD_OK;
-}
-
-
-sub _select {
- my ($data, $timeout, $do_read) = @_;
- my ($rin, $rout, $win, $wout, $tout, $nfound);
-
- vec($rin = '', fileno($data), 1) = 1;
-
- ($win, $rin) = ($rin, $win) unless $do_read;
-
- while (1) {
- $nfound = select($rout = $rin, $wout = $win, undef, $tout = $timeout);
-
- last if $nfound >= 0;
-
- croak "select: $!"
- unless $!{EINTR};
- }
-
- $nfound;
-}
-
-
-sub can_read {
- _select(@_[0, 1], 1);
-}
-
-
-sub can_write {
- _select(@_[0, 1], 0);
-}
-
-
-sub cmd {
- my $ftp = shift;
-
- ${*$ftp}{'net_ftp_cmd'};
-}
-
-
-sub bytes_read {
- my $ftp = shift;
-
- ${*$ftp}{'net_ftp_bytesread'} || 0;
-}
-
-1;