To apply your burgeoning sysprog skills in the writing of familiar and described UNIX tools.
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.
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):
All of the programs should accept the following command-line arguments (check for program-specific additional ones as well in the appropriate section):
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.
The Makefiles are set up for this, but you are basically to compile each program with the following compiler options:
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:
Claimed by: Christian Cattell (ccattell)
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:
Lack of one of these options should generate an error.
Claimed by:Jeff Jansen
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:
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 - 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:
Claimed by:Patrick (phastin1)
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:
Claimed by: Ben Schultes (bschulte)
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:
Claimed by: Kris (kbeykirc)
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:
Claimed by: Andrei Bratkovski (abratkov)
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:
Claimed by: Aaron Houghtaling (ahought2)
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:
Claimed by: Matthew Chon (mchon)
You will be implementing in accordance to the following specifications:
Your standard submission logic applies:
lab46:~/src/sysprog/wut#$ make submit ...