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.

172 POP3 PROXY SERVER CLASS DEFINITION ANNOYANCE-FILTER §208<br />

208. In order to determine whether the server will respond with a multi-line reply in addition to a<br />

status line, we must examine the command and its arguments. <strong>The</strong> command, which is case-insensitive,<br />

is forced to lower case to facilitate comparisons. Note that since we’ve already forwarded the request to<br />

the server, it’s OK to diddle clientBuffer here.<br />

〈 Parse request and argument into canonical form 208 〉 ≡<br />

while ((clientLength > 0) ∧ isspace (clientBuffer [clientLength − 1])) {<br />

clientLength −−;<br />

}<br />

command = argument = "";<br />

int i;<br />

for (i = 0; i < clientLength ; i++) {<br />

if (isspace (clientBuffer [i])) {<br />

break;<br />

}<br />

char ch = clientBuffer [i];<br />

if (isalpha (ch ) ∧ isupper (ch )) {<br />

ch = tolower (ch );<br />

}<br />

command += ch ;<br />

}<br />

while ((i < clientLength ) ∧ isspace (clientBuffer [i])) {<br />

i++;<br />

}<br />

if (i < clientLength ) {<br />

argument = string(clientBuffer + i, clientLength − i);<br />

}<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Client␣command␣(" ≪ command ≪ ")␣␣Argument␣(" ≪ argument ≪ ")" ≪<br />

endl ;<br />

}<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!