]> git.meshlink.io Git - catta/blob - main.c
92f349117025d13b5bb79f22a084592a305fc04a
[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_post_query(flx, 0, AF_UNSPEC, k); */
19 /*     flx_key_unref(k); */
20
21     k = flx_key_new("ecstasy.local.", FLX_DNS_CLASS_IN, FLX_DNS_TYPE_A);
22     flx_server_post_query(flx, 0, AF_INET, k);
23     flx_key_unref(k);
24
25     return FALSE;
26 }
27
28 static gboolean dump_timeout(gpointer data) {
29     flxServer *flx = data;
30     flx_server_dump(flx, stdout);
31     return TRUE;
32 }
33
34 int main(int argc, char *argv[]) {
35     flxServer *flx;
36     gchar *r;
37     GMainLoop *loop = NULL;
38
39     flx = flx_server_new(NULL);
40
41     flx_server_add_text(flx, 0, 0, AF_UNSPEC, FALSE, NULL, "hallo");
42
43     loop = g_main_loop_new(NULL, FALSE);
44     
45     g_timeout_add(1000*60, quit_timeout, loop);
46     g_timeout_add(1000, send_timeout, flx);
47     g_timeout_add(1000*10, dump_timeout, flx);
48     
49     g_main_loop_run(loop);
50
51     g_main_loop_unref(loop);
52
53
54     flx_server_free(flx);
55     
56     return 0;
57 }