17static stralloc
sa = {0};
18static stralloc
ia = {0};
19static stralloc
out = {0};
20static stralloc ipaddr = {0};
31 if (
sa.s[
sa.len-1] !=
'.')
32 if (!stralloc_append(&
sa,
"."))
return -1;
36 if (dns_ip6(&
ia,&
sa) > 0) {
37 for (i = 0; i + 16 <=
ia.len; i += 16) {
38 if (ip6_isv4mapped(
ia.s + i))
continue;
39 j = ip6_fmt(ip6str,
ia.s + i);
41 if (!stralloc_catb(ip,ip6str,
j))
return -1;
42 if (!stralloc_cats(ip,
" "))
return -1;
47 if (dns_ip4(&
ia,&
sa) > 0) {
48 for (i = 0; i + 4 <=
ia.len; i += 4) {
49 j = ip4_fmt(ip4str,
ia.s + i);
51 if (!stralloc_catb(ip,ip4str,
j))
return -1;
52 if (!stralloc_cats(ip,
" "))
return -1;
56 if (!stralloc_0(ip))
return -1;
61int main(
int argc,
char *
const *argv)
69 logmsg(
WHO,100,USAGE,
"dnsmx fqdn");
71 logmsg(
WHO,111,FATAL,
"out of memory");
78 j = str_chr(
out.s + len + 2,
'\0');
81 buffer_put(buffer_1,
out.s + len + 2,
j);
82 buffer_puts(buffer_1,
": ");
83 out.s[len + 3] =
'\0';
84 uint16_unpack_big(
out.s + len,&u);
85 buffer_put(buffer_1,
num,fmt_ulong(
num,u)) ;
86 buffer_puts(buffer_1,
" [");
87 buffer_put(buffer_1,ipaddr.s,
k);
88 buffer_puts(buffer_1,
"]");
90 buffer_putsflush(buffer_1,
"\n");
92 }
while (len <
out.len);
96 buffer_puts(buffer_1,argv[1]);
97 buffer_puts(buffer_1,
": -");
98 buffer_puts(buffer_1,
" [");
99 buffer_put(buffer_1,ipaddr.s,
k);
100 buffer_puts(buffer_1,
"]");
101 buffer_putsflush(buffer_1,
"\n");
int stralloc_copys(stralloc *, char const *)
int dns_ia(stralloc *ip, char *s)