diff options
author | Henryk Plötz <henryk@ploetzli.ch> | 2014-10-03 19:58:52 +0200 |
---|---|---|
committer | Henryk Plötz <henryk@ploetzli.ch> | 2014-10-03 19:58:52 +0200 |
commit | 0e5b2871ca6456b01d4bf037a6e68badf1ff1a41 (patch) | |
tree | 97b95b74c9618d85da9aa9451a55a819cd7b1c2e /dd.c | |
download | tinydnssec-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 'dd.c')
-rw-r--r-- | dd.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,36 @@ +#include "dns.h" +#include "dd.h" + +int dd(const char *q,const char *base,char ip[4]) +{ + int j; + unsigned int x; + + for (j = 0;;++j) { + if (dns_domain_equal(q,base)) return j; + if (j >= 4) return -1; + + if (*q <= 0) return -1; + if (*q >= 4) return -1; + if ((q[1] < '0') || (q[1] > '9')) return -1; + x = q[1] - '0'; + if (*q == 1) { + ip[j] = x; + q += 2; + continue; + } + if (!x) return -1; + if ((q[2] < '0') || (q[2] > '9')) return -1; + x = x * 10 + (q[2] - '0'); + if (*q == 2) { + ip[j] = x; + q += 3; + continue; + } + if ((q[3] < '0') || (q[3] > '9')) return -1; + x = x * 10 + (q[3] - '0'); + if (x > 255) return -1; + ip[j] = x; + q += 4; + } +} |