1 #include <sys/socket.h>
2 #include <netinet/in.h>
9 static gboolean quit_timeout(gpointer data) {
10 g_main_loop_quit(data);
14 static gboolean send_timeout(gpointer data) {
15 flxServer *flx = data;
18 k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_TXT);
19 flx_server_post_query(flx, 0, AF_UNSPEC, k);
22 k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_A);
23 flx_server_post_query(flx, 0, AF_INET, k);
29 static gboolean dump_timeout(gpointer data) {
30 flxServer *flx = data;
31 flx_server_dump(flx, stdout);
35 static void subscription(flxSubscription *s, flxRecord *r, gint interface, guchar protocol, flxSubscriptionEvent event, gpointer userdata) {
40 g_assert(interface > 0);
41 g_assert(protocol != AF_UNSPEC);
43 g_message("SUBSCRIPTION: record [%s] on %i.%i is %s", t = flx_record_to_string(r), interface, protocol,
44 event == FLX_SUBSCRIPTION_NEW ? "new" : (event == FLX_SUBSCRIPTION_CHANGE ? "changed" : "removed"));
50 int main(int argc, char *argv[]) {
53 GMainLoop *loop = NULL;
57 flx = flx_server_new(NULL);
59 flx_server_add_text(flx, 0, 0, AF_UNSPEC, FALSE, NULL, "hallo", NULL);
61 /* k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_ANY); */
62 /* s = flx_subscription_new(flx, k, 0, AF_UNSPEC, subscription, NULL); */
63 /* flx_key_unref(k); */
65 loop = g_main_loop_new(NULL, FALSE);
67 g_timeout_add(1000*30, quit_timeout, loop);
68 g_timeout_add(1000, send_timeout, flx);
69 g_timeout_add(1000*20, dump_timeout, flx);
71 g_main_loop_run(loop);
73 g_main_loop_unref(loop);
75 /* flx_subscription_free(s); */