Net-SSH2-0.69/0000755000175000017500000000000013244346650011720 5ustar salvasalvaNet-SSH2-0.69/lib/0000755000175000017500000000000013244346650012466 5ustar salvasalvaNet-SSH2-0.69/lib/Net/0000755000175000017500000000000013244346650013214 5ustar salvasalvaNet-SSH2-0.69/lib/Net/SSH2/0000755000175000017500000000000013244346650013733 5ustar salvasalvaNet-SSH2-0.69/lib/Net/SSH2/Channel.pm0000644000175000017500000003647213210471521015642 0ustar salvasalvapackage Net::SSH2::Channel; use strict; use warnings; use Carp; # methods sub shell { $_[0]->process('shell') } sub exec { $_[0]->process(exec => $_[1]) } sub subsystem { $_[0]->process(subsystem => $_[1]) } sub error { shift->session->error(@_) } sub blocking { shift->session->blocking(@_) } sub setenv { my ($self, %env) = @_; my $rc = 1; while (my ($k, $v) = each %env) { $self->_setenv($k, $v) or undef $rc; } $rc } sub read1 { my $self = shift; my $buffer; my $rc = $self->read($buffer, @_); return (defined $rc ? $buffer : undef); } sub read2 { my ($self, $max_size) = @_; $max_size = 32678 unless defined $max_size; my $ssh2 = $self->session; my $old_blocking = $ssh2->blocking; my $timeout = $ssh2->timeout; my $delay = (($timeout and $timeout < 2000) ? 0.0005 * $timeout : 1); my $deadline; $deadline = time + 1 + 0.001 * $timeout if $timeout; $ssh2->blocking(0); while (1) { my @out; my $bytes; my $fail; my $zero; for (0, 1) { my $rc = $self->read($out[$_], $max_size, $_); if (defined $rc) { $rc or $zero++; $bytes += $rc; $deadline = time + 1 + 0.001 * $timeout if $timeout; } else { $out[$_] = ''; if ($ssh2->error != Net::SSH2::LIBSSH2_ERROR_EAGAIN()) { $fail++; last; } } } if ($bytes) { $ssh2->blocking($old_blocking); return (wantarray ? @out : $out[0]) } my $eof = $self->eof; if ($fail or $eof) { $ssh2->_set_error if $eof; $ssh2->blocking($old_blocking); return; } unless ($zero) { return unless $old_blocking; if ($deadline and time > $deadline) { $ssh2->_set_error(Net::SSH2::LIBSSH2_ERROR_TIMEOUT(), "Time out waiting for data"); return; } return if $deadline and time > $deadline; my $sock = $ssh2->sock; my $fn = fileno($sock); my ($rbm, $wbm) = ('', ''); my $bd = $ssh2->block_directions; vec($rbm, $fn, 1) = 1 if $bd & Net::SSH2::LIBSSH2_SESSION_BLOCK_INBOUND(); vec($wbm, $fn, 1) = 1 if $bd & Net::SSH2::LIBSSH2_SESSION_BLOCK_OUTBOUND(); select $rbm, $wbm, undef, $delay; } } } my $readline_non_blocking_warned; sub readline { my ($self, $ext, $eol) = @_; return if $self->eof; $ext ||= 0; $eol = $/ unless @_ >= 3; $self->blocking or $readline_non_blocking_warned++ or warnings::warnif('Net::SSH2', "Calling Net::SSH2::Channel::readline in non-blocking mode is usually a programming error"); if (wantarray or not defined $eol) { my $data = ''; my $buffer; while (1) { my $bytes = $self->read($buffer, 32768, $ext); last unless defined $bytes; if (!$bytes and $self->eof) { $self->session->_set_error(Net::SSH2::LIBSSH2_ERROR_NONE()); last; } $data .= $buffer; } defined $eol and return split /(?<=\Q$eol\E)/s, $data; wantarray and not length $data and return (); return $data; } else { my $c; my $data = ''; while (1) { $c = $self->getc($ext); last unless defined $c; $data .= $c; if ( (!length($c) and $self->eof) or $data =~ /\Q$eol\E\z/) { $self->session->_set_error(Net::SSH2::LIBSSH2_ERROR_NONE()); last; } } return (length $data ? $data : undef); } } sub wait_closed { my $self = shift; if ($self->wait_eof) { $self->flush('all'); return $self->_wait_closed; } undef; } sub exit_status { my $self = shift; return unless $self->wait_closed; return $self->_exit_status; } sub exit_signal { my $self = shift; return unless $self->wait_closed; return $self->_exit_signal; } my %signal_number; sub exit_signal_number { my $self = shift; my $signal = $self->exit_signal; return unless defined $signal; return 0 unless $signal; unless (%signal_number) { require Config; my @names = split /\s+/, $Config::Config{sig_name}; @signal_number{@names} = 0..$#names; } $signal =~ s/\@\.[^\.]+\.config\.guess$//; my $number = $signal_number{$signal}; $number = 255 unless defined $number; return $number; } my %pty_modes = (TTY_OP_END => 0, VINTR => 1, VQUIT => 2, VERASE => 3, VKILL => 4, VEOF => 5, VEOL => 6, VEOL2 => 7, VSTART => 8, VSTOP => 9, VSUSP => 10, VDSUSP => 11, VREPRINT => 12, VWERASE => 13, VLNEXT => 14, VFLUSH => 15, VSWTCH => 16, VSTATUS => 17, VDISCARD => 18, IGNPAR => 30, PARMRK => 31, INPCK => 32, ISTRIP => 33, INLCR => 34, IGNCR => 35, ICRNL => 36, IUCLC => 37, IXON => 38, IXANY => 39, IXOFF => 40, IMAXBEL => 41, ISIG => 50, ICANON => 51, XCASE => 52, ECHO => 53, ECHOE => 54, ECHOK => 55, ECHONL => 56, NOFLSH => 57, TOSTOP => 58, IEXTEN => 59, ECHOCTL => 60, ECHOKE => 61, PENDIN => 62, OPOST => 70, OLCUC => 71, ONLCR => 72, OCRNL => 73, ONOCR => 74, ONLRET => 75, CS7 => 90, CS8 => 91, PARENB => 92, PARODD => 93, TTY_OP_ISPEED => 128, TTY_OP_OSPEED => 129); sub pty { my $self = shift; if (defined $_[1] and ref $_[1] eq 'HASH') { my $term = shift; my $modes = shift; my $packed = ''; while (my ($k, $v) = each %$modes) { unless ($k =~ /^\d+$/) { my $k1 = $pty_modes{uc $k}; defined $k1 or croak "Invalid pty mode key '$k'"; $k = $k1; } next if $k == 0; # ignore the TTY_OP_END marker $k > 159 and croak "Invalid pty mode key '$k'"; $packed .= pack CN => $k, $v; } $self->_pty($term, "$packed\x00", @_); } else { $self->_pty(@_); } } # tie interface sub PRINT { my $self = shift; my $sep = defined($,) ? $, : ''; $self->write(join $sep, @_) } sub PRINTF { my $self = shift; my $template = shift; $self->write(sprintf $template, @_); } sub WRITE { my ($self, $buf, $len, $offset) = @_; $self->write(substr($buf, $offset || 0, $len)) } sub READLINE { shift->readline(0, $/) } sub READ { my ($self, undef, $len, $offset) = @_; my $bytes = $self->read(my($buffer), $len); substr($_[1], $offset || 0) = $buffer if defined $bytes; return $bytes; } sub BINMODE { 1 } sub CLOSE { my $self = shift; my $ob = $self->blocking; $self->blocking(1); my $rc = undef; if ($self->close and $self->wait_closed) { my $status = $self->exit_status; my $signal = $self->exit_signal_number; $self->session->_set_error; $? = ($status << 8) | $signal; $rc = 1 if $? == 0; } $self->blocking($ob); $rc; } sub EOF { my $self = shift; $self->eof; } *GETC = \&getc; 1; __END__ =head1 NAME Net::SSH2::Channel - SSH2 channel object =head1 SYNOPSIS my $chan = $ssh2->channel() or $ssh2->die_with_error; $chan->exec("ls -ld /usr/local/libssh2*") or $ssh2->die_with_error; $chan->send_eof; while (<$chan>) { print "line read: $_"; } print "exit status: " . $chan->exit_status . "\n"; =head1 DESCRIPTION A channel object is created by the L C method. As well as being an object, it is also a tied filehandle. =head2 setenv ( key, value ... ) Sets remote environment variables. Note that most servers do not allow environment variables to be freely set. Pass in a list of keys and values with the values to set. It returns a true value if all the given environment variables were correctly set. =head2 blocking ( flag ) Enable or disable blocking. Note that this is currently implemented in libssh2 by setting a per-session flag. It's equivalent to L. =head2 eof Returns true if the remote server sent an EOF. =head2 send_eof Sends an EOF to the remote side. After an EOF has been sent, no more data may be sent to the remote process C channel. Note that if a PTY was requested for the channel, the EOF may be ignored by the remote server. See L. =head2 close Close the channel (happens automatically on object destruction). =head2 wait_closed Wait for a remote close event. In order to avoid a bug in libssh2 this method discards any unread data queued in the channel. =head2 exit_status Returns the channel's program exit status. This method blocks until the remote side closes the channel. =head2 pty ( terminal [, modes [, width [, height ]]] ) Request a terminal on a channel. C is the type of emulation (e.g. vt102, ansi, etc...). C are the terminal mode modifiers, for instance: $c->pty('vt100', { echo => 0, vintr => ord('k') }); The list of acceptable mode modifiers is available from the SSH Connection Protocol RFC (L). If provided, C and C are the width and height in characters (defaults to 80x24); if negative their absolute values specify width and height in pixels. =head2 pty_size ( width, height ) Request a terminal size change on a channel. C and C are the width and height in characters; if negative their absolute values specify width and height in pixels. =head2 ext_data ( mode ) Set extended data handling mode: =over 4 =item normal (default) Keep data in separate channels; C is read separately. =item ignore Ignore all extended data. =item merge Merge into the regular channel. =back =head2 process ( request, message ) Start a process on the channel. See also L, L, L. Note that only one invocation of C or any of the shortcuts C, C or C is allowed per channel. In order to run several commands, shells or/and subsystems, a new C instance must be used for every one. Alternatively, it is also possible to launch a remote shell (using L) and simulate the user interaction printing commands to its C stream and reading data back from its C and C. But this approach should be avoided if possible; talking to a shell is difficult and, in general, unreliable. =head2 shell Start a shell on the remote host (calls C). =head2 exec ( command ) Execute the command on the remote host (calls C). Note that the given command is parsed by the remote shell; it should be properly quoted, specially when passing data from untrusted sources. =head2 subsystem ( name ) Run subsystem on the remote host (calls C). =head2 read ( buffer, max_size [, ext ] ) Attempts to read up to C bytes from the channel into C. If C is true, reads from the extended data channel (C). The method returns as soon as some data is available, even if the given size has not been reached. Returns number of bytes read or C on failure. Note that 0 is a valid return code. =head2 read2 ( [max_size] ) Attempts to read from both the ordinary (stdout) and the extended (stderr) channel streams. Returns two scalars with the data read both from stdout and stderr. It returns as soon as some data is available and any of the returned values may be an empty string. When some error happens it returns the empty list. Example: my ($out, $err) = ('', ''); while (!$channel->eof) { if (my ($o, $e) = $channel->read2) { $out .= $o; $err .= $e; } else { $ssh2->die_with_error; } } print "STDOUT:\n$out\nSTDERR:\n$err\n"; =head2 readline ( [ext [, eol ] ] ) Reads the next line from the selected stream (C defaults to 0: stdout). C<$/> is used as the end of line marker when C is C. In list context reads and returns all the remaining lines until some read error happens or the remote side sends an eof. Note that this method is only safe when the complementary stream (e.g. C) is guaranteed to not generate data or when L has been used to discard or merge it; otherwise it may hang. This is a limitation of libssh2 that hopefully would be removed in a future release, in the meantime you are advised to use L instead. =head2 getc( [ext] ) Reads and returns the next character from the selected stream. Returns C on error. Note that due to some libssh2 quirks, the return value can be the empty string which may indicate an EOF condition (but not always!). See L. =head2 write ( buffer ) Send the data in C through the channel. Returns number of bytes written, undef on failure. In versions of this module prior to 0.57, when working in non-blocking mode, the would-block condition was signaled by returning C (a negative number) while leaving the session error status unset. From version 0.59, C is returned and the session error status is set to C as for any other error. In non-blocking mode, if C fails with a C error, no other operation must be invoked over any object in the same SSH session besides L and L. Once the socket becomes ready again, the exact same former C call, with exactly the same arguments must be invoked. Failing to do that would result in a corrupted SSH session. This is a limitation in libssh2. =head2 flush ( [ ext ] ) Flushes the channel; if C is present and set, flushes extended data channel. Returns number of bytes flushed, C on error. =head2 exit_signal Returns the name of exit signal from the remote command. In list context returns also the error message and a language tag, though as of libssh2 1.7.0, those values are always undef. This method blocks until the remote side closes the channel. =head2 exit_signal_number Converts the signal name to a signal number using the local mapping (which may be different to the remote one if the operating systems differ). =head2 window_read Returns the number of bytes which the remote end may send without overflowing the window limit. In list context it also returns the number of bytes that are immediately available for read and the size of the initial window. =head2 window_write Returns the number of bytes which may be safely written to the channel without blocking at the SSH level. In list context it also returns the size of the initial window. Note that this method doesn't take into account the TCP connection being used under the hood. Getting a positive integer back from this method does not guarantee that such number of bytes could be written to the channel without blocking the TCP connection. =head2 receive_window_adjust (adjustment [, force]) Adjust the channel receive window by the given C bytes. If the amount to be adjusted is less than C and force is false the adjustment amount will be queued for a later packet. On success returns the new size of the receive window. On failure it returns C. =head1 SEE ALSO L. =cut Net-SSH2-0.69/lib/Net/SSH2/Dir.pm0000644000175000017500000000146113033750102014774 0ustar salvasalvapackage Net::SSH2::Dir; use strict; use warnings; use Carp; # methods 1; __END__ =head1 NAME Net::SSH2::Dir - SSH 2 SFTP directory object =head1 DESCRIPTION An SFTP file object is created by the L C method. =head2 read Returns a hash (hashref in scalar context); keys are C and those returned by Net::SSH2::SFTP::stat; returns empty list or undef if no more files. =head1 SEE ALSO L. =head1 AUTHOR David B. Robins, Edbrobins@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2005, 2006 by David B. Robins; all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. =cut Net-SSH2-0.69/lib/Net/SSH2/Listener.pm0000644000175000017500000000144413033750102016044 0ustar salvasalvapackage Net::SSH2::Listener; use strict; use warnings; use Carp; # methods 1; __END__ =head1 NAME Net::SSH2::Listener - SSH 2 listener object =head1 DESCRIPTION A listener object is created by the L C method. The L C method can be used to check for connections. =head2 accept Accept a connection. Returns a channel object on success, undef on failure. =head1 SEE ALSO L. =head1 AUTHOR David B. Robins, Edbrobins@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2005, 2006 by David B. Robins; all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. =cut Net-SSH2-0.69/lib/Net/SSH2/Constants.pm0000644000175000017500000002102013244346623016240 0ustar salvasalvapackage Net::SSH2::Constants; # This file is generated automatically by util/gen_constants.pl sub import { die "Do not use Net::SSH2::Constants!"; } package Net::SSH2; use strict; use warnings; use base 'Exporter'; our @EXPORT_OK = qw(LIBSSH2_CALLBACK_DEBUG LIBSSH2_CALLBACK_DISCONNECT LIBSSH2_CALLBACK_IGNORE LIBSSH2_CALLBACK_MACERROR LIBSSH2_CALLBACK_X11 LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL SSH_EXTENDED_DATA_STDERR LIBSSH2_EXTENDED_DATA_STDERR LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA LIBSSH2_CHANNEL_FLUSH_STDERR LIBSSH2_CHANNEL_MINADJUST LIBSSH2_CHANNEL_PACKET_DEFAULT LIBSSH2_CHANNEL_WINDOW_DEFAULT LIBSSH2_DH_GEX_MAXGROUP LIBSSH2_DH_GEX_MINGROUP LIBSSH2_DH_GEX_OPTGROUP LIBSSH2_ERROR_ALLOC LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_NONE LIBSSH2_ERROR_BANNER_SEND LIBSSH2_ERROR_CHANNEL_CLOSED LIBSSH2_ERROR_CHANNEL_EOF_SENT LIBSSH2_ERROR_CHANNEL_FAILURE LIBSSH2_ERROR_CHANNEL_OUTOFORDER LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED LIBSSH2_ERROR_CHANNEL_UNKNOWN LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED LIBSSH2_ERROR_DECRYPT LIBSSH2_ERROR_FILE LIBSSH2_ERROR_HOSTKEY_INIT LIBSSH2_ERROR_HOSTKEY_SIGN LIBSSH2_ERROR_INVAL LIBSSH2_ERROR_INVALID_MAC LIBSSH2_ERROR_INVALID_POLL_TYPE LIBSSH2_ERROR_KEX_FAILURE LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE LIBSSH2_ERROR_METHOD_NONE LIBSSH2_ERROR_METHOD_NOT_SUPPORTED LIBSSH2_ERROR_PASSWORD_EXPIRED LIBSSH2_ERROR_PROTO LIBSSH2_ERROR_AUTHENTICATION_FAILED LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED LIBSSH2_ERROR_REQUEST_DENIED LIBSSH2_ERROR_SCP_PROTOCOL LIBSSH2_ERROR_PUBLICKEY_PROTOCOL LIBSSH2_ERROR_SFTP_PROTOCOL LIBSSH2_ERROR_SOCKET_DISCONNECT LIBSSH2_ERROR_SOCKET_NONE LIBSSH2_ERROR_SOCKET_SEND LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_TIMEOUT LIBSSH2_ERROR_ZLIB LIBSSH2_ERROR_KNOWN_HOSTS LIBSSH2_FLAG_SIGPIPE LIBSSH2_FLAG_COMPRESS LIBSSH2_FXF_APPEND LIBSSH2_ERROR_EAGAIN LIBSSH2_SESSION_BLOCK_INBOUND LIBSSH2_SESSION_BLOCK_OUTBOUND LIBSSH2_TRACE_TRANS LIBSSH2_TRACE_KEX LIBSSH2_TRACE_AUTH LIBSSH2_TRACE_CONN LIBSSH2_TRACE_SCP LIBSSH2_TRACE_SFTP LIBSSH2_TRACE_ERROR LIBSSH2_TRACE_PUBLICKEY LIBSSH2_TRACE_SOCKET LIBSSH2_FXF_CREAT LIBSSH2_FXF_EXCL LIBSSH2_FXF_READ LIBSSH2_FXF_TRUNC LIBSSH2_FXF_WRITE LIBSSH2_FX_BAD_MESSAGE LIBSSH2_FX_CONNECTION_LOST LIBSSH2_FX_DIR_NOT_EMPTY LIBSSH2_FX_EOF LIBSSH2_FX_FAILURE LIBSSH2_FX_FILE_ALREADY_EXISTS LIBSSH2_FX_INVALID_FILENAME LIBSSH2_FX_INVALID_HANDLE LIBSSH2_FX_LINK_LOOP LIBSSH2_FX_LOCK_CONFlICT LIBSSH2_FX_NOT_A_DIRECTORY LIBSSH2_FX_NO_CONNECTION LIBSSH2_FX_NO_MEDIA LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM LIBSSH2_FX_NO_SUCH_FILE LIBSSH2_FX_NO_SUCH_PATH LIBSSH2_FX_OK LIBSSH2_FX_OP_UNSUPPORTED LIBSSH2_FX_PERMISSION_DENIED LIBSSH2_FX_QUOTA_EXCEEDED LIBSSH2_FX_UNKNOWN_PRINCIPLE LIBSSH2_FX_WRITE_PROTECT LIBSSH2_H LIBSSH2_HOSTKEY_HASH_MD5 LIBSSH2_HOSTKEY_HASH_SHA1 LIBSSH2_METHOD_COMP_CS LIBSSH2_METHOD_COMP_SC LIBSSH2_METHOD_CRYPT_CS LIBSSH2_METHOD_CRYPT_SC LIBSSH2_METHOD_HOSTKEY LIBSSH2_METHOD_KEX LIBSSH2_METHOD_LANG_CS LIBSSH2_METHOD_LANG_SC LIBSSH2_METHOD_MAC_CS LIBSSH2_METHOD_MAC_SC LIBSSH2_PACKET_MAXCOMP LIBSSH2_PACKET_MAXDECOMP LIBSSH2_PACKET_MAXPAYLOAD LIBSSH2_POLLFD_CHANNEL LIBSSH2_POLLFD_CHANNEL_CLOSED LIBSSH2_POLLFD_LISTENER LIBSSH2_POLLFD_LISTENER_CLOSED LIBSSH2_POLLFD_POLLERR LIBSSH2_POLLFD_POLLEX LIBSSH2_POLLFD_POLLEXT LIBSSH2_POLLFD_POLLHUP LIBSSH2_POLLFD_POLLIN LIBSSH2_POLLFD_POLLNVAL LIBSSH2_POLLFD_POLLOUT LIBSSH2_POLLFD_POLLPRI LIBSSH2_POLLFD_SESSION_CLOSED LIBSSH2_POLLFD_SOCKET LIBSSH2_SFTP_ATTR_ACMODTIME LIBSSH2_SFTP_ATTR_EXTENDED LIBSSH2_SFTP_ATTR_PERMISSIONS LIBSSH2_SFTP_ATTR_SIZE LIBSSH2_SFTP_ATTR_UIDGID LIBSSH2_SFTP_LSTAT LIBSSH2_SFTP_OPENDIR LIBSSH2_SFTP_OPENFILE LIBSSH2_SFTP_PACKET_MAXLEN LIBSSH2_SFTP_READLINK LIBSSH2_SFTP_REALPATH LIBSSH2_SFTP_RENAME_ATOMIC LIBSSH2_SFTP_RENAME_NATIVE LIBSSH2_SFTP_RENAME_OVERWRITE LIBSSH2_SFTP_SETSTAT LIBSSH2_SFTP_STAT LIBSSH2_SFTP_SYMLINK LIBSSH2_SFTP_TYPE_BLOCK_DEVICE LIBSSH2_SFTP_TYPE_CHAR_DEVICE LIBSSH2_SFTP_TYPE_DIRECTORY LIBSSH2_SFTP_TYPE_FIFO LIBSSH2_SFTP_TYPE_REGULAR LIBSSH2_SFTP_TYPE_SOCKET LIBSSH2_SFTP_TYPE_SPECIAL LIBSSH2_SFTP_TYPE_SYMLINK LIBSSH2_SFTP_TYPE_UNKNOWN LIBSSH2_SFTP_VERSION LIBSSH2_SOCKET_POLL_MAXLOOPS LIBSSH2_SOCKET_POLL_UDELAY LIBSSH2_TERM_HEIGHT LIBSSH2_TERM_HEIGHT_PX LIBSSH2_TERM_WIDTH LIBSSH2_TERM_WIDTH_PX LIBSSH2_KNOWNHOST_TYPE_MASK LIBSSH2_KNOWNHOST_TYPE_PLAIN LIBSSH2_KNOWNHOST_TYPE_SHA1 LIBSSH2_KNOWNHOST_TYPE_CUSTOM LIBSSH2_KNOWNHOST_KEYENC_MASK LIBSSH2_KNOWNHOST_KEYENC_RAW LIBSSH2_KNOWNHOST_KEYENC_BASE64 LIBSSH2_KNOWNHOST_KEY_MASK LIBSSH2_KNOWNHOST_KEY_SHIFT LIBSSH2_KNOWNHOST_KEY_RSA1 LIBSSH2_KNOWNHOST_KEY_SSHRSA LIBSSH2_KNOWNHOST_KEY_SSHDSS LIBSSH2_KNOWNHOST_CHECK_MATCH LIBSSH2_KNOWNHOST_CHECK_MISMATCH LIBSSH2_KNOWNHOST_CHECK_NOTFOUND LIBSSH2_KNOWNHOST_CHECK_FAILURE LIBSSH2_HOSTKEY_POLICY_STRICT LIBSSH2_HOSTKEY_POLICY_ASK LIBSSH2_HOSTKEY_POLICY_TOFU LIBSSH2_HOSTKEY_POLICY_ADVISORY); our %EXPORT_TAGS = ( all => \@EXPORT_OK, callback => [qw(LIBSSH2_CALLBACK_DEBUG LIBSSH2_CALLBACK_DISCONNECT LIBSSH2_CALLBACK_IGNORE LIBSSH2_CALLBACK_MACERROR LIBSSH2_CALLBACK_X11)], channel => [qw(LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA LIBSSH2_CHANNEL_FLUSH_STDERR LIBSSH2_CHANNEL_MINADJUST LIBSSH2_CHANNEL_PACKET_DEFAULT LIBSSH2_CHANNEL_WINDOW_DEFAULT)], error => [qw(LIBSSH2_ERROR_ALLOC LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_NONE LIBSSH2_ERROR_BANNER_SEND LIBSSH2_ERROR_CHANNEL_CLOSED LIBSSH2_ERROR_CHANNEL_EOF_SENT LIBSSH2_ERROR_CHANNEL_FAILURE LIBSSH2_ERROR_CHANNEL_OUTOFORDER LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED LIBSSH2_ERROR_CHANNEL_UNKNOWN LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED LIBSSH2_ERROR_DECRYPT LIBSSH2_ERROR_FILE LIBSSH2_ERROR_HOSTKEY_INIT LIBSSH2_ERROR_HOSTKEY_SIGN LIBSSH2_ERROR_INVAL LIBSSH2_ERROR_INVALID_MAC LIBSSH2_ERROR_INVALID_POLL_TYPE LIBSSH2_ERROR_KEX_FAILURE LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE LIBSSH2_ERROR_METHOD_NONE LIBSSH2_ERROR_METHOD_NOT_SUPPORTED LIBSSH2_ERROR_PASSWORD_EXPIRED LIBSSH2_ERROR_PROTO LIBSSH2_ERROR_AUTHENTICATION_FAILED LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED LIBSSH2_ERROR_REQUEST_DENIED LIBSSH2_ERROR_SCP_PROTOCOL LIBSSH2_ERROR_PUBLICKEY_PROTOCOL LIBSSH2_ERROR_SFTP_PROTOCOL LIBSSH2_ERROR_SOCKET_DISCONNECT LIBSSH2_ERROR_SOCKET_NONE LIBSSH2_ERROR_SOCKET_SEND LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_TIMEOUT LIBSSH2_ERROR_ZLIB LIBSSH2_ERROR_KNOWN_HOSTS LIBSSH2_ERROR_EAGAIN)], fx => [qw(LIBSSH2_FX_BAD_MESSAGE LIBSSH2_FX_CONNECTION_LOST LIBSSH2_FX_DIR_NOT_EMPTY LIBSSH2_FX_EOF LIBSSH2_FX_FAILURE LIBSSH2_FX_FILE_ALREADY_EXISTS LIBSSH2_FX_INVALID_FILENAME LIBSSH2_FX_INVALID_HANDLE LIBSSH2_FX_LINK_LOOP LIBSSH2_FX_LOCK_CONFlICT LIBSSH2_FX_NOT_A_DIRECTORY LIBSSH2_FX_NO_CONNECTION LIBSSH2_FX_NO_MEDIA LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM LIBSSH2_FX_NO_SUCH_FILE LIBSSH2_FX_NO_SUCH_PATH LIBSSH2_FX_OK LIBSSH2_FX_OP_UNSUPPORTED LIBSSH2_FX_PERMISSION_DENIED LIBSSH2_FX_QUOTA_EXCEEDED LIBSSH2_FX_UNKNOWN_PRINCIPLE LIBSSH2_FX_WRITE_PROTECT)], fxf => [qw(LIBSSH2_FXF_APPEND LIBSSH2_FXF_CREAT LIBSSH2_FXF_EXCL LIBSSH2_FXF_READ LIBSSH2_FXF_TRUNC LIBSSH2_FXF_WRITE)], hash => [qw(LIBSSH2_HOSTKEY_HASH_MD5 LIBSSH2_HOSTKEY_HASH_SHA1)], method => [qw(LIBSSH2_METHOD_COMP_CS LIBSSH2_METHOD_COMP_SC LIBSSH2_METHOD_CRYPT_CS LIBSSH2_METHOD_CRYPT_SC LIBSSH2_METHOD_HOSTKEY LIBSSH2_METHOD_KEX LIBSSH2_METHOD_LANG_CS LIBSSH2_METHOD_LANG_SC LIBSSH2_METHOD_MAC_CS LIBSSH2_METHOD_MAC_SC)], policy => [qw(LIBSSH2_HOSTKEY_POLICY_STRICT LIBSSH2_HOSTKEY_POLICY_ASK LIBSSH2_HOSTKEY_POLICY_TOFU LIBSSH2_HOSTKEY_POLICY_ADVISORY)], sftp => [qw(LIBSSH2_SFTP_ATTR_ACMODTIME LIBSSH2_SFTP_ATTR_EXTENDED LIBSSH2_SFTP_ATTR_PERMISSIONS LIBSSH2_SFTP_ATTR_SIZE LIBSSH2_SFTP_ATTR_UIDGID LIBSSH2_SFTP_LSTAT LIBSSH2_SFTP_OPENDIR LIBSSH2_SFTP_OPENFILE LIBSSH2_SFTP_PACKET_MAXLEN LIBSSH2_SFTP_READLINK LIBSSH2_SFTP_REALPATH LIBSSH2_SFTP_RENAME_ATOMIC LIBSSH2_SFTP_RENAME_NATIVE LIBSSH2_SFTP_RENAME_OVERWRITE LIBSSH2_SFTP_SETSTAT LIBSSH2_SFTP_STAT LIBSSH2_SFTP_SYMLINK LIBSSH2_SFTP_TYPE_BLOCK_DEVICE LIBSSH2_SFTP_TYPE_CHAR_DEVICE LIBSSH2_SFTP_TYPE_DIRECTORY LIBSSH2_SFTP_TYPE_FIFO LIBSSH2_SFTP_TYPE_REGULAR LIBSSH2_SFTP_TYPE_SOCKET LIBSSH2_SFTP_TYPE_SPECIAL LIBSSH2_SFTP_TYPE_SYMLINK LIBSSH2_SFTP_TYPE_UNKNOWN LIBSSH2_SFTP_VERSION)], socket => [qw(LIBSSH2_SOCKET_POLL_MAXLOOPS LIBSSH2_SOCKET_POLL_UDELAY)], trace => [qw(LIBSSH2_TRACE_TRANS LIBSSH2_TRACE_KEX LIBSSH2_TRACE_AUTH LIBSSH2_TRACE_CONN LIBSSH2_TRACE_SCP LIBSSH2_TRACE_SFTP LIBSSH2_TRACE_ERROR LIBSSH2_TRACE_PUBLICKEY LIBSSH2_TRACE_SOCKET)], ); 1; Net-SSH2-0.69/lib/Net/SSH2/File.pm0000644000175000017500000001063713033750102015142 0ustar salvasalvapackage Net::SSH2::File; use strict; use warnings; use Carp; # methods sub readline { my ($self, $eol) = @_; $eol = $/ unless @_ >= 2; if (wantarray or not defined $eol) { my $data = ''; my $buffer; while (1) { $self->read($buffer, 32768) or last; $data .= $buffer; } defined $eol and return split /(?<=\Q$eol\E)/s, $data; wantarray and not length $data and return (); return $data; } else { my $c; my $data = ''; while (1) { $c = $self->getc; last unless defined $c; $data .= $c; last if $data =~ /\Q$eol\E\z/; } return (length $data ? $data : undef); } } # tie interface sub PRINT { my $self = shift; my $sep = defined($,) ? $, : ''; $self->write(join $sep, @_) } sub PRINTF { my $self = shift; my $template = shift; $self->write(sprintf $template, @_) } sub WRITE { my ($self, $buf, $len, $offset) = @_; $self->write(substr($buf, $offset, $len)) } sub READLINE { shift->readline($/) } *GETC = \&getc; sub READ { my ($self, undef, $len, $offset) = @_; my $bytes = $self->read(my($buffer), $len); substr($_[1], $offset || 0) = $buffer if defined $bytes; return $bytes; } sub CLOSE { } sub BINMODE { 1 } sub EOF { 0 } 1; __END__ =head1 NAME Net::SSH2::File - SSH2 SFTP file object =head1 DESCRIPTION An SFTP file object is created by the L C method. =head2 read ( buffer, size ) Read size bytes from the file into a given buffer. Returns number of bytes read, or undef on failure. =head2 write ( buffer ) Write buffer to the remote file. The C function wrapped by this method has a complex and quite difficult (if not impossible at all) to use API. It tries to hide the packet pipelining being done under the hood in order to attain decent throughput. Net::SSH2 can not hide that complexity without negatively affecting the transmission speed so it provides just a thin wrapper for that library function. An excerpt from C manual page follows: WRITE AHEAD Starting in libssh2 version 1.2.8, the default behavior of libssh2 is to create several smaller outgoing packets for all data you pass to this function and it will return a positive number as soon as the first packet is acknowledged from the server. This has the effect that sometimes more data has been sent off but isn't acked yet when this function returns, and when this function is subsequently called again to write more data, libssh2 will immediately figure out that the data is already received remotely. In most normal situation this should not cause any problems, but it should be noted that if you've once called libssh2_sftp_write() with data and it returns short, you MUST still assume that the rest of the data might've been cached so you need to make sure you don't alter that data and think that the version you have in your next function invoke will be detected or used. The reason for this funny behavior is that SFTP can only send 32K data in each packet and it gets all packets acked individually. This means we cannot use a simple serial approach if we want to reach high performance even on high latency connections. And we want that. =head2 stat Returns file attributes; see Net::SSH2::SFTP::stat. =head2 setstat ( key, value... ) Sets file attributes; see Net::SSH2::SFTP::setstat. =head2 seek ( offset ) Set the file pointer offset. =head2 tell Returns the current file pointer offset. =head1 SEE ALSO L. Check L for a high level, perlish and easy to use SFTP client module. It can work on top of Net::SSH2 via the L backend module. =head1 COPYRIGHT AND LICENSE Copyright (C) 2005, 2006 by David B. Robins Edbrobins@cpan.orgE; Copyright (C) 2015 by Salvador FandiEo Esfandino@yahoo.comE; All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. The documentation for this package contains and excerpt from libssh2 manual pages. You can consult the license of the libssh2 project for the conditions regulating the copyright of that part. =cut Net-SSH2-0.69/lib/Net/SSH2/SFTP.pm0000644000175000017500000000542513033750102015036 0ustar salvasalvapackage Net::SSH2::SFTP; use strict; use warnings; use Carp; sub die_with_error { my $self = shift; if (my ($code, $name) = $self->error) { croak join(": ", @_, "SFTP error $code $name"); } else { croak join(": ", @_, "no SFTP error registered"); } } 1; __END__ =head1 NAME Net::SSH2::SFTP - SSH 2 Secure FTP object =head1 DESCRIPTION An SFTP object is created by the L C method. =head2 error Returns the last SFTP error (one of the LIBSSH2_FX_* constants). Use this when Net::SSH2::error returns LIBSSH2_ERROR_SFTP_PROTOCOL. In list context, returns (code, error name). =head2 die_with_error( [message] ) Calls C with the given message and the error information from the object appended. =head2 open ( file [, flags [, mode ]]] ) Open or create a file on the remote host. The flags are the standard O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_CREAT, O_TRUNC, and O_EXCL, which may be combined as usual. Flags default to O_RDONLY and mode to 0666 (create only). Returns a L object on success. =head2 opendir ( dir ) Open a directory on the remote host; returns a Net::SSH2::Dir object on success. =head2 unlink ( file ) Delete the remote file. =head2 rename ( old, new [, flags ] ) Rename old to new. Flags are taken from LIBSSH2_SFTP_RENAME_*, and may be combined; the default is to use all (overwrite, atomic, native). =head2 mkdir ( path [, mode ] ) Create directory; mode defaults to 0777. =head2 rmdir ( path ) Remove directory. =head2 stat ( path [, follow ] ) Get file attributes for the given path. If follow is set (default), will follow symbolic links. On success, returns a hash containing the following: =over 4 =item mode =item size =item uid =item gid =item atime =item mtime =back =head2 setstat ( path, key, value... ) Set file attributes for given path; keys are the same as those returned by stat; note that it's not necessary to pass them all. =head2 symlink ( path, target [, type ] ) Create a symbolic link to a given target. =head2 readlink ( path ) Return the target of the given link, undef on failure. =head2 realpath ( path ) Resolve a filename's path; returns the resolved path, or undef on error. =head1 SEE ALSO L. Check L for a high level, perlish and easy to use SFTP client module. It can work on top of Net::SSH2 via the L backend module. =head1 AUTHOR David B. Robins, Edbrobins@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2005, 2006 by David B. Robins; all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. =cut Net-SSH2-0.69/lib/Net/SSH2/PublicKey.pm0000644000175000017500000000167313033750102016152 0ustar salvasalvapackage Net::SSH2::PublicKey; use strict; use warnings; use Carp; # methods 1; __END__ =head1 NAME Net::SSH2::PublicKey - SSH 2 public key object =head1 DESCRIPTION *** WARNING: public key functionality in libssh2 is experimental *** and mostly abandoned. Don't expect anything on this module to *** work correctly. A public key object is created by the L C method. =head1 METHODS =head2 add ( name, blob, overwrite flag, attributes... ) Adds a new public key; attributes is a list of hashes with C, C, and C keys; mandatory defaults to false and value to empty. =head2 remove ( name, blob ) Remove the given public key. =head2 fetch Returns a list of public keys in array context (count in scalar context); each item is a hash with keys C, C, and C, with the latter being a hash with C, C, and C keys. =head1 SEE ALSO L. =cut Net-SSH2-0.69/lib/Net/SSH2/KnownHosts.pm0000644000175000017500000001420113033750102016367 0ustar salvasalvapackage Net::SSH2::KnownHosts; use strict; use warnings; 1; __END__ =head1 NAME Net::SSH2::KnownHosts - SSH 2 knownhosts object =head1 SYNOPSIS ##################################################################### # # # WARNING: The API provided by Net::SSH2::KnownHosts is # # experimental and could change in future versions of the module!!! # # # ##################################################################### my $kh = $ssh2->known_hosts; my $n_ent = $kh->readfile($known_hosts_path); # a non-existent known_hosts file usually is not an error... unless (defined $n_ent) { if ($ssh2->error != LIBSSH2_ERROR_FILE or -f $known_hosts_path) { die; # propagate error; } } my ($key, $type) = $ssh2->remote_hostkey; my $flags = ( LIBSSH2_KNOWNHOST_TYPE_PLAIN | LIBSSH2_KNOWNHOST_KEYENC_RAW | (($type + 1) << LIBSSH2_KNOWNHOST_KEY_SHIFT) ); my $check = $kh->check($hostname, $port, $key, $flags); if ($check == LIBSSH2_KNOWNHOST_CHECK_MATCH) { # ok! } elsif ($check == LIBSSH2_KNOWNHOST_CHECK_MISMATCH) { die "host verification failed, the key has changed!"; } elsif ($check == LIBSSH2_KNOWNHOST_CHECK_NOTFOUND) { die "host verification failed, key not found in known_hosts file" if $strict_host_key_checking; # else, save new key to file: unless ( $kh->add($hostname, '', $key, "Perl added me", $flags) and $kh->writefile($known_hosts_path) ) { warn "unable to save known_hosts file: " . ($ssh2->error)[1]; } } else { die "host key verification failed, unknown reason"; } =head1 DESCRIPTION ##################################################################### # # # WARNING: The API provided by Net::SSH2::KnownHosts is # # experimental and could change in future versions of the module!!! # # # ##################################################################### The C object allows one to manipulate the entries in the C file usually located at C<~/.ssh/known_hosts> and which contains the public keys of the already known hosts. The methods currently supported are as follows: =head2 readfile (filename) Populates the object with the entries in the given file. It returns the number or entries read or undef on failure. =head2 writefile (filename) Saves the known host entries to the given file. =head2 add (hostname, salt, key, comment, key_type|host_format|key_format) Add a host and its associated key to the collection of known hosts. The C argument specifies the format of the given host: LIBSSH2_KNOWNHOST_TYPE_PLAIN - ascii "hostname.domain.tld" LIBSSH2_KNOWNHOST_TYPE_SHA1 - SHA1(salt, host) base64-encoded! LIBSSH2_KNOWNHOST_TYPE_CUSTOM - another hash If C is selected as host format, the salt must be provided to the salt argument in base64 format. The SHA-1 hash is what OpenSSH can be told to use in known_hosts files. If a custom type is used, salt is ignored and you must provide the host pre-hashed when checking for it in the C method. The available key formats are as follow: LIBSSH2_KNOWNHOST_KEYENC_RAW LIBSSH2_KNOWNHOST_KEYENC_BASE64 Finally, the available key types are as follow: LIBSSH2_KNOWNHOST_KEY_RSA1 LIBSSH2_KNOWNHOST_KEY_SSHRSA LIBSSH2_KNOWNHOST_KEY_SSHDSS The comment argument may be undef. =head2 check (hostname, port, key, key_type|host_format|key_format) Checks a host and its associated key against the collection of known hosts. The C argument has the same meaning as in the L method. C may be passed as the port argument. Returns: LIBSSH2_KNOWNHOST_CHECK_MATCH (0) LIBSSH2_KNOWNHOST_CHECK_MISMATCH (1) LIBSSH2_KNOWNHOST_CHECK_NOTFOUND (2) LIBSSH2_KNOWNHOST_CHECK_FAILURE (3) =head2 readline (string) Read a known_hosts entry from the given string. For instance, the following piece of code is more or less equivalent to the L method: my $kh = $ssh2->known_hosts; if (open my $fh, '<', $known_hosts_path) { while (<>) { eval { $kh->readline($_) } or warn "unable to parse known_hosts entry $_"; } } =head2 writeline (hostname, port, key, key_type|host_format|key_format) Searches the entry matching the given parameters (as described in the L method) and formats it into a line in the known_hosts format. This method returns undef when some error happens. This method should be considered experimental, the interface may change. =head1 SEE ALSO L, L. =head1 COPYRIGHT AND LICENSE Copyright (C) 2013-2015 Salvador FandiEo; all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. The documentation on this file is based on the comments inside C file from the libssh2 distribution which has the following copyright and license: Copyright (c) 2004-2009, Sara Golemon Copyright (c) 2009-2012 Daniel Stenberg Copyright (c) 2010 Simon Josefsson All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the copyright holder nor the names of any other contributors may be used to endorse or promote products derived from this software without specific prior written permission. =cut Net-SSH2-0.69/lib/Net/SSH2.pm0000644000175000017500000012046113244346457014302 0ustar salvasalvapackage Net::SSH2; our $VERSION = '0.69'; use 5.006; use strict; use warnings; use warnings::register; use Carp; require Net::SSH2::Constants; use Socket; use IO::File; use File::Basename; use Errno; # load IO::Socket::IP when available, otherwise fallback to IO::Socket::INET. my $socket_class = do { local ($SIG{__DIE__}, $SIG{__WARN__}, $@, $!); eval { require IO::Socket::IP; 'IO::Socket::IP'; } } || do { require IO::Socket::INET; 'IO::Socket::INET' }; # methods sub new { my ($class, %opts) = @_; my $self = $class->_new; for (qw(trace timeout debug)) { $self->$_($opts{$_}) if defined $opts{$_} } $self->flag(COMPRESS => $opts{compress}) if defined $opts{compress} and (version())[1] >= 0x10500; $self->flag(SIGPIPE => $opts{sigpipe}) if defined $opts{sigpipe}; return $self; } sub die_with_error { my $self = shift; if (my ($code, $name, $string) = $self->error) { croak join(": ", @_, "$string ($code $name)"); } else { croak join(": ", @_, "no libssh2 error registered"); } } sub method { my $self = shift; my $method_type = shift; $self->_method($method_type => (@_ ? join(',', @_) : ())); } my $connect_opts_warned; my $connect_fd_warned; my $connect_void_warned; sub connect { my $self = shift; defined $_[0] or croak "Net::SSH2::connect: hostname argument is undefined"; # try to connect, or get a file descriptor my ($fd, $sock); if (@_ == 1) { $sock = shift; if ($sock =~ /^\d{1,10}$/) { $connect_fd_warned++ or warnings::warnif($self, "Passing a file descriptor number to connect is deprecated"); $fd = $sock; } elsif(ref $sock) { # handled below } else { @_ = ($sock, 'ssh'); } } my %opts = (@_ > 2 ? splice(@_, 2) : ()); if (%opts) { $connect_opts_warned++ or warnings::warnif($self, "Passing options to connect is deprecated"); $self->timeout(1000 * $opts{Timeout}) if $opts{Timeout}; if ($opts{Compress} and ($self->version)[1] >= 0x10500) { $self->flag(COMPRESS => 1); } } my ($hostname, $port); if (@_ == 2) { ($hostname, $port) = @_; if (not defined $port) { $port = getservbyname('ssh', 'tcp') || 22; } elsif ($port =~ /\D/) { $port = getservbyname($port, 'tcp'); unless (defined $port) { $self->_set_error(LIBSSH2_ERROR_SOCKET_NONE(), "Unable to resolve TCP service name $_[1]"); goto error; } } my $timeout = $self->timeout; $sock = $socket_class->new( PeerHost => $hostname, PeerPort => $port, Blocking => $self->blocking, (defined($timeout) ? (Timeout => 0.001 * $timeout) : ()) ); unless ($sock) { $self->_set_error(LIBSSH2_ERROR_SOCKET_NONE(), "Unable to connect to remote host: $!"); goto error; } $sock->sockopt(SO_LINGER, pack('SS', 0, 0)); } # get a file descriptor unless (defined $fd) { $fd = fileno($sock); unless (defined $fd) { $self->_set_error(LIBSSH2_ERROR_SOCKET_NONE(), "Unable to get file descriptor from socket: $!"); goto error; } } if ($^O eq 'MSWin32') { require Win32API::File; $fd = Win32API::File::FdGetOsFHandle($fd); } { local ($@, $SIG{__DIE__}); $port = eval { $sock->peerport } || 22 unless defined $port; $hostname = eval { $sock->peername } unless defined $hostname; } # pass it in, do protocol return $self->_startup($fd, $sock, $hostname, $port); error: unless (defined wantarray) { unless ($connect_void_warned++) { local $!; warnings::warnif($self, "Calling connect in void context is deprecated"); } croak "Net::SSH2: failed to connect to ". join(':', grep defined, @_[0,1]) .": $!"; } return; } sub _auth_methods { return { 'agent' => { ssh => 'publickey', method => \&auth_agent, params => [qw(_fallback username)], }, 'hostbased' => { ssh => 'hostbased', method => \&auth_hostbased, params => [qw(username publickey privatekey hostname local_username? passphrase?)], }, 'publickey' => { ssh => 'publickey', method => \&auth_publickey, params => [qw(username publickey? privatekey passphrase?)], }, 'keyboard' => { ssh => 'keyboard-interactive', method => \&auth_keyboard, params => [qw(_interact _fallback username cb_keyboard?)] }, 'keyboard-auto' => { ssh => 'keyboard-interactive', method => \&auth_keyboard, params => [qw(username password)], }, 'password' => { ssh => 'password', method => \&auth_password, params => [qw(username password cb_password?)], }, 'password-interact' => { ssh => 'password', method => \&auth_password_interact, params => [qw(_interact _fallback username cb_password?)], }, 'none' => { ssh => 'none', method => \&auth_password, params => [qw(username)], }, }; } my @rank_default = qw(hostbased publickey keyboard-auto password agent keyboard password-interact none); sub _auth_rank { my ($self, $rank) = @_; $rank ||= \@rank_default; my $libver = ($self->version)[1] || 0; return @$rank if $libver > 0x010203; return grep { $_ ne 'agent' } @$rank; } sub _local_user { for (qw(USER LOGNAME)) { return $ENV{$_} if defined $ENV{$_} } local ($@, $SIG{__DIE__}, $SIG{__WARN__}); my $u = eval { getlogin }; return $u if defined $u; eval { getpwuid $< } } my $password_when_you_mean_passphrase_warned; sub auth { my ($self, %p) = @_; $self->_set_error(LIBSSH2_ERROR_AUTHENTICATION_FAILED(), "Authentication failed"); # default error $p{username} = _local_user unless defined $p{username}; my @rank = $self->_auth_rank(delete $p{rank}); my $remote_rank; $remote_rank = { map { $_ => 1 } $self->auth_list($p{username}) } if defined $p{username}; # if fallback is set, interact with the user even when a password # is given $p{fallback} = 1 unless defined $p{password} or defined $p{passphrase}; TYPE: for(my $i = 0; $i < @rank; $i++) { my $type = $rank[$i]; my $data = $self->_auth_methods->{$type}; unless ($data) { carp "unknown authentication method '$type'"; next; } next if $remote_rank and !$remote_rank->{$data->{ssh}}; # do we have the required parameters? my @pass; for my $param(@{$data->{params}}) { my $p = $param; my $opt = $p =~ s/\?$//; my $pseudo = $p =~ s/^_//; if ($p eq 'passphrase' and not exists $p{$p} and defined $p{password}) { $p = 'password'; $password_when_you_mean_passphrase_warned++ or carp "Using the key 'password' to refer to a passphrase is deprecated. Use 'passphrase' instead"; } if ($pseudo) { next TYPE unless $p{$p}; } else { next TYPE unless $opt or defined $p{$p}; push @pass, $p{$p}; # if it's optional, store undef } } # invoke the authentication method return $type if $data->{method}->($self, @pass) and $self->auth_ok; } return 'none' if $self->auth_ok; return; # failure } my $term_readkey_unavailable_warned; my $term_readkey_loaded; sub _load_term_readkey { return 1 if $term_readkey_loaded ||= do { local ($@, $!, $SIG{__DIE__}, $SIG{__WARN__}); eval { require Term::ReadKey; 1 } }; carp "Unable to load Term::ReadKey, will not ask for passwords at the console!" unless $term_readkey_unavailable_warned++; return; } sub _print_stderr { my $self = shift; my $ofh = select STDERR; local $|= 1; select $ofh; print STDERR $_ for @_; } sub _ask_user { my ($self, $prompt, $echo) = @_; my $timeout; if (($self->version)[1] >= 0x10209) { $timeout = $self->timeout || 0; $timeout = ($timeout + 999) / 1000; } _load_term_readkey or return; $self->_print_stderr($prompt); Term::ReadKey::ReadMode('noecho') unless $echo; my $reply = Term::ReadKey::ReadLine($timeout); Term::ReadKey::ReadMode('normal') unless $echo; $self->_print_stderr("\n") unless $echo and defined $reply; if (defined $reply) { chomp $reply } else { $self->_set_error(LIBSSH2_ERROR_SOCKET_TIMEOUT(), "Timeout waiting for user response!"); } return $reply; } sub auth_password_interact { my ($self, $username, $cb) = @_; _load_term_readkey or return; my $rc; for (0..2) { my $password = $self->_ask_user("${username}'s password? ", 0); $rc = $self->auth_password($username, $password, $cb); last if $rc or $self->error != LIBSSH2_ERROR_AUTHENTICATION_FAILED(); my $ofh = select STDERR; local $|= 1; select $ofh; $self->_print_stderr("Password authentication failed!\n"); } return $rc; } sub _local_home { return $ENV{HOME} if defined $ENV{HOME}; local ($@, $SIG{__DIE__}, $SIG{__WARN__}); my $home = eval { (getpwuid($<))[7] }; return $home; } my $check_hostkey_void_ctx_warned; sub check_hostkey { my ($self, $policy, $path, $comment) = @_; defined wantarray or $check_hostkey_void_ctx_warned++ or warnings::warnif($self, "Calling check_hostkey in void context is useless"); my $cb; if (not defined $policy) { $policy = LIBSSH2_HOSTKEY_POLICY_STRICT(); } elsif (ref $policy eq 'CODE') { $cb = $policy; } else { $policy = _parse_constant(HOSTKEY_POLICY => $policy); } my $hostname = $self->hostname; croak("hostname unknown: in order to use check_hostkey the peer host name ". "must be given (or discoverable) at connect time") unless defined $hostname; unless (defined $path) { my $home = _local_home; unless (defined $home) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to determine known_hosts location"); return; } require File::Spec; $path = File::Spec->catfile($home, '.ssh', 'known_hosts'); } my ($check, $key, $type, $flags); my $kh = $self->known_hosts; if ($kh and defined $kh->readfile($path)) { ($key, $type) = $self->remote_hostkey; $flags = ( LIBSSH2_KNOWNHOST_TYPE_PLAIN() | LIBSSH2_KNOWNHOST_KEYENC_RAW() | (($type + 1) << LIBSSH2_KNOWNHOST_KEY_SHIFT()) ); $check = $kh->check($hostname, $self->port, $key, $flags); $check == LIBSSH2_KNOWNHOST_CHECK_MATCH() and return "00"; } else { $check = LIBSSH2_KNOWNHOST_CHECK_FAILURE(); } if ($cb) { my $ok = $cb->($self, $check, $comment); $ok or $self->_set_error(LIBSSH2_ERROR_KNOWN_HOSTS(), 'Host key verification failed'); return $ok; } return $check if $policy == LIBSSH2_HOSTKEY_POLICY_ADVISORY(); # user doesn't care! if ($check == LIBSSH2_KNOWNHOST_CHECK_NOTFOUND()) { $self->_set_error(LIBSSH2_ERROR_KNOWN_HOSTS(), 'Unable to verify host key, host not found'); unless ($policy == LIBSSH2_HOSTKEY_POLICY_TOFU()) { if ($policy == LIBSSH2_HOSTKEY_POLICY_ASK()) { my $fp = unpack 'H*', $self->hostkey_hash(LIBSSH2_HOSTKEY_HASH_SHA1()); my $yes = $self->_ask_user("The authenticity of host '$hostname' can't be established.\n" . "Key fingerprint is SHA1:$fp.\n" . "Are you sure you want to continue connecting (yes/no)? ", 1); unless ($yes =~ /^y(es)?$/i) { $self->_set_error(LIBSSH2_ERROR_KNOWN_HOSTS(), 'Host key verification failed: user did not accept the key'); return undef; } } } $comment = '(Net::SSH2)' unless defined $comment; # we ignore errors here, that is the usual SSH client behaviour $kh->add($hostname, $self->port, $key, $comment, $flags) and $kh->writefile($path); return $check; } $self->_set_error(LIBSSH2_ERROR_KNOWN_HOSTS(), 'Host key verification failed: '. ( ($check == LIBSSH2_KNOWNHOST_CHECK_NOTFOUND()) ? "key not found in '$path'" : "unable to perform the check")); return undef; } sub scp_get { my ($self, $remote, $path) = @_; $path = basename $remote if not defined $path; my %stat; $self->blocking(1); my $chan = $self->_scp_get($remote, \%stat) or return; # read and commit blocks until we're finished my $file; if (ref $path) { $file = $path; } else { my $mode = $stat{mode} & 0777; $file = IO::File->new($path, O_WRONLY | O_CREAT | O_TRUNC, $mode); unless ($file) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to open local file: $!"); return; } binmode $file; } my $size = $stat{size}; while ($size > 0) { my $bytes_read = $chan->read(my($buf), (($size > 40000 ? 40000 : $size))); if ($bytes_read) { $size -= $bytes_read; while (length $buf) { my $bytes_written = $file->syswrite($buf, length $buf); if ($bytes_written) { substr $buf, 0, $bytes_written, ''; } elsif ($! != Errno::EAGAIN() && $! != Errno::EINTR()) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to write to local file: $!"); return; } } } elsif (!defined($bytes_read) and $self->error != LIBSSH2_ERROR_EAGAIN()) { return; } } # process SCP acknowledgment and send same $chan->read(my $eof, 1); $chan->write("\0"); return 1; } sub scp_put { my ($self, $path, $remote) = @_; $remote = basename $path if not defined $remote; my $file; if (ref $path) { $file = $path; } else { $file = IO::File->new($path, O_RDONLY); unless ($file) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to open local file: $!"); return; } binmode $file; } my @stat = $file->stat; unless (@stat) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to stat local file: $!"); return; } my $mode = $stat[2] & 0777; # mask off extras such as S_IFREG $self->blocking(1); my $chan = $self->_scp_put($remote, $mode, @stat[7, 8, 9]) or return; # read and transmit blocks until we're finished my $size = $stat[7]; while ($size > 0) { my $bytes_read = $file->sysread(my($buf), ($size > 32768 ? 32768 : $size)); if ($bytes_read) { $size -= $bytes_read; while (length $buf) { my $bytes_written = $chan->write($buf); if (defined $bytes_written) { substr($buf, 0, $bytes_written, ''); } elsif ($chan->error != LIBSSH2_ERROR_EAGAIN()) { return; } } } elsif (defined $bytes_read) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unexpected end of local file"); return; } elsif ($! != Errno::EAGAIN() and $! != Errno::EINTR()) { $self->_set_error(LIBSSH2_ERROR_FILE(), "Unable to read local file: $!"); return; } } # send/receive SCP acknowledgement $chan->write("\0"); return $chan->read(my($eof), 1) || undef; } my %Event; sub _init_poll { for my $event(qw( pollin pollpri pollext pollout pollerr pollhup pollnval pollex session_closed channel_closed listener_closed )) { no strict 'refs'; my $name = 'LIBSSH2_POLLFD_'.uc($event); (my $_event = $event) =~ s/^poll//; $Event{$_event} = &$name; } } sub poll { my ($self, $timeout, $event) = @_; $timeout ||= 0; # map incoming event structure (files to handles, events to integers) my @event; for my $in (@$event) { my ($handle, $events) = @{$in}{qw(handle events)}; $handle = fileno $handle unless ref $handle and ref($handle) =~ /^Net::SSH2::/; my $out = { handle => $handle, events => 0 }; $events = [$events] if not ref $events and $events =~ /^\D+$/; if (UNIVERSAL::isa($events, 'ARRAY')) { for my $name(@$events) { my $value = $Event{$name}; croak "Net::SSH2::poll: can't translate event '$name'" unless defined $value; $out->{events} |= $value; } } else { $out->{events} = $events || 0; } push @event, $out; } my $count = $self->_poll($timeout, \@event); return if not defined $count; # map received event structure (bitmask to hash of flags) my $i = 0; for my $item(@event) { my $revents = $item->{revents}; my $out = $event->[$i++]->{revents} = { value => $revents }; my $found = 0; # can't mask off values, since there are dupes while (my ($name, $value) = each %Event) { $out->{$name} = 1, $found |= $value if $revents & $value; } $out->{unknown} = $revents & ~$found if $revents & ~$found; } $count } sub _cb_kbdint_response_default { my ($self, $user, $name, $instr, @prompt) = @_; _load_term_readkey or return; my $prompt = "[user $user] "; $prompt .= "$name\n" if $name; $prompt .= "$instr\n" if $instr; $prompt =~ s/ $/\n/; $self->_print_stderr($prompt); return map $self->_ask_user($_->{text}, $_->{echo}), @prompt; } my $hostkey_warned; sub hostkey { $hostkey_warned++ or carp "Net::SSH2 'hostkey' method is obsolete, use 'hostkey_hash' instead"; shift->hostkey_hash(@_); } sub auth_list { my $auth = shift->_auth_list(@_); return unless defined $auth; wantarray ? split(/,/, $auth) : $auth } # mechanics sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. my $constname; our $AUTOLOAD; ($constname = $AUTOLOAD) =~ s/.*:://; croak "&Net::SSH2::constant not defined" if $constname eq 'constant'; my ($error, $val) = constant($constname); if ($error) { croak $error; } { no strict 'refs'; *$AUTOLOAD = sub { $val }; } goto &$AUTOLOAD; } require XSLoader; XSLoader::load('Net::SSH2', $VERSION); _init_poll(); require Net::SSH2::Channel; require Net::SSH2::SFTP; require Net::SSH2::File; require Net::SSH2::Listener; require Net::SSH2::KnownHosts; 1; __END__ =head1 NAME Net::SSH2 - Support for the SSH 2 protocol via libssh2. =head1 SYNOPSIS use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect('example.com') or $ssh2->die_with_error; $ssh->check_hostkey('ask') or $ssh2->die_with_error; if ($ssh2->auth_keyboard('fizban')) { my $chan = $ssh2->channel(); $chan->exec('program'); my $sftp = $ssh2->sftp(); my $fh = $sftp->open('/etc/passwd') or $sftp->die_with_error; print $_ while <$fh>; } =head1 DESCRIPTION Net::SSH2 is a Perl interface to the libssh2 (L) library. It supports the SSH2 protocol (there is no support for SSH1) with all of the key exchanges, ciphers, and compression of libssh2. Even if the module can be compiled and linked against very old versions of the library, nothing below 1.5.0 should really be used (older versions were quite buggy and unreliable) and version 1.7.0 or later is recommended. =head2 Error handling Unless otherwise indicated, methods return a true value on success and C on failure; use the L method to get extended error information. B: methods in Net::SSH2 not backed by libssh2 functions (i.e. L or L related methods) require libssh2 1.7.0 or later in order to set the error state. That means that after any of those methods fails, L would not return the real code but just some bogus result when an older version of the library is used. =head2 Typical usage The typical usage order is as follows: =over 4 =item 1 Create the SSH2 object calling L. =item 2 Configure the session if required. For instance, enabling compression or picking some specific encryption methods. =item 3 Establish the SSH connection calling the method L. =item 4 Check the remote host public key calling L. =item 5 Authenticate calling the required L. =item 6 Call L and related methods to create new bidirectional communication channels over the SSH connection. =item 7 Close the connection letting the Net::SSH2 object go out of scope or calling L explicitly. =back =head1 CONSTANTS All the constants defined in libssh2 can be imported from Net::SSH2. For instance: use Net::SSH2 qw(LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_HOSTKEY_POLICY_ASK); Though note that most methods accept the uncommon part of the constant name as a string. For instance the following two method calls are equivalent: $channel->ext_data(LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE); $channel->ext_data('merge'); Tags can be used to import the following constant subsets: callback channel error socket trace hash method disconnect policy fx fxf sftp The tag C can also be used to import all of them. =head1 METHODS =head2 new ( %options ) Create new Net::SSH2 object representing a SSH session. The accepted options are as follows: =over 4 =item timeout Sets the default timeout in milliseconds. See L. =item trace Sets tracing. See L. Example: my $ssh2 = Net::SSH2->new(trace => -1); Note that tracing requires a version of libssh2 compiled with debugging support. =item debug Enable debugging. See L. =item compress Sets flag C. See L. =item sigpipe Sets flag C. See L. =back =head2 banner ( text ) Set the SSH2 banner text sent to the remote host (prepends required "SSH-2.0-"). =head2 version In scalar context, returns libssh2 version/patch e.g. 0.18 or "0.18.0-20071110". In list context, returns that version plus the numeric version (major, minor, and patch, each encoded as 8 bits, e.g. 0x001200 for version 0.18) and the default banner text (e.g. "SSH-2.0-libssh2_0.18.0-20071110"). =head2 error Returns the last error code. In list context, returns (code, error name, error string). Note that the returned error value is only meaningful after some other method indicates an error by returning false. =head2 die_with_error ( [message] ) Calls C with the given message and the error information from the object appended. For instance: $ssh2->connect("ajhkfhdklfjhklsjhd", 22) or $ssh2->die_with_error; # dies as: # Unable to connect to remote host: Invalid argument (-1 LIBSSH2_ERROR_SOCKET_NONE) =head2 sock Returns a reference to the underlying L object (usually a derived class as L or L), or C if not yet connected. =head2 trace Calls C with supplied bitmask. In order to enable all tracing pass C<-1> as follows: $ssh2->trace(-1); A version of libssh2 compiled with tracing support is required. =head2 timeout ( timeout_ms ) Enables a global timeout (in milliseconds) which will affect every action (requires libssh2 1.2.9 or later). By default, or if you set the timeout to zero, Net::SSH2 has no timeout. Note that timeout errors may leave the SSH connection in an inconsistent state and further operations may fail or behave incorrectly. Actually, some methods are able to recover after a timeout error and others are not. I =head2 method ( type [, values... ] ) Sets or gets a method preference. For get, pass in the type only; to set, pass in either a list of values or a comma-separated string. Values can only be queried after the session is connected. The following methods can be set or queried: =over 4 =item LIBSSH2_METHOD_KEX Key exchange method names. Supported values: =over 4 =item diffie-hellman-group1-sha1 Diffie-Hellman key exchange with SHA-1 as hash, and Oakley Group 2 (see RFC 2409). =item diffie-hellman-group14-sha1 Diffie-Hellman key exchange with SHA-1 as hash, and Oakley Group 14 (see RFC 3526). =item diffie-hellman-group-exchange-sha1 Diffie-Hellman key exchange with SHA-1 as hash, using a safe-prime/generator pair (chosen by server) of arbitrary strength (specified by client) (see IETF draft secsh-dh-group-exchange). =back =item LIBSSH2_METHOD_HOSTKEY Public key algorithms. Supported values: =over 4 =item ssh-dss Based on the Digital Signature Standard (FIPS-186-2). =item ssh-rsa Based on PKCS#1 (RFC 3447). =back =item LIBSSH2_METHOD_CRYPT_CS Encryption algorithm from client to server. Supported algorithms: =over 4 =item aes256-cbc AES in CBC mode, with 256-bit key. =item rijndael-cbc@lysator.liu.se Alias for aes256-cbc. =item aes192-cbc AES in CBC mode, with 192-bit key. =item aes128-cbc AES in CBC mode, with 128-bit key. =item blowfish-cbc Blowfish in CBC mode. =item arcfour ARCFOUR stream cipher. =item cast128-cbc CAST-128 in CBC mode. =item 3des-cbc Three-key 3DES in CBC mode. =item none No encryption. =back =item LIBSSH2_METHOD_CRYPT_SC Encryption algorithm from server to client. See the C entry above for supported algorithms. =item LIBSSH2_METHOD_MAC_CS Message Authentication Code (MAC) algorithms from client to server. Supported values: =over 4 =item hmac-sha1 SHA-1 with 20-byte digest and key length. =item hmac-sha1-96 SHA-1 with 20-byte key length and 12-byte digest length. =item hmac-md5 MD5 with 16-byte digest and key length. =item hmac-md5-96 MD5 with 16-byte key length and 12-byte digest length. =item hmac-ripemd160 RIPEMD-160 algorithm with 20-byte digest length. =item hmac-ripemd160@openssh.com Alias for hmac-ripemd160. =item none No encryption. =back =item LIBSSH2_METHOD_MAC_SC Message Authentication Code (MAC) algorithms from server to client. See L for supported algorithms. =item LIBSSH2_METHOD_COMP_CS Compression methods from client to server. Supported values: =over 4 =item zlib The "zlib" compression method as described in RFC 1950 and RFC 1951. =item none No compression =back =item LIBSSH2_METHOD_COMP_SC Compression methods from server to client. See L for supported compression methods. =back =head2 connect ( handle | host [, port]) The argument combinations accepted are as follows: =over 4 =item a glob or C object reference Note that tied file handles are not acceptable. The underlying libssh2 requires real file handles. =item host [, port] In order to handle IPv6 addresses the optional module L is required. The port number defaults to 22. =back This method used to accept a C argument. That feature has been replaced by the constructor C option but note that it takes milliseconds instead of seconds! =head2 disconnect ( [description [, reason [, language]]] ) Sends a clean disconnect message to the remote server. Default values are empty strings for description and language, and C for the reason. =head2 hostname The name of the remote host given at connect time or retrieved from the TCP layer. =head2 port The port number of the remote SSH server. =head2 hostkey_hash ( hash type ) Returns a hash of the host key; note that the key is raw data and may contain nulls or control characters. The type may be as follows: =over 4 =item LIBSSH2_HOSTKEY_HASH_MD5 MD5 hash, 16 bytes long (requires libssh2 compiled with MD5 support). =item LIBSSH2_HOSTKEY_HASH_SHA1 SHA1 hash, 20 bytes long. =back Note: in previous versions of the module this method was called C. =head2 remote_hostkey Returns the public key from the remote host and its type which is one of C, C, or C. =head2 check_hostkey( [policy, [known_hosts_path [, comment] ] ] ) Looks for the remote host key inside the given known host file (defaults to C<~/.ssh/known_hosts>). On success, this method returns the result of the call done under the hood to C (i.e. C, C, C or C). On failure it returns C. The accepted policies are as follows: =over 4 =item LIBSSH2_HOSTKEY_POLICY_STRICT Only host keys already present in the known hosts file are accepted. This is the default policy. =item LIBSSH2_HOSTKEY_POLICY_ASK If the host key is not present in the known hosts file, the user is asked if it should be accepted or not. If accepted, the key is added to the known host file with the given comment. =item LIBSSH2_HOSTKEY_POLICY_TOFU Trust On First Use: if the host key is not present in the known hosts file, it is added there and accepted. =item LIBSSH2_HOSTKEY_POLICY_ADVISORY The key is always accepted, but it is never saved into the known host file. =item callback If a reference to a subroutine is given, it is called when the key is not present in the known hosts file or a different key is found. The arguments passed to the callback are the session object, the matching error (C, C or C) and the comment. =back =head2 auth_list ( [username] ) Returns the authentication methods accepted by the server. In scalar context the methods are returned as a comma separated string. When the server accepted an unauthenticated session for the given username, this method returns C but L returns true. =head2 auth_ok Returns true when the session is authenticated. =head2 auth_password ( username [, password [, callback ]] ) Authenticates using a password. If the password has expired, if a callback code reference was given, it's called as C and should return a password. If no callback is provided, LIBSSH2_ERROR_PASSWORD_EXPIRED is returned. =head2 auth_password_interact ( username [, callback]) Prompts the user for the password interactively (requires L). =head2 auth_publickey ( username, publickey_path, privatekey_path [, passphrase ] ) Authenticate using the given private key and an optional passphrase. When libssh2 is compiled using OpenSSL as the crypto backend, passing this method C as the public key argument is acceptable (OpenSSL is able to extract the public key from the private one). =head2 auth_publickey_frommemory ( username, publickey_blob, privatekey_blob [, passphrase ] ) Authenticate using the given public/private key and an optional passphrase. The keys must be PEM encoded (requires libssh2 1.6.0 or later with the OpenSSL backend). =head2 auth_hostbased ( username, publickey, privatekey, hostname, [, local username [, passphrase ]] ) Host-based authentication using an optional passphrase. The local username defaults to be the same as the remote username. =head2 auth_keyboard ( username, password | callback ) Authenticate using C. Takes either a password, or a callback code reference which is invoked as C(self, username, name, instruction, prompt...)> (where each prompt is a hash with C and C keys, signifying the prompt text and whether the user input should be echoed, respectively) which should return an array of responses. If only a username is provided, the default callback will handle standard interactive responses (requires L) =head2 auth_agent ( username ) Try to authenticate using an SSH agent (requires libssh2 1.2.3). =head2 auth ( ... ) This is a general, prioritizing authentication mechanism that can use any of the previous methods. You provide it some parameters and (optionally) a ranked list of methods you want considered (defaults to all). It will remove any unsupported methods or methods for which it doesn't have parameters (e.g. if you don't give it a public key, it can't use publickey or hostkey), and try the rest, returning whichever one succeeded or C if they all failed. If a parameter is passed with an C value, a default value will be supplied if possible. The parameters are: =over 4 =item rank An optional ranked list of methods to try. The names should be the names of the L C methods, e.g. C or C, with the addition of C for automated C and C which prompts the user for the password interactively. =item username =item password =item publickey =item privatekey C and C are file paths. =item passphrase =item hostname =item local_username =item interact If this option is set to a true value, interactive methods will be enabled. =item fallback If a password is given but authentication using it fails, the module will fall back to ask the user for another password if this parameter is set to a true value. =item cb_keyboard L callback. =item cb_password L callback. =back For historical reasons and in order to maintain backward compatibility with older versions of the module, when the C argument is given, it is also used as the passphrase (and a deprecation warning generated). In order to avoid that behaviour the C argument must be also passed (it could be C). For instance: $ssh2->auth(username => $user, privatekey => $privatekey_path, publickey => $publickey_path, password => $password, passphrase => undef); This work around will be removed in a not too distant future version of the module. =head2 flag (key, value) Sets the given session flag. The currently supported flag values are: =over 4 =item LIBSSH2_FLAG_COMPRESS If set before the connection negotiation is performed, compression will be negotiated for this connection. Compression can also be enabled passing option C to the constructor L. =item LIBSSH2_FLAG_SIGPIPE if set, Net::SSH2/libssh2 will not attempt to block SIGPIPEs but will let them trigger from the underlying socket layer. =back =head2 keepalive_config(want_reply, interval) Set how often keepalive messages should be sent. C indicates whether the keepalive messages should request a response from the server. C is number of seconds that can pass without any I/O. =head2 keepalive_send Send a keepalive message if needed. On failure returns undef. On success returns how many seconds you can sleep after this call before you need to call it again. Note that the underlying libssh2 function C can not recover from EAGAIN errors. If this method fails with such error, the SSH connection may become corrupted. The usage of this function is discouraged. =head2 channel ( [type, [window size, [packet size]]] ) Creates and returns a new channel object. See L. Type, if given, must be C (a reminiscence of an old, more generic, but never working wrapping). =head2 tcpip ( host, port [, shost, sport ] ) Creates a TCP connection from the remote host to the given host:port, returning a new channel. The C and C arguments are merely informative and passed to the remote SSH server as the origin of the connection. They default to 127.0.0.1:22. Note that this method does B open a new port on the local machine and forwards incoming connections to the remote side. =head2 listen ( port [, host [, bound port [, queue size ]]] ) Sets up a TCP listening port on the remote host. Host defaults to 0.0.0.0; if bound port is provided, it should be a scalar reference in which the bound port is returned. Queue size specifies the maximum number of queued connections allowed before the server refuses new connections. Returns a new Net::SSH2::Listener object. =head2 scp_get ( remote_path [, local_path ] ) Retrieve a file with SCP. Local path defaults to basename of remote. Alternatively, C may be an already open file handle or an IO::Handle object (e.g. IO::File, IO::Scalar). =head2 scp_put ( local_path [, remote_path ] ) Send a file with SCP. Remote path defaults to same as local. Alternatively, C may be an already open file handle or a reference to a IO::Handle object (it must have a valid stat method). =head2 sftp Return SecureFTP interface object (see L). Note that SFTP support in libssh2 is pretty rudimentary. You should consider using L with the L backend L instead. =head2 public_key Return public key interface object (see L). =head2 known_hosts Returns known hosts interface object (see L). =head2 poll ( timeout, arrayref of hashes ) B: the poll functionality in libssh2 is deprecated and its usage disregarded. Session methods L and L can be used instead to integrate Net::SSH2 inside an external event loop. Pass in a timeout in milliseconds and an arrayref of hashes with the following keys: =over 4 =item handle May be a L or L object, integer file descriptor, or perl file handle. =item events Requested events. Combination of LIBSSH2_POLLFD_* constants (with the POLL prefix stripped if present), or an arrayref of the names ('in', 'hup' etc.). =item revents Returned events. Returns a hash with the (lowercased) names of the received events ('in', 'hup', etc.) as keys with true values, and a C key with the integer value. =back Returns undef on error, or the number of active objects. =head2 block_directions Get the blocked direction after some method returns C. Returns C or/and C. =head2 debug ( state ) Class method (affects all Net::SSH2 objects). Pass 1 to enable, 0 to disable. Debug output is sent to C. =head2 blocking ( flag ) Enable or disable blocking. A good number of the methods in Net::SSH2/libssh2 can not work in non-blocking mode. Some of them may just forcibly enable blocking during its execution. A few may even corrupt the SSH session or crash the program. The ones that can be safely called are C and, with some caveats, C. See L. I =head1 SEE ALSO L, L, L, L, L. LibSSH2 documentation at L. IETF Secure Shell (secsh) working group at L. L and L integrate nicely with Net::SSH2. Other Perl modules related to SSH you may find interesting: L, L, L, L. =head1 COPYRIGHT AND LICENSE Copyright (C) 2005 - 2010 by David B. Robins (dbrobins@cpan.org). Copyright (C) 2010 - 2016 by Rafael Kitover (rkitover@cpan.org). Copyright (C) 2011 - 2018 by Salvador FandiEo (salva@cpan.org). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. =cut Net-SSH2-0.69/ppport.h0000644000175000017500000054004513033750102013410 0ustar salvasalva#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.20 Automatically created by Devel::PPPort running under perl 5.012004. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.20 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.11.5. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2010, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.20; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| BhkDISABLE||5.014000| BhkENABLE||5.014000| BhkENTRY_set||5.014000| BhkENTRY||| BhkFLAGS||| CALL_BLOCK_HOOKS||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.010001||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||5.011000| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.010001| HeVAL||5.004000| HvENAME||5.013007| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LINKLIST||5.013006| LVRET||| MARK||| MULTICALL||5.014000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| OP_CLASS||5.013007| OP_DESC||5.007003| OP_NAME||5.007003| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.014000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.014000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.014000||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.014000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.014000||p PL_bufptr|5.014000||p PL_compiling|5.004050||p PL_copline|5.014000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.014000||p PL_expect|5.014000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.014000||p PL_in_my|5.014000||p PL_keyword_plugin||5.011002| PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.014000||p PL_lex_stuff|5.014000||p PL_linestr|5.014000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_opfreehook||5.011000|n PL_parser|5.009005|5.009005|p PL_peepp||5.007003|n PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rpeepp||5.013005|n PL_rsfp_filters|5.014000||p PL_rsfp|5.014000||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.014000||p POP_MULTICALL||5.014000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.014000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_nomg||5.013002| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg_nolen||5.013007| SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE_nomg||5.013006| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.014000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_APIVERSION_BOOTCHECK||5.013004| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| XopDISABLE||5.014000| XopENABLE||5.014000| XopENTRY_set||5.014000| XopENTRY||5.014000| XopFLAGS||5.013007| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _append_range_to_invlist||| _new_invlist||| _pMY_CXT|5.007003||p _swash_inversion_hash||| _swash_to_invlist||| aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.014000||p aTHXR|5.014000||p aTHX_|5.006000||p aTHX|5.006000||p add_alternate||| add_cp_to_invlist||| add_data|||n add_range_to_invlist||| add_utf16_textfilter||| addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_deref_call||5.013007| amagic_i_ncmp||| amagic_ncmp||| anonymise_cv_maybe||| any_dup||| ao||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| assert_uft8_cache_coherent||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| blockhook_register||5.013003| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_cmp_utf8||5.013007| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p caller_cx||5.013005| calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| check_utf8_print||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_entersub_args_list||5.013006| ck_entersub_args_proto_or_list||5.013006| ck_entersub_args_proto||5.013006| ck_warner_d||5.011001|v ck_warner||5.011001|v ckwarn_common||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| clone_params_del|||n clone_params_new|||n closest_cop||| convert||| cop_free||| cop_hints_2hv||5.013007| cop_hints_fetch_pvn||5.013007| cop_hints_fetch_pvs||5.013007| cop_hints_fetch_pv||5.013007| cop_hints_fetch_sv||5.013007| cophh_2hv||5.013007| cophh_copy||5.013007| cophh_delete_pvn||5.013007| cophh_delete_pvs||5.013007| cophh_delete_pv||5.013007| cophh_delete_sv||5.013007| cophh_fetch_pvn||5.013007| cophh_fetch_pvs||5.013007| cophh_fetch_pv||5.013007| cophh_fetch_sv||5.013007| cophh_free||5.013007| cophh_new_empty||5.014000| cophh_store_pvn||5.013007| cophh_store_pvs||5.013007| cophh_store_pv||5.013007| cophh_store_sv||5.013007| cr_textfilter||| create_eval_scope||| croak_no_modify||5.013003| croak_nocontext|||vn croak_sv||5.013001| croak_xs_usage||5.010001| croak|||v csighandler||5.009003|n curmad||| curse||| custom_op_desc||5.007003| custom_op_name||5.007003| custom_op_register||5.013007| custom_op_xop||5.013007| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_get_call_checker||5.013006| cv_set_call_checker||5.013006| cv_undef||| cvgv_set||| cvstash_set||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.014000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000|n deprecate_commaless_var_list||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_sv||5.013001| die_unwind||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_close||| do_delete_local||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all_perl||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs_perl||| dump_packsubs||5.006000| dump_sub_perl||| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_rundefsv||5.013002| find_script||| find_uninit_var||| first_symbol|||n foldEQ_latin1||5.013008|n foldEQ_locale||5.013002|n foldEQ_utf8_flags||5.013010| foldEQ_utf8||5.013002| foldEQ||5.013002|n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_strict_version||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags|5.009005||p get_cvs|5.011000||p get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_bslash_c||| grok_bslash_o||| grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_add_by_type||5.011000| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv|5.009002||p gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_magicalize_isa||| gv_magicalize_overload||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| gv_try_downgrade||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||5.009004| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_ename_add||| hv_ename_delete||| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_fill||5.013002| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef_flags||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_dbargs||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr|||n intro_my||| intuit_method||| intuit_more||| invert||| invlist_array||| invlist_destroy||| invlist_extend||| invlist_intersection||| invlist_len||| invlist_max||| invlist_set_array||| invlist_set_len||| invlist_set_max||| invlist_trim||| invlist_union||| invoke_exception_hook||| io_close||| isALNUMC|5.006000||p isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isOCTAL||5.013005| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isWORDCHAR||5.013006| isXDIGIT|5.006000||p is_an_int||| is_ascii_string||5.011000|n is_gv_magical_sv||| is_handle_constructor|||n is_inplace_av||| is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_X_LVT||| is_utf8_X_LV_LVT_V||| is_utf8_X_LV||| is_utf8_X_L||| is_utf8_X_T||| is_utf8_X_V||| is_utf8_X_begin||| is_utf8_X_extend||| is_utf8_X_non_hangul||| is_utf8_X_prepend||| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000|n is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_perl_space||5.011001| is_utf8_perl_word||5.011001| is_utf8_posix_digit||5.011001| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003|n is_utf8_string_loc||5.008001|n is_utf8_string||5.006001|n is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| is_utf8_xidcont||5.013010| is_utf8_xidfirst||5.013010| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword_plugin_standard||| keyword||| leave_scope||| lex_bufutf8||5.011002| lex_discard_to||5.011002| lex_grow_linestr||5.011002| lex_next_chunk||5.011002| lex_peek_unichar||5.011002| lex_read_space||5.011002| lex_read_to||5.011002| lex_read_unichar||5.011002| lex_start||5.009005| lex_stuff_pvn||5.011002| lex_stuff_pvs||5.013005| lex_stuff_pv||5.013006| lex_stuff_sv||5.011002| lex_unstuff||5.011002| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.010001||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.010001||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhints||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall1||| magic_methcall|||v magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQs|5.009005||p memEQ|5.004000||p memNEs|5.009005||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess_sv||5.013001| mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_findext||5.013008| mg_find||| mg_free_type||5.013006| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_clean_isarev||| mro_gather_and_rename||| mro_get_from_name||5.010001| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.010001| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_package_moved||| mro_register||5.010001| mro_set_mro||5.010001| mro_set_private_data||5.010001| mul128||| mulexp10|||n munge_qwlist_to_paren_list||| my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat_flags||| my_lstat||5.014000| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat_flags||| my_stat||5.014000| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||5.013007| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpv_share||5.013006| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.010001||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.010001||p newSVpvn|5.004050||p newSVpvs_flags|5.010001||p newSVpvs_share|5.009003||p newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.013007| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr|||n no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n oopsAV||| oopsHV||| op_append_elem||5.013006| op_append_list||5.013006| op_clear||| op_const_sv||| op_contextualize||5.013006| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_linklist||5.013006| op_lvalue||5.013007| op_null||5.007002| op_prepend_elem||5.013006| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_scope||5.013007| op_xmldump||| open_script||| opt_scalarhv||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package_version||| package||| packlist||5.008001| pad_add_anon||| pad_add_name_sv||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||5.011002| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||| pad_swipe||| pad_tidy||| padlist_dup||| parse_arithexpr||5.013008| parse_barestmt||5.013007| parse_block||5.013007| parse_body||| parse_fullexpr||5.013008| parse_fullstmt||5.013005| parse_label||5.013007| parse_listexpr||5.013008| parse_stmtseq||5.013006| parse_termexpr||5.013008| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| populate_isa|||v pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_madprops||| prescan_version||5.011004| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch_pvn||| refcounted_he_fetch_pvs||| refcounted_he_fetch_pv||| refcounted_he_fetch_sv||| refcounted_he_free||| refcounted_he_inc||| refcounted_he_new_pvn||| refcounted_he_new_pvs||| refcounted_he_new_pv||| refcounted_he_new_sv||| refcounted_he_value||| refkids||| refto||| ref||5.014000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly||| regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy|||n report_evil_fh||| report_uninit||| report_wrongway_fh||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr|||n rpeep||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rv2cv_op_cv||5.013006| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem_flags||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hdelete||5.011000| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||5.010001| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||5.005000| save_padsv_and_mortalize||5.010001| save_pptr||| save_pushi32ptr||5.010001| save_pushptri32ptr||| save_pushptrptr||5.010001| save_pushptr||5.010001| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpvs||5.013006| savesharedpv||5.007003| savesharedsvpv||5.013006| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| set_regclass_bit_fold||| set_regclass_bit||| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.014000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool_flags||5.013006| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv_flags||5.013001| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_flags||5.013006| sv_catpv_mg|5.004050||p sv_catpv_nomg||5.013006| sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs_flags||5.013006| sv_catpvs_mg||5.013006| sv_catpvs_nomg||5.013006| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlpv||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_flags||5.013006| sv_cmp_locale_flags||5.013006| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm_flags||5.013006| sv_collxfrm||| sv_compile_2op_is_broken||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec_nomg||5.013002| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_common||| sv_dup_inc_multiple||| sv_dup_inc||| sv_dup||| sv_eq_flags||5.013006| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc_nomg||5.013002| sv_inc||| sv_insert_flags||5.010001| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.014000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_flags||5.011005| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs_mg||5.013006| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pvs||5.013006| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagicext||5.013008| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tied_method|||v tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| try_amagic_bin||| try_amagic_un||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unreferenced_to_tmp_stack||| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_textfilter||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_len_cache_update||| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warn_sv||5.013001| warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| with_queued_errors||| write_no_mem||| write_to_stderr||| xmldump_all_perl||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs_perl||| xmldump_packsubs||| xmldump_sub_perl||| xmldump_sub||| xmldump_vindent||| xs_apiversion_bootcheck||| xs_version_bootcheck||| yyerror||| yylex||| yyparse||| yyunlex||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((U8) (c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((U8) (c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ Net-SSH2-0.69/inc/0000755000175000017500000000000013244346650012471 5ustar salvasalvaNet-SSH2-0.69/inc/Module/0000755000175000017500000000000013244346650013716 5ustar salvasalvaNet-SSH2-0.69/inc/Module/Install/0000755000175000017500000000000013244346650015324 5ustar salvasalvaNet-SSH2-0.69/inc/Module/Install/CheckLib.pm0000644000175000017500000000264613244346622017335 0ustar salvasalva#line 1 package Module::Install::CheckLib; use strict; use warnings; use File::Spec; use base qw(Module::Install::Base); use vars qw($VERSION); $VERSION = '0.12'; sub checklibs { my $self = shift; return unless scalar @_; my %parms = @_; unless (_author_side(delete $parms{run_checks_as_author})) { require Devel::CheckLib; Devel::CheckLib::check_lib_or_exit( %parms ); return; } } sub assertlibs { my $self = shift; return unless scalar @_; my %parms = @_; unless (_author_side(delete $parms{run_checks_as_author})) { require Devel::CheckLib; Devel::CheckLib::assert_lib( %parms ); return; } } sub _author_side { my $run_checks_as_author = shift; if ($Module::Install::AUTHOR) { mkdir 'inc'; mkdir 'inc/Devel'; print "Extra directories created under inc/\n"; require Devel::CheckLib; local $/ = undef; open(CHECKLIBPM, $INC{'Devel/CheckLib.pm'}) || die("Can't read $INC{'Devel/CheckLib.pm'}: $!"); (my $checklibpm = ) =~ s/package Devel::CheckLib/package #\nDevel::CheckLib/; close(CHECKLIBPM); open(CHECKLIBPM, '>'.File::Spec->catfile(qw(inc Devel CheckLib.pm))) || die("Can't write inc/Devel/CheckLib.pm: $!"); print CHECKLIBPM $checklibpm; close(CHECKLIBPM); print "Copied Devel::CheckLib to inc/ directory\n"; return !$run_checks_as_author; } return 0; } 'All your libs are belong'; __END__ #line 132 Net-SSH2-0.69/inc/Module/Install/Makefile.pm0000644000175000017500000002743713244346622017413 0ustar salvasalva#line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 Net-SSH2-0.69/inc/Module/Install/Can.pm0000644000175000017500000000640513244346623016370 0ustar salvasalva#line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; if ($^O eq 'VMS') { require ExtUtils::CBuilder; my $builder = ExtUtils::CBuilder->new( quiet => 1, ); return $builder->have_compiler; } my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 245 Net-SSH2-0.69/inc/Module/Install/Win32.pm0000644000175000017500000000340313244346623016564 0ustar salvasalva#line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; Net-SSH2-0.69/inc/Module/Install/Metadata.pm0000644000175000017500000004330213244346622017403 0ustar salvasalva#line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic => 'http://opensource.org/licenses/artistic-license.php', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; Net-SSH2-0.69/inc/Module/Install/WriteAll.pm0000644000175000017500000000237613244346623017415 0ustar salvasalva#line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1; Net-SSH2-0.69/inc/Module/Install/Base.pm0000644000175000017500000000214713244346622016537 0ustar salvasalva#line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.17'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159 Net-SSH2-0.69/inc/Module/Install/Fetch.pm0000644000175000017500000000462713244346623016724 0ustar salvasalva#line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.17'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; Net-SSH2-0.69/inc/Module/Install.pm0000644000175000017500000002714513244346622015672 0ustar salvasalva#line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.006; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.17'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS'; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( {no_chdir => 1, wanted => sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($File::Find::name); my $in_pod = 0; foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }}, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. Net-SSH2-0.69/inc/Devel/0000755000175000017500000000000013244346650013530 5ustar salvasalvaNet-SSH2-0.69/inc/Devel/CheckLib.pm0000644000175000017500000004545413244346622015545 0ustar salvasalva# $Id: CheckLib.pm,v 1.25 2008/10/27 12:16:23 drhyde Exp $ package # Devel::CheckLib; use 5.00405; #postfix foreach use strict; use vars qw($VERSION @ISA @EXPORT); $VERSION = '1.07'; use Config qw(%Config); use Text::ParseWords 'quotewords'; use File::Spec; use File::Temp; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(assert_lib check_lib_or_exit check_lib); # localising prevents the warningness leaking out of this module local $^W = 1; # use warnings is a 5.6-ism _findcc(); # bomb out early if there's no compiler =head1 NAME Devel::CheckLib - check that a library is available =head1 DESCRIPTION Devel::CheckLib is a perl module that checks whether a particular C library and its headers are available. =head1 SYNOPSIS use Devel::CheckLib; check_lib_or_exit( lib => 'jpeg', header => 'jpeglib.h' ); check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] ); # or prompt for path to library and then do this: check_lib_or_exit( lib => 'jpeg', libpath => $additional_path ); =head1 USING IT IN Makefile.PL or Build.PL If you want to use this from Makefile.PL or Build.PL, do not simply copy the module into your distribution as this may cause problems when PAUSE and search.cpan.org index the distro. Instead, use the use-devel-checklib script. =head1 HOW IT WORKS You pass named parameters to a function, describing to it how to build and link to the libraries. It works by trying to compile some code - which defaults to this: int main(int argc, char *argv[]) { return 0; } and linking it to the specified libraries. If something pops out the end which looks executable, it gets executed, and if main() returns 0 we know that it worked. That tiny program is built once for each library that you specify, and (without linking) once for each header file. If you want to check for the presence of particular functions in a library, or even that those functions return particular results, then you can pass your own function body for main() thus: check_lib_or_exit( function => 'foo();if(libversion() > 5) return 0; else return 1;' incpath => ... libpath => ... lib => ... header => ... ); In that case, it will fail to build if either foo() or libversion() don't exist, and main() will return the wrong value if libversion()'s return value isn't what you want. =head1 FUNCTIONS All of these take the same named parameters and are exported by default. To avoid exporting them, C. =head2 assert_lib This takes several named parameters, all of which are optional, and dies with an error message if any of the libraries listed can not be found. B: dying in a Makefile.PL or Build.PL may provoke a 'FAIL' report from CPAN Testers' automated smoke testers. Use C instead. The named parameters are: =over =item lib Must be either a string with the name of a single library or a reference to an array of strings of library names. Depending on the compiler found, library names will be fed to the compiler either as C<-l> arguments or as C<.lib> file names. (E.g. C<-ljpeg> or C) =item libpath a string or an array of strings representing additional paths to search for libraries. =item LIBS a C-style space-separated list of libraries (each preceded by '-l') and directories (preceded by '-L'). This can also be supplied on the command-line. =item debug If true - emit information during processing that can be used for debugging. =back And libraries are no use without header files, so ... =over =item header Must be either a string with the name of a single header file or a reference to an array of strings of header file names. =item incpath a string or an array of strings representing additional paths to search for headers. =item INC a C-style space-separated list of incpaths, each preceded by '-I'. This can also be supplied on the command-line. =item ccflags Extra flags to pass to the compiler. =item ldflags Extra flags to pass to the linker. =item analyze_binary a callback function that will be invoked in order to perform custom analysis of the generated binary. The callback arguments are the library name and the path to the binary just compiled. It is possible to use this callback, for instance, to inspect the binary for further dependencies. =back =head2 check_lib_or_exit This behaves exactly the same as C except that instead of dieing, it warns (with exactly the same error message) and exits. This is intended for use in Makefile.PL / Build.PL when you might want to prompt the user for various paths and things before checking that what they've told you is sane. If any library or header is missing, it exits with an exit value of 0 to avoid causing a CPAN Testers 'FAIL' report. CPAN Testers should ignore this result -- which is what you want if an external library dependency is not available. =head2 check_lib This behaves exactly the same as C except that it is silent, returning false instead of dieing, or true otherwise. =cut sub check_lib_or_exit { eval 'assert_lib(@_)'; if($@) { warn $@; exit; } } sub check_lib { eval 'assert_lib(@_)'; return $@ ? 0 : 1; } # borrowed from Text::ParseWords sub _parse_line { my($delimiter, $keep, $line) = @_; my($word, @pieces); no warnings 'uninitialized'; # we will be testing undef strings while (length($line)) { # This pattern is optimised to be stack conservative on older perls. # Do not refactor without being careful and testing it on very long strings. # See Perl bug #42980 for an example of a stack busting input. $line =~ s/^ (?: # double quoted string (") # $quote ((?>[^\\"]*(?:\\.[^\\"]*)*))" # $quoted | # --OR-- # singe quoted string (') # $quote ((?>[^\\']*(?:\\.[^\\']*)*))' # $quoted | # --OR-- # unquoted string ( # $unquoted (?:\\.|[^\\"'])*? ) # followed by ( # $delim \Z(?!\n) # EOL | # --OR-- (?-x:$delimiter) # delimiter | # --OR-- (?!^)(?=["']) # a quote ) )//xs or return; # extended layout my ($quote, $quoted, $unquoted, $delim) = (($1 ? ($1,$2) : ($3,$4)), $5, $6); return() unless( defined($quote) || length($unquoted) || length($delim)); if ($keep) { $quoted = "$quote$quoted$quote"; } else { $unquoted =~ s/\\(.)/$1/sg; if (defined $quote) { $quoted =~ s/\\(.)/$1/sg if ($quote eq '"'); } } $word .= substr($line, 0, 0); # leave results tainted $word .= defined $quote ? $quoted : $unquoted; if (length($delim)) { push(@pieces, $word); push(@pieces, $delim) if ($keep eq 'delimiters'); undef $word; } if (!length($line)) { push(@pieces, $word); } } return(@pieces); } sub assert_lib { my %args = @_; my (@libs, @libpaths, @headers, @incpaths); # FIXME: these four just SCREAM "refactor" at me @libs = (ref($args{lib}) ? @{$args{lib}} : $args{lib}) if $args{lib}; @libpaths = (ref($args{libpath}) ? @{$args{libpath}} : $args{libpath}) if $args{libpath}; @headers = (ref($args{header}) ? @{$args{header}} : $args{header}) if $args{header}; @incpaths = (ref($args{incpath}) ? @{$args{incpath}} : $args{incpath}) if $args{incpath}; my $analyze_binary = $args{analyze_binary}; my @argv = @ARGV; push @argv, _parse_line('\s+', 0, $ENV{PERL_MM_OPT}||''); # work-a-like for Makefile.PL's LIBS and INC arguments # if given as command-line argument, append to %args for my $arg (@argv) { for my $mm_attr_key (qw(LIBS INC)) { if (my ($mm_attr_value) = $arg =~ /\A $mm_attr_key = (.*)/x) { # it is tempting to put some \s* into the expression, but the # MM command-line parser only accepts LIBS etc. followed by =, # so we should not be any more lenient with whitespace than that $args{$mm_attr_key} .= " $mm_attr_value"; } } } # using special form of split to trim whitespace if(defined($args{LIBS})) { foreach my $arg (split(' ', $args{LIBS})) { die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-[lLR]/); push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2); } } if(defined($args{INC})) { foreach my $arg (split(' ', $args{INC})) { die("INC argument badly-formed: $arg\n") unless($arg =~ /^-I/); push @incpaths, substr($arg, 2); } } my ($cc, $ld) = _findcc($args{debug}, $args{ccflags}, $args{ldflags}); my @missing; my @wrongresult; my @wronganalysis; my @use_headers; # first figure out which headers we can't find ... for my $header (@headers) { push @use_headers, $header; my($ch, $cfile) = File::Temp::tempfile( 'assertlibXXXXXXXX', SUFFIX => '.c' ); my $ofile = $cfile; $ofile =~ s/\.c$/$Config{_o}/; print $ch qq{#include <$_>\n} for @use_headers; print $ch qq{int main(void) { return 0; }\n}; close($ch); my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe}; my @sys_cmd; # FIXME: re-factor - almost identical code later when linking if ( $Config{cc} eq 'cl' ) { # Microsoft compiler require Win32; @sys_cmd = ( @$cc, $cfile, "/Fe$exefile", (map { '/I'.Win32::GetShortPathName($_) } @incpaths), "/link", @$ld, split(' ', $Config{libs}), ); } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland @sys_cmd = ( @$cc, @$ld, (map { "-I$_" } @incpaths), "-o$exefile", $cfile ); } else { # Unix-ish: gcc, Sun, AIX (gcc, cc), ... @sys_cmd = ( @$cc, @$ld, $cfile, (map { "-I$_" } @incpaths), "-o", "$exefile" ); } warn "# @sys_cmd\n" if $args{debug}; my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd); push @missing, $header if $rv != 0 || ! -x $exefile; _cleanup_exe($exefile); unlink $cfile; } # now do each library in turn with headers my($ch, $cfile) = File::Temp::tempfile( 'assertlibXXXXXXXX', SUFFIX => '.c' ); my $ofile = $cfile; $ofile =~ s/\.c$/$Config{_o}/; print $ch qq{#include <$_>\n} foreach (@headers); print $ch "int main(int argc, char *argv[]) { ".($args{function} || 'return 0;')." }\n"; close($ch); for my $lib ( @libs ) { my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe}; my @sys_cmd; if ( $Config{cc} eq 'cl' ) { # Microsoft compiler require Win32; my @libpath = map { q{/libpath:} . Win32::GetShortPathName($_) } @libpaths; # this is horribly sensitive to the order of arguments @sys_cmd = ( @$cc, $cfile, "${lib}.lib", "/Fe$exefile", (map { '/I'.Win32::GetShortPathName($_) } @incpaths), "/link", @$ld, split(' ', $Config{libs}), (map {'/libpath:'.Win32::GetShortPathName($_)} @libpaths), ); } elsif($Config{cc} eq 'CC/DECC') { # VMS } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland @sys_cmd = ( @$cc, @$ld, "-o$exefile", (map { "-I$_" } @incpaths), (map { "-L$_" } @libpaths), "-l$lib", $cfile); } else { # Unix-ish # gcc, Sun, AIX (gcc, cc) @sys_cmd = ( @$cc, @$ld, $cfile, "-o", "$exefile", (map { "-I$_" } @incpaths), (map { "-L$_" } @libpaths), "-l$lib", ); } warn "# @sys_cmd\n" if $args{debug}; my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd); if ($rv != 0 || ! -x $exefile) { push @missing, $lib; } else { my $absexefile = File::Spec->rel2abs($exefile); $absexefile = '"'.$absexefile.'"' if $absexefile =~ m/\s/; if (system($absexefile) != 0) { push @wrongresult, $lib; } else { if ($analyze_binary) { push @wronganalysis, $lib if !$analyze_binary->($lib, $exefile) } } } _cleanup_exe($exefile); } unlink $cfile; my $miss_string = join( q{, }, map { qq{'$_'} } @missing ); die("Can't link/include C library $miss_string, aborting.\n") if @missing; my $wrong_string = join( q{, }, map { qq{'$_'} } @wrongresult); die("wrong result: $wrong_string\n") if @wrongresult; my $analysis_string = join(q{, }, map { qq{'$_'} } @wronganalysis ); die("wrong analysis: $analysis_string") if @wronganalysis; } sub _cleanup_exe { my ($exefile) = @_; my $ofile = $exefile; $ofile =~ s/$Config{_exe}$/$Config{_o}/; # List of files to remove my @rmfiles; push @rmfiles, $exefile, $ofile, "$exefile\.manifest"; if ( $Config{cc} eq 'cl' ) { # MSVC also creates foo.ilk and foo.pdb my $ilkfile = $exefile; $ilkfile =~ s/$Config{_exe}$/.ilk/; my $pdbfile = $exefile; $pdbfile =~ s/$Config{_exe}$/.pdb/; push @rmfiles, $ilkfile, $pdbfile; } foreach (@rmfiles) { if ( -f $_ ) { unlink $_ or warn "Could not remove $_: $!"; } } return } # return ($cc, $ld) # where $cc is an array ref of compiler name, compiler flags # where $ld is an array ref of linker flags sub _findcc { my ($debug, $user_ccflags, $user_ldflags) = @_; # Need to use $keep=1 to work with MSWin32 backslashes and quotes my $Config_ccflags = $Config{ccflags}; # use copy so ASPerl will compile my @Config_ldflags = (); for my $config_val ( @Config{qw(ldflags)} ){ push @Config_ldflags, $config_val if ( $config_val =~ /\S/ ); } my @ccflags = grep { length } quotewords('\s+', 1, $Config_ccflags||'', $user_ccflags||''); my @ldflags = grep { length } quotewords('\s+', 1, @Config_ldflags, $user_ldflags||''); my @paths = split(/$Config{path_sep}/, $ENV{PATH}); my @cc = split(/\s+/, $Config{cc}); if (check_compiler ($cc[0], $debug)) { return ( [ @cc, @ccflags ], \@ldflags ); } # Find the extension for executables. my $exe = $Config{_exe}; if ($^O eq 'cygwin') { $exe = ''; } foreach my $path (@paths) { # Look for "$path/$cc[0].exe" my $compiler = File::Spec->catfile($path, $cc[0]) . $exe; if (check_compiler ($compiler, $debug)) { return ([ $compiler, @cc[1 .. $#cc], @ccflags ], \@ldflags) } next if ! $exe; # Look for "$path/$cc[0]" without the .exe, if necessary. $compiler = File::Spec->catfile($path, $cc[0]); if (check_compiler ($compiler, $debug)) { return ([ $compiler, @cc[1 .. $#cc], @ccflags ], \@ldflags) } } die("Couldn't find your C compiler.\n"); } sub check_compiler { my ($compiler, $debug) = @_; if (-f $compiler && -x $compiler) { if ($debug) { warn("# Compiler seems to be $compiler\n"); } return 1; } return ''; } # code substantially borrowed from IPC::Run3 sub _quiet_system { my (@cmd) = @_; # save handles local *STDOUT_SAVE; local *STDERR_SAVE; open STDOUT_SAVE, ">&STDOUT" or die "CheckLib: $! saving STDOUT"; open STDERR_SAVE, ">&STDERR" or die "CheckLib: $! saving STDERR"; # redirect to nowhere local *DEV_NULL; open DEV_NULL, ">" . File::Spec->devnull or die "CheckLib: $! opening handle to null device"; open STDOUT, ">&" . fileno DEV_NULL or die "CheckLib: $! redirecting STDOUT to null handle"; open STDERR, ">&" . fileno DEV_NULL or die "CheckLib: $! redirecting STDERR to null handle"; # run system command my $rv = system(@cmd); # restore handles open STDOUT, ">&" . fileno STDOUT_SAVE or die "CheckLib: $! restoring STDOUT handle"; open STDERR, ">&" . fileno STDERR_SAVE or die "CheckLib: $! restoring STDERR handle"; return $rv; } =head1 PLATFORMS SUPPORTED You must have a C compiler installed. We check for C<$Config{cc}>, both literally as it is in Config.pm and also in the $PATH. It has been tested with varying degrees of rigorousness on: =over =item gcc (on Linux, *BSD, Mac OS X, Solaris, Cygwin) =item Sun's compiler tools on Solaris =item IBM's tools on AIX =item SGI's tools on Irix 6.5 =item Microsoft's tools on Windows =item MinGW on Windows (with Strawberry Perl) =item Borland's tools on Windows =item QNX =back =head1 WARNINGS, BUGS and FEEDBACK This is a very early release intended primarily for feedback from people who have discussed it. The interface may change and it has not been adequately tested. Feedback is most welcome, including constructive criticism. Bug reports should be made using L or by email. When submitting a bug report, please include the output from running: perl -V perl -MDevel::CheckLib -e0 =head1 SEE ALSO L L =head1 AUTHORS David Cantrell Edavid@cantrell.org.ukE David Golden Edagolden@cpan.orgE Yasuhiro Matsumoto Emattn@cpan.orgE Thanks to the cpan-testers-discuss mailing list for prompting us to write it in the first place; to Chris Williams for help with Borland support; to Tony Cook for help with Microsoft compiler command-line options =head1 COPYRIGHT and LICENCE Copyright 2007 David Cantrell. Portions copyright 2007 David Golden. This module is free-as-in-speech software, and may be used, distributed, and modified under the same conditions as perl itself. =head1 CONSPIRACY This module is also free-as-in-mason software. =cut 1; Net-SSH2-0.69/example/0000755000175000017500000000000013244346650013353 5ustar salvasalvaNet-SSH2-0.69/example/read.pl0000644000175000017500000000215113033750102014605 0ustar salvasalva#!perl use strict; use warnings; # Sample Net::SSH2 code illustrating several ways to read the remote # /etc/passwd file. use Net::SSH2; use IO::Scalar; my $ssh2 = Net::SSH2->new; $ssh2->connect('localhost') or $ssh2->die_with_error; $ssh2->check_hostkey('ask') or $ssh2->die_with_error; # use an interactive authentication method with default callback # (if a password is provided here, it will forward it without prompting) $ssh2->auth(username => scalar getpwuid($<), interact => 1) or $ssh2->die_with_error; sub _read { my $handle = shift; while (my $line = <$handle>) { chomp $line; $line =~ s/:.*$//; print "found user '$line'\n"; } } # (a) read using SCP my $passwd = IO::Scalar->new; die "can't fetch /etc/passwd" unless $ssh2->scp_get('/etc/passwd', $passwd); $passwd->seek(0, 0); _read($passwd); # (b) read a line at a time with SFTP my $sftp = $ssh2->sftp; my $file = $sftp->open('/etc/passwd') or $sftp->die_with_error; _read($file); # (c) type it over a channel my $chan = $ssh2->channel; $chan->exec('cat /etc/passwd') or die $ssh2->die_with_error; _read($chan); Net-SSH2-0.69/example/scat.pl0000644000175000017500000000172413033750102014631 0ustar salvasalva#!/usr/bin/perl use strict; use warnings; use Net::SSH2; use Getopt::Long; my ($host, $port, $user, $pwd); GetOptions("host|h=s" => \$host, "port|p=s" => \$port, "user|u=s" => \$user, "password|pwd|pw|w=s" => \$pwd) or die "Failed to process arguments"; $host // die "hostname missing"; $user //= getpwuid $<; $port //= '22'; my $ssh2 = Net::SSH2->new(); # $ssh2->debug(1); $ssh2->connect($host, $port) or $ssh2->die_with_error; $ssh2->check_hostkey or $ssh2->die_with_error; if ($pwd) { $ssh2->auth_password($user, $pwd); } else { $ssh2->auth_password_interact($user); } my $channel = $ssh2->channel or $ssh2->die_with_error; $channel->exec("cat @ARGV") # FIXME: quote the arguments! or $ssh2->die_with_error; $channel->send_eof; my $buffer; while (1) { $channel->read($buffer, 32*1024) or last; print $buffer; } my $exit_status = $channel->exit_status; undef $channel; $ssh2->disconnect; exit($exit_status); Net-SSH2-0.69/example/rt80011.pl0000644000175000017500000000145313033750102014715 0ustar salvasalva#!/usr/bin/perl use strict; use warnings; use Net::SSH2; use Getopt::Std; use IO::Scalar; use 5.010; my %opts = (h => 'localhost'); getopts('h:u:p:', \%opts); my ($hostname, $user, $password) = @opts{qw(h u p)}; my $fn = shift // die "filename argument missing"; sub ssh2_die { my $ssh2 = shift; die join(': ', @_, join('|', $ssh2->error)); } my $ssh2 = Net::SSH2->new(); $ssh2->connect($hostname) or ssh2_die($ssh2, "Unable to connect to host $hostname"); $ssh2->auth(username => $user, password => $password) or ssh2_die($ssh2, "Authentication failed"); my $chan = $ssh2->channel(); my $output = IO::Scalar->new; $ssh2->scp_get($fn, $output) or ssh2_die($ssh2, "SCP failed"); my $lines = $output =~ tr/\n/\n/; say "Number of lines in remote file: $lines\n"; $chan->close; $ssh2->disconnect(); Net-SSH2-0.69/example/rt58911.pl0000644000175000017500000000140413033750102014727 0ustar salvasalva#!/usr/bin/perl -W use strict; use Fcntl; use warnings FATAL => qw (all); use Getopt::Std; use Net::SSH2; use 5.010; my %opts = (h => 'localhost'); getopts('h:u:p:', \%opts); my ($hostname, $user, $password) = @opts{qw(h u p)}; my $fn = shift // die "filename argument missing"; my $ssh2 = Net::SSH2->new(); sub ssh2_die { die join(': ', @_, join('|', $ssh2->error)) } $ssh2->debug(1); $ssh2->connect($hostname) or ssh2_die("connect failed");; $ssh2->auth(username => $user, password => $password) or ssh2_die('auth failed'); my $sftp = $ssh2->sftp() or ssh2_die("sftp failed"); my $remote = $sftp->open($fn, O_WRONLY | O_CREAT | O_TRUNC); my $str = 'A' x 327480; my $bytes = print $remote $str; say "print returned $bytes, expected " . length($str); Net-SSH2-0.69/example/benchmark.pl0000644000175000017500000000765613033750102015643 0ustar salvasalva#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Sort::Key::Top qw(ntop); my $host = shift @ARGV // die "host missing"; my $local_iface = 'lxcbr0'; my $remote_iface = 'eth0'; my $rate_unit = 'Mbit'; my $size = 16 * 1024 * 1024; my $dd_bs = 16 * 1024; my $dd_count = int($size / $dd_bs); my $cmd = "dd bs=$dd_bs count=$dd_count if=/dev/zero 2>/dev/null"; my $read_size = 4 * 64 * 1024; my $n = 8; my $delay_min = 10; my $delay_max = 100; my $delay_steps = 5; my $delay_f = ($delay_max / $delay_min) ** (1 / ($delay_steps - 1)); my @delays = (0, map int(0.5 + $delay_min * $delay_f ** $_), 0 .. $delay_steps - 1); my @rates = (10, 20, 100, 200, 1000); use Time::HiRes qw(time); use Net::SSH2; use Net::OpenSSH; my $ssh2 = Net::SSH2->new(compress => 0); #$ssh2->trace(-1); $ssh2->connect($host) or $ssh2->die_with_error; my $key_path = scalar(<~/.ssh/id_rsa>); $ssh2->auth(username => undef, publickey => "$key_path.pub", privatekey => $key_path) or $ssh2->die_with_error; $ssh2->auth_ok or die "auth failed"; my $openssh = Net::OpenSSH->new($host, key_path => $key_path); $openssh->die_on_error; my %save; $| = 1; sub mean1 { my $n = int (0.5 + 0.66 * @_); my @n = ntop -$n, @_; my $acu = 0; $acu += $_ for @n; return $acu / @n; } sub test { my ($ssh, $rate, $delay, $ix) = @_; my ($name, $sub) = ($ssh->isa('Net::SSH2') ? (libssh2 => \&test_net_ssh2) : (openssh => \&test_net_openssh)); my ($dt, $total) = $sub->($ssh); my $speed = $total / $dt / 1024 / 1024; # MB/s printf("%s => ix: %s, delay: %dms, rate: %d%s time: %.2fs, speed: %.2fMB/s\n", $name, $ix, $delay, $rate, $rate_unit, $dt, $speed); push @{$save{$rate}{$name}{$delay} //= []}, $speed; } sub test_net_ssh2 { my $ssh2 = shift; my $c = $ssh2->channel or $ssh2->die_with_error; $c->ext_data('ignore'); my $time0 = time; $c->exec($cmd) or $ssh2->die_with_error; $c->send_eof; my $total = 0; my $buf; while (my $bytes = $c->read($buf, $read_size)) { $total += $bytes; } $c->wait_closed or $ssh2->die_with_error; return (time - $time0, $total); } sub test_net_openssh { my $ssh = shift; my $time0 = time; my $fh = $ssh->pipe_out($cmd) or $ssh->die_on_error; my $total = 0; my $buf; while (my $bytes = sysread($fh, $buf, $read_size)) { $total += $bytes; } close $fh or die "close failed"; return (time - $time0, $total); } sub rsys { my ($ssh2, $cmd) = @_; my $c = $ssh2->channel or $ssh2->die_with_error; $c->exec($cmd); $c->send_eof(); while (my @o = $c->read2) { print for @o; } close $c or warn "rsys >>$cmd<< failed $?"; } sleep 1; for my $ssh ($openssh, $ssh2) { for my $rate (@rates) { for my $delay (@delays) { system "tc qdisc del dev $local_iface root netem 2>/dev/null; true"; rsys($ssh2, "tc qdisc del dev $remote_iface root netem 2>/dev/null; true"); rsys($ssh2, "tc qdisc add dev $remote_iface root netem delay ${delay}ms rate $rate$rate_unit"); system "tc qdisc add dev $local_iface root netem delay ${delay}ms rate $rate$rate_unit"; test($ssh, $rate, $delay, $_) for 1..$n; system "tc qdisc del dev $local_iface root netem 2>/dev/null"; rsys($ssh2, "tc qdisc del dev $remote_iface root netem 2>/dev/null; true"); say ""; } } } sub csv { say join ', ', @_ } END { csv Delays => @delays; if (%save) { for my $rate (sort { $a <=> $b } keys %save) { csv Rate => "$rate$rate_unit"; my $h1 = $save{$rate}; for my $name (sort keys %$h1) { my $h2 = $h1->{$name}; my @means = map mean1( @{$h2->{$_}} ), @delays; csv "$name $rate$rate_unit" => @means; } say ""; } } } Net-SSH2-0.69/SSH2.xs0000644000175000017500000022621513232575602013021 0ustar salvasalva/* * SSH2.xs - C functions for Net::SSH2 * * D. Robins, 20051022 */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define NEED_sv_2pv_flags #define NEED_newRV_noinc #define NEED_sv_2pv_nolen #include "ppport.h" #if PERL_REVISION == 5 && (PERL_VERSION < 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 )) # ifdef SvPVbyte_force # undef SvPVbyte_force # endif # define SvPVbyte_force(sv,lp) SvPV_force(sv,lp) # ifdef SvPVbyte_nolen # undef SvPVbyte_nolen # endif # define SvPVbyte_nolen SvPV_nolen #endif #include #include #include #define LIBSSH2_HOSTKEY_POLICY_STRICT 1 #define LIBSSH2_HOSTKEY_POLICY_ASK 2 #define LIBSSH2_HOSTKEY_POLICY_TOFU 3 #define LIBSSH2_HOSTKEY_POLICY_ADVISORY 4 #define LIBSSH2_EXTENDED_DATA_STDERR SSH_EXTENDED_DATA_STDERR #define LIBSSH2_CHANNEL_FLUSH_STDERR SSH_EXTENDED_DATA_STDERR #include "const-c.inc" #if defined(USE_ITHREADS) && (defined(I_PTHREAD) || defined(WIN32)) #ifdef USE_GCRYPT #define HAVE_GCRYPT #include #else /* OpenSSL */ #define HAVE_OPENSSL #include #endif #else /* is #warning portable across C compilers? */ /* NO, an error with -pedantic */ /* #warning "Building a non-threadsafe Net::SSH2" */ #endif #ifndef MULTIPLICITY /* for debugging output */ #define my_perl ((void *)0) #endif /* constants */ #ifndef LIBSSH2_ERROR_NONE #define LIBSSH2_ERROR_NONE 0 #endif /* LIBSSH2_ERROR_NONE */ /* LIBSSH2_ERROR_* values; from 0 continuing negative */ static const char *const xs_libssh2_error[] = { "NONE", "SOCKET_NONE", "BANNER_NONE", "BANNER_SEND", "INVALID_MAC", "KEX_FAILURE", "ALLOC", "SOCKET_SEND", "KEY_EXCHANGE_FAILURE", "TIMEOUT", "HOSTKEY_INIT", "HOSTKEY_SIGN", "DECRYPT", "SOCKET_DISCONNECT", "PROTO", "PASSWORD_EXPIRED", "FILE", "METHOD_NONE", "PUBLICKEY_UNRECOGNIZED", "PUBLICKEY_UNVERIFIED", "CHANNEL_OUTOFORDER", "CHANNEL_FAILURE", "CHANNEL_REQUEST_DENIED", "CHANNEL_UNKNOWN", "CHANNEL_WINDOW_EXCEEDED", "CHANNEL_PACKET_EXCEEDED", "CHANNEL_CLOSED", "CHANNEL_EOF_SENT", "SCP_PROTOCOL", "ZLIB", "SOCKET_TIMEOUT", "SFTP_PROTOCOL", "REQUEST_DENIED", "METHOD_NOT_SUPPORTED", "INVAL", "INVALID_POLL_TYPE", "PUBLICKEY_PROTOCOL", "EAGAIN", "ERROR_BUFFER_TOO_SMALL", "BAD_USE", "ERROR_COMPRESS", "OUT_OF_BOUNDARY", "AGENT_PROTOCOL", "SOCKET_RECV", "ENCRYPT", "BAD_SOCKET", "KNOWN_HOSTS", }; /* SSH_FX_* values; from 0 continuing positive */ static const char *const sftp_error[] = { "OK", "EOF", "NO_SUCH_FILE", "PERMISSION_DENIED", "FAILURE", "BAD_MESSAGE", "NO_CONNECTION", "CONNECTION_LOST", "OP_UNSUPPORTED", "INVALID_HANDLE", "NO_SUCH_PATH", "FILE_ALREADY_EXISTS", "WRITE_PROTECT", "NO_MEDIA", "NO_SPACE_ON_FILESYSTEM", "QUOTA_EXCEEDED", "UNKNOWN_PRINCIPLE", "LOCK_CONFLICT", "DIR_NOT_EMPTY", "NOT_A_DIRECTORY", "INVALID_FILENAME", "LINK_LOOP" }; /* private internal functions */ #define countof(x) (sizeof(x)/sizeof(*x)) #define XLATATTR(name, field, flag) \ else if (strEQ(key, name)) { \ attrs.field = SvUV(ST(i + 1)); \ attrs.flags |= LIBSSH2_SFTP_ATTR_##flag; \ } typedef int SSH2_RC; /* for converting true/false to 1/undef */ typedef int SSH2_BYTES; /* for functions returning a byte count or a negative number to signal an error */ typedef libssh2_int64_t SSH2_BYTES64; /* the same for unsigned 64bit numbers */ typedef libssh2_uint64_t SSH2_BYTESU64; /* the same for unsigned 64bit numbers */ typedef int SSH2_ERROR; /* for returning SSH2 error numbers */ typedef int SSH2_NERROR; /* for converting SSH2 error code to boolean just indicating success or failure */ typedef int SSH2_BOOL; /* for yes/no responses */ typedef IV SSH2_METHOD; /* LIBSSH2_METHOD_ constants */ typedef IV SSH2_FLAG; /* LIBSSH2_FLAG_ constants */ typedef IV SSH2_CALLBACK; /* LIBSSH2_CALLBACK_ constants */ typedef IV SSH2_HOSTKEY_HASH; /* LIBSSH2_HOSTKEY_HASH_ constants */ typedef IV SSH2_CHANNEL_EXTENDED_DATA; /* SSH2_CHANNEL_EXTENDED_DATA_ constants */ typedef IV SSH2_STREAM_ID; /* stream_id or LIBSSH2_CHANNEL_FLUSH macros */ typedef char * SSH2_CHARP; /* string that can not be NULL */ typedef char * SSH2_CHARP_OR_NULL; /* string that can be NULL */ /* Net::SSH2 object */ typedef struct SSH2 { LIBSSH2_SESSION* session; SV* sv_ss; /* NB: not set until callback() called */ SV* socket; SV* hostname; int port; SV* sv_tmp; SV* rgsv_cb[LIBSSH2_CALLBACK_X11 + 1]; } SSH2; /* Net::SSH2::Channel object */ typedef struct SSH2_CHANNEL { SSH2* ss; SV* sv_ss; LIBSSH2_CHANNEL* channel; } SSH2_CHANNEL; /* Net::SSH2::SFTP object */ typedef struct SSH2_SFTP { SSH2* ss; SV* sv_ss; LIBSSH2_SFTP* sftp; } SSH2_SFTP; /* Net::SSH2::Listener object */ typedef struct SSH2_LISTENER { SSH2* ss; SV* sv_ss; LIBSSH2_LISTENER* listener; } SSH2_LISTENER; /* Net::SSH2::File object */ typedef struct SSH2_FILE { SSH2_SFTP* sf; SV* sv_sf; LIBSSH2_SFTP_HANDLE* handle; } SSH2_FILE; /* Net::SSH2::Dir object */ typedef struct SSH2_DIR { SSH2_SFTP* sf; SV* sv_sf; LIBSSH2_SFTP_HANDLE* handle; } SSH2_DIR; /* Net::SSH2::PublicKey object */ typedef struct SSH2_PUBLICKEY { SSH2* ss; SV* sv_ss; LIBSSH2_PUBLICKEY* pkey; } SSH2_PUBLICKEY; #if LIBSSH2_VERSION_NUM >= 0x010200 /* Net::SSH2::KnownHosts object */ typedef struct SSH2_KNOWNHOSTS { SSH2 *ss; SV *sv_ss; LIBSSH2_KNOWNHOSTS* knownhosts; } SSH2_KNOWNHOSTS; #endif static int net_ss_debug_out = 0; static unsigned long gensym_count = 0; /* debug output */ static void debug(const char* format, ...) { if (net_ss_debug_out) { va_list va; va_start(va, format); vwarn(format, &va); va_end(va); } } /* libssh2 allocator thunks */ LIBSSH2_ALLOC_FUNC(local_alloc) { void *buf; New(0, buf, count, char); return buf; } LIBSSH2_REALLOC_FUNC(local_realloc) { return Renew(ptr, count, char); } LIBSSH2_FREE_FUNC(local_free) { Safefree(ptr); } #define SV2TYPE(sv, type) ((type)((sizeof(IV) < sizeof(type)) ? SvNV(sv) : SvIV(sv))) #define SV2UTYPE(sv, type) ((type)((sizeof(IV) < sizeof(type)) ? SvNV(sv) : SvUV(sv))) static void wrap_tied_into(SV *to, const char *pkg, void *object) { GV* gv = (GV*)newSVrv(to, pkg); IO* io = (IO*)newSV(0); SV* name_sv = sv_2mortal(newSVpvf("_GEN_%ld", (long)gensym_count++)); STRLEN name_len; const char *name = SvPVbyte(name_sv, name_len); SvUPGRADE((SV*)gv, SVt_PVGV); gv_init(gv, gv_stashpv(pkg, GV_ADD), name, name_len, 0); SvUPGRADE((SV*)io, SVt_PVIO); GvSV(gv) = newSViv(PTR2IV(object)); GvIOp(gv) = io; #if PERL_VERSION > 6 sv_magic((SV*)io, newRV((SV*)gv), PERL_MAGIC_tiedscalar, Nullch, 0); #else sv_magic((SV*)gv, newRV((SV*)gv), PERL_MAGIC_tiedscalar, Nullch, 0); #endif } static IV unwrap(SV *sv, const char *pkg, const char *method) { if (SvROK(sv) && sv_isa(sv, pkg)) { SV *inner = SvRV(sv); if (SvIOK(inner)) return SvIVX(inner); } croak("%s::%s: invalid object %s", pkg, method, SvPV_nolen(sv)); } static IV unwrap_tied(SV *sv, const char *pkg, const char *method) { if (SvROK(sv) && sv_isa(sv, pkg)) { SV *gv = SvRV(sv); if (SvTYPE(gv) == SVt_PVGV) { SV *inner = GvSV((GV*)gv); if (inner && SvIOK(inner)) return SvIVX(inner); } } croak("%s::%s: invalid object %s", pkg, method, SvPV_nolen(sv)); } /* push a hash of values onto the return stack, for '%hash = func()' */ static int push_hv(SV** sp, HV* hv) { I32 keys = hv_iterinit(hv); const char* pv_key; I32 len_key; SV* value; EXTEND(SP, keys * 2); while ((value = hv_iternextsv(hv, (char**)&pv_key, &len_key))) { PUSHs(sv_2mortal(newSVpvn(pv_key, len_key))); PUSHs(sv_2mortal(SvREFCNT_inc(value))); } SvREFCNT_dec(hv); return keys * 2; } static SV * sv_upper(SV *sv) { STRLEN len, i; char *pv = SvPVbyte(sv, len); for (i = 0; i < len; i++) { if (isLOWER(pv[i])) { sv = sv_2mortal(newSVpvn(pv, len)); pv = SvPVX(sv); for (; i < len; i++) pv[i] = toUPPER(pv[i]); break; } } return sv; } static IV sv2iv_constant_or_croak(const char *name, SV *sv) { if (!SvOK(sv) || SvIOK(sv) || looks_like_number(sv)) return SvIV(sv); else { STRLEN len; char *pv; int type, i; IV value; sv = sv_upper(sv); pv = SvPVbyte(sv, len); type = constant(aTHX_ pv, len, &value); if (type == PERL_constant_NOTFOUND) { sv = sv_2mortal(newSVpvf("LIBSSH2_%s_%s", name, pv)); pv = SvPVbyte(sv, len); type = constant(aTHX_ SvPV_nolen(sv), len, &value); } if (type == PERL_constant_ISIV) return value; croak("Invalid constant of type LIBSSH2_%s (%s)", name, pv); } } /* create a hash from an SFTP attributes structure */ static HV* hv_from_attrs(LIBSSH2_SFTP_ATTRIBUTES* attrs) { HV* hv = newHV(); debug("hv_from_attrs: attrs->flags = %d\n", attrs->flags); if (attrs->flags & LIBSSH2_SFTP_ATTR_SIZE) hv_store(hv, "size", 4, newSVuv(attrs->filesize), 0/*hash*/); if (attrs->flags & LIBSSH2_SFTP_ATTR_UIDGID) { hv_store(hv, "uid", 3, newSVuv(attrs->uid), 0/*hash*/); hv_store(hv, "gid", 3, newSVuv(attrs->gid), 0/*hash*/); } if (attrs->flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) hv_store(hv, "mode", 4, newSVuv(attrs->permissions), 0/*hash*/); if (attrs->flags & LIBSSH2_SFTP_ATTR_ACMODTIME) { hv_store(hv, "atime", 5, newSVuv(attrs->atime), 0/*hash*/); hv_store(hv, "mtime", 5, newSVuv(attrs->mtime), 0/*hash*/); } return hv; } /* return attributes from function, as flat hash or hashref */ #define XSRETURN_STAT_ATTRS(name) XSRETURN(return_stat_attrs(sp, &attrs, name)) static int return_stat_attrs(SV** sp, LIBSSH2_SFTP_ATTRIBUTES* attrs, SV* name) { HV* hv_attrs = hv_from_attrs(attrs); if (name) hv_store(hv_attrs, "name", 4, name, 0/*hash*/); switch (GIMME_V) { case G_SCALAR: PUSHs(sv_2mortal(newRV_noinc((SV*)hv_attrs))); return 1; case G_ARRAY: return push_hv(sp, hv_attrs); default: SvREFCNT_dec(hv_attrs); } return 0; } /* general wrapper */ #define NEW_ITEM(type, field, create, parent) do { \ Newz(0/*id*/, RETVAL, 1, type); \ if (RETVAL) { \ RETVAL->parent = parent; \ RETVAL->sv_##parent = SvREFCNT_inc(SvRV(ST(0))); \ RETVAL->field = create; \ debug(#create " -> 0x%p\n", RETVAL->field); \ } \ if (!RETVAL || !RETVAL->field) { \ if (RETVAL) \ SvREFCNT_dec(RETVAL->sv_##parent); \ Safefree(RETVAL); \ XSRETURN_EMPTY; \ } \ } while(0) /* wrap a libSSH2 channel */ #define NEW_CHANNEL(create) NEW_ITEM(SSH2_CHANNEL, channel, create, ss) /* wrap a libSSH2 listener */ #define NEW_LISTENER(create) NEW_ITEM(SSH2_LISTENER, listener, create, ss) /* wrap a libSSH2 SFTP connection */ #define NEW_SFTP(create) NEW_ITEM(SSH2_SFTP, sftp, create, ss) /* wrap a libSSH2 SFTP file */ #define NEW_FILE(create) NEW_ITEM(SSH2_FILE, handle, create, sf) /* wrap a libSSH2 SFTP directory */ #define NEW_DIR(create) NEW_ITEM(SSH2_DIR, handle, create, sf) /* wrap a libSSH2 public key object */ #define NEW_PUBLICKEY(create) NEW_ITEM(SSH2_PUBLICKEY, pkey, create, ss) /* wrap a libSSH2 knownhosts object */ #define NEW_KNOWNHOSTS(create) NEW_ITEM(SSH2_KNOWNHOSTS, knownhosts, create, ss) static void set_cb_args(pTHX_ AV* data) { GV *gv = gv_fetchpv("Net::SSH2::_cb_args", 1, SVt_PV); SV *sv = save_scalar(gv); sv_setsv(sv, sv_2mortal(newRV_inc((SV*)data))); } static SV* get_cb_arg(pTHX_ I32 ix) { SV *sv = get_sv("Net::SSH2::_cb_args", 1); if (SvROK(sv)) { AV *data = (AV*)SvRV(sv); if (SvTYPE(data) == SVt_PVAV) { SV **svp = av_fetch(data, ix, 0); if (svp && *svp) return *svp; Perl_croak(aTHX_ "internal error: unable to fetch callback data slot %d", ix); } } Perl_croak(aTHX_ "internal error: unexpected structure found for callback data"); } /* callback for returning a password via "keyboard-interactive" auth */ static LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(cb_kbdint_response_password) { if (num_prompts != 1 || prompts[0].echo) { int i; for (i = 0; i < num_prompts; ++i) { responses[i].text = NULL; responses[i].length = 0; } } else { /* single prompt, no echo: assume it's a password request */ dTHX; SV *password = get_cb_arg(aTHX_ 0); STRLEN len_password; const char* pv_password = SvPVbyte(password, len_password); responses[0].text = savepvn(pv_password, len_password); responses[0].length = len_password; } } /* thunk to call perl input-reading function for "keyboard-interactive" auth */ static LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(cb_kbdint_response_callback) { dTHX; dSP; int count, i; SV *cb = get_cb_arg(aTHX_ 0); SV *self = get_cb_arg(aTHX_ 1); SV *username = get_cb_arg(aTHX_ 2); ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP, 4 + num_prompts); PUSHs(self); PUSHs(username); PUSHs(sv_2mortal(newSVpvn(name, name_len))); PUSHs(sv_2mortal(newSVpvn(instruction, instruction_len))); for (i = 0; i < num_prompts; ++i) { HV* hv = newHV(); /* Perl_warn(aTHX_ "prompt %d: text: %p, length: %d, echo: %d\n", */ /* i, prompts[i].text, prompts[i].length, prompts[i].echo); */ PUSHs(sv_2mortal(newRV_noinc((SV*)hv))); hv_store(hv, "text", 4, newSVpvn(prompts[i].text, prompts[i].length), 0); hv_store(hv, "echo", 4, newSVuv(prompts[i].echo), 0); responses[i].text = NULL; responses[i].length = 0; } PUTBACK; count = call_sv(cb, G_ARRAY); SPAGAIN; if (count > num_prompts) { Perl_warn(aTHX_ "Too many responses from callback, %d expected but %d found!", num_prompts, count); while (count-- > num_prompts) POPs; } while (count-- > 0) { STRLEN len_response; SV *sv = POPs; char *pv_response = SvPVbyte(sv, len_response); responses[count].text = savepvn(pv_response, len_response); responses[count].length = len_response; } PUTBACK; FREETMPS; LEAVE; } /* thunk to call perl password change function for "password" auth */ static LIBSSH2_PASSWD_CHANGEREQ_FUNC(cb_password_change_callback) { dTHX; dSP; int count; SV *cb = get_cb_arg(aTHX_ 0); SV *self = get_cb_arg(aTHX_ 1); SV *username = get_cb_arg(aTHX_ 2); ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(self); XPUSHs(username); PUTBACK; count = call_sv(cb, G_SCALAR); SPAGAIN; if (count > 0) { STRLEN len_password; const char* pv_password = SvPVbyte(POPs, len_password); *newpw = savepvn(pv_password, len_password); *newpw_len = len_password; } else { *newpw = NULL; *newpw_len = 0; } PUTBACK; FREETMPS; LEAVE; } /* thunk to call perl SSH_MSG_IGNORE packet function */ static LIBSSH2_IGNORE_FUNC(cb_ignore_callback) { SSH2* ss = (SSH2*)*abstract; dSP; I32 ax; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newRV_inc(ss->sv_ss))); mXPUSHp(message, message_len); PUTBACK; count = call_sv(ss->rgsv_cb[LIBSSH2_CALLBACK_IGNORE], G_VOID); SPAGAIN; SP -= count; ax = (SP - PL_stack_base) + 1; PUTBACK; FREETMPS; LEAVE; } /* thunk to call perl SSH_MSG_DEBUG packet function */ static LIBSSH2_DEBUG_FUNC(cb_debug_callback) { SSH2* ss = (SSH2*)*abstract; dSP; I32 ax; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newRV_inc(ss->sv_ss))); mXPUSHi(always_display); mXPUSHp(message, message_len); mXPUSHp(language, language_len); PUTBACK; count = call_sv(ss->rgsv_cb[LIBSSH2_CALLBACK_DEBUG], G_VOID); SPAGAIN; SP -= count; ax = (SP - PL_stack_base) + 1; PUTBACK; FREETMPS; LEAVE; } /* thunk to call perl SSH_MSG_DISCONNECT packet function */ static LIBSSH2_DISCONNECT_FUNC(cb_disconnect_callback) { SSH2* ss = (SSH2*)*abstract; dSP; I32 ax; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newRV_inc(ss->sv_ss))); mXPUSHi(reason); mXPUSHp(message, message_len); mXPUSHp(language, language_len); PUTBACK; count = call_sv(ss->rgsv_cb[LIBSSH2_CALLBACK_DISCONNECT], G_VOID); SPAGAIN; SP -= count; ax = (SP - PL_stack_base) + 1; PUTBACK; FREETMPS; LEAVE; } /* thunk to call perl SSH_MSG_MACERROR packet function */ static LIBSSH2_MACERROR_FUNC(cb_macerror_callback) { SSH2* ss = (SSH2*)*abstract; int ret = 0; dSP; I32 ax; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newRV_inc(ss->sv_ss))); mXPUSHp(packet, packet_len); PUTBACK; count = call_sv(ss->rgsv_cb[LIBSSH2_CALLBACK_MACERROR], G_SCALAR); SPAGAIN; SP -= count ; ax = (SP - PL_stack_base) + 1; if (count > 0) ret = SvIV(ST(0)); PUTBACK; FREETMPS; LEAVE; return ret; } /* thunk to call perl X11 forwarder packet function */ static LIBSSH2_X11_OPEN_FUNC(cb_x11_open_callback) { SSH2* ss = (SSH2*)*abstract; dSP; I32 ax; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newRV_inc(ss->sv_ss))); /*TODO: we actually need to push a channel here, but we don't know the * SV of the channel (use a local hash?) */ XPUSHs(&PL_sv_undef); mXPUSHp(shost, strlen(shost)); mXPUSHi(sport); PUTBACK; count = call_sv(ss->rgsv_cb[LIBSSH2_CALLBACK_X11], G_VOID); SPAGAIN; SP -= count ; ax = (SP - PL_stack_base) + 1 ; PUTBACK; FREETMPS; LEAVE; } void * cb_as_void_ptr(void (*cb)()) { void * addr; memcpy(&addr, &cb, sizeof addr); return addr; } static void (*msg_cb[])() = { (void (*)())cb_ignore_callback, (void (*)())cb_debug_callback, (void (*)())cb_disconnect_callback, (void (*)())cb_macerror_callback, (void (*)())cb_x11_open_callback }; #define MY_CXT_KEY "Net::SSH2::_guts" XS_VERSION #ifdef HAVE_GCRYPT #ifndef WIN32 GCRY_THREAD_OPTION_PTHREAD_IMPL; #else GCRY_THREAD_OPTION_PTH_IMPL; #endif #endif typedef struct { HV* global_cb_data; UV tid; } my_cxt_t; START_MY_CXT static UV get_my_thread_id(void) /* returns threads->tid() value */ { dSP; UV tid = 0; int count = 0; #ifdef USE_ITHREADS ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv("threads", 0))); PUTBACK; count = call_method("tid", G_SCALAR|G_EVAL); SPAGAIN; if (SvTRUE(ERRSV) || count != 1) /* if threads not loaded or an error occurs return 0 */ tid = 0; else tid = (UV)POPi; PUTBACK; FREETMPS; LEAVE; #endif return tid; } #if defined(USE_ITHREADS) && !defined(HAVE_GCRYPT) /* IMPORTANT NOTE: * openssl locking was implemented according to http://www.openssl.org/docs/crypto/threads.html * we implement both static and dynamic locking as described on URL above * locking is supported when OPENSSL_THREADS macro is defined which means openssl-0.9.7 or newer * we intentionally do not implement cleanup of openssl's threading as it causes troubles * with apache-mpm-worker+mod_perl+mod_ssl+net-ssleay */ static perl_mutex *GLOBAL_openssl_mutex = NULL; static void openssl_locking_function(int mode, int type, const char *file, int line) { if (!GLOBAL_openssl_mutex) return; if (mode & CRYPTO_LOCK) MUTEX_LOCK(&GLOBAL_openssl_mutex[type]); else MUTEX_UNLOCK(&GLOBAL_openssl_mutex[type]); } #if OPENSSL_VERSION_NUMBER < 0x10000000L static unsigned long openssl_threadid_func(void) { dMY_CXT; return (unsigned long)(MY_CXT.tid); } #else static void openssl_threadid_func(CRYPTO_THREADID *id) { dMY_CXT; CRYPTO_THREADID_set_numeric(id, (unsigned long)(MY_CXT.tid)); } #endif struct CRYPTO_dynlock_value { perl_mutex mutex; }; static struct CRYPTO_dynlock_value *openssl_dynlocking_create_function(const char *file, int line) { struct CRYPTO_dynlock_value *retval; New(0, retval, 1, struct CRYPTO_dynlock_value); if (!retval) return NULL; MUTEX_INIT(&retval->mutex); return retval; } static void openssl_dynlocking_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) { if (!l) return; if (mode & CRYPTO_LOCK) MUTEX_LOCK(&l->mutex); else MUTEX_UNLOCK(&l->mutex); } static void openssl_dynlocking_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { if (!l) return; MUTEX_DESTROY(&l->mutex); Safefree(l); } static void openssl_threads_init(void) { int i; /* initialize static locking */ if ( !CRYPTO_get_locking_callback() ) { #if OPENSSL_VERSION_NUMBER < 0x10000000L if ( !CRYPTO_get_id_callback() ) { #else if ( !CRYPTO_THREADID_get_callback() ) { #endif New(0, GLOBAL_openssl_mutex, CRYPTO_num_locks(), perl_mutex); if (!GLOBAL_openssl_mutex) return; for (i=0; isession, &errmsg, NULL, 0); croak("%s::%s: %s (%d)", class, method, errmsg, err); } #define CROAK_LAST_ERROR(session, method) (croak_last_error((session), class, (method))) #if LIBSSH2_VERSION_NUM < 0x010601 #define libssh2_session_set_last_error(ss, errcode, errmsg) 0 #endif static void save_eagain(LIBSSH2_SESSION *session, int error) { if (error == LIBSSH2_ERROR_EAGAIN) libssh2_session_set_last_error(session, LIBSSH2_ERROR_EAGAIN, "Operation would block"); } /* perl module exports */ MODULE = Net::SSH2 PACKAGE = Net::SSH2 PREFIX = net_ss_ PROTOTYPES: DISABLE INCLUDE: const-xs.inc BOOT: { MY_CXT_INIT; #ifdef HAVE_GCRYPT gcry_error_t ret; #ifndef WIN32 ret = gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #else ret = gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); #endif if (gcry_err_code(ret) != GPG_ERR_NO_ERROR) croak("could not initialize libgcrypt for threads (%d: %s/%s)", gcry_err_code(ret), gcry_strsource(ret), gcry_strerror(ret)); if (!gcry_check_version(GCRYPT_VERSION)) croak("libgcrypt version mismatch (needed: %s)", GCRYPT_VERSION); #else /* OpenSSL */ openssl_threads_init(); MY_CXT.global_cb_data = newHV(); MY_CXT.tid = get_my_thread_id(); debug("Net::SSH2::BOOT: tid=%d my_perl=0x%p\n", MY_CXT.tid, my_perl); #endif } #define class "Net::SSH2" void CLONE(...) CODE: MY_CXT_CLONE; MY_CXT.global_cb_data = newHV(); MY_CXT.tid = get_my_thread_id(); debug("%s::CLONE: tid=%d my_perl=0x%p\n", class, MY_CXT.tid, my_perl); IV _parse_constant(char *prefix, SV *value) CODE: RETVAL = sv2iv_constant_or_croak(prefix, value); OUTPUT: RETVAL SSH2* net_ss__new(SV* proto) CODE: Newz(0/*id*/, RETVAL, 1, SSH2); if (RETVAL) { RETVAL->session = libssh2_session_init_ex( local_alloc, local_free, local_realloc, RETVAL); } if (!RETVAL || !RETVAL->session) { Safefree(RETVAL); XSRETURN_EMPTY; } debug("Net::SSH2: created new object 0x%x\n", RETVAL); OUTPUT: RETVAL void net_ss_trace(SSH2* ss, IV bitmask) CODE: libssh2_trace(ss->session, bitmask); #if LIBSSH2_VERSION_MAJOR >= 1 IV net_ss_block_directions(SSH2* ss) CODE: RETVAL = libssh2_session_block_directions(ss->session); OUTPUT: RETVAL #else void net_ss_block_directions(SSH2* ss) CODE: croak("libssh2 version 1.0 or higher required for block_directions support"); #endif #if LIBSSH2_VERSION_NUM >= 0x010209 SV * net_ss_timeout(SSH2* ss, SV *timeout = &PL_sv_undef) PREINIT: long r; CODE: if (items > 1) libssh2_session_set_timeout(ss->session, (SvOK(timeout) ? SvUV(timeout) : 0)); r = libssh2_session_get_timeout(ss->session); RETVAL = (r > 0 ? newSVuv(r) : &PL_sv_undef); OUTPUT: RETVAL #else void net_ss_timeout(SSH2* ss, long timeout) CODE: croak("libssh2 version 1.2.9 or higher required for set_timeout support"); #endif SSH2_BOOL net_ss_blocking(SSH2* ss, SSH2_BOOL blocking = 0) CODE: if (items > 1) libssh2_session_set_blocking(ss->session, blocking); RETVAL = libssh2_session_get_blocking(ss->session); OUTPUT: RETVAL void net_ss_DESTROY(SSH2* ss) CODE: debug("%s::DESTROY object 0x%x\n", class, ss); libssh2_session_free(ss->session); if (ss->socket) SvREFCNT_dec(ss->socket); if (ss->hostname) SvREFCNT_dec(ss->hostname); Safefree(ss); void net_ss_debug(SV*, IV debug) CODE: net_ss_debug_out = debug & 1; /* allow for future flags */ void net_ss_version(...) PPCODE: EXTEND(SP, 3); ST(0) = sv_2mortal(newSVpv(LIBSSH2_VERSION, 0)); if (GIMME_V != G_ARRAY) XSRETURN(1); #ifdef LIBSSH2_VERSION_NUM ST(1) = sv_2mortal(newSVuv(LIBSSH2_VERSION_NUM)); #else ST(1) = &PL_sv_undef; #endif ST(2) = sv_2mortal(newSVpv(LIBSSH2_SSH_DEFAULT_BANNER, 0)); XSRETURN(3); SSH2_NERROR net_ss_banner(SSH2* ss, SSH2_CHARP banner) PREINIT: SV* full_banner; CODE: full_banner = sv_2mortal(newSVpvf("SSH-2.0-%s", banner)); RETVAL = libssh2_banner_set(ss->session, SvPVbyte_nolen(full_banner)); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL SSH2_ERROR net_ss_error(SSH2* ss) PREINIT: char* errstr; int errlen; CODE: RETVAL = libssh2_session_last_error(ss->session, &errstr, &errlen, 0); if(GIMME_V == G_ARRAY) { SV *errcode_sv; if (RETVAL == LIBSSH2_ERROR_NONE) XSRETURN_EMPTY; EXTEND(SP, 3); ST(0) = sv_2mortal(newSViv(RETVAL)); if ((-RETVAL > 0) && (-RETVAL < countof(xs_libssh2_error))) errcode_sv = newSVpvf("LIBSSH2_ERROR_%s", xs_libssh2_error[-RETVAL]); else errcode_sv = newSVpvf("LIBSSH2_ERROR_UNKNOWN(%d)", RETVAL); ST(1) = sv_2mortal(errcode_sv); ST(2) = (errstr ? sv_2mortal(newSVpvn(errstr, errlen)) : &PL_sv_undef); XSRETURN(3); } OUTPUT: RETVAL void net_ss__set_error(SSH2 *ss, int errcode = 0, SSH2_CHARP_OR_NULL errmsg = NULL) CODE: libssh2_session_set_last_error(ss->session, errcode, errmsg); SSH2_NERROR net_ss__method(SSH2* ss, SSH2_METHOD type, SSH2_CHARP_OR_NULL prefs = NULL) CODE: /* if there are no other parameters, return the current value */ if (items == 2) { const char *method = libssh2_session_methods(ss->session, (int)type); if (!method) XSRETURN_EMPTY; XSRETURN_PV(method); } RETVAL = libssh2_session_method_pref(ss->session, (int)type, prefs); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010200 SSH2_NERROR net_ss_flag(SSH2* ss, SSH2_FLAG flag, int value) CODE: RETVAL = libssh2_session_flag(ss->session, (int)flag, value); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL #else void net_ss_flag(SSH2* ss, SV* flag, int value) CODE: croak("libssh2 version 1.2 or higher required for flag support"); #endif SSH2_RC net_ss_callback(SSH2* ss, SSH2_CALLBACK type, SV* callback = NULL) CODE: if (callback && !SvOK(callback)) callback = NULL; if (callback && !(SvROK(callback) && SvTYPE(SvRV(callback)) == SVt_PVCV)) croak("%s::callback: callback must be CODE ref", class); if (type < 0 || type >= countof(msg_cb)) croak("%s::callback: don't know how to handle: %s", class, SvPVbyte_nolen(callback)); ss->sv_ss = SvRV(ST(0)); /* don't keep a reference, just store it */ SvREFCNT_dec(ss->rgsv_cb[type]); libssh2_session_callback_set(ss->session, type, callback ? cb_as_void_ptr(msg_cb[type]) : NULL); SvREFCNT_inc(callback); ss->rgsv_cb[type] = callback; RETVAL = 1; OUTPUT: RETVAL SSH2_NERROR net_ss__startup(SSH2* ss, int fd, SV *socket, SV* hostname, int port) CODE: RETVAL = libssh2_session_startup(ss->session, fd); if ((RETVAL >= 0) && SvOK(socket)) { if (ss->socket) sv_2mortal(ss->socket); ss->socket = newSVsv(socket); ss->hostname = newSVsv(hostname); ss->port = port; } save_eagain(ss->session, RETVAL); OUTPUT: RETVAL SV * net_ss_hostname(SSH2* ss) CODE: RETVAL = (ss->hostname ? newSVsv(ss->hostname) : &PL_sv_undef); OUTPUT: RETVAL int net_ss_port(SSH2* ss) CODE: RETVAL = ss->port; OUTPUT: RETVAL SV * net_ss_sock(SSH2* ss) CODE: RETVAL = (ss->socket ? newSVsv(ss->socket) : &PL_sv_undef); OUTPUT: RETVAL SSH2_NERROR net_ss_disconnect(SSH2* ss, SSH2_CHARP description = "", \ int reason = SSH_DISCONNECT_BY_APPLICATION, SSH2_CHARP lang = "") CODE: RETVAL = libssh2_session_disconnect_ex(ss->session, reason, description, lang); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL void net_ss_hostkey_hash(SSH2* ss, SSH2_HOSTKEY_HASH type) PREINIT: const char* hash; static STRLEN rglen[] = { 16/*MD5*/, 20/*SHA1*/ }; PPCODE: if (type < 1 || type > countof(rglen)) { croak("%s::hostkey: unknown hostkey hash: %d", class, (int)type); } if ((hash = (const char*)libssh2_hostkey_hash(ss->session, type))) { PUSHs(sv_2mortal(newSVpvn(hash, rglen[type-1]))); XSRETURN(1); } XSRETURN_EMPTY; void net_ss_remote_hostkey(SSH2* ss) PREINIT: const char *key_pv; size_t key_len; int type_int; PPCODE: if ((key_pv = libssh2_session_hostkey(ss->session, &key_len, &type_int))) { XPUSHs(sv_2mortal(newSVpvn(key_pv, key_len))); if (GIMME_V != G_ARRAY) XSRETURN(1); else { XPUSHs(sv_2mortal(newSViv(type_int))); XSRETURN(2); } } else XSRETURN_EMPTY; SSH2_CHARP_OR_NULL net_ss__auth_list(SSH2* ss, SV *username = &PL_sv_undef) PREINIT: const char* pv_username = NULL; STRLEN len_username = 0; CODE: if (SvOK(username)) pv_username = SvPVbyte(username, len_username); RETVAL = libssh2_userauth_list(ss->session, pv_username, len_username); OUTPUT: RETVAL SSH2_RC net_ss_auth_ok(SSH2* ss) CODE: RETVAL = libssh2_userauth_authenticated(ss->session); OUTPUT: RETVAL SSH2_NERROR net_ss_auth_password(SSH2* ss, \ SV* username, SV* password = &PL_sv_undef, \ SV* callback = &PL_sv_undef) PREINIT: STRLEN len_username, len_password; const char *pv_username, *pv_password; int i, ok; CODE: pv_username = SvPVbyte(username, len_username); /* if we don't have a password, try for an unauthenticated login */ if (!SvPOK(password)) { /* That's how libssh2 tells you authentication 'none' is valid */ RETVAL = (((libssh2_userauth_list(ss->session, pv_username, len_username) == NULL) && libssh2_userauth_authenticated(ss->session)) ? 0 : -1); } else { if (SvOK(callback)) { if (!(SvROK(callback) && SvTYPE(SvRV(callback)) == SVt_PVCV)) Perl_croak(aTHX_ "%s::auth_password: callback must be CODE ref", class); else { AV *cb_args = (AV*)sv_2mortal((SV*)newAV()); av_push(cb_args, newSVsv(callback)); av_push(cb_args, newSVsv(ST(0))); /*session */ av_push(cb_args, newSVsv(username)); set_cb_args(aTHX_ cb_args); } } pv_password = SvPVbyte(password, len_password); RETVAL = libssh2_userauth_password_ex(ss->session, pv_username, len_username, pv_password, len_password, (SvOK(callback) ? cb_password_change_callback : NULL)); save_eagain(ss->session, RETVAL); } OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010203 SV * net_ss_auth_agent(SSH2* ss, SSH2_CHARP username) PREINIT: LIBSSH2_AGENT *agent; int old_blocking; CODE: RETVAL = &PL_sv_undef; /* unfortunatelly this can't be make to work on nb mode */ old_blocking = libssh2_session_get_blocking(ss->session); libssh2_session_set_blocking(ss->session, 1); if ((agent = libssh2_agent_init(ss->session)) != NULL) { if (libssh2_agent_connect(agent) == LIBSSH2_ERROR_NONE) { if (libssh2_agent_list_identities(agent) == LIBSSH2_ERROR_NONE) { struct libssh2_agent_publickey *identity = NULL; while (libssh2_agent_get_identity(agent, &identity, identity) == 0) { if (libssh2_agent_userauth(agent, username, identity) == LIBSSH2_ERROR_NONE) { RETVAL = &PL_sv_yes; break; } } } } libssh2_agent_free(agent); } libssh2_session_set_blocking(ss->session, old_blocking); OUTPUT: RETVAL #else void net_ss_auth_agent(SSH2* ss, SV* username) CODE: croak("libssh2 version 1.2.3 or higher required for agent support"); #endif SSH2_NERROR net_ss_auth_publickey(SSH2* ss, SV* username, SSH2_CHARP_OR_NULL publickey, \ SSH2_CHARP privatekey, SSH2_CHARP_OR_NULL passphrase = NULL); PREINIT: const char* pv_username; STRLEN len_username; CODE: pv_username = SvPVbyte(username, len_username); RETVAL = libssh2_userauth_publickey_fromfile_ex(ss->session, pv_username, len_username, publickey, privatekey, passphrase); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010600 SSH2_NERROR net_ss_auth_publickey_frommemory(SSH2* ss, SV* username, SV* publickey, \ SV* privatekey, SSH2_CHARP_OR_NULL passphrase = NULL) PREINIT: const char *pv_username, *pv_publickey, *pv_privatekey; STRLEN len_username, len_publickey, len_privatekey; CODE: pv_username = SvPVbyte(username, len_username); pv_publickey = SvPVbyte(publickey, len_publickey); pv_privatekey = SvPVbyte(privatekey, len_privatekey); RETVAL = libssh2_userauth_publickey_frommemory(ss->session, pv_username, len_username, pv_publickey, len_publickey, pv_privatekey, len_privatekey, passphrase); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL #endif SSH2_NERROR net_ss_auth_hostbased(SSH2* ss, SV* username, const char* publickey, \ const char* privatekey, SV* hostname, \ SV* local_username = &PL_sv_undef, \ SSH2_CHARP_OR_NULL passphrase = NULL) PREINIT: const char* pv_username, * pv_hostname, * pv_local_username; STRLEN len_username, len_hostname, len_local_username; CODE: pv_username = SvPVbyte(username, len_username); pv_hostname = SvPVbyte(hostname, len_hostname); if (SvPOK(local_username)) { pv_local_username = SvPVbyte(local_username, len_local_username); } else { pv_local_username = pv_username; len_local_username = len_username; } RETVAL = libssh2_userauth_hostbased_fromfile_ex(ss->session, pv_username, len_username, publickey, privatekey, passphrase, pv_hostname, len_hostname, pv_local_username, len_local_username); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ss_auth_keyboard(SSH2* ss, SV* username, SV* password = NULL) PREINIT: const char* pv_username; STRLEN len_username; AV *cb_args; CODE: pv_username = SvPVbyte(username, len_username); /* we either have a password, or a reference to a callback */ if (!password || !SvOK(password)) { password = sv_2mortal(newRV_inc((SV*)get_cv("Net::SSH2::_cb_kbdint_response_default", 1))); if (!SvOK(password)) Perl_croak(aTHX_ "Internal error: unable to retrieve callback"); } cb_args = (AV*)sv_2mortal((SV*)newAV()); av_push(cb_args, newSVsv(password)); av_push(cb_args, newSVsv(ST(0))); /*session */ av_push(cb_args, newSVsv(username)); set_cb_args(aTHX_ cb_args); if (SvROK(password) && (SvTYPE(SvRV(password)) == SVt_PVCV)) RETVAL = libssh2_userauth_keyboard_interactive_ex(ss->session, pv_username, len_username, cb_kbdint_response_callback); else RETVAL = libssh2_userauth_keyboard_interactive_ex(ss->session, pv_username, len_username, cb_kbdint_response_password); save_eagain(ss->session, RETVAL); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010205 void net_ss_keepalive_config(SSH2 *ss, int want_reply, unsigned int interval) CODE: libssh2_keepalive_config(ss->session, want_reply, interval); SSH2_BYTES net_ss_keepalive_send(SSH2 *ss) PREINIT: int seconds_to_next; CODE: RETVAL = libssh2_keepalive_send(ss->session, &seconds_to_next); save_eagain(ss->session, RETVAL); if (RETVAL >= 0) RETVAL = seconds_to_next; OUTPUT: RETVAL #else void net_ss_keepalive_config(SSH2 *ss, int want_reply, unsigned int interval) CODE: croak("libssh2 version 1.2.5 or higher required for keepalive_config support"); void net_ss_keepalive_send(SSH2 *ss) CODE: croak("libssh2 version 1.2.5 or higher required for keepalive_send support"); #endif SSH2_CHANNEL* net_ss_channel(SSH2* ss, SSH2_CHARP_OR_NULL channel_type = NULL, \ int window_size = LIBSSH2_CHANNEL_WINDOW_DEFAULT, \ int packet_size = LIBSSH2_CHANNEL_PACKET_DEFAULT) PREINIT: static const char mandatory_type[] = "session"; CODE: if (channel_type && strcmp(channel_type, mandatory_type)) Perl_croak(aTHX_ "channel_type must be 'session' ('%s' given)", channel_type); NEW_CHANNEL(libssh2_channel_open_ex(ss->session, mandatory_type, strlen(mandatory_type), window_size, packet_size, NULL/*message*/, 0/*message_len*/)); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x10601 SSH2_CHANNEL* net_ss__scp_get(SSH2* ss, SSH2_CHARP path, HV* stat) PREINIT: libssh2_struct_stat st; CODE: NEW_CHANNEL(libssh2_scp_recv2(ss->session, path, &st)); hv_store(stat, "mode", 4, newSVuv(st.st_mode), 0/*hash*/); hv_store(stat, "uid", 3, newSVuv(st.st_uid), 0/*hash*/); hv_store(stat, "gid", 3, newSVuv(st.st_gid), 0/*hash*/); #if IVSIZE >= 8 hv_store(stat, "size", 4, newSVuv(st.st_size), 0/*hash*/); #else hv_store(stat, "size", 4, newSVnv(st.st_size), 0/*hash*/); #endif hv_store(stat, "atime", 5, newSVuv((time_t)st.st_atime), 0/*hash*/); hv_store(stat, "mtime", 5, newSVuv((time_t)st.st_mtime), 0/*hash*/); OUTPUT: RETVAL #else SSH2_CHANNEL* net_ss__scp_get(SSH2* ss, SSH2_CHARP path, HV* stat) PREINIT: struct stat st; CODE: NEW_CHANNEL(libssh2_scp_recv(ss->session, path, &st)); hv_store(stat, "mode", 4, newSVuv(st.st_mode), 0/*hash*/); hv_store(stat, "uid", 3, newSVuv(st.st_uid), 0/*hash*/); hv_store(stat, "gid", 3, newSVuv(st.st_gid), 0/*hash*/); hv_store(stat, "size", 4, newSVuv(st.st_size), 0/*hash*/); hv_store(stat, "atime", 5, newSVuv((time_t)st.st_atime), 0/*hash*/); hv_store(stat, "mtime", 5, newSVuv((time_t)st.st_mtime), 0/*hash*/); OUTPUT: RETVAL #endif #if LIBSSH2_VERSION_NUM >= 0x10206 SSH2_CHANNEL* net_ss__scp_put(SSH2* ss, SSH2_CHARP path, int mode, SSH2_BYTESU64 size, \ time_t mtime = 0, time_t atime = 0) CODE: NEW_CHANNEL(libssh2_scp_send64(ss->session, path, mode, size, mtime, atime)); OUTPUT: RETVAL #else SSH2_CHANNEL* net_ss__scp_put(SSH2* ss, SSH2_CHARP path, int mode, size_t size, \ long mtime = 0, long atime = 0) CODE: NEW_CHANNEL(libssh2_scp_send_ex(ss->session, path, mode, size, mtime, atime)); OUTPUT: RETVAL #endif SSH2_CHANNEL* net_ss_tcpip(SSH2* ss, SSH2_CHARP host, int port, \ SSH2_CHARP shost = "127.0.0.1", int sport = 22) CODE: NEW_CHANNEL(libssh2_channel_direct_tcpip_ex(ss->session, (char*)host, port, (char*)shost, sport)); OUTPUT: RETVAL SSH2_LISTENER* net_ss_listen(SSH2* ss, int port, const char* host = NULL, \ SV* bound_port = NULL, int queue_maxsize = 16) PREINIT: int i_bound_port; CODE: if (bound_port && SvOK(bound_port)) { if (!SvROK(bound_port) && SvTYPE(SvRV(bound_port)) <= SVt_PVNV) croak("%s::listen: bound port must be scalar reference", class); } else bound_port = NULL; NEW_LISTENER(libssh2_channel_forward_listen_ex(ss->session, (char*)host, port, bound_port ? &i_bound_port : NULL, queue_maxsize)); if (RETVAL && bound_port) sv_setiv(SvRV(bound_port), i_bound_port); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010200 SSH2_KNOWNHOSTS* net_ss_known_hosts(SSH2 *ss) CODE: NEW_KNOWNHOSTS(libssh2_knownhost_init(ss->session)); OUTPUT: RETVAL #else void net_ss_known_hosts(SSH2 *ss) CODE: croak("libssh2 version 1.2 or higher required for known_hosts support"); #endif void net_ss__poll(SSH2* ss, int timeout, AV* event) PREINIT: LIBSSH2_POLLFD* pollfd; int i, count, changed; CODE: count = av_len(event) + 1; debug("%s::poll: timeout = %d, array[%d]\n", class, timeout, count); if (!count) /* some architectures return null for malloc(0) */ XSRETURN_IV(0); New(0, pollfd, count, LIBSSH2_POLLFD); if (!pollfd) Perl_croak(aTHX_ "Out of memory!"); for (i = 0; i < count; ++i) { SV* sv = *av_fetch(event, i, 0/*lval*/), ** handle, ** events; HV* hv; if (!SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVHV) croak("%s::poll: array element %d is not hash", class, i); hv = (HV*)SvRV(sv); if (!(handle = hv_fetch(hv, "handle", 6, 0/*lval*/)) || !*handle) croak("%s::poll: array element %d missing handle", class, i); if (sv_isobject(*handle)) { const char* package = HvNAME(SvSTASH(SvRV(*handle))); if (strEQ(package, "Net::SSH2::Channel")) { debug("- [%d] = channel\n", i); pollfd[i].type = LIBSSH2_POLLFD_CHANNEL; pollfd[i].fd.channel = ((SSH2_CHANNEL*)SvIVX(GvSV((GV*)SvRV(*handle))))->channel; } else if(strEQ(package, "Net::SSH2::Listener")) { debug("- [%d] = listener\n", i); pollfd[i].type = LIBSSH2_POLLFD_LISTENER; pollfd[i].fd.listener = ((SSH2_LISTENER*)SvIVX(SvRV(*handle)))->listener; } else { croak("%s::poll: invalid handle object in array (%d): %s", class, i, package); } } else if(SvIOK(*handle)) { pollfd[i].type = LIBSSH2_POLLFD_SOCKET; pollfd[i].fd.socket = SvIV(*handle); debug("- [%d] = file(%d)\n", i, pollfd[i].fd.socket); } else { croak("%s::poll: invalid handle in array (%d): %s", class, i, SvPVbyte_nolen(*handle)); } events = hv_fetch(hv, "events", 6, 0/*lval*/); if (!events || !*events || !SvIOK(*events)) { croak("%s::poll: bad or missing event mask in array (%d)", class, i); } pollfd[i].events = SvIV(*events); pollfd[i].revents = 0; debug("- [%d] events %d\n", i, pollfd[i].events); } changed = libssh2_poll(pollfd, count, timeout); debug("- libssh2_poll returned %d\n", changed); if (changed < 0) count = 0; for (i = 0; i < count; ++i) { HV* hv = (HV*)SvRV(*av_fetch(event, i, 0/*lval*/)); hv_store(hv, "revents", 7, newSViv(pollfd[i].revents), 0/*hash*/); debug("- [%d] revents %d\n", i, pollfd[i].revents); } Safefree(pollfd); if (changed < 0) XSRETURN_EMPTY; XSRETURN_IV(changed); SSH2_SFTP* net_ss_sftp(SSH2* ss) CODE: NEW_SFTP(libssh2_sftp_init(ss->session)); OUTPUT: RETVAL SSH2_PUBLICKEY* net_ss_public_key(SSH2* ss) CODE: NEW_PUBLICKEY(libssh2_publickey_init(ss->session)); OUTPUT: RETVAL #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::Channel PREFIX = net_ch_ PROTOTYPES: DISABLE #define class "Net::SSH2::Channel" void net_ch_DESTROY(SSH2_CHANNEL* ch) CODE: debug("%s::DESTROY\n", class); libssh2_channel_free(ch->channel); SvREFCNT_dec(ch->sv_ss); Safefree(ch); SV * net_ch_session(SSH2_CHANNEL* ch) CODE: RETVAL = newRV_inc(ch->sv_ss); OUTPUT: RETVAL SSH2_NERROR net_ch__setenv(SSH2_CHANNEL* ch, SV *key, SV *value) PREINIT: int i, success = 0; const char* pv_key, * pv_value; STRLEN len_key, len_value; CODE: pv_key = SvPVbyte(key, len_key); pv_value = SvPVbyte(value, len_value); RETVAL = libssh2_channel_setenv_ex(ch->channel, (char*)pv_key, len_key, (char*)pv_value, len_value); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010208 void net_ch__exit_signal(SSH2_CHANNEL* ch) PREINIT: char *exitsignal; char *errmsg; char *langtag; size_t exitsignal_len; size_t errmsg_len; size_t langtag_len; int retcount = 1; PPCODE: if (!libssh2_channel_get_exit_signal(ch->channel, &exitsignal, &exitsignal_len, &errmsg, &errmsg_len, &langtag, &langtag_len)) { LIBSSH2_SESSION *session = ch->ss->session; libssh2_session_set_last_error(session, 0, NULL); if (exitsignal) { XPUSHs(sv_2mortal(newSVpvn(exitsignal, exitsignal_len))); if (GIMME_V == G_ARRAY) { XPUSHs(errmsg ? sv_2mortal(newSVpvn(errmsg, errmsg_len)) : &PL_sv_undef); XPUSHs(langtag ? sv_2mortal(newSVpvn(langtag, langtag_len)) : &PL_sv_undef); retcount = 3; } libssh2_free(session, exitsignal); if (errmsg) libssh2_free(session, errmsg); if (langtag) libssh2_free(session, langtag); } else XPUSHs(&PL_sv_no); XSRETURN(retcount); } else XSRETURN(0); #else void net_ch__exit_signal(SSH2_CHANNEL* ch) CODE: croak("libssh2 version 1.2.8 or higher required for exit_signal support"); #endif SSH2_BYTES net_ch_eof(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_eof(ch->channel); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ch_send_eof(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_send_eof(ch->channel); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ch_close(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_close(ch->channel); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ch__wait_closed(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_wait_closed(ch->channel); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ch_wait_eof(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_wait_eof(ch->channel); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL int net_ch__exit_status(SSH2_CHANNEL* ch) CODE: RETVAL = libssh2_channel_get_exit_status(ch->channel); OUTPUT: RETVAL #if LIBSSH2_VERSION_MAJOR >= 1 SSH2_NERROR net_ch__pty(SSH2_CHANNEL* ch, SV* terminal, SV* modes = NULL, \ int width = 0, int height = 0) PREINIT: const char* pv_terminal, * pv_modes = NULL; STRLEN len_terminal, len_modes = 0; int width_px = LIBSSH2_TERM_WIDTH_PX, height_px = LIBSSH2_TERM_HEIGHT_PX; CODE: pv_terminal = SvPVbyte(terminal, len_terminal); if (modes && SvPOK(modes)) pv_modes = SvPVbyte(modes, len_modes); if (!width) width = LIBSSH2_TERM_WIDTH; else if(width < 0) { width_px = -width; width = 0; } if (!height) height = LIBSSH2_TERM_HEIGHT; else if(height < 0) { height_px = -height; height = 0; } RETVAL = libssh2_channel_request_pty_ex(ch->channel, (char*)pv_terminal, len_terminal, (char*)pv_modes, len_modes, width, height, width_px, height_px); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_ch_pty_size(SSH2_CHANNEL* ch, int width = 0, int height = 0) PREINIT: int width_px = LIBSSH2_TERM_WIDTH_PX, height_px = LIBSSH2_TERM_HEIGHT_PX; CODE: if (!width) croak("%s::pty_size: required parameter width missing", class); else if(width < 0) { width_px = -width; width = 0; } if (!height) croak("%s::pty_size: required parameter height missing", class); else if(height < 0) { height_px = -height; height = 0; } RETVAL = libssh2_channel_request_pty_size_ex(ch->channel, width, height, width_px, height_px); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL #else void net_ch_pty(SSH2_CHANNEL* ch, SV* terminal, SV* modes = NULL, \ int width = 0, int height = 0) CODE: croak("libssh2 version 1.0 or higher required for PTY support"); void net_ch_pty_size(SSH2_CHANNEL* ch, int width = 0, int height = 0) CODE: croak("libssh2 version 1.0 or higher required for PTY support"); #endif SSH2_NERROR net_ch_process(SSH2_CHANNEL* ch, SV* request, SV* message = NULL) PREINIT: const char* pv_request, * pv_message = NULL; STRLEN len_request, len_message = 0; CODE: pv_request = SvPVbyte(request, len_request); if (message && SvPOK(message)) pv_message = SvPVbyte(message, len_message); RETVAL = libssh2_channel_process_startup(ch->channel, pv_request, len_request, pv_message, len_message); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL int net_ch_ext_data(SSH2_CHANNEL* ch, SSH2_CHANNEL_EXTENDED_DATA mode) CODE: libssh2_channel_handle_extended_data(ch->channel, (int)mode); RETVAL = 1; OUTPUT: RETVAL SSH2_BYTES64 net_ch_read(SSH2_CHANNEL* ch, SV* buffer, size_t size = 32768, SSH2_STREAM_ID ext = 0) PREINIT: char* pv_buffer; STRLEN len_buffer; int blocking, count = 0; size_t total = 0; CODE: debug("%s::read(size = %d, ext = %d)\n", class, size, ext); sv_force_normal(buffer); sv_setpvn_mg(buffer, "", 0); SvPVbyte_force(buffer, len_buffer); pv_buffer = sv_grow(buffer, size + 1); blocking = libssh2_session_get_blocking(ch->ss->session); while (size) { count = libssh2_channel_read_ex(ch->channel, ext, pv_buffer, size); debug("- read %d bytes\n", count); if (count > 0) { total += count; pv_buffer += count; size -= count; if (blocking) break; } else { if ((count != LIBSSH2_ERROR_EAGAIN) || !blocking) break; } } debug("- read %d total\n", total); if (total || (count == 0)) { pv_buffer[0] = '\0'; SvPOK_only(buffer); SvCUR_set(buffer, total); SvSETMAGIC(buffer); RETVAL = total; } else { SvOK_off(buffer); SvSETMAGIC(buffer); save_eagain(ch->ss->session, count); RETVAL = count; } OUTPUT: RETVAL SV * net_ch_getc(SSH2_CHANNEL* ch, SSH2_STREAM_ID ext = 0) PREINIT: char buffer[2]; int count; CODE: debug("%s::getc(ext = %d)\n", class, ext); count = libssh2_channel_read_ex(ch->channel, ext, buffer, 1); if (count >= 0) { buffer[count] = '\0'; RETVAL = newSVpvn(buffer, count); } else { save_eagain(ch->ss->session, count); RETVAL = &PL_sv_undef; } OUTPUT: RETVAL SSH2_BYTES net_ch_write(SSH2_CHANNEL* ch, SV* buffer, SSH2_STREAM_ID ext = 0) PREINIT: const char* pv_buffer; STRLEN len_buffer, offset = 0; int count = 0; CODE: /* 1. in blocking mode, write all the data. 2. in non-blocking mode, write as much data as possible without blocking. 3. if some error happens... a. if some data was already written, discard the error and report the number of bytes written. b. if no data was written, report the error. */ pv_buffer = SvPVbyte(buffer, len_buffer); while (offset < len_buffer) { count = libssh2_channel_write_ex(ch->channel, ext, pv_buffer + offset, len_buffer - offset); if (count >= 0) offset += count; else if ((count != LIBSSH2_ERROR_EAGAIN) || !libssh2_session_get_blocking(ch->ss->session)) break; } if (offset || (count == 0)) /* yes, zero is a valid value */ RETVAL = offset; else { save_eagain(ch->ss->session, count); RETVAL = -1; } OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010100 SSH2_BYTES net_ch_receive_window_adjust(SSH2_CHANNEL *ch, unsigned long adjustment, SV *force = &PL_sv_undef) PREINIT: unsigned int bytes; CODE: RETVAL = libssh2_channel_receive_window_adjust2(ch->channel, adjustment, SvTRUE(force), &bytes); if (RETVAL) save_eagain(ch->ss->session, RETVAL); else RETVAL = bytes; OUTPUT: RETVAL #else void net_ch_receive_window_adjust(SSH2_CHANNEL* ch, ...) CODE: croak("libssh2 version 1.1 or higher required for receive_window_adjust support"); #endif #if LIBSSH2_VERSION_NUM >= 0x010200 void net_ch_window_write(SSH2_CHANNEL* ch) PREINIT: unsigned long window_size_initial = 0; PPCODE: XPUSHs(sv_2mortal(newSVuv(libssh2_channel_window_write_ex(ch->channel, &window_size_initial)))); if (GIMME_V == G_ARRAY) { XPUSHs(sv_2mortal(newSVuv(window_size_initial))); XSRETURN(2); } else XSRETURN(1); void net_ch_window_read(SSH2_CHANNEL *ch) PREINIT: unsigned long read_avail = 0; unsigned long window_size_initial = 0; PPCODE: XPUSHs(sv_2mortal(newSVuv(libssh2_channel_window_read_ex(ch->channel, &read_avail, &window_size_initial)))); if (GIMME_V == G_ARRAY) { XPUSHs(sv_2mortal(newSVuv(read_avail))); XPUSHs(sv_2mortal(newSVuv(window_size_initial))); XSRETURN(3); } else XSRETURN(1); #else void net_ch_window_write(SSH2_CHANNEL* ch) CODE: croak("libssh2 version 1.2 or higher required for window_write support"); void net_ch_window_read(SSH2_CHANNEL* ch) CODE: croak("libssh2 version 1.2 or higher required for window_read support"); #endif SSH2_BYTES net_ch_flush(SSH2_CHANNEL* ch, SSH2_STREAM_ID ext = 0) CODE: RETVAL = libssh2_channel_flush_ex(ch->channel, ext); save_eagain(ch->ss->session, RETVAL); OUTPUT: RETVAL #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::Listener PREFIX = net_ls_ PROTOTYPES: DISABLE #define class "Net::SSH2::Listener" void net_ls_DESTROY(SSH2_LISTENER* ls) CODE: debug("%s::DESTROY\n", class); libssh2_channel_forward_cancel(ls->listener); SvREFCNT_dec(ls->sv_ss); Safefree(ls); SSH2_CHANNEL* net_ls_accept(SSH2_LISTENER* ls) PREINIT: SSH2* ss; CODE: ss = ls->ss; NEW_CHANNEL(libssh2_channel_forward_accept(ls->listener)); OUTPUT: RETVAL #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::SFTP PREFIX = net_sf_ PROTOTYPES: DISABLE #define class "Net::SSH2::SFTP" void net_sf_DESTROY(SSH2_SFTP* sf) CODE: debug("%s::DESTROY\n", class); libssh2_sftp_shutdown(sf->sftp); debug("%s::DESTROY freeing session\n", class); SvREFCNT_dec(sf->sv_ss); Safefree(sf); SV * net_sf_session(SSH2_SFTP* sf) CODE: RETVAL = newRV_inc(sf->sv_ss); OUTPUT: RETVAL void net_sf_error(SSH2_SFTP* sf) PREINIT: unsigned long error; SV *errstr; PPCODE: error = libssh2_sftp_last_error(sf->sftp); ST(0) = sv_2mortal(newSVuv(error)); if (GIMME_V == G_ARRAY) { EXTEND(SP, 2); if ((error >= 0) && (error < countof(sftp_error))) errstr = newSVpvf("SSH_FX_%s", sftp_error[error]); else errstr = newSVpvf("SSH_FX_UNKNOWN(%lu)", error); ST(1) = sv_2mortal(errstr); XSRETURN(2); } else XSRETURN(1); #define XLATFLAG(posix, fxf) do { \ if (flags & posix || \ l_flags == 0 && posix == 0 && flags == posix /* 0-valued flag */) { \ l_flags |= fxf; \ flags &= ~posix; \ } \ } while(0) SSH2_FILE* net_sf_open(SSH2_SFTP* sf, SV* file, int flags = O_RDONLY, int mode = 0666) PREINIT: long l_flags = 0; const char* pv_file; STRLEN len_file; CODE: pv_file = SvPVbyte(file, len_file); /* map POSIX O_* to LIBSSH2_FXF_* (can't assume they're the same) */ XLATFLAG(O_RDWR, LIBSSH2_FXF_READ | LIBSSH2_FXF_WRITE); XLATFLAG(O_RDONLY, LIBSSH2_FXF_READ); XLATFLAG(O_WRONLY, LIBSSH2_FXF_WRITE); XLATFLAG(O_APPEND, LIBSSH2_FXF_APPEND); XLATFLAG(O_CREAT, LIBSSH2_FXF_CREAT); XLATFLAG(O_TRUNC, LIBSSH2_FXF_TRUNC); XLATFLAG(O_EXCL, LIBSSH2_FXF_EXCL); if (flags) croak("%s::open: unknown flag value: %d", class, flags); NEW_FILE(libssh2_sftp_open_ex(sf->sftp, (char*)pv_file, len_file, l_flags, mode, LIBSSH2_SFTP_OPENFILE)); OUTPUT: RETVAL #undef XLATFLAG SSH2_DIR* net_sf_opendir(SSH2_SFTP* sf, SV* dir) PREINIT: const char* pv_dir; STRLEN len_dir; CODE: pv_dir = SvPVbyte(dir, len_dir); NEW_DIR(libssh2_sftp_open_ex(sf->sftp, (char*)pv_dir, len_dir, 0/*flags*/, 0/*mode*/, LIBSSH2_SFTP_OPENDIR)); OUTPUT: RETVAL SSH2_NERROR net_sf_unlink(SSH2_SFTP* sf, SV* file) PREINIT: char* pv_file; STRLEN len_file; CODE: pv_file = SvPVbyte(file, len_file); RETVAL = libssh2_sftp_unlink_ex(sf->sftp, (char*)pv_file, len_file); OUTPUT: RETVAL SSH2_NERROR net_sf_rename(SSH2_SFTP* sf, SV* old, SV* new, \ long flags = ( LIBSSH2_SFTP_RENAME_OVERWRITE | \ LIBSSH2_SFTP_RENAME_ATOMIC | \ LIBSSH2_SFTP_RENAME_NATIVE ) ) PREINIT: const char* pv_old, * pv_new; STRLEN len_old, len_new; CODE: pv_old = SvPVbyte(old, len_old); pv_new = SvPVbyte(new, len_new); RETVAL = libssh2_sftp_rename_ex(sf->sftp, (char*)pv_old, len_old, (char*)pv_new, len_new, flags); OUTPUT: RETVAL SSH2_NERROR net_sf_mkdir(SSH2_SFTP* sf, SV* dir, int mode = 0777) PREINIT: const char* pv_dir; STRLEN len_dir; CODE: pv_dir = SvPVbyte(dir, len_dir); RETVAL = libssh2_sftp_mkdir_ex(sf->sftp, (char*)pv_dir, len_dir, mode); OUTPUT: RETVAL SSH2_NERROR net_sf_rmdir(SSH2_SFTP* sf, SV* dir) PREINIT: const char* pv_dir; STRLEN len_dir; CODE: pv_dir = SvPVbyte(dir, len_dir); RETVAL = libssh2_sftp_rmdir_ex(sf->sftp, (char*)pv_dir, len_dir); OUTPUT: RETVAL void net_sf_stat(SSH2_SFTP* sf, SV* path, int follow = 1) PREINIT: const char* pv_path; STRLEN len_path; int error; LIBSSH2_SFTP_ATTRIBUTES attrs; PPCODE: pv_path = SvPVbyte(path, len_path); error = !libssh2_sftp_stat_ex(sf->sftp, (char*)pv_path, len_path, (follow ? LIBSSH2_SFTP_STAT : LIBSSH2_SFTP_LSTAT), &attrs); if (error < 0) XSRETURN_EMPTY; XSRETURN_STAT_ATTRS(SvREFCNT_inc(path)); SSH2_NERROR net_sf_setstat(SSH2_SFTP* sf, SV* path, ...) PREINIT: const char* pv_path; STRLEN len_path; LIBSSH2_SFTP_ATTRIBUTES attrs; int i; CODE: pv_path = SvPVbyte(path, len_path); Zero(&attrs, 1, LIBSSH2_SFTP_ATTRIBUTES); /* read key/value pairs; cf. hv_from_attrs */ for (i = 2; i < items; i += 2) { const char* key = SvPVbyte_nolen(ST(i)); if (i + 1 == items) croak("%s::setstat: key without value", class); if (0); /* prime the chain */ XLATATTR("size", filesize, SIZE) XLATATTR("uid", uid, UIDGID) XLATATTR("gid", gid, UIDGID) XLATATTR("mode", permissions, PERMISSIONS) XLATATTR("atime", atime, ACMODTIME) XLATATTR("mtime", mtime, ACMODTIME) else croak("%s::setstat: unknown attribute: %s", class, key); } RETVAL = libssh2_sftp_stat_ex(sf->sftp, (char*)pv_path, len_path, LIBSSH2_SFTP_SETSTAT, &attrs); OUTPUT: RETVAL SSH2_NERROR net_sf_symlink(SSH2_SFTP* sf, SV* path, SV* target) PREINIT: char *pv_path, *pv_target; STRLEN len_path, len_target; CODE: pv_path = SvPVbyte(path, len_path); pv_target = SvPVbyte(target, len_target); RETVAL = libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, pv_target, len_target, LIBSSH2_SFTP_SYMLINK); OUTPUT: RETVAL SV * net_sf_readlink(SSH2_SFTP* sf, SV* path) PREINIT: const char* pv_path; char* pv_link; STRLEN len_path; int count; CODE: pv_path = SvPVbyte(path, len_path); RETVAL = newSV(MAXPATHLEN + 1); pv_link = SvPVX(RETVAL); count = libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, pv_link, MAXPATHLEN, LIBSSH2_SFTP_READLINK); if (count >= 0) { SvPOK_on(RETVAL); pv_link[count] = '\0'; SvCUR_set(RETVAL, count); } OUTPUT: RETVAL SV * net_sf_realpath(SSH2_SFTP* sf, SV* path) PREINIT: const char* pv_path; char* pv_real; STRLEN len_path; int count; CODE: pv_path = SvPVbyte(path, len_path); RETVAL = newSV(MAXPATHLEN + 1); pv_real = SvPVX(RETVAL); count = libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, pv_real, MAXPATHLEN, LIBSSH2_SFTP_REALPATH); if (count >= 0) { SvPOK_on(RETVAL); pv_real[count] = '\0'; SvCUR_set(RETVAL, count); } OUTPUT: RETVAL #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::File PREFIX = net_fi_ PROTOTYPES: DISABLE #define class "Net::SSH2::File" void net_fi_DESTROY(SSH2_FILE* fi) CODE: debug("%s::DESTROY\n", class); libssh2_sftp_close_handle(fi->handle); SvREFCNT_dec(fi->sv_sf); Safefree(fi); SSH2_BYTES net_fi_read(SSH2_FILE* fi, SV* buffer, size_t size) PREINIT: char* pv_buffer; STRLEN len_buffer; CODE: sv_force_normal(buffer); sv_setpvn_mg(buffer, "", 0); SvPVbyte_force(buffer, len_buffer); pv_buffer = sv_grow(buffer, size + 1); RETVAL = libssh2_sftp_read(fi->handle, pv_buffer, size); if (RETVAL < 0) SvOK_off(buffer); else { SvPOK_only(buffer); pv_buffer[RETVAL] = '\0'; SvCUR_set(buffer, RETVAL); } SvSETMAGIC(buffer); OUTPUT: RETVAL SV * net_fi_getc(SSH2_FILE* fi) PREINIT: char buffer[2]; int count; CODE: count = libssh2_sftp_read(fi->handle, buffer, 1); if (count == 1) { buffer[count] = '\0'; RETVAL = newSVpvn(buffer, count); } else RETVAL = &PL_sv_undef; OUTPUT: RETVAL SSH2_BYTES net_fi_write(SSH2_FILE* fi, SV* buffer) PREINIT: const char* pv_buffer; STRLEN len_buffer; CODE: sv_utf8_downgrade(buffer, 0); pv_buffer = SvPVbyte(buffer, len_buffer); RETVAL = libssh2_sftp_write(fi->handle, pv_buffer, len_buffer); OUTPUT: RETVAL void net_fi_stat(SSH2_FILE* fi) PREINIT: LIBSSH2_SFTP_ATTRIBUTES attrs; PPCODE: if (libssh2_sftp_fstat(fi->handle, &attrs)) XSRETURN_EMPTY; XSRETURN_STAT_ATTRS(NULL/*name*/); SSH2_NERROR net_fi_setstat(SSH2_FILE* fi, ...) PREINIT: LIBSSH2_SFTP_ATTRIBUTES attrs; int i; CODE: Zero(&attrs, 1, LIBSSH2_SFTP_ATTRIBUTES); /* read key/value pairs; cf. hv_from_attrs */ for (i = 1; i < items; i += 2) { const char* key = SvPVbyte_nolen(ST(i)); if (i + 1 == items) croak("%s::setstat: key without value", class); if (0); /* prime the chain */ XLATATTR("size", filesize, SIZE) XLATATTR("uid", uid, UIDGID) XLATATTR("gid", gid, UIDGID) XLATATTR("mode", permissions, PERMISSIONS) XLATATTR("atime", atime, ACMODTIME) XLATATTR("mtime", mtime, ACMODTIME) else croak("%s::setstat: unknown attribute: %s", class, key); } RETVAL = libssh2_sftp_fsetstat(fi->handle, &attrs); OUTPUT: RETVAL int net_fi_seek(SSH2_FILE* fi, size_t offset) CODE: libssh2_sftp_seek64(fi->handle, offset); RETVAL = 1; OUTPUT: RETVAL SSH2_BYTES64 net_fi_tell(SSH2_FILE* fi) CODE: RETVAL = libssh2_sftp_tell64(fi->handle); OUTPUT: RETVAL #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::Dir PREFIX = net_di_ PROTOTYPES: DISABLE #define class "Net::SSH2::Dir" void net_di_DESTROY(SSH2_DIR* di) CODE: debug("%s::DESTROY\n", class); libssh2_sftp_close_handle(di->handle); SvREFCNT_dec(di->sv_sf); Safefree(di); void net_di_read(SSH2_DIR* di) PREINIT: SV* buffer; char* pv_buffer; int count; LIBSSH2_SFTP_ATTRIBUTES attrs; PPCODE: buffer = newSV(MAXPATHLEN + 1); SvPOK_on(buffer); pv_buffer = SvPVX(buffer); count = libssh2_sftp_readdir(di->handle, pv_buffer, MAXPATHLEN, &attrs); if (count <= 0) { SvREFCNT_dec(buffer); XSRETURN_EMPTY; } pv_buffer[count] = '\0'; SvCUR_set(buffer, count); XSRETURN_STAT_ATTRS(buffer); #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::PublicKey PREFIX = net_pk_ PROTOTYPES: DISABLE #define class "Net::SSH2::PublicKey" void net_pk_DESTROY(SSH2_PUBLICKEY* pk) CODE: debug("%s::DESTROY\n", class); libssh2_publickey_shutdown(pk->pkey); SvREFCNT_dec(pk->sv_ss); Safefree(pk); SSH2_NERROR net_pk_add(SSH2_PUBLICKEY* pk, SV* name, SV* blob, int overwrite, ...) PREINIT: const char* pv_name, * pv_blob; STRLEN len_name, len_blob; unsigned long num_attrs, i; libssh2_publickey_attribute *attrs; CODE: pv_name = SvPVbyte(name, len_name); pv_blob = SvPVbyte(blob, len_blob); num_attrs = items - 4; New(0, attrs, num_attrs, libssh2_publickey_attribute); if (!attrs) Perl_croak(aTHX_ "Out of memory!"); for (i = 0; i < num_attrs; ++i) { HV* hv; SV** tmp; STRLEN len_tmp; if (!SvROK(ST(i + 4)) || SvTYPE(SvRV(ST(i + 4))) != SVt_PVHV) croak("%s::add: attribute %lu is not hash", class, i); hv = (HV*)SvRV(ST(i + 4)); if (!(tmp = hv_fetch(hv, "name", 4, 0/*lval*/)) || !*tmp) croak("%s::add: attribute %lu missing name", class, i); attrs[i].name = SvPVbyte(*tmp, len_tmp); attrs[i].name_len = len_tmp; if ((tmp = hv_fetch(hv, "value", 5, 0/*lval*/)) && *tmp) { attrs[i].value = SvPVbyte(*tmp, len_tmp); attrs[i].value_len = len_tmp; } else attrs[i].value_len = 0; if ((tmp = hv_fetch(hv, "mandatory", 9, 0/*lval*/)) && *tmp) attrs[i].mandatory = (char)SvIV(*tmp); else attrs[i].mandatory = 0; } RETVAL = libssh2_publickey_add_ex(pk->pkey, (const unsigned char *)pv_name, len_name, (const unsigned char *)pv_blob, len_blob, overwrite, num_attrs, attrs); Safefree(attrs); OUTPUT: RETVAL SSH2_NERROR net_pk_remove(SSH2_PUBLICKEY* pk, SV* name, SV* blob) PREINIT: const char* pv_name, * pv_blob; STRLEN len_name, len_blob; CODE: pv_name = SvPVbyte(name, len_name); pv_blob = SvPVbyte(blob, len_blob); RETVAL = libssh2_publickey_remove_ex(pk->pkey, (const unsigned char *)pv_name, len_name, (const unsigned char *)pv_blob, len_blob); OUTPUT: RETVAL void net_pk_fetch(SSH2_PUBLICKEY* pk) PREINIT: unsigned long keys, i, j; libssh2_publickey_list* list = NULL; PPCODE: if (!libssh2_publickey_list_fetch(pk->pkey, &keys, &list) || !list) XSRETURN_EMPTY; if (GIMME_V == G_ARRAY) { EXTEND(SP, keys); for (i = 0; i < keys; ++i) { HV* hv = newHV(); AV* av = newAV(); hv_store(hv, "name", 4, newSVpvn((char*)list[i].name, list[i].name_len), 0/*hash*/); hv_store(hv, "blob", 4, newSVpvn((char*)list[i].blob, list[i].blob_len), 0/*hash*/); hv_store(hv, "attr", 4, newRV_noinc((SV*)av), 0/*hash*/); av_extend(av, list[i].num_attrs - 1); for (j = 0; j < list[i].num_attrs; ++j) { HV* attr = newHV(); hv_store(attr, "name", 4, newSVpvn(list[i].attrs[j].name, list[i].attrs[j].name_len), 0/*hash*/); hv_store(attr, "value", 5, newSVpvn(list[i].attrs[j].value, list[i].attrs[j].value_len), 0/*hash*/); hv_store(attr, "mandatory", 9, newSViv(list[i].attrs[j].mandatory), 0/*hash*/); av_store(av, j, newRV_noinc((SV*)attr)); } ST(i) = sv_2mortal(newRV_noinc((SV*)hv)); } } libssh2_publickey_list_free(pk->pkey, list); if (GIMME_V == G_ARRAY) XSRETURN(keys); XSRETURN_UV(keys); #undef class MODULE = Net::SSH2 PACKAGE = Net::SSH2::KnownHosts PREFIX = net_kh_ PROTOTYPES: DISABLE #define class "Net::SSH2::KnownHosts" #if LIBSSH2_VERSION_NUM >= 0x010200 void net_kh_DESTROY(SSH2_KNOWNHOSTS *kh) CODE: debug("%s::DESTROY\n", class); libssh2_knownhost_free(kh->knownhosts); SvREFCNT_dec(kh->sv_ss); Safefree(kh); SSH2_BYTES net_kh_readfile(SSH2_KNOWNHOSTS *kh, SSH2_CHARP filename) CODE: RETVAL = libssh2_knownhost_readfile(kh->knownhosts, filename, LIBSSH2_KNOWNHOST_FILE_OPENSSH); OUTPUT: RETVAL SSH2_NERROR net_kh_writefile(SSH2_KNOWNHOSTS *kh, SSH2_CHARP filename) CODE: RETVAL = libssh2_knownhost_writefile(kh->knownhosts, filename, LIBSSH2_KNOWNHOST_FILE_OPENSSH); save_eagain(kh->ss->session, RETVAL); OUTPUT: RETVAL SSH2_NERROR net_kh_add(SSH2_KNOWNHOSTS *kh, SSH2_CHARP host, SSH2_CHARP salt, SV *key, SV *comment, int typemask) PREINIT: STRLEN key_len, comment_len; const char *key_pv, *comment_pv; CODE: key_pv = SvPVbyte(key, key_len); if (SvOK(comment)) comment_pv = SvPVbyte(comment, comment_len); else { comment_pv = NULL; comment_len = 0; } #if LIBSSH2_VERSION_NUM >= 0x010205 RETVAL = libssh2_knownhost_addc(kh->knownhosts, host, salt, key_pv, key_len, comment_pv, comment_len, typemask, NULL); #else RETVAL = libssh2_knownhost_add(kh->knownhosts, host, salt, key_pv, key_len, typemask, NULL); #endif save_eagain(kh->ss->session, RETVAL); OUTPUT: RETVAL int net_kh_check(SSH2_KNOWNHOSTS *kh, SSH2_CHARP host, SV *port, SV *key, int typemask) PREINIT: STRLEN key_len; const char *key_pv; UV port_uv; CODE: key_pv = SvPVbyte(key, key_len); port_uv = (SvOK(port) ? SvUV(port) : 0); #if LIBSSH2_VERSION_NUM >= 0x010206 RETVAL = libssh2_knownhost_checkp(kh->knownhosts, host, port_uv, key_pv, key_len, typemask, NULL); #else if ((port_uv != 0) && (port_uv != 22)) croak("libssh2 version 1.2.6 is required when using a custom TCP port"); RETVAL = libssh2_knownhost_check(kh->knownhosts, host, key_pv, key_len, typemask, NULL); #endif OUTPUT: RETVAL SSH2_NERROR net_kh_readline(SSH2_KNOWNHOSTS *kh, SV *line) PREINIT: STRLEN line_len; const char *line_pv; CODE: line_pv = SvPVbyte(line, line_len); RETVAL = libssh2_knownhost_readline(kh->knownhosts, line_pv, line_len, LIBSSH2_KNOWNHOST_FILE_OPENSSH); save_eagain(kh->ss->session, RETVAL); OUTPUT: RETVAL SV * net_kh_writeline(SSH2_KNOWNHOSTS *kh, SSH2_CHARP host, SV *port, SV *key, int typemask) PREINIT: int rc; STRLEN key_len; const char *key_pv; UV port_uv; size_t line_len; STRLEN buffer_len; SV *buffer; struct libssh2_knownhost *entry = NULL; CODE: RETVAL = &PL_sv_undef; key_pv = SvPVbyte(key, key_len); port_uv = (SvOK(port) ? SvUV(port) : 0); #if LIBSSH2_VERSION_NUM >= 0x010206 rc = libssh2_knownhost_checkp(kh->knownhosts, host, port_uv, key_pv, key_len, typemask, &entry); #else if ((port_uv != 0) && (port_uv != 22)) croak("libssh2 version 1.2.6 is required when using a custom TCP port"); rc = libssh2_knownhost_check(kh->knownhosts, host, key_pv, key_len, typemask, &entry); #endif if ((rc != LIBSSH2_KNOWNHOST_CHECK_MATCH) || !entry) { #if LIBSSH2_VERSION_NUM >= 0x010601 libssh2_session_set_last_error(kh->ss->session, LIBSSH2_ERROR_KNOWN_HOSTS, "matching host key not found"); #endif } else { buffer = sv_2mortal(newSV(512)); SvPOK_on(buffer); while (1) { rc = libssh2_knownhost_writeline(kh->knownhosts, entry, SvPVX(buffer), SvLEN(buffer), &line_len, LIBSSH2_KNOWNHOST_FILE_OPENSSH); if (rc == LIBSSH2_ERROR_NONE) { SvPVX(buffer)[line_len] = '\0'; SvCUR_set(buffer, line_len); RETVAL = SvREFCNT_inc(buffer); break; } if ((rc != LIBSSH2_ERROR_BUFFER_TOO_SMALL) || (SvLEN(buffer) > 256 * 1024)) break; SvGROW(buffer, SvLEN(buffer) * 2); } } OUTPUT: RETVAL # /* TODO */ # libssh2_knownhost_del() # libssh2_knownhost_get() # libssh2_knownhost_writeline() #endif #undef class # vim: set et ts=4: Net-SSH2-0.69/t/0000755000175000017500000000000013244346650012163 5ustar salvasalvaNet-SSH2-0.69/t/Net-SSH2.t0000644000175000017500000003502313232575602013614 0ustar salvasalva# -*- Mode: CPerl -*- # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-SSH2.t' # THIS LINE WILL BE READ BY A TEST BELOW ######################### use Test::More; use strict; use Fcntl qw(O_CREAT O_EXCL O_WRONLY); use File::Spec; use Getopt::Long; ######################### # default testing items from %ENV to facilitate testing my $host = $ENV{TEST_NET_SSH2_HOST}; my $port = $ENV{TEST_NET_SSH2_PORT}; my $user = $ENV{TEST_NET_SSH2_USER}; my $password = $ENV{TEST_NET_SSH2_PASSWORD}; my $passphrase = $ENV{TEST_NET_SSH2_PASSPHRASE}; my $known_hosts = $ENV{TEST_NET_SSH2_KNOWN_HOSTS}; my $policy = $ENV{TEST_NET_SSH2_POLICY} || 'ask'; my $timeout = $ENV{TEST_NET_SSH2_TIMEOUT} || 30; my $trace = $ENV{TEST_NET_SSH2_TRACE}; $known_hosts ||= File::Spec->devnull; GetOptions("host|h=s" => \$host, "port|p=s" => \$port, "user|u=s" => \$user, "password|pwd|pw|w=s" => \$password, "passphrase|pp=s" => \$passphrase, "known_hosts|kh|k=s" => \$known_hosts, "policy|o=s" => \$policy, "timeout|t=s" => \$timeout); $| = 1; sub slurp; sub quote; $timeout = ($timeout ? $timeout * 1000 : undef); # (1) use module BEGIN { use_ok('Net::SSH2', ':all') }; # (4) basics: create an object, check status my $ssh2 = Net::SSH2->new(); isa_ok($ssh2, 'Net::SSH2', 'new session'); ok(!$ssh2->error(), 'error state clear'); SKIP: { skip '- timeout not supported in libssh2 < 1.2.9', 1 if ($ssh2->version)[1] < 0x010209; is($ssh2->timeout($timeout), $timeout, "set timeout to ${timeout}s"); } SKIP: { skip 'trace dissabled', 1 unless $trace; $ssh2->trace($trace); } ok($ssh2->banner('SSH TEST'), 'set banner'); is(LIBSSH2_ERROR_SOCKET_NONE(), -1, 'LIBSSH2_* constants'); is(LIBSSH2_ERROR_NONE(), 0, "LIBSSH2_ERROR_NONE is zero"); is(Net::SSH2::LIBSSH2_ERROR_NONE(), 0, "LIBSSH2_ERROR_NONE is zero bis"); # (4) version my $version = $ssh2->version(); my ($version2, $vernum, $banner) = $ssh2->version(); is($version, $version2, 'list version match'); my ($major) = $version =~ /^(\d+)/; diag "libssh2 version: $version\n"; if (!defined($vernum) or $vernum < 0x010500) { diag "\n*** Your version of libssh2 is very old and broken. Upgrade it!!! ***\n\n"; } elsif ($vernum < 0x010700) { diag "Your version of libssh2 is behind the recomended 1.7.0"; } is($banner, "SSH-2.0-libssh2_$version", "banner is $banner"); # (2) timeout is($ssh2->poll(0), 0, 'poll indefinite'); is($ssh2->poll(2000), 0, 'poll 2 second'); is($ssh2->sock, undef, '->sock is undef before connect'); is($ssh2->hostname, undef, '->hostname is undef before connect'); # (1) connect unless (defined $host) { if (-t STDIN and -t STDOUT) { chomp(my $prompt = <_ask_user($prompt, 1); } unless (defined $host and length $host) { done_testing; exit(0); } } ($host, $port) = split /:/, $host if (($host =~ tr/://) == 1); if (defined $port) { ok($ssh2->connect($host, $port), "connect to $host port $port"); } else { ok($ssh2->connect($host), "connect to $host"); } isa_ok($ssh2->sock, 'IO::Socket', '->sock isa IO::Socket'); is($ssh2->hostname, $host, '->hostname'); # (8) server methods for my $type (qw(kex hostkey crypt_cs crypt_sc mac_cs mac_sc comp_cs comp_sc)) { my $method = $ssh2->method($type); ok($ssh2->method($type), "$type method: $method"); } # (2) check host key my $md5 = $ssh2->hostkey_hash('md5'); is(length $md5, 16, 'have MD5 hostkey hash'); my $sha1 = $ssh2->hostkey_hash('sha1'); is(length $sha1, 20, 'have SHA1 hostkey hash'); ok($ssh2->check_hostkey('advisory', $known_hosts), "check remote key - advisory") or diag(join " ", "Error:", $ssh2->error); ok($ssh2->check_hostkey($policy, $known_hosts), "check remote key - ask") or diag(join " ", "Error:", $ssh2->error); # (3) authentication methods unless ($user) { my $def_user = eval { getpwuid $< }; $user = $ssh2->_ask_user("Enter username" . ($def_user ? " [$def_user]: " : ": "), 1); $user = $def_user unless defined $user and length $user; } my $auth = $ssh2->auth_list($user); ok($auth, "authenticate: $auth"); my @auth_methods = split /,/, $auth; is_deeply(\@auth_methods, [$ssh2->auth_list($user)], 'list matches comma-separated'); ok(!$ssh2->auth_ok, 'not authenticated yet'); # (2) authenticate my $type; my $home = $ssh2->_local_home; if (defined $home) { for my $key (qw(dsa rsa)) { my $path = "$home/.ssh/id_$key"; if ($ssh2->auth_publickey($user, "$path.pub", $path, $passphrase)) { diag "authenticated with key at $path"; $type = 'pubkey'; last; } else { diag "failed to authenticate with key at $path"; } } } unless ($type) { diag "reverting to password authentication"; $type = $ssh2->auth(username => $user, password => $password, interact => 1); } ok($ssh2->auth_ok, 'authenticated successfully'); ok($type, "authentication type is defined (".($type||undef).")"); # (5) channels ok(!defined eval { $ssh2->channel("direct-tcpip") }, "only session channels"); my $chan = $ssh2->channel(); isa_ok($chan, 'Net::SSH2::Channel'); $chan->blocking(0); pass('set blocking'); ok(!$chan->eof(), 'not at EOF'); ok($chan->ext_data('normal'), 'normal extended data handling'); ok($chan->ext_data('merge'), 'merge extended data'); # (3) environment is($chan->setenv(), 1, 'empty setenv'); my %env = (test1 => 'A', test2 => 'something', test3 => 'E L S E', LANG => 'C'); # most sshds disallow set, so we're happy if these don't crash ok($chan->setenv(%env) || 1, 'set environment variables, it is ok if it fails'); is($chan->session, $ssh2, 'verify session'); # (1) callback ok($ssh2->callback(disconnect => sub { warn "SSH_MSG_DISCONNECT!\n"; }), 'set disconnect callback'); # (2) SFTP $ssh2->blocking(1); # creating channel may block my $sftp = $ssh2->sftp(); isa_ok($sftp, 'Net::SSH2::SFTP'); is($sftp->session, $ssh2, 'verify session'); # (4) directories my $dir = "net_ssh2_$$"; ok($sftp->mkdir($dir), "create directory $dir"); my %stat = $sftp->stat($dir); ok(scalar keys %stat, 'stat directory'); ok($stat{mode} & 0x4000, 'type is directory'); is($stat{name}, $dir, 'directory name matches'); # (4) SCP my $fn = "ppport.h"; my ($local_vol, $local_dir) = File::Spec->splitpath(File::Spec->rel2abs($0)); my $local_fn = File::Spec->join($local_vol, $local_dir, File::Spec->updir, $fn); my $local_data = slurp($local_fn); my @local_lines = slurp($local_fn); my $remote_fn = "$dir/$fn"; ok($ssh2->scp_put($local_fn, $remote_fn), "put $local_fn to remote $remote_fn"); SKIP: { # SKIP-scalar eval { require IO::Scalar }; skip '- IO::Scalar required', 2 if $@; my $tmp = IO::Scalar->new; ok($ssh2->scp_get($remote_fn, $tmp), "get $remote_fn from remote"); my $remote_data = ${$tmp->sref}; if (length $remote_data == length $local_data) { is($remote_data, $local_data, 'files match'); } else { fail('file size match'); if (length $remote_data == 0) { diag <channel(); # $ssh2->trace(-1); $chan->ext_data('ignore'); $chan->send_eof; ok($chan->exec("cat $remote_fn_quoted"), "exec cat $remote_fn_quoted"); my $remote_data = do { local $/; <$chan> }; is ($remote_data, $local_data); $chan = $ssh2->channel(); $chan->ext_data('ignore'); ok($chan->exec("cat $remote_fn_quoted"), "exec cat $remote_fn_quoted"); $chan->send_eof; my @remote_lines = <$chan>; is_deeply (\@remote_lines, \@local_lines, 'channel readline, list ctx'); $chan = $ssh2->channel(); $chan->ext_data('ignore'); ok($chan->exec("cat $remote_fn_quoted"), "exec cat $remote_fn_quoted"); $chan->send_eof; my $remote_data = $chan->getc; ok (defined $remote_data, 'getc defined'); is ($remote_data, substr($local_data, 0, length($remote_data)), 'channel getc value'); $chan = $ssh2->channel(); $chan->ext_data('ignore'); ok($chan->exec("cat $remote_fn_quoted"), "exec cat $remote_fn_quoted"); $chan->send_eof; @remote_lines = (); push @remote_lines, $_ while <$chan>; is_deeply (\@remote_lines, \@local_lines, 'channel readline, scalar ctx'); # (3) rename my $fn_alt = "$fn.renamed"; my $remote_fn_alt = "$remote_fn.renamed"; $sftp->unlink($remote_fn_alt); ok(!$sftp->unlink($remote_fn_alt), 'unlink non-existant file fails'); my @error = $sftp->error(); is_deeply(\@error, [LIBSSH2_FX_NO_SUCH_FILE(), 'SSH_FX_NO_SUCH_FILE'], 'got LIBSSH2_FX_NO_SUCH_FILE error'); ok($sftp->rename($remote_fn, $remote_fn_alt), "rename $remote_fn -> $remote_fn_alt"); # (3) stat %stat = $sftp->stat($remote_fn_alt); ok(scalar keys %stat, "stat $remote_fn_alt"); is($stat{name}, $remote_fn_alt, 'stat filename matches'); is($stat{size}, -s $local_fn, 'stat filesize matches'); # (3) open my $fh = $sftp->open($remote_fn_alt); isa_ok($fh, 'Net::SSH2::File', 'opened file'); my %fstat = $fh->stat; delete $stat{name}; # fstat has no name is_deeply(\%stat, \%fstat, 'compare stat and fstat'); my $fstat = $fh->stat; is_deeply($fstat, \%fstat, 'compare fstat % and %$'); undef $fh; # (3) exercise File tie interface my $fh = $sftp->open($remote_fn_alt); isa_ok($fh, 'Net::SSH2::File', 'opened file'); my $line = ''; my $count = read($fh, $line, 20000); ok(defined($count), 'file read via tie interface'); $count = read($fh, $line, 40000, length($line)); ok(defined($count),'file read via tie interface 2'); is ($line, substr($local_data, 0, length($line)), 'validate file read via tie interface 3'); $fh->seek(0); my @remote_lines = <$fh>; is_deeply(\@remote_lines, \@local_lines, 'read file lines via tie interface, list ctx'); $fh->seek(0); @remote_lines = (); push @remote_lines, $_ while <$fh>; is_deeply(\@remote_lines, \@local_lines, 'read file lines via tie interface, scalar ctx'); $fh->seek(0); my ($remote_data) = do { local $/; <$fh> }; is ($remote_data, $local_data, 'read lines with $/ undefined'); my $mode = binmode $fh; ok($mode, 'binmode via tie interface'); is(eof($fh), 0, 'eof via tie interface'); is(close $fh, undef, 'close via tie interface'); undef $fh; my $outfile = $dir . '/write.out'; my $fh = $sftp->open($outfile,O_CREAT|O_EXCL|O_WRONLY); isa_ok($fh, 'Net::SSH2::File', 'opened file for writing'); $count = print $fh 'test '; is($count,5,'print via tie interface'); $, = ','; $count = print $fh 'test '; undef $,; is($count,5,'print with separator via tie interface'); $count = printf $fh 'test %d',1; is($count, 6, 'printf via tie interface'); undef $fh; $sftp->unlink($outfile); # (2) SFTP dir my $dh = $sftp->opendir($dir); isa_ok($dh, 'Net::SSH2::Dir', 'opened directory'); my $found; while(my $item = $dh->read) { $found++ if $item->{name} eq $fn_alt } is($found, 1, "found $remote_fn_alt once"); undef $dh; # (3) cleanup SFTP ok($sftp->unlink($remote_fn_alt), "unlink $remote_fn_alt"); ok($sftp->rmdir($dir), "remove directory $dir"); undef $sftp; pass('close SFTP session'); # (5) poll ok($chan = $ssh2->channel("session"), "open channel stating type session"); ok($chan->exec('ls -d /'), "exec 'ls -d /'"); $chan->blocking(0); # don't block, or we'll wait forever my @poll = { handle => $chan, events => ['in'] }; ok($ssh2->poll(2000, \@poll), 'got poll response'); ok($poll[0]->{revents}->{in}, 'got input event'); $line = <$chan>; chomp $line; is($line, '/', "got result '/'"); $line = <$chan>; ok(!$line, 'no more lines'); # (4) public key $ssh2->blocking(1); # creating channel may block $chan = $ssh2->channel(); SKIP: { skip '- timeout not supported in libssh2 < 1.2.9', 11 if ($ssh2->version)[1] < 0x010209; ok($chan->exec('cat'), "exec 'cat'"); is($ssh2->timeout(100), 100, "sets timeout"); is($ssh2->timeout, 100, "timeout is 100"); ok(!$chan->read(my $buf, 10), "read fails"); is(($ssh2->error)[0], Net::SSH2::LIBSSH2_ERROR_TIMEOUT(), "error timeout"); is($ssh2->timeout(0), undef, "sets timeout to 0"); is($ssh2->timeout, undef, "timeout is undef"); is($ssh2->timeout(10), 10, "sets timeout to 10"); is($ssh2->timeout(undef), undef, "sets timeout to undef"); is($ssh2->timeout, undef, "timeout is undef 2"); is($ssh2->timeout($timeout), $timeout, "finally, set timeout to ${timeout}s again"); } my $pk = $ssh2->public_key; SKIP: { skip ' - public key infrastructure not present', 4 unless $pk; diag "What? you have the public key module working!!!"; isa_ok($pk, 'Net::SSH2::PublicKey', 'public key session'); my @keys = $pk->fetch(); pass('got '.(scalar @keys).' keys in array'); my $keys = $pk->fetch(); pass("got $keys keys available"); is(scalar @keys, $keys, 'public key counts match'); } undef $pk; ok($chan->close(), 'close channel'); # optional step undef $fh; # (5) exercise Channel tie interface $chan = $ssh2->channel(); isa_ok($chan, 'Net::SSH2::Channel'); is(eof($chan), 0, 'channel eof via tie interface'); $mode = binmode $chan; is($mode, 1, 'channel binmode via tie interface'); $chan->shell; $chan->subsystem('dummy'); is($chan->error,-39, 'channel error'); { local $, = ';'; $count = print $chan "echo hello\n"; is($count, 11, 'channel print with separator via tie interface'); undef $,; $count = print $chan "echo bye\n"; is($count, 9, 'channel print via tie interface'); $count = printf $chan "exit\n"; is($count, 5, 'channel printf via tie interface'); } { local $?; ok(close($chan) || $?, 'channel close via tie interface'); } undef $chan; # (2) disconnect ok($ssh2->disconnect('leaving'), 'sent disconnect message'); done_testing; exit(0); sub slurp { my $file = shift; if (open my $fh, '<', $file) { binmode $fh; my @data = do { local $/ unless wantarray; <$fh>; }; if (close $fh) { return (wantarray ? @data : $data[0]); } } die "Unable to read file '$file': $!"; } sub quote { my @o = map { join '', map( /'/ ? qq("$_") : /\W/ ? qq('$_') : $_ , split /('+)/ ) } @_; wantarray ? @o : $o[0]; } # vim:filetype=perl Net-SSH2-0.69/const-c.inc0000644000175000017500000022104013244346623013760 0ustar salvasalva#define PERL_constant_NOTFOUND 1 #define PERL_constant_NOTDEF 2 #define PERL_constant_ISIV 3 #define PERL_constant_ISNO 4 #define PERL_constant_ISNV 5 #define PERL_constant_ISPV 6 #define PERL_constant_ISPVN 7 #define PERL_constant_ISSV 8 #define PERL_constant_ISUNDEF 9 #define PERL_constant_ISUV 10 #define PERL_constant_ISYES 11 #ifndef NVTYPE typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */ #endif #ifndef aTHX_ #define aTHX_ /* 5.6 or later define this for threading support. */ #endif #ifndef pTHX_ #define pTHX_ /* 5.6 or later define this for threading support. */ #endif static int constant_17 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_FXF_CREAT LIBSSH2_FXF_TRUNC LIBSSH2_FXF_WRITE LIBSSH2_SFTP_STAT LIBSSH2_TRACE_KEX LIBSSH2_TRACE_SCP */ /* Offset 14 gives the best switch position. */ switch (name[14]) { case 'E': if (memEQ(name, "LIBSSH2_FXF_CREAT", 17)) { /* ^ */ #ifdef LIBSSH2_FXF_CREAT *iv_return = LIBSSH2_FXF_CREAT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_FXF_WRITE", 17)) { /* ^ */ #ifdef LIBSSH2_FXF_WRITE *iv_return = LIBSSH2_FXF_WRITE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'K': if (memEQ(name, "LIBSSH2_TRACE_KEX", 17)) { /* ^ */ #ifdef LIBSSH2_TRACE_KEX *iv_return = LIBSSH2_TRACE_KEX; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_TRACE_SCP", 17)) { /* ^ */ #ifdef LIBSSH2_TRACE_SCP *iv_return = LIBSSH2_TRACE_SCP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_SFTP_STAT", 17)) { /* ^ */ #ifdef LIBSSH2_SFTP_STAT *iv_return = LIBSSH2_SFTP_STAT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'U': if (memEQ(name, "LIBSSH2_FXF_TRUNC", 17)) { /* ^ */ #ifdef LIBSSH2_FXF_TRUNC *iv_return = LIBSSH2_FXF_TRUNC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_18 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_FILE LIBSSH2_ERROR_NONE LIBSSH2_ERROR_ZLIB LIBSSH2_FXF_APPEND LIBSSH2_FX_FAILURE LIBSSH2_METHOD_KEX LIBSSH2_SFTP_LSTAT LIBSSH2_TERM_WIDTH LIBSSH2_TRACE_AUTH LIBSSH2_TRACE_CONN LIBSSH2_TRACE_SFTP */ /* Offset 14 gives the best switch position. */ switch (name[14]) { case 'A': if (memEQ(name, "LIBSSH2_TRACE_AUTH", 18)) { /* ^ */ #ifdef LIBSSH2_TRACE_AUTH *iv_return = LIBSSH2_TRACE_AUTH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "LIBSSH2_TRACE_CONN", 18)) { /* ^ */ #ifdef LIBSSH2_TRACE_CONN *iv_return = LIBSSH2_TRACE_CONN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'F': if (memEQ(name, "LIBSSH2_ERROR_FILE", 18)) { /* ^ */ #ifdef LIBSSH2_ERROR_FILE *iv_return = LIBSSH2_ERROR_FILE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_TERM_WIDTH", 18)) { /* ^ */ #ifdef LIBSSH2_TERM_WIDTH *iv_return = LIBSSH2_TERM_WIDTH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_FX_FAILURE", 18)) { /* ^ */ #ifdef LIBSSH2_FX_FAILURE *iv_return = LIBSSH2_FX_FAILURE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_ERROR_NONE", 18)) { /* ^ */ #ifdef LIBSSH2_ERROR_NONE *iv_return = LIBSSH2_ERROR_NONE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_FXF_APPEND", 18)) { /* ^ */ #ifdef LIBSSH2_FXF_APPEND *iv_return = LIBSSH2_FXF_APPEND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_SFTP_LSTAT", 18)) { /* ^ */ #ifdef LIBSSH2_SFTP_LSTAT *iv_return = LIBSSH2_SFTP_LSTAT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_TRACE_SFTP", 18)) { /* ^ */ #ifdef LIBSSH2_TRACE_SFTP *iv_return = LIBSSH2_TRACE_SFTP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'Z': if (memEQ(name, "LIBSSH2_ERROR_ZLIB", 18)) { /* ^ */ #ifdef LIBSSH2_ERROR_ZLIB *iv_return = LIBSSH2_ERROR_ZLIB; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_METHOD_KEX", 18)) { /* ^ */ #ifdef LIBSSH2_METHOD_KEX *iv_return = LIBSSH2_METHOD_KEX; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_19 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_ALLOC LIBSSH2_ERROR_INVAL LIBSSH2_ERROR_PROTO LIBSSH2_FX_NO_MEDIA LIBSSH2_TERM_HEIGHT LIBSSH2_TRACE_ERROR LIBSSH2_TRACE_TRANS */ /* Offset 18 gives the best switch position. */ switch (name[18]) { case 'A': if (memEQ(name, "LIBSSH2_FX_NO_MEDI", 18)) { /* A */ #ifdef LIBSSH2_FX_NO_MEDIA *iv_return = LIBSSH2_FX_NO_MEDIA; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "LIBSSH2_ERROR_ALLO", 18)) { /* C */ #ifdef LIBSSH2_ERROR_ALLOC *iv_return = LIBSSH2_ERROR_ALLOC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_ERROR_INVA", 18)) { /* L */ #ifdef LIBSSH2_ERROR_INVAL *iv_return = LIBSSH2_ERROR_INVAL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_ERROR_PROT", 18)) { /* O */ #ifdef LIBSSH2_ERROR_PROTO *iv_return = LIBSSH2_ERROR_PROTO; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_TRACE_ERRO", 18)) { /* R */ #ifdef LIBSSH2_TRACE_ERROR *iv_return = LIBSSH2_TRACE_ERROR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_TRACE_TRAN", 18)) { /* S */ #ifdef LIBSSH2_TRACE_TRANS *iv_return = LIBSSH2_TRACE_TRANS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_TERM_HEIGH", 18)) { /* T */ #ifdef LIBSSH2_TERM_HEIGHT *iv_return = LIBSSH2_TERM_HEIGHT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_20 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CALLBACK_X11 LIBSSH2_ERROR_EAGAIN LIBSSH2_FLAG_SIGPIPE LIBSSH2_FX_LINK_LOOP LIBSSH2_SFTP_OPENDIR LIBSSH2_SFTP_SETSTAT LIBSSH2_SFTP_SYMLINK LIBSSH2_SFTP_VERSION LIBSSH2_TRACE_SOCKET */ /* Offset 15 gives the best switch position. */ switch (name[15]) { case 'A': if (memEQ(name, "LIBSSH2_ERROR_EAGAIN", 20)) { /* ^ */ #ifdef LIBSSH2_ERROR_EAGAIN *iv_return = LIBSSH2_ERROR_EAGAIN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_SFTP_OPENDIR", 20)) { /* ^ */ #ifdef LIBSSH2_SFTP_OPENDIR *iv_return = LIBSSH2_SFTP_OPENDIR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "LIBSSH2_FLAG_SIGPIPE", 20)) { /* ^ */ #ifdef LIBSSH2_FLAG_SIGPIPE *iv_return = LIBSSH2_FLAG_SIGPIPE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'K': if (memEQ(name, "LIBSSH2_CALLBACK_X11", 20)) { /* ^ */ #ifdef LIBSSH2_CALLBACK_X11 *iv_return = LIBSSH2_CALLBACK_X11; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_SFTP_SYMLINK", 20)) { /* ^ */ #ifdef LIBSSH2_SFTP_SYMLINK *iv_return = LIBSSH2_SFTP_SYMLINK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_TRACE_SOCKET", 20)) { /* ^ */ #ifdef LIBSSH2_TRACE_SOCKET *iv_return = LIBSSH2_TRACE_SOCKET; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_SFTP_VERSION", 20)) { /* ^ */ #ifdef LIBSSH2_SFTP_VERSION *iv_return = LIBSSH2_SFTP_VERSION; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_SFTP_SETSTAT", 20)) { /* ^ */ #ifdef LIBSSH2_SFTP_SETSTAT *iv_return = LIBSSH2_SFTP_SETSTAT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_FX_LINK_LOOP", 20)) { /* ^ */ #ifdef LIBSSH2_FX_LINK_LOOP *iv_return = LIBSSH2_FX_LINK_LOOP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_21 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_DECRYPT LIBSSH2_ERROR_TIMEOUT LIBSSH2_FLAG_COMPRESS LIBSSH2_METHOD_MAC_CS LIBSSH2_METHOD_MAC_SC LIBSSH2_POLLFD_POLLEX LIBSSH2_POLLFD_POLLIN LIBSSH2_POLLFD_SOCKET LIBSSH2_SFTP_OPENFILE LIBSSH2_SFTP_READLINK LIBSSH2_SFTP_REALPATH LIBSSH2_TERM_WIDTH_PX */ /* Offset 19 gives the best switch position. */ switch (name[19]) { case 'C': if (memEQ(name, "LIBSSH2_METHOD_MAC_CS", 21)) { /* ^ */ #ifdef LIBSSH2_METHOD_MAC_CS *iv_return = LIBSSH2_METHOD_MAC_CS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_POLLFD_POLLEX", 21)) { /* ^ */ #ifdef LIBSSH2_POLLFD_POLLEX *iv_return = LIBSSH2_POLLFD_POLLEX; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_POLLFD_SOCKET", 21)) { /* ^ */ #ifdef LIBSSH2_POLLFD_SOCKET *iv_return = LIBSSH2_POLLFD_SOCKET; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_POLLFD_POLLIN", 21)) { /* ^ */ #ifdef LIBSSH2_POLLFD_POLLIN *iv_return = LIBSSH2_POLLFD_POLLIN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_SFTP_OPENFILE", 21)) { /* ^ */ #ifdef LIBSSH2_SFTP_OPENFILE *iv_return = LIBSSH2_SFTP_OPENFILE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_SFTP_READLINK", 21)) { /* ^ */ #ifdef LIBSSH2_SFTP_READLINK *iv_return = LIBSSH2_SFTP_READLINK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_ERROR_DECRYPT", 21)) { /* ^ */ #ifdef LIBSSH2_ERROR_DECRYPT *iv_return = LIBSSH2_ERROR_DECRYPT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_TERM_WIDTH_PX", 21)) { /* ^ */ #ifdef LIBSSH2_TERM_WIDTH_PX *iv_return = LIBSSH2_TERM_WIDTH_PX; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_FLAG_COMPRESS", 21)) { /* ^ */ #ifdef LIBSSH2_FLAG_COMPRESS *iv_return = LIBSSH2_FLAG_COMPRESS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_METHOD_MAC_SC", 21)) { /* ^ */ #ifdef LIBSSH2_METHOD_MAC_SC *iv_return = LIBSSH2_METHOD_MAC_SC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_SFTP_REALPATH", 21)) { /* ^ */ #ifdef LIBSSH2_SFTP_REALPATH *iv_return = LIBSSH2_SFTP_REALPATH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'U': if (memEQ(name, "LIBSSH2_ERROR_TIMEOUT", 21)) { /* ^ */ #ifdef LIBSSH2_ERROR_TIMEOUT *iv_return = LIBSSH2_ERROR_TIMEOUT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_22 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CALLBACK_DEBUG LIBSSH2_FX_BAD_MESSAGE LIBSSH2_METHOD_COMP_CS LIBSSH2_METHOD_COMP_SC LIBSSH2_METHOD_HOSTKEY LIBSSH2_METHOD_LANG_CS LIBSSH2_METHOD_LANG_SC LIBSSH2_PACKET_MAXCOMP LIBSSH2_POLLFD_CHANNEL LIBSSH2_POLLFD_POLLERR LIBSSH2_POLLFD_POLLEXT LIBSSH2_POLLFD_POLLHUP LIBSSH2_POLLFD_POLLOUT LIBSSH2_POLLFD_POLLPRI LIBSSH2_SFTP_ATTR_SIZE LIBSSH2_SFTP_TYPE_FIFO LIBSSH2_TERM_HEIGHT_PX */ /* Offset 21 gives the best switch position. */ switch (name[21]) { case 'C': if (memEQ(name, "LIBSSH2_METHOD_COMP_S", 21)) { /* C */ #ifdef LIBSSH2_METHOD_COMP_SC *iv_return = LIBSSH2_METHOD_COMP_SC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_METHOD_LANG_S", 21)) { /* C */ #ifdef LIBSSH2_METHOD_LANG_SC *iv_return = LIBSSH2_METHOD_LANG_SC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_FX_BAD_MESSAG", 21)) { /* E */ #ifdef LIBSSH2_FX_BAD_MESSAGE *iv_return = LIBSSH2_FX_BAD_MESSAGE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_ATTR_SIZ", 21)) { /* E */ #ifdef LIBSSH2_SFTP_ATTR_SIZE *iv_return = LIBSSH2_SFTP_ATTR_SIZE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "LIBSSH2_CALLBACK_DEBU", 21)) { /* G */ #ifdef LIBSSH2_CALLBACK_DEBUG *iv_return = LIBSSH2_CALLBACK_DEBUG; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_POLLFD_POLLPR", 21)) { /* I */ #ifdef LIBSSH2_POLLFD_POLLPRI *iv_return = LIBSSH2_POLLFD_POLLPRI; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_POLLFD_CHANNE", 21)) { /* L */ #ifdef LIBSSH2_POLLFD_CHANNEL *iv_return = LIBSSH2_POLLFD_CHANNEL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_SFTP_TYPE_FIF", 21)) { /* O */ #ifdef LIBSSH2_SFTP_TYPE_FIFO *iv_return = LIBSSH2_SFTP_TYPE_FIFO; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_PACKET_MAXCOM", 21)) { /* P */ #ifdef LIBSSH2_PACKET_MAXCOMP *iv_return = LIBSSH2_PACKET_MAXCOMP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_POLLFD_POLLHU", 21)) { /* P */ #ifdef LIBSSH2_POLLFD_POLLHUP *iv_return = LIBSSH2_POLLFD_POLLHUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_POLLFD_POLLER", 21)) { /* R */ #ifdef LIBSSH2_POLLFD_POLLERR *iv_return = LIBSSH2_POLLFD_POLLERR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_METHOD_COMP_C", 21)) { /* S */ #ifdef LIBSSH2_METHOD_COMP_CS *iv_return = LIBSSH2_METHOD_COMP_CS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_METHOD_LANG_C", 21)) { /* S */ #ifdef LIBSSH2_METHOD_LANG_CS *iv_return = LIBSSH2_METHOD_LANG_CS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_POLLFD_POLLEX", 21)) { /* T */ #ifdef LIBSSH2_POLLFD_POLLEXT *iv_return = LIBSSH2_POLLFD_POLLEXT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_POLLFD_POLLOU", 21)) { /* T */ #ifdef LIBSSH2_POLLFD_POLLOUT *iv_return = LIBSSH2_POLLFD_POLLOUT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "LIBSSH2_TERM_HEIGHT_P", 21)) { /* X */ #ifdef LIBSSH2_TERM_HEIGHT_PX *iv_return = LIBSSH2_TERM_HEIGHT_PX; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'Y': if (memEQ(name, "LIBSSH2_METHOD_HOSTKE", 21)) { /* Y */ #ifdef LIBSSH2_METHOD_HOSTKEY *iv_return = LIBSSH2_METHOD_HOSTKEY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_23 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CALLBACK_IGNORE LIBSSH2_DH_GEX_MAXGROUP LIBSSH2_DH_GEX_MINGROUP LIBSSH2_DH_GEX_OPTGROUP LIBSSH2_FX_NO_SUCH_FILE LIBSSH2_FX_NO_SUCH_PATH LIBSSH2_METHOD_CRYPT_CS LIBSSH2_METHOD_CRYPT_SC LIBSSH2_POLLFD_LISTENER LIBSSH2_POLLFD_POLLNVAL LIBSSH2_TRACE_PUBLICKEY */ /* Offset 17 gives the best switch position. */ switch (name[17]) { case 'H': if (memEQ(name, "LIBSSH2_FX_NO_SUCH_FILE", 23)) { /* ^ */ #ifdef LIBSSH2_FX_NO_SUCH_FILE *iv_return = LIBSSH2_FX_NO_SUCH_FILE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_FX_NO_SUCH_PATH", 23)) { /* ^ */ #ifdef LIBSSH2_FX_NO_SUCH_PATH *iv_return = LIBSSH2_FX_NO_SUCH_PATH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_CALLBACK_IGNORE", 23)) { /* ^ */ #ifdef LIBSSH2_CALLBACK_IGNORE *iv_return = LIBSSH2_CALLBACK_IGNORE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_POLLFD_POLLNVAL", 23)) { /* ^ */ #ifdef LIBSSH2_POLLFD_POLLNVAL *iv_return = LIBSSH2_POLLFD_POLLNVAL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_TRACE_PUBLICKEY", 23)) { /* ^ */ #ifdef LIBSSH2_TRACE_PUBLICKEY *iv_return = LIBSSH2_TRACE_PUBLICKEY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_DH_GEX_MINGROUP", 23)) { /* ^ */ #ifdef LIBSSH2_DH_GEX_MINGROUP *iv_return = LIBSSH2_DH_GEX_MINGROUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_POLLFD_LISTENER", 23)) { /* ^ */ #ifdef LIBSSH2_POLLFD_LISTENER *iv_return = LIBSSH2_POLLFD_LISTENER; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_DH_GEX_OPTGROUP", 23)) { /* ^ */ #ifdef LIBSSH2_DH_GEX_OPTGROUP *iv_return = LIBSSH2_DH_GEX_OPTGROUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "LIBSSH2_DH_GEX_MAXGROUP", 23)) { /* ^ */ #ifdef LIBSSH2_DH_GEX_MAXGROUP *iv_return = LIBSSH2_DH_GEX_MAXGROUP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'Y': if (memEQ(name, "LIBSSH2_METHOD_CRYPT_CS", 23)) { /* ^ */ #ifdef LIBSSH2_METHOD_CRYPT_CS *iv_return = LIBSSH2_METHOD_CRYPT_CS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_METHOD_CRYPT_SC", 23)) { /* ^ */ #ifdef LIBSSH2_METHOD_CRYPT_SC *iv_return = LIBSSH2_METHOD_CRYPT_SC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_24 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_FX_DIR_NOT_EMPTY LIBSSH2_FX_LOCK_CONFlICT LIBSSH2_FX_NO_CONNECTION LIBSSH2_FX_WRITE_PROTECT LIBSSH2_HOSTKEY_HASH_MD5 LIBSSH2_PACKET_MAXDECOMP LIBSSH2_SFTP_ATTR_UIDGID LIBSSH2_SFTP_TYPE_SOCKET SSH_EXTENDED_DATA_STDERR */ /* Offset 22 gives the best switch position. */ switch (name[22]) { case 'C': if (memEQ(name, "LIBSSH2_FX_LOCK_CONFlICT", 24)) { /* ^ */ #ifdef LIBSSH2_FX_LOCK_CONFlICT *iv_return = LIBSSH2_FX_LOCK_CONFlICT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_FX_WRITE_PROTECT", 24)) { /* ^ */ #ifdef LIBSSH2_FX_WRITE_PROTECT *iv_return = LIBSSH2_FX_WRITE_PROTECT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'D': if (memEQ(name, "LIBSSH2_HOSTKEY_HASH_MD5", 24)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_HASH_MD5 *iv_return = LIBSSH2_HOSTKEY_HASH_MD5; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_SFTP_TYPE_SOCKET", 24)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_SOCKET *iv_return = LIBSSH2_SFTP_TYPE_SOCKET; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_SFTP_ATTR_UIDGID", 24)) { /* ^ */ #ifdef LIBSSH2_SFTP_ATTR_UIDGID *iv_return = LIBSSH2_SFTP_ATTR_UIDGID; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_PACKET_MAXDECOMP", 24)) { /* ^ */ #ifdef LIBSSH2_PACKET_MAXDECOMP *iv_return = LIBSSH2_PACKET_MAXDECOMP; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_FX_NO_CONNECTION", 24)) { /* ^ */ #ifdef LIBSSH2_FX_NO_CONNECTION *iv_return = LIBSSH2_FX_NO_CONNECTION; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "SSH_EXTENDED_DATA_STDERR", 24)) { /* ^ */ #ifdef SSH_EXTENDED_DATA_STDERR *iv_return = SSH_EXTENDED_DATA_STDERR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_FX_DIR_NOT_EMPTY", 24)) { /* ^ */ #ifdef LIBSSH2_FX_DIR_NOT_EMPTY *iv_return = LIBSSH2_FX_DIR_NOT_EMPTY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_25 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CALLBACK_MACERROR LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_CHANNEL_MINADJUST LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_SEND LIBSSH2_ERROR_INVALID_MAC LIBSSH2_ERROR_KEX_FAILURE LIBSSH2_ERROR_KNOWN_HOSTS LIBSSH2_ERROR_METHOD_NONE LIBSSH2_ERROR_SOCKET_NONE LIBSSH2_ERROR_SOCKET_SEND LIBSSH2_FX_INVALID_HANDLE LIBSSH2_FX_OP_UNSUPPORTED LIBSSH2_FX_QUOTA_EXCEEDED LIBSSH2_HOSTKEY_HASH_SHA1 LIBSSH2_PACKET_MAXPAYLOAD LIBSSH2_SFTP_TYPE_REGULAR LIBSSH2_SFTP_TYPE_SPECIAL LIBSSH2_SFTP_TYPE_SYMLINK LIBSSH2_SFTP_TYPE_UNKNOWN */ /* Offset 16 gives the best switch position. */ switch (name[16]) { case 'A': if (memEQ(name, "LIBSSH2_PACKET_MAXPAYLOAD", 25)) { /* ^ */ #ifdef LIBSSH2_PACKET_MAXPAYLOAD *iv_return = LIBSSH2_PACKET_MAXPAYLOAD; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "LIBSSH2_ERROR_SOCKET_NONE", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_SOCKET_NONE *iv_return = LIBSSH2_ERROR_SOCKET_NONE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_ERROR_SOCKET_SEND", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_SOCKET_SEND *iv_return = LIBSSH2_ERROR_SOCKET_SEND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_SFTP_TYPE_REGULAR", 25)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_REGULAR *iv_return = LIBSSH2_SFTP_TYPE_REGULAR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_TYPE_SPECIAL", 25)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_SPECIAL *iv_return = LIBSSH2_SFTP_TYPE_SPECIAL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_TYPE_SYMLINK", 25)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_SYMLINK *iv_return = LIBSSH2_SFTP_TYPE_SYMLINK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_TYPE_UNKNOWN", 25)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_UNKNOWN *iv_return = LIBSSH2_SFTP_TYPE_UNKNOWN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'F': if (memEQ(name, "LIBSSH2_CHANNEL_FLUSH_ALL", 25)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_FLUSH_ALL *iv_return = LIBSSH2_CHANNEL_FLUSH_ALL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'H': if (memEQ(name, "LIBSSH2_HOSTKEY_HASH_SHA1", 25)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_HASH_SHA1 *iv_return = LIBSSH2_HOSTKEY_HASH_SHA1; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_FX_INVALID_HANDLE", 25)) { /* ^ */ #ifdef LIBSSH2_FX_INVALID_HANDLE *iv_return = LIBSSH2_FX_INVALID_HANDLE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_CHANNEL_MINADJUST", 25)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_MINADJUST *iv_return = LIBSSH2_CHANNEL_MINADJUST; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_ERROR_BANNER_NONE", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_BANNER_NONE *iv_return = LIBSSH2_ERROR_BANNER_NONE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_ERROR_BANNER_SEND", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_BANNER_SEND *iv_return = LIBSSH2_ERROR_BANNER_SEND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_ERROR_KNOWN_HOSTS", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_KNOWN_HOSTS *iv_return = LIBSSH2_ERROR_KNOWN_HOSTS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_FX_OP_UNSUPPORTED", 25)) { /* ^ */ #ifdef LIBSSH2_FX_OP_UNSUPPORTED *iv_return = LIBSSH2_FX_OP_UNSUPPORTED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_ERROR_METHOD_NONE", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_METHOD_NONE *iv_return = LIBSSH2_ERROR_METHOD_NONE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'V': if (memEQ(name, "LIBSSH2_ERROR_INVALID_MAC", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_INVALID_MAC *iv_return = LIBSSH2_ERROR_INVALID_MAC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "LIBSSH2_ERROR_KEX_FAILURE", 25)) { /* ^ */ #ifdef LIBSSH2_ERROR_KEX_FAILURE *iv_return = LIBSSH2_ERROR_KEX_FAILURE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_CALLBACK_MACERROR", 25)) { /* ^ */ #ifdef LIBSSH2_CALLBACK_MACERROR *iv_return = LIBSSH2_CALLBACK_MACERROR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_FX_QUOTA_EXCEEDED", 25)) { /* ^ */ #ifdef LIBSSH2_FX_QUOTA_EXCEEDED *iv_return = LIBSSH2_FX_QUOTA_EXCEEDED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_26 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_HOSTKEY_INIT LIBSSH2_ERROR_HOSTKEY_SIGN LIBSSH2_ERROR_SCP_PROTOCOL LIBSSH2_FX_CONNECTION_LOST LIBSSH2_FX_NOT_A_DIRECTORY LIBSSH2_HOSTKEY_POLICY_ASK LIBSSH2_KNOWNHOST_KEY_MASK LIBSSH2_KNOWNHOST_KEY_RSA1 LIBSSH2_SFTP_ATTR_EXTENDED LIBSSH2_SFTP_PACKET_MAXLEN LIBSSH2_SFTP_RENAME_ATOMIC LIBSSH2_SFTP_RENAME_NATIVE LIBSSH2_SOCKET_POLL_UDELAY */ /* Offset 22 gives the best switch position. */ switch (name[22]) { case 'E': if (memEQ(name, "LIBSSH2_SOCKET_POLL_UDELAY", 26)) { /* ^ */ #ifdef LIBSSH2_SOCKET_POLL_UDELAY *iv_return = LIBSSH2_SOCKET_POLL_UDELAY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_ERROR_HOSTKEY_INIT", 26)) { /* ^ */ #ifdef LIBSSH2_ERROR_HOSTKEY_INIT *iv_return = LIBSSH2_ERROR_HOSTKEY_INIT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_FX_CONNECTION_LOST", 26)) { /* ^ */ #ifdef LIBSSH2_FX_CONNECTION_LOST *iv_return = LIBSSH2_FX_CONNECTION_LOST; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_KNOWNHOST_KEY_MASK", 26)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEY_MASK *iv_return = LIBSSH2_KNOWNHOST_KEY_MASK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_SFTP_ATTR_EXTENDED", 26)) { /* ^ */ #ifdef LIBSSH2_SFTP_ATTR_EXTENDED *iv_return = LIBSSH2_SFTP_ATTR_EXTENDED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_ERROR_SCP_PROTOCOL", 26)) { /* ^ */ #ifdef LIBSSH2_ERROR_SCP_PROTOCOL *iv_return = LIBSSH2_ERROR_SCP_PROTOCOL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_RENAME_ATOMIC", 26)) { /* ^ */ #ifdef LIBSSH2_SFTP_RENAME_ATOMIC *iv_return = LIBSSH2_SFTP_RENAME_ATOMIC; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_KNOWNHOST_KEY_RSA1", 26)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEY_RSA1 *iv_return = LIBSSH2_KNOWNHOST_KEY_RSA1; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_ERROR_HOSTKEY_SIGN", 26)) { /* ^ */ #ifdef LIBSSH2_ERROR_HOSTKEY_SIGN *iv_return = LIBSSH2_ERROR_HOSTKEY_SIGN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_FX_NOT_A_DIRECTORY", 26)) { /* ^ */ #ifdef LIBSSH2_FX_NOT_A_DIRECTORY *iv_return = LIBSSH2_FX_NOT_A_DIRECTORY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_RENAME_NATIVE", 26)) { /* ^ */ #ifdef LIBSSH2_SFTP_RENAME_NATIVE *iv_return = LIBSSH2_SFTP_RENAME_NATIVE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'X': if (memEQ(name, "LIBSSH2_SFTP_PACKET_MAXLEN", 26)) { /* ^ */ #ifdef LIBSSH2_SFTP_PACKET_MAXLEN *iv_return = LIBSSH2_SFTP_PACKET_MAXLEN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_HOSTKEY_POLICY_ASK", 26)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_POLICY_ASK *iv_return = LIBSSH2_HOSTKEY_POLICY_ASK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_27 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CALLBACK_DISCONNECT LIBSSH2_ERROR_SFTP_PROTOCOL LIBSSH2_FX_INVALID_FILENAME LIBSSH2_HOSTKEY_POLICY_TOFU LIBSSH2_KNOWNHOST_KEY_SHIFT LIBSSH2_KNOWNHOST_TYPE_MASK LIBSSH2_KNOWNHOST_TYPE_SHA1 LIBSSH2_SFTP_ATTR_ACMODTIME LIBSSH2_SFTP_TYPE_DIRECTORY */ /* Offset 25 gives the best switch position. */ switch (name[25]) { case 'A': if (memEQ(name, "LIBSSH2_KNOWNHOST_TYPE_SHA1", 27)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_TYPE_SHA1 *iv_return = LIBSSH2_KNOWNHOST_TYPE_SHA1; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "LIBSSH2_CALLBACK_DISCONNECT", 27)) { /* ^ */ #ifdef LIBSSH2_CALLBACK_DISCONNECT *iv_return = LIBSSH2_CALLBACK_DISCONNECT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'F': if (memEQ(name, "LIBSSH2_HOSTKEY_POLICY_TOFU", 27)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_POLICY_TOFU *iv_return = LIBSSH2_HOSTKEY_POLICY_TOFU; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_KNOWNHOST_KEY_SHIFT", 27)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEY_SHIFT *iv_return = LIBSSH2_KNOWNHOST_KEY_SHIFT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_FX_INVALID_FILENAME", 27)) { /* ^ */ #ifdef LIBSSH2_FX_INVALID_FILENAME *iv_return = LIBSSH2_FX_INVALID_FILENAME; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_ATTR_ACMODTIME", 27)) { /* ^ */ #ifdef LIBSSH2_SFTP_ATTR_ACMODTIME *iv_return = LIBSSH2_SFTP_ATTR_ACMODTIME; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_ERROR_SFTP_PROTOCOL", 27)) { /* ^ */ #ifdef LIBSSH2_ERROR_SFTP_PROTOCOL *iv_return = LIBSSH2_ERROR_SFTP_PROTOCOL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_SFTP_TYPE_DIRECTORY", 27)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_DIRECTORY *iv_return = LIBSSH2_SFTP_TYPE_DIRECTORY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_KNOWNHOST_TYPE_MASK", 27)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_TYPE_MASK *iv_return = LIBSSH2_KNOWNHOST_TYPE_MASK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_28 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CHANNEL_FLUSH_STDERR LIBSSH2_ERROR_CHANNEL_CLOSED LIBSSH2_ERROR_REQUEST_DENIED LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_EXTENDED_DATA_STDERR LIBSSH2_FX_PERMISSION_DENIED LIBSSH2_FX_UNKNOWN_PRINCIPLE LIBSSH2_KNOWNHOST_KEYENC_RAW LIBSSH2_KNOWNHOST_KEY_SSHDSS LIBSSH2_KNOWNHOST_KEY_SSHRSA LIBSSH2_KNOWNHOST_TYPE_PLAIN LIBSSH2_SOCKET_POLL_MAXLOOPS */ /* Offset 20 gives the best switch position. */ switch (name[20]) { case 'A': if (memEQ(name, "LIBSSH2_EXTENDED_DATA_STDERR", 28)) { /* ^ */ #ifdef LIBSSH2_EXTENDED_DATA_STDERR *iv_return = LIBSSH2_EXTENDED_DATA_STDERR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'H': if (memEQ(name, "LIBSSH2_CHANNEL_FLUSH_STDERR", 28)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_FLUSH_STDERR *iv_return = LIBSSH2_CHANNEL_FLUSH_STDERR; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_CLOSED", 28)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_CLOSED *iv_return = LIBSSH2_ERROR_CHANNEL_CLOSED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_SOCKET_POLL_MAXLOOPS", 28)) { /* ^ */ #ifdef LIBSSH2_SOCKET_POLL_MAXLOOPS *iv_return = LIBSSH2_SOCKET_POLL_MAXLOOPS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_FX_PERMISSION_DENIED", 28)) { /* ^ */ #ifdef LIBSSH2_FX_PERMISSION_DENIED *iv_return = LIBSSH2_FX_PERMISSION_DENIED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_KNOWNHOST_TYPE_PLAIN", 28)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_TYPE_PLAIN *iv_return = LIBSSH2_KNOWNHOST_TYPE_PLAIN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_FX_UNKNOWN_PRINCIPLE", 28)) { /* ^ */ #ifdef LIBSSH2_FX_UNKNOWN_PRINCIPLE *iv_return = LIBSSH2_FX_UNKNOWN_PRINCIPLE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_ERROR_REQUEST_DENIED", 28)) { /* ^ */ #ifdef LIBSSH2_ERROR_REQUEST_DENIED *iv_return = LIBSSH2_ERROR_REQUEST_DENIED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'Y': if (memEQ(name, "LIBSSH2_KNOWNHOST_KEYENC_RAW", 28)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEYENC_RAW *iv_return = LIBSSH2_KNOWNHOST_KEYENC_RAW; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_KNOWNHOST_KEY_SSHDSS", 28)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEY_SSHDSS *iv_return = LIBSSH2_KNOWNHOST_KEY_SSHDSS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_KNOWNHOST_KEY_SSHRSA", 28)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEY_SSHRSA *iv_return = LIBSSH2_KNOWNHOST_KEY_SSHRSA; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_ERROR_SOCKET_TIMEOUT", 28)) { /* ^ */ #ifdef LIBSSH2_ERROR_SOCKET_TIMEOUT *iv_return = LIBSSH2_ERROR_SOCKET_TIMEOUT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_29 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_CHANNEL_FAILURE LIBSSH2_ERROR_CHANNEL_UNKNOWN LIBSSH2_HOSTKEY_POLICY_STRICT LIBSSH2_KNOWNHOST_CHECK_MATCH LIBSSH2_KNOWNHOST_KEYENC_MASK LIBSSH2_KNOWNHOST_TYPE_CUSTOM LIBSSH2_POLLFD_CHANNEL_CLOSED LIBSSH2_POLLFD_SESSION_CLOSED LIBSSH2_SESSION_BLOCK_INBOUND LIBSSH2_SFTP_ATTR_PERMISSIONS LIBSSH2_SFTP_RENAME_OVERWRITE LIBSSH2_SFTP_TYPE_CHAR_DEVICE */ /* Offset 24 gives the best switch position. */ switch (name[24]) { case 'B': if (memEQ(name, "LIBSSH2_SESSION_BLOCK_INBOUND", 29)) { /* ^ */ #ifdef LIBSSH2_SESSION_BLOCK_INBOUND *iv_return = LIBSSH2_SESSION_BLOCK_INBOUND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_SFTP_TYPE_CHAR_DEVICE", 29)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_CHAR_DEVICE *iv_return = LIBSSH2_SFTP_TYPE_CHAR_DEVICE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_FAILURE", 29)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_FAILURE *iv_return = LIBSSH2_ERROR_CHANNEL_FAILURE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'K': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_UNKNOWN", 29)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_UNKNOWN *iv_return = LIBSSH2_ERROR_CHANNEL_UNKNOWN; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_POLLFD_CHANNEL_CLOSED", 29)) { /* ^ */ #ifdef LIBSSH2_POLLFD_CHANNEL_CLOSED *iv_return = LIBSSH2_POLLFD_CHANNEL_CLOSED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_POLLFD_SESSION_CLOSED", 29)) { /* ^ */ #ifdef LIBSSH2_POLLFD_SESSION_CLOSED *iv_return = LIBSSH2_POLLFD_SESSION_CLOSED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_KNOWNHOST_CHECK_MATCH", 29)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_CHECK_MATCH *iv_return = LIBSSH2_KNOWNHOST_CHECK_MATCH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'S': if (memEQ(name, "LIBSSH2_SFTP_ATTR_PERMISSIONS", 29)) { /* ^ */ #ifdef LIBSSH2_SFTP_ATTR_PERMISSIONS *iv_return = LIBSSH2_SFTP_ATTR_PERMISSIONS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_HOSTKEY_POLICY_STRICT", 29)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_POLICY_STRICT *iv_return = LIBSSH2_HOSTKEY_POLICY_STRICT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'U': if (memEQ(name, "LIBSSH2_KNOWNHOST_TYPE_CUSTOM", 29)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_TYPE_CUSTOM *iv_return = LIBSSH2_KNOWNHOST_TYPE_CUSTOM; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'W': if (memEQ(name, "LIBSSH2_SFTP_RENAME_OVERWRITE", 29)) { /* ^ */ #ifdef LIBSSH2_SFTP_RENAME_OVERWRITE *iv_return = LIBSSH2_SFTP_RENAME_OVERWRITE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case '_': if (memEQ(name, "LIBSSH2_KNOWNHOST_KEYENC_MASK", 29)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEYENC_MASK *iv_return = LIBSSH2_KNOWNHOST_KEYENC_MASK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_30 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CHANNEL_PACKET_DEFAULT LIBSSH2_CHANNEL_WINDOW_DEFAULT LIBSSH2_ERROR_CHANNEL_EOF_SENT LIBSSH2_ERROR_PASSWORD_EXPIRED LIBSSH2_FX_FILE_ALREADY_EXISTS LIBSSH2_POLLFD_LISTENER_CLOSED LIBSSH2_SESSION_BLOCK_OUTBOUND LIBSSH2_SFTP_TYPE_BLOCK_DEVICE */ /* Offset 20 gives the best switch position. */ switch (name[20]) { case 'A': if (memEQ(name, "LIBSSH2_FX_FILE_ALREADY_EXISTS", 30)) { /* ^ */ #ifdef LIBSSH2_FX_FILE_ALREADY_EXISTS *iv_return = LIBSSH2_FX_FILE_ALREADY_EXISTS; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_CHANNEL_PACKET_DEFAULT", 30)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_PACKET_DEFAULT *iv_return = LIBSSH2_CHANNEL_PACKET_DEFAULT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'K': if (memEQ(name, "LIBSSH2_SESSION_BLOCK_OUTBOUND", 30)) { /* ^ */ #ifdef LIBSSH2_SESSION_BLOCK_OUTBOUND *iv_return = LIBSSH2_SESSION_BLOCK_OUTBOUND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_EOF_SENT", 30)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_EOF_SENT *iv_return = LIBSSH2_ERROR_CHANNEL_EOF_SENT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_POLLFD_LISTENER_CLOSED", 30)) { /* ^ */ #ifdef LIBSSH2_POLLFD_LISTENER_CLOSED *iv_return = LIBSSH2_POLLFD_LISTENER_CLOSED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_CHANNEL_WINDOW_DEFAULT", 30)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_WINDOW_DEFAULT *iv_return = LIBSSH2_CHANNEL_WINDOW_DEFAULT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } if (memEQ(name, "LIBSSH2_SFTP_TYPE_BLOCK_DEVICE", 30)) { /* ^ */ #ifdef LIBSSH2_SFTP_TYPE_BLOCK_DEVICE *iv_return = LIBSSH2_SFTP_TYPE_BLOCK_DEVICE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'R': if (memEQ(name, "LIBSSH2_ERROR_PASSWORD_EXPIRED", 30)) { /* ^ */ #ifdef LIBSSH2_ERROR_PASSWORD_EXPIRED *iv_return = LIBSSH2_ERROR_PASSWORD_EXPIRED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_31 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_INVALID_POLL_TYPE LIBSSH2_ERROR_SOCKET_DISCONNECT LIBSSH2_HOSTKEY_POLICY_ADVISORY LIBSSH2_KNOWNHOST_CHECK_FAILURE LIBSSH2_KNOWNHOST_KEYENC_BASE64 */ /* Offset 25 gives the best switch position. */ switch (name[25]) { case 'A': if (memEQ(name, "LIBSSH2_KNOWNHOST_CHECK_FAILURE", 31)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_CHECK_FAILURE *iv_return = LIBSSH2_KNOWNHOST_CHECK_FAILURE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'B': if (memEQ(name, "LIBSSH2_KNOWNHOST_KEYENC_BASE64", 31)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_KEYENC_BASE64 *iv_return = LIBSSH2_KNOWNHOST_KEYENC_BASE64; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'L': if (memEQ(name, "LIBSSH2_ERROR_INVALID_POLL_TYPE", 31)) { /* ^ */ #ifdef LIBSSH2_ERROR_INVALID_POLL_TYPE *iv_return = LIBSSH2_ERROR_INVALID_POLL_TYPE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'O': if (memEQ(name, "LIBSSH2_ERROR_SOCKET_DISCONNECT", 31)) { /* ^ */ #ifdef LIBSSH2_ERROR_SOCKET_DISCONNECT *iv_return = LIBSSH2_ERROR_SOCKET_DISCONNECT; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'V': if (memEQ(name, "LIBSSH2_HOSTKEY_POLICY_ADVISORY", 31)) { /* ^ */ #ifdef LIBSSH2_HOSTKEY_POLICY_ADVISORY *iv_return = LIBSSH2_HOSTKEY_POLICY_ADVISORY; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_32 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_CHANNEL_OUTOFORDER LIBSSH2_ERROR_PUBLICKEY_PROTOCOL LIBSSH2_KNOWNHOST_CHECK_MISMATCH LIBSSH2_KNOWNHOST_CHECK_NOTFOUND */ /* Offset 24 gives the best switch position. */ switch (name[24]) { case 'M': if (memEQ(name, "LIBSSH2_KNOWNHOST_CHECK_MISMATCH", 32)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_CHECK_MISMATCH *iv_return = LIBSSH2_KNOWNHOST_CHECK_MISMATCH; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_KNOWNHOST_CHECK_NOTFOUND", 32)) { /* ^ */ #ifdef LIBSSH2_KNOWNHOST_CHECK_NOTFOUND *iv_return = LIBSSH2_KNOWNHOST_CHECK_NOTFOUND; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_ERROR_PUBLICKEY_PROTOCOL", 32)) { /* ^ */ #ifdef LIBSSH2_ERROR_PUBLICKEY_PROTOCOL *iv_return = LIBSSH2_ERROR_PUBLICKEY_PROTOCOL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'T': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_OUTOFORDER", 32)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_OUTOFORDER *iv_return = LIBSSH2_ERROR_CHANNEL_OUTOFORDER; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_34 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE LIBSSH2_ERROR_METHOD_NOT_SUPPORTED LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED */ /* Offset 14 gives the best switch position. */ switch (name[14]) { case 'K': if (memEQ(name, "LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE", 34)) { /* ^ */ #ifdef LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE *iv_return = LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'M': if (memEQ(name, "LIBSSH2_ERROR_METHOD_NOT_SUPPORTED", 34)) { /* ^ */ #ifdef LIBSSH2_ERROR_METHOD_NOT_SUPPORTED *iv_return = LIBSSH2_ERROR_METHOD_NOT_SUPPORTED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'P': if (memEQ(name, "LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED", 34)) { /* ^ */ #ifdef LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED *iv_return = LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_35 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA LIBSSH2_ERROR_AUTHENTICATION_FAILED */ /* Offset 34 gives the best switch position. */ switch (name[34]) { case 'A': if (memEQ(name, "LIBSSH2_CHANNEL_FLUSH_EXTENDED_DAT", 34)) { /* A */ #ifdef LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA *iv_return = LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'D': if (memEQ(name, "LIBSSH2_ERROR_AUTHENTICATION_FAILE", 34)) { /* D */ #ifdef LIBSSH2_ERROR_AUTHENTICATION_FAILED *iv_return = LIBSSH2_ERROR_AUTHENTICATION_FAILED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'E': if (memEQ(name, "LIBSSH2_CHANNEL_EXTENDED_DATA_MERG", 34)) { /* E */ #ifdef LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE *iv_return = LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant_36 (pTHX_ const char *name, IV *iv_return) { /* When generated this function returned values for the list of names given here. However, subsequent manual editing may have added or removed some. LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED */ /* Offset 30 gives the best switch position. */ switch (name[30]) { case 'D': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED", 36)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED *iv_return = LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'G': if (memEQ(name, "LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED", 36)) { /* ^ */ #ifdef LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED *iv_return = LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'I': if (memEQ(name, "LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE", 36)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE *iv_return = LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'N': if (memEQ(name, "LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL", 36)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL *iv_return = LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } return PERL_constant_NOTFOUND; } static int constant (pTHX_ const char *name, STRLEN len, IV *iv_return) { /* Initially switch on the length of the name. */ /* When generated this function returned values for the list of names given in this section of perl code. Rather than manually editing these functions to add or remove constants, which would result in this comment and section of code becoming inaccurate, we recommend that you edit this section of code, and use it to regenerate a new set of constant functions which you then use to replace the originals. Regenerate these constant functions by feeding this entire source file to perl -x #!/usr/bin/perl -w use ExtUtils::Constant qw (constant_types C_constant XS_constant); my $types = {map {($_, 1)} qw(IV)}; my @names = (qw(LIBSSH2_CALLBACK_DEBUG LIBSSH2_CALLBACK_DISCONNECT LIBSSH2_CALLBACK_IGNORE LIBSSH2_CALLBACK_MACERROR LIBSSH2_CALLBACK_X11 LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA LIBSSH2_CHANNEL_FLUSH_STDERR LIBSSH2_CHANNEL_MINADJUST LIBSSH2_CHANNEL_PACKET_DEFAULT LIBSSH2_CHANNEL_WINDOW_DEFAULT LIBSSH2_DH_GEX_MAXGROUP LIBSSH2_DH_GEX_MINGROUP LIBSSH2_DH_GEX_OPTGROUP LIBSSH2_ERROR_ALLOC LIBSSH2_ERROR_AUTHENTICATION_FAILED LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_SEND LIBSSH2_ERROR_CHANNEL_CLOSED LIBSSH2_ERROR_CHANNEL_EOF_SENT LIBSSH2_ERROR_CHANNEL_FAILURE LIBSSH2_ERROR_CHANNEL_OUTOFORDER LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED LIBSSH2_ERROR_CHANNEL_UNKNOWN LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED LIBSSH2_ERROR_DECRYPT LIBSSH2_ERROR_EAGAIN LIBSSH2_ERROR_FILE LIBSSH2_ERROR_HOSTKEY_INIT LIBSSH2_ERROR_HOSTKEY_SIGN LIBSSH2_ERROR_INVAL LIBSSH2_ERROR_INVALID_MAC LIBSSH2_ERROR_INVALID_POLL_TYPE LIBSSH2_ERROR_KEX_FAILURE LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE LIBSSH2_ERROR_KNOWN_HOSTS LIBSSH2_ERROR_METHOD_NONE LIBSSH2_ERROR_METHOD_NOT_SUPPORTED LIBSSH2_ERROR_NONE LIBSSH2_ERROR_PASSWORD_EXPIRED LIBSSH2_ERROR_PROTO LIBSSH2_ERROR_PUBLICKEY_PROTOCOL LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED LIBSSH2_ERROR_REQUEST_DENIED LIBSSH2_ERROR_SCP_PROTOCOL LIBSSH2_ERROR_SFTP_PROTOCOL LIBSSH2_ERROR_SOCKET_DISCONNECT LIBSSH2_ERROR_SOCKET_NONE LIBSSH2_ERROR_SOCKET_SEND LIBSSH2_ERROR_SOCKET_TIMEOUT LIBSSH2_ERROR_TIMEOUT LIBSSH2_ERROR_ZLIB LIBSSH2_EXTENDED_DATA_STDERR LIBSSH2_FLAG_COMPRESS LIBSSH2_FLAG_SIGPIPE LIBSSH2_FXF_APPEND LIBSSH2_FXF_CREAT LIBSSH2_FXF_EXCL LIBSSH2_FXF_READ LIBSSH2_FXF_TRUNC LIBSSH2_FXF_WRITE LIBSSH2_FX_BAD_MESSAGE LIBSSH2_FX_CONNECTION_LOST LIBSSH2_FX_DIR_NOT_EMPTY LIBSSH2_FX_EOF LIBSSH2_FX_FAILURE LIBSSH2_FX_FILE_ALREADY_EXISTS LIBSSH2_FX_INVALID_FILENAME LIBSSH2_FX_INVALID_HANDLE LIBSSH2_FX_LINK_LOOP LIBSSH2_FX_LOCK_CONFlICT LIBSSH2_FX_NOT_A_DIRECTORY LIBSSH2_FX_NO_CONNECTION LIBSSH2_FX_NO_MEDIA LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM LIBSSH2_FX_NO_SUCH_FILE LIBSSH2_FX_NO_SUCH_PATH LIBSSH2_FX_OK LIBSSH2_FX_OP_UNSUPPORTED LIBSSH2_FX_PERMISSION_DENIED LIBSSH2_FX_QUOTA_EXCEEDED LIBSSH2_FX_UNKNOWN_PRINCIPLE LIBSSH2_FX_WRITE_PROTECT LIBSSH2_H LIBSSH2_HOSTKEY_HASH_MD5 LIBSSH2_HOSTKEY_HASH_SHA1 LIBSSH2_HOSTKEY_POLICY_ADVISORY LIBSSH2_HOSTKEY_POLICY_ASK LIBSSH2_HOSTKEY_POLICY_STRICT LIBSSH2_HOSTKEY_POLICY_TOFU LIBSSH2_KNOWNHOST_CHECK_FAILURE LIBSSH2_KNOWNHOST_CHECK_MATCH LIBSSH2_KNOWNHOST_CHECK_MISMATCH LIBSSH2_KNOWNHOST_CHECK_NOTFOUND LIBSSH2_KNOWNHOST_KEYENC_BASE64 LIBSSH2_KNOWNHOST_KEYENC_MASK LIBSSH2_KNOWNHOST_KEYENC_RAW LIBSSH2_KNOWNHOST_KEY_MASK LIBSSH2_KNOWNHOST_KEY_RSA1 LIBSSH2_KNOWNHOST_KEY_SHIFT LIBSSH2_KNOWNHOST_KEY_SSHDSS LIBSSH2_KNOWNHOST_KEY_SSHRSA LIBSSH2_KNOWNHOST_TYPE_CUSTOM LIBSSH2_KNOWNHOST_TYPE_MASK LIBSSH2_KNOWNHOST_TYPE_PLAIN LIBSSH2_KNOWNHOST_TYPE_SHA1 LIBSSH2_METHOD_COMP_CS LIBSSH2_METHOD_COMP_SC LIBSSH2_METHOD_CRYPT_CS LIBSSH2_METHOD_CRYPT_SC LIBSSH2_METHOD_HOSTKEY LIBSSH2_METHOD_KEX LIBSSH2_METHOD_LANG_CS LIBSSH2_METHOD_LANG_SC LIBSSH2_METHOD_MAC_CS LIBSSH2_METHOD_MAC_SC LIBSSH2_PACKET_MAXCOMP LIBSSH2_PACKET_MAXDECOMP LIBSSH2_PACKET_MAXPAYLOAD LIBSSH2_POLLFD_CHANNEL LIBSSH2_POLLFD_CHANNEL_CLOSED LIBSSH2_POLLFD_LISTENER LIBSSH2_POLLFD_LISTENER_CLOSED LIBSSH2_POLLFD_POLLERR LIBSSH2_POLLFD_POLLEX LIBSSH2_POLLFD_POLLEXT LIBSSH2_POLLFD_POLLHUP LIBSSH2_POLLFD_POLLIN LIBSSH2_POLLFD_POLLNVAL LIBSSH2_POLLFD_POLLOUT LIBSSH2_POLLFD_POLLPRI LIBSSH2_POLLFD_SESSION_CLOSED LIBSSH2_POLLFD_SOCKET LIBSSH2_SESSION_BLOCK_INBOUND LIBSSH2_SESSION_BLOCK_OUTBOUND LIBSSH2_SFTP_ATTR_ACMODTIME LIBSSH2_SFTP_ATTR_EXTENDED LIBSSH2_SFTP_ATTR_PERMISSIONS LIBSSH2_SFTP_ATTR_SIZE LIBSSH2_SFTP_ATTR_UIDGID LIBSSH2_SFTP_LSTAT LIBSSH2_SFTP_OPENDIR LIBSSH2_SFTP_OPENFILE LIBSSH2_SFTP_PACKET_MAXLEN LIBSSH2_SFTP_READLINK LIBSSH2_SFTP_REALPATH LIBSSH2_SFTP_RENAME_ATOMIC LIBSSH2_SFTP_RENAME_NATIVE LIBSSH2_SFTP_RENAME_OVERWRITE LIBSSH2_SFTP_SETSTAT LIBSSH2_SFTP_STAT LIBSSH2_SFTP_SYMLINK LIBSSH2_SFTP_TYPE_BLOCK_DEVICE LIBSSH2_SFTP_TYPE_CHAR_DEVICE LIBSSH2_SFTP_TYPE_DIRECTORY LIBSSH2_SFTP_TYPE_FIFO LIBSSH2_SFTP_TYPE_REGULAR LIBSSH2_SFTP_TYPE_SOCKET LIBSSH2_SFTP_TYPE_SPECIAL LIBSSH2_SFTP_TYPE_SYMLINK LIBSSH2_SFTP_TYPE_UNKNOWN LIBSSH2_SFTP_VERSION LIBSSH2_SOCKET_POLL_MAXLOOPS LIBSSH2_SOCKET_POLL_UDELAY LIBSSH2_TERM_HEIGHT LIBSSH2_TERM_HEIGHT_PX LIBSSH2_TERM_WIDTH LIBSSH2_TERM_WIDTH_PX LIBSSH2_TRACE_AUTH LIBSSH2_TRACE_CONN LIBSSH2_TRACE_ERROR LIBSSH2_TRACE_KEX LIBSSH2_TRACE_PUBLICKEY LIBSSH2_TRACE_SCP LIBSSH2_TRACE_SFTP LIBSSH2_TRACE_SOCKET LIBSSH2_TRACE_TRANS SSH_EXTENDED_DATA_STDERR)); print constant_types(), "\n"; # macro defs foreach (C_constant ("Net::SSH2", 'constant', 'IV', $types, undef, 3, @names) ) { print $_, "\n"; # C constant subs } print "\n#### XS Section:\n"; print XS_constant ("Net::SSH2", $types); __END__ */ switch (len) { case 9: if (memEQ(name, "LIBSSH2_H", 9)) { #ifdef LIBSSH2_H *iv_return = LIBSSH2_H; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 13: if (memEQ(name, "LIBSSH2_FX_OK", 13)) { #ifdef LIBSSH2_FX_OK *iv_return = LIBSSH2_FX_OK; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 14: if (memEQ(name, "LIBSSH2_FX_EOF", 14)) { #ifdef LIBSSH2_FX_EOF *iv_return = LIBSSH2_FX_EOF; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 16: /* Names all of length 16. */ /* LIBSSH2_FXF_EXCL LIBSSH2_FXF_READ */ /* Offset 14 gives the best switch position. */ switch (name[14]) { case 'A': if (memEQ(name, "LIBSSH2_FXF_READ", 16)) { /* ^ */ #ifdef LIBSSH2_FXF_READ *iv_return = LIBSSH2_FXF_READ; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'C': if (memEQ(name, "LIBSSH2_FXF_EXCL", 16)) { /* ^ */ #ifdef LIBSSH2_FXF_EXCL *iv_return = LIBSSH2_FXF_EXCL; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } break; case 17: return constant_17 (aTHX_ name, iv_return); break; case 18: return constant_18 (aTHX_ name, iv_return); break; case 19: return constant_19 (aTHX_ name, iv_return); break; case 20: return constant_20 (aTHX_ name, iv_return); break; case 21: return constant_21 (aTHX_ name, iv_return); break; case 22: return constant_22 (aTHX_ name, iv_return); break; case 23: return constant_23 (aTHX_ name, iv_return); break; case 24: return constant_24 (aTHX_ name, iv_return); break; case 25: return constant_25 (aTHX_ name, iv_return); break; case 26: return constant_26 (aTHX_ name, iv_return); break; case 27: return constant_27 (aTHX_ name, iv_return); break; case 28: return constant_28 (aTHX_ name, iv_return); break; case 29: return constant_29 (aTHX_ name, iv_return); break; case 30: return constant_30 (aTHX_ name, iv_return); break; case 31: return constant_31 (aTHX_ name, iv_return); break; case 32: return constant_32 (aTHX_ name, iv_return); break; case 33: if (memEQ(name, "LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM", 33)) { #ifdef LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM *iv_return = LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 34: return constant_34 (aTHX_ name, iv_return); break; case 35: return constant_35 (aTHX_ name, iv_return); break; case 36: return constant_36 (aTHX_ name, iv_return); break; case 37: /* Names all of length 37. */ /* LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED */ /* Offset 27 gives the best switch position. */ switch (name[27]) { case 'T': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED", 37)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED *iv_return = LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'W': if (memEQ(name, "LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED", 37)) { /* ^ */ #ifdef LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED *iv_return = LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } break; } return PERL_constant_NOTFOUND; } Net-SSH2-0.69/MANIFEST0000644000175000017500000000133413244346574013057 0ustar salvasalvaBUILDING.WIN32 Changes const-c.inc const-xs.inc example/benchmark.pl example/read.pl example/rt58911.pl example/rt80011.pl example/scat.pl inc/Devel/CheckLib.pm inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/CheckLib.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Net/SSH2.pm lib/Net/SSH2/Channel.pm lib/Net/SSH2/Constants.pm lib/Net/SSH2/Dir.pm lib/Net/SSH2/File.pm lib/Net/SSH2/KnownHosts.pm lib/Net/SSH2/Listener.pm lib/Net/SSH2/PublicKey.pm lib/Net/SSH2/SFTP.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.yml ppport.h README SSH2.xs t/Net-SSH2.t typemap Net-SSH2-0.69/Changes0000644000175000017500000005354313244346441013223 0ustar salvasalvaRevision history for Perl extension Net::SSH2. 0.69 2018-2-24 - Fix META.yml generation (bug report by Slaven Rezic). 0.68 2017-12-13 - Fix build when using perl 5.26 which doesn't have "." in @INC anymore (patch by Marc-Philip Werner). 0.67 2017-12-02 - Fix Net::SSH2::Listener "accept" method (patch by Marc-Philip Werner). - Fix Net::SSH2::SFTP "readlink" and "realpath" methods (patch by Marc-Philip Werner). 0.66 2017-07-19 - Warn about readline being called in non-blocking mode. 0.65 2017-06-14 - Improve Travis CI testing - Fix perl 5.8 support - Warn when check_hostkey is called in void context. 0.64 2017-06-14 - Accept debug flag on the constructor. - Ensure the crypto libraries are positioned after libssh2 on the link line (bug report and patch by Jacques Germishuys). - Channel "pty" method now accepts mode modifiers passed as a hash. - In connect, warnif was clobbering $! (bug report and patch by ikegami). - t/Net-SSH2.t: add support for TEST_NET_SSH2_TRACE 0.63 2016-10-13 - die_with_error errors pointed to that method instead of its caller. - Fix case in user message. - Silence warning in perl 5.10. 0.62 2016-06-07 - Code handling the conversion of arguments accepting both integers and constant names was broken for undef. 0.61 2016-06-03 - "auth" method was skipping agent authentication always (bug report and patch by NIkolay A. Fetisov). 0.60 2016-05-23 - Fix connecting to a custom port (bug report by Jan Gehring). 0.59_23 2016-05-19 - Fix handling of eof in Channel read2 method. - Several documentation corrections. - Add example/benchmark.pl to the distribution. 0.59_22 2016-05-18 - Add support for some additional constants. - Make remote login name default to be the same as the local one. - Several documentation improvements. 0.59_21 2016-05-13 - Conversion of stream_id arguments has been moved to a typemap. - Channel 'flush' was not handling 'all' properly. 0.59_20 2016-05-11 - Method timeout is not available in old libssh2 versions. 0.59_19 2016-05-10 - Honour timeout setting from _ask_user method. 0.59_18 2016-05-09 - Fix failing test caused by a remote SIGPIPE (bug report by Ferenc Erki). - Work-around libssh2_channel_wait_closed bug. - Fix channel and file PRINTF methods. - Improve tests. 0.59_17 2016-05-06 - Port Channel "readline" method to File class. - Implement File getc in XS for improved performance. - Add workaround for perl bug around EOF method of tied file handles. - Add more tests. - Several documentation improvements. 0.59_16 2016-05-04 - Save EAGAIN errors after every libssh2 channel and session call. - Extend exit_signal method to return the tree values comming back from libssh2_channel_exit_signal. - Make Channel blocking method be just a wrapper for session blocking method. - Add channel wait_eof method. - Make exit_signal and exit_status call wait_closed under the hood, otherwise they could return a wrong result. - Make wait_closed call wait_eof under the hood to avoid bad usage errors. - Add method exit_signal_number that translates the result of exit_signal to the matching local signal number (note that on the remote machine the signal number may be different). - Channel CLOSE now mimics real file handles better and sets $?. - Improve the test script so that it can be better automated. 0.59_15 2016-05-03 - Channel and SFTP READLINE and readline methods were not handling correctly undef as the end of line marker (i.e. $/=undef). - SFTP and Channel BINMODE methods were returning undef instead of 1. - Add even more tests! - Add more tests (contributed by Chris Kirke). - SFTP file READ was broken (reported by Chris Kirke). 0.59_14 2016-04-28 - READLINE was not clearing the error code correctly. 0.59_13 2016-04-26 - Detect EOF in most cases (cannot be done always due to libssh2 limitations) in "readline" and "getc". - Clear error before returning from "readline" as it returns undef for compatibility with Perl builtin even when no error has happened. - Several documentation improvements. 0.59_12 2016-04-26 *** WARNING: backward incompatible change: "READLINE" had an undocumented hard coded timeout of 250ms which made the method unreliable. That timeout has been removed. If desired, the old behaviour can be attained setting non-blocking mode or with a global timeout. - Add Channel "readline" method. - Add Channel "getc" method. - Cleanup of the channel tie interface. 0.59_11 2016-04-22 - Add channel method "read2". - Do not retry read operations when "libssh2_channel_read_ex" returns 0 (bug report by Ferenc Erki). - Fix definitions for LIBSSH2_ERROR_NONE, LIBSSH2_SESSION_BLOCK_INBOUND and LIBSSH2_SESSION_BLOCK_OUTBOUND. - Scale timeout values passed between IO::Socket::* (using seconds) and libssh2 (using miliseconds). - Several documentation improvements. 0.59_10 2016-04-19 - Don't warn when undef is passed to method "timeout". - Add more tests. - Several documentation improvements. 0.59_09 2016-04-18 - Method "read" was not returning errors correctly. - Typemaps for 64bit integers were broken - Restrict the channel type to "session" in method "channel". - The realclean target of the generated Makefile was deleting const-c.inc and const-xs.inc which are not generated anymore. - Several documentation improvements. 0.59_08 2016-04-18 - Get extended diagnosis messages when $ENV{AUTOMATED_TESTING} is set. 0.59_07 2016-04-17 - In auth, do not call authentications methods unless they are supported by the server. - Fix minor scp_get issue - Add workaround for getpwuid not being available on MS Windows. - Several documentation fixes. 0.59_06 2016-04-17 - Add method die_with_error into Net::SSH2::SFTP - Several documentation improvements. 0.59_05 2016-04-16 - Switch the order of "policy" and "known_host_path" arguments in method "check_hostkey". - Improve "check_hostkey" method adding support for using a callback as policy. - Rename "remote_port" to "port", "remote_hostname" to "hostname" and "check_remote_hostkey" to "check_hostkey". - Rewrite constant generation code - Several documentation improvements. 0.59_04 2016-04-13 - Use libssh2 function "libssh2_scp_send64" when available. It allows sending files bigger than 4GB. - Improve the way the user is prompted. - Improve "check_remote_hostkey" method (WIP). - Add scat.pl sample script - Several documentation improvements. - Remove File::Slurp dependency in test script. 0.59_03 2016-04-12 - Fix Channel "read" method that was hanging in blocking mode. - Add "check_remote_hostkey" method for easy remote host key verification (WIP) - Add "die_with_error" method. - Several documentation improvements. 0.59_02 2016-04-12 - Fix "auth_list" method. - Fix handling of "lib" argument in Makefile.PL. - Compilation was broken for perls 5.8.0 .. 5.8.3. - Several documentation improvements. 0.59_01 2016-04-11 *** WARNING: this release includes lots of changes, some visible, most internal. Regressions are expected. Also, it introduces some minor backward incompatible changes - but in those cases, the old behavior was broken or insane anyway. - libssh2 version 1.7.0 is now recommended. The module would still compile against older versions, but not all its features will be available. - Makefile.PL has been refactored and improved. Now it is better able to find the library libssh2 and compile code using it. - Lots of XS code refactoring has been performed in order to simplify the module internals. Specifically, now typemaps are used extensively to convert between C and Perl types. Also, some complex non-performance-critical functions have been moved to the Perl side or broken in a high level Perl wrapper and a low level simpler C wrapper. - KnownHost methods now return undef on error instead of die'ing. Note that this submodule is still marked as experimental. - Die when data containing wide characters is passed (i.e. outside the latin1 range). In previous versions, methods on this module would happily accept strings internally encoded as latin1 or utf8 and pass then along untouched, resulting in unreliable behavior. - In 32bit perls, return offsets and file sizes as NVs when required to avoid overflow. - Method "new" now also accepts the options "compress" and "sigpipe". - Passing options to "connect" is now deprecated. - Passing a file descriptor number to "connect" is not supported anymore (it was already broken). - Method "connect" consistently returns undef on error. The error code can be retrieved calling the "error" method (requires libssh2 1.7.0). In previous versions, some errors made the method die. - Timeouts are handled correctly inside "connect". - Report EAGAIN in the same way as any other error. This introduces a minor backward incompatibility, but the old behavior was utterly insane and undocumented, and so probably, nobody was using it right anyway! - Use libssh2_session_set_last_error function for storage of the Perl level errors (required libssh2 1.7.0). This may introduce some minor backward incompatibilities, but the old code was broken and unreliable anyway. 0.58 2015-12-20 - re-released as stable 0.57_03 2015-12-5 - remove MYMETA.* from distribution (fixes #rt108717, reported by Alexandr Ciornii) - workaround bug in libssh2_agent_disconnect (fixes #28, reported by Tore Anderson) 0.57_02 2015-10-29 - Module::Install::CheckLib was missing 0.57_01 2015-10-26 - reimplement scp_put and scp_get methods fixing several issues - add support for Mac Homebrew and its keg-only OpenSSL 0.56 2015-10-9 - add support for auth_publickey_frommemory method (patch by Adam Osuchowski) - several documentation improvements - fix broken test, rsa were not used for authentication (#rt107382 reported by sisyphus) - fix broken test, sock method can return both IO::Socket::IP and IO::Socket::INET objects (#rt107381 reported by sisyphus) - improves docs for Net::SFTP::File::write method (#rt58911 reported by Salvatore Bonaccorso). 0.55 2015-09-27 - rerelease as stable - fix errors in test script 0.54_02 2015-09-13 - channel write method was concealing errors - several doc improvements (patches by Jason Lewis) 0.54_01 2015-08-27 - on auth method use key passphrase instead of password to refer to the private key passphrase - using password will be deprecated in future releases and is now warned - add support for IPv6 via IO::Socket::IP (patch submitted by Baldur Kristinsson) - use binmode when transferring data from/to the local filesystem in SCP methods - add support for password-interact authentication - add fallback option to auth method - allow undef as the publickey path (patch submitted by Yuni Kim) - on channel write method, when blocking mode is set, call libssh2_channel_write repeatly until the buffer is empty - on channel read method, when non-blocking mode is set, don't call libssh2_channel_read repeatly until the buffer is filled - add Net::SSH2 known_hosts method and Net::SSH2::KnownHosts class - add keepalive_config and keepalive_send methods - add channel methods "window_write", "window_read" and "receive_window_adjust" - add "Compress" option into "connect" method - add "flags" method - exit_signal was generating SIGSEGV - improve callback handling - several documentation clarifications added - fix several memory leaks - fix several file descriptor leaks - Lots of other minor tweaks 0.53 2013-09-01 06:05:17 - add support for ldargs, and LIBSSH2_LIB, LIBSSH2_INCLUDE, LIBSSH2_LDARGS env vars while building (RT#88265) 0.52 2013-08-14 02:43:11 - detect scp not being installed on the remote and return undef from scp_put (krimdomu: Jan) (GitHub PR: #17) 0.51 2013-08-03 21:17:47 - turn off -std=c89 -pedantic-errors for all builds except authors not on mingw or solaris 0.50 2013-07-29 10:25:13 - remove #warning, not standard C89, throws an error on non-threaded builds due to -pedantic-errors (RT#87398) 0.49 2013-07-22 20:11:25 - compile on gcc with '-DPERL_GCC_PEDANTIC -std=c89 -pedantic-errors -Wno-long-long' to enforce maximum compatibility with C89 (RT#87069) 0.48 2013-02-20 20:58:18 - fix builds on non-threaded perls (mauke: Lukas Mai) - set default extra libs for Win32 (kmx) 0.47 2013-02-10 19:06:42 - timeout method to set a global timeout for every action (uses libssh2_session_set_timeout) (pullreq from Thierry Treyer: zehkae) - threads support for OpenSSL and libgcrypt (pullreq from James Mccoy: jamessan) - support for building with libgcrypt (pass gcrypt to Makefile.PL) (pullreq from James Mccoy: jamessan) 0.46 2012-11-10 01:33:14 - patch from Robert-Jean Denault (Robert-jean.Denault@telus.com) to fix segfault when releasing sftp object in debug mode 0.45 2012-05-27 09:18:49 - add 64bit instructions to BUILDING.WIN32 and clarify some things 0.44 2012-04-25 16:27:55 - update to latest ppport.h - fix memory leak in password auth (RT#76701) (salva) 0.43 2012-04-24 07:47:21 - correct fix for (RT#73659) (remove inc=/lib= from @ARGV) - add BUILDING.WIN32 guide for building on Windows from scratch 0.42 2012-04-19 14:05:44 - add LD_RUN_PATH/LD_LIBRARY_PATH to search paths (RT#74747) - fix order of search paths for libs/includes 0.41 2012-04-18 22:12:07 - fix missing -I for include directory with inc= option to Makefile.PL (RT#73659) 0.40 2011-10-23 18:41:17 - add ssh-agent support (krimdomu) 0.39 2011-07-17 18:24:30 - fix double free in auth_password (RT#69444) 0.38 2011-06-02 14:52:30 - add version check for block_directions 0.37 2011-06-02 14:34:26 - update ppport.h - use correct libssh2 version check for exit_signal support 0.36 2011-05-27 21:28:00 - allow setting lib and inc paths on the command line (salva) 0.35 2011-05-10 17:43:17 - fix for segfault due to auth_list() (RT#68060) 0.34 2011-05-07 08:34:35 - fix trace option to ->new - handle partial writes for scp_put - add $chan->exit_signal (patch from tommy.lindgren@gmail.com) - add $ssh->block_directions - add new constants (socket, trace and ERROR_EAGAIN) 0.33 2010-07-13 07:59:22 - change trace option to use bitmask, so it becomes trace => -1, also added ->trace method 0.32 2010-07-13 07:47:12 - add trace => 1 option to ->new (RT#59292) 0.31 2010-06-13 09:35:38 - remove eval $VERSION, was confusing some testers 0.30 2010-05-20 10:43:14 - rename symbol libssh2_error to xs_libssh2_error to avoid symbol clashes (sisyphus) 0.29 2010-04-14 20:25:37 - fix splice warning when connecting with a socket handle (RT#56592) 0.28 2009-10-24 07:27:42 - added patch to find 64bit libs from H.Merijn Brand - fix breakage on versions < 1.0 related to the pty functions 0.27 2009-09-10 06:54:58 - reverting a bad release 0.25 2009-09-07 01:07:58 - fix an unitialized warning 0.24 2009-08-20 19:55:28 - include patch for $chan->pty_size($w, $h) from Rubio Vaughan 0.23 2009-08-18 04:00:42 - Fix timeout option (forgot key) 0.22 2009-08-15 11:10:03 - "or die" semantics for ->connect (in non-void context) - Timeout option for ->connect 0.21 2009-06-06 21:02:34 - some fixes for Cygwin 0.20 2009-06-01 04:17:37 - Added patch from sisyphus for win32 support for tests. - Link to some extra libs in case of static build (also from sisyphus.) - Added Timeout to socket options. - Added "sock" accessor for underlying socket. 0.19 2009-04-11 01:03:39 - Updated for perl 5.10 and 5.6 compatibility. 0.18 2007-11-10 dbr (svn revision 56) - Note version change: synced to libssh2. Should be compatible with libssh2 0.16+, including future versions provided API remains stable. - Documented Net::SSH2::version class method. - Removed references to LIBSSH2_APINO (removed in libssh2 0.16); fixes rt.cpan.org #28722. - Fixed memory leak in poll (rt.cpan.org #27368, based on patch from David Sullivan). - Fixed 0-valued POSIX flag translation bug (based on patch from Joseph Galbraith). - Check lib64 as well as lib for libraries (patch from Leo Eraly). - Add blocking method to Net::SSH2 object. 0.10 2007-02-24 dbr (svn revision 52) - Net::SSH2::SFTP::realpath fix (Hugues Lafarge). - Make compatible with perl 5.6 (rt.cpan.org #22821, SISYPHUS); required minimal changes to typemap and use lines (untested). - libssh2 0.13 seems to work, libssh2 0.14 still fails some tests. - Add missing Net::SSH2::PublicKey object. - Use (arbitrary) 8K buffer in scp_get and scp_put methods, rather than trying to transfer the whole file at once (rt.cpan.org #20679). - Remove 'use Term::ReadKey'; it's already 'require'd in the keyboard authentication callback (rt.cpan.org #22786). - Provide libssh2 with Perl's allocator callbacks and use Perl_malloc/ Perl_mfree instead of bare malloc/free (rt.cpan.org #23930). 0.09 2006-09-25 dbr (svn revision 50) - scp_get fixes: mode mask, truncate on create (Stephen Clouse). - Fix O_CREATE to O_CREAT in perldoc. - Fix typo: wait_close -> wait_closed (rt.cpan.org #20117). - Add example/ directory and read.pl example to manifest so that it gets included in the distribution (Danny Thomas). - Add Net::SSH2::debug class method to enable debugging output at runtime (used to require recompile to enable). - Have poll of empty array return 0 early to fix architectures that return 0 for malloc(0) (L. Adrian Griffis). - WARNING: latest libssh2 builds (0.13, 0.14) don't pass module tests any more; if you have problems try 0.12 or earlier. 0.08 2006-05-06 dbr (svn revision 46) - Fix refcount bug (objects not destroyed) (Stephen Clouse). 0.07 2006-03-17 dbr (svn revision 44) - Remove incorrect statement that poll with timeout of 0 will block. - Fix scp_put read size (fix by Pier Hegeman, rt.cpan.org #17370). - Fix Win32 check (rt.cpan.org #17656). - Fix scp_get buffer overrun (Rutger Ovidus, rt.cpan.org #16886). - Update Net::SSH2 SYNOPSIS (thanks to Roy Smith). - NOTE: CPAN alias AWA (Vandana Awasthi) released an unauthorized "0.07" version of Net::SSH2; you can recognize it because it says 0.06 in the changelog. I have not been able to contact AWA. 0.06 2006-01-14 dbr (svn revision 42) - Win32 modifications (thanks to Eric Lam for research and patches). - Use MAXPATHLEN instead of PATH_MAX; add some casts (thanks to bug report from Freddy Soderlund). - Update exec documentation to clarify that it runs a single command and closes the channel (thanks to Mike Schmidt). - Use '' for tied PRINT output separator if undefined (stop warnings). 0.05 2005-11-11 dbr (svn revision 40) - More C89 fixes (-ansi -pedantic); thanks to Chuck Carson for testing. - Remove "inline" (Solaris cc doesn't like it) (rt.cpan.org #15707). - Various minor cleanups. 0.04 2005-11-07 dbr (svn revision 38) - Fix c89 compile errors and warnings (-Wall). - Make example/read.pl available as first sample script. - Add public key objects (libssh2 0.12+ only). 0.03 2005-11-02 dbr (svn revision 36) - Use poll in Net::SSH2::Channel::GETC (250 ms timeout). - Change SCP interface; don't return a channel. 0.02 2005-11-01 dbr (svn revision 35) - Add tie support to Net::SSH2::File objects. 0.01 2005-11-01 dbr (svn revision 30) - First alpha release with full SSH2/SFTP support (uses libSSH2). - Original version; created by h2xs 1.23 with options -A -n Net::SSH2 -b 5.8.0. 0.00 2005-10-23 - Project started in Redmond, Washington, USA. Net-SSH2-0.69/typemap0000644000175000017500000000757513232575602013336 0ustar salvasalvaTYPEMAP char * T_PV unsigned char * T_PV const char * T_PV AV * T_AVREF time_t T_TIME_T size_t T_SIZE_T long T_LONG SSH2 * O_SESSION SSH2_CHANNEL * O_CHANNEL SSH2_LISTENER * O_LISTENER SSH2_SFTP * O_SFTP SSH2_FILE * O_FILE SSH2_DIR * O_DIR SSH2_PUBLICKEY* O_PUBLICKEY SSH2_KNOWNHOSTS* O_KNOWNHOSTS SSH2_RC T_SSH2_RC SSH2_ERROR T_SSH2_ERROR SSH2_NERROR T_SSH2_NERROR SSH2_BYTES T_SSH2_BYTES SSH2_BYTES64 T_SSH2_BYTES64 SSH2_BYTESU64 T_SSH2_BYTESU64 SSH2_BOOL T_SSH2_BOOL SSH2_METHOD T_SSH2_METHOD SSH2_FLAG T_SSH2_FLAG SSH2_CALLBACK T_SSH2_CALLBACK SSH2_HOSTKEY_HASH T_SSH2_HOSTKEY_HASH SSH2_CHANNEL_EXTENDED_DATA T_SSH2_CHANNEL_EXTENDED_DATA SSH2_CHARP T_SSH2_CHARP SSH2_CHARP_OR_NULL T_SSH2_CHARP_OR_NULL SSH2_STREAM_ID T_SSH2_STREAM_ID OUTPUT T_PV sv_setpv((SV*)$arg, $var); T_AVREF $arg = newRV((SV*)$var); T_SSH2_BYTES $arg = ( (($var) < 0) ? &PL_sv_undef : newSVuv($var) ); T_SSH2_BYTES64 $arg = ( (($var) < 0) ? &PL_sv_undef : ((IVSIZE >= 8) ? newSVuv($var) : newSVnv($var)) ); T_SSH2_BYTESU64 $arg = ((IVSIZE >= 8) ? newSVuv($var) : newSVnv($var)); T_SSH2_BOOL $arg = (($var) ? &PL_sv_yes : &PL_sv_no); T_SSH2_RC $arg = (($var) ? &PL_sv_yes : &PL_sv_undef); T_SSH2_ERROR $arg = newSViv($var); T_SSH2_NERROR $arg = ( (($var) < 0) ? &PL_sv_undef : &PL_sv_yes ); T_SSH2_CHARP_OR_NULL $arg = ($var ? newSVpv($var, 0) : &PL_sv_undef); O_SESSION sv_setref_pv($arg, "Net::SSH2", (void *)$var); O_CHANNEL wrap_tied_into($arg, "Net::SSH2::Channel", (void *)$var); O_LISTENER sv_setref_pv($arg, "Net::SSH2::Listener", (void *)$var); O_SFTP sv_setref_pv($arg, "Net::SSH2::SFTP", (void *)$var); O_FILE wrap_tied_into($arg, "Net::SSH2::File", (void *)$var); O_DIR sv_setref_pv($arg, "Net::SSH2::Dir", (void *)$var); O_PUBLICKEY sv_setref_pv($arg, "Net::SSH2::PublicKey", (void *)$var); O_KNOWNHOSTS sv_setref_pv($arg, "Net::SSH2::KnownHosts", (void *)$var); INPUT T_PV $var = ($type)SvPV_nolen($arg) T_AVREF if(SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) $var = (AV*)SvRV($arg); else croak(\"$var is not an array reference\"); O_SESSION $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); O_CHANNEL $var = INT2PTR($type, unwrap_tied($arg, \"$Package\", \"$func_name\")); O_LISTENER $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); O_SFTP $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); O_FILE $var = INT2PTR($type, unwrap_tied($arg, \"$Package\", \"$func_name\")); O_DIR $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); O_PUBLICKEY $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); O_KNOWNHOSTS $var = INT2PTR($type, unwrap($arg, \"$Package\", \"$func_name\")); T_SSH2_BOOL $var = SvTRUE($arg); T_SSH2_METHOD $var = sv2iv_constant_or_croak(\"METHOD\", $arg); T_SSH2_FLAG $var = sv2iv_constant_or_croak(\"FLAG\", $arg); T_SSH2_CALLBACK $var = sv2iv_constant_or_croak(\"CALLBACK\", $arg); T_SSH2_HOSTKEY_HASH $var = sv2iv_constant_or_croak(\"HOSTKEY_HASH\", $arg); T_SSH2_CHANNEL_EXTENDED_DATA $var = sv2iv_constant_or_croak(\"CHANNEL_EXTENDED_DATA\", $arg); T_SSH2_CHARP $var = SvPVbyte_nolen($arg); T_SSH2_CHARP_OR_NULL $var = (SvOK($arg) ? SvPVbyte_nolen($arg) : NULL); T_TIME_T $var = SV2TYPE($arg, time_t); T_SIZE_T $var = SV2TYPE($arg, size_t); T_INT $var = my_sv2int($arg); T_LONG $var = SV2TYPE($arg, long); T_SSH2_BYTES64 $var = SV2TYPE($arg, SSH2_BYTES64); T_SSH2_BYTESU64 $var = SV2UTYPE($arg, SSH2_BYTESU64); T_SSH2_STREAM_ID $var = sv2iv_constant_or_croak(\"CHANNEL_FLUSH\", $arg); Net-SSH2-0.69/BUILDING.WIN320000644000175000017500000001367113033750102013634 0ustar salvasalvaHere I'll describe how to build Net::SSH2 on Windows. ** Install MinGW and MSys Instructions are here: http://www.mingw.org/wiki/Getting_Started Use the GUI installer, make sure to install the C compiler, the C++ compiler (this is VERY important, don't forget the C++ compiler, it is used for linking!), MSys and the Developer Tools. I like to add C:\MinGW\bin;C:\MinGW\MSys\1.0\local\bin;C:\MinGW\MSys\1.0\bin to my PATH in the System Control Panel under Environment Variables in Advanced Settings; and set the HOME environment variable to C:\Users\rkitover. For 64bit perls, you will also need MinGW-w64, get it here: http://mingw-w64.sourceforge.net/ under WIN64 Downloads. Get either the rubenvb build from Personal Builds or the latest from Automated Builds, whichever is newer. Get the win64 native compiler suite, NOT the win32 cross-compiler suite. Unpack it to C:\MinGW_w64\. If there is a top level directory in the archive, unpack everything BELOW the top level directory to C:\MinGW_w64\. ** Building the libraries For this part we are going to use the MinGW MSys bash shell. You should have a shortcut for it under the MinGW program group. It's much nicer with the mintty terminal, if you want to install it run: mingw-get install mintty then make a copy of the MinGW Shell shortcut to your desktop and modify the Target to add the -mintty switch to the end. For 64bit perls, we will build with the MinGW-w64 toolchain, so modify your PATH as follows for this section: export PATH=/c/MinGW_w64/bin:$PATH * Build zlib Download the latest tarball of zlib from: http://zlib.net/ Unpack it and go into it: tar zxvf zlib-1.2.7.tar.gz cd zlib-1.2.7 Run: make -f win32/Makefile.gcc mkdir include cp *.h include mkdir lib cp libz.a lib * Build OpenSSL Download the latest tarball of OpenSSL from: http://www.openssl.org/source/ Unpack it in and go into it: tar zxvf openssl-1.0.1c.tar.gz cd openssl-1.0.1c Configure for 32bit: ./config no-shared zlib no-zlib-dynamic \ --with-zlib-include='C:\\Users\\rkitover\\src\\zlib-1.2.7\\include' \ --with-zlib-lib='C:\\Users\\rkitover\\src\\zlib-1.2.7\\lib' Configure for 64bit: ./Configure mingw64 no-shared no-asm no-hw zlib no-zlib-dynamic \ --with-zlib-include='C:\\Users\\rkitover\\src\\zlib-1.2.7\\include' \ --with-zlib-lib='C:\\Users\\rkitover\\src\\zlib-1.2.7\\lib' You can experiment by removing the "no-asm no-hw" flags to ./Configure and seeing if the build succeeds, the assembly files did not build for me with the latest MinGW-w64, this was with the gcc-4.7.0 rubenvb build. Build: make -j3 mkdir lib cp libssl.a libcrypto.a lib Adjust the -j parameter for your system's number of cores +1. The build may not run to completion, building the apps may fail, but we don't care about that, as long as the .a files build. * Build libssh2 Download the latest libssh2 from: http://libssh2.org/ Unpack it and go into it: tar zxvf libssh2-1.4.2.tar.gz cd libssh2-1.4.2 Note the directories where you built OpenSSL and zlib, I will use mine in the following example. Build libssh2: ./buildconf ./configure --with-openssl --with-libz \ --with-libssl-prefix=/c/Users/rkitover/src/openssl-1.0.1c \ --with-libz-prefix=/c/Users/rkitover/src/zlib-1.2.7 \ --disable-examples-build make -j3 The libssh2.a will be in src/.libs . * Build Net::SSH2 Download and unpack the Net::SSH2 distribution from CPAN, follow the download link from: https://metacpan.org/module/Net::SSH2 Open a cmd.exe shell. ActivePerl 32bit setup: Make sure you have dmake installed, to do this you may simply invoke: ppm install dmake Set your PATH for this session: set PATH=c:\perl\bin;c:\mingw\bin;c:\perl\site\bin;c:\windows\system32;c:\windows ActivePerl 64bit setup: Download the dmake dist from here: http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/dmake-4.12-20090907-SHAY.zip Extract dmake.exe and the startup/ folder into C:\Perl64\site\bin . Set your PATH as follows: set PATH=c:\perl64\bin;c:\mingw_w64\bin;c:\perl64\site\bin;c:\windows\system32;c:\windows It is important that Visual Studio/Platform SDK tools are not in your PATH, otherwise ActiveState Perl won't use MinGW, and that the official MinGW (or MinGW-w64, the one we compiled the libraries with) takes precedence over the one that is often installed via PPM. For Strawberry Perl, we also want to use the official MinGW rather than the bundled one, so set your PATH as follows: set PATH=c:\strawberry\perl\bin;c:\mingw\bin;c:\strawberry\c\bin;c:\windows\system32;c:\windows For 64bit Strawberry Perl, set your PATH as follows: set PATH=c:\strawberry64\perl\bin;c:\mingw_w64\bin;c:\strawberry64\c\bin;c:\windows\system32;c:\windows assuming you installed the 64bit Strawberry Perl to C:\Strawberry64 . For 64bit ActivePerl, edit the config file in C:\Perl64\lib\Config_heavy.pl and remove all instances of 'bufferoverflowU.lib'. For both 64bit perls, set LIBRARY_PATH as follows: set LIBRARY_PATH=c:\mingw_w64\x86_64-w64-mingw32\lib Make sure you have the newest EUMM. Type: cpan ExtUtils::MakeMaker Edit Makefile.PL, Change the line: my $extra_libs = '-lz -lssl -lcrypto'; to my $extra_libs = 'c:/users/rkitover/src/zlib-1.2.7/lib/libz.a c:/users/rkitover/src/openssl-1.0.1c/lib/libssl.a c:/users/rkitover/src/openssl-1.0.1c/lib/libcrypto.a'; (using the directories where you have the libs.) Change the line: my @define = $win32 ? (DEFINE => '-DLIBSSH2_WIN32') : (); to my @define = $win32 ? ( (DEFINE => '-DLIBSSH2_WIN32 -DLIBSSH2_API='), (LDDLFLAGS => $Config{lddlflags} . ' -static-libgcc -static-libstdc++'), ) : (); Build: perl Makefile.PL lib=c:\users\rkitover\src\libssh2-1.4.2\src\.libs inc=c:\users\rkitover\src\libssh2-1.4.2\include dmake dmake test dmake install That's it! Please send me improvements and clarifications for this guide. Net-SSH2-0.69/META.yml0000644000175000017500000000206113244346623013170 0ustar salvasalva--- abstract: 'Support for the SSH 2 protocol via libssh2.' author: - '- 2010 by David B. Robins (dbrobins@cpan.org).' build_requires: ExtUtils::MakeMaker: 6.59 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.17' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Net-SSH2 no_index: directory: - example - inc - t provides: Net::SSH2: file: lib/Net/SSH2.pm version: '0.69' Net::SSH2::Channel: file: lib/Net/SSH2/Channel.pm Net::SSH2::Dir: file: lib/Net/SSH2/Dir.pm Net::SSH2::File: file: lib/Net/SSH2/File.pm Net::SSH2::KnownHosts: file: lib/Net/SSH2/KnownHosts.pm Net::SSH2::Listener: file: lib/Net/SSH2/Listener.pm Net::SSH2::PublicKey: file: lib/Net/SSH2/PublicKey.pm Net::SSH2::SFTP: file: lib/Net/SSH2/SFTP.pm requires: perl: 5.6.0 resources: license: http://dev.perl.org/licenses/ repository: git://github.com/rkitover/net-ssh2.git version: '0.69' Net-SSH2-0.69/Makefile.PL0000644000175000017500000002350013244321057013664 0ustar salvasalva BEGIN { unshift @INC, '.' unless -d ".git"; } use inc::Module::Install 1.17; use Cwd; use Config; use File::Glob qw(bsd_glob); use strict; use warnings; my $win32 = ($^O eq 'MSWin32'); my $darwin = ($^O eq 'darwin'); my $solaris = ($^O eq 'solaris'); my $linux = !($win32 || $darwin || $solaris ); # yea, more than linux are going to end here! my $cc_gcc = $Config{cc} =~ /gcc/; my $cc_wincl = $win32 && $Config{cc} =~ /cl/; my $path_sep = $Config{path_sep}; print <<'EOF'; The libssh2 library is required by this module. If you don't have it, you can download it from http://www.libssh2.org; you may also need OpenSSL, which can be obtained from http://www.openssl.org , or libgcrypt, which can be obtained from http://www.gnupg.org . Debian: sudo aptitude install libssh2-1-dev OpenSUSE: sudo zypper in libssh2-1 libssh2-devel You can pass your libssh2 lib and include dirs (and extra link args) on the command line. E.g.: perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include \ ldargs="-lz" These can also be set through the LIBSSH2_LIB/LIBSSH2_INCLUDE/LIBSSH2_LDARGS environment variables. To build with libgcrypt instead of OpenSSL, pass 'gcrypt' as a parameter to Makefile.PL, e.g.: perl Makefile.PL gcrypt If you want to build on Windows, see the file BUILDING.WIN32 in the distribution. EOF my $crypto_backend; my $do_not_check_libs; sub makemaker_append_once; sub capture; sub findlib; name 'Net-SSH2'; all_from 'lib/Net/SSH2.pm'; perl_version '5.006000'; auto_provides; makemaker_append_once CCFLAGS => $Config{ccflags}; makemaker_append_once LDDLFLAGS => $Config{lddlflags}; my %arg2mmappend = ( inc => 'INC', lib => 'LIBS', ldargs => 'LDDLFLAGS' ); my %arg2prefix = (inc => '-I', lib => '-L'); my $arg_keys = join('|', map quotemeta, keys %arg2mmappend); my $do_not_check_libs_keys = 'lib|inc'; for (keys %ENV) { if (/^LIBSSH2_($arg_keys)$/) { my $value = $ENV{$_}; my $prefix = $arg2prefix{lc $1} || ''; $value = File::Spec->rel2abs($value) if $prefix; makemaker_append_once $arg2mmappend{lc $1} => $prefix . $value; $do_not_check_libs ||= /^LIBSSH2_($do_not_check_libs_keys)$/i; } } my @pass_through_args; for (@ARGV) { if (/^($arg_keys)=(.*)\z/) { my $prefix = $arg2prefix{$1} || ''; my $value = $2; $value = File::Spec->rel2abs($value) if $prefix; makemaker_append_once $arg2mmappend{$1} => $prefix.$value; $do_not_check_libs ||= /^($do_not_check_libs_keys)=/; } elsif ($_ eq 'gcrypt') { $crypto_backend = 'gcrypt'; } elsif ($_ eq 'openssl') { $crypto_backend = 'openssl'; } else { push @pass_through_args, $_; } } @ARGV = @pass_through_args; my @search_paths; for my $env ('LD_RUN_PATH', ($darwin ? 'DYLD_LIBRARY_PATH' : 'LD_LIBRARY_PATH')) { my $v = $ENV{$env}; push @search_paths, split(/\Q$path_sep\E/, $v) if defined $v; } push @search_paths, split(' ', $Config{libspath}), $Config{siteprefixexp}, $Config{prefixexp}, '/usr', '/usr/local', '/opt', '/opt/local', '/usr/local/libssh2', '/opt/libssh2', '/usr/local/libssh2/*', '/usr/local/ssl'; push @search_paths, $ENV{HOME}, "$ENV{HOME}/libssh2" if defined $ENV{HOME}; # mac homebrew support if ($^O eq 'darwin' && -x '/usr/local/bin/brew') { system("/usr/local/bin/brew info libssh2 | grep '^Not installed' >/dev/null"); if ($? >> 8 == 0) { system("/usr/local/bin/brew -v install libssh2"); } system("/usr/local/bin/brew info openssl | grep '^Not installed' >/dev/null"); if ($? >> 8 == 0) { system("/usr/local/bin/brew -v install openssl"); } push @search_paths, '/usr/local/Cellar/openssl/*'; } @search_paths = map { /\*/ ? (sort { (stat $b)[9] <=> (stat $a)[9] } grep -d, bsd_glob($_)) : $_ } @search_paths; my %sp_seen; @search_paths = grep !$sp_seen{$_}++, @search_paths; sub findlib { local $Module::Install::AUTHOR; my %args = @_; my @search_paths = @{delete $args{search_paths} || []}; for my $sp (undef, @search_paths) { for my $libpath (defined $sp ? (map [$_], grep -d, "$sp/lib", "$sp/lib64", $sp) : []) { my $incpath = (defined $sp ? [grep -d, "$sp/include"] : []); my @ldflags = ''; push @ldflags, "-Wl,-rpath=".$libpath->[0] if $cc_gcc and defined $sp; for my $ldflags (@ldflags) { if (eval { assertlibs( %args, libpath => $libpath, incpath => $incpath, ldflags => $ldflags); 1; }) { warn "Library $args{lib} found in ".(defined $sp ? $sp : "standard place")."\n"; makemaker_append_once INC => "-I$_" for @$incpath; makemaker_append_once LIBS => "-L$_" for @$libpath; makemaker_append_once LIBS => "-l$args{lib}"; makemaker_append_once LDDLFLAGS => $ldflags if $ldflags; return 1; } else { warn $@ if $@ and $ENV{AUTOMATED_TESTING}; } } } } die "Unable to find a working version of library $args{lib} in the following directories:\n ". (join "\n ", @search_paths)."\n"; } if ($do_not_check_libs) { $crypto_backend ||= 'openssl'; } else { warn "Looking for libraries...\n"; my $detected_crypto_backend; # This is a workaround for Module::Install::CheckLib behaving # differently in user and author mode. Specifically, in author # mode, we call M::I::CheckLib normally so that it can copy # its files under "inc/", and then, we hide we are in author # mode and call it again so that it actually runs the # checklibs stuff.. if ($Module::Install::AUTHOR) { eval { assertlibs( lib => 'ssh2', header => 'libssh2.h', libpath => [], incpath => []); }; } findlib(lib => 'ssh2', header => 'libssh2.h', search_paths => \@search_paths, function => < sub { warn "Analyzing file $_[1]\n"; local $@; eval { my $out = capture ldd => $_[1]; # warn "out:\n$out"; if ($out =~ /gcrypt/i) { $detected_crypto_backend = 'gcrypt'; } elsif ($out =~ /lib(ssl|crypto)/i) { $detected_crypto_backend = 'openssl'; } else { warn "Unable to detect crypto backend used by libssh2!\n" } }; warn $@ if $@ and $ENV{AUTOMATED_TESTING}; 1; }, run_checks_as_author => 1, ); if (defined $detected_crypto_backend) { if (defined $crypto_backend) { $crypto_backend eq $detected_crypto_backend or warn "Detected crypto backend ($detected_crypto_backend) does not match ". "the one requested on the command line ($crypto_backend)"; } else { warn "Detected crypto backend: $detected_crypto_backend\n"; $crypto_backend = $detected_crypto_backend; } } $crypto_backend ||= 'openssl'; unless ($win32) { findlib(lib => 'z', header => 'zlib.h', search_paths => \@search_paths, run_checks_as_author => 1); if ($crypto_backend eq 'gcrypt') { findlib(lib => 'gcrypt', header => 'gcrypt.h', search_paths => \@search_paths, run_checks_as_author => 1); } else { findlib(lib => 'ssl', header => 'openssl/ssl.h', search_paths => \@search_paths, run_checks_as_author => 1); findlib(lib => 'crypto', header => 'openssl/crypto.h', search_paths => \@search_paths, run_checks_as_author => 1); } } } makemaker_append_once LIBS => '-lssh2', '-lz'; if ($crypto_backend eq 'gcrypt') { makemaker_append_once(LDDLFLAGS => '-lgcrypt'); } else { if ($cc_wincl) { makemaker_append_once(LIBS => "-l$_") for qw(ssleay32 libeay32); # Win32 + MSVC compiler } if ($cc_gcc && $win32) { makemaker_append_once(LIBS => "-l$_") for qw(ssl32 eay32); # Win32 + GCC compiler (mingw) } else { makemaker_append_once(LIBS => "-l$_") for qw(ssl crypto); } } makemaker_append_once(DEFINE => '-DLIBSSH2_WIN32') if $win32; makemaker_append_once(DEFINE => '-DUSE_GCRYPT') if $crypto_backend eq 'gcrypt'; makemaker_append_once(CCFLAGS => '-Wno-deprecated-declarations') if $^O eq 'darwin'; makemaker_append_once(CCFLAGS => '-DPERL_GCC_PEDANTIC -std=c99 -pedantic-errors -Wno-long-long') if $Module::Install::AUTHOR and $linux and $cc_gcc; resources repository => 'git://github.com/rkitover/net-ssh2.git'; my $gen = "util/gen_constants.pl"; if (-f $gen) { system $^X, $gen and warn "$gen failed: $?\n"; } WriteAll; my %appended; sub makemaker_append_once { my $key = shift; for (@_) { makemaker_append $key, $_ unless $appended{$key}{$_}++; } } sub capture { if (open my $fh, '-|', @_) { my $out = do { local $/, <$fh> }; close $fh; return $out; } '' } Net-SSH2-0.69/const-xs.inc0000644000175000017500000000514713244346623014200 0ustar salvasalvavoid constant(sv) PREINIT: #ifdef dXSTARG dXSTARG; /* Faster if we have it. */ #else dTARGET; #endif STRLEN len; int type; IV iv; /* NV nv; Uncomment this if you need to return NVs */ /* const char *pv; Uncomment this if you need to return PVs */ INPUT: SV * sv; const char * s = SvPV(sv, len); PPCODE: /* Change this to constant(aTHX_ s, len, &iv, &nv); if you need to return both NVs and IVs */ type = constant(aTHX_ s, len, &iv); /* Return 1 or 2 items. First is error message, or undef if no error. Second, if present, is found value */ switch (type) { case PERL_constant_NOTFOUND: sv = sv_2mortal(newSVpvf("%s is not a valid Net::SSH2 macro", s)); PUSHs(sv); break; case PERL_constant_NOTDEF: sv = sv_2mortal(newSVpvf( "Your vendor has not defined Net::SSH2 macro %s, used", s)); PUSHs(sv); break; case PERL_constant_ISIV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHi(iv); break; /* Uncomment this if you need to return NOs case PERL_constant_ISNO: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(&PL_sv_no); break; */ /* Uncomment this if you need to return NVs case PERL_constant_ISNV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHn(nv); break; */ /* Uncomment this if you need to return PVs case PERL_constant_ISPV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHp(pv, strlen(pv)); break; */ /* Uncomment this if you need to return PVNs case PERL_constant_ISPVN: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHp(pv, iv); break; */ /* Uncomment this if you need to return SVs case PERL_constant_ISSV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(sv); break; */ /* Uncomment this if you need to return UNDEFs case PERL_constant_ISUNDEF: break; */ /* Uncomment this if you need to return UVs case PERL_constant_ISUV: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHu((UV)iv); break; */ /* Uncomment this if you need to return YESs case PERL_constant_ISYES: EXTEND(SP, 1); PUSHs(&PL_sv_undef); PUSHs(&PL_sv_yes); break; */ default: sv = sv_2mortal(newSVpvf( "Unexpected return type %d while processing Net::SSH2 macro %s, used", type, s)); PUSHs(sv); } Net-SSH2-0.69/README0000644000175000017500000000573213244346530012604 0ustar salvasalvaNet::SSH2 - Secure Shell protocol interface =========================================== Net::SSH2 is a perl interface to the libssh2 (http://www.libssh2.org) library. It supports the SSH2 protocol (there is no support for SSH1) with all of the key exchanges, ciphers, and compression of libssh2. At present, libssh2 requires OpenSSL (http://www.openssl.org) and can optionally use zlib for compression (http://www.zlib.net). MODULE DEPENDENCIES To install modules that Net::SSH2 depends upon type the following: cpanm Module::Install Module::Install::CheckLib IO::Scalar Term::ReadKey DEPENDENCIES This module also requires these libraries: libssh2 (http://www.libssh2.org; recommended to use version 1.7.0 or later) OpenSSL (http://www.openssl.org) zlib (optional; http://www.zlib.net) To install dependencies: Debian: sudo aptitude install libssh2-1-dev libssl-dev OpenSUSE: sudo zypper in libssh2-1 libssh2-devel OS X homebrew: brew install libssh2 INSTALLATION To install Net::SSH2 type the following: perl Makefile.PL make make test make install BUGS/FEATURE REQUESTS Please report bugs and request features on the CPAN bug tracking site, rt.cpan.org. If you are able and willing to provide a fix, attach a patch and please provide your name to be credited in the changelog and an email address for verification/discussion. The ssh-sftp-perl-users mailing list (http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users), while set up for Net::SSH::Perl, is also an appropriate place to post questions or comments about Net::SSH2. TESTING You can run more extensive tests with the following command: perl -Mblib t/Net-SSH2.t This will prompt you for a hostname and subsequently a username to test connecting with. You can use localhost, a remote hostname or an IPv4 or IPv6 address. There are some tests (SCP) that require IO::Scalar installed to run. HACKING The module is kept in a GitHub (http://github.com/rkitover/net-ssh2/) repository, git://github.com/rkitover/net-ssh2.git If you are interested in making a change/fix, please discuss it first. If you are unfamiliar with XS (perl C bindings), you should review the perlxs, perlapi, and perlcall perldoc pages to learn more. The secure shell protocol is managed by the IETF secsh working group at http://www.ietf.org/html.charters/secsh-charter.html. The source code of libSSH2 will also be instructive. TODO More examples for the example/ directory would be nice. Add get/put (file) methods to Net::SSH2::SFTP (as a shortcut, rather than requiring open/read/write/close). COPYRIGHT AND LICENCE Copyright (C) 2005-2008 by David B. Robins. Copyright (C) 2010-2016 by Rafael Kitover (rkitover@cpan.org). Copyright (C) 2011-2018 by Salvador Fandino (salva@cpan.org). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. Net-SSH2-0.69/MANIFEST.SKIP0000644000175000017500000000035113033750102013600 0ustar salvasalva^\.svn/ ^\.git/ \.swp\z \.so\z \.exists\z \.o\z ^blib/ \.bs\z \.c\z \.old\z \.bak\z \.tar\.gz\z \~\z ^pm_to_blib\z ^Makefile\z ^\.travis.yml ^\.travis/ ^\.gitignore ^t/pod-spell.t ^MYMETA\. ^00.*\.patch\z gen_constants\.pl\z pods.t\z