]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
hpux: provide a replacement for vsyslog() for HP-UX
authorVincent Bernat <vbe@deezer.com>
Wed, 2 Apr 2014 15:54:20 +0000 (17:54 +0200)
committerVincent Bernat <vbe@deezer.com>
Wed, 2 Apr 2014 15:54:20 +0000 (17:54 +0200)
configure.ac
src/compat/compat.h
src/compat/vsyslog.c [new file with mode: 0644]

index 779d79bb4b14e630bd214922be762faedd4eb77f..f4f8e9e77aa2965f1b5991dde2b431cd7d87ce36 100644 (file)
@@ -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
index 983b40b6baba873e0382d05356d7be76aa20fa6c..e4092346d4757c8dd00080442e9aaab23bc9c4cf 100644 (file)
 #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 (file)
index 0000000..8c0f8f2
--- /dev/null
@@ -0,0 +1,15 @@
+/* -*- mode: c; c-file-style: "openbsd" -*- */
+
+#include <stdlib.h>
+#include <syslog.h>
+#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);
+}