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); */
20 /* flx_key_unref(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); */
24 /* flx_key_unref(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, FLX_SERVER_ENTRY_UNIQUE, NULL, "hallo", NULL);
60 flx_server_add_service(flx, 0, 0, AF_UNSPEC, "_http._tcp", "gurke", NULL, NULL, 80, "foo", NULL);
62 /* k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_ANY); */
63 /* s = flx_subscription_new(flx, k, 0, AF_UNSPEC, subscription, NULL); */
64 /* flx_key_unref(k); */
66 loop = g_main_loop_new(NULL, FALSE);
68 g_timeout_add(1000*30, quit_timeout, loop);
69 g_timeout_add(1000, send_timeout, flx);
70 g_timeout_add(1000*20, dump_timeout, flx);
72 g_main_loop_run(loop);
74 g_main_loop_unref(loop);
76 /* flx_subscription_free(s); */