Question: Modifi the following program, using c++ with a linux base system. Using the requirements stated. This program is meant to give students practice working on

Modifi the following program, using c++ with a linux base system. Using the requirements stated.

This program is meant to give students practice working on projects that contain multiple files of source code. It will require to construct a Makefile and appropriate header files. It will also include the use of getopt to handle optional command line parameters. Manipulating data read in from a file will also be introduced.

The following functions will be of use to you (read and write are mandatory).

read(2)

write(2)

getopt(3)

Description

In this assignment, you will be creating an upgrade to the cat command you implemented in assignment 2. Lets call it dog because canines are so obviously better than felines. The features that will be added to this program include:

The ability to specify a command line parameter (-b x ) to change the size of the buffer used with read and write to x.

The ability to specify a command line parameter (-n x ) to change the number of bytes read from each file to ex. (Instead of reading the entire file.)

The ability to specify a command line parameter (-c x ) to change the shift to x when applying a simple Caesar cipher to text within the file (described below).

The ability to specify a command line parameter (-r x ) to specify the shift to x when applying a similar rotation to binary data within the file.

The ability to specify a command line parameter (-x ) to output the data in the file as hexadecimal numbers.

Requirements

The main loop should be in your main function in one source code file. The functions that perform the encryption should be found in another file. Their declarations will need to be in a header file so that they can be called from main even though their implementations are in another file.

You must make a Makefile that has rules sufficient to compile your program when a user types make in the same directory as your source code. Only files that have changed or have had their dependencies change should be recompiled.

You must use the system calls read and write to do the input and output for the program.

Obviously, your source code must be well documented. If it is not, there will be a large pointpenalty. This requirement holds for all assignments, whether this line is in the writeup or not.

The features enabled by the command line parameters listed in the description section abovemust be implemented.

Note: If both -r and -c are specified, the behavior can change depending on which is executed first. Dont allow a user to specify both: give them an error message if they try. The other command line parameters can all be on at the same time without any problem. Make sure that they work together.

#include #include #include #include #include #include #include #define read_buffer_size 8192

int main(int argc, char* argv[]) {

//file descriptor for opening and closing

int file_descriptor; //size of buffer for file reading char read_buffer[read_buffer_size]; ssize_t read_bytes;

//looping through all files given in argument int i; for(i=1;i 0) { printf("%s",read_buffer); } //once done with file closig the file using file descriptor

close (file_descriptor); } }

return (EXIT_SUCCESS); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!