source: trunk/third/libsoup/tests/dns.c @ 21108

Revision 21108, 962 bytes checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21107, which included commits to RCS files with non-trunk default branches.
Line 
1#include <config.h>
2
3#include <stdio.h>
4#include <stdlib.h>
5
6#include "libsoup/soup-address.h"
7
8GMainLoop *loop;
9
10static void
11resolve_callback (SoupAddress *addr, guint status, gpointer data)
12{
13        if (status != SOUP_STATUS_OK) {
14                fprintf (stderr, "%s\n", soup_status_get_phrase (status));
15                exit (1);
16        }
17
18        printf ("Name:    %s\n", soup_address_get_name (addr));
19        printf ("Address: %s\n", soup_address_get_physical (addr));
20        g_main_loop_quit (loop);
21}
22
23static void
24usage (void)
25{
26        fprintf (stderr, "Usage: dns [hostname | -r IP]\n");
27        exit (1);
28}
29
30int
31main (int argc, char **argv)
32{
33        SoupAddress *addr;
34
35        if (argc != 2)
36                usage ();
37
38        g_type_init ();
39        g_thread_init (NULL);
40
41        addr = soup_address_new (argv[1], 0);
42        if (!addr) {
43                fprintf (stderr, "Could not parse address %s\n", argv[1]);
44                exit (1);
45        }
46
47        soup_address_resolve_async (addr, resolve_callback, NULL);
48
49        loop = g_main_loop_new (NULL, TRUE);
50        g_main_run (loop);
51        g_main_loop_unref (loop);
52
53        return 0;
54}
Note: See TracBrowser for help on using the repository browser.