From 7badca4113bc8289755cd536593d8f3287aae9d5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 12 Oct 2005 23:05:50 +0000 Subject: * integrate avahi-compat-howl into build system * compat-libdns_sd: warn to syslog in addition to STDERR * compat-howl: make use of compat-libdns_sd warning functions git-svn-id: file:///home/lennart/svn/public/avahi/trunk@750 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-compat-libdns_sd/warn.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'avahi-compat-libdns_sd') diff --git a/avahi-compat-libdns_sd/warn.c b/avahi-compat-libdns_sd/warn.c index 7ebc7b1..4cd20e6 100644 --- a/avahi-compat-libdns_sd/warn.c +++ b/avahi-compat-libdns_sd/warn.c @@ -30,9 +30,15 @@ #include #include #include +#include +#include #include "warn.h" +#ifndef COMPAT_LAYER +#define COMPAT_LAYER "Apple Bonjour" +#endif + static pthread_mutex_t linkage_mutex = PTHREAD_MUTEX_INITIALIZER; static int linkage_warning = 0; @@ -58,6 +64,24 @@ static void get_exe_name(char *t, size_t l) { } } +static void warning(const char *ident, const char *fmt, ...) { + va_list ap, ap2; + + assert(ident); + assert(fmt); + + va_start(ap, fmt); + va_copy(ap2, ap); + + vfprintf(stderr, fmt, ap); + va_end(ap); + + openlog(ident, LOG_PID, LOG_USER); + vsyslog(LOG_WARNING, fmt, ap2); + closelog(); + va_end(ap2); +} + void avahi_warn_linkage(void) { int w; @@ -66,11 +90,12 @@ void avahi_warn_linkage(void) { linkage_warning = 1; pthread_mutex_unlock(&linkage_mutex); - if (!w && !getenv("AVAHI_BONJOUR_NOWARN")) { + if (!w && !getenv("AVAHI_COMPAT_NOWARN")) { char exename[256]; + get_exe_name(exename, sizeof(exename)); - - fprintf(stderr, "*** WARNING: The application '%s' uses the Bonjour compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename); + + warning(exename, "*** WARNING: The application '%s' uses the "COMPAT_LAYER" compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename); } } @@ -78,7 +103,7 @@ void avahi_warn_unsupported(const char *function) { char exename[256]; get_exe_name(exename, sizeof(exename)); - fprintf(stderr, "*** WARNING: The application '%s' called '%s()' which is not supported (or only supported partially) in the Bonjour compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename, function); + warning(exename, "*** WARNING: The application '%s' called '%s()' which is not supported (or only supported partially) in the "COMPAT_LAYER" compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename, function); } -- cgit