summaryrefslogtreecommitdiffstats
path: root/avahi-client
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-01-20 22:56:11 +0000
committerLennart Poettering <lennart@poettering.net>2006-01-20 22:56:11 +0000
commite614891d38cae63957d0bfc00d34ecdbad4f8322 (patch)
tree55336f0efd0999e0ed17bec823470844587fe65c /avahi-client
parent7d59b3ba820c19488b0637b5dd9798deb68fb0dc (diff)
* add new API function avahi_nss_support()
* add new DBUS method Server.IsNSSSupportAvailable() * add support for IsNSSSupportAvailabke() to avahi-bookmarks git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1092 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-client')
-rw-r--r--avahi-client/Makefile.am13
-rw-r--r--avahi-client/check-nss-test.c32
-rw-r--r--avahi-client/check-nss.c57
-rw-r--r--avahi-client/client.h3
4 files changed, 104 insertions, 1 deletions
diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am
index 3a03392..f45f58d 100644
--- a/avahi-client/Makefile.am
+++ b/avahi-client/Makefile.am
@@ -35,7 +35,8 @@ noinst_PROGRAMS = \
client-test \
srv-test \
xdg-config-test \
- rr-test
+ rr-test \
+ check-nss-test
endif
@@ -48,6 +49,7 @@ libavahi_client_la_SOURCES = \
resolver.c \
publish.h lookup.h \
xdg-config.c xdg-config.h \
+ check-nss.c \
../avahi-common/dbus.c ../avahi-common/dbus.h \
../avahi-common/dbus-watch-glue.c ../avahi-common/dbus-watch-glue.h
@@ -71,4 +73,13 @@ xdg_config_test_SOURCES = xdg-config-test.c xdg-config.c xdg-config.h
xdg_config_test_CFLAGS = $(AM_CFLAGS)
xdg_config_test_LDADD = $(AM_LDADD)
+check_nss_test_SOURCES = check-nss.c check-nss-test.c client.h
+check_nss_test_CFLAGS = $(AM_CFLAGS)
+check_nss_test_LDADD = $(AM_LDADD)
+
+if HAVE_DLOPEN
+check_nss_test_LDADD += -ldl
+libavahi_client_la_LIBADD += -ldl
+endif
+
endif
diff --git a/avahi-client/check-nss-test.c b/avahi-client/check-nss-test.c
new file mode 100644
index 0000000..172b4fa
--- /dev/null
+++ b/avahi-client/check-nss-test.c
@@ -0,0 +1,32 @@
+/* $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 <config.h>
+#endif
+
+#include <stdio.h>
+
+#include <avahi-client/client.h>
+
+int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
+ printf("NSS Support available: %s\n", avahi_nss_support() ? "yes" : "no");
+}
diff --git a/avahi-client/check-nss.c b/avahi-client/check-nss.c
new file mode 100644
index 0000000..0a933fa
--- /dev/null
+++ b/avahi-client/check-nss.c
@@ -0,0 +1,57 @@
+/* $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 <config.h>
+#endif
+
+#ifdef HAVE_DLOPEN
+#include <dlfcn.h>
+#endif
+#include <stdlib.h>
+
+#include "client.h"
+
+int avahi_nss_support(void) {
+ int b = 0;
+
+#ifdef HAVE_DLOPEN
+ static const char * const libs[] = {
+ "libnss_mdns.so.2",
+ "libnss_mdns4.so.2",
+ "libnss_mdns6.so.2",
+ NULL };
+
+ const char * const *l;
+
+ for (l = libs; *l; l++) {
+ void *dl;
+
+ if ((dl = dlopen(*l, RTLD_LAZY))) {
+ b = 1;
+ dlclose(dl);
+ break;
+ }
+ }
+#endif
+
+ return b;
+}
diff --git a/avahi-client/client.h b/avahi-client/client.h
index 9d73778..098d568 100644
--- a/avahi-client/client.h
+++ b/avahi-client/client.h
@@ -85,6 +85,9 @@ int avahi_client_errno (AvahiClient*);
/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */
uint32_t avahi_client_get_local_service_cookie(AvahiClient *client);
+/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise */
+int avahi_nss_support(void);
+
AVAHI_C_DECL_END
#endif