summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-19 00:10:02 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-19 00:10:02 +0000
commit16d9e30dd7fa052bd7e6dd37927d7f27bec90ef1 (patch)
treed52fcd4dfde907c278a29c76e59f899c92c1a4b4
parentd266407d3e6d8f2a8e14e8bd2f89fa8a4333613c (diff)
* Compile tests only when --enable-tests was specified on the configure command line
* Build compat layers only when --enable-compat-{howl,libdns_sd} was passed to configure * drop avahi_strlcpy() to reduce our code/API size * replace getifname() with if_indextoname in avahi-dnsconfd * declare environ if needed in avahi-dnsconfd * drop some useless definitions like AVAHI_PUBLISH_NULL = 0 git-svn-id: file:///home/lennart/svn/public/avahi/trunk@819 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--Makefile.am2
-rw-r--r--avahi-client/Makefile.am4
-rw-r--r--avahi-common/Makefile.am2
-rw-r--r--avahi-common/defs.h3
-rw-r--r--avahi-common/domain.c21
-rw-r--r--avahi-compat-howl/Makefile.am4
-rw-r--r--avahi-compat-howl/samples/Makefile.am4
-rw-r--r--avahi-compat-howl/text.c18
-rw-r--r--avahi-compat-libdns_sd/Makefile.am4
-rw-r--r--avahi-core/Makefile.am2
-rw-r--r--avahi-core/entry.c2
-rw-r--r--avahi-daemon/Makefile.am2
-rw-r--r--avahi-dnsconfd/main.c42
-rw-r--r--avahi-glib/Makefile.am4
-rw-r--r--configure.ac64
-rw-r--r--docs/TODO1
-rw-r--r--examples/Makefile.am8
-rw-r--r--tests/Makefile.am2
18 files changed, 132 insertions, 57 deletions
diff --git a/Makefile.am b/Makefile.am
index d08fd87..d557c62 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,7 +63,7 @@ SUBDIRS = \
tests \
service-type-database \
avahi-compat-libdns_sd \
- avahi-compat-howl
+ avahi-compat-howl
DX_INPUT = \
diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am
index 57b8cb0..fdbeb90 100644
--- a/avahi-client/Makefile.am
+++ b/avahi-client/Makefile.am
@@ -29,10 +29,14 @@ avahi_clientinclude_HEADERS = client.h
noinst_HEADERS = internal.h
+if ENABLE_TESTS
+
noinst_PROGRAMS = \
client-test \
srv-test
+endif
+
lib_LTLIBRARIES = libavahi-client.la
libavahi_client_la_SOURCES = \
diff --git a/avahi-common/Makefile.am b/avahi-common/Makefile.am
index 972e9ad..670c855 100644
--- a/avahi-common/Makefile.am
+++ b/avahi-common/Makefile.am
@@ -40,12 +40,14 @@ avahi_commoninclude_HEADERS = \
llist.h \
rlist.h
+if ENABLE_TESTS
noinst_PROGRAMS = \
strlst-test \
domain-test \
alternative-test \
timeval-test \
watch-test
+endif
lib_LTLIBRARIES = \
libavahi-common.la
diff --git a/avahi-common/defs.h b/avahi-common/defs.h
index 67bdddc..3b8c2a5 100644
--- a/avahi-common/defs.h
+++ b/avahi-common/defs.h
@@ -154,7 +154,6 @@ typedef enum {
/** Some flags for publishing functions */
typedef enum {
- AVAHI_PUBLISH_NULL = 0,
AVAHI_PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */
AVAHI_PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
AVAHI_PUBLISH_NO_ANNOUNCE = 4, /**< For raw records: Do not announce this RR to other hosts */
@@ -166,7 +165,6 @@ typedef enum {
/** Some flags for lookup functions */
typedef enum {
- AVAHI_LOOKUP_NULL = 0,
AVAHI_LOOKUP_USE_WIDE_AREA = 1, /**< Force lookup via wide area DNS */
AVAHI_LOOKUP_USE_MULTICAST = 2, /**< Force lookup via multicast DNS */
AVAHI_LOOKUP_NO_TXT = 4, /**< When doing service resolving, don't lookup TXT record */
@@ -175,7 +173,6 @@ typedef enum {
/** Some flags for lookup callback functions */
typedef enum {
- AVAHI_LOOKUP_RESULT_NULL = 0,
AVAHI_LOOKUP_RESULT_CACHED = 1, /**< This response originates from the cache */
AVAHI_LOOKUP_RESULT_WIDE_AREA = 2, /**< This response originates from wide area DNS */
AVAHI_LOOKUP_RESULT_MULTICAST = 4, /**< This response originates from multicast DNS */
diff --git a/avahi-common/domain.c b/avahi-common/domain.c
index f2e4395..e82411f 100644
--- a/avahi-common/domain.c
+++ b/avahi-common/domain.c
@@ -530,19 +530,22 @@ int avahi_service_name_join(char *p, size_t size, const char *name, const char *
return AVAHI_OK;
}
+#ifndef HAVE_STRLCPY
-char *avahi_strlcpy(char *dest, const char *src, size_t n) {
+static size_t strlcpy(char *dest, const char *src, size_t n) {
assert(dest);
assert(src);
-
- if (n == 0)
- return dest;
-
- strncpy(dest, src, n-1);
- dest[n-1] = 0;
- return dest;
+
+ if (n > 0) {
+ strncpy(dest, src, n-1);
+ dest[n-1] = 0;
+ }
+
+ return strlen(src);
}
+#endif
+
int avahi_service_name_split(const char *p, char *name, size_t name_size, char *type, size_t type_size, char *domain, size_t domain_size) {
enum {
NAME,
@@ -574,7 +577,7 @@ int avahi_service_name_split(const char *p, char *name, size_t name_size, char *
switch (state) {
case NAME:
- avahi_strlcpy(name, buf, name_size);
+ strlcpy(name, buf, name_size);
state = TYPE;
break;
diff --git a/avahi-compat-howl/Makefile.am b/avahi-compat-howl/Makefile.am
index 5c12782..e183b7e 100644
--- a/avahi-compat-howl/Makefile.am
+++ b/avahi-compat-howl/Makefile.am
@@ -25,6 +25,7 @@ AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
SUBDIRS = . samples
if HAVE_DBUS
+if ENABLE_COMPAT_HOWL
avahi_compat_howldir=$(includedir)/avahi-compat-howl
avahi_compat_howl_rendezvousdir=$(avahi_compat_howldir)/rendezvous
@@ -70,7 +71,9 @@ HOWLHEADERS = \
lib_LTLIBRARIES = libavahi-compat-howl.la
+if ENABLE_TESTS
noinst_PROGRAMS = address-test text-test browse-domain-test
+endif
libavahi_compat_howl_la_SOURCES = \
$(HOWLHEADERS) \
@@ -105,3 +108,4 @@ browse_domain_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include
browse_domain_test_LDADD = $(AM_LDADD) libavahi-compat-howl.la
endif
+endif
diff --git a/avahi-compat-howl/samples/Makefile.am b/avahi-compat-howl/samples/Makefile.am
index 14bbfb7..21d15a8 100644
--- a/avahi-compat-howl/samples/Makefile.am
+++ b/avahi-compat-howl/samples/Makefile.am
@@ -23,8 +23,11 @@ AM_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/avahi-compat-howl/include
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
if HAVE_DBUS
+if ENABLE_COMPAT_HOWL
+if ENABLE_TESTS
noinst_PROGRAMS = browse resolve publish query
+endif
browse_SOURCES = \
browse.c
@@ -47,3 +50,4 @@ query_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include
query_LDADD = $(AM_LDADD) ../libavahi-compat-howl.la
endif
+endif
diff --git a/avahi-compat-howl/text.c b/avahi-compat-howl/text.c
index 1cd34fe..fb05acf 100644
--- a/avahi-compat-howl/text.c
+++ b/avahi-compat-howl/text.c
@@ -39,6 +39,22 @@ struct _sw_text_record {
int buffer_valid;
};
+#ifndef HAVE_STRLCPY
+
+static size_t strlcpy(char *dest, const char *src, size_t n) {
+ assert(dest);
+ assert(src);
+
+ if (n > 0) {
+ strncpy(dest, src, n-1);
+ dest[n-1] = 0;
+ }
+
+ return strlen(src);
+}
+
+#endif
+
sw_result sw_text_record_init(sw_text_record *self) {
assert(self);
@@ -223,7 +239,7 @@ sw_result sw_text_record_iterator_next(
if (avahi_string_list_get_pair(self->index, &mkey, &mvalue, &msize) < 0)
return SW_E_UNKNOWN;
- avahi_strlcpy(key, mkey, SW_TEXT_RECORD_MAX_LEN);
+ strlcpy(key, mkey, SW_TEXT_RECORD_MAX_LEN);
memset(val, 0, SW_TEXT_RECORD_MAX_LEN);
memcpy(val, mvalue, msize);
*val_len = msize;
diff --git a/avahi-compat-libdns_sd/Makefile.am b/avahi-compat-libdns_sd/Makefile.am
index 2b65059..bd33bb0 100644
--- a/avahi-compat-libdns_sd/Makefile.am
+++ b/avahi-compat-libdns_sd/Makefile.am
@@ -23,6 +23,7 @@ AM_CFLAGS=-I$(top_srcdir)
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
if HAVE_DBUS
+if ENABLE_COMPAT_LIBDNS_SD
avahi_compat_libdns_sddir=$(includedir)/avahi-compat-libdns_sd
@@ -30,7 +31,9 @@ avahi_compat_libdns_sd_HEADERS = dns_sd.h
lib_LTLIBRARIES = libavahi-compat-libdns_sd.la
+if ENABLE_TESTS
noinst_PROGRAMS = txt-test
+endif
libavahi_compat_libdns_sd_la_SOURCES = \
dns_sd.h \
@@ -61,3 +64,4 @@ libdns_sd-test: libdns_sd-test.c libavahi-compat-libdns_sd.la
CLEANFILES = libdns_sd-test.o libdns_sd-test
endif
+endif
diff --git a/avahi-core/Makefile.am b/avahi-core/Makefile.am
index 3ecce11..9516615 100644
--- a/avahi-core/Makefile.am
+++ b/avahi-core/Makefile.am
@@ -34,6 +34,7 @@ avahiinclude_HEADERS = \
lib_LTLIBRARIES = \
libavahi-core.la
+if ENABLE_TESTS
noinst_PROGRAMS = \
prioq-test \
avahi-test \
@@ -44,6 +45,7 @@ noinst_PROGRAMS = \
hashmap-test \
querier-test \
update-test
+endif
libavahi_core_la_SOURCES = \
timeeventq.c timeeventq.h\
diff --git a/avahi-core/entry.c b/avahi-core/entry.c
index 23ab5e0..18fe431 100644
--- a/avahi-core/entry.c
+++ b/avahi-core/entry.c
@@ -890,7 +890,7 @@ int avahi_server_add_dns_server_name(
r->data.srv.weight = 0;
r->data.srv.port = port;
r->data.srv.name = n;
- ret = avahi_server_add(s, g, interface, protocol, AVAHI_PUBLISH_NULL, r);
+ ret = avahi_server_add(s, g, interface, protocol, 0, r);
avahi_record_unref(r);
return ret;
diff --git a/avahi-daemon/Makefile.am b/avahi-daemon/Makefile.am
index 8c433d5..9e347e3 100644
--- a/avahi-daemon/Makefile.am
+++ b/avahi-daemon/Makefile.am
@@ -40,8 +40,10 @@ AM_CFLAGS+= \
sbin_PROGRAMS = \
avahi-daemon
+if ENABLE_TESTS
noinst_PROGRAMS = \
ini-file-parser-test
+endif
avahi_daemon_SOURCES = \
main.c main.h \
diff --git a/avahi-dnsconfd/main.c b/avahi-dnsconfd/main.c
index cca0b68..84b0f68 100644
--- a/avahi-dnsconfd/main.c
+++ b/avahi-dnsconfd/main.c
@@ -61,8 +61,6 @@ static enum {
BROWSING
} state = ACKWAIT;
-static int quit = 0;
-
static enum {
DAEMON_RUN,
DAEMON_KILL,
@@ -72,8 +70,13 @@ static enum {
DAEMON_CHECK
} command = DAEMON_RUN;
+static int quit = 0;
static int daemonize = 0;
+#if !HAVE_DECL_ENVIRON
+extern char **environ;
+#endif
+
typedef struct DNSServerInfo DNSServerInfo;
struct DNSServerInfo {
@@ -213,37 +216,6 @@ static char *concat_dns_servers(AvahiIfIndex interface) {
return r;
}
-static char *getifname(AvahiIfIndex interface, char *name, size_t len) {
- int fd = -1;
- char *ret = NULL;
- struct ifreq ifr;
-
- assert(interface >= 0);
-
- if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
- daemon_log(LOG_ERR, "socket(): %s", strerror(errno));
- goto finish;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = (int) interface;
-
- if (ioctl(fd, SIOCGIFNAME, &ifr) < 0) {
- daemon_log(LOG_ERR, "SIOCGIFNAME: %s\n", strerror(errno));
- goto finish;
- }
-
- strncpy(name, ifr.ifr_name, len-1);
- name[len-1] = 0;
- ret = name;
-
-finish:
- if (fd >= 0)
- close(fd);
-
- return ret;
-}
-
static void set_env(const char *name, const char *value) {
char **e;
size_t l;
@@ -274,11 +246,11 @@ static void run_script(int new, AvahiIfIndex interface, AvahiProtocol protocol,
char *p;
int ret;
char ia[16], pa[16];
- char name[IFNAMSIZ+1];
+ char name[IF_NAMESIZE];
assert(interface > 0);
- if (!getifname(interface, name, sizeof(name)))
+ if (!if_indextoname(interface, name))
return;
p = concat_dns_servers(interface);
diff --git a/avahi-glib/Makefile.am b/avahi-glib/Makefile.am
index 02c6181..69bd51e 100644
--- a/avahi-glib/Makefile.am
+++ b/avahi-glib/Makefile.am
@@ -33,9 +33,13 @@ avahiinclude_HEADERS = \
lib_LTLIBRARIES = \
libavahi-glib.la
+if ENABLE_TESTS
+
noinst_PROGRAMS = \
glib-watch-test
+endif
+
libavahi_glib_la_SOURCES = \
glib-watch.c glib-watch.h \
glib-malloc.h glib-malloc.c
diff --git a/configure.ac b/configure.ac
index 2ed9a8a..744a284 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,13 +229,15 @@ AC_FUNC_MEMCMP
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_MALLOC
AC_FUNC_REALLOC
-AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid strcasecmp gettimeofday putenv strncasecmp])
+AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid strcasecmp gettimeofday putenv strncasecmp strclpy])
AC_FUNC_CHOWN
AC_FUNC_STAT
AC_TYPE_MODE_T
AC_TYPE_PID_T
+AC_CHECK_DECLS(environ)
+
# Check for pkg-config manually first, as if its not installed the
# PKG_PROG_PKG_CONFIG macro won't be defined.
AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
@@ -340,8 +342,6 @@ if test "x$HAVE_GTK" = "xyes" ; then
fi
AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
-
-
#
# D-BUS
#
@@ -567,7 +567,6 @@ avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket"
AC_SUBST(avahi_runtime_dir)
AC_SUBST(avahi_socket)
-
#
# Avahi interfaces dir
#
@@ -576,7 +575,6 @@ if test "x$HAVE_PYTHON_DBUS" = "xyes" -o "x$HAVE_GTK" = "xyes"; then
AC_SUBST(interfacesdir)
fi
-
#
# Doxygen
#
@@ -616,6 +614,49 @@ fi
AM_CONDITIONAL([USE_XMLTOMAN], [test "x$xmltoman" = xyes])
+#
+# Conditionally compile test and example programs
+#
+AC_ARG_ENABLE(tests,
+ AS_HELP_STRING([--enable-tests],[Enable building of tests and examples]),
+ [case "${enableval}" in
+ yes) ENABLE_TESTS=yes ;;
+ no) ENABLE_TESTS=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
+ esac],
+ [ENABLE_TESTS=no])
+
+AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"])
+
+#
+# Optionally enable libdns_sd compatibility support
+#
+AC_ARG_ENABLE(compat-libdns_sd,
+ AS_HELP_STRING([--enable-compat-libdns_sd],[Enable compatibility layer for libdns_sd]),
+ [case "${enableval}" in
+ yes) ENABLE_COMPAT_LIBDNS_SD=yes ;;
+ no) ENABLE_COMPAT_LIBDNS_SD=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-compat-libdns_sd) ;;
+ esac],
+ [ENABLE_COMPAT_LIBDNS_SD=no])
+
+AM_CONDITIONAL([ENABLE_COMPAT_LIBDNS_SD], [test "x$ENABLE_COMPAT_LIBDNS_SD" = "xyes"])
+
+#
+# Optionally enable HOWL compatibility support
+#
+AC_ARG_ENABLE(compat-howl,
+ AS_HELP_STRING([--enable-compat-howl],[Enable compatibility layer for HOWL]),
+ [case "${enableval}" in
+ yes) ENABLE_COMPAT_HOWL=yes ;;
+ no) ENABLE_COMPAT_HOWL=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-compat-howl) ;;
+ esac],
+ [ENABLE_COMPAT_HOWL=no])
+
+AM_CONDITIONAL([ENABLE_COMPAT_HOWL], [test "x$ENABLE_COMPAT_HOWL" = "xyes"])
+
+
# ==========================================================================
AC_CONFIG_FILES([
Makefile
@@ -694,6 +735,14 @@ if test "x$BUILD_DAEMON" = "xyes" -a "x$HAVE_DBUS" = "xyes" ; then
BUILD_CLIENT=yes
fi
+if test "x$ENABLE_COMPAT_LIBDNS_SD" = "xyes" -a "x$BUILD_CLIENT" != "xyes" ; then
+ AC_MSG_ERROR([building avahi-compat-libdns_sd without building libavahi-client doesn't work])
+fi
+if test "x$ENABLE_COMPAT_HOWL" = "xyes" -a "x$BUILD_CLIENT" != "xyes" ; then
+ AC_MSG_ERROR([building avahi-compat-howl without building libavahi-client doesn't work])
+fi
+
+
echo "
Building libavahi-core yes
Building avahi-daemon: ${BUILD_DAEMON}
@@ -705,6 +754,7 @@ echo "
Building libavahi-qt3: ${HAVE_QT3}
Building libavahi-qt4: ${HAVE_QT4}
Building avahi-sharp: ${HAVE_MONO}
- Building avahi-compat-libdns_sd: ${BUILD_CLIENT}
- Building avahi-compat-howl: ${BUILD_CLIENT}
+ Building avahi-compat-libdns_sd: ${ENABLE_COMPAT_LIBDNS_SD}
+ Building avahi-compat-howl: ${ENABLE_COMPAT_HOWL}
+ Building tests: ${ENABLE_TESTS}
"
diff --git a/docs/TODO b/docs/TODO
index 7c660d4..b5ce6b1 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -3,6 +3,7 @@ for 0.6:
* add API to allow user to tell the server that some service is not reachable
* generate local CNAME responses
* drop partially created created entries on failure
+* add error state for server and entry group
* add support for subtypes in static services
* Add static host configuration like static services [lathiat]
* wrap avahi_server_add_record() via DBUS and in avahi-client [lathiat]
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 2a3d48e..92cdccd 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -19,9 +19,11 @@
AM_CFLAGS=-I$(top_srcdir)
+if ENABLE_TESTS
noinst_PROGRAMS = \
core-publish-service \
core-browse-services
+endif
core_publish_service_SOURCES = core-publish-service.c
core_publish_service_CFLAGS = $(AM_CFLAGS)
@@ -33,10 +35,13 @@ core_browse_services_LDADD = $(AM_LDADD) ../avahi-core/libavahi-core.la ../avahi
if HAVE_DBUS
+if ENABLE_TESTS
noinst_PROGRAMS += \
client-publish-service \
client-browse-services
+endif
+
client_publish_service_SOURCES = client-publish-service.c
client_publish_service_CFLAGS = $(AM_CFLAGS)
client_publish_service_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la
@@ -47,8 +52,11 @@ client_browse_services_LDADD = $(AM_LDADD) ../avahi-client/libavahi-client.la ..
if HAVE_GLIB
+if ENABLE_TESTS
noinst_PROGRAMS += \
glib-integration
+endif
+
glib_integration_SOURCES = glib-integration.c
glib_integration_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS)
glib_integration_LDADD = $(AM_LDADD) $(GLIB20_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la ../avahi-glib/libavahi-glib.la
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b3fa8ca..c91cea4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,9 @@ if HAVE_GLIB
if HAVE_DBUS
if HAVE_NETLINK
+if ENABLE_TESTS
noinst_PROGRAMS = c-plus-plus-test
+endif
c_plus_plus_test_SOURCES = c-plus-plus-test.cc