7 static int doit(stralloc *work,
const char *rule)
11 unsigned int prefixlen;
14 if ((ch !=
'?') && (ch !=
'=') && (ch !=
'*') && (ch !=
'-'))
return 1;
16 if (!rule[colon])
return 1;
18 if (work->len < colon)
return 1;
19 prefixlen = work->len - colon;
20 if ((ch ==
'=') && prefixlen)
return 1;
21 if (
case_diffb(rule,colon,work->s + prefixlen))
return 1;
23 if (
byte_chr(work->s,prefixlen,
'.') < prefixlen)
return 1;
24 if (
byte_chr(work->s,prefixlen,
':') < prefixlen)
return 1;
25 if (
byte_chr(work->s,prefixlen,
'[') < prefixlen)
return 1;
26 if (
byte_chr(work->s,prefixlen,
']') < prefixlen)
return 1;
29 work->len = prefixlen;
30 if (ch ==
'-') work->len = 0;
43 for (j = i = 0;j < rules->len;++j)
45 if (!doit(fqdn,rules->s + i))
return -1;
50 plus =
byte_chr(fqdn->s,fqdnlen,
'+');
56 j =
byte_chr(fqdn->s + i,fqdnlen - i,
'+');
59 if (
dns_ip6(out,fqdn) == -1)
return -1;
60 if (out->len)
return 0;
62 if (i >= fqdnlen)
return 0;
69 static stralloc
rules;
int stralloc_copy(stralloc *, const stralloc *)
void byte_copy(void *, unsigned int, const void *)
int stralloc_cats(stralloc *, const char *)
int case_diffb(const char *, unsigned int, const char *)
int dns_ip6(stralloc *, stralloc *)
int dns_ip6_qualify_rules(stralloc *out, stralloc *fqdn, const stralloc *in, const stralloc *rules)
int rules(void(*callback)(char *, unsigned int), int fd, char *ip, char *host, char *info)
unsigned int str_chr(const char *, int)
unsigned int byte_chr(const char *, unsigned int n, int)
int dns_ip6_qualify(stralloc *out, stralloc *fqdn, const stralloc *in)
int dns_resolvconfrewrite(stralloc *)