From 125d0154e6c591addbaf1fae7c9ffdf5b7e7ed7b Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Fri, 9 Apr 2010 14:34:28 +0200 Subject: Exclude syslog code if FEATURE_SYSLOG is not set syslog.h and syslog(...) may not exist in such configuration Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Denys Vlasenko --- libbb/info_msg.c | 12 +++++++++--- libbb/verror_msg.c | 9 +++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/info_msg.c b/libbb/info_msg.c index bc9d23b..81164fa 100644 --- a/libbb/info_msg.c +++ b/libbb/info_msg.c @@ -8,7 +8,9 @@ */ #include "libbb.h" -#include +#if ENABLE_FEATURE_SYSLOG +# include +#endif void FAST_FUNC bb_info_msg(const char *s, ...) { @@ -24,8 +26,10 @@ void FAST_FUNC bb_info_msg(const char *s, ...) vprintf(s, p); fputs(msg_eol, stdout); } - if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) +# if ENABLE_FEATURE_SYSLOG + if (logmode & LOGMODE_SYSLOG) vsyslog(LOG_INFO, s, p2); +# endif va_end(p2); va_end(p); #else @@ -42,8 +46,10 @@ void FAST_FUNC bb_info_msg(const char *s, ...) if (used < 0) return; - if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) +# if ENABLE_FEATURE_SYSLOG + if (logmode & LOGMODE_SYSLOG) syslog(LOG_INFO, "%s", msg); +# endif if (logmode & LOGMODE_STDIO) { fflush_all(); /* used = strlen(msg); - must be true already */ diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 70f792f..6134329 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c @@ -6,9 +6,10 @@ * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ - #include "libbb.h" -#include +#if ENABLE_FEATURE_SYSLOG +# include +#endif smallint logmode = LOGMODE_STDIO; const char *msg_eol = "\n"; @@ -67,9 +68,11 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) fflush_all(); full_write(STDERR_FILENO, msg, used); } +#if ENABLE_FEATURE_SYSLOG if (logmode & LOGMODE_SYSLOG) { syslog(LOG_ERR, "%s", msg + applet_len); } +#endif free(msg); } @@ -128,9 +131,11 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) fflush_all(); writev(STDERR_FILENO, iov, 3); } +# if ENABLE_FEATURE_SYSLOG if (logmode & LOGMODE_SYSLOG) { syslog(LOG_ERR, "%s", msgc); } +# endif free(msgc); } #endif -- cgit v1.1