diff options
Diffstat (limited to 'ext/Socket')
-rw-r--r-- | ext/Socket/Socket.xs | 1724 |
1 files changed, 1214 insertions, 510 deletions
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index e08982909b..1a21396e1c 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -174,740 +174,1444 @@ not_here(char *s) return -1; } -static double -constant(char *name, int arg) -{ - errno = 0; - switch (*name) { - case 'A': - if (strEQ(name, "AF_802")) -#ifdef AF_802 - return AF_802; -#else - goto not_there; -#endif - if (strEQ(name, "AF_APPLETALK")) -#ifdef AF_APPLETALK - return AF_APPLETALK; -#else - goto not_there; +#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 - if (strEQ(name, "AF_CCITT")) -#ifdef AF_CCITT - return AF_CCITT; + +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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_CHAOS")) -#ifdef AF_CHAOS - return AF_CHAOS; + } + break; + case 'P': + if (memEQ(name, "PF_NS", 5)) { + /* ^ */ +#ifdef PF_NS + *iv_return = PF_NS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_DATAKIT")) -#ifdef AF_DATAKIT - return AF_DATAKIT; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_DECnet")) -#ifdef AF_DECnet - return AF_DECnet; + } + if (memEQ(name, "PF_802", 6)) { + /* ^ */ +#ifdef PF_802 + *iv_return = PF_802; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_DLI")) + } + break; + case 'D': + if (memEQ(name, "AF_DLI", 6)) { + /* ^ */ #ifdef AF_DLI - return AF_DLI; + *iv_return = AF_DLI; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_ECMA")) -#ifdef AF_ECMA - return AF_ECMA; -#else - goto not_there; -#endif - if (strEQ(name, "AF_GOSIP")) -#ifdef AF_GOSIP - return AF_GOSIP; -#else - goto not_there; -#endif - if (strEQ(name, "AF_HYLINK")) -#ifdef AF_HYLINK - return AF_HYLINK; + } + if (memEQ(name, "PF_DLI", 6)) { + /* ^ */ +#ifdef PF_DLI + *iv_return = PF_DLI; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_IMPLINK")) -#ifdef AF_IMPLINK - return AF_IMPLINK; + } + break; + case 'L': + if (memEQ(name, "AF_LAT", 6)) { + /* ^ */ +#ifdef AF_LAT + *iv_return = AF_LAT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_INET")) -#ifdef AF_INET - return AF_INET; + } + if (memEQ(name, "PF_LAT", 6)) { + /* ^ */ +#ifdef PF_LAT + *iv_return = PF_LAT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_LAT")) -#ifdef AF_LAT - return AF_LAT; + } + break; + case 'M': + if (memEQ(name, "AF_MAX", 6)) { + /* ^ */ +#ifdef AF_MAX + *iv_return = AF_MAX; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_MAX")) -#ifdef AF_MAX - return AF_MAX; + } + if (memEQ(name, "PF_MAX", 6)) { + /* ^ */ +#ifdef PF_MAX + *iv_return = PF_MAX; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_NBS")) + } + break; + case 'N': + if (memEQ(name, "AF_NBS", 6)) { + /* ^ */ #ifdef AF_NBS - return AF_NBS; + *iv_return = AF_NBS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_NIT")) + } + if (memEQ(name, "AF_NIT", 6)) { + /* ^ */ #ifdef AF_NIT - return AF_NIT; + *iv_return = AF_NIT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_NS")) -#ifdef AF_NS - return AF_NS; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_OSI")) + } + break; + case 'O': + if (memEQ(name, "AF_OSI", 6)) { + /* ^ */ #ifdef AF_OSI - return AF_OSI; + *iv_return = AF_OSI; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_OSINET")) -#ifdef AF_OSINET - return AF_OSINET; + } + if (memEQ(name, "PF_OSI", 6)) { + /* ^ */ +#ifdef PF_OSI + *iv_return = PF_OSI; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_PUP")) + } + break; + case 'P': + if (memEQ(name, "AF_PUP", 6)) { + /* ^ */ #ifdef AF_PUP - return AF_PUP; + *iv_return = AF_PUP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_SNA")) -#ifdef AF_SNA - return AF_SNA; + } + if (memEQ(name, "PF_PUP", 6)) { + /* ^ */ +#ifdef PF_PUP + *iv_return = PF_PUP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_UNIX")) -#ifdef AF_UNIX - return AF_UNIX; + } + break; + case 'S': + if (memEQ(name, "AF_SNA", 6)) { + /* ^ */ +#ifdef AF_SNA + *iv_return = AF_SNA; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_UNSPEC")) -#ifdef AF_UNSPEC - return AF_UNSPEC; + } + if (memEQ(name, "PF_SNA", 6)) { + /* ^ */ +#ifdef PF_SNA + *iv_return = PF_SNA; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "AF_X25")) + } + break; + case 'X': + if (memEQ(name, "AF_X25", 6)) { + /* ^ */ #ifdef AF_X25 - return AF_X25; -#else - goto not_there; -#endif - break; - case 'B': - break; - case 'C': - break; - case 'D': - break; - case 'E': - break; - case 'F': - break; - case 'G': - break; - case 'H': - break; - case 'I': - if (strEQ(name, "IOV_MAX")) -#ifdef IOV_MAX - return IOV_MAX; + *iv_return = AF_X25; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "IPPROTO_TCP")) -#ifdef IPPROTO_TCP - return IPPROTO_TCP; -#else - goto not_there; -#endif - break; - case 'J': - break; - case 'K': - break; - case 'L': - break; - case 'M': - if (strEQ(name, "MSG_BCAST")) -#ifdef MSG_BCAST - return MSG_BCAST; + } + if (memEQ(name, "PF_X25", 6)) { + /* ^ */ +#ifdef PF_X25 + *iv_return = PF_X25; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_CTLFLAGS")) -#ifdef MSG_CTLFLAGS - return MSG_CTLFLAGS; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_CTLIGNORE")) -#ifdef MSG_CTLIGNORE - return MSG_CTLIGNORE; + } + if (memEQ(name, "PF_ECMA", 7)) { + /* ^ */ +#ifdef PF_ECMA + *iv_return = PF_ECMA; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_CTRUNC")) -#if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */ - return MSG_CTRUNC; + } + break; + case 'E': + if (memEQ(name, "MSG_EOF", 7)) { + /* ^ */ +#ifdef MSG_EOF + *iv_return = MSG_EOF; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_DONTROUTE")) -#if defined(MSG_DONTROUTE) || defined(HAS_MSG_DONTROUTE) /* might be an enum */ - return MSG_DONTROUTE; + } + if (memEQ(name, "MSG_EOR", 7)) { + /* ^ */ +#ifdef MSG_EOR + *iv_return = MSG_EOR; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_DONTWAIT")) -#ifdef MSG_DONTWAIT - return MSG_DONTWAIT; + } + break; + case 'F': + if (memEQ(name, "MSG_FIN", 7)) { + /* ^ */ +#ifdef MSG_FIN + *iv_return = MSG_FIN; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_EOF")) -#ifdef MSG_EOF - return MSG_EOF; + } + break; + case 'M': + if (memEQ(name, "IOV_MAX", 7)) { + /* ^ */ +#ifdef IOV_MAX + *iv_return = IOV_MAX; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_EOR")) -#ifdef MSG_EOR - return MSG_EOR; + } + break; + case 'N': + if (memEQ(name, "AF_INET", 7)) { + /* ^ */ +#ifdef AF_INET + *iv_return = AF_INET; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_ERRQUEUE")) -#ifdef MSG_ERRQUEUE - return MSG_ERRQUEUE; + } + if (memEQ(name, "AF_UNIX", 7)) { + /* ^ */ +#ifdef AF_UNIX + *iv_return = AF_UNIX; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_FIN")) -#ifdef MSG_FIN - return MSG_FIN; + } + if (memEQ(name, "PF_INET", 7)) { + /* ^ */ +#ifdef PF_INET + *iv_return = PF_INET; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_MAXIOVLEN")) -#ifdef MSG_MAXIOVLEN - return MSG_MAXIOVLEN; + } + if (memEQ(name, "PF_UNIX", 7)) { + /* ^ */ +#ifdef PF_UNIX + *iv_return = PF_UNIX; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_MCAST")) -#ifdef MSG_MCAST - return MSG_MCAST; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_NOSIGNAL")) -#ifdef MSG_NOSIGNAL - return MSG_NOSIGNAL; + } + break; + case 'R': + if (memEQ(name, "MSG_RST", 7)) { + /* ^ */ +#ifdef MSG_RST + *iv_return = MSG_RST; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_OOB")) -#if defined(MSG_OOB) || defined(HAS_MSG_OOB) /* might be an enum */ - return MSG_OOB; + } + break; + case 'S': + if (memEQ(name, "MSG_SYN", 7)) { + /* ^ */ +#ifdef MSG_SYN + *iv_return = MSG_SYN; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_PEEK")) -#if defined(MSG_PEEK) || defined(HAS_MSG_PEEK) /* might be an enum */ - return MSG_PEEK; + } + break; + case 'U': + if (memEQ(name, "MSG_URG", 7)) { + /* ^ */ +#ifdef MSG_URG + *iv_return = MSG_URG; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_PROXY")) -#if defined(MSG_PROXY) || defined(HAS_MSG_PROXY) /* might be an enum */ - return MSG_PROXY; + } + break; + case 'Y': + if (memEQ(name, "SO_TYPE", 7)) { + /* ^ */ +#ifdef SO_TYPE + *iv_return = SO_TYPE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_RST")) -#ifdef MSG_RST - return MSG_RST; + } + break; + case '_': + if (memEQ(name, "SHUT_RD", 7)) { + /* ^ */ +#ifdef SHUT_RD + *iv_return = SHUT_RD; + return PERL_constant_ISIV; #else - goto not_there; + *iv_return = 0; + return PERL_constant_ISIV; #endif - if (strEQ(name, "MSG_SYN")) -#ifdef MSG_SYN - return MSG_SYN; + } + if (memEQ(name, "SHUT_WR", 7)) { + /* ^ */ +#ifdef SHUT_WR + *iv_return = SHUT_WR; + return PERL_constant_ISIV; #else - goto not_there; + *iv_return = 1; + return PERL_constant_ISIV; #endif - if (strEQ(name, "MSG_TRUNC")) -#ifdef MSG_TRUNC - return MSG_TRUNC; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "MSG_WAITALL")) -#ifdef MSG_WAITALL - return MSG_WAITALL; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - break; - case 'N': - break; - case 'O': - break; - case 'P': - if (strEQ(name, "PF_802")) -#ifdef PF_802 - return PF_802; + } + break; + case 'M': + if (memEQ(name, "SOCK_RDM", 8)) { + /* ^ */ +#ifdef SOCK_RDM + *iv_return = SOCK_RDM; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_APPLETALK")) -#ifdef PF_APPLETALK - return PF_APPLETALK; + } + break; + case 'P': + if (memEQ(name, "AF_GOSIP", 8)) { + /* ^ */ +#ifdef AF_GOSIP + *iv_return = AF_GOSIP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_CCITT")) -#ifdef PF_CCITT - return PF_CCITT; + } + if (memEQ(name, "PF_GOSIP", 8)) { + /* ^ */ +#ifdef PF_GOSIP + *iv_return = PF_GOSIP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_CHAOS")) -#ifdef PF_CHAOS - return PF_CHAOS; + } + break; + case 'R': + if (memEQ(name, "SO_ERROR", 8)) { + /* ^ */ +#ifdef SO_ERROR + *iv_return = SO_ERROR; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_DATAKIT")) -#ifdef PF_DATAKIT - return PF_DATAKIT; + } + break; + case 'S': + if (memEQ(name, "AF_CHAOS", 8)) { + /* ^ */ +#ifdef AF_CHAOS + *iv_return = AF_CHAOS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_DECnet")) -#ifdef PF_DECnet - return PF_DECnet; + } + if (memEQ(name, "PF_CHAOS", 8)) { + /* ^ */ +#ifdef PF_CHAOS + *iv_return = PF_CHAOS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_DLI")) -#ifdef PF_DLI - return PF_DLI; + } + break; + case 'T': + if (memEQ(name, "AF_CCITT", 8)) { + /* ^ */ +#ifdef AF_CCITT + *iv_return = AF_CCITT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_ECMA")) -#ifdef PF_ECMA - return PF_ECMA; + } + if (memEQ(name, "PF_CCITT", 8)) { + /* ^ */ +#ifdef PF_CCITT + *iv_return = PF_CCITT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_GOSIP")) -#ifdef PF_GOSIP - return PF_GOSIP; + } + break; + case 'W': + if (memEQ(name, "SOCK_RAW", 8)) { + /* ^ */ +#ifdef SOCK_RAW + *iv_return = SOCK_RAW; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_HYLINK")) -#ifdef PF_HYLINK - return PF_HYLINK; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_IMPLINK")) -#ifdef PF_IMPLINK - return PF_IMPLINK; + } + if (memEQ(name, "MSG_MCAST", 9)) { + /* ^ */ +#ifdef MSG_MCAST + *iv_return = MSG_MCAST; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_INET")) -#ifdef PF_INET - return PF_INET; + } + break; + case 'B': + if (memEQ(name, "SO_RCVBUF", 9)) { + /* ^ */ +#ifdef SO_RCVBUF + *iv_return = SO_RCVBUF; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_LAT")) -#ifdef PF_LAT - return PF_LAT; + } + if (memEQ(name, "SO_SNDBUF", 9)) { + /* ^ */ +#ifdef SO_SNDBUF + *iv_return = SO_SNDBUF; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_MAX")) -#ifdef PF_MAX - return PF_MAX; + } + break; + case 'D': + if (memEQ(name, "SHUT_RDWR", 9)) { + /* ^ */ +#ifdef SHUT_RDWR + *iv_return = SHUT_RDWR; + return PERL_constant_ISIV; #else - goto not_there; + *iv_return = 2; + return PERL_constant_ISIV; #endif - if (strEQ(name, "PF_NBS")) -#ifdef PF_NBS - return PF_NBS; + } + break; + case 'E': + if (memEQ(name, "SCM_CREDS", 9)) { + /* ^ */ +#ifdef SCM_CREDS + *iv_return = SCM_CREDS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_NIT")) -#ifdef PF_NIT - return PF_NIT; + } + break; + case 'G': + if (memEQ(name, "SO_LINGER", 9)) { + /* ^ */ +#ifdef SO_LINGER + *iv_return = SO_LINGER; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_NS")) -#ifdef PF_NS - return PF_NS; + } + break; + case 'I': + if (memEQ(name, "AF_HYLINK", 9)) { + /* ^ */ +#ifdef AF_HYLINK + *iv_return = AF_HYLINK; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_OSI")) -#ifdef PF_OSI - return PF_OSI; + } + if (memEQ(name, "PF_HYLINK", 9)) { + /* ^ */ +#ifdef PF_HYLINK + *iv_return = PF_HYLINK; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_OSINET")) + } + 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 - return PF_OSINET; + *iv_return = PF_OSINET; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_PUP")) -#ifdef PF_PUP - return PF_PUP; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_SNA")) -#ifdef PF_SNA - return PF_SNA; + } + if (memEQ(name, "SOMAXCONN", 9)) { + /* ^ */ +#ifdef SOMAXCONN + *iv_return = SOMAXCONN; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_UNIX")) -#ifdef PF_UNIX - return PF_UNIX; + } + break; + case 'P': + if (memEQ(name, "AF_UNSPEC", 9)) { + /* ^ */ +#ifdef AF_UNSPEC + *iv_return = AF_UNSPEC; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_UNSPEC")) + } + if (memEQ(name, "PF_UNSPEC", 9)) { + /* ^ */ #ifdef PF_UNSPEC - return PF_UNSPEC; + *iv_return = PF_UNSPEC; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "PF_X25")) -#ifdef PF_X25 - return PF_X25; + } + break; + case 'U': + if (memEQ(name, "MSG_TRUNC", 9)) { + /* ^ */ +#ifdef MSG_TRUNC + *iv_return = MSG_TRUNC; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - break; - case 'Q': - break; - case 'R': - break; - case 'S': - if (strEQ(name, "SCM_CONNECT")) -#ifdef SCM_CONNECT - return SCM_CONNECT; + } + break; + case 'X': + if (memEQ(name, "TCP_MAXRT", 9)) { + /* ^ */ +#ifdef TCP_MAXRT + *iv_return = TCP_MAXRT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SCM_CREDENTIALS")) -#ifdef SCM_CREDENTIALS - return SCM_CREDENTIALS; + } + break; + case 'n': + if (memEQ(name, "AF_DECnet", 9)) { + /* ^ */ +#ifdef AF_DECnet + *iv_return = AF_DECnet; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SCM_CREDS")) -#ifdef SCM_CREDS - return SCM_CREDS; + } + if (memEQ(name, "PF_DECnet", 9)) { + /* ^ */ +#ifdef PF_DECnet + *iv_return = PF_DECnet; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SCM_RIGHTS")) -#if defined(SCM_RIGHTS) || defined(HAS_SCM_RIGHTS) /* might be an enum */ - return SCM_RIGHTS; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SCM_TIMESTAMP")) -#ifdef SCM_TIMESTAMP - return SCM_TIMESTAMP; + } + if (memEQ(name, "PF_DATAKIT", 10)) { + /* ^ */ +#ifdef PF_DATAKIT + *iv_return = PF_DATAKIT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SHUT_RD")) -#ifdef SHUT_RD - return SHUT_RD; + } + break; + case 'C': + if (memEQ(name, "SOL_SOCKET", 10)) { + /* ^ */ +#ifdef SOL_SOCKET + *iv_return = SOL_SOCKET; + return PERL_constant_ISIV; #else - return 0; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SHUT_RDWR")) -#ifdef SHUT_RDWR - return SHUT_RDWR; + } + break; + case 'D': + if (memEQ(name, "TCP_STDURG", 10)) { + /* ^ */ +#ifdef TCP_STDURG + *iv_return = TCP_STDURG; + return PERL_constant_ISIV; #else - return 2; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SHUT_WR")) -#ifdef SHUT_WR - return SHUT_WR; + } + 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 1; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOCK_DGRAM")) + } + if (memEQ(name, "SOCK_DGRAM", 10)) { + /* ^ */ #ifdef SOCK_DGRAM - return SOCK_DGRAM; + *iv_return = SOCK_DGRAM; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOCK_RAW")) -#ifdef SOCK_RAW - return SOCK_RAW; + } + break; + case 'L': + if (memEQ(name, "AF_IMPLINK", 10)) { + /* ^ */ +#ifdef AF_IMPLINK + *iv_return = AF_IMPLINK; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOCK_RDM")) -#ifdef SOCK_RDM - return SOCK_RDM; + } + if (memEQ(name, "PF_IMPLINK", 10)) { + /* ^ */ +#ifdef PF_IMPLINK + *iv_return = PF_IMPLINK; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOCK_SEQPACKET")) -#ifdef SOCK_SEQPACKET - return SOCK_SEQPACKET; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOCK_STREAM")) -#ifdef SOCK_STREAM - return SOCK_STREAM; + } + break; + case 'X': + if (memEQ(name, "TCP_MAXSEG", 10)) { + /* ^ */ +#ifdef TCP_MAXSEG + *iv_return = TCP_MAXSEG; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOL_SOCKET")) -#ifdef SOL_SOCKET - return SOL_SOCKET; + } + if (memEQ(name, "UIO_MAXIOV", 10)) { + /* ^ */ +#ifdef UIO_MAXIOV + *iv_return = UIO_MAXIOV; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SOMAXCONN")) -#ifdef SOMAXCONN - return SOMAXCONN; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_ACCEPTCONN")) -#ifdef SO_ACCEPTCONN - return SO_ACCEPTCONN; + } + break; + case 'I': + if (memEQ(name, "SO_RCVTIMEO", 11)) { + /* ^ */ +#ifdef SO_RCVTIMEO + *iv_return = SO_RCVTIMEO; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_BROADCAST")) -#ifdef SO_BROADCAST - return SO_BROADCAST; + } + if (memEQ(name, "SO_SNDTIMEO", 11)) { + /* ^ */ +#ifdef SO_SNDTIMEO + *iv_return = SO_SNDTIMEO; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_DEBUG")) -#ifdef SO_DEBUG - return SO_DEBUG; + } + break; + case 'N': + if (memEQ(name, "SCM_CONNECT", 11)) { + /* ^ */ +#ifdef SCM_CONNECT + *iv_return = SCM_CONNECT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_DONTLINGER")) -#ifdef SO_DONTLINGER - return SO_DONTLINGER; + } + break; + case 'O': + if (memEQ(name, "SO_RCVLOWAT", 11)) { + /* ^ */ +#ifdef SO_RCVLOWAT + *iv_return = SO_RCVLOWAT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_DONTROUTE")) -#ifdef SO_DONTROUTE - return SO_DONTROUTE; + } + if (memEQ(name, "SO_SNDLOWAT", 11)) { + /* ^ */ +#ifdef SO_SNDLOWAT + *iv_return = SO_SNDLOWAT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_ERROR")) -#ifdef SO_ERROR - return SO_ERROR; + } + break; + case 'R': + if (memEQ(name, "SOCK_STREAM", 11)) { + /* ^ */ +#ifdef SOCK_STREAM + *iv_return = SOCK_STREAM; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_KEEPALIVE")) -#ifdef SO_KEEPALIVE - return SO_KEEPALIVE; + } + break; + case 'T': + if (memEQ(name, "MSG_WAITALL", 11)) { + /* ^ */ +#ifdef MSG_WAITALL + *iv_return = MSG_WAITALL; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_LINGER")) -#ifdef SO_LINGER - return SO_LINGER; + } + break; + case '_': + if (memEQ(name, "IPPROTO_TCP", 11)) { + /* ^ */ +#ifdef IPPROTO_TCP + *iv_return = IPPROTO_TCP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_OOBINLINE")) -#ifdef SO_OOBINLINE - return SO_OOBINLINE; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_RCVBUF")) -#ifdef SO_RCVBUF - return SO_RCVBUF; + } + break; + case 'D': + if (memEQ(name, "SO_REUSEADDR", 12)) { + /* ^ */ +#ifdef SO_REUSEADDR + *iv_return = SO_REUSEADDR; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_RCVLOWAT")) -#ifdef SO_RCVLOWAT - return SO_RCVLOWAT; + } + break; + case 'G': + if (memEQ(name, "MSG_CTLFLAGS", 12)) { + /* ^ */ +#ifdef MSG_CTLFLAGS + *iv_return = MSG_CTLFLAGS; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_RCVTIMEO")) -#ifdef SO_RCVTIMEO - return SO_RCVTIMEO; + } + break; + case 'I': + if (memEQ(name, "MSG_DONTWAIT", 12)) { + /* ^ */ +#ifdef MSG_DONTWAIT + *iv_return = MSG_DONTWAIT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_REUSEADDR")) -#ifdef SO_REUSEADDR - return SO_REUSEADDR; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_REUSEPORT")) + } + break; + case 'R': + if (memEQ(name, "SO_REUSEPORT", 12)) { + /* ^ */ #ifdef SO_REUSEPORT - return SO_REUSEPORT; + *iv_return = SO_REUSEPORT; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_SNDBUF")) -#ifdef SO_SNDBUF - return SO_SNDBUF; + } + break; + case 'S': + if (memEQ(name, "SO_BROADCAST", 12)) { + /* ^ */ +#ifdef SO_BROADCAST + *iv_return = SO_BROADCAST; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_SNDLOWAT")) -#ifdef SO_SNDLOWAT - return SO_SNDLOWAT; + } + break; + case 'T': + if (memEQ(name, "SO_DONTROUTE", 12)) { + /* ^ */ +#ifdef SO_DONTROUTE + *iv_return = SO_DONTROUTE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_SNDTIMEO")) -#ifdef SO_SNDTIMEO - return SO_SNDTIMEO; + } + break; + case 'U': + if (memEQ(name, "MSG_ERRQUEUE", 12)) { + /* ^ */ +#ifdef MSG_ERRQUEUE + *iv_return = MSG_ERRQUEUE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_TYPE")) -#ifdef SO_TYPE - return SO_TYPE; + } + break; + case 'V': + if (memEQ(name, "SO_KEEPALIVE", 12)) { + /* ^ */ +#ifdef SO_KEEPALIVE + *iv_return = SO_KEEPALIVE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "SO_USELOOPBACK")) -#ifdef SO_USELOOPBACK - return SO_USELOOPBACK; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - break; - case 'T': - if (strEQ(name, "TCP_KEEPALIVE")) + } + break; + case 'E': + if (memEQ(name, "TCP_KEEPALIVE", 13)) { + /* ^ */ #ifdef TCP_KEEPALIVE - return TCP_KEEPALIVE; + *iv_return = TCP_KEEPALIVE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "TCP_MAXRT")) -#ifdef TCP_MAXRT - return TCP_MAXRT; + } + break; + case 'I': + if (memEQ(name, "SCM_TIMESTAMP", 13)) { + /* ^ */ +#ifdef SCM_TIMESTAMP + *iv_return = SCM_TIMESTAMP; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "TCP_MAXSEG")) -#ifdef TCP_MAXSEG - return TCP_MAXSEG; + } + break; + case 'N': + if (memEQ(name, "SO_DONTLINGER", 13)) { + /* ^ */ +#ifdef SO_DONTLINGER + *iv_return = SO_DONTLINGER; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "TCP_NODELAY")) -#ifdef TCP_NODELAY - return TCP_NODELAY; + } + 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 - goto not_there; + return PERL_constant_NOTDEF; #endif - if (strEQ(name, "TCP_STDURG")) -#ifdef TCP_STDURG - return TCP_STDURG; + } + break; + case 'T': + if (memEQ(name, "MSG_CTLIGNORE", 13)) { + /* ^ */ +#ifdef MSG_CTLIGNORE + *iv_return = MSG_CTLIGNORE; + return PERL_constant_ISIV; #else - goto not_there; + return PERL_constant_NOTDEF; #endif - break; - case 'U': - if (strEQ(name, "UIO_MAXIOV")) -#ifdef UIO_MAXIOV - return UIO_MAXIOV; -#else - goto not_there; -#endif - break; - case 'V': - break; - case 'W': - break; - case 'X': - break; - case 'Y': - break; - case 'Z': - break; - } - errno = EINVAL; - return 0; + } + 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. -not_there: - errno = ENOENT; - return 0; + 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 -double -constant(name,arg) - char * name - int arg +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) |