]> git.meshlink.io Git - catta/blob - main.c
75d03ac6a31ce346b04c3f9b214785c8703f3994
[catta] / main.c
1 #include <sys/socket.h>
2 #include <netinet/in.h>
3 #include <arpa/inet.h>
4
5 #include "flx.h"
6 #include "server.h"
7
8 static gboolean quit_timeout(gpointer data) {
9     g_main_loop_quit(data);
10     return FALSE;
11 }
12
13 static gboolean send_timeout(gpointer data) {
14     flxServer *flx = data;
15     flxKey *k;
16
17     k = flx_key_new("cocaine.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_A);
18     flx_server_send_query(flx, 0, AF_UNSPEC, k);
19     flx_key_unref(k);
20
21     return FALSE;
22 }
23
24 int main(int argc, char *argv[]) {
25     flxServer *flx;
26     gchar *r;
27     GMainLoop *loop = NULL;
28
29     flx = flx_server_new(NULL);
30
31     flx_server_add_text(flx, 0, 0, AF_UNSPEC, FALSE, NULL, "hallo");
32
33     loop = g_main_loop_new(NULL, FALSE);
34     
35     g_timeout_add(1000*5, quit_timeout, loop);
36     g_timeout_add(1000, send_timeout, flx);
37     
38     g_main_loop_run(loop);
39
40     g_main_loop_unref(loop);
41
42     flx_server_dump(flx, stdout);
43
44     flx_server_free(flx);
45     
46     return 0;
47 }