/* Public stuff here */

#define MAX_HEADERS 100
#define MAX_FLAGS 300
typedef struct EXP {int fn; int binop; int header; int isnot; char *reg; char *mask; char *p2; int srcline; struct EXP *next;} Exp;
typedef struct LINE {int action,lineno; int p1; int p2; char *reason; char *src; Exp *elist; struct LINE *next;} Linex;
typedef struct FPROG {Linex *lines; char *headers[MAX_HEADERS]; int nheaders; char *flags[MAX_FLAGS]; int nflags; } FProg;
FProg *dfilter_compile(char *fname) ;
int dfilter_run(FProg *dfilterprog, char *item, int len, char *reason);
void dfilter_free(FProg *dfilterprog);
int skip_filter(void);
int skip_from(void);
int skip_dup(void);
void dfilter_emsg(int (*msgfn)( const char *format,... ));
void dfilter_trace(int x);

#ifdef DFILTER_MAIN
/* Private stuff here */
int df_group_match(char *wild, char *grp2);
int df_group_match_list(char *wild, char *grps);
int count_lines(char  *item);
int df_flag_findadd(char *header);
int df_flag_get(int x);
int df_comp_assign(char *p[], int np);
void df_var_set(char *var, char *val);
char *df_var_get(char *var);
void df_var_free(void);
int df_var_replace(char *p[], int np);
Linex *df_comp_if (char *p[], int np);
Exp *df_comp_exp(char *p[], int np, int *upto);
int df_token(char *line, char *p[], int maxp);
int df_find_action(Linex **eline,char *p[],int np,int *upto);
int df_header_findadd(char *arg1);
int df_header_find(char *arg1);
char *df_hdrs_get(int x);
int df_hdrs_free(void);
int df_hdrs_exists(int x);
int comp_match(Exp *exp, char *arg1, char *arg2);
int comp_inpath(Exp *exp, char *arg1, char *arg2);
int comp_rexp(Exp *exp, char *arg1, char *arg2);
int comp_rexp_case(Exp *exp, char *arg1, char *arg2);
int comp_equals(Exp *exp, char *arg1, char *arg2);
int comp_constant(Exp *exp, char *arg1, char *arg2);
int comp_size(Exp *exp, char *arg1, char *arg2);
int comp_isin(Exp *exp, char *arg1, char *arg2);
int comp_ifflag(Exp *exp, char *arg1, char *arg2);
int comp_exists(Exp *exp, char *arg1, char *arg2);
int comp_matchall(Exp *exp, char *arg1, char *arg2);
int comp_matchone(Exp *exp, char *arg1, char *arg2);
int comp_allmod(Exp *exp, char *arg1, char *arg2);
Linex *df_comp_else(char *p[], int np);
Linex *df_comp_end(char *p[], int np);
int comp_isbinaryn(Exp *exp, char *arg1, char *arg2);
int comp_get(Exp *exp, char *arg1, char *arg2);

int run_isbinaryn(Exp *exp);
int run_constant(Exp *exp);
int run_match(Exp *exp);
int run_inpath(Exp *exp);
int run_ifflag(Exp *exp);
int run_exists(Exp *exp);
int run_rexp(Exp *exp);
int run_splitrexp(Exp *exp);
int run_lastrexp(Exp *exp);
int run_equals(Exp *exp);
int run_size(Exp *exp);
int run_isin(Exp *exp);
int run_isinlist(Exp *exp);
int run_matchall(Exp *exp);
int run_matchone(Exp *exp);
int run_split(Exp *exp);
int run_lines(Exp *exp);
int run_isuuencoded(Exp *exp);
int run_isbinary(Exp *exp);
int run_ishtml(Exp *exp);
int run_isbase64(Exp *exp);
int run_isimage(Exp *exp);
int run_allmod(Exp *exp);
int run_isencodedtext(Exp *exp);
int run_isencodedhtml(Exp *exp);
int run_isencodedurl(Exp *exp);
int run_isencodedexe(Exp *exp);
int run_get(Exp *exp);
int run_ispost(Exp *exp);
int comp_attach(Exp *exp, char *arg1, char *arg2);
int run_attach(Exp *exp);
int run_isinc(Exp *exp);


int df_getline(char *item, int *upto, char *bf, int bfsz);
int df_match_mod(char *groups);
int df_ismod(char *group);


#endif
