From 2400eaeb734f5a80812fdb936626fa9fdcbda115 Mon Sep 17 00:00:00 2001 From: John Denker Date: Tue, 17 Jul 2012 15:17:17 -0700 Subject: implement regular expressions --- tools/mail-scan.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/mail-scan.c b/tools/mail-scan.c index 79b8d58..0cda6e5 100644 --- a/tools/mail-scan.c +++ b/tools/mail-scan.c @@ -15,9 +15,8 @@ ///////////// // Another hint: using the "-addr" feature: -// grep score=[234] /home/user/Maildir/spam/* -l | \... -// xargs mail-scan +from -addr | sort | uniq -c | sort -nr | head | blacklist-update -bare - +// mail-scan +x-spam.*:score=[234] /home/jean/Maildir/spam/* -l | \.... +// xargs mail-scan +from -addr | sort | uniq -c | sort -nr | head -20 #include #include /* for exit() */ @@ -294,15 +293,14 @@ int main(int _argc, const char** _argv){ headword = header.substr(0, where); rest = ltrim(header.substr(1+where)); } -// temporary? FIXME? lowercase - headword = toLower(headword); - rest = toLower(rest); + for (list::const_iterator ptr = watchword.begin(); ptr != watchword.end(); ptr++) { - if (headword == toLower(ptr->key)) { +// regex_match not regex_search ... keyrx must match *whole* headword + if (boost::regex_match(headword, ptr->keyrx)){ // here if match as to keyword; check for match as to value if (ptr->val.length()==0 - || rest.find(toLower(ptr->val)) != string::npos) { + || boost::regex_search(rest, ptr->valrx)){ foundsome_infile++; if (!vflag) { if (!addr_mode){ -- cgit v1.2.3