Project 3 -- fork(), exec(), and wait()

Due Thursday, December 1, 9:00 pm

(Note that due date is later than originally listed in the class schedule.)

NOTE: This assignment, like the other projects in this class, is due at a particular time, listed above. This means that if you are even a minute late, you lose 20%. If you are worried about potentially being late, turn in your project ahead of time. Do this by submitting it electronically before the due date (the electronic copy is what is due by the time given above) then giving the hard copy to me or the TA during office hours or by sliding it under my office door (the hard copy is due within twenty-four hours after the electronic copy is due). Do not send assignments to my personal email address or to the personal email address of the TA. Do not leave hard copies in my departmental mail box or attempt to give them to departmental staff (who cannot and will not accept them).

As discussed in class, the software you created for Project 2 was built on a "pull" model of information transmission where the user would request the information and it would be given to him or her at that time. However, as further discussed in class, another model may be equally useful for grade distribution - the "push" model where new information is sent out to users when it is available. For grades, this software could be run by the instructor or teaching assistant when the grade file is updated by one of them.

There are, of course, many ways in which the push model could be implemented but one of the most straightforward is to use email. Indeed, for this assignment you will write a program that emails grades to the class members who "opt in" to this system. By "opt in" we mean that users need to choose to be a part of this system. For this project, you may opt in by sending your email address of choice to cs3113@cs.ou.edu. To opt in by email, you need to send this email from a verifiable account such as your class account on the CS network (the Linux boxes in EL 158) or your OU email account. Alternately, you may opt in by bringing your email account information to office hours. (Of course, you may choose not to opt in, in which case you will not receive emails when the grade file is updated.)

Please note, when you opt in you are giving permission for your scores and ultimately your grade for this class to be emailed to the email address you provide. You should be aware of the possibility of a loss of privacy when these emails travel through unsecured networks or machines.

Of course, while email is ubiquitous in the modern world, writing a program to send email may not be straightforward. Instead, it may be easier to write a program that simply uses existing email software to actually send the emails. You will take this latter approach in this project, making use of the system calls fork(), exec(), and wait() (or waitpid()).

The Assignment

You are to create a program called gradesend. When run, gradesend will open a comma-separated value (csv) version of the grade file and parse it similarly to the way it was parsed in Project 2. In particular, gradesend should create, for each email to be sent, a message consisting of a copy the header lines (which are the first four lines of the file), the line showing the email recipient's own scores, and the six trailer lines showing the aggregate score information (maximum, minimum, median, mode, mean and standard deviation). Note, however, that gradesend should not include in this message the lines showing the scores of other users nor the final lines of the file showing the numbers of letter grades.

After a message is created, gradesend should send it to the email address specified in the csv file for the given student. Note that, if there is no email address specified for a given student, gradesend should neither create nor send a message for that student. Also note that the order of creating and sending messages is up to you. You could have gradesend create one message, send it, create a second message, send it, and so on (alternating between creating and sending messages) or gradesend could create all messages first, then send all of them or some other ordering of message creation and transmission. As long as all messages are created and sent, you have met this requirement of this project.

Also note that how gradesend provides the message to the email program is up to you. Perhaps the simplest method, given what you have learned in the class so far, would be to have gradesend write each message to a file then tell the email program to send this file as an attachment. (For an idea of how to do this, take a look at the instructions on how to send electronic copies of your projects.) If you have gradesend write each message to a file, be sure to have gradesend delete any such file before it exits.

Further note that the email program you have gradesend use to actually send the email is also up to you. Any email program found on the CSN machines is acceptable.

For all of these options, you must be sure to explain your choices in your writeup. This means that you need to not only specify what choices you made but explain on what basis you made them.

The general form of the call to gradesend will be:

    gradesend <classgradefile> <outfile>
where <classgradefile> is the name of the existing grade file containing entries for the whole class and <outfile> is the name of the file to which user output is sent.

If only one argument is given, it is assumed to be <classgradefile> and user output is sent to standard out.

If no argument is given, gradesend will send user output to standard out and will look for the most recent file with a name of the form gradefile_<arbitrary>.csv in the current working directory, where <arbitrary> may be any string of up to 20 characters in length. Please note that this default behavior when no <classgradefile> is specified is different than the default behavior for gradelook.

For user output, gradesend will provide a simple message to the user for each student in the gradefile, as follows:

An example grade file in OpenOffice.org 1.0 spreadsheet format and csv format is available, to give you an idea of how the actual grade file should look. To use it, you should add a line for yourself. Feel free to make up scores for yourself for this file.



Notes on this assignment

You should not expect the csv files (either the original or the reduced version with just your scores) to be very understandable with a text editor or pager. Instead, you should be able to import it back into OpenOffice and view it that way.



What to turn in.

You will turn in both a hard copy and an electronic copy of your assignment. Please follow the instructions on how to send electronic copies. Do not send them to my email address.

Both the hard copy and the electronic copy will contain a write-up plus the source code for gradesend. The electronic copy will also contain the executable of gradesend. The electronic copy of your write-up should not be in a proprietary format (such as MS Word); it should be either in plain ASCII text or in a portable format (such as Postscript or PDF). Your source code for gradesend should be in a single file called gradesend.c or gradesend.cxx and your executable code should be called gradesend.

Your source code should be well structured and well commented. It should conform to good coding standards (e.g., no memory leaks).

Your write-up will include 1/2 to 1 page (roughly 80 characters per line, 50 lines per page) explaining the data structures and algorithms used in your code. This page limitation does not include figures used in your explanations, which are encouraged and may take up any amount of space. (The explanations do not remove the requirement that your code be well commented.)



Other

You may write your program from scratch or may start from programs for which the source code is freely available on the web or through other sources (such as friends or student organizations). If you do not start from scratch, you must give a complete and accurate accounting of where all of your code came from and indicate which parts are original or changed, and which you got from which other source. Failure to give credit where credit is due is academic fraud and will be dealt with accordingly.

As noted in the syllabus, you are required to work on this programming assignment in a group of at least two people. It is your responsibility to find other group members and work with them. The group should turn in only one (1) hard copy and one (1) electronic copy of the assignment. Both the electronic and hard copies should contain the names and student ID numbers of all group members. If your group composition changes during the course of working on this assignment (for example, a group of five splits into a group of two and a separate group of three), this must be clearly indicated in your write-up, including the names and student ID numbers of everyone involved and details of when the change occurred and who accomplished what before and after the change.

Each group member is required to contribute equally to each project, as far as is possible. You must thoroughly document which group members were involved in each part of the project. For example, if you have three functions in your program and one function was written by group member one, the second was written by group member two, and the third was written jointly and equally by group members three and four, both your write-up and the comments in your code must clearly indicate this division of labor.