File Copy Program

Due Date:
October 10, 1996
Deliverables:
When the assignment is complete, send me an e-mail message telling me the path to the project directory. The project directory is to contain an RCS subdirectory, and nothing else. In addition, the ~/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.
Requirements:
In addition to the information given here, be sure to consult the Grading Form for this assignment, which includes additional information about the requirements for this project.

Project Overview

Write a program, vcopy, that can be used to copy one file to another.

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.

Project Steps

  1. Write a file-copy program using Unix System Calls. Write a program that copies one file to another. The input file is to be specified after a -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.

  2. There is only one step for this assignment!


Christopher Vickery
Queens College of CUNY