ext/Socket/Socket.xs

In Socket.xs do I take it that this

	if (strEQ(name, "MSG_CTRUNC"))
#if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
	    return MSG_CTRUNC;
#else
	    goto not_there;
#endif

should be MSG_CTRUNC? As in:

#if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */

Secondly, Socket.pm EXPORTs MSG_URG, but there is no code to generate it
in Socket.xs. Was this an oversight somewhere?

Nicholas Clark
0
nick
6/3/2001 2:03:46 PM
perl.perl5.porters 48287 articles. 1 followers. Follow

3 Replies
727 Views

Similar Articles

[PageSpeed] 48

On Sun, Jun 03, 2001 at 03:03:46PM +0100, Nicholas Clark wrote:
> In Socket.xs do I take it that this
> 
> 	if (strEQ(name, "MSG_CTRUNC"))
> #if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
> 	    return MSG_CTRUNC;
> #else
> 	    goto not_there;
> #endif
> 
> should be MSG_CTRUNC? As in:

Yes.

> #if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
> 
> Secondly, Socket.pm EXPORTs MSG_URG, but there is no code to generate it
> in Socket.xs. Was this an oversight somewhere?

Yes.

The Socket.xs (and Fcntl.xs) have for a long time been maintained
manually.  You see the fallout.

> Nicholas Clark

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
6/3/2001 3:40:21 PM
--dTy3Mrz/UPE2dbVg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Jun 03, 2001 at 10:40:21AM -0500, Jarkko Hietaniemi wrote:
> On Sun, Jun 03, 2001 at 03:03:46PM +0100, Nicholas Clark wrote:
> > In Socket.xs do I take it that this
> > 
> > 	if (strEQ(name, "MSG_CTRUNC"))
> > #if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
> > 	    return MSG_CTRUNC;
> > #else
> > 	    goto not_there;
> > #endif
> > 
> > should be MSG_CTRUNC? As in:
> 
> Yes.
> 
> > #if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
> > 
> > Secondly, Socket.pm EXPORTs MSG_URG, but there is no code to generate it
> > in Socket.xs. Was this an oversight somewhere?
> 
> Yes.
> 
> The Socket.xs (and Fcntl.xs) have for a long time been maintained
> manually.  You see the fallout.

The attached and appended rejig Socket, Fcntl and Sys::Syslog to use constant
code generated by the ExtUtils::Constant routines.
They incorporate all the oddities such as

name/value/macro differ:
    case '_':
	if (strEQ(name, "S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */
#ifdef S_IFMT
	  return S_IFMT;
#else
	  goto not_there;
#endif
	break;

fake your own value:
      case 'E':
	  if (strEQ(name, "EK_CUR"))
#ifdef SEEK_CUR
	    return SEEK_CUR;
#else
	    return 1;
#endif

more than one way to test for presence:
	if (strEQ(name, "MSG_CTRUNC"))
#if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
	    return MSG_CTRUNC;
#else
	    goto not_there;
#endif


They return IVs (by default) not NVs.
They don't set errno. (Which is the principal backward incompatibility, but
will be seen as an improvement by some people on this list)
The enclosed perl code can regenerate the switch statements.
[And has been dogfood tested to add MSG_URG.]

And typically the generated code is getting to a memEQ test for nearly all
inputs with only 2 switch statements and no preceding linear search.

It should be possible to add the INADDR_ANY() INADDR_LOOPBACK() INADDR_NONE()
INADDR_BROADCAST() constant XSubs from Socket.xs into the constant routine
[although I think it may require BOOT time initialisation of static variables.
Currently they read:

void
INADDR_BROADCAST()
        CODE:
        {
        struct in_addr  ip_address;
        ip_address.s_addr = htonl(INADDR_BROADCAST);
        ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address));
        }

Nicholas Clark

--- ext/Sys/Syslog/Syslog.pm.orig	Fri Mar 16 02:57:28 2001
+++ ext/Sys/Syslog/Syslog.pm	Sun Jun  3 16:42:27 2001
@@ -7,7 +7,7 @@
 @ISA = qw(Exporter DynaLoader);
 @EXPORT = qw(openlog closelog setlogmask syslog);
 @EXPORT_OK = qw(setlogsock);
-$VERSION = '0.01';
+$VERSION = '0.02';
 
 use Socket;
 use Sys::Hostname;
@@ -119,6 +119,8 @@
 Dependency on F<syslog.ph> replaced with XS code by Tom Hughes
 E<lt>F<tom@compton.nu>E<gt>.
 
+Code for constant()s regenerated by Nicholas Clark E<lt>nick@ccl4.orgE<gt>.
+
 =cut
 
 sub AUTOLOAD {
@@ -128,10 +130,10 @@
     my $constname;
     our $AUTOLOAD;
     ($constname = $AUTOLOAD) =~ s/.*:://;
-    croak "& not defined" if $constname eq 'constant';
-    my $val = constant($constname);
-    if ($! != 0) {
-	croak "Your vendor has not defined Sys::Syslog macro $constname";
+    croak "&Sys::Syslog::constant not defined" if $constname eq 'constant';
+    my ($error, $val) = constant($constname);
+    if ($error) {
+	croak $error;
     }
     *$AUTOLOAD = sub { $val };
     goto &$AUTOLOAD;
--- ext/Socket/Socket.pm.orig	Fri Mar 16 02:57:28 2001
+++ ext/Socket/Socket.pm	Sun Jun  3 14:43:30 2001
@@ -1,7 +1,7 @@
 package Socket;
 
 our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
-$VERSION = "1.72";
+$VERSION = "1.73";
 
 =head1 NAME
 
@@ -329,10 +329,10 @@
 sub AUTOLOAD {
     my($constname);
     ($constname = $AUTOLOAD) =~ s/.*:://;
-    my $val = constant($constname, @_ ? $_[0] : 0);
-    if ($! != 0) {
-	my ($pack,$file,$line) = caller;
-	croak "Your vendor has not defined Socket macro $constname, used";
+    croak "&Socket::constant not defined" if $constname eq 'constant';
+    my ($error, $val) = constant($constname);
+    if ($error) {
+	croak $error;
     }
     eval "sub $AUTOLOAD () { $val }";
     goto &$AUTOLOAD;
--- ext/Fcntl/Fcntl.pm.orig	Sun Dec 17 18:43:06 2000
+++ ext/Fcntl/Fcntl.pm	Sun Jun  3 14:41:42 2001
@@ -60,7 +60,7 @@
 require Exporter;
 use XSLoader ();
 @ISA = qw(Exporter);
-$VERSION = "1.03";
+$VERSION = "1.04";
 # Items to export into callers namespace by default
 # (move infrequently used names to @EXPORT_OK below)
 @EXPORT =
@@ -201,17 +201,11 @@
 
 sub AUTOLOAD {
     (my $constname = $AUTOLOAD) =~ s/.*:://;
-    my $val = constant($constname);
-    if ($! != 0) {
-	if ($! =~ /Invalid/ || $!{EINVAL}) {
-	    $AutoLoader::AUTOLOAD = $AUTOLOAD;
-	    goto &AutoLoader::AUTOLOAD;
-	}
-	else {
-	    my ($pack,$file,$line) = caller;
-	    die "Your vendor has not defined Fcntl macro $constname, used at $file line $line.
-";
-	}
+    die "&Fcntl::constant not defined" if $constname eq 'constant';
+    my ($error, $val) = constant($constname);
+    if ($error) {
+        my (undef,$file,$line) = caller;
+        die "$error at $file line $line.\n";
     }
     *$AUTOLOAD = sub { $val };
     goto &$AUTOLOAD;

--dTy3Mrz/UPE2dbVg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Socket.xs"

#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#ifndef VMS
# ifdef I_SYS_TYPES
#  include <sys/types.h>
# endif
# include <sys/socket.h>
# if defined(USE_SOCKS) && defined(I_SOCKS)
#   include <socks.h>
# endif 
# ifdef MPE
#  define PF_INET AF_INET
#  define PF_UNIX AF_UNIX
#  define SOCK_RAW 3
# endif
# ifdef I_SYS_UN
#  include <sys/un.h>
# endif
/* XXX Configure test for <netinet/in_systm.h needed XXX */
# if defined(NeXT) || defined(__NeXT__)
#  include <netinet/in_systm.h>
# endif
# ifdef I_NETINET_IN
#  include <netinet/in.h>
# endif
# ifdef I_NETDB
#  include <netdb.h>
# endif
# ifdef I_ARPA_INET
#  include <arpa/inet.h>
# endif
# ifdef I_NETINET_TCP
#  include <netinet/tcp.h>
# endif
#else
# include "sockadapt.h"
#endif

#ifdef I_SYSUIO
# include <sys/uio.h>
#endif

#ifndef AF_NBS
# undef PF_NBS
#endif

#ifndef AF_X25
# undef PF_X25
#endif

#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(register const char *cp, struct in_addr *addr)
{
	dTHX;
	register U32 val;
	register int base;
	register char c;
	int nparts;
	const char *s;
	unsigned int parts[4];
	register unsigned int *pp = parts;

	if (!cp)
		return 0;
	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(PL_hexdigit,c))) {
				val = (val << 4) + 
					((s - PL_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(char *s)
{
    croak("Socket::%s not implemented on this architecture", s);
    return -1;
}

#define PERL_constant_NOTFOUND	1
#define PERL_constant_NOTDEF	2
#define PERL_constant_ISIV	3
#define PERL_constant_ISNV	4
#define PERL_constant_ISPV	5
#define PERL_constant_ISPVN	6
#define PERL_constant_ISUV	7

#ifndef NVTYPE
typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it.  */
#endif

static int
constant_5 (const char *name, IV *iv_return) {
  /* Names all of length 5.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_NS PF_NS */
  /* Offset 0 gives the best switch position.  */
  switch (name[0]) {
  case 'A':
    if (memEQ(name, "AF_NS", 5)) {
    /*               ^          */
#ifdef AF_NS
      *iv_return = AF_NS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "PF_NS", 5)) {
    /*               ^          */
#ifdef PF_NS
      *iv_return = PF_NS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_6 (const char *name, IV *iv_return) {
  /* Names all of length 6.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_802 AF_DLI AF_LAT AF_MAX AF_NBS AF_NIT AF_OSI AF_PUP AF_SNA AF_X25
     PF_802 PF_DLI PF_LAT PF_MAX PF_NBS PF_NIT PF_OSI PF_PUP PF_SNA PF_X25 */
  /* Offset 3 gives the best switch position.  */
  switch (name[3]) {
  case '8':
    if (memEQ(name, "AF_802", 6)) {
    /*                  ^        */
#ifdef AF_802
      *iv_return = AF_802;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_802", 6)) {
    /*                  ^        */
#ifdef PF_802
      *iv_return = PF_802;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "AF_DLI", 6)) {
    /*                  ^        */
#ifdef AF_DLI
      *iv_return = AF_DLI;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_DLI", 6)) {
    /*                  ^        */
#ifdef PF_DLI
      *iv_return = PF_DLI;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "AF_LAT", 6)) {
    /*                  ^        */
#ifdef AF_LAT
      *iv_return = AF_LAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_LAT", 6)) {
    /*                  ^        */
#ifdef PF_LAT
      *iv_return = PF_LAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'M':
    if (memEQ(name, "AF_MAX", 6)) {
    /*                  ^        */
#ifdef AF_MAX
      *iv_return = AF_MAX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_MAX", 6)) {
    /*                  ^        */
#ifdef PF_MAX
      *iv_return = PF_MAX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "AF_NBS", 6)) {
    /*                  ^        */
#ifdef AF_NBS
      *iv_return = AF_NBS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "AF_NIT", 6)) {
    /*                  ^        */
#ifdef AF_NIT
      *iv_return = AF_NIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_NBS", 6)) {
    /*                  ^        */
#ifdef PF_NBS
      *iv_return = PF_NBS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_NIT", 6)) {
    /*                  ^        */
#ifdef PF_NIT
      *iv_return = PF_NIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "AF_OSI", 6)) {
    /*                  ^        */
#ifdef AF_OSI
      *iv_return = AF_OSI;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_OSI", 6)) {
    /*                  ^        */
#ifdef PF_OSI
      *iv_return = PF_OSI;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "AF_PUP", 6)) {
    /*                  ^        */
#ifdef AF_PUP
      *iv_return = AF_PUP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_PUP", 6)) {
    /*                  ^        */
#ifdef PF_PUP
      *iv_return = PF_PUP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "AF_SNA", 6)) {
    /*                  ^        */
#ifdef AF_SNA
      *iv_return = AF_SNA;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_SNA", 6)) {
    /*                  ^        */
#ifdef PF_SNA
      *iv_return = PF_SNA;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "AF_X25", 6)) {
    /*                  ^        */
#ifdef AF_X25
      *iv_return = AF_X25;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_X25", 6)) {
    /*                  ^        */
#ifdef PF_X25
      *iv_return = PF_X25;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_7 (const char *name, IV *iv_return) {
  /* Names all of length 7.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_ECMA AF_INET AF_UNIX IOV_MAX MSG_EOF MSG_EOR MSG_FIN MSG_OOB MSG_RST
     MSG_SYN MSG_URG PF_ECMA PF_INET PF_UNIX SHUT_RD SHUT_WR SO_TYPE */
  /* Offset 4 gives the best switch position.  */
  switch (name[4]) {
  case 'C':
    if (memEQ(name, "AF_ECMA", 7)) {
    /*                   ^        */
#ifdef AF_ECMA
      *iv_return = AF_ECMA;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_ECMA", 7)) {
    /*                   ^        */
#ifdef PF_ECMA
      *iv_return = PF_ECMA;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "MSG_EOF", 7)) {
    /*                   ^        */
#ifdef MSG_EOF
      *iv_return = MSG_EOF;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "MSG_EOR", 7)) {
    /*                   ^        */
#ifdef MSG_EOR
      *iv_return = MSG_EOR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "MSG_FIN", 7)) {
    /*                   ^        */
#ifdef MSG_FIN
      *iv_return = MSG_FIN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'M':
    if (memEQ(name, "IOV_MAX", 7)) {
    /*                   ^        */
#ifdef IOV_MAX
      *iv_return = IOV_MAX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "AF_INET", 7)) {
    /*                   ^        */
#ifdef AF_INET
      *iv_return = AF_INET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "AF_UNIX", 7)) {
    /*                   ^        */
#ifdef AF_UNIX
      *iv_return = AF_UNIX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_INET", 7)) {
    /*                   ^        */
#ifdef PF_INET
      *iv_return = PF_INET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_UNIX", 7)) {
    /*                   ^        */
#ifdef PF_UNIX
      *iv_return = PF_UNIX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "MSG_OOB", 7)) {
    /*                    ^       */
#if defined(MSG_OOB) || defined(HAS_MSG_OOB) /* might be an enum */
      *iv_return = MSG_OOB;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "MSG_RST", 7)) {
    /*                   ^        */
#ifdef MSG_RST
      *iv_return = MSG_RST;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "MSG_SYN", 7)) {
    /*                   ^        */
#ifdef MSG_SYN
      *iv_return = MSG_SYN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "MSG_URG", 7)) {
    /*                   ^        */
#ifdef MSG_URG
      *iv_return = MSG_URG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'Y':
    if (memEQ(name, "SO_TYPE", 7)) {
    /*                   ^        */
#ifdef SO_TYPE
      *iv_return = SO_TYPE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '_':
    if (memEQ(name, "SHUT_RD", 7)) {
    /*                   ^        */
#ifdef SHUT_RD
      *iv_return = SHUT_RD;
      return PERL_constant_ISIV;
#else
      *iv_return = 0;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "SHUT_WR", 7)) {
    /*                   ^        */
#ifdef SHUT_WR
      *iv_return = SHUT_WR;
      return PERL_constant_ISIV;
#else
      *iv_return = 1;
      return PERL_constant_ISIV;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_8 (const char *name, IV *iv_return) {
  /* Names all of length 8.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_CCITT AF_CHAOS AF_GOSIP MSG_PEEK PF_CCITT PF_CHAOS PF_GOSIP SOCK_RAW
     SOCK_RDM SO_DEBUG SO_ERROR */
  /* Offset 7 gives the best switch position.  */
  switch (name[7]) {
  case 'G':
    if (memEQ(name, "SO_DEBUG", 8)) {
    /*                      ^      */
#ifdef SO_DEBUG
      *iv_return = SO_DEBUG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'K':
    if (memEQ(name, "MSG_PEEK", 8)) {
    /*                      ^      */
#if defined(MSG_PEEK) || defined(HAS_MSG_PEEK) /* might be an enum */
      *iv_return = MSG_PEEK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'M':
    if (memEQ(name, "SOCK_RDM", 8)) {
    /*                      ^      */
#ifdef SOCK_RDM
      *iv_return = SOCK_RDM;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "AF_GOSIP", 8)) {
    /*                      ^      */
#ifdef AF_GOSIP
      *iv_return = AF_GOSIP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_GOSIP", 8)) {
    /*                      ^      */
#ifdef PF_GOSIP
      *iv_return = PF_GOSIP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "SO_ERROR", 8)) {
    /*                      ^      */
#ifdef SO_ERROR
      *iv_return = SO_ERROR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "AF_CHAOS", 8)) {
    /*                      ^      */
#ifdef AF_CHAOS
      *iv_return = AF_CHAOS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_CHAOS", 8)) {
    /*                      ^      */
#ifdef PF_CHAOS
      *iv_return = PF_CHAOS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "AF_CCITT", 8)) {
    /*                      ^      */
#ifdef AF_CCITT
      *iv_return = AF_CCITT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_CCITT", 8)) {
    /*                      ^      */
#ifdef PF_CCITT
      *iv_return = PF_CCITT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'W':
    if (memEQ(name, "SOCK_RAW", 8)) {
    /*                      ^      */
#ifdef SOCK_RAW
      *iv_return = SOCK_RAW;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_9 (const char *name, IV *iv_return) {
  /* Names all of length 9.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_DECnet AF_HYLINK AF_OSINET AF_UNSPEC MSG_BCAST MSG_MCAST MSG_PROXY
     MSG_TRUNC PF_DECnet PF_HYLINK PF_OSINET PF_UNSPEC SCM_CREDS SHUT_RDWR
     SOMAXCONN SO_LINGER SO_RCVBUF SO_SNDBUF TCP_MAXRT */
  /* Offset 6 gives the best switch position.  */
  switch (name[6]) {
  case 'A':
    if (memEQ(name, "MSG_BCAST", 9)) {
    /*                     ^        */
#ifdef MSG_BCAST
      *iv_return = MSG_BCAST;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "MSG_MCAST", 9)) {
    /*                     ^        */
#ifdef MSG_MCAST
      *iv_return = MSG_MCAST;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'B':
    if (memEQ(name, "SO_RCVBUF", 9)) {
    /*                     ^        */
#ifdef SO_RCVBUF
      *iv_return = SO_RCVBUF;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "SO_SNDBUF", 9)) {
    /*                     ^        */
#ifdef SO_SNDBUF
      *iv_return = SO_SNDBUF;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "SHUT_RDWR", 9)) {
    /*                     ^        */
#ifdef SHUT_RDWR
      *iv_return = SHUT_RDWR;
      return PERL_constant_ISIV;
#else
      *iv_return = 2;
      return PERL_constant_ISIV;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "SCM_CREDS", 9)) {
    /*                     ^        */
#ifdef SCM_CREDS
      *iv_return = SCM_CREDS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "SO_LINGER", 9)) {
    /*                     ^        */
#ifdef SO_LINGER
      *iv_return = SO_LINGER;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "AF_HYLINK", 9)) {
    /*                     ^        */
#ifdef AF_HYLINK
      *iv_return = AF_HYLINK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_HYLINK", 9)) {
    /*                     ^        */
#ifdef PF_HYLINK
      *iv_return = PF_HYLINK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "AF_OSINET", 9)) {
    /*                     ^        */
#ifdef AF_OSINET
      *iv_return = AF_OSINET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_OSINET", 9)) {
    /*                     ^        */
#ifdef PF_OSINET
      *iv_return = PF_OSINET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "MSG_PROXY", 9)) {
    /*                     ^        */
#if defined(MSG_PROXY) || defined(HAS_MSG_PROXY) /* might be an enum */
      *iv_return = MSG_PROXY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "SOMAXCONN", 9)) {
    /*                     ^        */
#ifdef SOMAXCONN
      *iv_return = SOMAXCONN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "AF_UNSPEC", 9)) {
    /*                     ^        */
#ifdef AF_UNSPEC
      *iv_return = AF_UNSPEC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_UNSPEC", 9)) {
    /*                     ^        */
#ifdef PF_UNSPEC
      *iv_return = PF_UNSPEC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "MSG_TRUNC", 9)) {
    /*                     ^        */
#ifdef MSG_TRUNC
      *iv_return = MSG_TRUNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "TCP_MAXRT", 9)) {
    /*                     ^        */
#ifdef TCP_MAXRT
      *iv_return = TCP_MAXRT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'n':
    if (memEQ(name, "AF_DECnet", 9)) {
    /*                     ^        */
#ifdef AF_DECnet
      *iv_return = AF_DECnet;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_DECnet", 9)) {
    /*                     ^        */
#ifdef PF_DECnet
      *iv_return = PF_DECnet;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_10 (const char *name, IV *iv_return) {
  /* Names all of length 10.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_DATAKIT AF_IMPLINK MSG_CTRUNC PF_DATAKIT PF_IMPLINK SCM_RIGHTS
     SOCK_DGRAM SOL_SOCKET TCP_MAXSEG TCP_STDURG UIO_MAXIOV */
  /* Offset 6 gives the best switch position.  */
  switch (name[6]) {
  case 'A':
    if (memEQ(name, "AF_DATAKIT", 10)) {
    /*                     ^          */
#ifdef AF_DATAKIT
      *iv_return = AF_DATAKIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_DATAKIT", 10)) {
    /*                     ^          */
#ifdef PF_DATAKIT
      *iv_return = PF_DATAKIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'C':
    if (memEQ(name, "SOL_SOCKET", 10)) {
    /*                     ^          */
#ifdef SOL_SOCKET
      *iv_return = SOL_SOCKET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "TCP_STDURG", 10)) {
    /*                     ^          */
#ifdef TCP_STDURG
      *iv_return = TCP_STDURG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "SCM_RIGHTS", 10)) {
    /*                     ^          */
#if defined(SCM_RIGHTS) || defined(HAS_SCM_RIGHTS) /* might be an enum */
      *iv_return = SCM_RIGHTS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "SOCK_DGRAM", 10)) {
    /*                     ^          */
#ifdef SOCK_DGRAM
      *iv_return = SOCK_DGRAM;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "AF_IMPLINK", 10)) {
    /*                     ^          */
#ifdef AF_IMPLINK
      *iv_return = AF_IMPLINK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_IMPLINK", 10)) {
    /*                     ^          */
#ifdef PF_IMPLINK
      *iv_return = PF_IMPLINK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "MSG_CTRUNC", 10)) {
    /*                     ^          */
#if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
      *iv_return = MSG_CTRUNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "TCP_MAXSEG", 10)) {
    /*                     ^          */
#ifdef TCP_MAXSEG
      *iv_return = TCP_MAXSEG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "UIO_MAXIOV", 10)) {
    /*                     ^          */
#ifdef UIO_MAXIOV
      *iv_return = UIO_MAXIOV;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_11 (const char *name, IV *iv_return) {
  /* Names all of length 11.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     IPPROTO_TCP MSG_WAITALL SCM_CONNECT SOCK_STREAM SO_RCVLOWAT SO_RCVTIMEO
     SO_SNDLOWAT SO_SNDTIMEO TCP_NODELAY */
  /* Offset 7 gives the best switch position.  */
  switch (name[7]) {
  case 'E':
    if (memEQ(name, "TCP_NODELAY", 11)) {
    /*                      ^          */
#ifdef TCP_NODELAY
      *iv_return = TCP_NODELAY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "SO_RCVTIMEO", 11)) {
    /*                      ^          */
#ifdef SO_RCVTIMEO
      *iv_return = SO_RCVTIMEO;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "SO_SNDTIMEO", 11)) {
    /*                      ^          */
#ifdef SO_SNDTIMEO
      *iv_return = SO_SNDTIMEO;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "SCM_CONNECT", 11)) {
    /*                      ^          */
#ifdef SCM_CONNECT
      *iv_return = SCM_CONNECT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "SO_RCVLOWAT", 11)) {
    /*                      ^          */
#ifdef SO_RCVLOWAT
      *iv_return = SO_RCVLOWAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "SO_SNDLOWAT", 11)) {
    /*                      ^          */
#ifdef SO_SNDLOWAT
      *iv_return = SO_SNDLOWAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "SOCK_STREAM", 11)) {
    /*                      ^          */
#ifdef SOCK_STREAM
      *iv_return = SOCK_STREAM;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "MSG_WAITALL", 11)) {
    /*                      ^          */
#ifdef MSG_WAITALL
      *iv_return = MSG_WAITALL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '_':
    if (memEQ(name, "IPPROTO_TCP", 11)) {
    /*                      ^          */
#ifdef IPPROTO_TCP
      *iv_return = IPPROTO_TCP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_12 (const char *name, IV *iv_return) {
  /* Names all of length 12.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     AF_APPLETALK MSG_CTLFLAGS MSG_DONTWAIT MSG_ERRQUEUE MSG_NOSIGNAL
     PF_APPLETALK SO_BROADCAST SO_DONTROUTE SO_KEEPALIVE SO_OOBINLINE
     SO_REUSEADDR SO_REUSEPORT */
  /* Offset 10 gives the best switch position.  */
  switch (name[10]) {
  case 'A':
    if (memEQ(name, "MSG_NOSIGNAL", 12)) {
    /*                         ^        */
#ifdef MSG_NOSIGNAL
      *iv_return = MSG_NOSIGNAL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "SO_REUSEADDR", 12)) {
    /*                         ^        */
#ifdef SO_REUSEADDR
      *iv_return = SO_REUSEADDR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "MSG_CTLFLAGS", 12)) {
    /*                         ^        */
#ifdef MSG_CTLFLAGS
      *iv_return = MSG_CTLFLAGS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "MSG_DONTWAIT", 12)) {
    /*                         ^        */
#ifdef MSG_DONTWAIT
      *iv_return = MSG_DONTWAIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "AF_APPLETALK", 12)) {
    /*                         ^        */
#ifdef AF_APPLETALK
      *iv_return = AF_APPLETALK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "PF_APPLETALK", 12)) {
    /*                         ^        */
#ifdef PF_APPLETALK
      *iv_return = PF_APPLETALK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "SO_OOBINLINE", 12)) {
    /*                         ^        */
#ifdef SO_OOBINLINE
      *iv_return = SO_OOBINLINE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "SO_REUSEPORT", 12)) {
    /*                         ^        */
#ifdef SO_REUSEPORT
      *iv_return = SO_REUSEPORT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "SO_BROADCAST", 12)) {
    /*                         ^        */
#ifdef SO_BROADCAST
      *iv_return = SO_BROADCAST;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "SO_DONTROUTE", 12)) {
    /*                         ^        */
#ifdef SO_DONTROUTE
      *iv_return = SO_DONTROUTE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "MSG_ERRQUEUE", 12)) {
    /*                         ^        */
#ifdef MSG_ERRQUEUE
      *iv_return = MSG_ERRQUEUE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'V':
    if (memEQ(name, "SO_KEEPALIVE", 12)) {
    /*                         ^        */
#ifdef SO_KEEPALIVE
      *iv_return = SO_KEEPALIVE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_13 (const char *name, IV *iv_return) {
  /* Names all of length 13.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     MSG_CTLIGNORE MSG_DONTROUTE MSG_MAXIOVLEN SCM_TIMESTAMP SO_ACCEPTCONN
     SO_DONTLINGER TCP_KEEPALIVE */
  /* Offset 5 gives the best switch position.  */
  switch (name[5]) {
  case 'A':
    if (memEQ(name, "MSG_MAXIOVLEN", 13)) {
    /*                    ^              */
#ifdef MSG_MAXIOVLEN
      *iv_return = MSG_MAXIOVLEN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'C':
    if (memEQ(name, "SO_ACCEPTCONN", 13)) {
    /*                    ^              */
#ifdef SO_ACCEPTCONN
      *iv_return = SO_ACCEPTCONN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "TCP_KEEPALIVE", 13)) {
    /*                    ^              */
#ifdef TCP_KEEPALIVE
      *iv_return = TCP_KEEPALIVE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "SCM_TIMESTAMP", 13)) {
    /*                    ^              */
#ifdef SCM_TIMESTAMP
      *iv_return = SCM_TIMESTAMP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "SO_DONTLINGER", 13)) {
    /*                    ^              */
#ifdef SO_DONTLINGER
      *iv_return = SO_DONTLINGER;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "MSG_DONTROUTE", 13)) {
    /*                    ^              */
#if defined(MSG_DONTROUTE) || defined(HAS_MSG_DONTROUTE) /* might be an enum */
      *iv_return = MSG_DONTROUTE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "MSG_CTLIGNORE", 13)) {
    /*                    ^              */
#ifdef MSG_CTLIGNORE
      *iv_return = MSG_CTLIGNORE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_14 (const char *name, IV *iv_return) {
  /* Names all of length 14.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     SOCK_SEQPACKET SO_USELOOPBACK */
  /* Offset 8 gives the best switch position.  */
  switch (name[8]) {
  case 'O':
    if (memEQ(name, "SO_USELOOPBACK", 14)) {
    /*                       ^            */
#ifdef SO_USELOOPBACK
      *iv_return = SO_USELOOPBACK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "SOCK_SEQPACKET", 14)) {
    /*                       ^            */
#ifdef SOCK_SEQPACKET
      *iv_return = SOCK_SEQPACKET;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant (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

#!perl -w
use ExtUtils::Constant qw (constant_types C_constant XS_constant);

my $types = {IV => 1};
my @names = (qw(AF_802 AF_APPLETALK AF_CCITT AF_CHAOS AF_DATAKIT AF_DECnet
	       AF_DLI AF_ECMA AF_GOSIP AF_HYLINK AF_IMPLINK AF_INET AF_LAT
	       AF_MAX AF_NBS AF_NIT AF_NS AF_OSI AF_OSINET AF_PUP AF_SNA
	       AF_UNIX AF_UNSPEC AF_X25 IOV_MAX IPPROTO_TCP MSG_BCAST
	       MSG_CTLFLAGS MSG_CTLIGNORE MSG_DONTWAIT MSG_EOF MSG_EOR
	       MSG_ERRQUEUE MSG_FIN MSG_MAXIOVLEN MSG_MCAST MSG_NOSIGNAL
	       MSG_RST MSG_SYN MSG_TRUNC MSG_WAITALL PF_802 PF_APPLETALK
	       PF_CCITT PF_CHAOS PF_DATAKIT PF_DECnet PF_DLI PF_ECMA PF_GOSIP
	       PF_HYLINK PF_IMPLINK PF_INET PF_LAT PF_MAX PF_NBS PF_NIT PF_NS
	       PF_OSI PF_OSINET PF_PUP PF_SNA PF_UNIX PF_UNSPEC PF_X25
	       SCM_CONNECT SCM_CREDENTIALS SCM_CREDS SCM_TIMESTAMP SOCK_DGRAM
	       SOCK_RAW SOCK_RDM SOCK_SEQPACKET SOCK_STREAM SOL_SOCKET
	       SOMAXCONN SO_ACCEPTCONN SO_BROADCAST SO_DEBUG SO_DONTLINGER
	       SO_DONTROUTE SO_ERROR SO_KEEPALIVE SO_LINGER SO_OOBINLINE
	       SO_RCVBUF SO_RCVLOWAT SO_RCVTIMEO SO_REUSEADDR SO_REUSEPORT
	       SO_SNDBUF SO_SNDLOWAT SO_SNDTIMEO SO_TYPE SO_USELOOPBACK
	       TCP_KEEPALIVE TCP_MAXRT TCP_MAXSEG TCP_NODELAY TCP_STDURG
	       UIO_MAXIOV MSG_URG),
            {name=>"MSG_CTRUNC", type=>"IV", macro=>["#if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"MSG_DONTROUTE", type=>"IV", macro=>["#if defined(MSG_DONTROUTE) || defined(HAS_MSG_DONTROUTE) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"MSG_OOB", type=>"IV", macro=>["#if defined(MSG_OOB) || defined(HAS_MSG_OOB) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"MSG_PEEK", type=>"IV", macro=>["#if defined(MSG_PEEK) || defined(HAS_MSG_PEEK) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"MSG_PROXY", type=>"IV", macro=>["#if defined(MSG_PROXY) || defined(HAS_MSG_PROXY) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"SCM_RIGHTS", type=>"IV", macro=>["#if defined(SCM_RIGHTS) || defined(HAS_SCM_RIGHTS) /* might be an enum *" . "/\n", "#endif\n"]},
            {name=>"SHUT_RD", type=>"IV", default=>["IV", "0"]},
            {name=>"SHUT_RDWR", type=>"IV", default=>["IV", "2"]},
            {name=>"SHUT_WR", type=>"IV", default=>["IV", "1"]});

print constant_types(); # macro defs
foreach (C_constant ("Socket", 'constant', 'IV', $types, undef, undef, @names) ) {
    print $_, "\n"; # C constant subs
}
print "#### XS Section:\n";
print XS_constant ("Socket", $types);
__END__
   */

  switch (len) {
  case 5:
    return constant_5 (name, iv_return);
    break;
  case 6:
    return constant_6 (name, iv_return);
    break;
  case 7:
    return constant_7 (name, iv_return);
    break;
  case 8:
    return constant_8 (name, iv_return);
    break;
  case 9:
    return constant_9 (name, iv_return);
    break;
  case 10:
    return constant_10 (name, iv_return);
    break;
  case 11:
    return constant_11 (name, iv_return);
    break;
  case 12:
    return constant_12 (name, iv_return);
    break;
  case 13:
    return constant_13 (name, iv_return);
    break;
  case 14:
    return constant_14 (name, iv_return);
    break;
  case 15:
    if (memEQ(name, "SCM_CREDENTIALS", 15)) {
#ifdef SCM_CREDENTIALS
      *iv_return = SCM_CREDENTIALS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}


MODULE = Socket		PACKAGE = Socket

void
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(s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(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 Socket macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(
	    "Your vendor has not defined Socket 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 UVs
        case PERL_constant_ISUV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHu((UV)iv);
          break; */
        default:
          sv = sv_2mortal(newSVpvf(
	    "Unexpected return type %d while processing Socket macro %s used",
               type, s));
          PUSHs(sv);
        }

void
inet_aton(host)
	char *	host
	CODE:
	{
	struct in_addr ip_address;
	struct hostent * phe;
	int ok = inet_aton(host, &ip_address);

	if (!ok && (phe = gethostbyname(host))) {
		Copy( phe->h_addr, &ip_address, phe->h_length, char );
		ok = 1;
	}

	ST(0) = sv_newmortal();
	if (ok) {
		sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address );
	}
	}

void
inet_ntoa(ip_address_sv)
	SV *	ip_address_sv
	CODE:
	{
	STRLEN addrlen;
	struct in_addr addr;
	char * addr_str;
	char * ip_address = SvPV(ip_address_sv,addrlen);
	if (addrlen != sizeof(addr)) {
	    croak("Bad arg length for %s, length is %d, should be %d",
			"Socket::inet_ntoa",
			addrlen, sizeof(addr));
	}

	Copy( ip_address, &addr, sizeof addr, char );
	addr_str = inet_ntoa(addr);

	ST(0) = sv_2mortal(newSVpvn(addr_str, strlen(addr_str)));
	}

void
pack_sockaddr_un(pathname)
	char *	pathname
	CODE:
	{
#ifdef I_SYS_UN
	struct sockaddr_un sun_ad; /* fear using sun */
	STRLEN len;

	Zero( &sun_ad, sizeof sun_ad, char );
	sun_ad.sun_family = AF_UNIX;
	len = strlen(pathname);
	if (len > sizeof(sun_ad.sun_path))
	    len = sizeof(sun_ad.sun_path);
#  ifdef OS2	/* Name should start with \socket\ and contain backslashes! */
	{
	    int off;
	    char *s, *e;

	    if (pathname[0] != '/' && pathname[0] != '\\')
		croak("Relative UNIX domain socket name '%s' unsupported", pathname);
	    else if (len < 8 
		     || pathname[7] != '/' && pathname[7] != '\\'
		     || !strnicmp(pathname + 1, "socket", 6))
		off = 7;
	    else
		off = 0;		/* Preserve names starting with \socket\ */
	    Copy( "\\socket", sun_ad.sun_path, off, char);
	    Copy( pathname, sun_ad.sun_path + off, len, char );

	    s = sun_ad.sun_path + off - 1;
	    e = s + len + 1;
	    while (++s < e)
		if (*s = '/')
		    *s = '\\';
	}
#  else	/* !( defined OS2 ) */ 
	Copy( pathname, sun_ad.sun_path, len, char );
#  endif
	ST(0) = sv_2mortal(newSVpvn((char *)&sun_ad, sizeof sun_ad));
#else
	ST(0) = (SV *) not_here("pack_sockaddr_un");
#endif
	
	}

void
unpack_sockaddr_un(sun_sv)
	SV *	sun_sv
	CODE:
	{
#ifdef I_SYS_UN
	struct sockaddr_un addr;
	STRLEN sockaddrlen;
	char * sun_ad = SvPV(sun_sv,sockaddrlen);
	char * e;
#   ifndef __linux__
	/* On Linux sockaddrlen on sockets returned by accept, recvfrom,
	   getpeername and getsockname is not equal to sizeof(addr). */
	if (sockaddrlen != sizeof(addr)) {
	    croak("Bad arg length for %s, length is %d, should be %d",
			"Socket::unpack_sockaddr_un",
			sockaddrlen, sizeof(addr));
	}
#   endif

	Copy( sun_ad, &addr, sizeof addr, char );

	if ( addr.sun_family != AF_UNIX ) {
	    croak("Bad address family for %s, got %d, should be %d",
			"Socket::unpack_sockaddr_un",
			addr.sun_family,
			AF_UNIX);
	}
	e = addr.sun_path;
	while (*e && e < addr.sun_path + sizeof addr.sun_path)
	    ++e;
	ST(0) = sv_2mortal(newSVpvn(addr.sun_path, e - addr.sun_path));
#else
	ST(0) = (SV *) not_here("unpack_sockaddr_un");
#endif
	}

void
pack_sockaddr_in(port,ip_address)
	unsigned short	port
	char *	ip_address
	CODE:
	{
	struct sockaddr_in sin;

	Zero( &sin, sizeof sin, char );
	sin.sin_family = AF_INET;
	sin.sin_port = htons(port);
	Copy( ip_address, &sin.sin_addr, sizeof sin.sin_addr, char );

	ST(0) = sv_2mortal(newSVpvn((char *)&sin, sizeof sin));
	}

void
unpack_sockaddr_in(sin_sv)
	SV *	sin_sv
	PPCODE:
	{
	STRLEN sockaddrlen;
	struct sockaddr_in addr;
	unsigned short	port;
	struct in_addr	ip_address;
	char *	sin = SvPV(sin_sv,sockaddrlen);
	if (sockaddrlen != sizeof(addr)) {
	    croak("Bad arg length for %s, length is %d, should be %d",
			"Socket::unpack_sockaddr_in",
			sockaddrlen, sizeof(addr));
	}
	Copy( sin, &addr,sizeof addr, char );
	if ( addr.sin_family != AF_INET ) {
	    croak("Bad address family for %s, got %d, should be %d",
			"Socket::unpack_sockaddr_in",
			addr.sin_family,
			AF_INET);
	} 
	port = ntohs(addr.sin_port);
	ip_address = addr.sin_addr;

	EXTEND(SP, 2);
	PUSHs(sv_2mortal(newSViv((IV) port)));
	PUSHs(sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address)));
	}

void
INADDR_ANY()
	CODE:
	{
	struct in_addr	ip_address;
	ip_address.s_addr = htonl(INADDR_ANY);
	ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address ));
	}

void
INADDR_LOOPBACK()
	CODE:
	{
	struct in_addr	ip_address;
	ip_address.s_addr = htonl(INADDR_LOOPBACK);
	ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address));
	}

void
INADDR_NONE()
	CODE:
	{
	struct in_addr	ip_address;
	ip_address.s_addr = htonl(INADDR_NONE);
	ST(0) = sv_2mortal(newSVpvn((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(newSVpvn((char *)&ip_address,sizeof ip_address));
	}

--dTy3Mrz/UPE2dbVg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Syslog.xs"

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#ifdef I_SYSLOG
#include <syslog.h>
#endif

#define PERL_constant_NOTFOUND	1
#define PERL_constant_NOTDEF	2
#define PERL_constant_ISIV	3
#define PERL_constant_ISNV	4
#define PERL_constant_ISPV	5
#define PERL_constant_ISPVN	6
#define PERL_constant_ISUV	7

#ifndef NVTYPE
typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it.  */
#endif

static int
constant_7 (const char *name, IV *iv_return) {
  /* Names all of length 7.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     LOG_ERR LOG_FTP LOG_LPR LOG_PID */
  /* Offset 4 gives the best switch position.  */
  switch (name[4]) {
  case 'E':
    if (memEQ(name, "LOG_ERR", 7)) {
    /*                   ^        */
#ifdef LOG_ERR
      *iv_return = LOG_ERR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "LOG_FTP", 7)) {
    /*                   ^        */
#ifdef LOG_FTP
      *iv_return = LOG_FTP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "LOG_LPR", 7)) {
    /*                   ^        */
#ifdef LOG_LPR
      *iv_return = LOG_LPR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "LOG_PID", 7)) {
    /*                   ^        */
#ifdef LOG_PID
      *iv_return = LOG_PID;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_8 (const char *name, IV *iv_return) {
  /* Names all of length 8.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     LOG_AUTH LOG_CONS LOG_CRIT LOG_CRON LOG_INFO LOG_KERN LOG_LFMT LOG_MAIL
     LOG_NEWS LOG_USER LOG_UUCP */
  /* Offset 6 gives the best switch position.  */
  switch (name[6]) {
  case 'C':
    if (memEQ(name, "LOG_UUCP", 8)) {
    /*                     ^       */
#ifdef LOG_UUCP
      *iv_return = LOG_UUCP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "LOG_USER", 8)) {
    /*                     ^       */
#ifdef LOG_USER
      *iv_return = LOG_USER;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "LOG_INFO", 8)) {
    /*                     ^       */
#ifdef LOG_INFO
      *iv_return = LOG_INFO;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "LOG_CRIT", 8)) {
    /*                     ^       */
#ifdef LOG_CRIT
      *iv_return = LOG_CRIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "LOG_MAIL", 8)) {
    /*                     ^       */
#ifdef LOG_MAIL
      *iv_return = LOG_MAIL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'M':
    if (memEQ(name, "LOG_LFMT", 8)) {
    /*                     ^       */
#ifdef LOG_LFMT
      *iv_return = LOG_LFMT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "LOG_CONS", 8)) {
    /*                     ^       */
#ifdef LOG_CONS
      *iv_return = LOG_CONS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "LOG_CRON", 8)) {
    /*                     ^       */
#ifdef LOG_CRON
      *iv_return = LOG_CRON;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "LOG_KERN", 8)) {
    /*                     ^       */
#ifdef LOG_KERN
      *iv_return = LOG_KERN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "LOG_AUTH", 8)) {
    /*                     ^       */
#ifdef LOG_AUTH
      *iv_return = LOG_AUTH;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'W':
    if (memEQ(name, "LOG_NEWS", 8)) {
    /*                     ^       */
#ifdef LOG_NEWS
      *iv_return = LOG_NEWS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_9 (const char *name, IV *iv_return) {
  /* Names all of length 9.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     LOG_ALERT LOG_DEBUG LOG_EMERG */
  /* Offset 4 gives the best switch position.  */
  switch (name[4]) {
  case 'A':
    if (memEQ(name, "LOG_ALERT", 9)) {
    /*                   ^          */
#ifdef LOG_ALERT
      *iv_return = LOG_ALERT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "LOG_DEBUG", 9)) {
    /*                   ^          */
#ifdef LOG_DEBUG
      *iv_return = LOG_DEBUG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "LOG_EMERG", 9)) {
    /*                   ^          */
#ifdef LOG_EMERG
      *iv_return = LOG_EMERG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_10 (const char *name, IV *iv_return) {
  /* Names all of length 10.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     LOG_DAEMON LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4
     LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_NDELAY LOG_NOTICE LOG_NOWAIT
     LOG_ODELAY LOG_PERROR LOG_SYSLOG */
  /* Offset 9 gives the best switch position.  */
  switch (name[9]) {
  case '0':
    if (memEQ(name, "LOG_LOCAL0", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL0
      *iv_return = LOG_LOCAL0;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '1':
    if (memEQ(name, "LOG_LOCAL1", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL1
      *iv_return = LOG_LOCAL1;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '2':
    if (memEQ(name, "LOG_LOCAL2", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL2
      *iv_return = LOG_LOCAL2;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '3':
    if (memEQ(name, "LOG_LOCAL3", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL3
      *iv_return = LOG_LOCAL3;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '4':
    if (memEQ(name, "LOG_LOCAL4", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL4
      *iv_return = LOG_LOCAL4;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '5':
    if (memEQ(name, "LOG_LOCAL5", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL5
      *iv_return = LOG_LOCAL5;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '6':
    if (memEQ(name, "LOG_LOCAL6", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL6
      *iv_return = LOG_LOCAL6;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '7':
    if (memEQ(name, "LOG_LOCAL7", 10)) {
    /*                        ^       */
#ifdef LOG_LOCAL7
      *iv_return = LOG_LOCAL7;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "LOG_NOTICE", 10)) {
    /*                        ^       */
#ifdef LOG_NOTICE
      *iv_return = LOG_NOTICE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "LOG_SYSLOG", 10)) {
    /*                        ^       */
#ifdef LOG_SYSLOG
      *iv_return = LOG_SYSLOG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "LOG_DAEMON", 10)) {
    /*                        ^       */
#ifdef LOG_DAEMON
      *iv_return = LOG_DAEMON;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "LOG_PERROR", 10)) {
    /*                        ^       */
#ifdef LOG_PERROR
      *iv_return = LOG_PERROR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "LOG_NOWAIT", 10)) {
    /*                        ^       */
#ifdef LOG_NOWAIT
      *iv_return = LOG_NOWAIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'Y':
    if (memEQ(name, "LOG_NDELAY", 10)) {
    /*                        ^       */
#ifdef LOG_NDELAY
      *iv_return = LOG_NDELAY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "LOG_ODELAY", 10)) {
    /*                        ^       */
#ifdef LOG_ODELAY
      *iv_return = LOG_ODELAY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_11 (const char *name, IV *iv_return) {
  /* Names all of length 11.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     LOG_FACMASK LOG_PRIMASK LOG_WARNING */
  /* Offset 6 gives the best switch position.  */
  switch (name[6]) {
  case 'C':
    if (memEQ(name, "LOG_FACMASK", 11)) {
    /*                     ^           */
#ifdef LOG_FACMASK
      *iv_return = LOG_FACMASK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "LOG_PRIMASK", 11)) {
    /*                     ^           */
#ifdef LOG_PRIMASK
      *iv_return = LOG_PRIMASK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "LOG_WARNING", 11)) {
    /*                     ^           */
#ifdef LOG_WARNING
      *iv_return = LOG_WARNING;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant (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

#!perl -w
use ExtUtils::Constant qw (constant_types C_constant XS_constant);

my $types = {IV => 1};
my @names = (qw(LOG_ALERT LOG_AUTH LOG_AUTHPRIV LOG_CONS LOG_CRIT LOG_CRON
	       LOG_DAEMON LOG_DEBUG LOG_EMERG LOG_ERR LOG_FACMASK LOG_FTP
	       LOG_INFO LOG_KERN LOG_LFMT LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2
	       LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR
	       LOG_MAIL LOG_NDELAY LOG_NEWS LOG_NFACILITIES LOG_NOTICE
	       LOG_NOWAIT LOG_ODELAY LOG_PERROR LOG_PID LOG_PRIMASK LOG_SYSLOG
	       LOG_USER LOG_UUCP LOG_WARNING));

print constant_types(); # macro defs
foreach (C_constant ("Sys::Syslog", 'constant', 'IV', $types, undef, undef, @names) ) {
    print $_, "\n"; # C constant subs
}
print "#### XS Section:\n";
print XS_constant ("Sys::Syslog", $types);
__END__
   */

  switch (len) {
  case 7:
    return constant_7 (name, iv_return);
    break;
  case 8:
    return constant_8 (name, iv_return);
    break;
  case 9:
    return constant_9 (name, iv_return);
    break;
  case 10:
    return constant_10 (name, iv_return);
    break;
  case 11:
    return constant_11 (name, iv_return);
    break;
  case 12:
    if (memEQ(name, "LOG_AUTHPRIV", 12)) {
#ifdef LOG_AUTHPRIV
      *iv_return = LOG_AUTHPRIV;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 15:
    if (memEQ(name, "LOG_NFACILITIES", 15)) {
#ifdef LOG_NFACILITIES
      *iv_return = LOG_NFACILITIES;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

MODULE = Sys::Syslog		PACKAGE = Sys::Syslog		

char *
_PATH_LOG()
    CODE:
#ifdef _PATH_LOG
	RETVAL = _PATH_LOG;
#else
	RETVAL = "";
#endif
    OUTPUT:
	RETVAL

int
LOG_FAC(p)
    INPUT:
	int		p
    CODE:
#ifdef LOG_FAC
	RETVAL = LOG_FAC(p);
#else
	croak("Your vendor has not defined the Sys::Syslog macro LOG_FAC");
	RETVAL = -1;
#endif
    OUTPUT:
	RETVAL

int
LOG_PRI(p)
    INPUT:
	int		p
    CODE:
#ifdef LOG_PRI
	RETVAL = LOG_PRI(p);
#else
	croak("Your vendor has not defined the Sys::Syslog macro LOG_PRI");
	RETVAL = -1;
#endif
    OUTPUT:
	RETVAL

int
LOG_MAKEPRI(fac,pri)
    INPUT:
	int		fac
	int		pri
    CODE:
#ifdef LOG_MAKEPRI
	RETVAL = LOG_MAKEPRI(fac,pri);
#else
	croak("Your vendor has not defined the Sys::Syslog macro LOG_MAKEPRI");
	RETVAL = -1;
#endif
    OUTPUT:
	RETVAL

int
LOG_MASK(pri)
    INPUT:
	int		pri
    CODE:
#ifdef LOG_MASK
	RETVAL = LOG_MASK(pri);
#else
	croak("Your vendor has not defined the Sys::Syslog macro LOG_MASK");
	RETVAL = -1;
#endif
    OUTPUT:
	RETVAL

int
LOG_UPTO(pri)
    INPUT:
	int		pri
    CODE:
#ifdef LOG_UPTO
	RETVAL = LOG_UPTO(pri);
#else
	croak("Your vendor has not defined the Sys::Syslog macro LOG_UPTO");
	RETVAL = -1;
#endif
    OUTPUT:
	RETVAL


void
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(s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(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 Sys::Syslog macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(
	    "Your vendor has not defined Sys::Syslog macro %s used", s));
          PUSHs(sv);
          break;
        case PERL_constant_ISIV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHi(iv);
          break;
        default:
          sv = sv_2mortal(newSVpvf(
	    "Unexpected return type %d while processing Sys::Syslog macro %s used",
               type, s));
          PUSHs(sv);
        }

--dTy3Mrz/UPE2dbVg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Fcntl.xs"

#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#ifdef VMS
#  include <file.h>
#else
#if defined(__GNUC__) && defined(__cplusplus) && defined(WIN32)
#define _NO_OLDNAMES
#endif 
#  include <fcntl.h>
#if defined(__GNUC__) && defined(__cplusplus) && defined(WIN32)
#undef _NO_OLDNAMES
#endif 
#endif

#ifdef I_UNISTD
#include <unistd.h>
#endif

/* This comment is a kludge to get metaconfig to see the symbols
    VAL_O_NONBLOCK
    VAL_EAGAIN
    RD_NODATA
    EOF_NONBLOCK
   and include the appropriate metaconfig unit
   so that Configure will test how to turn on non-blocking I/O
   for a file descriptor.  See config.h for how to use these
   in your extension. 
   
   While I'm at it, I'll have metaconfig look for HAS_POLL too.
   --AD  October 16, 1995
*/

#define PERL_constant_NOTFOUND	1
#define PERL_constant_NOTDEF	2
#define PERL_constant_ISIV	3
#define PERL_constant_ISNV	4
#define PERL_constant_ISPV	5
#define PERL_constant_ISPVN	6
#define PERL_constant_ISUV	7

#ifndef NVTYPE
typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it.  */
#endif

static int
constant_5 (const char *name, IV *iv_return) {
  /* Names all of length 5.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     FEXCL FSYNC O_RAW */
  /* Offset 2 gives the best switch position.  */
  switch (name[2]) {
  case 'R':
    if (memEQ(name, "O_RAW", 5)) {
    /*                 ^        */
#ifdef O_RAW
      *iv_return = O_RAW;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "FEXCL", 5)) {
    /*                 ^        */
#ifdef FEXCL
      *iv_return = FEXCL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'Y':
    if (memEQ(name, "FSYNC", 5)) {
    /*                 ^        */
#ifdef FSYNC
      *iv_return = FSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_6 (const char *name, IV *iv_return) {
  /* Names all of length 6.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     FASYNC FCREAT FDEFER FDSYNC FRSYNC FTRUNC O_EXCL O_RDWR O_RSRC O_SYNC
     O_TEXT */
  /* Offset 3 gives the best switch position.  */
  switch (name[3]) {
  case 'D':
    if (memEQ(name, "O_RDWR", 6)) {
    /*                  ^        */
#ifdef O_RDWR
      *iv_return = O_RDWR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "FCREAT", 6)) {
    /*                  ^        */
#ifdef FCREAT
      *iv_return = FCREAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_TEXT", 6)) {
    /*                  ^        */
#ifdef O_TEXT
      *iv_return = O_TEXT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "FDEFER", 6)) {
    /*                  ^        */
#ifdef FDEFER
      *iv_return = FDEFER;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "O_RSRC", 6)) {
    /*                  ^        */
#ifdef O_RSRC
      *iv_return = O_RSRC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "FTRUNC", 6)) {
    /*                  ^        */
#ifdef FTRUNC
      *iv_return = FTRUNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "O_EXCL", 6)) {
    /*                  ^        */
#ifdef O_EXCL
      *iv_return = O_EXCL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'Y':
    if (memEQ(name, "FASYNC", 6)) {
    /*                  ^        */
#ifdef FASYNC
      *iv_return = FASYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "FDSYNC", 6)) {
    /*                  ^        */
#ifdef FDSYNC
      *iv_return = FDSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "FRSYNC", 6)) {
    /*                  ^        */
#ifdef FRSYNC
      *iv_return = FRSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_SYNC", 6)) {
    /*                  ^        */
#ifdef O_SYNC
      *iv_return = O_SYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_7 (const char *name, IV *iv_return) {
  /* Names all of length 7.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     FAPPEND FNDELAY F_DUPFD F_EXLCK F_FSYNC F_GETFD F_GETFL F_GETLK F_NODNY
     F_POSIX F_RDACC F_RDDNY F_RDLCK F_RWACC F_RWDNY F_SETFD F_SETFL F_SETLK
     F_SHARE F_SHLCK F_UNLCK F_WRACC F_WRDNY F_WRLCK LOCK_EX LOCK_NB LOCK_SH
     LOCK_UN O_ALIAS O_ASYNC O_CREAT O_DEFER O_DSYNC O_RSYNC O_TRUNC S_ENFMT
     S_IEXEC S_IFBLK S_IFCHR S_IFDIR S_IFIFO S_IFLNK S_IFREG S_IFWHT S_IREAD
     S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISTXT S_ISUID
     S_ISVTX S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR _S_IFMT */
  /* Offset 4 gives the best switch position.  */
  switch (name[4]) {
  case 'A':
    if (memEQ(name, "F_RDACC", 7)) {
    /*                   ^        */
#ifdef F_RDACC
      *iv_return = F_RDACC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_RWACC", 7)) {
    /*                   ^        */
#ifdef F_RWACC
      *iv_return = F_RWACC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SHARE", 7)) {
    /*                   ^        */
#ifdef F_SHARE
      *iv_return = F_SHARE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_WRACC", 7)) {
    /*                   ^        */
#ifdef F_WRACC
      *iv_return = F_WRACC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'B':
    if (memEQ(name, "S_IFBLK", 7)) {
    /*                   ^        */
#ifdef S_IFBLK
      *iv_return = S_IFBLK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'C':
    if (memEQ(name, "S_IFCHR", 7)) {
    /*                   ^        */
#ifdef S_IFCHR
      *iv_return = S_IFCHR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "F_NODNY", 7)) {
    /*                   ^        */
#ifdef F_NODNY
      *iv_return = F_NODNY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_RDDNY", 7)) {
    /*                   ^        */
#ifdef F_RDDNY
      *iv_return = F_RDDNY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_RWDNY", 7)) {
    /*                   ^        */
#ifdef F_RWDNY
      *iv_return = F_RWDNY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_WRDNY", 7)) {
    /*                   ^        */
#ifdef F_WRDNY
      *iv_return = F_WRDNY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IFDIR", 7)) {
    /*                   ^        */
#ifdef S_IFDIR
      *iv_return = S_IFDIR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "FAPPEND", 7)) {
    /*                   ^        */
#ifdef FAPPEND
      *iv_return = FAPPEND;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_CREAT", 7)) {
    /*                   ^        */
#ifdef O_CREAT
      *iv_return = O_CREAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IREAD", 7)) {
    /*                   ^        */
#ifdef S_IREAD
      *iv_return = S_IREAD;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "O_DEFER", 7)) {
    /*                   ^        */
#ifdef O_DEFER
      *iv_return = O_DEFER;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_ENFMT", 7)) {
    /*                   ^        */
#ifdef S_ENFMT
      *iv_return = S_ENFMT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "_S_IFMT", 7)) {
    /*                   ^        */
#ifdef S_IFMT
      *iv_return = S_IFMT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "S_IRGRP", 7)) {
    /*                   ^        */
#ifdef S_IRGRP
      *iv_return = S_IRGRP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_ISGID", 7)) {
    /*                   ^        */
#ifdef S_ISGID
      *iv_return = S_ISGID;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IWGRP", 7)) {
    /*                   ^        */
#ifdef S_IWGRP
      *iv_return = S_IWGRP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IXGRP", 7)) {
    /*                   ^        */
#ifdef S_IXGRP
      *iv_return = S_IXGRP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "O_ALIAS", 7)) {
    /*                   ^        */
#ifdef O_ALIAS
      *iv_return = O_ALIAS;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IFIFO", 7)) {
    /*                   ^        */
#ifdef S_IFIFO
      *iv_return = S_IFIFO;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "FNDELAY", 7)) {
    /*                   ^        */
#ifdef FNDELAY
      *iv_return = FNDELAY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_EXLCK", 7)) {
    /*                   ^        */
#ifdef F_EXLCK
      *iv_return = F_EXLCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_RDLCK", 7)) {
    /*                   ^        */
#ifdef F_RDLCK
      *iv_return = F_RDLCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SHLCK", 7)) {
    /*                   ^        */
#ifdef F_SHLCK
      *iv_return = F_SHLCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_UNLCK", 7)) {
    /*                   ^        */
#ifdef F_UNLCK
      *iv_return = F_UNLCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_WRLCK", 7)) {
    /*                   ^        */
#ifdef F_WRLCK
      *iv_return = F_WRLCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IFLNK", 7)) {
    /*                   ^        */
#ifdef S_IFLNK
      *iv_return = S_IFLNK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "S_IROTH", 7)) {
    /*                   ^        */
#ifdef S_IROTH
      *iv_return = S_IROTH;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IWOTH", 7)) {
    /*                   ^        */
#ifdef S_IWOTH
      *iv_return = S_IWOTH;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IXOTH", 7)) {
    /*                   ^        */
#ifdef S_IXOTH
      *iv_return = S_IXOTH;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "F_DUPFD", 7)) {
    /*                   ^        */
#ifdef F_DUPFD
      *iv_return = F_DUPFD;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "S_IFREG", 7)) {
    /*                   ^        */
#ifdef S_IFREG
      *iv_return = S_IFREG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "F_POSIX", 7)) {
    /*                   ^        */
#ifdef F_POSIX
      *iv_return = F_POSIX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "F_GETFD", 7)) {
    /*                   ^        */
#ifdef F_GETFD
      *iv_return = F_GETFD;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_GETFL", 7)) {
    /*                   ^        */
#ifdef F_GETFL
      *iv_return = F_GETFL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_GETLK", 7)) {
    /*                   ^        */
#ifdef F_GETLK
      *iv_return = F_GETLK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SETFD", 7)) {
    /*                   ^        */
#ifdef F_SETFD
      *iv_return = F_SETFD;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SETFL", 7)) {
    /*                   ^        */
#ifdef F_SETFL
      *iv_return = F_SETFL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SETLK", 7)) {
    /*                   ^        */
#ifdef F_SETLK
      *iv_return = F_SETLK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_ISTXT", 7)) {
    /*                   ^        */
#ifdef S_ISTXT
      *iv_return = S_ISTXT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "O_TRUNC", 7)) {
    /*                   ^        */
#ifdef O_TRUNC
      *iv_return = O_TRUNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IRUSR", 7)) {
    /*                   ^        */
#ifdef S_IRUSR
      *iv_return = S_IRUSR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_ISUID", 7)) {
    /*                   ^        */
#ifdef S_ISUID
      *iv_return = S_ISUID;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IWUSR", 7)) {
    /*                   ^        */
#ifdef S_IWUSR
      *iv_return = S_IWUSR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IXUSR", 7)) {
    /*                   ^        */
#ifdef S_IXUSR
      *iv_return = S_IXUSR;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'V':
    if (memEQ(name, "S_ISVTX", 7)) {
    /*                   ^        */
#ifdef S_ISVTX
      *iv_return = S_ISVTX;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'W':
    if (memEQ(name, "S_IFWHT", 7)) {
    /*                   ^        */
#ifdef S_IFWHT
      *iv_return = S_IFWHT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IRWXG", 7)) {
    /*                   ^        */
#ifdef S_IRWXG
      *iv_return = S_IRWXG;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IRWXO", 7)) {
    /*                   ^        */
#ifdef S_IRWXO
      *iv_return = S_IRWXO;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "S_IRWXU", 7)) {
    /*                   ^        */
#ifdef S_IRWXU
      *iv_return = S_IRWXU;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "S_IEXEC", 7)) {
    /*                   ^        */
#ifdef S_IEXEC
      *iv_return = S_IEXEC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'Y':
    if (memEQ(name, "F_FSYNC", 7)) {
    /*                   ^        */
#ifdef F_FSYNC
      *iv_return = F_FSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_ASYNC", 7)) {
    /*                   ^        */
#ifdef O_ASYNC
      *iv_return = O_ASYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_DSYNC", 7)) {
    /*                   ^        */
#ifdef O_DSYNC
      *iv_return = O_DSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_RSYNC", 7)) {
    /*                   ^        */
#ifdef O_RSYNC
      *iv_return = O_RSYNC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case '_':
    if (memEQ(name, "LOCK_EX", 7)) {
    /*                   ^        */
#ifdef LOCK_EX
      *iv_return = LOCK_EX;
      return PERL_constant_ISIV;
#else
      *iv_return = 2;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "LOCK_NB", 7)) {
    /*                   ^        */
#ifdef LOCK_NB
      *iv_return = LOCK_NB;
      return PERL_constant_ISIV;
#else
      *iv_return = 4;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "LOCK_SH", 7)) {
    /*                   ^        */
#ifdef LOCK_SH
      *iv_return = LOCK_SH;
      return PERL_constant_ISIV;
#else
      *iv_return = 1;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "LOCK_UN", 7)) {
    /*                   ^        */
#ifdef LOCK_UN
      *iv_return = LOCK_UN;
      return PERL_constant_ISIV;
#else
      *iv_return = 8;
      return PERL_constant_ISIV;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_8 (const char *name, IV *iv_return) {
  /* Names all of length 8.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     F_COMPAT F_DUP2FD F_FREESP F_GETOWN F_SETLKW F_SETOWN O_APPEND O_BINARY
     O_DIRECT O_EXLOCK O_NDELAY O_NOCTTY O_RANDOM O_RDONLY O_SHLOCK O_WRONLY
     SEEK_CUR SEEK_END SEEK_SET S_IFSOCK S_IWRITE */
  /* Offset 3 gives the best switch position.  */
  switch (name[3]) {
  case 'A':
    if (memEQ(name, "O_RANDOM", 8)) {
    /*                  ^          */
#ifdef O_RANDOM
      *iv_return = O_RANDOM;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'D':
    if (memEQ(name, "O_NDELAY", 8)) {
    /*                  ^          */
#ifdef O_NDELAY
      *iv_return = O_NDELAY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_RDONLY", 8)) {
    /*                  ^          */
#ifdef O_RDONLY
      *iv_return = O_RDONLY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'E':
    if (memEQ(name, "F_GETOWN", 8)) {
    /*                  ^          */
#ifdef F_GETOWN
      *iv_return = F_GETOWN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SETLKW", 8)) {
    /*                  ^          */
#ifdef F_SETLKW
      *iv_return = F_SETLKW;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "F_SETOWN", 8)) {
    /*                  ^          */
#ifdef F_SETOWN
      *iv_return = F_SETOWN;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "S_IFSOCK", 8)) {
    /*                  ^          */
#ifdef S_IFSOCK
      *iv_return = S_IFSOCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'H':
    if (memEQ(name, "O_SHLOCK", 8)) {
    /*                  ^          */
#ifdef O_SHLOCK
      *iv_return = O_SHLOCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'I':
    if (memEQ(name, "O_BINARY", 8)) {
    /*                  ^          */
#ifdef O_BINARY
      *iv_return = O_BINARY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_DIRECT", 8)) {
    /*                  ^          */
#ifdef O_DIRECT
      *iv_return = O_DIRECT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'K':
    if (memEQ(name, "SEEK_CUR", 8)) {
    /*                  ^          */
#ifdef SEEK_CUR
      *iv_return = SEEK_CUR;
      return PERL_constant_ISIV;
#else
      *iv_return = 1;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "SEEK_END", 8)) {
    /*                  ^          */
#ifdef SEEK_END
      *iv_return = SEEK_END;
      return PERL_constant_ISIV;
#else
      *iv_return = 2;
      return PERL_constant_ISIV;
#endif
    }
    if (memEQ(name, "SEEK_SET", 8)) {
    /*                  ^          */
#ifdef SEEK_SET
      *iv_return = SEEK_SET;
      return PERL_constant_ISIV;
#else
      *iv_return = 0;
      return PERL_constant_ISIV;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "F_COMPAT", 8)) {
    /*                  ^          */
#ifdef F_COMPAT
      *iv_return = F_COMPAT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_NOCTTY", 8)) {
    /*                  ^          */
#ifdef O_NOCTTY
      *iv_return = O_NOCTTY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "O_APPEND", 8)) {
    /*                  ^          */
#ifdef O_APPEND
      *iv_return = O_APPEND;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'R':
    if (memEQ(name, "F_FREESP", 8)) {
    /*                  ^          */
#ifdef F_FREESP
      *iv_return = F_FREESP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_WRONLY", 8)) {
    /*                  ^          */
#ifdef O_WRONLY
      *iv_return = O_WRONLY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "F_DUP2FD", 8)) {
    /*                  ^          */
#ifdef F_DUP2FD
      *iv_return = F_DUP2FD;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'W':
    if (memEQ(name, "S_IWRITE", 8)) {
    /*                  ^          */
#ifdef S_IWRITE
      *iv_return = S_IWRITE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'X':
    if (memEQ(name, "O_EXLOCK", 8)) {
    /*                  ^          */
#ifdef O_EXLOCK
      *iv_return = O_EXLOCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_9 (const char *name, IV *iv_return) {
  /* Names all of length 9.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     FNONBLOCK F_ALLOCSP F_FSYNC64 F_GETLK64 F_SETLK64 F_UNSHARE O_ACCMODE */
  /* Offset 2 gives the best switch position.  */
  switch (name[2]) {
  case 'A':
    if (memEQ(name, "F_ALLOCSP", 9)) {
    /*                 ^            */
#ifdef F_ALLOCSP
      *iv_return = F_ALLOCSP;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    if (memEQ(name, "O_ACCMODE", 9)) {
    /*                 ^            */
#ifdef O_ACCMODE
      *iv_return = O_ACCMODE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "F_FSYNC64", 9)) {
    /*                 ^            */
#ifdef F_FSYNC64
      *iv_return = F_FSYNC64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "F_GETLK64", 9)) {
    /*                 ^            */
#ifdef F_GETLK64
      *iv_return = F_GETLK64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "FNONBLOCK", 9)) {
    /*                 ^            */
#ifdef FNONBLOCK
      *iv_return = FNONBLOCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'S':
    if (memEQ(name, "F_SETLK64", 9)) {
    /*                 ^            */
#ifdef F_SETLK64
      *iv_return = F_SETLK64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'U':
    if (memEQ(name, "F_UNSHARE", 9)) {
    /*                 ^            */
#ifdef F_UNSHARE
      *iv_return = F_UNSHARE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_10 (const char *name, IV *iv_return) {
  /* Names all of length 10.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     FD_CLOEXEC FLARGEFILE F_FREESP64 F_SETLKW64 O_NOFOLLOW O_NONBLOCK */
  /* Offset 4 gives the best switch position.  */
  switch (name[4]) {
  case 'E':
    if (memEQ(name, "F_FREESP64", 10)) {
    /*                   ^            */
#ifdef F_FREESP64
      *iv_return = F_FREESP64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'F':
    if (memEQ(name, "O_NOFOLLOW", 10)) {
    /*                   ^            */
#ifdef O_NOFOLLOW
      *iv_return = O_NOFOLLOW;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "FLARGEFILE", 10)) {
    /*                   ^            */
#ifdef FLARGEFILE
      *iv_return = FLARGEFILE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'L':
    if (memEQ(name, "FD_CLOEXEC", 10)) {
    /*                   ^            */
#ifdef FD_CLOEXEC
      *iv_return = FD_CLOEXEC;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "O_NONBLOCK", 10)) {
    /*                   ^            */
#ifdef O_NONBLOCK
      *iv_return = O_NONBLOCK;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'T':
    if (memEQ(name, "F_SETLKW64", 10)) {
    /*                   ^            */
#ifdef F_SETLKW64
      *iv_return = F_SETLKW64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant_11 (const char *name, IV *iv_return) {
  /* Names all of length 11.  */
  /* When generated this function returned values for the list of names given
     here.  However, subsequent manual editing may have added or removed some.
     F_ALLOCSP64 O_DIRECTORY O_LARGEFILE O_NOINHERIT O_TEMPORARY */
  /* Offset 5 gives the best switch position.  */
  switch (name[5]) {
  case 'E':
    if (memEQ(name, "O_DIRECTORY", 11)) {
    /*                    ^            */
#ifdef O_DIRECTORY
      *iv_return = O_DIRECTORY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'G':
    if (memEQ(name, "O_LARGEFILE", 11)) {
    /*                    ^            */
#ifdef O_LARGEFILE
      *iv_return = O_LARGEFILE;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'N':
    if (memEQ(name, "O_NOINHERIT", 11)) {
    /*                    ^            */
#ifdef O_NOINHERIT
      *iv_return = O_NOINHERIT;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'O':
    if (memEQ(name, "F_ALLOCSP64", 11)) {
    /*                    ^            */
#ifdef F_ALLOCSP64
      *iv_return = F_ALLOCSP64;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  case 'P':
    if (memEQ(name, "O_TEMPORARY", 11)) {
    /*                    ^            */
#ifdef O_TEMPORARY
      *iv_return = O_TEMPORARY;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

static int
constant (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

#!perl -w
use ExtUtils::Constant qw (constant_types C_constant XS_constant);

my $types = {IV => 1};
my @names = (qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FD_CLOEXEC FEXCL FLARGEFILE
	       FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC F_ALLOCSP F_ALLOCSP64
	       F_COMPAT F_DUP2FD F_DUPFD F_EXLCK F_FREESP F_FREESP64 F_FSYNC
	       F_FSYNC64 F_GETFD F_GETFL F_GETLK F_GETLK64 F_GETOWN F_NODNY
	       F_POSIX F_RDACC F_RDDNY F_RDLCK F_RWACC F_RWDNY F_SETFD F_SETFL
	       F_SETLK F_SETLK64 F_SETLKW F_SETLKW64 F_SETOWN F_SHARE F_SHLCK
	       F_UNLCK F_UNSHARE F_WRACC F_WRDNY F_WRLCK O_ACCMODE O_ALIAS
	       O_APPEND O_ASYNC O_BINARY O_CREAT O_DEFER O_DIRECT O_DIRECTORY
	       O_DSYNC O_EXCL O_EXLOCK O_LARGEFILE O_NDELAY O_NOCTTY O_NOFOLLOW
	       O_NOINHERIT O_NONBLOCK O_RANDOM O_RAW O_RDONLY O_RDWR O_RSRC
	       O_RSYNC O_SEQUENTIAL O_SHLOCK O_SYNC O_TEMPORARY O_TEXT O_TRUNC
	       O_WRONLY S_ENFMT S_IEXEC S_IFBLK S_IFCHR S_IFDIR S_IFIFO S_IFLNK
	       S_IFREG S_IFSOCK S_IFWHT S_IREAD S_IRGRP S_IROTH S_IRUSR S_IRWXG
	       S_IRWXO S_IRWXU S_ISGID S_ISTXT S_ISUID S_ISVTX S_IWGRP S_IWOTH
	       S_IWRITE S_IWUSR S_IXGRP S_IXOTH S_IXUSR),
            {name=>"LOCK_EX", type=>"IV", default=>["IV", "2"]},
            {name=>"LOCK_NB", type=>"IV", default=>["IV", "4"]},
            {name=>"LOCK_SH", type=>"IV", default=>["IV", "1"]},
            {name=>"LOCK_UN", type=>"IV", default=>["IV", "8"]},
            {name=>"SEEK_CUR", type=>"IV", default=>["IV", "1"]},
            {name=>"SEEK_END", type=>"IV", default=>["IV", "2"]},
            {name=>"SEEK_SET", type=>"IV", default=>["IV", "0"]},
            {name=>"_S_IFMT", type=>"IV", macro=>"S_IFMT", value=>"S_IFMT"});

print constant_types(); # macro defs
foreach (C_constant ("Fcntl", 'constant', 'IV', $types, undef, undef, @names) ) {
    print $_, "\n"; # C constant subs
}
print "#### XS Section:\n";
print XS_constant ("Fcntl", $types);
__END__
   */

  switch (len) {
  case 5:
    return constant_5 (name, iv_return);
    break;
  case 6:
    return constant_6 (name, iv_return);
    break;
  case 7:
    return constant_7 (name, iv_return);
    break;
  case 8:
    return constant_8 (name, iv_return);
    break;
  case 9:
    return constant_9 (name, iv_return);
    break;
  case 10:
    return constant_10 (name, iv_return);
    break;
  case 11:
    return constant_11 (name, iv_return);
    break;
  case 12:
    if (memEQ(name, "O_SEQUENTIAL", 12)) {
#ifdef O_SEQUENTIAL
      *iv_return = O_SEQUENTIAL;
      return PERL_constant_ISIV;
#else
      return PERL_constant_NOTDEF;
#endif
    }
    break;
  }
  return PERL_constant_NOTFOUND;
}

MODULE = Fcntl		PACKAGE = Fcntl

void
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(s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(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 Fcntl macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(
	    "Your vendor has not defined Fcntl 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 UVs
        case PERL_constant_ISUV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHu((UV)iv);
          break; */
        default:
          sv = sv_2mortal(newSVpvf(
	    "Unexpected return type %d while processing Fcntl macro %s used",
               type, s));
          PUSHs(sv);
        }

--dTy3Mrz/UPE2dbVg--
0
nick
6/3/2001 4:54:36 PM
On Sun, Jun 03, 2001 at 05:54:36PM +0100, Nicholas Clark wrote:
> On Sun, Jun 03, 2001 at 10:40:21AM -0500, Jarkko Hietaniemi wrote:
> > On Sun, Jun 03, 2001 at 03:03:46PM +0100, Nicholas Clark wrote:
> > > In Socket.xs do I take it that this
> > > 
> > > 	if (strEQ(name, "MSG_CTRUNC"))
> > > #if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */
> > > 	    return MSG_CTRUNC;
> > > #else
> > > 	    goto not_there;
> > > #endif

> They return IVs (by default) not NVs.
> They don't set errno. (Which is the principal backward incompatibility, but
> will be seen as an improvement by some people on this list)
> The enclosed perl code can regenerate the switch statements.
> [And has been dogfood tested to add MSG_URG.]

Oh. and as there are no not_there: labels (and no gotos) there are no
not_there: labels for gcc -Wall to warn are never used. :-)

Hangon. That should be the principal selling point, shouldn't it?
I've just supplied a patch that removes 256 gotos 

Nicholas Clark
0
nick
6/3/2001 5:03:19 PM
Reply:

Similar Artilces:

[PATCH] Fix declaration-after-statement in ext/Socket/Socket.xs
This trivial patch lets C89-ish compilers compile Socket.c again. --- perl-current/ext/Socket/Socket.xs Thu Mar 26 20:02:08 2009 +++ perl-andy/ext/Socket/Socket.xs Thu Apr 9 10:05:26 2009 @@ -477,13 +477,14 @@ const char * host CODE: #ifdef HAS_INETPTON + int ok; struct in6_addr ip_address; if(af != AF_INET && af != AF_INET6) { croak("Bad address family for %s, got %d, should be either AF_INET or AF_INET6", "Socket::inet_pton", af); } ...

[PATCH] Whitespace fixes in ext/Socket/Socket.{pm,xs}
--tsOsTdHNUZQcU9Ye Content-Type: multipart/mixed; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The attached patch fixes whitespace in recent code added to Socket.{xs,pm} to be consistent with the rest of the files. No functionallity change. --=20 Paul "LeoNerd" Evans leonerd@leonerd.org.uk ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/ --3MwIy2ne0vdjdPXF Content-Type: text/x-di...

Coverity FORWARD NULL finding in ext/Socket/Socket.c XS_Socket_inet_aton
It doesn't like this bit: int ok = (host != NULL) && (*host != '\0') && inet_aton(host, &ip_address); if (!ok && (phe = gethostbyname(host))) { where host is set to SvPV_nolen(ST(0)). I don't think sv_2pv_flags *can* return NULL in the first place, so perhaps the host != NULL check should be removed. If somehow it can return NULL, gethostbyname shouldn't be called when host is NULL. On Mon, Apr 10, 2006 at 01:51:32AM -0700, Yitzchak Scott-Thoennes wrote: > It doesn't like this bit: > > int ok = > ...

Socket to Socket example needed
Does anyone have any configuration examples of how to set up a socket to socket connection. I would appeciate any examples or help anyone can offer. Thanks. Rob McGinness Rutland Regional Medical Center 802-747-6526 rmcginness@rrmc.org I guess that you talk about one AIM module that drives two socket conections. If you try to build such module, you must create two protocol objects within the project. Each protocol object can control its own related objects (frame, port, open, close, etc.) > Does anyone have any configuration examples of how to set > up a socket to socke...

SOCKET
Hi all!!! Can any body help me with some information or docs about Sockets with Power Builder. I'm Working with PB 6.5, but if you have an example in PB 7 I can use it. Now I'm waiting for your help. :-) If you mean three-tier apps, pb has it's own communication objects (transport, connection). If you need something more than that you can use third-party libraries as OLE objects, because you can't work from pob directly with wsock32.dll. <CARRADINE> wrote in message news:1111D847FE7E5A290058E38C85256C75.0058E3D185256C75@webforums... > Hi all!...

Socket
How to get the ipaddress of the client machine using Socket programing,i want to check which r the pc's r connected to the server using vb.net any example will be very helpfull for me thanks in advance PrasantHI think therefore i'mvPras© If you're representing the client as a Socket, this class has a RemoteEndPoint Public property that is of type EndPoint. It encapsulates information about the client. If you're representing the client as a TcpClient, this class has a Protected Client property of type Socket (thus getting to the RemoteEndPoint). Protected meaning you have ...

Socket
Dear The Expert, Where can I find complete articles for implementing windows socket in ASP.NET? TIA Winan...

socket
Hola, qualcuno sa dirmi perch�: #!/usr/bin/perl use IO::Socket; #use diagnostics; my $host=$ARGV[0]; if(!$host){ die"...host???\n"; } $|=1; $socket=IO::Socket::INET->new(PeerAddr =>$host, PeerPort=>80, Proto=>"TCP") || die"$!\n"; print $socket "GET / HTTP/1.0\r\n\r\n"; while(<$socket>){ print"$_\n"; } close($socket); FUNZIONA (scrivi e leggo dal socket),mentre al contrario: #!/usr/bin/perl use Socket; #use diagnostics; my $host=$ARGV[0]; if(!$host){ die"...host???\n"...

socket
perlipc doc has sample for doing a socket: use IO::Socket; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "localhost", PeerPort => "daytime(13)", ) or die "cannot connect to daytime port at localhost"; while ( <$remote> ) { print } but it dies for me. i see 'daytime' in /etc/services at port 13. osx 10.1.3 perl 5.6.1 Just because something's in services, doesn't mean it's running. Services indicates "names" for port numbers, e.g., &quo...

socket()
I have never used perl before today. I am trying to run a perl script in windows that works fine in linux, but it keeps stopping at a socket line, giving the following message: Invalid argument at ./src/Irc.pl line 21, <FH> chunk 60. Everything that I have looked at pointe me to: http://www.perldoc.com/perl5.6/pod/perlipc.html but when I go there, I get a blank page. Viewing the source, I can see that the page has completed loading, but has nothing between the &lt;body> and &lt;/body> tags. Can anyone give me some info on the socket() command? Is there something...

Sockets
Hi, Is it possible to make a sockets connection with PB6.5? (and how) Thanks in advance, Joe I think this is what you're looking for http://www.teamsybase.com/roy.kiesler/downloads/wininet.zip HTH Arnoud Url: http://www.gloriant.be <Joe> wrote in message news:7F08A3D1FC072C7E003E028585256CC2.003E029385256CC2@webforums... > Hi, > > Is it possible to make a sockets connection with PB6.5? (and how) > > > Thanks in advance, > Joe > WinInet cannot be used for raw socket connection -- it is a simple wrapper for FTP/HTTP/Gop...

Sockets
PB8.0 W2K What do people use to implement sockets in PB? Nathan I just use the API functions. On Tue, 31 Dec 2002 11:02:34 -0600, NP <tarsi@no-see-evil.binhost.com> wrote: >PB8.0 >W2K > >What do people use to implement sockets in PB? > >Nathan Bruce Armstrong [TeamSybase] http://www.teamsybase.com Not 1 - but 2 new books on developing with PowerBuilder http://www.pb9books.com Which can now be pre-ordered through Amazon.com http://www.amazon.com/exec/obidos/tg/detail/-/0672325004 http://www.amazon.com/exec/obidos/tg/detail/-/0672324997...

Sockets
Does anyone have a suggestion for the easiest and best way to implement sockets in their PB application? Thanks. Shenn Sellers waste.ssellers@co.riverside.ca.us I use freeware OCX (SocketWrench) from Catalyst (www.catalyst.com) Wether it is the best implementation I don't know, but it works for me. Maciek. Shenn Sellers wrote: >Does anyone have a suggestion for the easiest and best way to implement >sockets in their PB application? > >Thanks. > >Shenn Sellers >waste.ssellers@co.riverside.ca.us > > > ...

sockets
i am new in sockets i have a device that sends to my web application through TCPIP my web application is hosted in a real IP how can i recieve the data sent by that device? do i have to write the code in the default web site page?     Hi hishamabdelrahman, As far as I know, if you want to communicate with HTTP web server by using socket, you should use the HTTP protocol, please refer the URL below.http://www.faqs.org/rfcs/rfc2616.html For Socket class, please refer the Microsoft web site.http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket.aspx And I think ...

Web resources about - ext/Socket/Socket.xs - perl.perl5.porters

Resources last updated: 12/4/2015 8:55:40 PM