18static int dorule(
void (*callback)(
char *,
unsigned int)) {
27 datalen = cdb_datalen(&c);
28 data = alloc(datalen);
30 if (cdb_read(&c,
data,datalen,cdb_datapos(&c)) == -1) {
35 callback(
data, datalen);
40static int doit(
void (*callback)(
char *,
unsigned int),
char *ip,
char *host,
char *info) {
43 int ipv6 = str_len(ip) - byte_chr(ip,str_len(ip),
':');
46 if (!stralloc_copys(&
rules_name,info))
return -1;
47 if (!stralloc_cats(&
rules_name,
"@"))
return -1;
58 if (!stralloc_copys(&
rules_name,info))
return -1;
59 if (!stralloc_cats(&
rules_name,
"@="))
return -1;
60 if (!stralloc_cats(&
rules_name,host))
return -1;
73 if (!stralloc_copys(&
rules_name,ip))
return -1;
79 if (!stralloc_copys(&
rules_name,
"="))
return -1;
80 if (!stralloc_cats(&
rules_name,host))
return -1;
86 if (!stralloc_copys(&
rules_name,ip))
return -1;
98 for (p = 129; p > 1; p--) {
99 if (!stralloc_copys(&
rules_name,
"^"))
return -1;
101 r = dorule(callback);
107 for (p = 33; p > 1; p--) {
108 if (!stralloc_copys(&
rules_name,
"_"))
return -1;
110 r = dorule(callback);
119 if (!stralloc_copys(&
rules_name,
"="))
return -1;
120 if (!stralloc_cats(&
rules_name,host))
return -1;
121 r = dorule(callback);
126 if (!stralloc_copys(&
rules_name,
"="))
return -1;
127 r = dorule(callback);
132 return dorule(callback);
135int rules(
void (*callback)(
char *,
unsigned int),
int fd,
char *ip,
char *host,
char *info) {
139 r =
doit(callback,ip,host,info);
int rules(void(*callback)(char *, unsigned int), int fd, char *ip, char *host, char *info)
int ip6_bitstring(stralloc *ip6string, char *ip6addr, unsigned int prefix)
unsigned int ip6_fmt_str(stralloc *dest, char *src)
int ip4_bitstring(stralloc *ip4string, char *ip, unsigned int prefix)
void doit(int fdleft, int fdright)