1
0

filters.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef INTFILTER
  2. # define BINFILTER
  3. #endif
  4. #ifdef PCRE2FILTER
  5. # undef BINFILTER
  6. # undef INTFILTER
  7. #endif
  8. #ifdef INTFILTER
  9. # ifdef BINSEARCH
  10. # ifndef BESORT
  11. # define OMITMASK
  12. # endif
  13. # endif
  14. #endif
  15. #ifdef OMITMASK
  16. # define EXPANDMASK
  17. #endif
  18. // whether binfilter struct is needed
  19. #ifdef BINFILTER
  20. # define NEEDBINFILTER
  21. #endif
  22. #ifdef INTFILTER
  23. # define NEEDBINFILTER
  24. #endif
  25. #ifdef NEEDBINFILTER
  26. # ifndef BINFILTERLEN
  27. # define BINFILTERLEN PUBLIC_LEN
  28. # endif
  29. struct binfilter {
  30. u8 f[BINFILTERLEN];
  31. size_t len; // real len minus one
  32. u8 mask;
  33. } ;
  34. VEC_STRUCT(bfiltervec,struct binfilter);
  35. #ifdef BINFILTER
  36. extern struct bfiltervec filters;
  37. #endif
  38. #endif // NEEDBINFILTER
  39. #ifdef INTFILTER
  40. struct intfilter {
  41. IFT f;
  42. # ifndef OMITMASK
  43. IFT m;
  44. # endif
  45. } ;
  46. VEC_STRUCT(ifiltervec,struct intfilter);
  47. extern struct ifiltervec filters;
  48. # ifdef OMITMASK
  49. extern IFT ifiltermask;
  50. # endif
  51. #endif // INTFILTER
  52. #ifdef PCRE2FILTER
  53. #define PCRE2_CODE_UNIT_WIDTH 8
  54. #include <pcre2.h>
  55. struct pcre2filter {
  56. char *str;
  57. pcre2_code *re;
  58. } ;
  59. VEC_STRUCT(pfiltervec,struct pcre2filter);
  60. extern struct pfiltervec filters;
  61. #endif // PCRE2FILTER
  62. extern int flattened;
  63. extern void filters_init(void);
  64. extern void filters_add(const char *filter);
  65. extern size_t filters_count(void);