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.

140 MAIL FOLDER ANNOYANCE-FILTER §168<br />

168. Write the message transcript saved in tlist to the designated file name fname . If fname is “−”,<br />

the transcript is written to standard output. Depending upon their provenance, transcripts may or may<br />

not contain the POP3 line end terminator CR at the end of lines. We append the line feed, which<br />

automatically provides the correct line termination for UNIX mail folders and the CR/LF required for<br />

POP3 messages.<br />

〈 Class implementations 11 〉 +≡<br />

void mailFolder ::writeMessageTranscript (ostream &os ) const<br />

{<br />

assert(tlist ≠ Λ);<br />

}<br />

unsigned int n = tlist ⃗ size ( );<br />

if ((n > 1) ∧ (tlist ⃗ back ( ).substr (0, (sizeof messageSentinel ) − 1) ≡ messageSentinel )) {<br />

n−−;<br />

}<br />

list〈string〉::iterator p = tlist ⃗ begin ( );<br />

for (unsigned int i = 0; i < n; i++) {<br />

os ≪ ∗p++ ≪ endl ;<br />

;<br />

}<br />

void mailFolder ::writeMessageTranscript (const string fname ) const<br />

{<br />

if (fname ≠ "−") {<br />

ofstream of (fname .c str ( ));<br />

writeMessageTranscript (of );<br />

of .close ( );<br />

}<br />

else {<br />

writeMessageTranscript (cout );<br />

}<br />

}

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

Saved successfully!

Ooh no, something went wrong!