last updated: Sun Apr 10 19:20:33 EDT 2005 (sklar)
assignment description.
This homework assignment is the third part of your four-part homework project. This hw3 will be written in C and will implement users entering reviews for movies and looking at reviews that other users enter. You'll also create a makefile.
NOTE that beginning with this assignment, we will MERGE everyone's movies.dat file. So keep that in mind when you are submitting -- whatever test entries are in your data file may be seen by the whole class...
This assignment is worth 10 points. Distribution of points is indicated below.
IMPORTANT NOTES:
HERE ARE THE STEPS FOR HW3:
Download the timesheet and fill in predictions of how long it will take you to do each task associated with this assignment. Then, as you are working on the assignment, keep track of how long it actually takes you.
You will not lose points for the values you put on this timesheet. It is for your benefit -- so you can see how long you think it will take you to do things, and how long it really takes you. You will not be marked on the content of the timesheet -- only that you have completed and submitted it.
In hw2, you created: user.h, login.c and register.c. Because both login.c and register.c use the data structure defined in user.h, it is likely that there are functions that both C programs may use. Instead of repeating code in both login.c and register.c, it is better from a programming standpoint to create a third file, say user.c, that contains any functions which operate on the data structure you've defined in user.h. Then you can link user.c with register.c to create register.cgi, and you can link user.c with login.c to create login.cgi. The header file, user.h, should contain only the data structure definition (i.e., typedef struct...). It should NOT contain any actual function definitions or variable declarations!! It should also contain the function prototypes of all the functions which are in user.c. Thus user.h should be included in all three C files.
For this step, create user.c and modify login.c, register.c and user.h to conform to the rules stated above.
ALSO make sure that register.c makes a check that the new user is unique before appending the username to the data file. This was implied in hw2, but not everyone did it. Make sure you do it here (otherwise you'll lose 0.5 points on this section)!
Create a makefile that has several targets:
The review.cgi target is something you'll write in the steps below.
The all target should build all the C and C++ cgi programs.
The clean target should remove any object files (*.o).
WARNING!!
Don't clean the *.cgi files!!!
Otherwise you'll lose your cgi programs that are written in PERL!!!
In this assignment, you'll be adding two more functions to the web site:
Modify your PERL list.cgi, adding two buttons or links (you decide how you want to do this), one for each of the two new functionalities. That is, for each movie, there should be a button or link that says something like "see reviews for this movie" and a button or link that says "enter a review for this movie".
These buttons or links will each invoke review.cgi, which is described below. You'll find that you will need to pass some information from your list.cgi program into review.cgi (such as the user's name and the ID of the movie associated with the button or link that the user clicked on). You can do this using either GET or POST methods or in the URL -- that design decision is up to you.
NOTE that the "enter review" button or link should only appear when a user is logged into the site!
Here, you need to write a C program called review.c (to be compiled into review.cgi) which will be the action method activated when the new buttons or links are clicked on the list.cgi indicating that the user wants to enter a review or see the reviews for a particular movie.
Reviews must be stored as follows:
BEGIN REVIEW USER=jennifer REVIEW=i love this movie! END REVIEW BEGIN REVIEW USER=alex REVIEW=i hate this movie! END REVIEW |
The review program can be invoked in one of three "modes":
NOTE that you should handle the funky CGI characters elegantly here (as described at the top of this page). You'll deal with this aspect in lab7 (on april 6), but make sure you also include the functionality here.
NOTE that my instructions are less explicit than in the past, in terms of what exact functions to write. You're ready to make some of these design decisions on your own :-)
ALSO NOTE that I expect very clean, commented code. It should be nicely indented in a consistent way. Functions, variables and data structures should have meaningful, descriptive names. Ugly, unreadable, undecipherable code will cost you 1 point of this portion of the assignment. In other words, even if your code is working perfectly, you'll lose 1 point out of the 6 for this step if our code is utterly undecipherable. OUCH!!
Just like with the labs, you need to submit your homework electronically. Make sure that you have followed the file naming specifications listed above (case included!) Failure to follow do so will result in 10% off the assignment grade -- ouch!
You need to submit: timesheet.txt, README, user.h, user.c, register.c, login.c, review.c, makefile, users.dat, register.html, login.html, index.c, index.html, about.html, list.cgi, your movies.dat, any review files you've created for the movies in your movies.dat, any image files that your movies.dat file references locally, and any other files we'll need to run your assignment.
bash# ssh cluster.cs.columbia.edu
bash# ~cs3157/bin/submit-hw 3