Concurrency - 40%
tee -> eet
tee is a program that duplicates stdin to stdout AND duplicates stdin to multiple files (append only, no overwrite)
stdin --------------------> stdout
| |
| |
V V
FileA FileB
You are to write the eet program. It multiplexes parts of several files in sequence into a single
output (stdout).
eet -d ... [FILE]...
Running the eet program will output a token from each file in alternating order. The token is a
sequence of characters delimited by a special character. Each token is printed followed by a new line character. The file is processed until no further tokens exist. If a file has no further tokens, it outputs <filename> no more tokens After a round of multiplexing from each file, a new line is printed.
The eet program must have the flag -d as the first command line argument. The second command line argument are the parameters of -d that are a set of single delimiter characters to define a token.
The remaining parameters are files to provide as input. If the 1st, 2nd, or 3rd command line
arguments are missing files then the program will terminate with exit code 1.
Example
As an example, consider the input of four files
FileA ----->|
|
FileB ----->|
|-------------> stdout
FileC ----->|
|
FileD ----->|
./eet -d ",.;" FileA FileB FileC FileD
output characters of FileA up to delimiter output characters of FileB up to delimiter output characters of FileC up to delimiter output characters of FileD up to delimiter