-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdnstest.c
55 lines (48 loc) · 1.09 KB
/
dnstest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "lib/socket.h"
#include "lib/io.h"
#include "lib/iarray.h"
#include "lib/case.h"
#include "lib/open.h"
#include "lib/stralloc.h"
#include "lib/scan.h"
#include "lib/fmt.h"
#include "lib/str.h"
#include "lib/tai.h"
#include "lib/taia.h"
#include "lib/buffer.h"
#include "lib/dns.h"
#include "lib/errmsg.h"
#include "lib/ip4.h"
#include <errno.h>
int
main(int argc, char* argv[]) {
static char seed[128];
static stralloc fqdn;
static stralloc out;
char str[IP4_FMT];
unsigned int i;
errmsg_iam("dnsip");
(void)argc;
dns_random_init(seed);
if(*argv)
++argv;
while(*argv) {
if(!stralloc_copys(&fqdn, *argv)) {
buffer_putsflush(buffer_2, "out of memory\n");
return 111;
}
if(dns_ip4(&out, &fqdn) == -1) {
errmsg_warnsys("unable to find P address for ", *argv, 0);
return 111;
}
for(i = 0; i + 4 <= out.len; i += 4) {
if(i)
buffer_puts(buffer_1, " ");
buffer_put(buffer_1, str, fmt_ip4(str, out.s + i));
}
buffer_puts(buffer_1, "\n");
++argv;
}
buffer_flush(buffer_1);
return 0;
}