c8e03439773246b72057ffb46826bba4a6748e19
[samba.git] / libcli / dns / dns_lookuptest.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Internal DNS query structures
4  *  Copyright (C) Volker Lendecke 2018
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <talloc.h>
23 #include <errno.h>
24 #include "libcli/dns/dns_lookup.h"
25 #include "lib/util/debug.h"
26
27 static int dns_lookuptest1(void)
28 {
29         struct dns_name_packet *reply = NULL;
30         int ret;
31
32         ret = dns_lookup(NULL, "www.samba.org", DNS_QCLASS_IN, DNS_QTYPE_A,
33                          NULL, &reply);
34         if (ret != 0) {
35                 fprintf(stderr, "dns_lookup failed: %s\n", strerror(ret));
36                 return ret;
37         }
38
39         TALLOC_FREE(reply);
40         return 0;
41 }
42
43 int main(int argc, const char *argv[]) {
44         int ret;
45
46         setup_logging(argv[0], DEBUG_DEFAULT_STDERR);
47         debug_parse_levels("10");
48
49         ret = dns_lookuptest1();
50         if (ret != 0) {
51                 return 1;
52         }
53
54         return 0;
55 }