~ubuntu-branches/ubuntu/precise/libnet-sftp-foreign-perl/precise

« back to all changes in this revision

Viewing changes to lib/Net/SFTP/Foreign/Common.pm

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2008-06-18 18:55:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080618185525-bnfip6qbklllevj6
Tags: 1.38+dfsg-1
* New upstream release.
* Set Standards-Version to 3.8.0; rename debian/README.Debian-source to
  debian/README.source; fix a typo in debian/README.source.
* Switch from cdbs to debhelper 7; don't install README any more; install
  samples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package Net::SFTP::Foreign::Common;
2
2
 
3
 
our $VERSION = '1.31';
 
3
our $VERSION = '1.37';
4
4
 
5
5
use strict;
6
6
use warnings;
8
8
use Scalar::Util qw(dualvar tainted);
9
9
use Fcntl qw(S_ISLNK S_ISDIR);
10
10
 
11
 
use Net::SFTP::Foreign::Helpers qw(_gen_wanted _ensure_list);
 
11
use Net::SFTP::Foreign::Helpers qw(_gen_wanted _ensure_list _debug);
12
12
use Net::SFTP::Foreign::Constants qw(:status);
13
13
 
14
14
my %status_str = ( SSH2_FX_OK, "OK",
21
21
                   SSH2_FX_CONNECTION_LOST, "Connection lost",
22
22
                   SSH2_FX_OP_UNSUPPORTED, "Operation unsupported" );
23
23
 
 
24
*debug = \$Net::SFTP::Foreign::debug;
 
25
our $debug;
 
26
 
24
27
sub _set_status {
25
28
    my $sftp = shift;
26
29
    my $code = shift;
34
37
        unless (defined $str and length $str) {
35
38
            $str = $status_str{$code} || "Unknown status ($code)";
36
39
        }
 
40
        $debug and $debug & 64 and _debug("_set_status code: $code, str: $str");
37
41
        return $sftp->{_status} = dualvar($code, $str);
38
42
    }
39
43
    else {
56
60
        else {
57
61
            $str = $code ? "Unknown error $code" : "OK";
58
62
        }
 
63
        $debug and $debug & 64 and _debug("_set_err code: $code, str: $str");
59
64
        return $sftp->{_error} = dualvar $code, $str;
60
65
    }
61
66
    else {
87
92
            $! = Errno::EBADMSG();
88
93
        }
89
94
        elsif ($status == SSH2_FX_OP_UNSUPPORTED) {
90
 
            $! = Errnor::ENOTSUP()
 
95
            $! = Errno::ENOTSUP()
91
96
        }
92
97
        elsif ($status) {
93
 
            $! = Errnor::EIO()
 
98
            $! = Errno::EIO()
94
99
        }
95
100
    }
96
101
}