Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Preferences.hh

Go to the documentation of this file.
00001 // Preferences.hh - source file for the mailfilter program
00002 // Copyright (c) 2000 - 2002  Andreas Bauer <baueran@in.tum.de>
00003 //
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 2 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017 // USA.
00018 
00019 #ifndef PREFERENCES_HH
00020 #define PREFERENCES_HH
00021 
00022 #include <string>
00023 #include <vector>
00024 #include <list>
00025 extern "C" {
00026 #include <sys/types.h>
00027 #include <regex.h>
00028 }
00029 #include "RegExp.hh"
00030 #include "mailfilter.hh"
00031 
00032 // Filter modes
00033 #define CASE_DEFAULT       0
00034 #define CASE_SENSITIVE     1
00035 #define CASE_INSENSITIVE   2
00036 
00037 // Verbose levels
00038 #define MIN_VERBOSE        0
00039 #define MAX_VERBOSE        6
00040 
00041 using namespace std;
00042 
00043 namespace pref {
00044   
00045   struct serverInfo {
00046     string name;
00047     string user;
00048     string pass;
00049     int protocol;
00050     int port;
00051   };
00052 
00053 
00054   struct filterInfo {
00055     string filter;        // Filter as ordinary string object
00056     int case_sensitive;   // Values can be { CASE_SENSITIVE | CASE_INSENSITIVE | CASE_DEFAULT }
00057 
00058     // Negative filters
00059     bool negative;        // true if filter is of type 'DENY<>myaddress@something.com', otherwise false
00060     bool matched;         // Is set to true during run-time if a negative filter has matched a line, otherwise leave this value with false
00061 
00062     regex_t cFilter;      // Compiled filter
00063   };
00064   
00065 
00066   struct friendInfo {
00067     string filter;
00068     regex_t cFilter;
00069   };
00070 
00071 
00072   class Preferences {
00073   private:
00074     // Variables
00075     vector<serverInfo> servers;
00076     vector<filterInfo> filters;
00077     vector<friendInfo> friends;
00078     serverInfo popServer;
00079     string logfile;
00080     string file;
00081     int maxsize;
00082     int maxsizeFriends;
00083     bool icase;
00084     bool normal;
00085     int regType;
00086     int regNewline;
00087     int verboseLevel;
00088     int timeOut;
00089     bool test;
00090     bool showHeaders;
00091     bool delDuplicates;
00092     bool compiled;
00093     int maxLineLength;
00094     re::RegExp regExp;
00095 
00096     // Private function(s)
00097     int cmpNoCase(const string&, const string&);
00098 
00099   public:
00100     Preferences(const string&);
00101     ~Preferences();
00102 
00103     const vector<serverInfo>& getServers(void);
00104     int getMaxsize(void);
00105     int getMaxsizeFriends(void);
00106     bool getIcase(void);
00107     bool isNormal(void);
00108     int getVerboseLevel(void);
00109     void setVerboseLevel(int);
00110     const string& getLogfile(void);
00111     void setLogfile(const string&);
00112     vector<filterInfo>* getFilters(void);
00113     vector<friendInfo>* getFriends(void);
00114     int getRegType(void);
00115     int getRegNewline(void);
00116     bool getTestMode(void);
00117     bool getDelDubs(void);
00118     bool getShowHeaders(void);
00119     int getMaxLineLength(void);
00120     void showErrorDeprecated(const string&);
00121     void showErrorParameter(const string&, const string&, const string&);
00122     void showErrorParameter(const string&, const string&, int);
00123     int getTimeOut(void);
00124     void setTimeOut(int);
00125     void keyword(const string, const string, const string);
00126     void keyword(const string, const string, int);
00127     int precompileExpressions(void);
00128     void setCompiled(bool);
00129     bool getCompiled(void);
00130   };
00131   
00132   // Exceptions
00133   class MalformedPrefsFile { };
00134   class IOException { };
00135   class RegExException { };
00136 }
00137 
00138 #endif

Generated on Sat Sep 14 10:49:26 2002 for mailfilter by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002