diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-15 21:31:30 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-15 21:31:30 +0000 |
commit | f1167112d926b189fe189599576e8588923f036c (patch) | |
tree | 20d7d4c58594540de8a4771ae78b204bf8a3db16 /avahi-client | |
parent | 86727e2f97a5e845d462178692c8574d226f22d7 (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-client')
-rw-r--r-- | avahi-client/Makefile.am | 26 | ||||
-rw-r--r-- | avahi-client/client-test.c | 59 |
2 files changed, 41 insertions, 44 deletions
diff --git a/avahi-client/Makefile.am b/avahi-client/Makefile.am index 0a5bffa..1aff288 100644 --- a/avahi-client/Makefile.am +++ b/avahi-client/Makefile.am @@ -22,35 +22,27 @@ AM_CFLAGS=-I$(top_srcdir) # This cool debug trap works on i386/gcc only AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' -if ENABLE_DBUS +if HAVE_DBUS avahi_clientincludedir=$(includedir)/avahi-client +avahi_clientinclude_HEADERS = client.h -avahi_clientinclude_HEADERS = \ - client.h +noinst_HEADERS = internal.h -noinst_HEADERS = \ - internal.h +noinst_PROGRAMS = client-test -noinst_PROGRAMS = \ - client-test - -lib_LTLIBRARIES = \ - libavahi-client.la +lib_LTLIBRARIES = libavahi-client.la libavahi_client_la_SOURCES = \ client.c client.h \ entrygroup.c \ browser.c - libavahi_client_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -libavahi_client_la_LIBADD = $(AM_LDADD) $(DBUS_LIBS) ../avahi-common/libavahi-common.la ../avahi-common/libdbus-watch-glue.la +libavahi_client_la_LIBADD = $(AM_LDADD) $(DBUS_LIBS) ../avahi-common/libavahi-common.la ../avahi-common/libdbus-watch-glue-pic.la libavahi_client_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info 0:0:0 -client_test_SOURCES = \ - client-test.c - -client_test_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS) -client_test_LDADD = $(AM_LDADD) $(GLIB20_LIBS) libavahi-client.la ../avahi-common/libavahi-common.la ../avahi-glib/libavahi-glib.la +client_test_SOURCES = client-test.c +client_test_CFLAGS = $(AM_CFLAGS) +client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la endif diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 2189467..11bc4f2 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -25,10 +25,13 @@ #include <avahi-client/client.h> #include <avahi-common/error.h> -#include <avahi-glib/glib-watch.h> -#include <avahi-glib/glib-malloc.h> +#include <avahi-common/simple-watch.h> +#include <avahi-common/malloc.h> #include <stdio.h> -#include <glib.h> +#include <assert.h> + +static const AvahiPoll *poll_api = NULL; + static void avahi_client_callback (AvahiClient *c, AvahiClientState state, void *user_data) @@ -60,60 +63,54 @@ avahi_service_type_browser_callback (AvahiServiceTypeBrowser *b, AvahiIfIndex in printf ("XXX: Callback on %s, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", avahi_service_type_browser_path (b), interface, protocol, event, type, domain, (char*)user_data); } -static gboolean -test_free_domain_browser (gpointer data) +static void test_free_domain_browser(AvahiTimeout *timeout, void* userdata) { - AvahiServiceBrowser *b = data; + AvahiServiceBrowser *b = userdata; printf ("XXX: freeing domain browser\n"); avahi_service_browser_free (b); - return FALSE; } -static gboolean -test_free_entry_group (gpointer data) +static void test_free_entry_group (AvahiTimeout *timeout, void* userdata) { - AvahiEntryGroup *g = data; + AvahiEntryGroup *g = userdata; printf ("XXX: freeing entry group\n"); avahi_entry_group_free (g); - return FALSE; } int main (int argc, char *argv[]) { - GMainLoop *loop; AvahiClient *avahi; AvahiEntryGroup *group; AvahiStringList *txt; AvahiDomainBrowser *domain; AvahiServiceBrowser *sb; AvahiServiceTypeBrowser *st; - AvahiGLibPoll *glib_poll; + AvahiSimplePoll *simple_poll; char *ret; + struct timeval tv; - avahi_set_allocator(avahi_glib_allocator()); - - glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT); - loop = g_main_loop_new (NULL, FALSE); + simple_poll = avahi_simple_poll_new(); + poll_api = avahi_simple_poll_get(simple_poll); - avahi = avahi_client_new (avahi_glib_poll_get(glib_poll), avahi_client_callback, "omghai2u"); + avahi = avahi_client_new(poll_api, avahi_client_callback, "omghai2u"); - g_assert (avahi != NULL); + assert (avahi != NULL); ret = avahi_client_get_version_string (avahi); printf ("Avahi Server Version: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); - g_free (ret); + avahi_free (ret); ret = avahi_client_get_host_name (avahi); printf ("Host Name: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); - g_free (ret); + avahi_free (ret); ret = avahi_client_get_domain_name (avahi); printf ("Domain Name: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); - g_free (ret); + avahi_free (ret); ret = avahi_client_get_host_name_fqdn (avahi); printf ("FQDN: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); - g_free (ret); + avahi_free (ret); group = avahi_entry_group_new (avahi, avahi_entry_group_callback, "omghai"); @@ -148,12 +145,20 @@ main (int argc, char *argv[]) else printf ("Sucessfully created service browser, path %s\n", avahi_service_browser_path (sb)); - g_timeout_add (2000, test_free_entry_group, group); - g_timeout_add (5000, test_free_domain_browser, sb); - g_main_loop_run (loop); + avahi_elapse_time(&tv, 5000, 0); + poll_api->timeout_new(poll_api, &tv, test_free_entry_group, group); + avahi_elapse_time(&tv, 8000, 0); + poll_api->timeout_new(poll_api, &tv, test_free_domain_browser, sb); + + for (;;) + if (avahi_simple_poll_iterate(simple_poll, -1) != 0) + break; + + + avahi_simple_poll_free(simple_poll); - g_free (avahi); + avahi_free (avahi); return 0; } |