~/man
directory tree is to contain
man pages for the executable program and for those functions
indicated in the Project Steps, below. 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.
Note: You must use the features of the Unix programming environment described in this document, even though there might be "better" ways to do the same things. One purpose of the assignment is to give you experience with the facilities specified here.
You are to do the exercise as a sequence of steps as listed below, and the code for each step is to have its own RCS version number. Because you will have to add modules in some of the later steps, there should be a different version of the project Makefile for each step, too.
There is only one step for this assignment, but you should think of it as the first step of a multi-step project to develop a text-conversion system.
-i
command line argument; use stdin if there is no
-i
command line argument. The output file is to be specified
after a -o
command line argument; use stdout if there
is no -o
command line argument.
Your program must use the Unix system calls, open(), read(),
and write() to do all i/o operations. You must also provide a function
name vgetc(), that operates the same way as the standard
fgetc() library function, except that it takes a file descriptor
as its argument rather than a FILE*
. In order for vgetc() to
work, you will have to supply a function named vopen() that acts as an
interface to open(), and does whatever buffer management is necessary
for the fd. You do not have to supply a "vputc" function, and
vopen() does not have to do any buffer management for files that are
opened for writing.
Use the numerical value of the environment variable, V_BUF_SIZE
to determine how large a buffer vopen() is to allocate for each file
it opens. If V_BUF_SIZE
is not valid, vopen()
is to set errno
to EINVAL
(defined in
<errno.h>
) and return -1.
Buffer management will be discussed in class.
Put the source code for vopen() and vgetc() in a separate file
from main(),
and #include
a header file containing function prototypes for
these two functions in both your .c
files. Be sure you write
your code so that the file containing main() has access to no more
information about vopen() and vgetc() than their function
prototypes.
Write a man page for your program. It may be brief, but it must be in standard man page format, and it must be installed properly. Consult the man page handout for this course and/or the man entry in Section 5 of the on-line man pages for information on how to mark up the text of your man page.
Write man pages for your two functions, vopen() and
vgetc() in standard man page format, and install them in the
proper section of your ~/man
tree.