#include <HeaderInfo.h>
Public Member Functions | |
| HeaderInfo (const bool doTrace) | |
| ~HeaderInfo () | |
| const char * | subject () |
| void | subject (const char *pBuf) |
| const char * | to () |
| void | to (const char *pBuf) |
| const char * | from () |
| void | from (const char *pBuf) |
| const char * | fromNoColon () |
| void | fromNoColon (const char *pBuf) |
| const char * | reason () |
| void | reason (const char *pBuf) |
| const char * | date () |
| void | date (const char *pBuf) |
| const MailFilter::classification | klass () |
| void | klass (MailFilter::classification k) |
Private Member Functions | |
| HeaderInfo (const HeaderInfo &rhs) | |
| FILE * | openTraceFile () |
| void | init () |
Private Attributes | |
| const bool | mDoTrace |
| char | mSubject [128] |
| char | mTo [128] |
| char | mFrom [128] |
| char | mFromNoColon [128] |
| char | mDate [128] |
| char | mReason [128] |
| MailFilter::classification | mKlass |
Definition at line 50 of file HeaderInfo.h.
|
|
If an email was marked as garbage and discarded, write out a garbage_trace entry if the class variable mDoTrace is set. Definition at line 121 of file HeaderInfo.C. References mDoTrace, and openTraceFile().
00122 {
00123 if (mDoTrace && klass() == MailFilter::GARBAGE) {
00124 FILE *fp = openTraceFile();
00125 if (fp != 0) {
00126 fprintf(fp, "\n");
00127 fprintf(fp, "From %s\n", SpamUtil().trimEnd(mFromNoColon));
00128 fprintf(fp, "From: %s\n", SpamUtil().trimEnd(mFrom));
00129 fprintf(fp, "To: %s\n", SpamUtil().trimEnd(mTo));
00130 fprintf(fp, "Subject: %s\n", SpamUtil().trimEnd(mSubject));
00131 fprintf(fp, "Date: %s\n", SpamUtil().trimEnd(mDate));
00132 fprintf(fp, "Reason-its-garbage: %s\n", SpamUtil().trimEnd(mReason));
00133 fclose(fp);
00134 }
00135 }
00136 }
|
|
|
Open the garbage_trace file. If the file is larger than MAX_FILE_SIZE it will be truncated. Definition at line 78 of file HeaderInfo.C. References Logger::getLogger(), and Logger::log(). Referenced by ~HeaderInfo().
00079 {
00080 const char *traceFileName = "garbage_trace";
00081 const size_t MAX_FILE_SIZE = 50 * 1024; // file size in K bytes
00082 Logger log = pLogger->getLogger("HeaderInfo");
00083 char msgbuf[128];
00084 FILE *fp = 0;
00085 char *mode = "a"; // open for append
00086 if ((fp = fopen(traceFileName, mode)) != 0) {
00087 int fileSize = SpamUtil().getFileSize( fp, traceFileName, msgbuf );
00088 if (fileSize >= 0) {
00089 if (fileSize > MAX_FILE_SIZE) {
00090 mode = "w"; // open for truncate
00091 fclose(fp);
00092 // open and truncate the file
00093 if ((fp = fopen(traceFileName, mode)) == 0) {
00094 char *err_reason = strerror( errno);
00095 sprintf( msgbuf, "could not re-open %s. Reason: %s",
00096 traceFileName, err_reason );
00097 log.log(Logger::ERROR, "openTraceFile", msgbuf);
00098 }
00099 }
00100 }
00101 else { // error getting stat on file
00102 log.log(Logger::ERROR, "openTraceFile", msgbuf);
00103 }
00104 }
00105 else { // error opening file
00106 char *err_reason = strerror( errno);
00107 sprintf( msgbuf, "could not open %s. Reason: %s",
00108 traceFileName, err_reason );
00109 log.log(Logger::ERROR, "openTraceFile", msgbuf);
00110 }
00111
00112 return fp;
00113 } // openTraceFile
|
|
|
Copy the subject into a local buffer and set the a flag which indicates that the subject has been found. Definition at line 59 of file HeaderInfo.C.
00060 {
00061 if (pBuf != 0) {
00062 strncpy(mSubject, pBuf, sizeof(mSubject) );
00063 if (mSubject[0] == '\0') {
00064 mSubject[0] = ' ';
00065 mSubject[1] = '\0';
00066 }
00067 else {
00068 SpamUtil().trimEnd(mSubject);
00069 }
00070 }
00071 } // subject
|
|
|
mDoTrade: true = generate a garbage trace message Definition at line 54 of file HeaderInfo.h. Referenced by ~HeaderInfo(). |
1.3.3