1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */ 2 /* Balsa E-Mail Client 3 * 4 * Copyright (C) 1997-2013 Stuart Parmenter and others, 5 * See the file AUTHORS for a list. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 * 02111-1307, USA. 21 */ 22 /* 23 * filter-funcs.h 24 * 25 * Various internal filter functions, not for general 26 * use. 27 */ 28 29 30 #ifndef __FILTER_FUNCS_H__ 31 #define __FILTER_FUNCS_H__ 32 33 #include "filter.h" 34 #include <gtk/gtk.h> 35 36 /* Conditions definitions */ 37 38 /* match flags */ 39 #define CONDITION_EMPTY 0 /* for initialization */ 40 #define CONDITION_MATCH_TO 1<<0 /* match in the To: field */ 41 #define CONDITION_MATCH_FROM 1<<1 /* match in the From: field */ 42 #define CONDITION_MATCH_SUBJECT 1<<2 /* match in the Subject field */ 43 #define CONDITION_MATCH_CC 1<<3 /* match in the cc: field */ 44 #define CONDITION_MATCH_US_HEAD 1<<4 /* match in a user header */ 45 #define CONDITION_MATCH_BODY 1<<7 /* match in the body */ 46 47 /* match_fields macros */ 48 #define CONDITION_SETMATCH(x, y) \ 49 ((((LibBalsaCondition*)(x))->match.string.fields) |= (y)) 50 #define CONDITION_CLRMATCH(x, y) \ 51 ((((LibBalsaCondition*)(x))->match.string.fields) &= ~(y)) 52 #define CONDITION_CHKMATCH(x, y) \ 53 ((((LibBalsaCondition*)(x))->match.string.fields) & (y)) 54 55 /* Filter defintions */ 56 /* filter flags */ 57 #define FILTER_EMPTY 0 /* for clearing bitfields */ 58 59 #define FILTER_VALID 1<<1 /* ready to filter (eg regex strings 60 have been compiled with regcomp(), with no errors...) */ 61 #define FILTER_COMPILED 1<<2 /* the filter needs to be compiled (ie there are uncompiled regex) */ 62 63 /* flag operation macros */ 64 #define FILTER_SETFLAG(x, y) ((((LibBalsaFilter*)(x))->flags) |= (y)) 65 #define FILTER_CLRFLAG(x, y) ((((LibBalsaFilter*)(x))->flags) &= ~(y)) 66 #define FILTER_CHKFLAG(x, y) ((((LibBalsaFilter*)(x))->flags) & (y)) 67 68 /* Conditions */ 69 70 LibBalsaCondition* libbalsa_condition_new(void); 71 72 void libbalsa_conditions_free(GSList * conditions); 73 74 LibBalsaConditionRegex* libbalsa_condition_regex_new(void); 75 void libbalsa_condition_regex_free(LibBalsaConditionRegex *, gpointer); 76 void regexs_free(GSList *); 77 void libbalsa_condition_compile_regexs(LibBalsaCondition* cond); 78 gboolean libbalsa_condition_compare(LibBalsaCondition *c1, 79 LibBalsaCondition *c2); 80 81 /* Filters */ 82 /* Free a filter 83 * free_condition is a gint into a gpointer : if <>0 the function frees filter conditions also 84 */ 85 LibBalsaFilter *libbalsa_filter_new(void); 86 void libbalsa_filter_free(LibBalsaFilter *, gpointer free_condition); 87 void libbalsa_filter_clear_filters(GSList *,gint free_conditions); 88 void libbalsa_filter_append_condition(LibBalsaFilter*, LibBalsaCondition *); 89 void libbalsa_filter_prepend_condition(LibBalsaFilter*, LibBalsaCondition*, 90 ConditionMatchType op); 91 void libbalsa_filter_delete_regex(LibBalsaFilter*,LibBalsaCondition*, 92 LibBalsaConditionRegex *, gpointer); 93 gboolean libbalsa_filter_compile_regexs(LibBalsaFilter *); 94 95 gboolean libbalsa_filter_export_sieve(LibBalsaFilter* fil, gchar* filename); 96 97 /* GtkTreeView helper */ 98 GtkTreeView *libbalsa_filter_list_new(gboolean with_data, 99 const gchar * title, 100 GtkSelectionMode mode, 101 GCallback selection_changed_cb, 102 gboolean sorted); 103 #endif /* __FILTER_FUNCS_H__ */ 104