summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-12-20 11:14:00 +1200
committerChip Salzenberg <chip@atlantic.net>1996-12-20 11:14:00 +1200
commit7e1af8bca57f405a8444b575a870918a6d88fc5c (patch)
treeb443adc34d8d77831bf947076abd5770335592cf /ext
parent7f3dfc00eaef7e421633b2b47af9963dbc626e75 (diff)
downloadperl-7e1af8bca57f405a8444b575a870918a6d88fc5c.tar.gz
[inseparable changes from patch from perl5.003_12 to perl5.003_13]
DOCUMENTATION Subject: small doc tweaks for _12 Date: Thu, 19 Dec 1996 11:05:57 -0500 From: Roderick Schertler <roderick@gate.net> Files: lib/UNIVERSAL.pm pod/perldiag.pod pod/perltie.pod Msg-ID: <1826.851011557@eeyore.ibcinc.com> (applied based on p5p patch as commit 3314ffc68a11690bd9977cbdd7ea0601ad6ced13) PORTABILITY Subject: Add missing backslash in Configure From: Chip Salzenberg <chip@atlantic.net> Files: Configure UTILITIES, LIBRARY, AND EXTENSIONS Subject: Include libnet-1.01 instead of old Net::FTP From: Graham Barr <Graham.Barr@tiuk.ti.com> Files: MANIFEST lib/Net/Cmd.pm lib/Net/Domain.pm lib/Net/DummyInetd.pm lib/Net/FTP.pm lib/Net/NNTP.pm lib/Net/Netrc.pm lib/Net/POP3.pm lib/Net/SMTP.pm lib/Net/SNPP.pm lib/Net/Socket.pm lib/Net/Telnet.pm lib/Net/Time.pm pod/perlmod.pod Subject: Use binmode when doing binary FTP From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: lib/Net/FTP.pm Subject: Re: Open3.pm tries to close unopened file handle Date: 18 Dec 1996 22:19:54 -0500 From: Roderick Schertler <roderick@gate.net> Files: MANIFEST lib/IPC/Open2.pm lib/IPC/Open3.pm lib/open2.pl lib/open3.pl pod/perldiag.pod pod/perlfunc.pod t/lib/open2.t t/lib/open3.t Msg-ID: <pzloavmd9h.fsf@eeyore.ibcinc.com> (applied based on p5p patch as commit 982b4e8fc47473059e209787b589853f4c8f8f9e) Subject: Long-standing problem in Socket module Date: Wed, 18 Dec 1996 23:18:14 -0500 From: Spider Boardman <spider@orb.nashua.nh.us> Files: Configure Porting/Glossary config_H config_h.SH ext/Socket/Socket.pm ext/Socket/Socket.xs Msg-ID: <199612190418.XAA07291@Orb.Nashua.NH.US> (applied based on p5p patch as commit 3e6a22d2723daf415793f9a4fc1b57f4d8a576fd) Subject: flock() constants Date: Thu, 19 Dec 1996 01:37:17 -0500 From: Roderick Schertler <roderick@gate.net> Files: ext/Fcntl/Fcntl.pm ext/Fcntl/Fcntl.xs pod/perlfunc.pod Msg-ID: <26669.850977437@eeyore.ibcinc.com> (applied based on p5p patch as commit 3dea0e15e4684f6defe2f25a16bc696b96697ac2)
Diffstat (limited to 'ext')
-rw-r--r--ext/Fcntl/Fcntl.pm17
-rw-r--r--ext/Fcntl/Fcntl.xs31
-rw-r--r--ext/IO/lib/IO/Pipe.pm2
-rw-r--r--ext/Socket/Socket.pm18
-rw-r--r--ext/Socket/Socket.xs122
5 files changed, 181 insertions, 9 deletions
diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm
index 9d000a1e68..489853416d 100644
--- a/ext/Fcntl/Fcntl.pm
+++ b/ext/Fcntl/Fcntl.pm
@@ -7,6 +7,7 @@ Fcntl - load the C Fcntl.h defines
=head1 SYNOPSIS
use Fcntl;
+ use Fcntl qw(:DEFAULT :flock);
=head1 DESCRIPTION
@@ -21,14 +22,21 @@ far more likely chance of getting the numbers right.
Only C<#define> symbols get translated; you must still correctly
pack up your own arguments to pass as args for locking functions, etc.
+=head1 EXPORTED SYMBOLS
+
+By default your system's F_* and O_* constants (eg, F_DUPFD and O_CREAT)
+are exported into your namespace. You can request that the flock()
+constants (LOCK_SH, LOCK_EX, LOCK_NB and LOCK_UN) be provided by using
+the tag C<:flock>. See L<Exporter>.
+
=cut
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
-$VERSION = "1.00";
+$VERSION = "1.01";
# Items to export into callers namespace by default
# (move infrequently used names to @EXPORT_OK below)
@EXPORT =
@@ -42,6 +50,11 @@ $VERSION = "1.00";
);
# Other items we are prepared to export if requested
@EXPORT_OK = qw(
+ LOCK_SH LOCK_EX LOCK_NB LOCK_UN
+);
+# Named groups of exports
+%EXPORT_TAGS = (
+ 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)],
);
sub AUTOLOAD {
diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs
index 90f3af5028..0f51b100d7 100644
--- a/ext/Fcntl/Fcntl.xs
+++ b/ext/Fcntl/Fcntl.xs
@@ -115,6 +115,37 @@ int arg;
goto not_there;
#endif
break;
+ case 'L':
+ if (strnEQ(name, "LOCK_", 5)) {
+ /* We support flock() on systems which don't have it, so
+ always supply the constants. */
+ if (strEQ(name, "LOCK_SH"))
+#ifdef LOCK_SH
+ return LOCK_SH;
+#else
+ return 1;
+#endif
+ if (strEQ(name, "LOCK_EX"))
+#ifdef LOCK_EX
+ return LOCK_EX;
+#else
+ return 2;
+#endif
+ if (strEQ(name, "LOCK_NB"))
+#ifdef LOCK_NB
+ return LOCK_NB;
+#else
+ return 4;
+#endif
+ if (strEQ(name, "LOCK_UN"))
+#ifdef LOCK_UN
+ return LOCK_UN;
+#else
+ return 8;
+#endif
+ } else
+ goto not_there;
+ break;
case 'O':
if (strnEQ(name, "O_", 2)) {
if (strEQ(name, "O_CREAT"))
diff --git a/ext/IO/lib/IO/Pipe.pm b/ext/IO/lib/IO/Pipe.pm
index 27fe7f1aa2..9ec8b6498a 100644
--- a/ext/IO/lib/IO/Pipe.pm
+++ b/ext/IO/lib/IO/Pipe.pm
@@ -4,7 +4,7 @@ package IO::Pipe;
=head1 NAME
-IO::pipe - supply object methods for pipes
+IO::Pipe - supply object methods for pipes
=head1 SYNOPSIS
diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm
index 9872d03526..e04689d9b8 100644
--- a/ext/Socket/Socket.pm
+++ b/ext/Socket/Socket.pm
@@ -1,7 +1,7 @@
package Socket;
use vars qw($VERSION @ISA @EXPORT);
-$VERSION = "1.5";
+$VERSION = "1.6";
=head1 NAME
@@ -52,7 +52,8 @@ In addition, some structure manipulation functions are available:
Takes a string giving the name of a host, and translates that
to the 4-byte string (structure). Takes arguments of both
the 'rtfm.mit.edu' type and '18.181.0.24'. If the host name
-cannot be resolved, returns undef.
+cannot be resolved, returns undef. For multi-homed hosts (hosts
+with more than one address), the first address found is returned.
=item inet_ntoa IP_ADDRESS
@@ -72,6 +73,15 @@ a particular network interface. This wildcard address
allows you to bind to all of them simultaneously.)
Normally equivalent to inet_aton('0.0.0.0').
+=item INADDR_BROADCAST
+
+Note: does not return a number, but a packed string.
+
+Returns the 4-byte 'this-lan' ip broadcast address.
+This can be useful for some protocols to solicit information
+from all servers on the same LAN cable.
+Normally equivalent to inet_aton('255.255.255.255').
+
=item INADDR_LOOPBACK
Note - does not return a number.
@@ -83,7 +93,7 @@ to inet_aton('localhost').
Note - does not return a number.
-Returns the 4-byte invalid ip address. Normally equivalent
+Returns the 4-byte 'invalid' ip address. Normally equivalent
to inet_aton('255.255.255.255').
=item sockaddr_in PORT, ADDRESS
@@ -145,7 +155,7 @@ require DynaLoader;
inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in
pack_sockaddr_un unpack_sockaddr_un
sockaddr_in sockaddr_un
- INADDR_ANY INADDR_LOOPBACK INADDR_NONE
+ INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK INADDR_NONE
AF_802
AF_APPLETALK
AF_CCITT
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs
index 6c39557185..7e3e3b375d 100644
--- a/ext/Socket/Socket.xs
+++ b/ext/Socket/Socket.xs
@@ -30,10 +30,117 @@
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif /* INADDR_NONE */
+#ifndef INADDR_BROADCAST
+#define INADDR_BROADCAST 0xffffffff
+#endif /* INADDR_BROADCAST */
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7F000001
#endif /* INADDR_LOOPBACK */
+#ifndef HAS_INET_ATON
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+static int
+my_inet_aton(cp, addr)
+register const char *cp;
+struct in_addr *addr;
+{
+ register unsigned long val;
+ register int base;
+ register char c;
+ int nparts;
+ const char *s;
+ unsigned int parts[4];
+ register unsigned int *pp = parts;
+
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, other=decimal.
+ */
+ val = 0; base = 10;
+ if (*cp == '0') {
+ if (*++cp == 'x' || *cp == 'X')
+ base = 16, cp++;
+ else
+ base = 8;
+ }
+ while ((c = *cp) != '\0') {
+ if (isDIGIT(c)) {
+ val = (val * base) + (c - '0');
+ cp++;
+ continue;
+ }
+ if (base == 16 && (s=strchr(hexdigit,c))) {
+ val = (val << 4) +
+ ((s - hexdigit) & 15);
+ cp++;
+ continue;
+ }
+ break;
+ }
+ if (*cp == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16-bits)
+ * a.b (with b treated as 24 bits)
+ */
+ if (pp >= parts + 3 || val > 0xff)
+ return 0;
+ *pp++ = val, cp++;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (*cp && !isSPACE(*cp))
+ return 0;
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ nparts = pp - parts + 1; /* force to an int for switch() */
+ switch (nparts) {
+
+ case 1: /* a -- 32 bits */
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ if (val > 0xffffff)
+ return 0;
+ val |= parts[0] << 24;
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ if (val > 0xffff)
+ return 0;
+ val |= (parts[0] << 24) | (parts[1] << 16);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ if (val > 0xff)
+ return 0;
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ break;
+ }
+ addr->s_addr = htonl(val);
+ return 1;
+}
+
+#undef inet_aton
+#define inet_aton my_inet_aton
+
+#endif /* ! HAS_INET_ATON */
+
static int
not_here(s)
@@ -595,15 +702,17 @@ inet_aton(host)
{
struct in_addr ip_address;
struct hostent * phe;
+ int ok;
if (phe = gethostbyname(host)) {
Copy( phe->h_addr, &ip_address, phe->h_length, char );
+ ok = 1;
} else {
- ip_address.s_addr = inet_addr(host);
+ ok = inet_aton(host, &ip_address);
}
ST(0) = sv_newmortal();
- if(ip_address.s_addr != INADDR_NONE) {
+ if (ok) {
sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address );
}
}
@@ -748,3 +857,12 @@ INADDR_NONE()
ip_address.s_addr = htonl(INADDR_NONE);
ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address));
}
+
+void
+INADDR_BROADCAST()
+ CODE:
+ {
+ struct in_addr ip_address;
+ ip_address.s_addr = htonl(INADDR_BROADCAST);
+ ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address));
+ }