From 9f3b0d60f95d6c3fbbc6fe8c0e1d6472b1b5524f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 3 Feb 2004 03:58:38 +0000 Subject: [PATCH] Fix EBCDIC conversion for syslog() --- include/ldap_log.h | 6 ++++++ libraries/liblber/debug.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/ldap_log.h b/include/ldap_log.h index 7f1d6c7e86..d053bdf78d 100644 --- a/include/ldap_log.h +++ b/include/ldap_log.h @@ -114,6 +114,12 @@ LDAP_BEGIN_DECL # ifdef LDAP_SYSLOG extern int ldap_syslog; extern int ldap_syslog_level; + +# ifdef HAVE_EBCDIC +# define syslog eb_syslog + extern void eb_syslog(int pri, const char *fmt, ...); +# endif + # endif /* LDAP_SYSLOG */ /* this doesn't below as part of ldap.h */ diff --git a/libraries/liblber/debug.c b/libraries/liblber/debug.c index caaa49312b..042627f56a 100644 --- a/libraries/liblber/debug.c +++ b/libraries/liblber/debug.c @@ -302,3 +302,19 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... ) fputs( buffer, stderr ); va_end( vl ); } + +#if defined(HAVE_EBCDIC) && defined(LDAP_SYSLOG) +void eb_syslog( int pri, const char *fmt, ... ) +{ + char buffer[4096]; + va_list vl; + + va_start( vl, fmt ); + vsnprintf( buffer, sizeof(buffer), fmt, vl ); + buffer[sizeof(buffer)-1] = '\0'; + + __atoe(buffer); + syslog( pri, "%s", buffer ); + va_end( vl ); +} +#endif