From 9f497e04a0a84af2fc2217dcfb09d92ac34774fe Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 2 Apr 2014 17:54:20 +0200 Subject: [PATCH] hpux: provide a replacement for vsyslog() for HP-UX --- configure.ac | 2 +- src/compat/compat.h | 6 +++++- src/compat/vsyslog.c | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/compat/vsyslog.c diff --git a/configure.ac b/configure.ac index 779d79bb..f4f8e9e7 100644 --- a/configure.ac +++ b/configure.ac @@ -114,7 +114,7 @@ AC_FUNC_FORK AC_SEARCH_LIBS([setproctitle], [util bsd]) AC_REPLACE_FUNCS([setproctitle]) AC_CHECK_FUNCS([setproctitle_init]) -AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln asprintf]) +AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln asprintf vsyslog]) AC_CHECK_FUNCS([setresuid setresgid]) case " $LIBS " in diff --git a/src/compat/compat.h b/src/compat/compat.h index 983b40b6..e4092346 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -46,10 +46,14 @@ #endif #if !HAVE_ASPRINTF -int vasprintf(char **str, const char *fmt, va_list ap) __attribute__ ((format (printf, 2, 0))); +int vasprintf(char **, const char *, va_list) __attribute__ ((format (printf, 2, 0))); int asprintf (char **, const char *, ...) __attribute__ ((format (printf, 2, 3))); #endif +#if !HAVE_VSYSLOG +void vsyslog(int, const char *, va_list) __attribute__ ((format (printf, 2, 0))); +#endif + #if !HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); #endif diff --git a/src/compat/vsyslog.c b/src/compat/vsyslog.c new file mode 100644 index 00000000..8c0f8f2d --- /dev/null +++ b/src/compat/vsyslog.c @@ -0,0 +1,15 @@ +/* -*- mode: c; c-file-style: "openbsd" -*- */ + +#include +#include +#include "compat.h" + +/* vsyslog() doesn't exist on HP-UX */ +void +vsyslog(int facility, const char *format, va_list ap) { + char *msg = NULL; + vasprintf(&msg, format, ap); + if (!msg) return; + syslog(facility, "%s", msg); + free(msg); +} -- 2.39.5