summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/ext/IO
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-04-06 16:11:09 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-04-06 16:11:09 +0000
commite852ed17d905386f3bbad057fda2f07926227f89 (patch)
tree9c602984a369e27373c3cd3b71bd8c8e791393f2 /gnu/usr.bin/perl/ext/IO
parent9cfdf10e50d1f9e72606c75c7b7a0e18940c80aa (diff)
virgin perl 5.6.0
Diffstat (limited to 'gnu/usr.bin/perl/ext/IO')
-rw-r--r--gnu/usr.bin/perl/ext/IO/ChangeLog318
-rw-r--r--gnu/usr.bin/perl/ext/IO/lib/IO/Dir.pm239
-rw-r--r--gnu/usr.bin/perl/ext/IO/lib/IO/Poll.pm205
-rw-r--r--gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm406
-rw-r--r--gnu/usr.bin/perl/ext/IO/lib/IO/Socket/UNIX.pm143
-rw-r--r--gnu/usr.bin/perl/ext/IO/poll.c135
-rw-r--r--gnu/usr.bin/perl/ext/IO/poll.h55
7 files changed, 1501 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/ext/IO/ChangeLog b/gnu/usr.bin/perl/ext/IO/ChangeLog
new file mode 100644
index 00000000000..c45e7853264
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/ChangeLog
@@ -0,0 +1,318 @@
+For more recent changes, see the Perl Changes* file(s).
+
+Change 173 on 1998/07/14 by <gbarr@pobox.com> (Graham Barr)
+
+ IO::Socket
+ - Added method connected
+
+ IO.xs
+ - Added check that file * is not null
+
+ t/io_udp.t
+ - Added check for connected
+ - Made change to catch recv not returning the address, and added a fix to
+ ensure test does not hang
+
+ t/io_sock.t
+ - Added check for connected.
+
+Change 137 on 1998/05/21 by <gbarr@pobox.com> (Graham Barr)
+
+ IO::Socket::INET
+ - Added checks to all peer* and host* methods for undef
+
+Change 134 on 1998/05/09 by <gbarr@pobox.com> (Graham Barr)
+
+ t/io_sock.t
+ - fix race condition on Solaris & SunOS
+
+ IO::Handle
+ - Applied patch from Gisle Aas <gisle@aas.no> for
+ documentation update
+ - Applied patch from Kuma <tgy@chocobo.org>
+ changed input_line_number to be on a per-handle basis.
+
+ IO::File
+ - Applied patch from Gisle Aas <gisle@aas.no> for
+ documentation update
+
+ IO::Seekable
+ - Applied patch from Gisle Aas <gisle@aas.no> for
+ documentation update
+ added sysseek
+
+ IO, IO::Socket::INET
+ - documentation update
+
+ IO.xs
+ - Applied patch from Gisle Aas <gisle@aas.no> for
+ blocking
+
+Change 133 on 1998/05/09 by <gbarr@pobox.com> (Graham Barr)
+
+ t/io_sock.t
+ - Added checks for blocking()
+
+Sun Apr 12 1998 <gbarr@pobox.com> (Graham Barr)
+
+ IO.xs
+ - enclosed newCONSTSUB in #ifdef as _64 now defines it.
+
+Thu Mar 19 1998 <gbarr@pobox.com> (Graham Barr)
+
+ All
+ - Changed copyright/distribution policy back to be the same as perl
+
+Sun Feb 15 1998 <gbarr@pobox.com> (Graham Barr)
+
+ IO::Socket
+ - Fix to ->accept, accept() returns false on error not undef.
+
+*** Release 1.19
+
+Thu Feb 5 1998 <gbarr@pobox.com> (Graham Barr)
+
+ All
+ - change copyright notice
+
+ IO::Socket::INET
+ - changed configure to accept PeerHost and LocalHost as well as the
+ PeerAddr and LocalAddr arguments.
+
+Mon Feb 2 1998 <gbarr@pobox.com> (Graham Barr)
+
+ IO::Handle
+ - Added printflush so that flush.pl can be depreciated
+
+ IO::Socket
+ - Remove C<use Config> statement as it was not needed
+
+Tue Jan 27 1998 <gbarr@pobox.com> (Graham Barr)
+
+ IO::Socket::INET
+ - removed carp if $^W
+
+*** Patch 1.1804
+
+Sat Jan 17 1998 <gbarr@pobox.com> (Graham Barr)
+
+ t/io_sock.t
+ - Replaced C<Listen => 0> with C<LocalAddr => 'localhost'>
+
+ IO/Socket/INET.pm
+ - Modified the MultiHomed code. Now each address for a given host has
+ a timeout of C<Timeout>.
+ - added _get_addr method for doing hostname lookups. Now Net::DNS can be
+ use by sub-classing IO::Socket::INET, Thanks Gisle Aas
+
+ t/io_multihomed.t
+ - new test added. Thanks Gisle Aas.
+
+*** Patch 1.1803
+
+Mon Nov 17 1997 <gbarr@pobox.com> (Graham Barr)
+
+ poll.c
+ - Added #ifdef I_* tests
+
+ IO::Socket
+ - Changed initialization of @domain2pkg to fix problem of Domain option
+ not working
+ - Added patch for multi-homed hosts, Thanks to Gisle Aas <gisle@aas.no>
+
+ IO::Socket::INET
+ - Change default proto to getprotobyname instead of 'tcp' constant string
+ - Added patch for multi-homed hosts, Thanks to Gisle Aas <gisle@aas.no>
+
+ t/io_sock.t
+ - Change to test fix for Domain problem fixed in IO::Socket and be
+ more comprehensive, Thanks to Gisle Aas <gisle@aas.no>
+
+ t/io_unix.t
+ - New test, Thanks to Gisle Aas <gisle@aas.no>
+
+*** Patch 1.1802
+
+Wed Nov 12 1997 <gbarr@pobox.com> (Graham Barr)
+
+ t/io_poll.t
+ - test 4 made an assumption that was not portable, fixed.
+
+*** Patch 1.1801
+
+Wed Oct 22 1997 <gbarr@pobox.com> (Graham Barr)
+
+ IO.xs
+ - change #ifdef's to allow compilation with 5.002
+
+ IO::Socket
+ - Fix to ensure that socket is not returned as non-blocking
+ unless the user asks for it
+
+ t/io_udp.t
+ - Fix to stop endless loop
+
+*** Release 1.18
+
+Mon Oct 13 1997 <gbarr@pobox.com> (Graham Barr)
+
+ IO.xs, IO::Handle
+ - 1.17 broke compatability with 5.003, small tweaks to restore
+ compatability
+
+ t/io_const.t
+ - Added new test to ensure backwards compatability with constants
+ is not broken
+
+Wed Oct 8 1997 <gbarr@pobox.com> (Graham Barr)
+
+ IO.xs
+ - Added #define's to cope with argument changes to start_subparse
+ from 5.003_22, _23 and _24
+
+ IO::Select
+ - Renamed has_error to be has_exception which is more correct,
+ has_error is a wrapper around has_exception with a warning if
+ $^W is set.
+
+ Makefile.PL
+ - Remove 'linkext' option to WriteMakefile so that static linking
+ should work properly, cannot remember why I added it.
+
+Sun Oct 5 1997 <gbarr@pobox.com> (Graham Barr)
+
+ IO::Pipe
+ - GLOB assignment does not copy the fileno while under -T
+ added checks for undefined fileno, and added fdopen
+ - reader and write can now be called as static methods
+
+ Makefile.PL
+ - Attempt to locate <poll.h> and define I_POLL if found
+
+*** Release 1.17
+
+Fri Sep 26 1997 <gbarr@pobox.com> (Graham Barr)
+
+ IO.xs
+ - Fix bug in _poll for ANSI C compilers
+
+ IO::Socket
+ - Split IO::Socket::INET and IO::Socket::UNIX into separate files
+
+ IO::File
+ - Patch to open() for when file is in current directory.
+
+*** Release 1.16
+
+Mon 15 Sep 1997 <gbarr@pobox.com> Graham Barr
+
+ o New modules
+ - IO::Dir
+ - IO::Poll
+
+ o IO::Socket
+ - Changed new to call autoflush on the new socket
+ - IO::Socket::INET->new now accepts a single argument
+ - IO::Socket::INET default to protocol 'tcp'
+
+ o IO::File
+ - Added doc for new_tmpfile
+
+ o IO::Handle
+ - Removed use of AutoLoader for constants, constants are
+ now defined as constant XS subs
+ - Added fsync, but will not be avaliable for use
+ unless HAS_FSYNC is defined, perls configure does not define
+ this yet.
+ - Moved bootstrap of IO.xs to IO.pm. IO::Handle no longer
+ contains an AUTOLOAD sub in it's ISA hier
+
+ o IO::Seekable
+ - Remove clearerr, as it is defined in IO.xs
+
+ o IO.xs
+ - Patched IO.xs with patch from Chip for setvbuf warning
+ - Added XS sub "constant" for backwards compatability
+
+ o Misc
+ - Fixed IO::Socket::configure, it was not passing $arg to domain
+ specific package
+ - Changed all $fh variables in IO::Handle to $io and all $fh
+ variables in IO::Socket to $sock as Chip suggested
+ - Fixed usage messages to be consistant
+
+*** Release 1.15
+
+Sun 19 Jan 1997 <bodg@tiuk.ti.com> Graham Barr
+
+ o Updated PODs for IO::Handle and IO::File
+ o Modified IO.xs so that DESTROY gets called on IO::File
+ objects that were created with IO::File->new_tmpfile
+ o Modified the domain2pkg code in IO::Socket so that it
+ does not use blessd refs
+ o Created a new package IO::Pipe::End so that pipe specific
+ stuff can be moved out of IO::Handle.
+ o Added Ilya's OS/2 changes to Pipe.pm and io_pipe.t
+
+ o These changes happened somtime before the release of 1.15
+ - added shutdown to IO::Socket
+ - modified connect to not use alarm
+ - modified accept and connect to use IO::Select
+
+*** Release 1.14
+
+Tue 24 Dec 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o Updated to patches in perl core dist.
+ o Added C<use strict> to all modules
+ o Modified t/io_sock.t, hopefully the race condition has gone
+ o Added close statements to reader/writer in IO::Pipe
+ o IO::Handle::syswrite was calling sysread, fixed :-)
+
+*** Release 1.12
+
+Thu 19 Sep 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o Modified IO.xs so that it will compile with pre perlio version
+ of perl (ie pre perl5.003_02)
+ o Modified IO::Socket::send so not to pass 4 arguments to send
+ if the socket is connected
+
+*** Release 1.10
+
+Mon 11 Sep 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o Fixed a bug in IO::Socket which caused DESTROY to be called
+ on a partly initialised connection
+ o Changed IO.xs to use Perlio
+ o Modified usage message to report correct package
+ o Added IO::File::new changes from Chip, to allow PERM to be passed
+ o Added sysread and syswrite methods to IO::Handle
+ o Updated documentation
+ o Fixed a bug in IO::Select that caused a hang if the last handle
+ was removed.
+ o Added count method to IO::Select
+ o Renamed and modified tests so that they can be copied into the
+ perl distribution
+ o Added fcntl and ioctl methods to IO::Handle
+
+Thu 25 Jul 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o It is now not necessary to call the domain sub-classes of
+ IO::Socket. when connect is called it notes the domain.
+ Domain specific methods, which are normally non-critical, are
+ called via this note-ing.
+ o Added methods to IO::Socket to retrieve the domain, type and
+ protocol of a given socket
+
+Tue 23 Jul 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o IO::Socket::connect changed how we do timeouts, as it did not work
+
+ o IO::Handle::new_from_fd removed method call to _ref_fd, which was
+ a leftover from FileHandle
+
+Fri 28 Jun 1996 <bodg@tiuk.ti.com> Graham Barr
+
+ o Modified IO::Socket::UNIX::configure to default to using a socket
+ type of SOCK_STREAM if no type is specified.
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Dir.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Dir.pm
new file mode 100644
index 00000000000..1fa07ed6b8b
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Dir.pm
@@ -0,0 +1,239 @@
+# IO::Dir.pm
+#
+# Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+
+package IO::Dir;
+
+use 5.003_26;
+
+use strict;
+use Carp;
+use Symbol;
+use Exporter;
+use IO::File;
+our(@ISA, $VERSION, @EXPORT_OK);
+use Tie::Hash;
+use File::stat;
+
+@ISA = qw(Tie::Hash Exporter);
+$VERSION = "1.03";
+@EXPORT_OK = qw(DIR_UNLINK);
+
+sub DIR_UNLINK () { 1 }
+
+sub new {
+ @_ >= 1 && @_ <= 2 or croak 'usage: new IO::Dir [DIRNAME]';
+ my $class = shift;
+ my $dh = gensym;
+ if (@_) {
+ IO::Dir::open($dh, $_[0])
+ or return undef;
+ }
+ bless $dh, $class;
+}
+
+sub DESTROY {
+ my ($dh) = @_;
+ closedir($dh);
+}
+
+sub open {
+ @_ == 2 or croak 'usage: $dh->open(DIRNAME)';
+ my ($dh, $dirname) = @_;
+ return undef
+ unless opendir($dh, $dirname);
+ ${*$dh}{io_dir_path} = $dirname;
+ 1;
+}
+
+sub close {
+ @_ == 1 or croak 'usage: $dh->close()';
+ my ($dh) = @_;
+ closedir($dh);
+}
+
+sub read {
+ @_ == 1 or croak 'usage: $dh->read()';
+ my ($dh) = @_;
+ readdir($dh);
+}
+
+sub seek {
+ @_ == 2 or croak 'usage: $dh->seek(POS)';
+ my ($dh,$pos) = @_;
+ seekdir($dh,$pos);
+}
+
+sub tell {
+ @_ == 1 or croak 'usage: $dh->tell()';
+ my ($dh) = @_;
+ telldir($dh);
+}
+
+sub rewind {
+ @_ == 1 or croak 'usage: $dh->rewind()';
+ my ($dh) = @_;
+ rewinddir($dh);
+}
+
+sub TIEHASH {
+ my($class,$dir,$options) = @_;
+
+ my $dh = $class->new($dir)
+ or return undef;
+
+ $options ||= 0;
+
+ ${*$dh}{io_dir_unlink} = $options & DIR_UNLINK;
+ $dh;
+}
+
+sub FIRSTKEY {
+ my($dh) = @_;
+ $dh->rewind;
+ scalar $dh->read;
+}
+
+sub NEXTKEY {
+ my($dh) = @_;
+ scalar $dh->read;
+}
+
+sub EXISTS {
+ my($dh,$key) = @_;
+ -e ${*$dh}{io_dir_path} . "/" . $key;
+}
+
+sub FETCH {
+ my($dh,$key) = @_;
+ &lstat(${*$dh}{io_dir_path} . "/" . $key);
+}
+
+sub STORE {
+ my($dh,$key,$data) = @_;
+ my($atime,$mtime) = ref($data) ? @$data : ($data,$data);
+ my $file = ${*$dh}{io_dir_path} . "/" . $key;
+ unless(-e $file) {
+ my $io = IO::File->new($file,O_CREAT | O_RDWR);
+ $io->close if $io;
+ }
+ utime($atime,$mtime, $file);
+}
+
+sub DELETE {
+ my($dh,$key) = @_;
+ # Only unlink if unlink-ing is enabled
+ my $file = ${*$dh}{io_dir_path} . "/" . $key;
+
+ return 0
+ unless ${*$dh}{io_dir_unlink};
+
+ -d $file
+ ? rmdir($file)
+ : unlink($file);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+IO::Dir - supply object methods for directory handles
+
+=head1 SYNOPSIS
+
+ use IO::Dir;
+ $d = new IO::Dir ".";
+ if (defined $d) {
+ while (defined($_ = $d->read)) { something($_); }
+ $d->rewind;
+ while (defined($_ = $d->read)) { something_else($_); }
+ undef $d;
+ }
+
+ tie %dir, IO::Dir, ".";
+ foreach (keys %dir) {
+ print $_, " " , $dir{$_}->size,"\n";
+ }
+
+=head1 DESCRIPTION
+
+The C<IO::Dir> package provides two interfaces to perl's directory reading
+routines.
+
+The first interface is an object approach. C<IO::Dir> provides an object
+constructor and methods, which are just wrappers around perl's built in
+directory reading routines.
+
+=over 4
+
+=item new ( [ DIRNAME ] )
+
+C<new> is the constuctor for C<IO::Dir> objects. It accepts one optional
+argument which, if given, C<new> will pass to C<open>
+
+=back
+
+The following methods are wrappers for the directory related functions built
+into perl (the trailing `dir' has been removed from the names). See L<perlfunc>
+for details of these functions.
+
+=over 4
+
+=item open ( DIRNAME )
+
+=item read ()
+
+=item seek ( POS )
+
+=item tell ()
+
+=item rewind ()
+
+=item close ()
+
+=back
+
+C<IO::Dir> also provides a interface to reading directories via a tied
+HASH. The tied HASH extends the interface beyond just the directory
+reading routines by the use of C<lstat>, from the C<File::stat> package,
+C<unlink>, C<rmdir> and C<utime>.
+
+=over 4
+
+=item tie %hash, IO::Dir, DIRNAME [, OPTIONS ]
+
+=back
+
+The keys of the HASH will be the names of the entries in the directory.
+Reading a value from the hash will be the result of calling
+C<File::stat::lstat>. Deleting an element from the hash will call C<unlink>
+providing that C<DIR_UNLINK> is passed in the C<OPTIONS>.
+
+Assigning to an entry in the HASH will cause the time stamps of the file
+to be modified. If the file does not exist then it will be created. Assigning
+a single integer to a HASH element will cause both the access and
+modification times to be changed to that value. Alternatively a reference to
+an array of two values can be passed. The first array element will be used to
+set the access time and the second element will be used to set the modification
+time.
+
+=head1 SEE ALSO
+
+L<File::stat>
+
+=head1 AUTHOR
+
+Graham Barr. Currently maintained by the Perl Porters. Please report all
+bugs to <perl5-porters@perl.org>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Poll.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Poll.pm
new file mode 100644
index 00000000000..687664b9abf
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Poll.pm
@@ -0,0 +1,205 @@
+# IO::Poll.pm
+#
+# Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+
+package IO::Poll;
+
+use strict;
+use IO::Handle;
+use Exporter ();
+our(@ISA, @EXPORT_OK, @EXPORT, $VERSION);
+
+@ISA = qw(Exporter);
+$VERSION = "0.01";
+
+@EXPORT = qw(poll);
+
+@EXPORT_OK = qw(
+ POLLIN
+ POLLPRI
+ POLLOUT
+ POLLRDNORM
+ POLLWRNORM
+ POLLRDBAND
+ POLLWRBAND
+ POLLNORM
+ POLLERR
+ POLLHUP
+ POLLNVAL
+);
+
+sub new {
+ my $class = shift;
+
+ my $self = bless [{},{}], $class;
+
+ $self;
+}
+
+sub mask {
+ my $self = shift;
+ my $io = shift;
+ my $fd = fileno($io);
+ if(@_) {
+ my $mask = shift;
+ $self->[0]{$fd} ||= {};
+ if($mask) {
+ $self->[0]{$fd}{$io} = $mask;
+ }
+ else {
+ delete $self->[0]{$fd}{$io};
+ }
+ }
+ elsif(exists $self->[0]{$fd}{$io}) {
+ return $self->[0]{$fd}{$io};
+ }
+ return;
+}
+
+
+sub poll {
+ my($self,$timeout) = @_;
+
+ $self->[1] = {};
+
+ my($fd,$ref);
+ my @poll = ();
+
+ while(($fd,$ref) = each %{$self->[0]}) {
+ my $events = 0;
+ map { $events |= $_ } values %{$ref};
+ push(@poll,$fd, $events);
+ }
+
+ my $ret = @poll ? _poll(defined($timeout) ? $timeout * 1000 : -1,@poll) : 0;
+
+ return $ret
+ unless $ret > 0;
+
+ while(@poll) {
+ my($fd,$got) = splice(@poll,0,2);
+ $self->[1]{$fd} = $got
+ if $got;
+ }
+
+ return $ret;
+}
+
+sub events {
+ my $self = shift;
+ my $io = shift;
+ my $fd = fileno($io);
+
+ exists $self->[1]{$fd} && exists $self->[0]{$fd}{$io}
+ ? $self->[1]{$fd} & $self->[0]{$fd}{$io}
+ : 0;
+}
+
+sub remove {
+ my $self = shift;
+ my $io = shift;
+ $self->mask($io,0);
+}
+
+sub handles {
+ my $self = shift;
+
+ return map { keys %$_ } values %{$self->[0]}
+ unless(@_);
+
+ my $events = shift || 0;
+ my($fd,$ev,$io,$mask);
+ my @handles = ();
+
+ while(($fd,$ev) = each %{$self->[1]}) {
+ if($ev & $events) {
+ while(($io,$mask) = each %{$self->[0][$fd]}) {
+ push(@handles, $io)
+ if $events & $mask;
+ }
+ }
+ }
+ return @handles;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+IO::Poll - Object interface to system poll call
+
+=head1 SYNOPSIS
+
+ use IO::Poll qw(POLLRDNORM POLLWRNORM POLLIN POLLHUP);
+
+ $poll = new IO::Poll;
+
+ $poll->mask($input_handle => POLLRDNORM | POLLIN | POLLHUP);
+ $poll->mask($output_handle => POLLWRNORM);
+
+ $poll->poll($timeout);
+
+ $ev = $poll->events($input);
+
+=head1 DESCRIPTION
+
+C<IO::Poll> is a simple interface to the system level poll routine.
+
+=head1 METHODS
+
+=over 4
+
+=item mask ( IO [, EVENT_MASK ] )
+
+If EVENT_MASK is given, then, if EVENT_MASK is non-zero, IO is added to the
+list of file descriptors and the next call to poll will check for
+any event specified in EVENT_MASK. If EVENT_MASK is zero then IO will be
+removed from the list of file descriptors.
+
+If EVENT_MASK is not given then the return value will be the current
+event mask value for IO.
+
+=item poll ( [ TIMEOUT ] )
+
+Call the system level poll routine. If TIMEOUT is not specified then the
+call will block. Returns the number of handles which had events
+happen, or -1 on error.
+
+=item events ( IO )
+
+Returns the event mask which represents the events that happend on IO
+during the last call to C<poll>.
+
+=item remove ( IO )
+
+Remove IO from the list of file descriptors for the next poll.
+
+=item handles( [ EVENT_MASK ] )
+
+Returns a list of handles. If EVENT_MASK is not given then a list of all
+handles known will be returned. If EVENT_MASK is given then a list
+of handles will be returned which had one of the events specified by
+EVENT_MASK happen during the last call ti C<poll>
+
+=back
+
+=head1 SEE ALSO
+
+L<poll(2)>, L<IO::Handle>, L<IO::Select>
+
+=head1 AUTHOR
+
+Graham Barr. Currently maintained by the Perl Porters. Please report all
+bugs to <perl5-porters@perl.org>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm
new file mode 100644
index 00000000000..27a3d4d847e
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm
@@ -0,0 +1,406 @@
+# IO::Socket::INET.pm
+#
+# Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+
+package IO::Socket::INET;
+
+use strict;
+our(@ISA, $VERSION);
+use IO::Socket;
+use Socket;
+use Carp;
+use Exporter;
+use Errno;
+
+@ISA = qw(IO::Socket);
+$VERSION = "1.25";
+
+my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1;
+
+IO::Socket::INET->register_domain( AF_INET );
+
+my %socket_type = ( tcp => SOCK_STREAM,
+ udp => SOCK_DGRAM,
+ icmp => SOCK_RAW
+ );
+
+sub new {
+ my $class = shift;
+ unshift(@_, "PeerAddr") if @_ == 1;
+ return $class->SUPER::new(@_);
+}
+
+sub _sock_info {
+ my($addr,$port,$proto) = @_;
+ my @proto = ();
+ my @serv = ();
+
+ $port = $1
+ if(defined $addr && $addr =~ s,:([\w\(\)/]+)$,,);
+
+ if(defined $proto) {
+ if (@proto = ( $proto =~ m,\D,
+ ? getprotobyname($proto)
+ : getprotobynumber($proto))
+ ) {
+ $proto = $proto[2] || undef;
+ }
+ else {
+ $@ = "Bad protocol '$proto'";
+ return;
+ }
+ }
+
+ if(defined $port) {
+ $port =~ s,\((\d+)\)$,,;
+
+ my $defport = $1 || undef;
+ my $pnum = ($port =~ m,^(\d+)$,)[0];
+
+ if ($port =~ m,\D,) {
+ unless (@serv = getservbyname($port, $proto[0] || "")) {
+ $@ = "Bad service '$port'";
+ return;
+ }
+ }
+
+ $port = $pnum || $serv[2] || $defport || undef;
+
+ $proto = (getprotobyname($serv[3]))[2] || undef
+ if @serv && !$proto;
+ }
+
+ return ($addr || undef,
+ $port || undef,
+ $proto || undef
+ );
+}
+
+sub _error {
+ my $sock = shift;
+ my $err = shift;
+ {
+ local($!);
+ $@ = join("",ref($sock),": ",@_);
+ close($sock)
+ if(defined fileno($sock));
+ }
+ $! = $err;
+ return undef;
+}
+
+sub _get_addr {
+ my($sock,$addr_str, $multi) = @_;
+ my @addr;
+ if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
+ (undef, undef, undef, undef, @addr) = gethostbyname($addr_str);
+ } else {
+ my $h = inet_aton($addr_str);
+ push(@addr, $h) if defined $h;
+ }
+ @addr;
+}
+
+sub configure {
+ my($sock,$arg) = @_;
+ my($lport,$rport,$laddr,$raddr,$proto,$type);
+
+
+ $arg->{LocalAddr} = $arg->{LocalHost}
+ if exists $arg->{LocalHost} && !exists $arg->{LocalAddr};
+
+ ($laddr,$lport,$proto) = _sock_info($arg->{LocalAddr},
+ $arg->{LocalPort},
+ $arg->{Proto})
+ or return _error($sock, $!, $@);
+
+ $laddr = defined $laddr ? inet_aton($laddr)
+ : INADDR_ANY;
+
+ return _error($sock, $EINVAL, "Bad hostname '",$arg->{LocalAddr},"'")
+ unless(defined $laddr);
+
+ $arg->{PeerAddr} = $arg->{PeerHost}
+ if exists $arg->{PeerHost} && !exists $arg->{PeerAddr};
+
+ unless(exists $arg->{Listen}) {
+ ($raddr,$rport,$proto) = _sock_info($arg->{PeerAddr},
+ $arg->{PeerPort},
+ $proto)
+ or return _error($sock, $!, $@);
+ }
+
+ $proto ||= (getprotobyname('tcp'))[2];
+
+ my $pname = (getprotobynumber($proto))[0];
+ $type = $arg->{Type} || $socket_type{$pname};
+
+ my @raddr = ();
+
+ if(defined $raddr) {
+ @raddr = $sock->_get_addr($raddr, $arg->{MultiHomed});
+ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
+ unless @raddr;
+ }
+
+ while(1) {
+
+ $sock->socket(AF_INET, $type, $proto) or
+ return _error($sock, $!, "$!");
+
+ if ($arg->{Reuse}) {
+ $sock->sockopt(SO_REUSEADDR,1) or
+ return _error($sock, $!, "$!");
+ }
+
+ if($lport || ($laddr ne INADDR_ANY) || exists $arg->{Listen}) {
+ $sock->bind($lport || 0, $laddr) or
+ return _error($sock, $!, "$!");
+ }
+
+ if(exists $arg->{Listen}) {
+ $sock->listen($arg->{Listen} || 5) or
+ return _error($sock, $!, "$!");
+ last;
+ }
+
+ # don't try to connect unless we're given a PeerAddr
+ last unless exists($arg->{PeerAddr});
+
+ $raddr = shift @raddr;
+
+ return _error($sock, $EINVAL, 'Cannot determine remote port')
+ unless($rport || $type == SOCK_DGRAM || $type == SOCK_RAW);
+
+ last
+ unless($type == SOCK_STREAM || defined $raddr);
+
+ return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'")
+ unless defined $raddr;
+
+# my $timeout = ${*$sock}{'io_socket_timeout'};
+# my $before = time() if $timeout;
+
+ if ($sock->connect(pack_sockaddr_in($rport, $raddr))) {
+# ${*$sock}{'io_socket_timeout'} = $timeout;
+ return $sock;
+ }
+
+ return _error($sock, $!, "Timeout")
+ unless @raddr;
+
+# if ($timeout) {
+# my $new_timeout = $timeout - (time() - $before);
+# return _error($sock,
+# (exists(&Errno::ETIMEDOUT) ? Errno::ETIMEDOUT() : $EINVAL),
+# "Timeout") if $new_timeout <= 0;
+# ${*$sock}{'io_socket_timeout'} = $new_timeout;
+# }
+
+ }
+
+ $sock;
+}
+
+sub connect {
+ @_ == 2 || @_ == 3 or
+ croak 'usage: $sock->connect(NAME) or $sock->connect(PORT, ADDR)';
+ my $sock = shift;
+ return $sock->SUPER::connect(@_ == 1 ? shift : pack_sockaddr_in(@_));
+}
+
+sub bind {
+ @_ == 2 || @_ == 3 or
+ croak 'usage: $sock->bind(NAME) or $sock->bind(PORT, ADDR)';
+ my $sock = shift;
+ return $sock->SUPER::bind(@_ == 1 ? shift : pack_sockaddr_in(@_))
+}
+
+sub sockaddr {
+ @_ == 1 or croak 'usage: $sock->sockaddr()';
+ my($sock) = @_;
+ my $name = $sock->sockname;
+ $name ? (sockaddr_in($name))[1] : undef;
+}
+
+sub sockport {
+ @_ == 1 or croak 'usage: $sock->sockport()';
+ my($sock) = @_;
+ my $name = $sock->sockname;
+ $name ? (sockaddr_in($name))[0] : undef;
+}
+
+sub sockhost {
+ @_ == 1 or croak 'usage: $sock->sockhost()';
+ my($sock) = @_;
+ my $addr = $sock->sockaddr;
+ $addr ? inet_ntoa($addr) : undef;
+}
+
+sub peeraddr {
+ @_ == 1 or croak 'usage: $sock->peeraddr()';
+ my($sock) = @_;
+ my $name = $sock->peername;
+ $name ? (sockaddr_in($name))[1] : undef;
+}
+
+sub peerport {
+ @_ == 1 or croak 'usage: $sock->peerport()';
+ my($sock) = @_;
+ my $name = $sock->peername;
+ $name ? (sockaddr_in($name))[0] : undef;
+}
+
+sub peerhost {
+ @_ == 1 or croak 'usage: $sock->peerhost()';
+ my($sock) = @_;
+ my $addr = $sock->peeraddr;
+ $addr ? inet_ntoa($addr) : undef;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+IO::Socket::INET - Object interface for AF_INET domain sockets
+
+=head1 SYNOPSIS
+
+ use IO::Socket::INET;
+
+=head1 DESCRIPTION
+
+C<IO::Socket::INET> provides an object interface to creating and using sockets
+in the AF_INET domain. It is built upon the L<IO::Socket> interface and
+inherits all the methods defined by L<IO::Socket>.
+
+=head1 CONSTRUCTOR
+
+=over 4
+
+=item new ( [ARGS] )
+
+Creates an C<IO::Socket::INET> object, which is a reference to a
+newly created symbol (see the C<Symbol> package). C<new>
+optionally takes arguments, these arguments are in key-value pairs.
+
+In addition to the key-value pairs accepted by L<IO::Socket>,
+C<IO::Socket::INET> provides.
+
+
+ PeerAddr Remote host address <hostname>[:<port>]
+ PeerHost Synonym for PeerAddr
+ PeerPort Remote port or service <service>[(<no>)] | <no>
+ LocalAddr Local host bind address hostname[:port]
+ LocalHost Synonym for LocalAddr
+ LocalPort Local host bind port <service>[(<no>)] | <no>
+ Proto Protocol name (or number) "tcp" | "udp" | ...
+ Type Socket type SOCK_STREAM | SOCK_DGRAM | ...
+ Listen Queue size for listen
+ Reuse Set SO_REUSEADDR before binding
+ Timeout Timeout value for various operations
+ MultiHomed Try all adresses for multi-homed hosts
+
+
+If C<Listen> is defined then a listen socket is created, else if the
+socket type, which is derived from the protocol, is SOCK_STREAM then
+connect() is called.
+
+Although it is not illegal, the use of C<MultiHomed> on a socket
+which is in non-blocking mode is of little use. This is because the
+first connect will never fail with a timeout as the connaect call
+will not block.
+
+The C<PeerAddr> can be a hostname or the IP-address on the
+"xx.xx.xx.xx" form. The C<PeerPort> can be a number or a symbolic
+service name. The service name might be followed by a number in
+parenthesis which is used if the service is not known by the system.
+The C<PeerPort> specification can also be embedded in the C<PeerAddr>
+by preceding it with a ":".
+
+If C<Proto> is not given and you specify a symbolic C<PeerPort> port,
+then the constructor will try to derive C<Proto> from the service
+name. As a last resort C<Proto> "tcp" is assumed. The C<Type>
+parameter will be deduced from C<Proto> if not specified.
+
+If the constructor is only passed a single argument, it is assumed to
+be a C<PeerAddr> specification.
+
+Examples:
+
+ $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org',
+ PeerPort => 'http(80)',
+ Proto => 'tcp');
+
+ $sock = IO::Socket::INET->new(PeerAddr => 'localhost:smtp(25)');
+
+ $sock = IO::Socket::INET->new(Listen => 5,
+ LocalAddr => 'localhost',
+ LocalPort => 9000,
+ Proto => 'tcp');
+
+ $sock = IO::Socket::INET->new('127.0.0.1:25');
+
+
+ NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+
+As of VERSION 1.18 all IO::Socket objects have autoflush turned on
+by default. This was not the case with earlier releases.
+
+ NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+
+=back
+
+=head2 METHODS
+
+=over 4
+
+=item sockaddr ()
+
+Return the address part of the sockaddr structure for the socket
+
+=item sockport ()
+
+Return the port number that the socket is using on the local host
+
+=item sockhost ()
+
+Return the address part of the sockaddr structure for the socket in a
+text form xx.xx.xx.xx
+
+=item peeraddr ()
+
+Return the address part of the sockaddr structure for the socket on
+the peer host
+
+=item peerport ()
+
+Return the port number for the socket on the peer host.
+
+=item peerhost ()
+
+Return the address part of the sockaddr structure for the socket on the
+peer host in a text form xx.xx.xx.xx
+
+=back
+
+=head1 SEE ALSO
+
+L<Socket>, L<IO::Socket>
+
+=head1 AUTHOR
+
+Graham Barr. Currently maintained by the Perl Porters. Please report all
+bugs to <perl5-porters@perl.org>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/UNIX.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/UNIX.pm
new file mode 100644
index 00000000000..d083f48b78f
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/UNIX.pm
@@ -0,0 +1,143 @@
+# IO::Socket::UNIX.pm
+#
+# Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+
+package IO::Socket::UNIX;
+
+use strict;
+our(@ISA, $VERSION);
+use IO::Socket;
+use Socket;
+use Carp;
+
+@ISA = qw(IO::Socket);
+$VERSION = "1.20";
+
+IO::Socket::UNIX->register_domain( AF_UNIX );
+
+sub new {
+ my $class = shift;
+ unshift(@_, "Peer") if @_ == 1;
+ return $class->SUPER::new(@_);
+}
+
+sub configure {
+ my($sock,$arg) = @_;
+ my($bport,$cport);
+
+ my $type = $arg->{Type} || SOCK_STREAM;
+
+ $sock->socket(AF_UNIX, $type, 0) or
+ return undef;
+
+ if(exists $arg->{Local}) {
+ my $addr = sockaddr_un($arg->{Local});
+ $sock->bind($addr) or
+ return undef;
+ }
+ if(exists $arg->{Listen}) {
+ $sock->listen($arg->{Listen} || 5) or
+ return undef;
+ }
+ elsif(exists $arg->{Peer}) {
+ my $addr = sockaddr_un($arg->{Peer});
+ $sock->connect($addr) or
+ return undef;
+ }
+
+ $sock;
+}
+
+sub hostpath {
+ @_ == 1 or croak 'usage: $sock->hostpath()';
+ my $n = $_[0]->sockname || return undef;
+ (sockaddr_un($n))[0];
+}
+
+sub peerpath {
+ @_ == 1 or croak 'usage: $sock->peerpath()';
+ my $n = $_[0]->peername || return undef;
+ (sockaddr_un($n))[0];
+}
+
+1; # Keep require happy
+
+__END__
+
+=head1 NAME
+
+IO::Socket::UNIX - Object interface for AF_UNIX domain sockets
+
+=head1 SYNOPSIS
+
+ use IO::Socket::UNIX;
+
+=head1 DESCRIPTION
+
+C<IO::Socket::UNIX> provides an object interface to creating and using sockets
+in the AF_UNIX domain. It is built upon the L<IO::Socket> interface and
+inherits all the methods defined by L<IO::Socket>.
+
+=head1 CONSTRUCTOR
+
+=over 4
+
+=item new ( [ARGS] )
+
+Creates an C<IO::Socket::UNIX> object, which is a reference to a
+newly created symbol (see the C<Symbol> package). C<new>
+optionally takes arguments, these arguments are in key-value pairs.
+
+In addition to the key-value pairs accepted by L<IO::Socket>,
+C<IO::Socket::UNIX> provides.
+
+ Type Type of socket (eg SOCK_STREAM or SOCK_DGRAM)
+ Local Path to local fifo
+ Peer Path to peer fifo
+ Listen Create a listen socket
+
+If the constructor is only passed a single argument, it is assumed to
+be a C<Peer> specification.
+
+
+ NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+
+As of VERSION 1.18 all IO::Socket objects have autoflush turned on
+by default. This was not the case with earlier releases.
+
+ NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item hostpath()
+
+Returns the pathname to the fifo at the local end
+
+=item peerpath()
+
+Returns the pathanme to the fifo at the peer end
+
+=back
+
+=head1 SEE ALSO
+
+L<Socket>, L<IO::Socket>
+
+=head1 AUTHOR
+
+Graham Barr. Currently maintained by the Perl Porters. Please report all
+bugs to <perl5-porters@perl.org>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
diff --git a/gnu/usr.bin/perl/ext/IO/poll.c b/gnu/usr.bin/perl/ext/IO/poll.c
new file mode 100644
index 00000000000..024c52ff9f4
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/poll.c
@@ -0,0 +1,135 @@
+/*
+ * poll.c
+ *
+ * Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the same terms as Perl itself.
+ *
+ * For systems that do not have the poll() system call (for example Linux
+ * kernels < v2.1.23) try to emulate it as closely as possible using select()
+ *
+ */
+
+#include "EXTERN.h"
+#include "perl.h"
+#include "poll.h"
+#ifdef I_SYS_TIME
+# include <sys/time.h>
+#endif
+#ifdef I_TIME
+# include <time.h>
+#endif
+#include <sys/types.h>
+#if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
+# include <sys/socket.h>
+#endif
+#include <sys/stat.h>
+#include <errno.h>
+
+#ifdef HAS_SELECT
+#ifdef I_SYS_SELECT
+#include <sys/select.h>
+#endif
+#endif
+
+#ifdef EMULATE_POLL_WITH_SELECT
+
+# define POLL_CAN_READ (POLLIN | POLLRDNORM )
+# define POLL_CAN_WRITE (POLLOUT | POLLWRNORM | POLLWRBAND )
+# define POLL_HAS_EXCP (POLLRDBAND | POLLPRI )
+
+# define POLL_EVENTS_MASK (POLL_CAN_READ | POLL_CAN_WRITE | POLL_HAS_EXCP)
+
+int
+poll(struct pollfd *fds, unsigned long nfds, int timeout)
+{
+ int i,err;
+ fd_set rfd,wfd,efd,ifd;
+ struct timeval timebuf;
+ struct timeval *tbuf = (struct timeval *)0;
+ int n = 0;
+ int count;
+
+ FD_ZERO(&ifd);
+
+again:
+
+ FD_ZERO(&rfd);
+ FD_ZERO(&wfd);
+ FD_ZERO(&efd);
+
+ for(i = 0 ; i < nfds ; i++) {
+ int events = fds[i].events;
+ int fd = fds[i].fd;
+
+ fds[i].revents = 0;
+
+ if(fd < 0 || FD_ISSET(fd, &ifd))
+ continue;
+
+ if(fd > n)
+ n = fd;
+
+ if(events & POLL_CAN_READ)
+ FD_SET(fd, &rfd);
+
+ if(events & POLL_CAN_WRITE)
+ FD_SET(fd, &wfd);
+
+ if(events & POLL_HAS_EXCP)
+ FD_SET(fd, &efd);
+ }
+
+ if(timeout >= 0) {
+ timebuf.tv_sec = timeout / 1000;
+ timebuf.tv_usec = (timeout % 1000) * 1000;
+ tbuf = &timebuf;
+ }
+
+ err = select(n+1,&rfd,&wfd,&efd,tbuf);
+
+ if(err < 0) {
+#ifdef HAS_FSTAT
+ if(errno == EBADF) {
+ for(i = 0 ; i < nfds ; i++) {
+ struct stat buf;
+ if((fstat(fds[i].fd,&buf) < 0) && (errno == EBADF)) {
+ FD_SET(fds[i].fd, &ifd);
+ goto again;
+ }
+ }
+ }
+#endif /* HAS_FSTAT */
+ return err;
+ }
+
+ count = 0;
+
+ for(i = 0 ; i < nfds ; i++) {
+ int revents = (fds[i].events & POLL_EVENTS_MASK);
+ int fd = fds[i].fd;
+
+ if(fd < 0)
+ continue;
+
+ if(FD_ISSET(fd, &ifd))
+ revents = POLLNVAL;
+ else {
+ if(!FD_ISSET(fd, &rfd))
+ revents &= ~POLL_CAN_READ;
+
+ if(!FD_ISSET(fd, &wfd))
+ revents &= ~POLL_CAN_WRITE;
+
+ if(!FD_ISSET(fd, &efd))
+ revents &= ~POLL_HAS_EXCP;
+ }
+
+ if((fds[i].revents = revents) != 0)
+ count++;
+ }
+
+ return count;
+}
+
+#endif /* EMULATE_POLL_WITH_SELECT */
diff --git a/gnu/usr.bin/perl/ext/IO/poll.h b/gnu/usr.bin/perl/ext/IO/poll.h
new file mode 100644
index 00000000000..4055b496248
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/IO/poll.h
@@ -0,0 +1,55 @@
+/*
+ * poll.h
+ *
+ * Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the same terms as Perl itself.
+ *
+ */
+
+#ifndef POLL_H
+# define POLL_H
+
+#if (defined(HAS_POLL) && defined(I_POLL)) || defined(POLLWRBAND)
+# include <poll.h>
+#else
+#ifdef HAS_SELECT
+
+
+/* We shall emulate poll using select */
+
+#define EMULATE_POLL_WITH_SELECT
+
+typedef struct pollfd {
+ int fd;
+ short events;
+ short revents;
+} pollfd_t;
+
+#define POLLIN 0x0001
+#define POLLPRI 0x0002
+#define POLLOUT 0x0004
+#define POLLRDNORM 0x0040
+#define POLLWRNORM POLLOUT
+#define POLLRDBAND 0x0080
+#define POLLWRBAND 0x0100
+#define POLLNORM POLLRDNORM
+
+/* Return ONLY events (NON testable) */
+
+#define POLLERR 0x0008
+#define POLLHUP 0x0010
+#define POLLNVAL 0x0020
+
+int poll (struct pollfd *, unsigned long, int);
+
+#ifndef HAS_POLL
+# define HAS_POLL
+#endif
+
+#endif /* HAS_SELECT */
+
+#endif /* I_POLL */
+
+#endif /* POLL_H */
+