1 #include <sys/socket.h>
2 #include <netinet/in.h>
8 static gboolean quit_timeout(gpointer data) {
9 g_main_loop_quit(data);
13 static gboolean dump_timeout(gpointer data) {
14 AvahiServer *Avahi = data;
15 avahi_server_dump(Avahi, stdout);
19 static void subscription(AvahiSubscription *s, AvahiRecord *r, gint interface, guchar protocol, AvahiSubscriptionEvent event, gpointer userdata) {
24 g_assert(interface > 0);
25 g_assert(protocol != AF_UNSPEC);
27 g_message("SUBSCRIPTION: record [%s] on %i.%i is %s", t = avahi_record_to_string(r), interface, protocol,
28 event == AVAHI_SUBSCRIPTION_NEW ? "new" : (event == AVAHI_SUBSCRIPTION_CHANGE ? "changed" : "removed"));
33 static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata) {
34 g_message("entry group state: %i", state);
37 int main(int argc, char *argv[]) {
40 GMainLoop *loop = NULL;
45 avahi = avahi_server_new(NULL);
47 /* g = avahi_entry_group_new(avahi, entry_group_callback, NULL); */
49 /* avahi_server_add_text(avahi, g, 0, AF_UNSPEC, AVAHI_ENTRY_UNIQUE, NULL, "hallo", NULL); */
50 /* avahi_server_add_service(avahi, g, 0, AF_UNSPEC, "_http._tcp", "gurke", NULL, NULL, 80, "foo", NULL); */
52 /* avahi_entry_group_commit(g); */
54 avahi_server_dump(avahi, stdout);
57 /* k = avahi_key_new("ecstasy.local.", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_ANY); */
58 /* s = avahi_subscription_new(avahi, k, 0, AF_UNSPEC, subscription, NULL); */
59 /* avahi_key_unref(k); */
61 loop = g_main_loop_new(NULL, FALSE);
63 /* g_timeout_add(1000*20, dump_timeout, Avahi); */
64 /* g_timeout_add(1000*30, quit_timeout, loop); */
66 g_main_loop_run(loop);
67 g_main_loop_unref(loop);
69 /* avahi_subscription_free(s); */
70 /* avahi_entry_group_free(g); */
71 avahi_server_free(avahi);