main.cc
, hexline.cc
,
Makefile
, hexdump.1
, and
hexline.3
. These files are described below. Consult "Using RCS" for information on how to set
up your project directory and use RCS for project management.
Your ~/man
directory tree is to contain man pages
for hexdump(1) and hexline(3). See "How to Write a Man Page" for information
on how to prepare your man
pages.
You may also leave a README
file in the project directory
if you think that one is needed, but I neither expect nor require you
to do so.
When the assignment is complete, send me an email message telling me the path to the project directory.
hexdump
, and it must be built from three source files,
which are named main.cc
, hexline.cc
, and
hexline.h
. The header file must be #included
in both the .cc
files.
I will provide a Makefile
, the hexline.h
header
file, and a library file named libhex.so
. The
Makefile
has been emailed to you, the header file is
installed in your ~/include
directory, and the library
file is installed in your ~/lib
directory. Create a
directory just for this project, and copy the Makefile
into it before you start work on the project. Always use the
make(1) command to compile and link your program. (There is an
alias for "make" to save you all that typing: "mk".)
You are to do the project in two steps. For the first step you are to
write main.cc
and build hexdump
by linking
main.o
with libhex.so
, which contains a
single object module with the function definition for
hexline(). Once you have the code for this step tested and
debugged, you are to write your own version of hexline.cc
,
create a new libhex.so
, and link your main program to it.
The Makefile
supplied to you has two lines that will build
the new libhex.so
for you, but you have to remove the
comment markers ('#
' characters) from them. Read the
Makefile
to find them.
Write man
pages for hexline(3) and hexdump(1). Check all
.cc
, .h
, .1
, .3
,
and Manpage
files into RCS using the ci
command. Delete all other files from your project directory, and make
sure the command "mk" builds the program using both your
.cc
files. Check out copies of the man
pages
and copy them to the proper directories, clean up the project
directory, and send me mail with the pathname of the project
directory.
hexdump
hexdump
takes two optional command line
options:
After the options, the user may enter any number of file names. Each file will be dumped from its starting offset to its ending offset. If no file names are given, the program dumps stdin.
- -s <n>
- Specifies a starting offset for the dump. The default value is zero, which means to begin the dump with the first byte of the file.
- -e <n>
- Specifies the offset of the last byte of the file to be dumped. The default value is -1, which means "the last byte of the file."
For this assignment, you must do all input and output by using the read() and write() system calls. Exception: you may use perror() and/or fprintf() for writing error messages to stderr.
There is a working version of hexdump
in
~vickery/bin
, which you may use to see what the program is
supposed to do.