mkp224o/filters.h

97 lines
1.3 KiB
C
Raw Normal View History

2018-01-20 16:33:28 +01:00
2018-01-20 17:14:49 +01:00
#ifndef INTFILTER
# define BINFILTER
2018-01-20 16:33:28 +01:00
#endif
2018-01-20 17:14:49 +01:00
2018-01-20 20:55:45 +01:00
#ifdef PCRE2FILTER
# undef BINFILTER
# undef INTFILTER
#endif
2018-01-20 17:14:49 +01:00
#ifdef INTFILTER
# ifdef BINSEARCH
# ifndef BESORT
# define OMITMASK
# endif
# endif
2018-01-20 16:33:28 +01:00
#endif
#ifdef OMITMASK
2018-01-20 17:14:49 +01:00
# define EXPANDMASK
2018-01-20 16:33:28 +01:00
#endif
2018-01-20 17:14:49 +01:00
// whether binfilter struct is needed
#ifdef BINFILTER
# define NEEDBINFILTER
#endif
#ifdef INTFILTER
# define NEEDBINFILTER
2018-01-20 16:33:28 +01:00
#endif
2018-01-20 17:14:49 +01:00
#ifdef NEEDBINFILTER
2018-01-20 17:14:49 +01:00
# ifndef BINFILTERLEN
# define BINFILTERLEN PUBLIC_LEN
# endif
2018-01-20 16:33:28 +01:00
struct binfilter {
u8 f[BINFILTERLEN];
size_t len; // real len minus one
u8 mask;
} ;
2019-03-16 20:57:29 +01:00
VEC_STRUCT(bfiltervec,struct binfilter);
#ifdef BINFILTER
extern struct bfiltervec filters;
#endif
2018-01-20 17:14:49 +01:00
#endif // NEEDBINFILTER
2018-01-20 16:33:28 +01:00
#ifdef INTFILTER
2019-03-16 20:57:29 +01:00
2018-01-20 16:33:28 +01:00
struct intfilter {
IFT f;
# ifndef OMITMASK
IFT m;
# endif
} ;
2018-01-20 20:55:45 +01:00
2019-03-16 20:57:29 +01:00
VEC_STRUCT(ifiltervec,struct intfilter);
2018-01-20 20:55:45 +01:00
2019-03-16 20:57:29 +01:00
extern struct ifiltervec filters;
2018-01-20 16:33:28 +01:00
# ifdef OMITMASK
2019-03-16 20:57:29 +01:00
extern IFT ifiltermask;
# endif
2018-01-20 17:14:49 +01:00
#endif // INTFILTER
2018-01-20 16:33:28 +01:00
2018-01-20 20:55:45 +01:00
#ifdef PCRE2FILTER
2019-03-16 20:57:29 +01:00
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
2018-01-20 20:55:45 +01:00
2019-03-16 20:57:29 +01:00
struct pcre2filter {
char *str;
2018-01-20 20:55:45 +01:00
pcre2_code *re;
2019-03-16 20:57:29 +01:00
} ;
2019-03-16 20:57:29 +01:00
VEC_STRUCT(pfiltervec,struct pcre2filter);
2018-01-20 20:55:45 +01:00
2019-03-16 20:57:29 +01:00
extern struct pfiltervec filters;
2018-01-20 20:55:45 +01:00
#endif // PCRE2FILTER
2018-01-20 16:33:28 +01:00
2019-03-16 20:57:29 +01:00
extern int flattened;
2018-01-20 16:33:28 +01:00
2019-03-16 20:57:29 +01:00
extern void filters_init(void);
extern void filters_add(const char *filter);
2019-03-16 20:57:29 +01:00
extern size_t filters_count(void);