mailfilter  0.8.3
filter.hh
Go to the documentation of this file.
1 // filter.hh - source file for the mailfilter program
2 // Copyright (c) 2000 - 2009 Andreas Bauer <baueran@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
18 
19 #ifndef FILTER_HH
20 #define FILTER_HH
21 
22 #include <string>
23 extern "C" {
24 #include <regex.h>
25 #include <sys/types.h>
26 }
27 
28 // Filter modes
29 #define CASE_DEFAULT REG_ICASE
30 #define CASE_SENSITIVE 0
31 #define CASE_INSENSITIVE REG_ICASE
32 
33 using namespace std;
34 
35 class Filter
36 {
37 private:
38  string expr;
39  regex_t comp_expr;
40  regex_t comp_normal_expr;
41  // Values can be CASE_SENSITIVE, CASE_INSENSITIVE, or CASE_DEFAULT:
42  int case_sensitivity;
43  bool negativity;
44  bool compiled;
45 
46 public:
47  Filter (void);
48  ~Filter (void);
49  string expression (void) const;
50  void set_expression (const char*);
51  int compile (void);
52  void set_negativity (bool);
53  bool is_negative (void) const;
54  int ccase (void) const;
55  void set_case (int);
56  const regex_t* comp_exp (void) const;
57 };
58 
59 #endif
Definition: filter.hh:35