From d5943da7f606f67caa7ce42f494b1add48bab45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 6 Feb 2002 16:03:18 +0000 Subject: [PATCH] Provide a fallback for platforms that don't support varadic macros. Sponsored by: DARPA, NAI Labs git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@37 185d5e19-27fe-0310-9dcf-9bff6b9f3609 --- lib/openpam_log.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/openpam_log.c b/lib/openpam_log.c index 8c7f593..d733b69 100644 --- a/lib/openpam_log.c +++ b/lib/openpam_log.c @@ -43,6 +43,8 @@ #include "openpam_impl.h" +#if defined(openpam_log) + /* * Log a message through syslog(3) */ @@ -79,3 +81,37 @@ _openpam_log(int level, const char *func, const char *fmt, ...) va_end(ap); } +#else + +/* + * If openpam_log isn't defined as a macro, we're on a platform that + * doesn't support varadic macros (or it does but we aren't aware of + * it). Do the next best thing. + */ + +void +openpam_log(int level, const char *fmt, ...) +{ + va_list ap; + int priority; + + switch (level) { + case PAM_LOG_DEBUG: + priority = LOG_DEBUG; + break; + case PAM_LOG_VERBOSE: + priority = LOG_INFO; + break; + case PAM_LOG_NOTICE: + priority = LOG_NOTICE; + break; + case PAM_LOG_ERROR: + priority = LOG_ERR; + break; + } + va_start(ap, fmt); + vsyslog(priority, fmt, ap); + va_end(ap); +} + +#endif