Question
Description c++, using a linux features Upgrade the code that is provided and implemented the following features that will be added to this program include:
Description c++, using a linux features
Upgrade the code that is provided and implemented the following 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.
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.
The following functions will be of use to you (read and write are mandatory).
read(2)
write(2)
getopt(3)
******************************************************************************************
Modifie this code
#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 { //using linux system call open file with readonly flag file_descriptor = open (argv [i], O_RDONLY); //if file not opened if (file_descriptor == -1) { perror ("open"); printf("file can not be opened : %s ",argv[i]); } else { while((read_bytes = read (file_descriptor, &read_buffer, read_buffer_size)) > 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started