00001
00002 #ifndef MAIL_FILTER_H
00003 #define MAIL_FILTER_H
00004
00041 #include <vector>
00042 #include <stdio.h>
00043
00044 #include "Logger.h"
00045 #include "SpamParameters.h"
00046
00047 class HeaderInfo;
00048
00060 class MailFilter
00061 {
00062 public:
00063
00064 typedef enum { BAD_VALUE, UNKNOWN, EMAIL, SUSPECT, GARBAGE } classification;
00065
00066 private:
00068 size_t mFileCount;
00070 Logger log;
00072 std::vector<char *> fileNames;
00073
00074 bool isFromLine(const char *buf);
00075 bool copyToTempFiles();
00076 const char *getNewTempFileName();
00077 FILE *openFile( const char *fileName,
00078 const char *mode,
00079 const char *callingFunc );
00080 void closeFile(FILE *fp,
00081 const char *fileName,
00082 const char *callingFunc);
00083 bool writeLine(const char *buf,
00084 FILE *fp,
00085 const char *fileName,
00086 const char *callingFunc );
00087 const char *readLine(char *buf,
00088 const size_t bufSize,
00089 FILE *fp,
00090 const char *fileName,
00091 const char *callingFunc );
00092 void append_file( const char *srcfile,
00093 const char *destfile );
00094 void error_append_file( const char *srcfile,
00095 const char *destfile);
00096 classification checkMail(const char *tempFileName,
00097 SpamParameters ¶ms,
00098 HeaderInfo &headInfo );
00099
00100 public:
00101 MailFilter(SpamParameters ¶m);
00102 ~MailFilter();
00103 };
00104
00105 #endif