summaryrefslogtreecommitdiff
path: root/ext/Sys
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-06-04 14:45:47 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-04 14:45:47 +0000
commit18085af43f37d9b6d6bdb18bc8afe8bcd232298e (patch)
treeb8a15ac8a2bdfcd76cd8d11e855f05142a2d53ae /ext/Sys
parent2570cdf10e029e79aea6f367c31eb4d83b4b6f66 (diff)
downloadperl-18085af43f37d9b6d6bdb18bc8afe8bcd232298e.tar.gz
The #10402 didn't take. Weird.
p4raw-id: //depot/perl@10428
Diffstat (limited to 'ext/Sys')
-rw-r--r--ext/Sys/Syslog/Syslog.xs950
1 files changed, 475 insertions, 475 deletions
diff --git a/ext/Sys/Syslog/Syslog.xs b/ext/Sys/Syslog/Syslog.xs
index e600da0add..15eb64e88f 100644
--- a/ext/Sys/Syslog/Syslog.xs
+++ b/ext/Sys/Syslog/Syslog.xs
@@ -6,578 +6,547 @@
#include <syslog.h>
#endif
-static double
-constant_LOG_NO(char *name, int len)
-{
- switch (name[6 + 0]) {
- case 'T':
- if (strEQ(name + 6, "TICE")) { /* "LOG_NO" removed */
-#ifdef LOG_NOTICE
- return LOG_NOTICE;
-#else
- goto not_there;
-#endif
- }
- case 'W':
- if (strEQ(name + 6, "WAIT")) { /* "LOG_NO" removed */
-#ifdef LOG_NOWAIT
- return LOG_NOWAIT;
+#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
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_NOTICE) || !defined(LOG_NOWAIT)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_N(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'D':
- if (strEQ(name + 5, "DELAY")) { /* "LOG_N" removed */
-#ifdef LOG_NDELAY
- return LOG_NDELAY;
-#else
- goto not_there;
-#endif
- }
- case 'E':
- if (strEQ(name + 5, "EWS")) { /* "LOG_N" removed */
-#ifdef LOG_NEWS
- return LOG_NEWS;
-#else
- goto not_there;
-#endif
- }
- case 'F':
- if (strEQ(name + 5, "FACILITIES")) { /* "LOG_N" removed */
-#ifdef LOG_NFACILITIES
- return LOG_NFACILITIES;
+ break;
+ case 'F':
+ if (memEQ(name, "LOG_FTP", 7)) {
+ /* ^ */
+#ifdef LOG_FTP
+ *iv_return = LOG_FTP;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'O':
- return constant_LOG_NO(name, len);
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_NDELAY) || !defined(LOG_NEWS) || !defined(LOG_NFACILITIES)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_P(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'E':
- if (strEQ(name + 5, "ERROR")) { /* "LOG_P" removed */
-#ifdef LOG_PERROR
- return LOG_PERROR;
+ break;
+ case 'L':
+ if (memEQ(name, "LOG_LPR", 7)) {
+ /* ^ */
+#ifdef LOG_LPR
+ *iv_return = LOG_LPR;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'I':
- if (strEQ(name + 5, "ID")) { /* "LOG_P" removed */
+ }
+ break;
+ case 'P':
+ if (memEQ(name, "LOG_PID", 7)) {
+ /* ^ */
#ifdef LOG_PID
- return LOG_PID;
+ *iv_return = LOG_PID;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'R':
- if (strEQ(name + 5, "RIMASK")) { /* "LOG_P" removed */
-#ifdef LOG_PRIMASK
- return LOG_PRIMASK;
-#else
- goto not_there;
-#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_PERROR) || !defined(LOG_PID) || !defined(LOG_PRIMASK)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
+ break;
+ }
+ return PERL_constant_NOTFOUND;
}
-static double
-constant_LOG_AU(char *name, int len)
-{
- if (6 + 2 > len ) {
- errno = EINVAL;
- return 0;
- }
- switch (name[6 + 2]) {
- case '\0':
- if (strEQ(name + 6, "TH")) { /* "LOG_AU" removed */
-#ifdef LOG_AUTH
- return LOG_AUTH;
+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
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'P':
- if (strEQ(name + 6, "THPRIV")) { /* "LOG_AU" removed */
-#ifdef LOG_AUTHPRIV
- return LOG_AUTHPRIV;
+ }
+ break;
+ case 'E':
+ if (memEQ(name, "LOG_USER", 8)) {
+ /* ^ */
+#ifdef LOG_USER
+ *iv_return = LOG_USER;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_AUTH) || !defined(LOG_AUTHPRIV)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_A(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'L':
- if (strEQ(name + 5, "LERT")) { /* "LOG_A" removed */
-#ifdef LOG_ALERT
- return LOG_ALERT;
+ break;
+ case 'F':
+ if (memEQ(name, "LOG_INFO", 8)) {
+ /* ^ */
+#ifdef LOG_INFO
+ *iv_return = LOG_INFO;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'U':
- return constant_LOG_AU(name, len);
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_ALERT)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_CR(char *name, int len)
-{
- switch (name[6 + 0]) {
- case 'I':
- if (strEQ(name + 6, "IT")) { /* "LOG_CR" removed */
+ break;
+ case 'I':
+ if (memEQ(name, "LOG_CRIT", 8)) {
+ /* ^ */
#ifdef LOG_CRIT
- return LOG_CRIT;
+ *iv_return = LOG_CRIT;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'O':
- if (strEQ(name + 6, "ON")) { /* "LOG_CR" removed */
-#ifdef LOG_CRON
- return LOG_CRON;
+ }
+ if (memEQ(name, "LOG_MAIL", 8)) {
+ /* ^ */
+#ifdef LOG_MAIL
+ *iv_return = LOG_MAIL;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_CRIT) || !defined(LOG_CRON)
-not_there:
- errno = ENOENT;
- return 0;
+ 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
-}
-
-static double
-constant_LOG_C(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'O':
- if (strEQ(name + 5, "ONS")) { /* "LOG_C" removed */
+ }
+ break;
+ case 'N':
+ if (memEQ(name, "LOG_CONS", 8)) {
+ /* ^ */
#ifdef LOG_CONS
- return LOG_CONS;
+ *iv_return = LOG_CONS;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'R':
- return constant_LOG_CR(name, len);
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_CONS)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_D(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'A':
- if (strEQ(name + 5, "AEMON")) { /* "LOG_D" removed */
-#ifdef LOG_DAEMON
- return LOG_DAEMON;
+ break;
+ case 'O':
+ if (memEQ(name, "LOG_CRON", 8)) {
+ /* ^ */
+#ifdef LOG_CRON
+ *iv_return = LOG_CRON;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'E':
- if (strEQ(name + 5, "EBUG")) { /* "LOG_D" removed */
-#ifdef LOG_DEBUG
- return LOG_DEBUG;
+ }
+ break;
+ case 'R':
+ if (memEQ(name, "LOG_KERN", 8)) {
+ /* ^ */
+#ifdef LOG_KERN
+ *iv_return = LOG_KERN;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_DAEMON) || !defined(LOG_DEBUG)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_U(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'S':
- if (strEQ(name + 5, "SER")) { /* "LOG_U" removed */
-#ifdef LOG_USER
- return LOG_USER;
+ break;
+ case 'T':
+ if (memEQ(name, "LOG_AUTH", 8)) {
+ /* ^ */
+#ifdef LOG_AUTH
+ *iv_return = LOG_AUTH;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'U':
- if (strEQ(name + 5, "UCP")) { /* "LOG_U" removed */
-#ifdef LOG_UUCP
- return LOG_UUCP;
+ }
+ break;
+ case 'W':
+ if (memEQ(name, "LOG_NEWS", 8)) {
+ /* ^ */
+#ifdef LOG_NEWS
+ *iv_return = LOG_NEWS;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_USER) || !defined(LOG_UUCP)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
+ break;
+ }
+ return PERL_constant_NOTFOUND;
}
-static double
-constant_LOG_E(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'M':
- if (strEQ(name + 5, "MERG")) { /* "LOG_E" removed */
-#ifdef LOG_EMERG
- return LOG_EMERG;
-#else
- goto not_there;
-#endif
- }
- case 'R':
- if (strEQ(name + 5, "RR")) { /* "LOG_E" removed */
-#ifdef LOG_ERR
- return LOG_ERR;
+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
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_EMERG) || !defined(LOG_ERR)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_F(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'A':
- if (strEQ(name + 5, "ACMASK")) { /* "LOG_F" removed */
-#ifdef LOG_FACMASK
- return LOG_FACMASK;
+ break;
+ case 'D':
+ if (memEQ(name, "LOG_DEBUG", 9)) {
+ /* ^ */
+#ifdef LOG_DEBUG
+ *iv_return = LOG_DEBUG;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'T':
- if (strEQ(name + 5, "TP")) { /* "LOG_F" removed */
-#ifdef LOG_FTP
- return LOG_FTP;
+ }
+ break;
+ case 'E':
+ if (memEQ(name, "LOG_EMERG", 9)) {
+ /* ^ */
+#ifdef LOG_EMERG
+ *iv_return = LOG_EMERG;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_FACMASK) || !defined(LOG_FTP)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
+ break;
+ }
+ return PERL_constant_NOTFOUND;
}
-static double
-constant_LOG_LO(char *name, int len)
-{
- if (6 + 3 >= len ) {
- errno = EINVAL;
- return 0;
- }
- switch (name[6 + 3]) {
- case '0':
- if (strEQ(name + 6, "CAL0")) { /* "LOG_LO" removed */
+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
- return LOG_LOCAL0;
+ *iv_return = LOG_LOCAL0;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '1':
- if (strEQ(name + 6, "CAL1")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '1':
+ if (memEQ(name, "LOG_LOCAL1", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL1
- return LOG_LOCAL1;
+ *iv_return = LOG_LOCAL1;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '2':
- if (strEQ(name + 6, "CAL2")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '2':
+ if (memEQ(name, "LOG_LOCAL2", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL2
- return LOG_LOCAL2;
+ *iv_return = LOG_LOCAL2;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '3':
- if (strEQ(name + 6, "CAL3")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '3':
+ if (memEQ(name, "LOG_LOCAL3", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL3
- return LOG_LOCAL3;
+ *iv_return = LOG_LOCAL3;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '4':
- if (strEQ(name + 6, "CAL4")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '4':
+ if (memEQ(name, "LOG_LOCAL4", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL4
- return LOG_LOCAL4;
+ *iv_return = LOG_LOCAL4;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '5':
- if (strEQ(name + 6, "CAL5")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '5':
+ if (memEQ(name, "LOG_LOCAL5", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL5
- return LOG_LOCAL5;
+ *iv_return = LOG_LOCAL5;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '6':
- if (strEQ(name + 6, "CAL6")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '6':
+ if (memEQ(name, "LOG_LOCAL6", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL6
- return LOG_LOCAL6;
+ *iv_return = LOG_LOCAL6;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case '7':
- if (strEQ(name + 6, "CAL7")) { /* "LOG_LO" removed */
+ }
+ break;
+ case '7':
+ if (memEQ(name, "LOG_LOCAL7", 10)) {
+ /* ^ */
#ifdef LOG_LOCAL7
- return LOG_LOCAL7;
+ *iv_return = LOG_LOCAL7;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_LOCAL0) || !defined(LOG_LOCAL1) || !defined(LOG_LOCAL2) || !defined(LOG_LOCAL3) || !defined(LOG_LOCAL4) || !defined(LOG_LOCAL5) || !defined(LOG_LOCAL6) || !defined(LOG_LOCAL7)
-not_there:
- errno = ENOENT;
- return 0;
-#endif
-}
-
-static double
-constant_LOG_L(char *name, int len)
-{
- switch (name[5 + 0]) {
- case 'F':
- if (strEQ(name + 5, "FMT")) { /* "LOG_L" removed */
-#ifdef LOG_LFMT
- return LOG_LFMT;
+ break;
+ case 'E':
+ if (memEQ(name, "LOG_NOTICE", 10)) {
+ /* ^ */
+#ifdef LOG_NOTICE
+ *iv_return = LOG_NOTICE;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'O':
- return constant_LOG_LO(name, len);
- case 'P':
- if (strEQ(name + 5, "PR")) { /* "LOG_L" removed */
-#ifdef LOG_LPR
- return LOG_LPR;
+ }
+ break;
+ case 'G':
+ if (memEQ(name, "LOG_SYSLOG", 10)) {
+ /* ^ */
+#ifdef LOG_SYSLOG
+ *iv_return = LOG_SYSLOG;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
-
-#if !defined(LOG_LFMT) || !defined(LOG_LPR)
-not_there:
- errno = ENOENT;
- return 0;
+ 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
-}
-
-static double
-constant(char *name, int len)
-{
- errno = 0;
- if (0 + 4 >= len ) {
- errno = EINVAL;
- return 0;
- }
- switch (name[0 + 4]) {
- case 'A':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_A(name, len);
- case 'C':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_C(name, len);
- case 'D':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_D(name, len);
- case 'E':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_E(name, len);
- case 'F':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_F(name, len);
- case 'I':
- if (strEQ(name + 0, "LOG_INFO")) { /* "" removed */
-#ifdef LOG_INFO
- return LOG_INFO;
+ }
+ break;
+ case 'R':
+ if (memEQ(name, "LOG_PERROR", 10)) {
+ /* ^ */
+#ifdef LOG_PERROR
+ *iv_return = LOG_PERROR;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'K':
- if (strEQ(name + 0, "LOG_KERN")) { /* "" removed */
-#ifdef LOG_KERN
- return LOG_KERN;
+ }
+ break;
+ case 'T':
+ if (memEQ(name, "LOG_NOWAIT", 10)) {
+ /* ^ */
+#ifdef LOG_NOWAIT
+ *iv_return = LOG_NOWAIT;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'L':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_L(name, len);
- case 'M':
- if (strEQ(name + 0, "LOG_MAIL")) { /* "" removed */
-#ifdef LOG_MAIL
- return LOG_MAIL;
+ }
+ break;
+ case 'Y':
+ if (memEQ(name, "LOG_NDELAY", 10)) {
+ /* ^ */
+#ifdef LOG_NDELAY
+ *iv_return = LOG_NDELAY;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'N':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_N(name, len);
- case 'O':
- if (strEQ(name + 0, "LOG_ODELAY")) { /* "" removed */
+ }
+ if (memEQ(name, "LOG_ODELAY", 10)) {
+ /* ^ */
#ifdef LOG_ODELAY
- return LOG_ODELAY;
+ *iv_return = LOG_ODELAY;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'P':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_P(name, len);
- case 'S':
- if (strEQ(name + 0, "LOG_SYSLOG")) { /* "" removed */
-#ifdef LOG_SYSLOG
- return LOG_SYSLOG;
+ }
+ 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
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
- case 'U':
- if (!strnEQ(name + 0,"LOG_", 4))
- break;
- return constant_LOG_U(name, len);
- case 'W':
- if (strEQ(name + 0, "LOG_WARNING")) { /* "" removed */
+ }
+ break;
+ case 'R':
+ if (memEQ(name, "LOG_WARNING", 11)) {
+ /* ^ */
#ifdef LOG_WARNING
- return LOG_WARNING;
+ *iv_return = LOG_WARNING;
+ return PERL_constant_ISIV;
#else
- goto not_there;
+ return PERL_constant_NOTDEF;
#endif
- }
}
- errno = EINVAL;
- return 0;
+ break;
+ }
+ return PERL_constant_NOTFOUND;
+}
-#if !defined(LOG_INFO) || !defined(LOG_KERN) || !defined(LOG_MAIL) || !defined(LOG_ODELAY) || !defined(LOG_SYSLOG) || !defined(LOG_WARNING)
-not_there:
- errno = ENOENT;
- return 0;
+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 *
@@ -663,15 +632,46 @@ LOG_UPTO(pri)
RETVAL
-double
+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
- char * s = SvPV(sv, len);
- CODE:
- RETVAL = constant(s,len);
- OUTPUT:
- RETVAL
-
+ 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);
+ }