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 --- Makefile.am | 3 +- avahi-compat-howl/Makefile.am | 79 +++++++++++++++++++++++++++++++++++++++++++ avahi-compat-howl/warn.c | 30 ++++++++++++++++ avahi-compat-howl/warn.h | 30 ++++++++++++++++ avahi-compat-libdns_sd/warn.c | 33 +++++++++++++++--- configure.ac | 3 ++ 6 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 avahi-compat-howl/Makefile.am create mode 100644 avahi-compat-howl/warn.c create mode 100644 avahi-compat-howl/warn.h diff --git a/Makefile.am b/Makefile.am index b0ed265..12465c5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,7 +60,8 @@ SUBDIRS = \ man \ tests \ service-type-database \ - avahi-compat-libdns_sd + avahi-compat-libdns_sd \ + avahi-compat-howl DX_INPUT = \ diff --git a/avahi-compat-howl/Makefile.am b/avahi-compat-howl/Makefile.am new file mode 100644 index 0000000..3239086 --- /dev/null +++ b/avahi-compat-howl/Makefile.am @@ -0,0 +1,79 @@ +# $Id$ + +# This file is part of avahi. +# +# avahi is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# avahi is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with avahi; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. + +AM_CFLAGS=-I$(top_srcdir) + +# This cool debug trap works on i386/gcc only +AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' + +if HAVE_DBUS + +avahi_compat_howldir=$(includedir)/avahi-compat-howl + +avahi_compat_howl_HEADERS = \ + include/howl.h \ + include/rendezvous/rendezvous.h \ + include/rendezvous/text_record.h \ + include/corby/message.h \ + include/corby/object.h \ + include/corby/orb.h \ + include/corby/corby.h \ + include/corby/channel.h \ + include/corby/buffer.h \ + include/discovery/discovery.h \ + include/discovery/text_record.h \ + include/salt/socket.h \ + include/salt/address.h \ + include/salt/platform.h \ + include/salt/signal.h \ + include/salt/interface.h \ + include/salt/salt.h \ + include/salt/time.h \ + include/salt/debug.h + +lib_LTLIBRARIES = libavahi-compat-howl.la + +#noinst_PROGRAMS = txt-test + +libavahi_compat_howl_la_SOURCES = \ + $(avahi_compat_howl_HEADERS) \ + warn.c warn.h +libavahi_compat_howl_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +libavahi_compat_howl_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info $(LIBAVAHI_COMPAT_HOWL_VERSION_INFO) $(PTHREAD_LIBS) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la + +#txt_test_SOURCES = \ +# dns_sd.h \ +# txt.c \ +# txt-test.c \ +# warn.c warn.h +#txt_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +#txt_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la + +# You can test the compatibility layer by sticking in mDNSResponder's +# dns-sd.c source here, naming it "libdns_sd-test.c" and running "make +# libdns_sd-test" manually. We do not distribute that file due to +# licensing restrictions. + +#libdns_sd-test: libdns_sd-test.c libavahi-compat-libdns_sd.la +# $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test.o -c libdns_sd-test.c +# $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test libdns_sd-test.o $(PTHREAD_LIBS) ../avahi-common/libavahi-common.la libavahi-compat-libdns_sd.la + +#CLEANFILES = libdns_sd-test.o libdns_sd-test + +endif diff --git a/avahi-compat-howl/warn.c b/avahi-compat-howl/warn.c new file mode 100644 index 0000000..a792c98 --- /dev/null +++ b/avahi-compat-howl/warn.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "warn.h" + +#define COMPAT_LAYER "HOWL" + +#include "../avahi-compat-libdns_sd/warn.c" diff --git a/avahi-compat-howl/warn.h b/avahi-compat-howl/warn.h new file mode 100644 index 0000000..13dbb31 --- /dev/null +++ b/avahi-compat-howl/warn.h @@ -0,0 +1,30 @@ +#ifndef foowarnhhowlfoo +#define foowarnhhowlfoo + +/* $Id$ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#define avahi_warn_unsupported avahi_warn_unsupported_HOWL +#define avahi_warn_linkage avahi_warn_linkage_HOWL + +#include "../avahi-compat-libdns_sd/warn.h" + +#endif 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); } diff --git a/configure.ac b/configure.ac index 9627ab5..9854203 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,7 @@ AC_SUBST(LIBAVAHI_GLIB_VERSION_INFO, [0:1:0]) AC_SUBST(LIBAVAHI_QT3_VERSION_INFO, [0:0:0]) AC_SUBST(LIBAVAHI_QT4_VERSION_INFO, [0:0:0]) AC_SUBST(LIBAVAHI_COMPAT_LIBDNS_SD_VERSION_INFO, [1:0:0]) +AC_SUBST(LIBAVAHI_COMPAT_HOWL_VERSION_INFO, [0:0:0]) if type -p stow > /dev/null && test -d /usr/local/stow ; then AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***]) @@ -627,6 +628,7 @@ tests/Makefile service-type-database/Makefile avahi-sharp/Makefile avahi-compat-libdns_sd/Makefile +avahi-compat-howl/Makefile ]) AC_OUTPUT @@ -689,4 +691,5 @@ echo " Building libavahi-qt4: ${HAVE_QT4} Building avahi-sharp: ${HAVE_MONO} Building avahi-compat-libdns_sd: ${BUILD_CLIENT} + Building avahi-compat-howl: ${BUILD_CLIENT} " -- cgit