author | Frank Zschockelt <lm@freakysoft.de> |
Sat, 11 May 2019 22:25:15 +0200 | |
changeset 737 | ca896de7b10d |
parent 648 | b29eecd0ac08 |
permissions | -rw-r--r-- |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
1 |
/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
2 |
|
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
3 |
#include <loudmouth.h> |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
4 |
#include "lm-blocking-resolver.h" |
607 | 5 |
|
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
6 |
GMainLoop *main_loop; |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
7 |
|
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
8 |
static void |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
9 |
resolver_result_cb (LmResolver *resolver, |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
10 |
LmResolverResult result, |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
11 |
gpointer user_data) |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
12 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
13 |
gchar *host; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
14 |
struct addrinfo *addr; |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
15 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
16 |
g_object_get (resolver, "host", &host, NULL); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
17 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
18 |
if (result != LM_RESOLVER_RESULT_OK) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
19 |
g_print ("Failed to lookup %s\n", host); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
20 |
g_free (host); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
21 |
return; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
22 |
} |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
23 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
24 |
g_print ("In %s\n", G_STRFUNC); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
25 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
26 |
while ((addr = lm_resolver_results_get_next (resolver))) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
27 |
g_print ("Result!\n"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
28 |
} |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
29 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
30 |
g_free (host); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
31 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
32 |
g_main_loop_quit (main_loop); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
33 |
} |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
34 |
|
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
35 |
int |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
36 |
main (int argc, char **argv) |
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
37 |
{ |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
38 |
#if 0 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
39 |
LmResolver *resolver; |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
40 |
#endif |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
41 |
LmResolver *srv_resolver; |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
42 |
|
648
b29eecd0ac08
Disable g_type_init for glib >= 2.35
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
43 |
#if !GLIB_CHECK_VERSION(2, 35, 0) |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
44 |
g_type_init (); |
648
b29eecd0ac08
Disable g_type_init for glib >= 2.35
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
45 |
#endif |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
46 |
#if 0 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
47 |
resolver = lm_resolver_new_for_host ("kenny.imendio.com", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
48 |
resolver_result_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
49 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
50 |
lm_resolver_lookup (resolver); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
51 |
#endif |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
52 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
53 |
srv_resolver = lm_resolver_new_for_service ("jabber.org", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
54 |
"xmpp-client", "tcp", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
55 |
resolver_result_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
56 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
57 |
lm_resolver_lookup (srv_resolver); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
58 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
59 |
g_print ("Running main loop\n"); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
60 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
61 |
main_loop = g_main_loop_new (NULL, FALSE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
62 |
g_main_loop_run (main_loop); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
63 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
64 |
g_print ("Finished\n"); |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
65 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
66 |
return 0; |
472
5aa76e995f0d
Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
67 |
} |