summaryrefslogtreecommitdiffstats
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-15 21:31:30 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-15 21:31:30 +0000
commitf1167112d926b189fe189599576e8588923f036c (patch)
tree20d7d4c58594540de8a4771ae78b204bf8a3db16 /avahi-core
parent86727e2f97a5e845d462178692c8574d226f22d7 (diff)
* cleanup build system a little
* strip remaining glib usage * -fPIC build fix for x86-64 (thanks tvainika) git-svn-id: file:///home/lennart/svn/public/avahi/trunk@336 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/Makefile.am26
-rw-r--r--avahi-core/avahi-test.c56
-rw-r--r--avahi-core/conformance-test.c54
3 files changed, 74 insertions, 62 deletions
diff --git a/avahi-core/Makefile.am b/avahi-core/Makefile.am
index 71f698e..3c6dbcf 100644
--- a/avahi-core/Makefile.am
+++ b/avahi-core/Makefile.am
@@ -19,12 +19,6 @@
AM_CFLAGS=-I$(top_srcdir)
-# Import stuff from avahi-common
-COMMON_LDADD=../avahi-common/libavahi-common.la
-
-# Import stuff from avahi-glib
-GLIB_LDADD=../avahi-glib/libavahi-glib.la
-
# This cool debug trap works on i386/gcc only
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
@@ -77,29 +71,29 @@ libavahi_core_la_SOURCES = \
hashmap.c hashmap.h
libavahi_core_la_CFLAGS = $(AM_CFLAGS)
-libavahi_core_la_LIBADD = $(AM_LDADD) $(COMMON_LDADD)
+libavahi_core_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
libavahi_core_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info 0:0:0
prioq_test_SOURCES = \
prioq-test.c \
prioq.c prioq.h
prioq_test_CFLAGS = $(AM_CFLAGS)
-prioq_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
+prioq_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
avahi_test_SOURCES = \
avahi-test.c
-avahi_test_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS)
-avahi_test_LDADD = $(AM_LDADD) $(COMMON_LDADD) libavahi-core.la $(GLIB_LDADD) $(GLIB20_LIBS)
+avahi_test_CFLAGS = $(AM_CFLAGS)
+avahi_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la libavahi-core.la
conformance_test_SOURCES = \
conformance-test.c
-conformance_test_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS)
-conformance_test_LDADD = $(AM_LDADD) $(COMMON_LDADD) libavahi-core.la $(GLIB_LDADD) $(GLIB20_LIBS)
+conformance_test_CFLAGS = $(AM_CFLAGS)
+conformance_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la libavahi-core.la
avahi_reflector_SOURCES = \
avahi-reflector.c
avahi_reflector_CFLAGS = $(AM_CFLAGS)
-avahi_reflector_LDADD = $(AM_LDADD) $(COMMON_LDADD) libavahi-core.la
+avahi_reflector_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la libavahi-core.la
dns_test_SOURCES = \
dns.c dns.h \
@@ -109,7 +103,7 @@ dns_test_SOURCES = \
rr.c rr.h \
hashmap.c hashmap.h
dns_test_CFLAGS = $(AM_CFLAGS)
-dns_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
+dns_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
timeeventq_test_SOURCES = \
timeeventq-test.c \
@@ -117,14 +111,14 @@ timeeventq_test_SOURCES = \
prioq.h prioq.c \
log.c log.h
timeeventq_test_CFLAGS = $(AM_CFLAGS)
-timeeventq_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
+timeeventq_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
hashmap_test_SOURCES = \
hashmap-test.c \
hashmap.h hashmap.c \
util.h util.c
hashmap_test_CFLAGS = $(AM_CFLAGS)
-hashmap_test_LDADD = $(AM_LDADD) $(COMMON_LDADD)
+hashmap_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
valgrind: avahi-test
libtool --mode=execute valgrind ./avahi-test
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c
index 375fb7d..4b6cd56 100644
--- a/avahi-core/avahi-test.c
+++ b/avahi-core/avahi-test.c
@@ -31,8 +31,7 @@
#include <assert.h>
#include <avahi-common/malloc.h>
-#include <avahi-glib/glib-watch.h>
-#include <avahi-glib/glib-malloc.h>
+#include <avahi-common/simple-watch.h>
#include <avahi-core/core.h>
#include <avahi-core/log.h>
@@ -41,19 +40,26 @@ static AvahiSEntryGroup *group = NULL;
static AvahiServer *server = NULL;
static char *service_name = NULL;
-static int quit_timeout(void* data) {
- g_main_loop_quit(data);
- return 0;
+static const AvahiPoll *poll_api;
+
+static void quit_timeout_callback(AvahiTimeout *timeout, void* userdata) {
+ AvahiSimplePoll *simple_poll = userdata;
+
+ avahi_simple_poll_quit(simple_poll);
}
static void dump_line(const char *text, void* userdata) {
printf("%s\n", text);
}
-static int dump_timeout(void* data) {
- AvahiServer *Avahi = data;
- avahi_server_dump(Avahi, dump_line, NULL);
- return 1;
+static void dump_timeout_callback(AvahiTimeout *timeout, void* userdata) {
+ struct timeval tv;
+
+ AvahiServer *avahi = userdata;
+ avahi_server_dump(avahi, dump_line, NULL);
+
+ avahi_elapse_time(&tv, 5000, 0);
+ poll_api->timeout_update(timeout, &tv);
}
static void record_browser_callback(AvahiSRecordBrowser *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, AvahiRecord *record, void* userdata) {
@@ -120,7 +126,7 @@ static void create_entries(int new_name) {
assert(avahi_s_entry_group_is_empty(group));
if (!service_name)
- service_name = g_strdup("Test Service");
+ service_name = avahi_strdup("Test Service");
else if (new_name) {
char *n = avahi_alternative_service_name(service_name);
avahi_free(service_name);
@@ -210,7 +216,6 @@ static void dsb_callback(AvahiSDNSServerBrowser *b, AvahiIfIndex iface, AvahiPro
}
int main(int argc, char *argv[]) {
- GMainLoop *loop = NULL;
AvahiSRecordBrowser *r;
AvahiSHostNameResolver *hnr;
AvahiSAddressResolver *ar;
@@ -222,15 +227,16 @@ int main(int argc, char *argv[]) {
AvahiSServiceBrowser *sb;
AvahiSServiceResolver *sr;
AvahiSDNSServerBrowser *dsb;
- AvahiGLibPoll *glib_poll;
+ AvahiSimplePoll *simple_poll;
int error;
+ struct timeval tv;
- avahi_set_allocator(avahi_glib_allocator());
- glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
+ simple_poll = avahi_simple_poll_new();
+ poll_api = avahi_simple_poll_get(simple_poll);
avahi_server_config_init(&config);
/* config.host_name = g_strdup("test"); */
- server = avahi_server_new(avahi_glib_poll_get(glib_poll), &config, server_callback, NULL, &error);
+ server = avahi_server_new(poll_api, &config, server_callback, NULL, &error);
avahi_server_config_free(&config);
k = avahi_key_new("_http._tcp.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
@@ -251,13 +257,15 @@ int main(int argc, char *argv[]) {
dsb = avahi_s_dns_server_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "local", AVAHI_DNS_SERVER_RESOLVE, AVAHI_PROTO_UNSPEC, dsb_callback, NULL);
-
- g_timeout_add(1000*5, dump_timeout, server);
- g_timeout_add(1000*60, quit_timeout, loop);
-
- loop = g_main_loop_new(NULL, 0);
- g_main_loop_run(loop);
- g_main_loop_unref(loop);
+ avahi_elapse_time(&tv, 1000*5, 0);
+ poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, server);
+
+ avahi_elapse_time(&tv, 1000*60, 0);
+ poll_api->timeout_new(poll_api, &tv, quit_timeout_callback, server);
+
+ for (;;)
+ if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
+ break;
avahi_s_record_browser_free(r);
avahi_s_host_name_resolver_free(hnr);
@@ -273,8 +281,8 @@ int main(int argc, char *argv[]) {
if (server)
avahi_server_free(server);
- if (glib_poll)
- avahi_glib_poll_free(glib_poll);
+ if (simple_poll)
+ avahi_simple_poll_free(simple_poll);
avahi_free(service_name);
diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c
index fab9b56..3702372 100644
--- a/avahi-core/conformance-test.c
+++ b/avahi-core/conformance-test.c
@@ -32,8 +32,8 @@
#include <assert.h>
#include <avahi-common/alternative.h>
-#include <avahi-glib/glib-watch.h>
-#include <avahi-glib/glib-malloc.h>
+#include <avahi-common/malloc.h>
+#include <avahi-common/simple-watch.h>
#include "core.h"
#include "log.h"
@@ -42,14 +42,19 @@ static char *name = NULL;
static AvahiSEntryGroup *group = NULL;
static int try = 0;
static AvahiServer *avahi = NULL;
+static const AvahiPoll *poll_api;
static void dump_line(const char *text, void* userdata) {
printf("%s\n", text);
}
-static int dump_timeout(void* data) {
+static void dump_timeout_callback(AvahiTimeout *timeout, void* data) {
+ struct timeval tv;
+
avahi_server_dump(avahi, dump_line, NULL);
- return 1;
+
+ avahi_elapse_time(&tv, 5000, 0);
+ poll_api->timeout_update(timeout, &tv);
}
static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
@@ -59,7 +64,7 @@ static void create_service(const char *t) {
assert(t || name);
- n = t ? g_strdup(t) : avahi_alternative_service_name(name);
+ n = t ? avahi_strdup(t) : avahi_alternative_service_name(name);
avahi_free(name);
name = n;
@@ -74,14 +79,16 @@ static void create_service(const char *t) {
try++;
}
-static int rename_timeout(void* data) {
+static void rename_timeout_callback(AvahiTimeout *timeout, void *userdata) {
+ struct timeval tv;
if (access("flag", F_OK) == 0) {
create_service("New - Bonjour Service Name");
- return 0;
+ return;
}
- return 1;
+ avahi_elapse_time(&tv, 5000, 0);
+ poll_api->timeout_update(timeout, &tv);
}
static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata) {
@@ -103,27 +110,30 @@ static void server_callback(AvahiServer *s, AvahiServerState state, void* userda
}
int main(int argc, char *argv[]) {
- GMainLoop *loop = NULL;
- gint error;
- AvahiGLibPoll *glib_poll;
+ int error;
+ AvahiSimplePoll *simple_poll;
+ struct timeval tv;
- avahi_set_allocator(avahi_glib_allocator());
-
- glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
-
- avahi = avahi_server_new(avahi_glib_poll_get(glib_poll), NULL, server_callback, NULL, &error);
+ simple_poll = avahi_simple_poll_new();
+ poll_api = avahi_simple_poll_get(simple_poll);
- loop = g_main_loop_new(NULL, 0);
- g_timeout_add(1000*5, dump_timeout, avahi);
- g_timeout_add(1000*5, rename_timeout, avahi);
- g_main_loop_run(loop);
- g_main_loop_unref(loop);
+ avahi = avahi_server_new(poll_api, NULL, server_callback, NULL, &error);
+ avahi_elapse_time(&tv, 5000, 0);
+ poll_api->timeout_new(poll_api, &tv, dump_timeout_callback, avahi);
+
+ avahi_elapse_time(&tv, 5000, 0);
+ poll_api->timeout_new(poll_api, &tv, rename_timeout_callback, avahi);
+
+ for (;;)
+ if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
+ break;
+
if (group)
avahi_s_entry_group_free(group);
avahi_server_free(avahi);
- avahi_glib_poll_free(glib_poll);
+ avahi_simple_poll_free(simple_poll);
return 0;
}