JMU
Programming Assignment 1


1 Summary

You have been hired by the (fictitious) company zmedia to develop some of the code they will need for their zplayer.

Specifically, you have been hired to develop the bookz_lib module and the bookz_player module.

2 Specifications and Other Documents

zmedia has provided you with the following documents.

3 A Collection of bookz

zmedia has provided you with a collection of "adventure" bookz in a "gzipped tarball".

You must uncompress it (using gzip) and extract the collection (using tar) before using it, but you must not change any of the individual file names or the contents of the files.

4 Additional Specifications/Constraints

In addition to conforming to the documents provided by zmedia (and all related course policies), your code must satisfy the following additional specifications/constraints.
  1. You must use the system calls read() and write() for input/output. You must not use C/C++ I/O libraries (e.g., you must not use printf() or scanf() or any of their variants other than sprintf()).
  2. Files must be opened using the most appropriate access mode.
  3. Files must be closed.

5 Help

Remember, the course WWW pages contain a lot of helpful information. In addition, you may find the following information helpful.

5.1 Working with the Collection of booz

Remember that you can get help on UNIX commands (like gzip and tar tar ) from the command line using man or on-line.

5.2 Slowing the Display

It is unlikely that the bookz_player will display the "lines" of the bookz one per second. Specifically, it will display them much more quickly than that. Hence, you will need to slow the display. This can be accomplished with a call to the sleep() sleep function after each "line" is displayed.
unsigned int sleep(unsigned int seconds);
Purpose:
Suspend execution for a given amount of time
Details:
secondsThe number of seconds
Return0 normally; the unslept seconds if interrupted
#include <unistd.h> unistd.h

5.3 Displaying the Number of Lines Read

Since you can't use printf() you will need to convert the numebr of lines read to a char[] in order to display it using write(). The easiest way to do this is using the library function sprintf() sprintf .

You should know (or be able to figure out) how to determine the number of digits in a number. If you get stuck, you can review my , CS139 lecture on the topic.

Copyright 2017