]> git.meshlink.io Git - catta/blob - avahi-core/avahi-test.c
change avahi.h to core.h in source files
[catta] / avahi-core / avahi-test.c
1 /* $Id$ */
2
3 /***
4   This file is part of avahi.
5  
6   avahi is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as
8   published by the Free Software Foundation; either version 2.1 of the
9   License, or (at your option) any later version.
10  
11   avahi is distributed in the hope that it will be useful, but WITHOUT
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14   Public License for more details.
15  
16   You should have received a copy of the GNU Lesser General Public
17   License along with avahi; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19   USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
29 #include <stdlib.h>
30
31 #include "core.h"
32
33 static gboolean quit_timeout(gpointer data) {
34     g_main_loop_quit(data);
35     return FALSE;
36 }
37
38 static gboolean dump_timeout(gpointer data) {
39     AvahiServer *Avahi = data;
40     avahi_server_dump(Avahi, stdout);
41     return TRUE;
42 }
43
44 static void subscription(AvahiSubscription *s, AvahiRecord *r, gint interface, guchar protocol, AvahiSubscriptionEvent event, gpointer userdata) {
45     gchar *t;
46     
47     g_assert(s);
48     g_assert(r);
49     g_assert(interface > 0);
50     g_assert(protocol != AF_UNSPEC);
51
52     g_message("SUBSCRIPTION: record [%s] on %i.%i is %s", t = avahi_record_to_string(r), interface, protocol,
53               event == AVAHI_SUBSCRIPTION_NEW ? "new" : (event == AVAHI_SUBSCRIPTION_CHANGE ? "changed" : "removed"));
54
55     g_free(t);
56 }
57
58 static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata) {
59     g_message("entry group state: %i", state);
60 }
61
62 int main(int argc, char *argv[]) {
63     AvahiServer *avahi;
64     gchar *r;
65     GMainLoop *loop = NULL;
66     AvahiSubscription *s;
67     AvahiKey *k;
68     AvahiEntryGroup *g;
69
70     avahi = avahi_server_new(NULL);
71
72 /*     g = avahi_entry_group_new(avahi, entry_group_callback, NULL);  */
73     
74 /*    avahi_server_add_text(avahi, g, 0, AF_UNSPEC, AVAHI_ENTRY_UNIQUE, NULL, "hallo", NULL); */
75 /*      avahi_server_add_service(avahi, g, 0, AF_UNSPEC, "_http._tcp", "gurke", NULL, NULL, 80, "foo", NULL);  */
76     
77 /*     avahi_entry_group_commit(g);  */
78
79     avahi_server_dump(avahi, stdout);
80     
81     
82 /*     k = avahi_key_new("ecstasy.local.", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_ANY); */
83 /*     s = avahi_subscription_new(avahi, k, 0, AF_UNSPEC, subscription, NULL); */
84 /*     avahi_key_unref(k); */
85
86     loop = g_main_loop_new(NULL, FALSE);
87     
88   /*   g_timeout_add(1000*20, dump_timeout, Avahi); */
89 /*     g_timeout_add(1000*30, quit_timeout, loop); */
90     
91     g_main_loop_run(loop);
92     g_main_loop_unref(loop);
93
94 /*     avahi_subscription_free(s); */
95     /* avahi_entry_group_free(g);  */
96     avahi_server_free(avahi);
97     
98     return 0;
99 }