Starting from:

$25

CSCI1730 - Breakout - Lab 06 - Solved

Cat

Problem / Exercise
For this lab, you will implement your own version of the cat systems program, a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to concatenate files. The Single Unix Specification defines the operation of cat to read files in the sequence given in its arguments, writing their contents to the standard output in the same sequence. If one of the input filenames is specified as a single hyphen (-), then cat reads from standard input at that point in the sequence. If no files are specified, cat reads from standard input only. The command-syntax is:

$ ./cat [file_name...]

You are NOT allowed to use the exec, system, popen, and pclose system calls or functions in your implementation. You are not allowed to call the existing cat implementation. You must supply your own implementation that uses low-level I/O. Low-level file I/O (APUE Ch. 3) is a requirement for this breakout lab.

Hint: if you would like to check to see whether you have implemented cat correctly, then you could simply compare the behaviors of your cat program with the cat program on odin.


2           Some Nonfunctional Requirements
Your submission needs to satisfy the following nonfunctional requirements:

•    Directory Setup: Make sure that all of your files are in a directory called LastName-FirstName-lab06, where LastName and FirstName are replaced with your actual last name and first name, respectively.

•    Libraries: You are allowed to use any of the C standard libraries. However, when reading and writing to a file are concerned, you need to use low-level calls to read(2) and write(2) and related functions. You are NOT allowed to use the following system calls in any of your implementations: fork(2), execve(2), exec(3), popen(3), and system(3) (or related functions).

•    Unbuffered Output: Whenever possible, program output should be unbuffered. The best way to guarantee that output is unbuffered (i.e., characters at the destination as soon as possible) is to directly call write(2).

•    Documentation: You code must be documented using Javadoc style comments. Use inline documentation, as needed, to explain ambiguous or tricky parts of your code.

•    Standards & Flags: Make sure that when you compile, you pass the following options to gcc:

-Wall -pedantic-errors

1

Other compiler/linker options may be needed in addition to the ones mentioned above. The expectation is that the grader should be able to type make clean and make in the following to clean and compile/link your submission, respectively.

•    README File: Make sure to include a README file that includes the following information presented in a reasonably formatted way:

–    Your Name and UGA ID (811#).

–    Instructions on how to compile and run your program.

•    Compiler Warnings: Since you should be compiling with both the -Wall and -pedantic-errors options, your code is expected to compile without gcc issuing any warnings.

•    Memory Leaks: Since this assignment may make use of dynamic memory allocation, you are expected to ensure that your implementation does not result in any memory leaks. We will test for memory leaks using the valgrind utility.


More products