======SYSPROG PROJECT: Writing Unix Tools (wut1)======
=====OBJECTIVE=====
To apply your burgeoning sysprog skills in the writing of familiar and described UNIX tools.
=====GRABIT=====
I have rigged up a grabit for **wut1**, which contains a directory structure, some useful Makefiles, and a header file to assist you in the development process.
=====PROGRAM=====
It is your task to implement getopt(3)-style command-line arguments and ensure functionality for the following tools (pick one, but your one must be unique; each person is doing a different one). You may choose to do others for potential bonus point considerations.
The programs are (edit the appropriate section and record your name to claim it; once someone has claimed a program, it is considered unavailable for others in the class to do for core credit):
====command-line arguments====
All of the programs should accept the following command-line arguments (check for program-specific additional ones as well in the appropriate section):
* **-h** display usage information and exit
* **-V** display version information and exit
* **-s "STRING"** specify STRING as value to process
* **-4** set nibble as processing unit/word size
* **-7** set byte/word as 7-bits
* **-8** set byte/word as 8-bits (default)
* **-n** no delimiter between processing units
* **-d 'CHAR'** use CHAR as delimiter between processing units (space is default)
* **-q** quiet, do not display anything to STDOUT
* **-v** verbose, display more information to STDOUT
====general program processing/usage====
**__usage__:** the program takes delimiter-separated numeric values via specified filename, or as a string communicated via the command-line, or from STDIN, converts them and then displays the result as appropriate for the particular tool (considering delimited output as well; delimiter is set to a single space by default). The program terminates upon exhausting all of its input.
====compiling===
The Makefiles are set up for this, but you are basically to compile each program with the following compiler options:
* **-Wall** increased warning pickiness/verbosity
* **-Werror** treat warnings as errors
* **--std=c99** compile with C99 language standards
====binary.c====
binary.c - program to display hex numbers in their
binary representation.
synopsis: binary [OPTION]... [FILE]...
execute: binary -s "de ad be ef 00 01 5a"
or: echo "de ad be ef 00 01 5a" | binary
Additional Command-line arguments to implement:
* **-B** input data is to be considered as binary (basically a passthrough)
* **-O** input data is to be considered as octal
* **-D** input data is to be considered as decimal
* **-H** input data is to be considered as hexadecimal (default)
Claimed by: Christian Cattell (ccattell)
====parity.c====
parity.c - program to check the parity (odd, even, none)
of input binary values.
synopsis: parity PARITYOPTION [OPTION]... [FILE]...
execute: parity -O -s "10110010"
or: echo "10110010" | parity -E
Additional Command-line arguments to implement:
* **-O** odd parity
* **-E** even parity
* **-N** no parity
Lack of one of these options should generate an error.
Claimed by:Jeff Jansen
====endian.c====
endian.c - program to encode value(s) according to
an indicated endianness.
synopsis: endian [OPTION]... [FILE]...
execute: endian -s "dead beef" -e -w 16 -b 16
or: echo "de ad be ef" | endian -E -b 16
Additional Command-line arguments to implement:
* **-w #** set wordsize (power of 2 between 4 and 128, 8 is default)
* **-u** also consider underlying bytes in endianness encoding
* **-E** encode as big endian
* **-e** encode as little endian (default)
* **-b BASE** input/output base (of 2, 8, 10, or 16; base 2 is default)
Your program can indicate a "setting not supported" message (and exit) if the **-7** argument is specified.
The **-4** and **-8** arguments are equivalent to **-w 4** and **-w 8**, respectively.
Claimed by: Dillon Vargeson(dvarges3)
====checksum.c====
checksum.c - program to calculate checksum
of provided values.
synopsis: checksum [OPTION]... [FILE]...
execute: checksum -b 16 -s "de ad be ef"
or: echo "de ad be ef" | checksum -b 16
Additional Command-line arguments to implement:
* **-b BASE** input/output base (of 2, 8, 10, or 16; base 2 is default)
* **-P** perform parity word checksum
* **-S** perform word sum checksum (default)
Claimed by:Patrick (phastin1)
====twoscomp.c====
twoscomp.c - program to calculate two's complement
of provided values.
synopsis: twoscomp [OPTION]... [FILE]...
compile: gcc -o twoscomp twoscomp.c -Wall -Werror --std=c99
execute: twoscomp -s "10011010"
or: echo "11001011" | twoscomp
Additional Command-line arguments to implement:
* **-w #** set wordsize (power of 2 between 4 and 128, 8 is default)
* **-b BASE** input/output base (of 2, 8, 10, or 16; base 2 is default)
Claimed by: Ben Schultes (bschulte)
====addition.c====
addition.c - program to perform addition (without
actually using any addition- only logic operations)
on the input values.
synopsis: addition [OPTION]... [FILE]...
execute: addition -s "10011010 11010001"
or: echo "11001011 00011101" | addition
Additional Command-line arguments to implement:
* **-b BASE** input/output base (of 2, 8, 10, or 16; base 2 is default)
* **-C** final carry out value is set to return value (otherwise return 0 on success)
* **-I #** set an initial carry in value (defaults to 0)
Claimed by: Kris (kbeykirc)
====bitmask.c====
bitmask.c - program to apply specified bitmask
against set of input values.
synopsis: bitmask -M BITMASK [OPTION]... [FILE]...
execute: bitmask -M "10110111" -s "10011010 11010001"
or: echo "11001011 00011101" | bitmask -M "10110101"
Additional Command-line arguments to implement:
* **-w #** set wordsize (power of 2 between 4 and 128, 8 is default)
* **-b BASE** input/output base (of 2, 8, 10, or 16; base 2 is default)
* **-M "BITMASK"** specify bitmask value for processing (required)
Claimed by: Andrei Bratkovski (abratkov)
====rotate.c====
rotate.c - program to perform a bit rotate
against a set of input values.
synopsis: rotate -L[#]|-R[#] [OPTION]... [FILE]...
execute: rotate -L 3 -s "10011010 11010001"
or: echo "1100101100011101" | rotate -W 16 -R
A bit rotate preserves bits, a bit shift discards bits.
Additional Command-line arguments to implement:
* **-w #** set wordsize (power of 2 between 4 and 128)
* **-L #** perform a left rotate operation (shift by # bits; 1 if not specified)
* **-R #** perform a right rotate operation (shift by # bits; 1 if not specified)
Claimed by: Aaron Houghtaling (ahought2)
====invert.c====
invert.c - program to perform a bit inversion
against a set of input values (toggle all
0s to 1s, and 1s to 0s).
synopsis: invert [OPTION]... [FILE]...
execute: invert -s "10011010 11010001"
or: echo "1100101100011101" | invert
Word size doesn't really matter for invert. It is merely flipping bits, however many there are.
Additional Command-line arguments to implement:
* **-B** input data is to be considered as binary (default)
* **-O** input data is to be considered as octal
* **-D** input data is to be considered as decimal
* **-H** input data is to be considered as hexadecimal
Claimed by: Matthew Chon (mchon)
=====SPECIFICATIONS=====
You will be implementing in accordance to the following specifications:
* well commented
* top comment banner including compile and sample execution instructions (and description)
* consistent presentation of comments throughout code identifying process particulars
* consistently indented
* getopt(3)-style command-line arguments
* help/usage
* implement described functionality
* do reasonable error checking to ensure correct operation
=====SUBMISSION=====
Your standard submission logic applies:
lab46:~/src/sysprog/wut#$ make submit
...