From: Vincent Bernat Date: Wed, 2 Apr 2014 15:54:20 +0000 (+0200) Subject: hpux: provide a replacement for vsyslog() for HP-UX X-Git-Tag: 0.7.8~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f497e04a0a84af2fc2217dcfb09d92ac34774fe;p=thirdparty%2Flldpd.git hpux: provide a replacement for vsyslog() for HP-UX --- 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); +}