]> git.meshlink.io Git - catta/blob - main.c
some work
[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 GMainLoop *loop = NULL;
9
10 static gboolean timeout(gpointer data) {
11     g_main_loop_quit(loop);
12     return FALSE;
13 }
14
15 int main(int argc, char *argv[]) {
16     flxServer *flx;
17     flxLocalAddrSource *l;
18     flxAddress a;
19     gchar *r;
20     flxQuery q;
21
22     flx = flx_server_new(NULL);
23
24     l = flx_local_addr_source_new(flx);
25
26     flx_address_parse("127.0.0.1", AF_INET, &a);
27     flx_server_add_address(flx, 0, 0, AF_UNSPEC, "localhost", &a);
28
29     flx_address_parse("::1", AF_INET6, &a);
30     flx_server_add_address(flx, 0, 0, AF_UNSPEC, "ip6-localhost", &a);
31
32     q.name = "campari.local.";
33     q.class = FLX_DNS_CLASS_IN;
34     q.type = FLX_DNS_TYPE_A;
35     flx_server_post_query_job(flx, 0, AF_UNSPEC, NULL, &q);
36     
37     g_timeout_add(5000, timeout, NULL);
38     
39     loop = g_main_loop_new(NULL, FALSE);
40     g_main_loop_run(loop);
41     g_main_loop_unref(loop);
42
43     flx_server_dump(flx, stdout);
44
45     flx_local_addr_source_free(l);
46     flx_server_free(flx);
47     return 0;
48 }