Main Page | Compound List | File List | Compound Members | File Members

SpamParameters.h

00001 
00002 #ifndef SPAMPARAMETERS_H
00003 #define SPAMPARAMETERS_H
00004 
00005 /*
00006   This email filter was written by Ian Kaplan, Bear Products
00007   International.  It is copyrighted by Ian Kaplan, 2004,
00008   www.bearcave.com.
00009 
00010   You have permission to use this software without restriction on two
00011   conditions:
00012 
00013     1. You must preserve this copyright notice in this software and
00014        any software derived from it.
00015 
00016     2. You accept any risk entailed in using this software.  By
00017        using this software, you acknowledge that you have a
00018        sophisticated background in software engineering and 
00019        understand the way this software functions.  You further
00020        acknowledge that using this software may result in the
00021        irretrievable loss of important e-email and you alone
00022        are responsible for this loss.
00023 
00024   If either of these conditions are unacceptable, you may not use any
00025   part of this software.
00026 
00027  */
00028 
00029 #include <stdlib.h>
00030 
00031 #include <vector>
00032 
00033 #include "SpamException.h"
00034  
00125 class SpamParameters
00126 {
00127  public:
00128   typedef enum { to_list = 0, 
00129                  from_address,
00130                  from_kill,
00131                  spam_words, 
00132                  kill_words, 
00133                  flags,
00134                  my_domain,
00135                  valid_users,
00136                  SpamEnumMax } SpamEnum;
00137 
00138  private:
00139   static std::vector<const char *> section[ (size_t)SpamEnumMax ];
00140   SpamEnum currentSection;
00141 
00142   class enumTableElem {
00143   public:
00144     const char *name;
00145     const SpamEnum enumVal;
00146     enumTableElem(const char *n, const SpamEnum e) : name(n), enumVal(e) {}
00147   }; // class enumTableElem
00148 
00149   static const enumTableElem enumTable[];
00150 
00151   static bool initialized;
00152 
00153   typedef enum { BadState = 0,
00154                  sectionDef,
00155                  beginBracket,
00156                  spamPhrase } paramState;
00157 
00158   paramState currentState;
00159 
00160   bool skipLine(const char *buf);
00161   void finiteStateMachine(const char *buf) throw( SpamException );
00162   SpamEnum SpamParameters::findEnum(const char *str );
00163   void enterPhrase(const char *buf);
00164 
00165  public:
00166   SpamParameters(const char *paramFileName) throw( SpamException );
00167   SpamParameters();
00168   ~SpamParameters();
00169   std::vector<const char *> &getSection( SpamEnum sec ) throw( SpamException );
00170   bool hasFlag(const char *name);
00171   void print();
00172 };
00173 
00174 #endif

Generated on Sat Mar 27 13:07:38 2004 for Mail Filter by doxygen 1.3.3