Net-SSH2-0.58/0000755000175000017500000000000012635456667011733 5ustar salvasalvaNet-SSH2-0.58/MANIFEST.SKIP0000644000175000017500000000035612630775314013621 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 ^const-c\.inc\z ^const-xs\.inc\z ^\.travis.yml ^\.travis/ ^\.gitignore ^t/pod-spell.t ^MYMETA\. ^00.*\.patch\z Net-SSH2-0.58/Changes0000644000175000017500000002663612635456626013236 0ustar salvasalvaRevision history for Perl extension Net::SSH2. 0.58 2015-12-20 - rereleas 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.58/lib/0000755000175000017500000000000012635456667012501 5ustar salvasalvaNet-SSH2-0.58/lib/Net/0000755000175000017500000000000012635456667013227 5ustar salvasalvaNet-SSH2-0.58/lib/Net/SSH2/0000755000175000017500000000000012635456667013746 5ustar salvasalvaNet-SSH2-0.58/lib/Net/SSH2/File.pm0000644000175000017500000001011412602324501015127 0ustar salvasalvapackage Net::SSH2::File; use strict; use warnings; use Carp; # methods # tie interface sub PRINT { my $self = shift; my $sep = defined($,) ? $, : ''; $self->write(join $sep, @_) } sub PRINTF { my $self = shift; $self->write(sprintf @_) } sub WRITE { my ($self, $buf, $len, $offset) = @_; $self->write(substr($buf, $offset, $len)) } sub READLINE { my $self = shift; if (wantarray) { my @lines; my $line; push @lines, $line while defined($line = $self->READLINE); return @lines; } my ($line, $eol, $c) = ('', $/); $line .= $c while $line !~ /\Q$eol\E$/ and defined($c = $self->GETC); length($line) ? $line : undef } sub GETC { my $self = shift; my $buf; $self->read($buf, 1) ? $buf : undef } sub READ { my ($self, $rbuf, $len, $offset) = @_; my ($tmp, $count); return unless defined($count = $self->read($tmp, $len)); substr($$rbuf, $offset) = $tmp; $count } sub CLOSE { } sub BINMODE { } 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.58/lib/Net/SSH2/PublicKey.pm0000644000175000017500000000217012531574006016152 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 A public key object is created by the L C method. =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. =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.58/lib/Net/SSH2/SFTP.pm0000644000175000017500000000467512602324461015050 0ustar salvasalvapackage Net::SSH2::SFTP; use strict; use warnings; use Carp; # methods 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 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 Net::SSH2::File 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.58/lib/Net/SSH2/KnownHosts.pm0000644000175000017500000001442412635456504016414 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 $ok = eval { $kh->readfile($known_hosts_path); }; # a non-existent known_hosts file usually is not an error... unless (defined $ok) { 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_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: eval { $kh->add($hostname, '', $key, "Perl added me", $flags); $kh->writefile($known_hosts_path); } or 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. This method dies when some error happens. On success it returns the number or entries read. =head2 writefile (filename) Saves the known host entries to the given file. This method dies when some error happens. =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. This too base64 encoded. 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. This method dies when some error happens. =head2 check (hostname, port, key, key_type|host_format|key_format) Check 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. This method dies when some error happens. 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 dies 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 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.58/lib/Net/SSH2/Channel.pm0000644000175000017500000001350412635456504015645 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(@_) } # tie interface sub PRINT { my $self = shift; my $sep = defined($,) ? $, : ''; $self->write(join $sep, @_) } sub PRINTF { my $self = shift; $self->write(sprintf @_) } sub WRITE { my ($self, $buf, $len, $offset) = @_; $self->write(substr($buf, $offset, $len)) } sub READLINE { my $self = shift; return if $self->eof; if (wantarray) { my @lines; my $line; push @lines, $line while defined($line = $self->READLINE); return @lines; } my ($line, $eol, $c) = ('', $/); $line .= $c while $line !~ /\Q$eol\E$/ and defined($c = $self->GETC); length($line) ? $line : undef } sub GETC { my $self = shift; my $buf; my @poll = ({ handle => $self, events => 'in' }); return unless $self->session->poll(250, \@poll) and $poll[0]->{revents}->{in}; $self->read($buf, 1) ? $buf : undef } sub READ { my ($self, $rbuf, $len, $offset) = @_; my ($tmp, $count); return unless defined($count = $self->read($tmp, $len)); substr($$rbuf, $offset) = $tmp; $count } sub CLOSE { &close } sub BINMODE { } sub EOF { &eof } 1; __END__ =head1 NAME Net::SSH2::Channel - SSH 2 channel object =head1 DESCRIPTION A channel object is created by the L C method. As well as being an object, it is also a tied filehandle. The L C method can be used to check for read/write availability and other conditions. =head2 setenv ( key, value ... ) Sets remote environment variables. Note that most implementations do not allow environment variables to be freely set. Pass in a list of keys and values with the values to set. Returns the number of successful sets. =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 Send an EOF to the remote. After an EOF has been sent, no more data may be sent; the connection should be closed. =head2 close Close the channel (happens automatically on object destruction). =head2 wait_closed Wait for a remote close event. Must have already seen remote EOF. =head2 exit_status Returns the channel's program exit status. =head2 pty ( terminal [, modes [, width [, height ]]] ) Request a terminal on a channel. 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 process ( request, message ) Start a process on the channel. See also L, L, L. =head2 shell Start a shell on the remote host; calls L("shell"). =head2 exec ( command ) Execute the command on the remote host; calls L("exec", command). Note that only one of these requests can succeed per channel (cp. L); if you want to run a series of commands, consider using L instead. =head2 subsystem ( name ) Run subsystem on the remote host; calls L("subsystem", command). =head2 ext_data ( mode ) Set extended data handling mode: =over 4 =item normal (default) Keep data in separate channels; stderr is read separately. =item ignore Ignore all extended data. =item merge Merge into the regular channel. =back =head2 read ( buffer, size [, ext ] ) Attempts to read size bytes into the buffer. Returns number of bytes read, undef on failure. If ext is present and set, reads from the extended data channel (stderr). =head2 write ( buffer [, ext ] ) Attempts to write the buffer to the channel. Returns number of bytes written, undef on failure. If ext is present and set, writes to the extended data channel (stderr). In case the write operation would block and non-blocking mode is active then it returns LIBSSH2_ERROR_AGAIN without setting the global session error (yes, that's quite ugly, but it is how the underlying libssh2 works). =head2 flush ( [ ext ] ) Flushes the channel; if ext is present and set, flushes extended data channel. Returns number of bytes flushed, undef on error. =head2 exit_signal Returns the exit signal of the command executed on the channel. Requires libssh 1.2.8 or higher. =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 on the channel without blocking. In list context it also returns the size of the initial window. =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 undef. =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.58/lib/Net/SSH2/Listener.pm0000644000175000017500000000144412531574006016053 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.58/lib/Net/SSH2/Dir.pm0000644000175000017500000000146112531574006015003 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.58/lib/Net/SSH2.pm0000644000175000017500000010336312635456636014306 0ustar salvasalvapackage Net::SSH2; our $VERSION = '0.58'; use 5.006; use strict; use warnings; use Carp; require Exporter; use AutoLoader; use Socket; use IO::File; use File::Basename; use Errno; use base 'Exporter'; # constants my @EX_callback = qw( LIBSSH2_CALLBACK_DEBUG LIBSSH2_CALLBACK_DISCONNECT LIBSSH2_CALLBACK_IGNORE LIBSSH2_CALLBACK_MACERROR LIBSSH2_CALLBACK_X11 ); my @EX_channel = qw( LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL ); my @EX_socket = qw( LIBSSH2_SOCKET_BLOCK_INBOUND LIBSSH2_SOCKET_BLOCK_OUTBOUND ); my @EX_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 ); my @EX_error = qw( LIBSSH2_ERROR_ALLOC 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_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_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_ERROR_EAGAIN ); my @EX_hash = qw( LIBSSH2_HOSTKEY_HASH_MD5 LIBSSH2_HOSTKEY_HASH_SHA1 ); my @EX_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 ); my @EX_fxf = qw( LIBSSH2_FXF_APPEND LIBSSH2_FXF_CREAT LIBSSH2_FXF_EXCL LIBSSH2_FXF_READ LIBSSH2_FXF_TRUNC LIBSSH2_FXF_WRITE ); my @EX_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 ); my @EX_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 ); my @EX_disconnect = qw( SSH_DISCONNECT_AUTH_CANCELLED_BY_USER SSH_DISCONNECT_BY_APPLICATION SSH_DISCONNECT_COMPRESSION_ERROR SSH_DISCONNECT_CONNECTION_LOST SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT SSH_DISCONNECT_ILLEGAL_USER_NAME SSH_DISCONNECT_KEY_EXCHANGE_FAILED SSH_DISCONNECT_MAC_ERROR SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE SSH_DISCONNECT_PROTOCOL_ERROR SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED SSH_DISCONNECT_RESERVED SSH_DISCONNECT_SERVICE_NOT_AVAILABLE SSH_DISCONNECT_TOO_MANY_CONNECTIONS ); our %EXPORT_TAGS = ( all => [ @EX_callback, @EX_channel, @EX_error, @EX_socket, @EX_trace, @EX_hash, @EX_method, @EX_fx, @EX_fxf, @EX_sftp, @EX_disconnect, ], # ssh callback => \@EX_callback, channel => \@EX_channel, error => \@EX_error, socket => \@EX_socket, trace => \@EX_trace, hash => \@EX_hash, method => \@EX_method, disconnect => \@EX_disconnect, # sftp fx => \@EX_fx, fxf => \@EX_fxf, sftp => \@EX_sftp, ); our @EXPORT_OK = @{$EXPORT_TAGS{all}}; # 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 = shift; my %opts = @_; my $self = $class->_new; $self->trace($opts{trace}) if defined $opts{trace}; return $self; } sub connect { my $self = shift; croak "Net::SSH2::connect: not enough parameters" if @_ < 1; my $wantarray = wantarray; # try to connect, or get a file descriptor my ($fd, $sock); if (@_ == 1) { $sock = shift; if ($sock =~ /^\d{1,10}$/) { $fd = $sock; } elsif(ref $sock) { # handled below } else { @_ = ($sock, getservbyname(qw(ssh tcp)) || 22); } } my %opts = splice @_, 2 if @_ >= 4; $opts{Timeout} ||= 30; if (@_ == 2) { $sock = $socket_class->new( PeerHost => $_[0], PeerPort => $_[1], Timeout => $opts{Timeout}, ); if (not $sock) { if (not defined $wantarray) { croak "Net::SSH2: failed to connect to $_[0]:$_[1]: $!" } else { return; # to support ->connect ... or die } } $sock->sockopt(SO_LINGER, pack('SS', 0, 0)); } # get a file descriptor $fd ||= fileno($sock); croak "Net::SSH2::connect: can't get file descriptor for $sock" unless defined $fd; if ($^O eq 'MSWin32') { require Win32API::File; $fd = Win32API::File::FdGetOsFHandle($fd); } # enable compression when requested and if the underlying libssh2 # supports it $self->flag(COMPRESS => 1) if $opts{Compress} and ($self->version)[1] >= 0x010200; # pass it in, do protocol return $self->_startup($fd, $sock); } sub _auth_methods { return { 'agent' => { ssh => 'agent', 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; } my $password_when_you_mean_passphrase_warned; sub auth { my ($self, %p) = @_; my @rank = $self->_auth_rank(delete $p{rank}); # 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}; confess "unknown authentication method '$type'" unless $data; # 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; # 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 auth_password_interact { my ($self, $username, $cb) = @_; _load_term_readkey or return; local $| = 1; my $rc; for (0..2) { print "[user $username] password?\n"; Term::ReadKey::ReadMode('noecho'); my $password = Term::ReadKey::ReadLine(0); Term::ReadKey::ReadMode('normal'); chomp $password; $rc = $self->auth_password($username, $password, $cb); last if $rc or $self->error != LIBSSH2_ERROR_AUTHENTICATION_FAILED(); print "Password authentication failed!\n"; } return $rc; } 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; local $| = 1; my $prompt = "[user $user] "; $prompt .= "$name\n" if $name; $prompt .= "$instr\n" if $instr; $prompt =~ s/ $/\n/; print $prompt; my @out; for my $prompt(@prompt) { print STDERR "$prompt->{text}"; Term::ReadKey::ReadMode('noecho') unless $prompt->{echo}; chomp(my $value = Term::ReadKey::ReadLine(0)); Term::ReadKey::ReadMode('normal') unless $prompt->{echo}; push @out, $value; } @out } my $hostkey_warned; sub hostkey { $hostkey_warned++ or carp "Net::SSH2 'hostkey' method is obsolete, use 'hostkey_hash' instead"; shift->hostkey_hash(@_); } # 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 die $!; if ($ssh2->auth_keyboard('fizban')) { my $chan = $ssh2->channel(); $chan->exec('program'); my $sftp = $ssh2->sftp(); my $fh = $sftp->open('/etc/passwd') or die; print $_ while <$fh>; } =head1 DESCRIPTION C 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. Unless otherwise indicated, methods return a true value on success and false on failure; use the error method to get extended error information. The typical order is to create the SSH2 object, set up the connection methods you want to use, call connect, authenticate with one of the C methods, then create channels on the connection to perform commands. =head1 EXPORTS Exports the following constant tags: =over 4 =item all All constants. =back ssh constants: =over 4 =item callback =item channel =item error =item socket =item trace Tracing constants for use with C<< ->trace >> and C<< ->new(trace => ...) >>. =item hash Key hash constants. =item method =item disconnect Disconnect type constants. =back SFTP constants: =over 4 =item fx =item fxf =item sftp =back =head1 METHODS =head2 new Create new SSH2 object. To turn on tracing with a debug build of libssh2 use: my $ssh2 = Net::SSH2->new(trace => -1); =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; returns false if no error. 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 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 libssh2_trace with supplied bitmask, to enable all tracing use: $ssh2->trace(-1); You need a debug build of libssh2 with tracing support. =head2 timeout ( timeout_ms ) Enables a global timeout (in milliseconds) which will affect every action. libssh2 version 1.2.9 or higher is required to use this method. =head2 method ( type [, values... ] ) Sets or returns 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 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 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 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 CRYPT_SC Encryption algorithm from server to client. See L for supported algorithms. =item 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 MAC_SC Message Authentication Code (MAC) algorithms from server to client. See L for supported algorithms. =item 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 COMP_SC Compression methods from server to client. See L for supported compression methods. =back =head2 connect ( handle | host [, port [, Timeout => secs ] [, Compress => 1]] ) Accepts a handle over which to conduct the SSH 2 protocol. The handle may be: =over 4 =item an C object =item a glob reference =item an integer file descriptor =item a host name and port In order to handle IPv6 addresses the optional module L needs to be installed (otherwise the module will use the IPv4 only core module L to establish the connection). =back =head2 disconnect ( [description [, reason [, language]]] ) Send a clean disconnect message to the remote server. Default values are empty strings for description and language, and C for the reason. =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: =over 4 =item MD5 (16 bytes) =item SHA1 (20 bytes) =back Note: in previous versions of the module this method was called C. =head2 remote_hostkey Returns the public key of the remote host and its type which is one of C, C, or C. =head2 auth_list ( [username] ) Get a list (or comma-separated string in scalar context) of authentication methods supported by the server; or returns C. If C is returned and L is true, the server accepted an unauthenticated session for the given username. =head2 auth_ok Returns true iff the session is authenticated. =head2 auth_password ( username [, password [, callback ]] ) Authenticate using a password (C must be enabled in C or equivalent for this to work.) 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 using Term::ReadKey. =head2 auth_publickey ( username, publickey_path, privatekey_path [, passphrase ] ) Note that public key and private key are names of files containing the keys! Authenticate using keys 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 (OpenSSH 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. This method requires libssh2 1.6.0 or later compiled 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 "keyboard-interactive". 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; L is required. =head2 auth_agent ( username ) Try to authenticate using ssh-agent. This requires libssh2 version 1.2.3 or later. =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 a false value if they all failed. If a parameter is passed with an undef 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. 'keyboard' or 'publickey', with the addition of 'keyboard-auto' for automated 'keyboard-interactive' and 'password-interact' that prompts the user for the password interactively. =item username =item password =item publickey =item privatekey =item passphrase As in the methods, publickey and privatekey are filenames. =item hostname =item local_username =item interact If this is set to a true value, interactive methods will be considered. =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 COMPRESS If set before the connection negotiation is performed, compression will be negotiated for this connection. Compression can also be enabled passing the C option L. =item 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. =head2 channel ( [type, [window size, [packet size]]] ) Creates and returns a new channel object. The default type is "session". See L. =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 [, local ] ) Retrieve a file with scp; local path defaults to basename of remote. C may be an IO object (e.g. IO::File, IO::Scalar). =head2 scp_put ( local [, remote ] ) Send a file with scp; remote path defaults to same as local. C may be an IO object instead of a filename (but it must have a valid stat method). =head2 sftp Return SecureFTP interface object (see L). =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 ) 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 when a function returns LIBSSH2_ERROR_EAGAIN, returns LIBSSH2_SOCKET_BLOCK_INBOUND or LIBSSH2_SOCKET_BLOCK_OUTBOUND from the socket export group. =head2 debug ( state ) Class method (affects all Net::SSH2 objects). Pass 1 to enable, 0 to disable. Debug output is sent to stderr via C. =head2 blocking ( flag ) Enable or disable blocking. Note that if blocking is disabled, methods that create channels may fail, e.g. C, C, C. =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 - 2015 by Rafael Kitover (rkitover@cpan.org). Copyright (C) 2011 - 2015 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.58/MANIFEST0000644000175000017500000000126412630775314013053 0ustar salvasalvaBUILDING.WIN32 Changes example/read.pl example/rt58911.pl example/rt80011.pl fallback/const-c.inc fallback/const-xs.inc 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/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 TODO typemap Net-SSH2-0.58/inc/0000755000175000017500000000000012635456667012504 5ustar salvasalvaNet-SSH2-0.58/inc/Module/0000755000175000017500000000000012635456667013731 5ustar salvasalvaNet-SSH2-0.58/inc/Module/Install.pm0000644000175000017500000003021712635456645015674 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.16'; # 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}; $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( 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($subpath . '.pm'); 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; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; 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; } END_NEW 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; } END_OLD 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; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; 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]): $!"; } END_NEW 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]): $!"; } END_OLD # _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.58/inc/Module/Install/0000755000175000017500000000000012635456667015337 5ustar salvasalvaNet-SSH2-0.58/inc/Module/Install/Makefile.pm0000644000175000017500000002743712635456645017423 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.16'; @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.58/inc/Module/Install/Can.pm0000644000175000017500000000615712635456646016404 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.16'; @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; 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 236 Net-SSH2-0.58/inc/Module/Install/Win32.pm0000644000175000017500000000340312635456646016574 0ustar salvasalva#line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @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.58/inc/Module/Install/Fetch.pm0000644000175000017500000000462712635456646016734 0ustar salvasalva#line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @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.58/inc/Module/Install/WriteAll.pm0000644000175000017500000000237612635456646017425 0ustar salvasalva#line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @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.58/inc/Module/Install/CheckLib.pm0000644000175000017500000000244212635456645017337 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.08'; sub checklibs { my $self = shift; my @parms = @_; return unless scalar @parms; unless ( $Module::Install::AUTHOR ) { require Devel::CheckLib; Devel::CheckLib::check_lib_or_exit( @parms ); return; } _author_side(); } sub assertlibs { my $self = shift; my @parms = @_; return unless scalar @parms; unless ( $Module::Install::AUTHOR ) { require Devel::CheckLib; Devel::CheckLib::assert_lib( @parms ); return; } _author_side(); } sub _author_side { 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 1; } 'All your libs are belong'; __END__ #line 126 Net-SSH2-0.58/inc/Module/Install/Metadata.pm0000644000175000017500000004330212635456645017413 0ustar salvasalva#line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.16'; @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.58/inc/Module/Install/Base.pm0000644000175000017500000000214712635456645016547 0ustar salvasalva#line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.16'; } # 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.58/inc/Devel/0000755000175000017500000000000012635456667013543 5ustar salvasalvaNet-SSH2-0.58/inc/Devel/CheckLib.pm0000644000175000017500000003576112635456645015555 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.03'; 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(void) { 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. =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; } 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}; # 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(); my @missing; my @wrongresult; 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 ); } 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 $ofile if -e $ofile; 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(void) { ".($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, (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); push @missing, $lib if $rv != 0 || ! -x $exefile; my $absexefile = File::Spec->rel2abs($exefile); $absexefile = '"'.$absexefile.'"' if $absexefile =~ m/\s/; push @wrongresult, $lib if $rv == 0 && -x $exefile && system($absexefile) != 0; unlink $ofile if -e $ofile; _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; } sub _cleanup_exe { my ($exefile) = @_; my $ofile = $exefile; $ofile =~ s/$Config{_exe}$/$Config{_o}/; unlink $exefile if -f $exefile; unlink $ofile if -f $ofile; unlink "$exefile\.manifest" if -f "$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/; unlink $ilkfile if -f $ilkfile; unlink $pdbfile if -f $pdbfile; } 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 { # 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||''); my @ldflags = grep { length } quotewords('\s+', 1, @Config_ldflags); my @paths = split(/$Config{path_sep}/, $ENV{PATH}); my @cc = split(/\s+/, $Config{cc}); return ( [ @cc, @ccflags ], \@ldflags ) if -x $cc[0]; foreach my $path (@paths) { my $compiler = File::Spec->catfile($path, $cc[0]) . ($^O eq 'cygwin' ? '' : $Config{_exe}); return ([ $compiler, @cc[1 .. $#cc], @ccflags ], \@ldflags) if -x $compiler; next if ! length $Config{_exe}; $compiler = File::Spec->catfile($path, $cc[0]); return ([ $compiler, @cc[1 .. $#cc], @ccflags ], \@ldflags) if -x $compiler; } die("Couldn't find your C compiler\n"); } # 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.58/typemap0000644000175000017500000000741012635456504013325 0ustar salvasalvaTYPEMAP char * T_PV unsigned char * T_PV const char * T_PV AV * T_AVREF 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 OUTPUT T_PV sv_setpv((SV*)$arg, $var); T_AVREF $arg = newRV((SV*)$var); O_SESSION sv_setref_pv($arg, "Net::SSH2", (void *)$var); O_CHANNEL { GV* gv = (GV*)newSVrv($arg, "Net::SSH2::Channel"); IO* io = (IO*)newSV(0); const char* name = form("_GEN_%ld", (long)net_ch_gensym++); SvUPGRADE((SV*)gv, SVt_PVGV); SvUPGRADE((SV*)io, SVt_PVIO); gv_init(gv, gv_stashpv("Net::SSH2::Channel", 0/*create*/), name, strlen(name), 0/*multi*/); GvSV(gv) = newSViv(PTR2IV($var)); 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); } } O_LISTENER sv_setref_pv($arg, "Net::SSH2::Listener", (void *)$var); O_SFTP sv_setref_pv($arg, "Net::SSH2::SFTP", (void *)$var); O_FILE { GV* gv = (GV*)newSVrv($arg, "Net::SSH2::File"); IO* io = (IO*)newSV(0); const char* name = form("_GEN_%ld", (long)net_fi_gensym++); SvUPGRADE((SV*)gv, SVt_PVGV); SvUPGRADE((SV*)io, SVt_PVIO); gv_init(gv, gv_stashpv("Net::SSH2::File", 0/*create*/), name, strlen(name), 0/*multi*/); GvSV(gv) = newSViv(PTR2IV($var)); 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); } } 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 if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid session object\"); O_CHANNEL if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVGV)) $var = ($type)SvIVX(GvSV((GV*)SvRV($arg))); else croak(\"${Package}::$func_name() - invalid channel object\"); O_LISTENER if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid listener object\"); O_SFTP if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid SFTP object\"); O_FILE if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVGV)) $var = ($type)SvIVX(GvSV((GV*)SvRV($arg))); else croak(\"${Package}::$func_name() - invalid SFTP file object\"); O_DIR if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid SFTP directory object\"); O_PUBLICKEY if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid public key object\"); O_KNOWNHOSTS if(sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = ($type)SvIV((SV*)SvRV($arg)); else croak(\"${Package}::$func_name() - invalid knownhost object\"); Net-SSH2-0.58/example/0000755000175000017500000000000012635456667013366 5ustar salvasalvaNet-SSH2-0.58/example/read.pl0000644000175000017500000000202012531574006014607 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; die "can't connect" unless $ssh2->connect('localhost'); # use an interactive authentication method with default callback # (if a password is provided here, it will forward it without prompting) die "can't authenticate" unless $ssh2->auth(username => scalar getpwuid($<), interact => 1); 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 die; _read($file); # (c) type it over a channel my $chan = $ssh2->channel; $chan->exec('cat /etc/passwd') or die; _read($chan); Net-SSH2-0.58/example/rt80011.pl0000644000175000017500000000145312602324504014717 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.58/example/rt58911.pl0000644000175000017500000000140412602317663014741 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.58/SSH2.xs0000644000175000017500000021607312635456504013025 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" #include #include #include #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" }; /* 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 XLATEXT (SvTRUE(ext) ? SSH_EXTENDED_DATA_STDERR : 0) #define XLATATTR(name, field, flag) \ else if (strEQ(key, name)) { \ attrs.field = SvUV(ST(i + 1)); \ attrs.flags |= LIBSSH2_SFTP_ATTR_##flag; \ } /* Net::SSH2 object */ typedef struct SSH2 { LIBSSH2_SESSION* session; SV* sv_ss; /* NB: not set until callback() called */ SV* socket; SV* sv_tmp; int errcode; SV* errmsg; 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 net_ch_gensym = 0; static unsigned long net_fi_gensym = 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); } /* set Net:SSH2-specific error message */ static void set_error(SSH2* ss, int errcode, const char* errmsg) { ss->errcode = errcode; if (ss->errmsg) SvREFCNT_dec(ss->errmsg); ss->errmsg = errmsg ? newSVpv(errmsg, 0) : NULL; } /* clear our local error flag */ static void clear_error(SSH2* ss) { set_error(ss, LIBSSH2_ERROR_NONE, NULL/*errmsg*/); } /* split a string at commas and push each substring onto the perl stack */ static int split_comma(SV** sp, const char* str) { int i; const char* p; if (!str || !*str) return 0; i = 1; while ((p = strchr(str, ','))) { mXPUSHp(str, p - str); str = p + 1; ++i; } mXPUSHp(str, strlen(str)); return i; } /* 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; } /* return NULL if undef or NULL, else return string */ static const char* default_string(SV* sv) { return (sv && SvPOK(sv)) ? SvPV_nolen(sv) : NULL; } /* return an integer constant from an SV name or value */ static int iv_constant_sv(const char *prefix, SV* c_sv, IV* piv) { int ret = 1; /* accept type as constant, constant without prefix, or numeric value */ if (SvIOK(c_sv)) { *piv = SvIV(c_sv); } else { SV *sv = newSVsv(c_sv); char* str = SvPV_nolen(sv), * p; const char* pv; STRLEN len = strlen(prefix); for (p = str; *p; ++p) *p = toUPPER(*p); if (strncmp(str, prefix, len)) sv_insert(sv, 0/*offset*/, 0/*replace*/, (char*)prefix, len); pv = SvPV(sv, len); if (constant(aTHX_ pv, len, piv) != PERL_constant_ISIV) ret = 0; SvREFCNT_dec(sv); } return ret; } /* 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 = SvPV(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(); 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 = SvPV(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 = SvPV(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; ierrcode != LIBSSH2_ERROR_NONE) && (ss->errmsg != NULL)) errmsg = SvPV_nolen(ss->errmsg); else { if (libssh2_session_last_error(ss->session, &errmsg, NULL, 0) == LIBSSH2_ERROR_NONE) croak("Internal error: croak_last_error called but there was no error!"); } croak("%s::%s: %s", klass, method, errmsg); } #define CROAK_LAST_ERROR(session, method) (croak_last_error((session), class, (method))) /* 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); 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; } clear_error(RETVAL); debug("Net::SSH2: created new object 0x%x\n", RETVAL); OUTPUT: RETVAL void net_ss_trace(SSH2* ss, SV* bitmask) CODE: libssh2_trace(ss->session, SvIV(bitmask)); #if LIBSSH2_VERSION_MAJOR >= 1 SV* net_ss_block_directions(SSH2* ss) CODE: RETVAL = newSViv((IV)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 void net_ss_timeout(SSH2* ss, long timeout) CODE: libssh2_session_set_timeout(ss->session, timeout); #else void net_ss_timeout(SSH2* ss, long timeout) CODE: croak("libssh2 version 1.2.9 or higher required for set_timeout support"); #endif void net_ss_blocking(SSH2* ss, SV* blocking) CODE: clear_error(ss); libssh2_session_set_blocking(ss->session, SvTRUE(blocking)); XSRETURN_IV(1); void net_ss_DESTROY(SSH2* ss) CODE: debug("%s::DESTROY object 0x%x\n", class, ss); clear_error(ss); libssh2_session_free(ss->session); SvREFCNT_dec(ss->socket); Safefree(ss); void net_ss_debug(SV*, SV* debug) CODE: net_ss_debug_out = SvIV(debug) & 1; /* allow for future flags */ void net_ss_version(SV* name = NULL) CODE: switch (GIMME_V) { case G_SCALAR: XSRETURN_PV(LIBSSH2_VERSION); case G_ARRAY: EXTEND(SP, 3); ST(0) = sv_2mortal(newSVpv(LIBSSH2_VERSION, 0)); #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); } void net_ss_banner(SSH2* ss, SV* banner) PREINIT: int success; SV* sv_banner; CODE: clear_error(ss); sv_banner = newSVsv(banner); sv_insert(sv_banner, 0/*offset*/, 0/*len*/, "SSH-2.0-", 8); success = !libssh2_banner_set(ss->session, SvPV_nolen(sv_banner)); SvREFCNT_dec(sv_banner); XSRETURN_IV(success); void net_ss_error(SSH2* ss, ...) PREINIT: SV* errmsg; int errcode; CODE: if (items == 3) { set_error(ss, SvIV(ST(1)), SvPV_nolen(ST(2))); XSRETURN_EMPTY; } else if(items != 1) croak("%s::error: too many arguments", class); /* if we have a local error, take it, else use libSSH2's value */ if (ss->errcode != LIBSSH2_ERROR_NONE && ss->errmsg != NULL) { errcode = ss->errcode; errmsg = SvREFCNT_inc(ss->errmsg); } else { char* errstr; int errlen; errcode = libssh2_session_last_error( ss->session, &errstr, &errlen, 0/*want_buf*/); errmsg = errstr ? newSVpvn(errstr, errlen) : NULL; } if (errcode == LIBSSH2_ERROR_NONE && errmsg == NULL) XSRETURN_EMPTY; switch (GIMME_V) { case G_SCALAR: XSRETURN_IV(errcode); case G_ARRAY: { SV* code; EXTEND(SP, 3); ST(0) = sv_2mortal(newSViv(errcode)); if (errcode < 0) { code = (-errcode < countof(xs_libssh2_error)) ? newSVpvf("LIBSSH2_ERROR_%s", xs_libssh2_error[-errcode]) : newSVpvf("LIBSSH2_ERROR_UNKNOWN(%d)", errcode); } else if(errcode > 0) code = newSVpv(Strerror(errcode), 0); else code = newSVpvn("", 0); /* possibly set via set_error */ ST(1) = sv_2mortal(code); ST(2) = sv_2mortal(errmsg); XSRETURN(3); } } void net_ss_method(SSH2* ss, SV* method_type, ...) PREINIT: IV type; int i; SV* prefs; STRLEN len; PPCODE: clear_error(ss); if (!iv_constant_sv("LIBSSH2_METHOD_", method_type, &type)) croak("%s::method: unknown method type: %s", class, SvPV_nolen(method_type)); /* 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); } /* accept prefs as a string or multiple strings, joining with "," */ prefs = newSVpvn("", 0); for (i = 2; i < items; ++i) { const char* pv_pref; if (i > 2) sv_catpvn(prefs, ",", 1); pv_pref = SvPV(ST(i), len); sv_catpvn(prefs, pv_pref, len); } /* call and clean up */ i = libssh2_session_method_pref(ss->session, (int)type, SvPV_nolen(prefs)); SvREFCNT_dec(prefs); XSRETURN_IV(!i); #if LIBSSH2_VERSION_NUM >= 0x010200 void net_ss_flag(SSH2* ss, SV* flag, int value) PREINIT: IV flag_iv; int success; PPCODE: clear_error(ss); if (!iv_constant_sv("LIBSSH2_FLAG_", flag, &flag_iv)) croak("%s::method: unknown flag: %s", class, SvPV_nolen(flag)); success = libssh2_session_flag(ss->session, (int)flag_iv, value); XSRETURN_IV(!success); #else void net_ss_flag(SSH2* ss, SV* flag, int value) CODE: croak("libssh2 version 1.2 or higher required for flag support"); #endif void net_ss_callback(SSH2* ss, SV* type, SV* callback = NULL) PREINIT: IV i_type; CODE: clear_error(ss); 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 (!iv_constant_sv("LIBSSH2_CALLBACK_", type, &i_type)) croak("%s::callback: invalid callback type: %s", class, SvPV_nolen(callback)); if (i_type < 0 || i_type >= countof(msg_cb)) croak("%s::callback: don't know how to handle: %s", class, SvPV_nolen(callback)); ss->sv_ss = SvRV(ST(0)); /* don't keep a reference, just store it */ SvREFCNT_dec(ss->rgsv_cb[i_type]); libssh2_session_callback_set(ss->session, i_type, callback ? cb_as_void_ptr(msg_cb[i_type]) : NULL); SvREFCNT_inc(callback); ss->rgsv_cb[i_type] = callback; XSRETURN_IV(1); void net_ss__startup(SSH2* ss, int socket, SV *store) PREINIT: int success; CODE: clear_error(ss); success = !libssh2_session_startup(ss->session, socket); if (success && store) { ss->socket = SvREFCNT_inc(SvRV(store)); } XSRETURN_IV(success); SV * net_ss_sock(SSH2* ss) CODE: if (ss->socket) { RETVAL = newRV_inc((SV *)ss->socket); } else { RETVAL = &PL_sv_undef; } OUTPUT: RETVAL void net_ss_disconnect(SSH2* ss, const char* description = "", \ int reason = SSH_DISCONNECT_BY_APPLICATION, const char *lang = "") CODE: clear_error(ss); XSRETURN_IV(!libssh2_session_disconnect_ex( ss->session, reason, description, lang)); void net_ss_hostkey_hash(SSH2* ss, SV* hash_type) PREINIT: IV type; const char* hash; static STRLEN rglen[] = { 16/*MD5*/, 20/*SHA1*/ }; PPCODE: clear_error(ss); if (!iv_constant_sv("LIBSSH2_HOSTKEY_HASH_", hash_type, &type) || type < 1 || type > countof(rglen)) { croak("%s::hostkey: unknown hostkey hash: %s", class, SvPV_nolen(hash_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; void net_ss_auth_list(SSH2* ss, SV* username = NULL) PREINIT: const char* pv_username = NULL; char* auth; STRLEN len_username = 0; int count = 1; PPCODE: clear_error(ss); if (username && SvPOK(username)) pv_username = SvPV(username, len_username); auth = libssh2_userauth_list(ss->session, pv_username, len_username); if (!auth) XSRETURN_EMPTY; if (GIMME_V == G_ARRAY) count = split_comma(sp, auth); else PUSHs(sv_2mortal(newSVpv(auth, 0))); /* Safefree(auth); this causes a double-free segfault */ XSRETURN(count); void net_ss_auth_ok(SSH2* ss) CODE: clear_error(ss); XSRETURN_IV(libssh2_userauth_authenticated(ss->session)); SV * 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: clear_error(ss); pv_username = SvPV(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 */ ok = ((libssh2_userauth_list(ss->session, pv_username, len_username) == NULL) && libssh2_userauth_authenticated(ss->session)); } 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 = SvPV(password, len_password); ok = (libssh2_userauth_password_ex(ss->session, pv_username, len_username, pv_password, len_password, (SvOK(callback) ? cb_password_change_callback : NULL)) >= 0); } RETVAL = (ok ? &PL_sv_yes : &PL_sv_no); OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010203 SV * net_ss_auth_agent(SSH2* ss, const char* username) PREINIT: LIBSSH2_AGENT *agent; int old_blocking; CODE: RETVAL = &PL_sv_no; clear_error(ss); /* 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 void net_ss_auth_publickey(SSH2* ss, SV* username, SV* publickey, \ const char* privatekey, SV* passphrase = NULL) PREINIT: const char* pv_username; STRLEN len_username; CODE: clear_error(ss); pv_username = SvPV(username, len_username); XSRETURN_IV(!libssh2_userauth_publickey_fromfile_ex(ss->session, pv_username, len_username, default_string(publickey), privatekey, default_string(passphrase))); #if LIBSSH2_VERSION_NUM >= 0x010600 void net_ss_auth_publickey_frommemory(SSH2* ss, SV* username, SV* publickey, \ SV* privatekey, SV* passphrase = NULL) PREINIT: const char *pv_username, *pv_publickey, *pv_privatekey; STRLEN len_username, len_publickey, len_privatekey; CODE: clear_error(ss); pv_username = SvPV(username, len_username); pv_publickey = SvPV(publickey, len_publickey); pv_privatekey = SvPV(privatekey, len_privatekey); XSRETURN_IV(!libssh2_userauth_publickey_frommemory(ss->session, pv_username, len_username, pv_publickey, len_publickey, pv_privatekey, len_privatekey, default_string(passphrase))); #endif void net_ss_auth_hostbased(SSH2* ss, SV* username, const char* publickey, \ const char* privatekey, SV* hostname, SV* local_username = NULL, \ SV* passphrase = NULL) PREINIT: const char* pv_username, * pv_hostname, * pv_local_username; STRLEN len_username, len_hostname, len_local_username; CODE: clear_error(ss); pv_username = SvPV(username, len_username); pv_hostname = SvPV(hostname, len_hostname); if (!local_username || !SvPOK(local_username)) { pv_local_username = pv_username; len_local_username = len_username; } else pv_local_username = SvPV(local_username, len_local_username); XSRETURN_IV(!libssh2_userauth_hostbased_fromfile_ex(ss->session, pv_username, len_username, publickey, privatekey, default_string(passphrase), pv_hostname, len_hostname, pv_local_username, len_local_username)); SV * net_ss_auth_keyboard(SSH2* ss, SV* username, SV* password = NULL) PREINIT: const char* pv_username; STRLEN len_username; int rc; AV *cb_args; CODE: clear_error(ss); pv_username = SvPV(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)) rc = libssh2_userauth_keyboard_interactive_ex(ss->session, pv_username, len_username, cb_kbdint_response_callback); else rc = libssh2_userauth_keyboard_interactive_ex(ss->session, pv_username, len_username, cb_kbdint_response_password); RETVAL = (rc < 0 ? &PL_sv_no : &PL_sv_yes); 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); void net_ss_keepalive_send(SSH2 *ss) PREINIT: int success; int seconds_to_next; PPCODE: success = libssh2_keepalive_send(ss->session, &seconds_to_next); if (success == LIBSSH2_ERROR_NONE) XSRETURN_IV(seconds_to_next); else XSRETURN_EMPTY; #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, SV* channel_type = NULL, \ int window_size = LIBSSH2_CHANNEL_WINDOW_DEFAULT, \ int packet_size = LIBSSH2_CHANNEL_PACKET_DEFAULT) PREINIT: const char* pv_channel_type; STRLEN len_channel_type; CODE: clear_error(ss); if (channel_type) pv_channel_type = SvPV(channel_type, len_channel_type); else { pv_channel_type = "session"; len_channel_type = 7; } NEW_CHANNEL(libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_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, const char* path, HV* stat = NULL) PREINIT: libssh2_struct_stat st; CODE: clear_error(ss); NEW_CHANNEL(libssh2_scp_recv2(ss->session, path, &st)); if (stat) { hv_clear(stat); 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, newSViv((time_t)st.st_mtime), 0/*hash*/); } OUTPUT: RETVAL #else SSH2_CHANNEL* net_ss__scp_get(SSH2* ss, const char* path, HV* stat = NULL) PREINIT: struct stat st; CODE: clear_error(ss); NEW_CHANNEL(libssh2_scp_recv(ss->session, path, &st)); if (stat) { hv_clear(stat); 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, newSViv((time_t)st.st_mtime), 0/*hash*/); } OUTPUT: RETVAL #endif SSH2_CHANNEL* net_ss__scp_put(SSH2* ss, const char* path, int mode, size_t size, \ long mtime = 0, long atime = 0) CODE: clear_error(ss); NEW_CHANNEL(libssh2_scp_send_ex(ss->session, path, mode, size, mtime, atime)); OUTPUT: RETVAL SSH2_CHANNEL* net_ss_tcpip(SSH2* ss, const char* host, int port, \ const char* shost = NULL, int sport = 0) CODE: if (!shost) shost = "127.0.0.1"; if (!sport) sport = 22; 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: clear_error(ss); 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) { set_error(ss, 0, "out of memory allocating pollfd structures"); XSRETURN_EMPTY; } 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, SvPV_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: clear_error(ss); NEW_SFTP(libssh2_sftp_init(ss->session)); OUTPUT: RETVAL SSH2_PUBLICKEY* net_ss_public_key(SSH2* ss) CODE: clear_error(ss); 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); clear_error(ch->ss); libssh2_channel_free(ch->channel); SvREFCNT_dec(ch->sv_ss); Safefree(ch); void net_ch_session(SSH2_CHANNEL* ch) CODE: ST(0) = sv_2mortal(newRV_inc(ch->sv_ss)); XSRETURN(1); void net_ch_setenv(SSH2_CHANNEL* ch, ...) PREINIT: int i, success = 0; const char* pv_key, * pv_value; STRLEN len_key, len_value; CODE: clear_error(ch->ss); for (i = 1; i < items; i += 2) { if (i + 1 == items) croak("%s::setenv: key without value", class); pv_key = SvPV(ST(i), len_key); pv_value = SvPV(ST(i + 1), len_value); success += !libssh2_channel_setenv_ex(ch->channel, (char*)pv_key, len_key, (char*)pv_value, len_value); } XSRETURN_IV(success); #if LIBSSH2_VERSION_NUM >= 0x010208 SV* net_ch_exit_signal(SSH2_CHANNEL* ch) PREINIT: char *exitsignal = NULL; CODE: clear_error(ch->ss); RETVAL; libssh2_channel_get_exit_signal(ch->channel, &exitsignal, NULL, NULL, NULL, NULL, NULL); if (exitsignal) { RETVAL = newSVpv(exitsignal, 0); libssh2_free(ch->ss->session, exitsignal); } else RETVAL = &PL_sv_undef; OUTPUT: RETVAL #else void net_ch_exit_signal(SSH2_CHANNEL* ch) CODE: croak("libssh2 version 1.2.8 or higher required for exit_signal support"); #endif void net_ch_blocking(SSH2_CHANNEL* ch, SV* blocking) CODE: clear_error(ch->ss); libssh2_channel_set_blocking(ch->channel, SvTRUE(blocking)); XSRETURN_IV(1); void net_ch_eof(SSH2_CHANNEL* ch) CODE: clear_error(ch->ss); XSRETURN_IV(libssh2_channel_eof(ch->channel)); void net_ch_send_eof(SSH2_CHANNEL* ch) CODE: clear_error(ch->ss); XSRETURN_IV(!libssh2_channel_send_eof(ch->channel)); void net_ch_close(SSH2_CHANNEL* ch) CODE: clear_error(ch->ss); XSRETURN_IV(!libssh2_channel_close(ch->channel)); void net_ch_wait_closed(SSH2_CHANNEL* ch) CODE: clear_error(ch->ss); XSRETURN_IV(!libssh2_channel_wait_closed(ch->channel)); void net_ch_exit_status(SSH2_CHANNEL* ch) CODE: clear_error(ch->ss); XSRETURN_IV(libssh2_channel_get_exit_status(ch->channel)); #if LIBSSH2_VERSION_MAJOR >= 1 void 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 = SvPV(terminal, len_terminal); if (modes && SvPOK(modes)) pv_modes = SvPV(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; } XSRETURN_IV(!libssh2_channel_request_pty_ex(ch->channel, (char*)pv_terminal, len_terminal, (char*)pv_modes, len_modes, width, height, width_px, height_px)); void 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; } XSRETURN_IV(!libssh2_channel_request_pty_size_ex(ch->channel, width, height, width_px, height_px)); #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 void 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 = SvPV(request, len_request); if (message && SvPOK(message)) pv_message = SvPV(message, len_message); XSRETURN_IV(!libssh2_channel_process_startup(ch->channel, pv_request, len_request, pv_message, len_message)); void net_ch_ext_data(SSH2_CHANNEL* ch, SV* mode) PREINIT: IV i_mode; CODE: if (!iv_constant_sv("LIBSSH2_CHANNEL_EXTENDED_DATA_", mode, &i_mode)) croak("%s::ext_data: unknown extended data mode: %s", class, SvPV_nolen(mode)); libssh2_channel_handle_extended_data(ch->channel, i_mode); XSRETURN_IV(1); void net_ch_read(SSH2_CHANNEL* ch, SV* buffer, size_t size, SV *ext = &PL_sv_undef) PREINIT: char* pv_buffer; int count, total = 0; CODE: debug("%s::read(size = %d, ext = %d)\n", class, size, SvTRUE(ext)); clear_error(ch->ss); SvPOK_on(buffer); pv_buffer = sv_grow(buffer, size + 1/*NUL*/); /* force PV */ again: count = libssh2_channel_read_ex(ch->channel, XLATEXT, pv_buffer, size); debug("- read %d bytes\n", count); if (count < 0) { if (!total) { SvCUR_set(buffer, 0); XSRETURN_EMPTY; } count = 0; } total += count; if (count > 0 && (unsigned)count < size && libssh2_session_get_blocking(ch->ss->session)) { pv_buffer += count; size -= count; goto again; } pv_buffer[count] = '\0'; SvCUR_set(buffer, total); debug("- read %d total\n", total); XSRETURN_IV(total); SV * net_ch_write(SSH2_CHANNEL* ch, SV* buffer, SV *ext = &PL_sv_undef) 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. */ clear_error(ch->ss); pv_buffer = SvPV(buffer, len_buffer); while (offset < len_buffer) { count = libssh2_channel_write_ex(ch->channel, XLATEXT, 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 = newSVuv(offset); else if (count == LIBSSH2_ERROR_EAGAIN) RETVAL = newSViv(LIBSSH2_ERROR_EAGAIN); else RETVAL = &PL_sv_undef; OUTPUT: RETVAL #if LIBSSH2_VERSION_NUM >= 0x010100 void net_ch_receive_window_adjust(SSH2_CHANNEL *ch, unsigned long adjustment, SV *force = &PL_sv_undef) PREINIT: unsigned int new_size; PPCODE: if (libssh2_channel_receive_window_adjust2(ch->channel, adjustment, SvTRUE(force), &new_size) == LIBSSH2_ERROR_NONE) { XPUSHs(sv_2mortal(newSVuv(new_size))); XSRETURN(1); } else XSRETURN_EMPTY; #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 void net_ch_flush(SSH2_CHANNEL* ch, SV *ext = &PL_sv_undef) PREINIT: int count; CODE: clear_error(ch->ss); count = libssh2_channel_flush_ex(ch->channel, XLATEXT); if (count < 0) XSRETURN_EMPTY; XSRETURN_IV(count); #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); clear_error(ls->ss); 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: clear_error(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); clear_error(sf->ss); libssh2_sftp_shutdown(sf->sftp); debug("%s::DESTROY freeing session\n", class); SvREFCNT_dec(sf->sv_ss); Safefree(sf); void net_sf_session(SSH2_SFTP* sf) CODE: ST(0) = sv_2mortal(newRV_inc(sf->sv_ss)); XSRETURN(1); void net_sf_error(SSH2_SFTP* sf) PREINIT: unsigned long error; CODE: error = libssh2_sftp_last_error(sf->sftp); switch (GIMME_V) { case G_SCALAR: XSRETURN_UV(error); case G_ARRAY: EXTEND(SP, 2); ST(0) = sv_2mortal(newSVuv(error)); if (error < countof(sftp_error)) ST(1) = sv_2mortal(newSVpvf("SSH_FX_%s", sftp_error[error])); else ST(1) = sv_2mortal(newSVpvf("SSH_FX_UNKNOWN(%lu)", error)); XSRETURN(2); } #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: clear_error(sf->ss); pv_file = SvPV(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: clear_error(sf->ss); pv_dir = SvPV(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 void net_sf_unlink(SSH2_SFTP* sf, SV* file) PREINIT: const char* pv_file; STRLEN len_file; CODE: clear_error(sf->ss); pv_file = SvPV(file, len_file); XSRETURN_IV(!libssh2_sftp_unlink_ex(sf->sftp, (char*)pv_file, len_file)); void 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: clear_error(sf->ss); pv_old = SvPV(old, len_old); pv_new = SvPV(new, len_new); XSRETURN_IV(!libssh2_sftp_rename_ex(sf->sftp, (char*)pv_old, len_old, (char*)pv_new, len_new, flags)); void net_sf_mkdir(SSH2_SFTP* sf, SV* dir, int mode = 0777) PREINIT: const char* pv_dir; STRLEN len_dir; CODE: clear_error(sf->ss); pv_dir = SvPV(dir, len_dir); XSRETURN_IV(!libssh2_sftp_mkdir_ex(sf->sftp, (char*)pv_dir, len_dir, mode)); void net_sf_rmdir(SSH2_SFTP* sf, SV* dir) PREINIT: const char* pv_dir; STRLEN len_dir; CODE: clear_error(sf->ss); pv_dir = SvPV(dir, len_dir); XSRETURN_IV(!libssh2_sftp_rmdir_ex(sf->sftp, (char*)pv_dir, len_dir)); void net_sf_stat(SSH2_SFTP* sf, SV* path, int follow = 1) PREINIT: const char* pv_path; STRLEN len_path; int success; LIBSSH2_SFTP_ATTRIBUTES attrs; PPCODE: clear_error(sf->ss); pv_path = SvPV(path, len_path); success = !libssh2_sftp_stat_ex(sf->sftp, (char*)pv_path, len_path, follow ? LIBSSH2_SFTP_STAT : LIBSSH2_SFTP_LSTAT, &attrs); if (!success) XSRETURN_EMPTY; XSRETURN_STAT_ATTRS(SvREFCNT_inc(path)); void net_sf_setstat(SSH2_SFTP* sf, SV* path, ...) PREINIT: const char* pv_path; STRLEN len_path; LIBSSH2_SFTP_ATTRIBUTES attrs; int i; CODE: clear_error(sf->ss); pv_path = SvPV(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 = SvPV_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); } XSRETURN_IV(!libssh2_sftp_stat_ex(sf->sftp, (char*)pv_path, len_path, LIBSSH2_SFTP_SETSTAT, &attrs)); void net_sf_symlink(SSH2_SFTP* sf, SV* path, SV* target) PREINIT: const char* pv_path, * pv_target; STRLEN len_path, len_target; CODE: clear_error(sf->ss); pv_path = SvPV(path, len_path); pv_target = SvPV(target, len_target); XSRETURN_IV(!libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, (char*)pv_target, len_target, LIBSSH2_SFTP_SYMLINK)); void net_sf_readlink(SSH2_SFTP* sf, SV* path) PREINIT: SV* link; const char* pv_path; char* pv_link; STRLEN len_path; int count; CODE: clear_error(sf->ss); pv_path = SvPV(path, len_path); link = newSV(MAXPATHLEN + 1); SvPOK_on(link); pv_link = SvPVX(link); count = libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, pv_link, MAXPATHLEN, LIBSSH2_SFTP_READLINK); if (count < 0) { SvREFCNT_dec(link); XSRETURN_EMPTY; } pv_link[count] = '\0'; SvCUR_set(link, count); ST(0) = sv_2mortal(link); XSRETURN(1); void net_sf_realpath(SSH2_SFTP* sf, SV* path) PREINIT: SV* real; const char* pv_path; char* pv_real; STRLEN len_path; int count; CODE: clear_error(sf->ss); pv_path = SvPV(path, len_path); real = newSV(MAXPATHLEN + 1); SvPOK_on(real); pv_real = SvPVX(real); count = libssh2_sftp_symlink_ex(sf->sftp, pv_path, len_path, pv_real, MAXPATHLEN, LIBSSH2_SFTP_REALPATH); if (count < 0) { SvREFCNT_dec(real); XSRETURN_EMPTY; } pv_real[count] = '\0'; SvCUR_set(real, count); ST(0) = sv_2mortal(real); XSRETURN(1); #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); clear_error(fi->sf->ss); libssh2_sftp_close_handle(fi->handle); SvREFCNT_dec(fi->sv_sf); Safefree(fi); void net_fi_read(SSH2_FILE* fi, SV* buffer, size_t size) PREINIT: char* pv_buffer; int count; CODE: clear_error(fi->sf->ss); SvPOK_on(buffer); pv_buffer = sv_grow(buffer, size + 1/*NUL*/); /* force PV */ pv_buffer[size] = '\0'; count = libssh2_sftp_read(fi->handle, pv_buffer, size); if (count < 0) { SvCUR_set(buffer, 0); XSRETURN_EMPTY; } SvCUR_set(buffer, count); XSRETURN_IV(count); void net_fi_write(SSH2_FILE* fi, SV* buffer) PREINIT: const char* pv_buffer; STRLEN len_buffer; ssize_t count; CODE: clear_error(fi->sf->ss); pv_buffer = SvPV(buffer, len_buffer); count = libssh2_sftp_write(fi->handle, pv_buffer, len_buffer); if (count < 0) XSRETURN_EMPTY; XSRETURN_UV(count); void net_fi_stat(SSH2_FILE* fi) PREINIT: LIBSSH2_SFTP_ATTRIBUTES attrs; PPCODE: clear_error(fi->sf->ss); if (libssh2_sftp_fstat(fi->handle, &attrs)) XSRETURN_EMPTY; XSRETURN_STAT_ATTRS(NULL/*name*/); void net_fi_setstat(SSH2_FILE* fi, ...) PREINIT: LIBSSH2_SFTP_ATTRIBUTES attrs; int i; CODE: clear_error(fi->sf->ss); Zero(&attrs, 1, LIBSSH2_SFTP_ATTRIBUTES); /* read key/value pairs; cf. hv_from_attrs */ for (i = 1; i < items; i += 2) { const char* key = SvPV_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); } XSRETURN_IV(!libssh2_sftp_fsetstat(fi->handle, &attrs)); void net_fi_seek(SSH2_FILE* fi, size_t offset) CODE: clear_error(fi->sf->ss); libssh2_sftp_seek(fi->handle, offset); XSRETURN(1); void net_fi_tell(SSH2_FILE* fi) CODE: clear_error(fi->sf->ss); XSRETURN_UV(libssh2_sftp_tell(fi->handle)); #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); clear_error(di->sf->ss); 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: clear_error(di->sf->ss); 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); clear_error(pk->ss); libssh2_publickey_shutdown(pk->pkey); SvREFCNT_dec(pk->sv_ss); Safefree(pk); void net_pk_add(SSH2_PUBLICKEY* pk, SV* name, SV* blob, int overwrite, ...) PREINIT: int success; const char* pv_name, * pv_blob; STRLEN len_name, len_blob; unsigned long num_attrs, i; libssh2_publickey_attribute *attrs; CODE: clear_error(pk->ss); pv_name = SvPV(name, len_name); pv_blob = SvPV(blob, len_blob); num_attrs = items - 4; New(0, attrs, num_attrs, libssh2_publickey_attribute); if (!attrs) { set_error(pk->ss, 0, "out of memory allocating attribute structures"); XSRETURN_EMPTY; } 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 = SvPV(*tmp, len_tmp); attrs[i].name_len = len_tmp; if ((tmp = hv_fetch(hv, "value", 5, 0/*lval*/)) && *tmp) { attrs[i].value = SvPV(*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; } success = !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); XSRETURN_IV(!success); void net_pk_remove(SSH2_PUBLICKEY* pk, SV* name, SV* blob) PREINIT: const char* pv_name, * pv_blob; STRLEN len_name, len_blob; CODE: clear_error(pk->ss); pv_name = SvPV(name, len_name); pv_blob = SvPV(blob, len_blob); XSRETURN_IV(!libssh2_publickey_remove_ex(pk->pkey, (const unsigned char *)pv_name, len_name, (const unsigned char *)pv_blob, len_blob)); 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); clear_error(kh->ss); libssh2_knownhost_free(kh->knownhosts); SvREFCNT_dec(kh->sv_ss); Safefree(kh); void net_kh_readfile(SSH2_KNOWNHOSTS *kh, const char *filename) PREINIT: int n; CODE: clear_error(kh->ss); n = libssh2_knownhost_readfile(kh->knownhosts, filename, LIBSSH2_KNOWNHOST_FILE_OPENSSH); if (n >= 0) XSRETURN_IV(n); else CROAK_LAST_ERROR(kh->ss, "readfile"); void net_kh_writefile(SSH2_KNOWNHOSTS *kh, const char *filename) PREINIT: int rc; PPCODE: clear_error(kh->ss); rc = libssh2_knownhost_writefile(kh->knownhosts, filename, LIBSSH2_KNOWNHOST_FILE_OPENSSH); if (rc == LIBSSH2_ERROR_NONE) { XPUSHs(&PL_sv_yes); XSRETURN(1); } else CROAK_LAST_ERROR(kh->ss, "writefile"); void net_kh_add(SSH2_KNOWNHOSTS *kh, const char *host, const char *salt, SV *key, SV *comment, int typemask) PREINIT: int rc; STRLEN key_len, comment_len; const char *key_pv, *comment_pv; CODE: clear_error(kh->ss); key_pv = SvPV_const(key, key_len); if (SvOK(comment)) comment_pv = SvPV_const(comment, comment_len); else { comment_pv = NULL; comment_len = 0; } #if LIBSSH2_VERSION_NUM >= 0x010205 rc = libssh2_knownhost_addc(kh->knownhosts, host, salt, key_pv, key_len, comment_pv, comment_len, typemask, NULL); #else if (SvOK(comment)) croak("libssh2 version 1.2.5 is required to add keys with comments"); rc = libssh2_knownhost_add(kh->knownhosts, host, salt, key_pv, key_len, typemask, NULL); #endif if (rc == LIBSSH2_ERROR_NONE) { XPUSHs(&PL_sv_yes); XSRETURN(1); } else CROAK_LAST_ERROR(kh->ss, "add"); int net_kh_check(SSH2_KNOWNHOSTS *kh, const char *host, SV *port, SV *key, int typemask) PREINIT: STRLEN key_len; const char *key_pv; UV port_uv; CODE: clear_error(kh->ss); key_pv = SvPV_const(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 != 0) && (port != 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 void net_kh_readline(SSH2_KNOWNHOSTS *kh, SV *line) PREINIT: int rc; STRLEN line_len; const char *line_pv; PPCODE: line_pv = SvPV_const(line, line_len); rc = libssh2_knownhost_readline(kh->knownhosts, line_pv, line_len, LIBSSH2_KNOWNHOST_FILE_OPENSSH); if (rc == LIBSSH2_ERROR_NONE) { XPUSHs(&PL_sv_yes); XSRETURN(1); } else CROAK_LAST_ERROR(kh->ss, "readline"); void net_kh_writeline(SSH2_KNOWNHOSTS *kh, const char *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; PPCODE: clear_error(kh->ss); key_pv = SvPV_const(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 != 0) && (port != 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 >= 0x010403 set_error(kh->ss, LIBSSH2_ERROR_KNOWN_HOSTS, "matching host key not found"); #else set_error(kh->ss, LIBSSH2_ERROR_SOCKET_NONE, "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); XPUSHs(buffer); XSRETURN(1); } if ((rc != LIBSSH2_ERROR_BUFFER_TOO_SMALL) || (SvLEN(buffer) > 64 * 1024)) break; SvGROW(buffer, SvLEN(buffer) * 2); } } CROAK_LAST_ERROR(kh->ss, "writeline"); # /* TODO */ # libssh2_knownhost_del() # libssh2_knownhost_get() # libssh2_knownhost_writeline() #endif #undef class # vim: set et ts=4: Net-SSH2-0.58/ppport.h0000644000175000017500000054004512531574006013417 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.58/BUILDING.WIN320000644000175000017500000001367112531574006013643 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.58/META.yml0000644000175000017500000000206112635456646013200 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.16' 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.58' 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.58' Net-SSH2-0.58/TODO0000644000175000017500000000022212531574006012376 0ustar salvasalvaPolling sometimes doesn't work. Segfaults on exit sometimes. sftp is incredibly slow. Detect static build on Win32 and not define -DLIBSSH2_WIN32 Net-SSH2-0.58/t/0000755000175000017500000000000012635456667012176 5ustar salvasalvaNet-SSH2-0.58/t/Net-SSH2.t0000644000175000017500000001774712635456504013634 0ustar salvasalva# 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 tests => 73; use strict; use File::Basename; use Fcntl ':mode'; ######################### # to speed up testing, set host, user and pass here my ($host, $user, $password, $passphrase) = qw(); # (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'); #$ssh2->trace(-1); ok($ssh2->banner('SSH TEST'), 'set banner'); is(LIBSSH2_ERROR_SOCKET_NONE(), -1, 'LIBSSH2_* constants'); # (4) version my $version = $ssh2->version(); my ($version2, $vernum, $banner) = $ssh2->version(); is($version, $version2, 'list version match'); my ($major) = $version =~ /^(\d+)/; SKIP: { skip 'old libssh2', 1 if !defined($vernum); skip 'version not decimal', 1 if ($version =~ y/.//) > 1; if ($major > 0) { ok(($vernum >> 8) == ($major << 8) + ($version - $major) * 10, 'decimal version matches'); } else { ok(($vernum >> 8) == ($major << 8) + ($version - $major) * 100, 'decimal version matches'); } } 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'); # (1) connect SKIP: { # SKIP-connect skip '- non-interactive session', 62 unless $host or -t STDOUT; $| = 1; unless ($host) { print <); print "\n"; } SKIP: { # SKIP-server skip '- no server daemon available', 62 unless $host; ok($ssh2->connect($host), "connect to $host"); isa_ok($ssh2->sock, 'IO::Socket', '->sock isa IO::Socket'); # (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) hostkey hash 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'); # (3) authentication methods unless ($user) { my $def_user; $def_user = getpwuid $< if $^O !~ /mswin/i; print $def_user ? "\nEnter username [$def_user]: " : "\nEnter username: "; chomp($user = ); $user ||= $def_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; if (defined $ENV{HOME}) { for my $key (qw(dsa rsa)) { if ($ssh2->auth_publickey($user, "$ENV{HOME}/.ssh/id_$key.pub", "$ENV{HOME}/.ssh/id_$key", $passphrase)) { $type = 'pubkey'; last; } } } unless ($type) { $type = $ssh2->auth(username => $user, password => $password, interact => 1); } ok($type, "authenticated"); SKIP: { # SKIP-auth skip '- failed to authenticate with server', 37 unless $ssh2->auth_ok; pass('authenticated successfully'); # (5) channels my $chan = $ssh2->channel(); isa_ok($chan, 'Net::SSH2::Channel', 'new 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(), 0, 'empty setenv'); my %env = (test1 => 'A', test2 => 'something', test3 => 'E L S E'); # most sshds disallow set, so we're happy if these don't crash ok($chan->setenv(%env) <= keys %env, 'set environment variables'); 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', 'SFTP session'); 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(S_ISDIR($stat{mode}), 'type is directory'); is($stat{name}, $dir, 'directory name matches'); # (4) SCP my $remote = "$dir/".basename($0); ok($ssh2->scp_put($0, $remote), "put $0 to remote"); SKIP: { # SKIP-scalar eval { require IO::Scalar }; skip '- IO::Scalar required', 2 if $@; my $check = IO::Scalar->new; ok($ssh2->scp_get($remote, $check), "get $remote from remote"); SKIP: { # SKIP-slurp eval { require File::Slurp }; skip '- File::Slurp required', 1 if $@; if($^O =~ /MSWin32/i) { is(${$check->sref}, File::Slurp::read_file($0, binmode => ':raw'), 'files match'); } else { is(${$check->sref}, File::Slurp::read_file($0), 'files match'); } } # SKIP-slurp } # SKIP-scalar # (3) rename my $altname = "$remote.renamed"; $sftp->unlink($altname); ok(!$sftp->unlink($altname), '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, $altname), "rename $remote -> $altname"); # (3) stat %stat = $sftp->stat($altname); ok(scalar keys %stat, "stat $altname"); is($stat{name}, $altname, 'stat filename matches'); is($stat{size}, -s $0, 'stat filesize matches'); # (3) open my $fh = $sftp->open($altname); 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; # (2) SFTP dir my $dh = $sftp->opendir($dir); isa_ok($dh, 'Net::SSH2::Dir', 'opened directory'); my $found; while(my $item = $dh->read) { $found = 1, last if $item->{name} eq basename $altname; } ok($found, "found $altname"); undef $dh; # (2) read file $fh = $sftp->open($altname); isa_ok($fh, 'Net::SSH2::File', 'opened file'); scalar <$fh> for 1..2; my $line = <$fh>; chomp $line; if($^O =~ /MSWin32/i) { $line =~ s/\r//; } is($line, '# THIS LINE WILL BE READ BY A TEST BELOW', "read '$line'"); #undef $fh; # don't undef it, ensure reference counts work properly # (3) cleanup SFTP ok($sftp->unlink($altname), "unlink $altname"); ok($sftp->rmdir($dir), "remove directory $dir"); undef $sftp; pass('close SFTP session'); # (5) poll $chan = $ssh2->channel(); 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 my $pk = $ssh2->public_key; SKIP: { skip ' - public key infrastructure not present', 4 unless $pk; 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; # (2) disconnect ok($chan->close(), 'close channel'); # optional step undef $fh; ok($ssh2->disconnect('leaving'), 'sent disconnect message'); } # SKIP-auth } # SKIP-server } # SKIP-connect # vim:filetype=perl Net-SSH2-0.58/fallback/0000755000175000017500000000000012635456667013472 5ustar salvasalvaNet-SSH2-0.58/fallback/const-c.inc0000644000175000017500000021132012531574006015511 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_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 15 gives the best switch position. */ switch (name[15]) { case 'D': 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 'E': 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 'F': 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 'I': 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 'K': 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; case 'L': 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 'O': 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 'T': 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 } break; case 'U': 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 } 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; } 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 */ /* Offset 16 gives the best switch position. */ switch (name[16]) { case 'A': 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 '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 } 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 'H': 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 'N': 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 'O': 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; case 'R': 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 '_': 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; } 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_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 '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_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; } 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_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_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_ERROR_CHANNEL_CLOSED LIBSSH2_ERROR_REQUEST_DENIED LIBSSH2_ERROR_SOCKET_TIMEOUT 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_BLOCK_INBOUND LIBSSH2_SOCKET_POLL_MAXLOOPS */ /* Offset 25 gives the best switch position. */ switch (name[25]) { case 'A': 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 'D': 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 } break; case 'I': 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 } 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 'O': 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 } 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 'P': 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 'R': 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_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 'S': 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 'U': if (memEQ(name, "LIBSSH2_SOCKET_BLOCK_INBOUND", 28)) { /* ^ */ #ifdef LIBSSH2_SOCKET_BLOCK_INBOUND *iv_return = LIBSSH2_SOCKET_BLOCK_INBOUND; 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_KNOWNHOST_CHECK_MATCH LIBSSH2_KNOWNHOST_KEYENC_MASK LIBSSH2_KNOWNHOST_TYPE_CUSTOM LIBSSH2_POLLFD_CHANNEL_CLOSED LIBSSH2_POLLFD_SESSION_CLOSED LIBSSH2_SFTP_ATTR_PERMISSIONS LIBSSH2_SFTP_RENAME_OVERWRITE LIBSSH2_SFTP_TYPE_CHAR_DEVICE LIBSSH2_SOCKET_BLOCK_OUTBOUND */ /* Offset 24 gives the best switch position. */ switch (name[24]) { case 'B': if (memEQ(name, "LIBSSH2_SOCKET_BLOCK_OUTBOUND", 29)) { /* ^ */ #ifdef LIBSSH2_SOCKET_BLOCK_OUTBOUND *iv_return = LIBSSH2_SOCKET_BLOCK_OUTBOUND; 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 '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_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 '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_KNOWNHOST_CHECK_FAILURE LIBSSH2_KNOWNHOST_KEYENC_BASE64 */ /* Offset 22 gives the best switch position. */ switch (name[22]) { case 'I': 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 'K': 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 'N': 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 'P': 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; } 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_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_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_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_METHOD_NONE LIBSSH2_ERROR_METHOD_NOT_SUPPORTED 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_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_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_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_BLOCK_INBOUND LIBSSH2_SOCKET_BLOCK_OUTBOUND 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)); 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: /* Names all of length 35. */ /* LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA */ /* Offset 16 gives the best switch position. */ switch (name[16]) { case 'E': if (memEQ(name, "LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE", 35)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE *iv_return = LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; case 'F': if (memEQ(name, "LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA", 35)) { /* ^ */ #ifdef LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA *iv_return = LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA; return PERL_constant_ISIV; #else return PERL_constant_NOTDEF; #endif } break; } 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.58/fallback/const-xs.inc0000644000175000017500000000514712531574006015731 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.58/Makefile.PL0000644000175000017500000002530012630775314013671 0ustar salvasalvause inc::Module::Install 0.91; use Cwd; use Config; # override library and include directories here if desired my $lib = $ENV{LIBSSH2_LIB} || ''; my $inc = $ENV{LIBSSH2_INCLUDE} || ''; my $extra_libs = '-lz' . ($ENV{LIBSSH2_LDARGS} ? (' ' . $ENV{LIBSSH2_LDARGS}) : ''); my $ldargs; # from command line my $use_gcrypt = 0; my @args = @ARGV; my @pass_through_args; while (my $arg = shift @args) { if (my ($param, $val) = $arg =~ /^(inc|lib|ldargs)=(.*)\z/) { my $var = $param eq 'inc' ? \$inc : ($param eq 'lib' ? \$lib : \$ldargs); $$var = $val; next; } elsif ($arg eq 'gcrypt') { $use_gcrypt = 1; next; } push @pass_through_args, $arg; } @ARGV = @pass_through_args; # Windows, as usual, is a special case my $win32 = ($^O eq 'MSWin32'); if ($use_gcrypt) { $extra_libs .= ' -lgcrypt'; } else { if ($win32 && $Config{cc} =~ /cl/) { $extra_libs .= ' -lssleay32 -llibeay32'; # Win32 + MSVC compiler } if ($win32 && $Config{cc} =~ /gcc/) { $extra_libs .= ' -lssl32 -leay32'; # Win32 + GCC compiler (mingw) } else { $extra_libs .= ' -lssl -lcrypto'; } } $extra_libs = "$extra_libs $ldargs" if $ldargs; my $defines = ''; $defines .= '-DLIBSSH2_WIN32 ' if $win32; $defines .= '-DUSE_GCRYPT ' if $use_gcrypt; my @define = $defines ? (DEFINE => $defines) : (); name 'Net-SSH2'; all_from 'lib/Net/SSH2.pm'; perl_version '5.006000'; my @extra_search_paths; # 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 @extra_search_paths, (sort { (stat($b))[9] <=> (stat($a))[9] } glob('/usr/local/Cellar/openssl/*'))[0]; } my @search_paths = ( (split /\Q$Config{path_sep}\E/, $ENV{LD_RUN_PATH}), (split /\Q$Config{path_sep}\E/, ($^O eq 'darwin' ? $ENV{DYLD_LIBRARY_PATH} : $ENV{LD_LIBRARY_PATH})), $ENV{HOME}, ($ENV{HOME}."/libssh2"), (split ' ', $Config{libspath}), $Config{siteprefixexp}, $Config{prefixexp}, '/usr/local/ssl', '/usr', '/usr/local', '/opt', '/opt/local', '/', @extra_search_paths ); my %seen; foreach my $path (@search_paths) { $seen{$path}++; } my (%skip, @without_dups); foreach my $path (@search_paths) { next if $skip{$path}; if ($seen{$path} > 1) { $skip{$path} = 1; } push @without_dups, $path; } @search_paths = @without_dups; my @search_libs = grep -d, map +("$_/lib", "$_/lib64", $_), @search_paths; my @search_incs = grep -d, map "$_/include", @search_paths; 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 if (!$lib && !$inc) { checklibs( lib => 'ssh2', header => 'libssh2.h', libpath => [@search_libs], incpath => [@search_incs] ); unless ($win32) { if ($use_gcrypt) { checklibs( lib => 'gcrypt', header => 'gcrypt.h', libpath => [@search_libs], incpath => [@search_incs] ); } else { checklibs( lib => 'ssl', header => 'openssl/crypto.h', libpath => [@search_libs], incpath => [@search_incs] ); } } $lib = (join ' ', map "-L$_", @search_libs) . " -lssh2 $extra_libs"; $inc = join ' ', map "-I$_", @search_incs; } else { $lib = "-L$lib -lssh2 $extra_libs" if $lib; $inc = "-I$inc" if $inc; } my $extra_ccflags = ' '; if ($^O eq 'darwin') { $extra_ccflags .= '-Wno-deprecated-declarations' } auto_provides; libs $lib; inc "$inc -I."; makemaker_args @define, # this is known to NOT work on mingw, solaris and darwin, and we only turn it on for devs ($Module::Install::AUTHOR && $^O ne 'MSWin32' && $^O ne 'solaris' && $^O ne 'darwin' && $Config{cc} =~ /gcc/i ? ( CCFLAGS => '-DPERL_GCC_PEDANTIC -std=c99 -pedantic-errors -Wno-long-long ' ) : ( CCFLAGS => $Config{ccflags} . $extra_ccflags )) ; realclean_files qw/const-c.inc const-xs.inc/; resources repository => 'git://github.com/rkitover/net-ssh2.git'; WriteAll; if (eval {require ExtUtils::Constant; 1}) { # If you edit these definitions to change the constants used by this module, # you will need to use the generated const-c.inc and const-xs.inc # files to replace their "fallback" counterparts before distributing your # changes. 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_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_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_FLAG_SIGPIPE LIBSSH2_FLAG_COMPRESS LIBSSH2_FXF_APPEND LIBSSH2_ERROR_EAGAIN LIBSSH2_SOCKET_BLOCK_INBOUND LIBSSH2_SOCKET_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 )); ExtUtils::Constant::WriteConstants( NAME => 'Net::SSH2', NAMES => \@names, DEFAULT_TYPE => 'IV', C_FILE => 'const-c.inc', XS_FILE => 'const-xs.inc', ); } else { use File::Copy; use File::Spec; foreach my $file ('const-c.inc', 'const-xs.inc') { my $fallback = File::Spec->catfile('fallback', $file); copy ($fallback, $file) or die "Can't copy $fallback to $file: $!"; } } Net-SSH2-0.58/README0000644000175000017500000000564012612733050012573 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.6.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. 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 - 2015 by Rafael Kitover (rkitover@cpan.org). Copyright (C) 2011 - 2015 by Salvador Fandiño (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.