Get Info Demo Program
version 1.0

This program will introduce several packages that are available on my web site.

The basic program will read information about 'something' and organize the entries.
For this program, that 'something' will be information about a person.

The ProdList package is a series of routines that implement a number of ADTs
(Abstract Data Type) of various dynamic arrays.  The difference between the
various "flavors" of ProdList is basically what type of array it supports.

The most common ProdList types that I use are:
	ProdPtrList - an array of void pointers
	ProdAPtrList - two arrays: a character string and a void pointer

The ProdPtrList can be used to store arrays of structures of any type.
The ProdAPtrList contain routines to support indexed structures.

The program creates a PtrProdList, which we will use to store the collection.

The program loops asking the user for information.  A trick I often use is to ask
for the first field, or ENTER to quit.  That saves having to ask ("add another?").

If the user enters something, then we create a new stuff entry and fill in the fields.

Notice that I am using a routine called "read_line" that will read a line of text and
strip off the CR-LF sequence.  This is the start of an ADT.  Eventually, it will allow
you to "unread" a line of text, but right now, it is just a simple routine to read
a line of text.  If/when I actually finish the read_line ADT, I can drop the latest
version of the source file into this directory, and I will have additional capabilities
available.  I may never use them, but at least it won't require any changes to the
source file.

Each field is asked for, and added to the structure.  If a field is numeric, then
we need to convert from the character string the user enters to the actual numeric value.
In this program, we have an integer field called "ID"; all the other fields are character
strings.

For character strings, we could either use character arrays or character pointers.
I always prefer character pointers, since it saves space, and I don't have to worry
about a string getting too long.  (Does the term "Buffer Overflow" sound familiar?
that is how such bugs happen.  People allocate a fixed amount of memory, and then
forget to check it before copying something into the field.)

The input buffer, "buf", is sized using the symbolic constant "BUFSIZ+1". BUFSIZ is
the maximum number of characters that can be read at one time.  By sizing the buffer
to one more than the max. value, and setting the next character to a binary zero,
that means that no matter how many characters the user enters, we don't get a buffer
overflow.  The worst that should happen is the input gets truncated, and the extra 
character will terminate whatever string was entered.

After the entry has been initialized, we use the routine add_ptr_prodlist to add the
structure to the collection.  This routine will automatically resize the array if
there is an attempt to add more entries than the current size.

The loop continues asking the user to enter information until they signal they are done.
At that point, we print out how many entries we added (using the nitems field).  The
trick that I often use when asking the user for records of information is for the first
field, to give them the option of entering a value, or pressing ENTER to signal that
they are done entering new entries.  Of course, the first field you ask for should
be required, otherwise they wouldn't be able to enter an empty field.  (You could also
tell them to enter something special (e.g., END) to signal they are done.

We then loop through the collection and print out what was entered.

As you can see, this doesn't do much, but it is a good start.  You should always
write some debugging code at the beginning to make sure that things are working
correctly.  If you wait until you are done writing the program, it will probably
be too complicated to debug.

The statement to print out how many enties, and the loop to display them is debugging
code.  If what we see is what we entered, then things are fine so far.
