diff options
author | Aleksey Veresov <AKVeresov@gmail.com> | 2020-04-28 01:57:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 01:57:14 +0300 |
commit | e9f1c6b518a62e3b173c8dfa396bbf18b5dc7cde (patch) | |
tree | 3a75964121c7dbd06ef89010bbfbf80651f58428 /dns_example.c | |
download | vsdns-e9f1c6b518a62e3b173c8dfa396bbf18b5dc7cde.tar vsdns-e9f1c6b518a62e3b173c8dfa396bbf18b5dc7cde.tar.xz vsdns-e9f1c6b518a62e3b173c8dfa396bbf18b5dc7cde.zip |
It's alive
Diffstat (limited to 'dns_example.c')
-rw-r--r-- | dns_example.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dns_example.c b/dns_example.c new file mode 100644 index 0000000..27eea8d --- /dev/null +++ b/dns_example.c @@ -0,0 +1,28 @@ +#include <dns.h> +#include <stdio.h> + + +int main() +{ + struct dns_answers *ans = dns_get("10.1.1.1", + "veresov.pro", + dns_type_mx); + struct dns_answers *cur; + for (cur = ans; cur; cur = cur->next) { + if (cur->type == dns_type_a) { + unsigned char *ip = cur->data; + printf("IP of %s is %d.%d.%d.%d.\n", + cur->host, ip[0], ip[1], ip[2], ip[3]); + } else if (cur->type == dns_type_cname) { + printf("Cannonical name of %s is %s.\n", cur->host, cur->data); + } else if (cur->type == dns_type_txt) { + printf("Text from %s: %s\n", cur->host, cur->data); + } else if (cur->type == dns_type_mx) { + printf("Mail exchange server for %s with preference %d is %s.\n", + cur->host, + dns_mx_preference(cur->data), dns_mx_server(cur->data)); + } + } + dns_free(ans); + return 0; +} |