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.

176 POP3 PROXY SERVER CLASS DEFINITION ANNOYANCE-FILTER §213<br />

213. If the server’s reponse included a multi-line reply, relay it to the client. We write it with a single<br />

send unless POP3_MAX_CLIENT_WRITE is defined, in which case we write the reply in chunks of that size;<br />

if you wish to be ultra-conservative, you might define it to be POP_MAX_MESSAGE.<br />

〈 Relay multi-line reply, if any, to the client 213 〉 ≡<br />

if (reply ≠ "") {<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Relaying␣" ≪ reply .length ( ) ≪ "␣byte␣multi−line␣reply␣to␣client." ≪<br />

endl ;<br />

}<br />

#ifdef POP3_MAX_CLIENT_WRITE<br />

clientLength = 0;<br />

int rpl = reply .length ( );<br />

while (clientLength < ((int) reply .length ( ))) {<br />

int bcl , pcl ;<br />

bcl = min (rpl , POP3_MAX_CLIENT_WRITE);<br />

#ifdef POP3_TRACE_TRANSFER_DETAIL<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Writing␣" ≪ bcl ≪ "␣bytes␣of␣multi−line␣reply␣to␣client." ≪ endl ;<br />

}<br />

#endif<br />

pcl = send (clientSocket , reply .data ( ) + clientLength , bcl , 0);<br />

if (pcl ≠ bcl ) {<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Error␣writing␣" ≪ bcl ≪ "␣bytes:␣wrote␣" ≪ pcl ≪ "␣bytes." ≪<br />

endl ;<br />

}<br />

break; /∗ Note that test below will error transfer ∗/<br />

}<br />

clientLength += pcl ;<br />

rpl −= pcl ;<br />

}<br />

#else<br />

clientLength = send (clientSocket , reply .data ( ), reply .length ( ), 0);<br />

#endif<br />

if (clientLength ≠ static cast〈int〉(reply .length ( ))) {<br />

perror ("POP3Proxy␣relaying␣multi−line␣reply␣to␣request␣to␣client");<br />

break;<br />

}<br />

#ifdef POP3_TRACE_TRANSFER_DETAIL<br />

if (popProxyTrace ) {<br />

}<br />

#endif<br />

}<br />

cerr<br />

≪ "POP3:␣" ≪ endl ;<br />

cerr ≪ reply ;<br />

cerr ≪ "POP3:␣" ≪ endl ;<br />

This code is cited in section 256.<br />

This code is used in section 204.

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

Saved successfully!

Ooh no, something went wrong!