aboutsummaryrefslogtreecommitdiff
path: root/dnsip.c
diff options
context:
space:
mode:
authorHenryk Plötz <henryk@ploetzli.ch>2014-10-03 19:58:52 +0200
committerHenryk Plötz <henryk@ploetzli.ch>2014-10-03 19:58:52 +0200
commit0e5b2871ca6456b01d4bf037a6e68badf1ff1a41 (patch)
tree97b95b74c9618d85da9aa9451a55a819cd7b1c2e /dnsip.c
downloadtinydnssec-0e5b2871ca6456b01d4bf037a6e68badf1ff1a41.tar.gz
tinydnssec-0e5b2871ca6456b01d4bf037a6e68badf1ff1a41.tar.bz2
Initial commit of djbdns-1.05.tar.gz
Source was http://cr.yp.to/djbdns/djbdns-1.05.tar.gz, SHA1 2efdb3a039d0c548f40936aa9cb30829e0ce8c3d
Diffstat (limited to 'dnsip.c')
-rw-r--r--dnsip.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/dnsip.c b/dnsip.c
new file mode 100644
index 0000000..60c5d3d
--- /dev/null
+++ b/dnsip.c
@@ -0,0 +1,40 @@
+#include "buffer.h"
+#include "exit.h"
+#include "strerr.h"
+#include "ip4.h"
+#include "dns.h"
+
+#define FATAL "dnsip: fatal: "
+
+static char seed[128];
+
+static stralloc fqdn;
+static stralloc out;
+char str[IP4_FMT];
+
+int main(int argc,char **argv)
+{
+ int i;
+
+ dns_random_init(seed);
+
+ if (*argv) ++argv;
+
+ while (*argv) {
+ if (!stralloc_copys(&fqdn,*argv))
+ strerr_die2x(111,FATAL,"out of memory");
+ if (dns_ip4(&out,&fqdn) == -1)
+ strerr_die4sys(111,FATAL,"unable to find IP address for ",*argv,": ");
+
+ for (i = 0;i + 4 <= out.len;i += 4) {
+ buffer_put(buffer_1,str,ip4_fmt(str,out.s + i));
+ buffer_puts(buffer_1," ");
+ }
+ buffer_puts(buffer_1,"\n");
+
+ ++argv;
+ }
+
+ buffer_flush(buffer_1);
+ _exit(0);
+}