12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

§164 ANNOYANCE-FILTER MAIL FOLDER 137<br />

164. To facilitate parsing of header fields, this static method performs a case-insensitive test for<br />

header field target and, if it is found, stores its argument into arg , set to canonical lower case.<br />

〈 Class implementations 11 〉 +≡<br />

bool mailFolder ::compareHeaderField (string &s, const string target , string &arg )<br />

{<br />

if (s.length ( ) > target .length ( )) {<br />

string sc = s;<br />

stringCanonicalise (sc);<br />

if ((sc.substr (0, target .length ( )) ≡ target ) ∧ (sc[target .length ( )] ≡ ’:’)) {<br />

unsigned int i;<br />

for (i = target .length ( ) + 1; i < sc.length ( ); i++) {<br />

if (¬isISOspace (sc[i])) {<br />

break;<br />

}<br />

}<br />

if (i < sc.length ( )) {<br />

int n = 0;<br />

while ((i + n) < sc.length ( )) {<br />

if (isISOspace (sc[i + n]) ∨ (sc[i + n] ≡ ’;’)) {<br />

break;<br />

}<br />

n++;<br />

}<br />

arg = sc.substr (i, n);<br />

}<br />

else {<br />

arg = "";<br />

}<br />

return true ;<br />

}<br />

}<br />

return false ;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!