/* ISC license. */ #include #include #include #include int s6dns_domain_fromstring (s6dns_domain_t *d, char const *s, size_t len) { register size_t j = 1 ; register size_t i = 0 ; unsigned int lastdot = 0 ; d->s[0] = '.' ; for (; i < len ; i++) { if (lastdot) { if ((j >= 255) || (lastdot++ >= 64)) return (errno = ENAMETOOLONG, 0) ; d->s[j++] = s[i] ; } if (s[i] == '.') lastdot = 0 ; else if (!lastdot) { i-- ; lastdot = 1 ; } } case_lowerb(d->s + 1, j-1) ; d->len = j ; return 1 ; }