Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 41 lines (30 sloc) 0.745 kb
3e25c70 import dnscache 1.00
D. J. Bernstein authored
1 #include "buffer.h"
2 #include "exit.h"
3 #include "strerr.h"
4 #include "ip4.h"
5 #include "dns.h"
6
7 #define FATAL "dnsip: fatal: "
8
9 static char seed[128];
10
11 static stralloc fqdn;
12 static stralloc out;
13 char str[IP4_FMT];
14
df36440 import djbdns 1.03
D. J. Bernstein authored
15 int main(int argc,char **argv)
3e25c70 import dnscache 1.00
D. J. Bernstein authored
16 {
17 int i;
18
19 dns_random_init(seed);
20
21 if (*argv) ++argv;
22
23 while (*argv) {
24 if (!stralloc_copys(&fqdn,*argv))
25 strerr_die2x(111,FATAL,"out of memory");
26 if (dns_ip4(&out,&fqdn) == -1)
27 strerr_die4sys(111,FATAL,"unable to find IP address for ",*argv,": ");
28
29 for (i = 0;i + 4 <= out.len;i += 4) {
30 buffer_put(buffer_1,str,ip4_fmt(str,out.s + i));
31 buffer_puts(buffer_1," ");
32 }
33 buffer_puts(buffer_1,"\n");
34
35 ++argv;
36 }
37
38 buffer_flush(buffer_1);
39 _exit(0);
40 }
Something went wrong with that request. Please try again.