mkp224o/filters_common.inc.h
cathugger 30491bd9f8
various things
disable paranoid check which was never triggered as far as I'm aware
add editorconfig
some whitespace changes in configure.ac
which to batch mode by default
start working on putting all filtering options in one bin
some other tweaks
2020-11-21 11:34:25 +00:00

53 lines
875 B
C

#ifdef INTFILTER
static inline size_t S(filter_len)(size_t i)
{
# ifndef OMITMASK
const u8 *m = (const u8 *)&VEC_BUF(filters,i).m;
# else // OMITMASK
const u8 *m = (const u8 *)&ifiltermask;
# endif // OMITMASK
size_t c = 0;
for (size_t j = 0;;) {
u8 v = m[j];
for (size_t k = 0;;) {
if (!v)
return c;
++c;
if (++k >= 8)
break;
v <<= 1;
}
if (++j >= sizeof(IFT))
break;
}
return c;
}
#define filter_len S(filter_len)
#endif // INTFILTER
#ifdef BINFILTER
static inline size_t S(filter_len)(size_t i)
{
size_t c = VEC_BUF(filters,i).len * 8;
u8 v = VEC_BUF(filters,i).mask;
for (size_t k = 0;;) {
if (!v)
return c;
++c;
if (++k >= 8)
return c;
v <<= 1;
}
}
#define filter_len S(filter_len)
#endif // BINFILTER
#ifdef PCRE2FILTER
#define filter_len(i) ((pcre2ovector[1] - pcre2ovector[0]) * 5)
#endif // PCRE2FILTER