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;
28 work->len = prefixlen;
29 if (ch ==
'-') work->len = 0;
42 for (j = i = 0;j < rules->len;++j)
44 if (!doit(fqdn,rules->s + i))
return -1;
49 plus =
byte_chr(fqdn->s,fqdnlen,
'+');
55 j =
byte_chr(fqdn->s + i,fqdnlen - i,
'+');
58 if (
dns_ip4(out,fqdn) == -1)
return -1;
59 if (out->len)
return 0;
61 if (i >= fqdnlen)
return 0;
68 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_ip4(stralloc *, const stralloc *)
int rules(void(*callback)(char *, unsigned int), int fd, char *ip, char *host, char *info)
int dns_ip4_qualify_rules(stralloc *out, stralloc *fqdn, const stralloc *in, const stralloc *rules)
int dns_ip4_qualify(stralloc *out, stralloc *fqdn, const stralloc *in)
unsigned int str_chr(const char *, int)
unsigned int byte_chr(const char *, unsigned int n, int)
int dns_resolvconfrewrite(stralloc *)