Abstract
Extend the simple character compression filter of p3 to
- process command line arguments
- handle command line options
- provide decompression capabilities
Details
Take the compression program written for p3, and:In addition, use the getopt(3c) function to add the following options to your simple compressor:
- If no command line arguments are given, stdin should be compressed to stdout. This was the behavior of program #3.
- If any command line arguments are given, each is to be taken as the name of an input file to be read (first) and compressed in sequence to stdout. Compress each input stream (file) "independently" -- a compression sequence should not cross a stream boundary.
- If the dash ('-') is used as a command line argument, stdin should be used as that input file. Only one dash can be used per command line. The first dash should be used, but any subsequent dashes should be ignored but generate warning messages to stderr.
Generate a specific error message followed by a usage message to stderr if the command line arguments are incorrect.
- -o filename to specify an output file name
- -d decompress the input(s)
- -c char Use the character char instead of the tilde (~) as the compression code.
- -m digit Use digit as the minimum run of characters to begin compressing instead of the default 3. Generate an error (and usage) message if this single character is less than 2 or not a digit.
- -h Generate a usage (help) message to stdout.
In general, the program should have all the default features and functionality of the previous version. Note that since this version also decompresses, you can now use this program to test itself.
Note that this program must be able to compress newlines as well as anything else. Take a look at the sample solution for p3 to see a version that does compress newlines if you are uncertain that your p3 submission is correct. (Note that the sample solution will only be available starting a few days after p3 is due.)
Submission Requirements
- As usual, the program must be named p4.c and must reside in the cse271.131/p4 subdirectory.
- Divide the source code into two or more .c and .h files.
- Create and use an appropriate Makefile that will compile your program using make into an executable named p4, and will clean the directory with make clean.
- Your name must be in the comment section (along with appropriate description, etc.).
- Do a touch DONE when the program is ready to be collected.