Abstract
Extend the simple character compression filter of p2 to
- process command line arguments
- handle command line options
- provide decompression capabilities
Details
Take the compression program written for p2, 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 #2.
- 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.
While I will not require that this program be able to compress newlines, it must be able to compress anything else (and it really should be able to handle newlines too). Take a look at the sample solution for p2 if you are uncertain that your p2 submission is correct.
Submission Requirements
- As usual, the program must be named p3.c and must reside in the cse271.071/p3 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 p3, 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.