some tweaks
[mkp224o.git] / filters_common.inc.h
blob613e6946f2a7b3bf53fa0ca1a77af49f7f0f903a
1 #ifdef INTFILTER
3 static inline size_t filter_len(size_t i)
5 # ifndef OMITMASK
6 const u8 *m = (const u8 *)&VEC_BUF(filters,i).m;
7 # else // OMITMASK
8 const u8 *m = (const u8 *)&ifiltermask;
9 # endif // OMITMASK
10 size_t c = 0;
11 for (size_t j = 0;;) {
12 u8 v = m[j];
13 for (size_t k = 0;;) {
14 if (!v)
15 return c;
16 ++c;
17 if (++k >= 8)
18 break;
19 v <<= 1;
21 if (++j >= sizeof(IFT))
22 break;
24 return c;
27 #endif // INTFILTER
29 #ifdef BINFILTER
31 static inline size_t filter_len(size_t i)
33 size_t c = VEC_BUF(filters,i).len * 8;
34 u8 v = VEC_BUF(filters,i).mask;
35 for (size_t k = 0;;) {
36 if (!v)
37 return c;
38 ++c;
39 if (++k >= 8)
40 return c;
41 v <<= 1;
45 #endif // BINFILTER
47 #ifdef PCRE2FILTER
49 #define filter_len(i) ((pcre2ovector[1] - pcre2ovector[0]) * 5)
51 #endif // PCRE2FILTER