The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
174 POP3 PROXY SERVER CLASS DEFINITION ANNOYANCE-FILTER §210<br />
210. If the status from the server is positive and the command is one which elicits a multiple-line<br />
reply, read the reply from the server until the terminating sentinel, a single period followed by the<br />
CR/LF line terminator. Any line in the reply which begins with a period is quoted by prefixing a<br />
period.<br />
We concatenate replies from the server into the reply string until the end sentinel is encountered.<br />
〈 Read multi-line reply from server if present 210 〉 ≡<br />
reply = "";<br />
if ((serverBuffer [0] ≡ ’+’) ∧ ((multiLine .find (command ) ≠ multiLine .end ( )) ∨ ((argument ≡<br />
"") ∧ (cMultiLine .find (command ) ≠ cMultiLine .end ( ))))) {<br />
int bll ;<br />
char bp[POP_BUFFER];<br />
if (popProxyTrace ) {<br />
cerr ≪ "POP3:␣Reading␣multi−line␣reply␣from␣server." ≪ endl ;<br />
}<br />
do {<br />
bll = recv (serverSocket , bp, POP_MAX_MESSAGE, 0);<br />
if (bll < 0) {<br />
perror ("POP3Proxy␣reading␣multi−line␣reply␣to␣request␣from␣server");<br />
break;<br />
}<br />
#ifdef POP3_TRACE_TRANSFER_DETAIL<br />
if (popProxyTrace ) {<br />
cerr ≪ "POP3:␣Appending␣" ≪ bll ≪ "␣bytes␣to␣multi−line␣reply." ≪ endl ;<br />
}<br />
#endif<br />
reply += string(bp, bll );<br />
} while ((reply .length ( ) < 3) ∨ ((reply ≠ ".\r\n") ∧ (reply .substr (reply .length ( ) − 5) ≠<br />
"\r\n.\r\n")));<br />
}<br />
This code is used in section 204.<br />
211. Here’s where we permit the filterFunction to get into the act. If there’s a filterFunction , we<br />
hand it everything it needs to modify the status line and reply from the server. Note that even though<br />
we go to the effort to pass the canonicalised and parsed command and argument, it’s up to the filter<br />
function to compose the rough-and-ready status string in the serverBuffer string, which must be zero<br />
terminated.<br />
〈 Fiddle with the reply from the server as required 211 〉 ≡<br />
if (popProxyTrace ) {<br />
cerr ≪ "POP3:␣Calling␣filter␣function." ≪ endl ;<br />
}<br />
if (filterFunction ≠ Λ) {<br />
serverBuffer [serverLength ] = 0;<br />
filterFunction (command , argument , serverBuffer , &serverLength , reply );<br />
}<br />
if (popProxyTrace ) {<br />
cerr ≪ "POP3:␣Returned␣from␣filter␣function." ≪ endl ;<br />
}<br />
This code is used in section 204.