CSCI 1730                  Programming Project 2B                    Summer 2008

                             Directory Lister


This project is due by midnight on *** Sunday, June 21 ***.

The goal of this project is to introduce you to the basic library functions
for reading directories in UNIX.  You will implement a program that lists all
the files in a given directory.  The final listing will be accomplished by
your custout( , ) function from part A.

Your program should take one or two command line parameters, where the first
is a path (relative or absolute) to a directory and the second, if present,
is passed along to custout( , ) as the second argument.  If there is only
one command line argument supply an empty string for the second argument to
cust( , ).  An example command line is:
          {odin} dirlister path_to_dir [flags]
Here "dirlister" is the name of your executable file.  Some examples of
"path_to_start" are "/", "/usr/local/bin", "~", "~/Project8", ".", "..",
and "mydir/subdir", all without the "'s.  The optional flags parameter can
be any string if present, but will only control the order in which files
are listed if it is one of the twelve proper nonempty forms specified in
part A.

Your program should list all of the files in the directory specified by
path_to_dir to standard output in the order encountered by readdir( ), or
else in the order indicated by the flags parameter if it is one of the
proper nonempty forms.  List the names of the files one per line.

Your project submission should include an implementation file dirlister.c,
a Makefile, a READ_ME file, and the custout.c file from part A ** along with
a header file custout.h with the function prototype **.   Your Makefile
should compile levelister.c and custout.c to the executable file dirlister
using gcc (** see the sample makefile linked from the "projects" page under
Project 2A **.)

Some things to note:

  *The names of the files submitted and of the executable file generated
   by the Makefile must be followed exactly, so that the teaching assistant
   and the instructor can test your project without editing your code.

  *All operations on directories must be done using the basic routines
   described in section 4.21 of the text.  These are declared in dirent.h
   and include opendir( ), readdir( ), rewinddir( ), and closedir( ).  The
   basic routines do NOT include utilities such as ls, fts, ftw, or nftw.
	
  *Your program must be written in C.  Operations on C-style strings may
   make use of the C string library.
  
  *Test your dirlister program on different absolute and relative directory
   paths and a variety of flags for the ordering.  
   
  *Use custout( , ) from custout.c to produce the final output.

  *The program should be robust and include appropriate error checks.

  *The submission procedure and requirements common to all projects are
   described on a separate page which is linked from the course "projects"
   sub-page.  Follow the submission procedure carefully.

  *A project which does not compile on odin using gcc for GCC 4.1.2 will
   score 0.  Projects which do compile properly will be scored out of 100
   (if on time) based on (1) correctness of operation, (2) quality of design,
   (3) coding style and documentation of the source code, and (4) correctness
   and usefulness of the READ_ME file and the Makefile.