#include using namespace std; #include "strsep.h" #include "mask.h" CMask::CMask() { } CMask::~CMask() { } CMask::CMask(const CMask& msk) { s_Sender = msk.s_Sender; s_Recipient = msk.s_Recipient; F_From = msk.F_From; F_To = msk.F_To; s_Subject = msk.s_Subject; d_Flags = msk.d_Flags; } CMask::CMask(string sndr, string recpt, CFtnAddr frm, CFtnAddr to, string subj, dword flgs) { s_Sender = sndr; s_Recipient = recpt; F_From = frm; F_To = to; s_Subject = subj; d_Flags = flgs; } CMask& CMask::operator=(const CMask& msk) { if ((this)==(&msk)) return (*this); s_Sender = msk.s_Sender; s_Recipient = msk.s_Recipient; s_Subject=msk.s_Subject; F_From=msk.F_From; F_To=msk.F_To; d_Flags=msk.d_Flags; return (*this); } CMask& CMask::operator=(const string& str) { char *buf; buf = new char[128]; buf=const_cast(str.c_str()); s_Sender=strseparate(&buf, ","); F_From=strseparate(&buf, ","); s_Recipient=strseparate(&buf, ","); F_To=strseparate(&buf, ","); s_Subject=strseparate(&buf, ","); strseparate(&buf,","); delete [] buf; return (*this); } bool CMask::operator==(const CMask& msk) { bool sndMatch=false; bool rcpMatch=false; bool frmMatch=false; bool toMatch=false; bool subjMatch=false; bool attrMatch=true; /* try to determine matches simply */ if (msk.s_Sender == s_Sender) sndMatch=true; if (s_Sender=="*") sndMatch=true; if (msk.s_Recipient == s_Recipient) rcpMatch=true; if (s_Recipient=="*") rcpMatch=true; if (F_From == msk.F_From) frmMatch=true; if (F_To == msk.F_To) toMatch=true; if (msk.s_Subject == s_Subject) subjMatch=true; if (s_Subject=="*") subjMatch=true; /* do dirty checking with ~ */ if (strchr(s_Sender.c_str(), '~')!=NULL) { if (strstr(msk.s_Sender.c_str(), strchr(s_Sender.c_str(),'~')+1)!=NULL) sndMatch=true; } if (strchr(s_Recipient.c_str(), '~')!=NULL) { if (strstr(msk.s_Recipient.c_str(), strchr(s_Recipient.c_str(),'~')+1)!=NULL) rcpMatch=true; } if (strchr(s_Subject.c_str(), '~')!=NULL) { if (strstr(msk.s_Subject.c_str(), strchr(s_Subject.c_str(),'~')+1)!=NULL) subjMatch=true; } if (sndMatch && rcpMatch && frmMatch && toMatch && subjMatch && attrMatch) return true; else return false; } int CMask::parseAttr(string s_Flags) { bool mand=false; for (unsigned int i=0;i