loudmouth/test-dns.c
author Jayson Vantuyl <jvantuyl@engineyard.com>
Wed, 25 Mar 2009 11:28:18 -0700
changeset 596 9096d2549372
parent 518 cdd6a0c5b439
child 607 e2bd14357c9a
permissions -rw-r--r--
Removed Dangerous Instructions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
5aa76e995f0d Renamed the test to test-dns and fixed a bug in the asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     5
        
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
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
    43
    g_type_init ();
474
b4eff3e1235c Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents: 472
diff changeset
    44
#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
    45
    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
    46
                                         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
    47
                                         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
    48
    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
    49
#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
    50
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
    51
    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
    52
                                                "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
    53
                                                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
    54
                                                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
    55
    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
    56
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
    57
    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
    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
    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
    60
    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
    61
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
    62
    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
    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
    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
    65
}