| 1 | #include "buffer.h" |
| 2 | #include "exit.h" |
| 3 | #include "strerr.h" |
| 4 | #include "ip4.h" |
| 5 | #include "dns.h" |
| 6 | |
| 7 | #define FATAL "dnsipq: fatal: " |
| 8 | |
| 9 | static char seed[128]; |
| 10 | |
| 11 | static stralloc in; |
| 12 | static stralloc fqdn; |
| 13 | static stralloc out; |
| 14 | char str[IP4_FMT]; |
| 15 | |
| 16 | int main(int argc,char **argv) |
| 17 | { |
| 18 | int i; |
| 19 | |
| 20 | dns_random_init(seed); |
| 21 | |
| 22 | if (*argv) ++argv; |
| 23 | |
| 24 | while (*argv) { |
| 25 | if (!stralloc_copys(&in,*argv)) |
| 26 | strerr_die2x(111,FATAL,"out of memory"); |
| 27 | if (dns_ip4_qualify(&out,&fqdn,&in) == -1) |
| 28 | strerr_die4sys(111,FATAL,"unable to find IP address for ",*argv,": "); |
| 29 | |
| 30 | buffer_put(buffer_1,fqdn.s,fqdn.len); |
| 31 | buffer_puts(buffer_1," "); |
| 32 | for (i = 0;i + 4 <= out.len;i += 4) { |
| 33 | buffer_put(buffer_1,str,ip4_fmt(str,out.s + i)); |
| 34 | buffer_puts(buffer_1," "); |
| 35 | } |
| 36 | buffer_puts(buffer_1,"\n"); |
| 37 | |
| 38 | ++argv; |
| 39 | } |
| 40 | |
| 41 | buffer_flush(buffer_1); |
| 42 | _exit(0); |
| 43 | } |