?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/Handle.pm.tar
???????
usr/lib64/perl5/IO/Handle.pm 0000644 00000040401 15125746042 0011371 0 ustar 00 package IO::Handle; =head1 NAME IO::Handle - supply object methods for I/O handles =head1 SYNOPSIS use IO::Handle; $io = IO::Handle->new(); if ($io->fdopen(fileno(STDIN),"r")) { print $io->getline; $io->close; } $io = IO::Handle->new(); if ($io->fdopen(fileno(STDOUT),"w")) { $io->print("Some text\n"); } # setvbuf is not available by default on Perls 5.8.0 and later. use IO::Handle '_IOLBF'; $io->setvbuf($buffer_var, _IOLBF, 1024); undef $io; # automatically closes the file if it's open autoflush STDOUT 1; =head1 DESCRIPTION C<IO::Handle> is the base class for all other IO handle classes. It is not intended that objects of C<IO::Handle> would be created directly, but instead C<IO::Handle> is inherited from by several other classes in the IO hierarchy. If you are reading this documentation, looking for a replacement for the C<FileHandle> package, then I suggest you read the documentation for C<IO::File> too. =head1 CONSTRUCTOR =over 4 =item new () Creates a new C<IO::Handle> object. =item new_from_fd ( FD, MODE ) Creates an C<IO::Handle> like C<new> does. It requires two parameters, which are passed to the method C<fdopen>; if the fdopen fails, the object is destroyed. Otherwise, it is returned to the caller. =back =head1 METHODS See L<perlfunc> for complete descriptions of each of the following supported C<IO::Handle> methods, which are just front ends for the corresponding built-in functions: $io->close $io->eof $io->fcntl( FUNCTION, SCALAR ) $io->fileno $io->format_write( [FORMAT_NAME] ) $io->getc $io->ioctl( FUNCTION, SCALAR ) $io->read ( BUF, LEN, [OFFSET] ) $io->print ( ARGS ) $io->printf ( FMT, [ARGS] ) $io->say ( ARGS ) $io->stat $io->sysread ( BUF, LEN, [OFFSET] ) $io->syswrite ( BUF, [LEN, [OFFSET]] ) $io->truncate ( LEN ) See L<perlvar> for complete descriptions of each of the following supported C<IO::Handle> methods. All of them return the previous value of the attribute and takes an optional single argument that when given will set the value. If no argument is given the previous value is unchanged (except for $io->autoflush will actually turn ON autoflush by default). $io->autoflush ( [BOOL] ) $| $io->format_page_number( [NUM] ) $% $io->format_lines_per_page( [NUM] ) $= $io->format_lines_left( [NUM] ) $- $io->format_name( [STR] ) $~ $io->format_top_name( [STR] ) $^ $io->input_line_number( [NUM]) $. The following methods are not supported on a per-filehandle basis. IO::Handle->format_line_break_characters( [STR] ) $: IO::Handle->format_formfeed( [STR]) $^L IO::Handle->output_field_separator( [STR] ) $, IO::Handle->output_record_separator( [STR] ) $\ IO::Handle->input_record_separator( [STR] ) $/ Furthermore, for doing normal I/O you might need these: =over 4 =item $io->fdopen ( FD, MODE ) C<fdopen> is like an ordinary C<open> except that its first parameter is not a filename but rather a file handle name, an IO::Handle object, or a file descriptor number. (For the documentation of the C<open> method, see L<IO::File>.) =item $io->opened Returns true if the object is currently a valid file descriptor, false otherwise. =item $io->getline This works like <$io> described in L<perlop/"I/O Operators"> except that it's more readable and can be safely called in a list context but still returns just one line. If used as the conditional within a C<while> or C-style C<for> loop, however, you will need to emulate the functionality of <$io> with C<< defined($_ = $io->getline) >>. =item $io->getlines This works like <$io> when called in a list context to read all the remaining lines in a file, except that it's more readable. It will also croak() if accidentally called in a scalar context. =item $io->ungetc ( ORD ) Pushes a character with the given ordinal value back onto the given handle's input stream. Only one character of pushback per handle is guaranteed. =item $io->write ( BUF, LEN [, OFFSET ] ) This C<write> is somewhat like C<write> found in C, in that it is the opposite of read. The wrapper for the perl C<write> function is called C<format_write>. However, whilst the C C<write> function returns the number of bytes written, this C<write> function simply returns true if successful (like C<print>). A more C-like C<write> is C<syswrite> (see above). =item $io->error Returns a true value if the given handle has experienced any errors since it was opened or since the last call to C<clearerr>, or if the handle is invalid. It only returns false for a valid handle with no outstanding errors. =item $io->clearerr Clear the given handle's error indicator. Returns -1 if the handle is invalid, 0 otherwise. =item $io->sync C<sync> synchronizes a file's in-memory state with that on the physical medium. C<sync> does not operate at the perlio api level, but operates on the file descriptor (similar to sysread, sysseek and systell). This means that any data held at the perlio api level will not be synchronized. To synchronize data that is buffered at the perlio api level you must use the flush method. C<sync> is not implemented on all platforms. Returns "0 but true" on success, C<undef> on error, C<undef> for an invalid handle. See L<fsync(3c)>. =item $io->flush C<flush> causes perl to flush any buffered data at the perlio api level. Any unread data in the buffer will be discarded, and any unwritten data will be written to the underlying file descriptor. Returns "0 but true" on success, C<undef> on error. =item $io->printflush ( ARGS ) Turns on autoflush, print ARGS and then restores the autoflush status of the C<IO::Handle> object. Returns the return value from print. =item $io->blocking ( [ BOOL ] ) If called with an argument C<blocking> will turn on non-blocking IO if C<BOOL> is false, and turn it off if C<BOOL> is true. C<blocking> will return the value of the previous setting, or the current setting if C<BOOL> is not given. If an error occurs C<blocking> will return undef and C<$!> will be set. =back If the C functions setbuf() and/or setvbuf() are available, then C<IO::Handle::setbuf> and C<IO::Handle::setvbuf> set the buffering policy for an IO::Handle. The calling sequences for the Perl functions are the same as their C counterparts--including the constants C<_IOFBF>, C<_IOLBF>, and C<_IONBF> for setvbuf()--except that the buffer parameter specifies a scalar variable to use as a buffer. You should only change the buffer before any I/O, or immediately after calling flush. WARNING: The IO::Handle::setvbuf() is not available by default on Perls 5.8.0 and later because setvbuf() is rather specific to using the stdio library, while Perl prefers the new perlio subsystem instead. WARNING: A variable used as a buffer by C<setbuf> or C<setvbuf> B<must not be modified> in any way until the IO::Handle is closed or C<setbuf> or C<setvbuf> is called again, or memory corruption may result! Remember that the order of global destruction is undefined, so even if your buffer variable remains in scope until program termination, it may be undefined before the file IO::Handle is closed. Note that you need to import the constants C<_IOFBF>, C<_IOLBF>, and C<_IONBF> explicitly. Like C, setbuf returns nothing. setvbuf returns "0 but true", on success, C<undef> on failure. Lastly, there is a special method for working under B<-T> and setuid/gid scripts: =over 4 =item $io->untaint Marks the object as taint-clean, and as such data read from it will also be considered taint-clean. Note that this is a very trusting action to take, and appropriate consideration for the data source and potential vulnerability should be kept in mind. Returns 0 on success, -1 if setting the taint-clean flag failed. (eg invalid handle) =back =head1 NOTE An C<IO::Handle> object is a reference to a symbol/GLOB reference (see the C<Symbol> package). Some modules that inherit from C<IO::Handle> may want to keep object related variables in the hash table part of the GLOB. In an attempt to prevent modules trampling on each other I propose the that any such module should prefix its variables with its own name separated by _'s. For example the IO::Socket module keeps a C<timeout> variable in 'io_socket_timeout'. =head1 SEE ALSO L<perlfunc>, L<perlop/"I/O Operators">, L<IO::File> =head1 BUGS Due to backwards compatibility, all filehandles resemble objects of class C<IO::Handle>, or actually classes derived from that class. They actually aren't. Which means you can't derive your own class from C<IO::Handle> and inherit those methods. =head1 HISTORY Derived from FileHandle.pm by Graham Barr E<lt>F<gbarr@pobox.com>E<gt> =cut use 5.008_001; use strict; use Carp; use Symbol; use SelectSaver; use IO (); # Load the XS module require Exporter; our @ISA = qw(Exporter); our $VERSION = "1.42"; our @EXPORT_OK = qw( autoflush output_field_separator output_record_separator input_record_separator input_line_number format_page_number format_lines_per_page format_lines_left format_name format_top_name format_line_break_characters format_formfeed format_write print printf say getline getlines printflush flush SEEK_SET SEEK_CUR SEEK_END _IOFBF _IOLBF _IONBF ); ################################################ ## Constructors, destructors. ## sub new { my $class = ref($_[0]) || $_[0] || "IO::Handle"; if (@_ != 1) { # Since perl will automatically require IO::File if needed, but # also initialises IO::File's @ISA as part of the core we must # ensure IO::File is loaded if IO::Handle is. This avoids effect- # ively "half-loading" IO::File. if ($] > 5.013 && $class eq 'IO::File' && !$INC{"IO/File.pm"}) { require IO::File; shift; return IO::File::->new(@_); } croak "usage: $class->new()"; } my $io = gensym; bless $io, $class; } sub new_from_fd { my $class = ref($_[0]) || $_[0] || "IO::Handle"; @_ == 3 or croak "usage: $class->new_from_fd(FD, MODE)"; my $io = gensym; shift; IO::Handle::fdopen($io, @_) or return undef; bless $io, $class; } # # There is no need for DESTROY to do anything, because when the # last reference to an IO object is gone, Perl automatically # closes its associated files (if any). However, to avoid any # attempts to autoload DESTROY, we here define it to do nothing. # sub DESTROY {} ################################################ ## Open and close. ## sub _open_mode_string { my ($mode) = @_; $mode =~ /^\+?(<|>>?)$/ or $mode =~ s/^r(\+?)$/$1</ or $mode =~ s/^w(\+?)$/$1>/ or $mode =~ s/^a(\+?)$/$1>>/ or croak "IO::Handle: bad open mode: $mode"; $mode; } sub fdopen { @_ == 3 or croak 'usage: $io->fdopen(FD, MODE)'; my ($io, $fd, $mode) = @_; local(*GLOB); if (ref($fd) && "$fd" =~ /GLOB\(/o) { # It's a glob reference; Alias it as we cannot get name of anon GLOBs my $n = qualify(*GLOB); *GLOB = *{*$fd}; $fd = $n; } elsif ($fd =~ m#^\d+$#) { # It's an FD number; prefix with "=". $fd = "=$fd"; } open($io, _open_mode_string($mode) . '&' . $fd) ? $io : undef; } sub close { @_ == 1 or croak 'usage: $io->close()'; my($io) = @_; close($io); } ################################################ ## Normal I/O functions. ## # flock # select sub opened { @_ == 1 or croak 'usage: $io->opened()'; defined fileno($_[0]); } sub fileno { @_ == 1 or croak 'usage: $io->fileno()'; fileno($_[0]); } sub getc { @_ == 1 or croak 'usage: $io->getc()'; getc($_[0]); } sub eof { @_ == 1 or croak 'usage: $io->eof()'; eof($_[0]); } sub print { @_ or croak 'usage: $io->print(ARGS)'; my $this = shift; print $this @_; } sub printf { @_ >= 2 or croak 'usage: $io->printf(FMT,[ARGS])'; my $this = shift; printf $this @_; } sub say { @_ or croak 'usage: $io->say(ARGS)'; my $this = shift; local $\ = "\n"; print $this @_; } sub truncate { @_ == 2 or croak 'usage: $io->truncate(LEN)'; truncate($_[0], $_[1]); } sub read { @_ == 3 || @_ == 4 or croak 'usage: $io->read(BUF, LEN [, OFFSET])'; read($_[0], $_[1], $_[2], $_[3] || 0); } sub sysread { @_ == 3 || @_ == 4 or croak 'usage: $io->sysread(BUF, LEN [, OFFSET])'; sysread($_[0], $_[1], $_[2], $_[3] || 0); } sub write { @_ >= 2 && @_ <= 4 or croak 'usage: $io->write(BUF [, LEN [, OFFSET]])'; local($\) = ""; $_[2] = length($_[1]) unless defined $_[2]; print { $_[0] } substr($_[1], $_[3] || 0, $_[2]); } sub syswrite { @_ >= 2 && @_ <= 4 or croak 'usage: $io->syswrite(BUF [, LEN [, OFFSET]])'; if (defined($_[2])) { syswrite($_[0], $_[1], $_[2], $_[3] || 0); } else { syswrite($_[0], $_[1]); } } sub stat { @_ == 1 or croak 'usage: $io->stat()'; stat($_[0]); } ################################################ ## State modification functions. ## sub autoflush { my $old = SelectSaver->new(qualify($_[0], caller)); my $prev = $|; $| = @_ > 1 ? $_[1] : 1; $prev; } sub output_field_separator { carp "output_field_separator is not supported on a per-handle basis" if ref($_[0]); my $prev = $,; $, = $_[1] if @_ > 1; $prev; } sub output_record_separator { carp "output_record_separator is not supported on a per-handle basis" if ref($_[0]); my $prev = $\; $\ = $_[1] if @_ > 1; $prev; } sub input_record_separator { carp "input_record_separator is not supported on a per-handle basis" if ref($_[0]); my $prev = $/; $/ = $_[1] if @_ > 1; $prev; } sub input_line_number { local $.; () = tell qualify($_[0], caller) if ref($_[0]); my $prev = $.; $. = $_[1] if @_ > 1; $prev; } sub format_page_number { my $old; $old = SelectSaver->new(qualify($_[0], caller)) if ref($_[0]); my $prev = $%; $% = $_[1] if @_ > 1; $prev; } sub format_lines_per_page { my $old; $old = SelectSaver->new(qualify($_[0], caller)) if ref($_[0]); my $prev = $=; $= = $_[1] if @_ > 1; $prev; } sub format_lines_left { my $old; $old = SelectSaver->new(qualify($_[0], caller)) if ref($_[0]); my $prev = $-; $- = $_[1] if @_ > 1; $prev; } sub format_name { my $old; $old = SelectSaver->new(qualify($_[0], caller)) if ref($_[0]); my $prev = $~; $~ = qualify($_[1], caller) if @_ > 1; $prev; } sub format_top_name { my $old; $old = SelectSaver->new(qualify($_[0], caller)) if ref($_[0]); my $prev = $^; $^ = qualify($_[1], caller) if @_ > 1; $prev; } sub format_line_break_characters { carp "format_line_break_characters is not supported on a per-handle basis" if ref($_[0]); my $prev = $:; $: = $_[1] if @_ > 1; $prev; } sub format_formfeed { carp "format_formfeed is not supported on a per-handle basis" if ref($_[0]); my $prev = $^L; $^L = $_[1] if @_ > 1; $prev; } sub formline { my $io = shift; my $picture = shift; local($^A) = $^A; local($\) = ""; formline($picture, @_); print $io $^A; } sub format_write { @_ < 3 || croak 'usage: $io->write( [FORMAT_NAME] )'; if (@_ == 2) { my ($io, $fmt) = @_; my $oldfmt = $io->format_name(qualify($fmt,caller)); CORE::write($io); $io->format_name($oldfmt); } else { CORE::write($_[0]); } } sub fcntl { @_ == 3 || croak 'usage: $io->fcntl( OP, VALUE );'; my ($io, $op) = @_; return fcntl($io, $op, $_[2]); } sub ioctl { @_ == 3 || croak 'usage: $io->ioctl( OP, VALUE );'; my ($io, $op) = @_; return ioctl($io, $op, $_[2]); } # this sub is for compatibility with older releases of IO that used # a sub called constant to determine if a constant existed -- GMB # # The SEEK_* and _IO?BF constants were the only constants at that time # any new code should just check defined(&CONSTANT_NAME) sub constant { no strict 'refs'; my $name = shift; (($name =~ /^(SEEK_(SET|CUR|END)|_IO[FLN]BF)$/) && defined &{$name}) ? &{$name}() : undef; } # so that flush.pl can be deprecated sub printflush { my $io = shift; my $old; $old = SelectSaver->new(qualify($io, caller)) if ref($io); local $| = 1; if(ref($io)) { print $io @_; } else { print @_; } } 1; usr/share/perl5/Tie/Handle.pm 0000644 00000010152 15126015465 0011764 0 ustar 00 package Tie::Handle; use 5.006_001; our $VERSION = '4.2'; # Tie::StdHandle used to be inside Tie::Handle. For backwards compatibility # loading Tie::Handle has to make Tie::StdHandle available. use Tie::StdHandle; =head1 NAME Tie::Handle - base class definitions for tied handles =head1 SYNOPSIS package NewHandle; require Tie::Handle; @ISA = qw(Tie::Handle); sub READ { ... } # Provide a needed method sub TIEHANDLE { ... } # Overrides inherited method package main; tie *FH, 'NewHandle'; =head1 DESCRIPTION This module provides some skeletal methods for handle-tying classes. See L<perltie> for a list of the functions required in tying a handle to a package. The basic B<Tie::Handle> package provides a C<new> method, as well as methods C<TIEHANDLE>, C<PRINT>, C<PRINTF> and C<GETC>. For developers wishing to write their own tied-handle classes, the methods are summarized below. The L<perltie> section not only documents these, but has sample code as well: =over 4 =item TIEHANDLE classname, LIST The method invoked by the command C<tie *glob, classname>. Associates a new glob instance with the specified class. C<LIST> would represent additional arguments (along the lines of L<AnyDBM_File> and compatriots) needed to complete the association. =item WRITE this, scalar, length, offset Write I<length> bytes of data from I<scalar> starting at I<offset>. =item PRINT this, LIST Print the values in I<LIST> =item PRINTF this, format, LIST Print the values in I<LIST> using I<format> =item READ this, scalar, length, offset Read I<length> bytes of data into I<scalar> starting at I<offset>. =item READLINE this Read a single line =item GETC this Get a single character =item CLOSE this Close the handle =item OPEN this, filename (Re-)open the handle =item BINMODE this Specify content is binary =item EOF this Test for end of file. =item TELL this Return position in the file. =item SEEK this, offset, whence Position the file. Test for end of file. =item DESTROY this Free the storage associated with the tied handle referenced by I<this>. This is rarely needed, as Perl manages its memory quite well. But the option exists, should a class wish to perform specific actions upon the destruction of an instance. =back =head1 MORE INFORMATION The L<perltie> section contains an example of tying handles. =head1 COMPATIBILITY This version of Tie::Handle is neither related to nor compatible with the Tie::Handle (3.0) module available on CPAN. It was due to an accident that two modules with the same name appeared. The namespace clash has been cleared in favor of this module that comes with the perl core in September 2000 and accordingly the version number has been bumped up to 4.0. =cut use Carp; use warnings::register; sub new { my $pkg = shift; $pkg->TIEHANDLE(@_); } # "Grandfather" the new, a la Tie::Hash sub TIEHANDLE { my $pkg = shift; if (defined &{"{$pkg}::new"}) { warnings::warnif("WARNING: calling ${pkg}->new since ${pkg}->TIEHANDLE is missing"); $pkg->new(@_); } else { croak "$pkg doesn't define a TIEHANDLE method"; } } sub PRINT { my $self = shift; if($self->can('WRITE') != \&WRITE) { my $buf = join(defined $, ? $, : "",@_); $buf .= $\ if defined $\; $self->WRITE($buf,length($buf),0); } else { croak ref($self)," doesn't define a PRINT method"; } } sub PRINTF { my $self = shift; if($self->can('WRITE') != \&WRITE) { my $buf = sprintf(shift,@_); $self->WRITE($buf,length($buf),0); } else { croak ref($self)," doesn't define a PRINTF method"; } } sub READLINE { my $pkg = ref $_[0]; croak "$pkg doesn't define a READLINE method"; } sub GETC { my $self = shift; if($self->can('READ') != \&READ) { my $buf; $self->READ($buf,1); return $buf; } else { croak ref($self)," doesn't define a GETC method"; } } sub READ { my $pkg = ref $_[0]; croak "$pkg doesn't define a READ method"; } sub WRITE { my $pkg = ref $_[0]; croak "$pkg doesn't define a WRITE method"; } sub CLOSE { my $pkg = ref $_[0]; croak "$pkg doesn't define a CLOSE method"; } 1; usr/lib64/perl5/vendor_perl/Net/SSLeay/Handle.pm 0000644 00000024575 15126442605 0015304 0 ustar 00 package Net::SSLeay::Handle; use 5.8.1; use strict; use Socket; use Net::SSLeay; require Exporter; =encoding utf-8 =head1 NAME Net::SSLeay::Handle - Perl module that lets SSL (HTTPS) sockets be handled as standard file handles. =head1 SYNOPSIS use Net::SSLeay::Handle qw/shutdown/; my ($host, $port) = ("localhost", 443); tie(*SSL, "Net::SSLeay::Handle", $host, $port); print SSL "GET / HTTP/1.0\r\n"; shutdown(\*SSL, 1); print while (<SSL>); close SSL; =head1 DESCRIPTION Net::SSLeay::Handle allows you to request and receive HTTPS web pages using "old-fashion" file handles as in: print SSL "GET / HTTP/1.0\r\n"; and print while (<SSL>); If you export the shutdown routine, then the only extra code that you need to add to your program is the tie function as in: my $socket; if ($scheme eq "https") { tie(*S2, "Net::SSLeay::Handle", $host, $port); $socket = \*S2; else { $socket = Net::SSLeay::Handle->make_socket($host, $port); } print $socket $request_headers; ... =cut use vars qw(@ISA @EXPORT_OK $VERSION); @ISA = qw(Exporter); @EXPORT_OK = qw(shutdown); $VERSION = '1.94'; my $Initialized; #-- only _initialize() once my $Debug = 0; #-- pretty hokey #== Tie Handle Methods ======================================================== # # see perldoc perltie for details. # #============================================================================== sub TIEHANDLE { my ($class, $socket, $port) = @_; $Debug > 10 and print "TIEHANDLE(@{[join ', ', @_]})\n"; ref $socket eq "GLOB" or $socket = $class->make_socket($socket, $port); $class->_initialize(); my $ctx = Net::SSLeay::CTX_new() or die_now("Failed to create SSL_CTX $!"); my $ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!"); my $fileno = fileno($socket); Net::SSLeay::set_fd($ssl, $fileno); # Must use fileno my $resp = Net::SSLeay::connect($ssl); $Debug and print "Cipher '" . Net::SSLeay::get_cipher($ssl) . "'\n"; my $self = bless { ssl => $ssl, ctx => $ctx, socket => $socket, fileno => $fileno, }, $class; return $self; } sub PRINT { my $self = shift; my $ssl = _get_ssl($self); my $resp = 0; for my $msg (@_) { defined $msg or last; $resp = Net::SSLeay::write($ssl, $msg) or last; } return $resp; } sub READLINE { my $self = shift; my $ssl = _get_ssl($self); if (wantarray) { my @lines; while (my $line = Net::SSLeay::ssl_read_until($ssl)) { push @lines, $line; } return @lines; } else { my $line = Net::SSLeay::ssl_read_until($ssl); return $line ? $line : undef; } } sub READ { my ($self, $buf, $len, $offset) = \ (@_); my $ssl = _get_ssl($$self); defined($$offset) or return length($$buf = Net::SSLeay::ssl_read_all($ssl, $$len)); defined(my $read = Net::SSLeay::ssl_read_all($ssl, $$len)) or return undef; my $buf_len = length($$buf); $$offset > $buf_len and $$buf .= chr(0) x ($$offset - $buf_len); substr($$buf, $$offset) = $read; return length($read); } sub WRITE { my $self = shift; my ($buf, $len, $offset) = @_; $offset = 0 unless defined $offset; # Return number of characters written. my $ssl = $self->_get_ssl(); return $len if Net::SSLeay::write($ssl, substr($buf, $offset, $len)); return undef; } sub CLOSE { my $self = shift; my $fileno = $self->{fileno}; $Debug > 10 and print "close($fileno)\n"; Net::SSLeay::free ($self->{ssl}); Net::SSLeay::CTX_free ($self->{ctx}); close $self->{socket}; } sub FILENO { $_[0]->{fileno} } =head1 FUNCTIONS =over =item shutdown shutdown(\*SOCKET, $mode) Calls to the main shutdown() don't work with tied sockets created with this module. This shutdown should be able to distinquish between tied and untied sockets and do the right thing. =cut sub shutdown { my ($obj, @params) = @_; my $socket = UNIVERSAL::isa($obj, 'Net::SSLeay::Handle') ? $obj->{socket} : $obj; return shutdown($socket, @params); } =item debug my $debug = Net::SSLeay::Handle->debug() Net::SSLeay::Handle->debug(1) Get/set debugging mode. Always returns the debug value before the function call. if an additional argument is given the debug option will be set to this value. =cut sub debug { my ($class, $debug) = @_; my $old_debug = $Debug; @_ >1 and $Debug = $debug || 0; return $old_debug; } #=== Internal Methods ========================================================= =item make_socket my $sock = Net::SSLeay::Handle->make_socket($host, $port); Creates a socket that is connected to $post using $port. It uses $Net::SSLeay::proxyhost and proxyport if set and authentificates itself against this proxy depending on $Net::SSLeay::proxyauth. It also turns autoflush on for the created socket. =cut sub make_socket { my ($class, $host, $port) = @_; $Debug > 10 and print "_make_socket(@{[join ', ', @_]})\n"; $host ||= 'localhost'; $port ||= 443; my $phost = $Net::SSLeay::proxyhost; my $pport = $Net::SSLeay::proxyhost ? $Net::SSLeay::proxyport : $port; my $dest_ip = gethostbyname($phost || $host); my $host_params = sockaddr_in($pport, $dest_ip); socket(my $socket, &PF_INET(), &SOCK_STREAM(), 0) or die "socket: $!"; connect($socket, $host_params) or die "connect: $!"; my $old_select = select($socket); $| = 1; select($old_select); $phost and do { my $auth = $Net::SSLeay::proxyauth; my $CRLF = $Net::SSLeay::CRLF; print $socket "CONNECT $host:$port HTTP/1.0$auth$CRLF$CRLF"; my $line = <$socket>; }; return $socket; } =back =cut sub _initialize { $Initialized++ and return; Net::SSLeay::load_error_strings(); Net::SSLeay::SSLeay_add_ssl_algorithms(); Net::SSLeay::randomize(); } sub __dummy { my $host = $Net::SSLeay::proxyhost; my $port = $Net::SSLeay::proxyport; my $auth = $Net::SSLeay::proxyauth; } #--- _get_self($socket) ------------------------------------------------------- # Returns a hash containing attributes for $socket (= \*SOMETHING) based # on fileno($socket). Will return undef if $socket was not created here. #------------------------------------------------------------------------------ sub _get_self { return $_[0]; } #--- _get_ssl($socket) -------------------------------------------------------- # Returns a the "ssl" attribute for $socket (= \*SOMETHING) based # on fileno($socket). Will cause a warning and return undef if $socket was not # created here. #------------------------------------------------------------------------------ sub _get_ssl { return $_[0]->{ssl}; } 1; __END__ =head2 USING EXISTING SOCKETS One of the motivations for writing this module was to avoid duplicating socket creation code (which is mostly error handling). The calls to tie() above where it is passed a $host and $port is provided for convenience testing. If you already have a socket connected to the right host and port, S1, then you can do something like: my $socket \*S1; if ($scheme eq "https") { tie(*S2, "Net::SSLeay::Handle", $socket); $socket = \*S2; } my $last_sel = select($socket); $| = 1; select($last_sel); print $socket $request_headers; ... Note: As far as I know you must be careful with the globs in the tie() function. The first parameter must be a glob (*SOMETHING) and the last parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler that was assigned to a reference to a glob (as in the example above) Also, the two globs must be different. When I tried to use the same glob, I got a core dump. =head2 EXPORT None by default. You can export the shutdown() function. It is suggested that you do export shutdown() or use the fully qualified Net::SSLeay::Handle::shutdown() function to shutdown SSL sockets. It should be smart enough to distinguish between SSL and non-SSL sockets and do the right thing. =head1 EXAMPLES use Net::SSLeay::Handle qw/shutdown/; my ($host, $port) = ("localhost", 443); tie(*SSL, "Net::SSLeay::Handle", $host, $port); print SSL "GET / HTTP/1.0\r\n"; shutdown(\*SSL, 1); print while (<SSL>); close SSL; =head1 TODO Better error handling. Callback routine? =head1 CAVEATS Tying to a file handle is a little tricky (for me at least). The first parameter to tie() must be a glob (*SOMETHING) and the last parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler that was assigned to a reference to a glob ($s = \*SOMETHING_ELSE). Also, the two globs must be different. When I tried to use the same glob, I got a core dump. I was able to associate attributes to globs created by this module (like *SSL above) by making a hash of hashes keyed by the file head1. =head1 CHANGES Please see Net-SSLeay-Handle-0.50/Changes file. =head1 BUGS If you encounter a problem with this module that you believe is a bug, please L<create a new issue|https://github.com/radiator-software/p5-net-ssleay/issues/new> in the Net-SSLeay GitHub repository. Please make sure your bug report includes the following information: =over =item * the code you are trying to run; =item * your operating system name and version; =item * the output of C<perl -V>; =item * the version of OpenSSL or LibreSSL you are using. =back =head1 AUTHOR Originally written by Jim Bowlin. Maintained by Sampo Kellomäki between July 2001 and August 2003. Maintained by Florian Ragwitz between November 2005 and January 2010. Maintained by Mike McCauley between November 2005 and June 2018. Maintained by Tuure Vartiainen between June 2018 and July 2018. Maintained by Chris Novakovic and Heikki Vatiainen since June 2018. =head1 COPYRIGHT Copyright (c) 2001 Jim Bowlin <jbowlin@linklint.org> Copyright (c) 2001-2003 Sampo Kellomäki <sampo@iki.fi> Copyright (c) 2005-2010 Florian Ragwitz <rafl@debian.org> Copyright (c) 2005-2018 Mike McCauley <mikem@airspayce.com> Copyright (c) 2018 Tuure Vartiainen <vartiait@radiatorsoftware.com> Copyright (c) 2018- Chris Novakovic <chris@chrisn.me.uk> Copyright (c) 2018- Heikki Vatiainen <hvn@radiatorsoftware.com> All rights reserved. =head1 LICENSE This module is released under the terms of the Artistic License 2.0. For details, see the C<LICENSE> file distributed with Net-SSLeay's source code. =head1 SEE ALSO Net::SSLeay, perl(1), http://openssl.org/ =cut usr/share/perl5/vendor_perl/TAP/Parser/SourceHandler/Handle.pm 0000644 00000005133 15132213134 0020171 0 ustar 00 package TAP::Parser::SourceHandler::Handle; use strict; use warnings; use TAP::Parser::IteratorFactory (); use TAP::Parser::Iterator::Stream (); use base 'TAP::Parser::SourceHandler'; TAP::Parser::IteratorFactory->register_handler(__PACKAGE__); =head1 NAME TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB. =head1 VERSION Version 3.42 =cut our $VERSION = '3.42'; =head1 SYNOPSIS use TAP::Parser::Source; use TAP::Parser::SourceHandler::Executable; my $source = TAP::Parser::Source->new->raw( \*TAP_FILE ); $source->assemble_meta; my $class = 'TAP::Parser::SourceHandler::Handle'; my $vote = $class->can_handle( $source ); my $iter = $class->make_iterator( $source ); =head1 DESCRIPTION This is a I<raw TAP stored in an IO Handle> L<TAP::Parser::SourceHandler> class. It has 2 jobs: 1. Figure out if the L<TAP::Parser::Source> it's given is an L<IO::Handle> or GLOB containing raw TAP output (L</can_handle>). 2. Creates an iterator for IO::Handle's & globs (L</make_iterator>). Unless you're writing a plugin or subclassing L<TAP::Parser>, you probably won't need to use this module directly. =head1 METHODS =head2 Class Methods =head3 C<can_handle> my $vote = $class->can_handle( $source ); Casts the following votes: 0.9 if $source is an IO::Handle 0.8 if $source is a glob =cut sub can_handle { my ( $class, $src ) = @_; my $meta = $src->meta; return 0.9 if $meta->{is_object} && UNIVERSAL::isa( $src->raw, 'IO::Handle' ); return 0.8 if $meta->{is_glob}; return 0; } =head3 C<make_iterator> my $iterator = $class->make_iterator( $source ); Returns a new L<TAP::Parser::Iterator::Stream> for the source. =cut sub make_iterator { my ( $class, $source ) = @_; $class->_croak('$source->raw must be a glob ref or an IO::Handle') unless $source->meta->{is_glob} || UNIVERSAL::isa( $source->raw, 'IO::Handle' ); return $class->iterator_class->new( $source->raw ); } =head3 C<iterator_class> The class of iterator to use, override if you're sub-classing. Defaults to L<TAP::Parser::Iterator::Stream>. =cut use constant iterator_class => 'TAP::Parser::Iterator::Stream'; 1; =head1 SUBCLASSING Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview. =head1 SEE ALSO L<TAP::Object>, L<TAP::Parser>, L<TAP::Parser::Iterator>, L<TAP::Parser::Iterator::Stream>, L<TAP::Parser::IteratorFactory>, L<TAP::Parser::SourceHandler>, L<TAP::Parser::SourceHandler::Executable>, L<TAP::Parser::SourceHandle
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????