filters_common.inc.h 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifdef INTFILTER
  2. static inline size_t S(filter_len)(size_t i)
  3. {
  4. # ifndef OMITMASK
  5. const u8 *m = (const u8 *)&VEC_BUF(filters,i).m;
  6. # else // OMITMASK
  7. (void) i;
  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;
  20. }
  21. if (++j >= sizeof(IFT))
  22. break;
  23. }
  24. return c;
  25. }
  26. #define filter_len S(filter_len)
  27. #endif // INTFILTER
  28. #ifdef BINFILTER
  29. static inline size_t S(filter_len)(size_t i)
  30. {
  31. size_t c = VEC_BUF(filters,i).len * 8;
  32. u8 v = VEC_BUF(filters,i).mask;
  33. for (size_t k = 0;;) {
  34. if (!v)
  35. return c;
  36. ++c;
  37. if (++k >= 8)
  38. return c;
  39. v <<= 1;
  40. }
  41. }
  42. #define filter_len S(filter_len)
  43. #endif // BINFILTER
  44. #ifdef PCRE2FILTER
  45. #define filter_len(i) ((pcre2ovector[1] - pcre2ovector[0]) * 5)
  46. #endif // PCRE2FILTER