The assignment is to write a miniature pseudo-web server. The goal is to serve up the proper files, but no others. The program will read lines from standard input. Each command is a sequence of several lines: GET pageref other lines [blank line] That is, it's the word "GET" (at the begining of the line), some number of blanks, and a "pageref" (see below). That line is followed by some number of lines with other content; these should be read and ignored. The command is terminated by a null line. When the command is fully read, the "pageref" must be parsed. It is either a pathname -- /foo/bar or some such -- or a pathname followed by a ? and a set of operands delimited by + signs: /foo/cgi/bar?arg1+arg2 That pageref has two operands, arg1 and arg2. The pathname part must be modified by a prefix substitution table (which you can compile in). If there was a table entry /foo /bletch the reference to /foo/bar will actually be to /bletch/bar. All paths not modified by the prefix table must be relative to some root directory, such as /home/smb/hw2/data. Prefixes only match full path components; thus, /fo /this_does_not_match would not specify a replacement for /foo/bar. The default prefix is used only for files that are not processed by the prefix match. Example: if the root is /home/smb/hw2/data and the prefix table has /foo /bletch /huh /somewhere the following mappings would take place: /any -> /home/smb/hw2/data/any /any/where -> /home/smb/hw2/data/any/where /foo/any -> /bletch/any Once a file has been expanded by a prefix, it is not further expanded. That is, that operation takes place at most once. Some directories, including at least one whose actual path name is created by prefix substitution, hold executable files. For other directories, just print the contents of the file as requested. For executable files, execute the command and print its output. "Executable" files are those that live in specified directories -- you configure the list. This assignment operates on real files; we're not using a pseudo-tree like last time. (Doing so might be fun, but it couples the two assignments -- and their grades -- too closely.) Don't go crazy about the file contents or executables. A good test file should have its name as its contents or some such, so you know that the right file was retrieved. The following shell script is perfectly fine for the executables: #!/bin/sh echo `basename $0`: $# args for i do echo "[$i]" done echo Remember that this is a security class. The object of the assignment is to write a program that will hand back the request files from the specified directories, and no others. Deliverables, in a tar file: The source code A README file describing any assumptions A directory tree that is being retrieved by this web server. It must include other test files that should not be retrievable by the program.