SE 598, Data Structures and Algorithms

STL Vector Programming Assignment, due 5:00 p.m. Wednesday, 21 June


Introduction

We'll start off with a simple one: write a program that reads a file of e-mail messages and then prompts the user for a message number. After each message number is input, the program prints the contents of the associated e-mail message and prompts for another message number, quitting when the user enters the character 'q' or indicates end-of-file. The name of the file to read is given on the command line.

Here's an example session:

cl readmbox mbox
6 messages read.
message number:  1

Would you like to make money fast?

message number: 7

message number 7 is out of range.
Numbers 1 through 6 are valid message numbers.

message number: q
cl
Your program should be called readmbox and should accept a single command line argument giving the name of the mailbox to read.

Format Descriptions

This project requires that you know about the formats of two entities: messages and mailboxes.

Message Format

The message format used in this project is a simple form of the RFC 822 standard used for Internet mail transport.

First, some definitions:

character
any of the ASCII characters from NUL (0 decimal) to DEL (127 decimal) inclusive.

linear white space character
either of the characters space (' ', ASCII character SP, 32 decimal) or tab ('\t', ASCII character HT, 9 decimal).

linear white space
a non-empty sequence of linear white space characters.

newline
the character or characters that correspond to the newline character '\n' in C++.

alphanumeric character
an upper or lower case letter ('A' through 'Z' and 'a' through 'z'), a decimal digit ('0' through '9', or one of the characters hyphen '-' or underscore '_'.

word
a non-empty sequence of alphanumeric characters starting with an upper- or lower-case letter.

text-line
a possibly empty sequence of characters, none of which are the newline character, followed by a newline.

empty text-line
an empty sequence of characters followed by a newline. Note that a text-line containing linear white space is not an empty text-line because it contains a non-empty sequence of characters.
A message consists of a header followed by the contents. The header is separated from the contents by an empty text-line. The empty text-line separating a message's header and contents is not part of either the header or the contents.

RFC 822 doesn't define the format of a messages contents, and this project won't either, except to assume that the contents is a possibly empty sequence of text-lines.

A message header is a non-empty sequence of fields. Each field is a text-string of the form

word:text-line
The word before the colon is called the label.

Mailbox Format

A mailbox is a possibly empty sequence of messages. Each message is preceded by a text-line of the form
From text-line
Note the linear white space between "From" and the text-line. Messages are separated from one another by at least one empty text-line.

Here is an example mailbox you may use to test your program.


This page last modified on 4 July 2000.