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 flxServer *flx = data;
15 flx_server_dump(flx, stdout);
19 static void subscription(flxSubscription *s, flxRecord *r, gint interface, guchar protocol, flxSubscriptionEvent 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 = flx_record_to_string(r), interface, protocol,
28 event == FLX_SUBSCRIPTION_NEW ? "new" : (event == FLX_SUBSCRIPTION_CHANGE ? "changed" : "removed"));
33 static void entry_group_callback(flxServer *s, flxEntryGroup *g, flxEntryGroupStatus status, gpointer userdata) {
34 g_message("entry group state: %i", status);
37 int main(int argc, char *argv[]) {
40 GMainLoop *loop = NULL;
45 flx = flx_server_new(NULL);
47 g = flx_entry_group_new(flx, entry_group_callback, NULL);
49 /* flx_server_add_text(flx, g, 0, AF_UNSPEC, FLX_ENTRY_UNIQUE, NULL, "hallo", NULL); */
50 flx_server_add_service(flx, g, 0, AF_UNSPEC, "_http._tcp", "gurke", NULL, NULL, 80, "foo", NULL);
52 flx_entry_group_commit(g);
54 flx_server_dump(flx, stdout);
57 /* k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_ANY); */
58 /* s = flx_subscription_new(flx, k, 0, AF_UNSPEC, subscription, NULL); */
59 /* flx_key_unref(k); */
61 loop = g_main_loop_new(NULL, FALSE);
63 g_timeout_add(1000*20, dump_timeout, flx);
64 g_timeout_add(1000*30, quit_timeout, loop);
66 g_main_loop_run(loop);
67 g_main_loop_unref(loop);
69 /* flx_subscription_free(s); */
70 /* flx_entry_group_free(g); */