12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

196 HEADER INCLUDE FILES ANNOYANCE-FILTER §243<br />

}<br />

#endif<br />

}<br />

else {<br />

cerr ≪ "Invalid␣port␣number␣specification␣in␣−−pop3server␣argument." ≪ endl ;<br />

return 1;<br />

}<br />

sarg = sarg .substr (0, pind );<br />

}<br />

popProxyServer = sarg ;<br />

if (verbose ) {<br />

cerr ≪ "POP3␣server␣will␣act␣as␣proxy␣for␣" ≪ popProxyServer ≪ ":" ≪<br />

popProxyServerPort ≪ endl ;<br />

}<br />

lastOption = true ; /∗ Bail out, ignoring any (erroneous) subsequent options ∗/<br />

break;<br />

#ifdef POP3_PROXY_SERVER<br />

case 230: /∗ −−pop3trace Trace POP3 proxy server operations on cerr ∗/<br />

popProxyTrace = true ;<br />

break;<br />

#endif<br />

case 203: /∗ −−prune Purge dictionary of infrequently used words ∗/<br />

updateProbability ( );<br />

dict .purge ( );<br />

break;<br />

case 213: /∗ −−ptrace Include token by token trace in −−pdiag output ∗/<br />

pTokenTrace = true ;<br />

break;<br />

case ’r’: /∗ −r, −−read fname Read dictionary from fname ∗/<br />

{<br />

#ifdef HAVE_MMAP<br />

int fileHandle = open (optarg , O_RDONLY);<br />

#else<br />

if (fileHandle ≡ −1) {<br />

cerr ≪ "Cannot␣open␣dictionary␣file␣" ≪ optarg ≪ endl ;<br />

return 1;<br />

}<br />

long fileLength = lseek (fileHandle , 0, 2);<br />

lseek (fileHandle , 0, 0);<br />

char ∗dp = static cast〈char ∗〉(mmap((caddr t )0, fileLength , PROT_READ,<br />

MAP_SHARED | MAP_NORESERVE, fileHandle , 0));<br />

istrstream is (dp, fileLength );<br />

ifstream is (optarg , ios ::binary );<br />

if (¬is ) {<br />

cerr ≪ "Cannot␣open␣dictionary␣file␣" ≪ optarg ≪ endl ;<br />

return 1;<br />

}<br />

#endif<br />

dict .importFromBinaryFile (is );<br />

#ifdef HAVE_MMAP

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

Saved successfully!

Ooh no, something went wrong!