CSCI 1730 Programming Project 1B Summer 2009 File Coder This program is due by midnight on Sunday, June 14. The goal of this project is to build on Project 1A, correcting and improving padder.c as needed and introducing you to random number generation in C. You will implement a program that reads in the content of one file and outputs the content in a coded form to another file. Write a C program that creates a copy of a binary file with its contents bitwise XORed with a sequence of pseudo-random bytes generated from successive calls to the library function rand( ), as described below. Use buffering as in Project 1A to make your program more efficient than it would be just reading and writing one byte at a time. Your program should take two or three command line parameters, where the first two are the names of files. The first parameter is the name of the input file and the second parameter is the name of the output file. The optional third parameter is a number for setting the seed for the random number generator. So an example command line is: {odin} coder plainFile codedFile seed_val Here coder is the name of your executable file and plainFile is the name of the input file. The coded version of the input file is to be written to codedFile. On odin see ~rwr/Random/randdemo.c for an example of how to set the seed and call the random number generator. In a single execution of coder the seed should be set once and only once. The function rand( ) should be called once for every four bytes (or, at the end, once for the remaining bytes if 1, 2, or 3 are left) in the input file. You'll need to convert each value returned by rand( ) into an array of four bytes (unsigned char values) in order to extract the bytes to XOR (in order) with the next four bytes of plainFile. In C/C++ the bitwise XOR is performed by the ^ operator. If the seed is supplied by the third command line parameter, use it to set the seed before processing the input file. Setting the seed is illustrated in the sample C program randdemo.c noted above. If there are only two command line parameters, set the seed using time( 0 ) as randdemo.c does in one place. When your program finishes writing the output file, it should write to stdout as follows: plainFile sucessfully written to codedFile using seed seed_val where plainFile and codedFile echo the names of the input and output files, and seed_val either echos the seed value supplied on the command line or else reports the value produced by the call to time( 0 ) and used to set the seed. Your project submission should include an implementation file coder.c, a Makefile and a READ_ME file. Your Makefile should compile coder.c to the executable file coder using gcc. Some things to note: *The names of the files must be followed exactly, so that the teaching assistant and the instructor can test your project without editing your code. *All file I/O must be done using the routines described in Chapter 3 of the text. *Test your coder program on text files, executable files, or any other sort of file you can find. One interesting test is to apply coder to the output file codedFile using the same seed as was used to produce codedFile, then compare the new output with the original input file plainFile. You can compare text files using diff, and arbitrary binary files with cmp. *The program should be robust and include appropriate error checks. For instance, if codedFile already exists then an error message should be issued; the existing file named codedFile should not be removed or altered. *The submission procedure and requirements common to all projects are described on a separate page which is linked from the course "projects" sub-page. Follow the submission procedure carefully. *A project which does not compile on odin using gcc for GCC 4.1.2 will score 0. Projects which do compile properly will be scored out of 100 (if on time) based on (1) correctness of operation, (2) quality of design, (3) coding style and documentation of the source code, and (4) correctness and usefulness of the READ_ME file and the Makefile.