[mod.sources] rolodex database program -- part 1 of 3

sources-request@panda.UUCP (03/14/86)

Mod.sources:  Volume 4, Issue 27
Submitted by: ihnp4!think!massar (JP Massar)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	README
#	rolo.1
#	Makefile
#	helplib
# This archive created: Thu Mar 13 18:29:50 1986
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(1693 characters)'
if test -f 'README'
then
	echo shar: will not over-write existing file "'README'"
else
cat << \SHAR_EOF > 'README'
This is an online rolodex program that has been used here at Thinking
Machines Corporation for quite a while.  Lot's of people find it very
useful and I have never had any problems with it.

This code has only been tested on BSD42 on a VAX.  It definitely will
not work under System V, although I have included a "sys5.h" to start
things going.

Instructions on how to install:

1.  This program should have come in 3 parts.  Choose an empty directory,
    and unshar them all.  Check the Makefile, you may want to select
    either TERMCAP or TERMINFO.

2.  Pick a library subdirectory where the help and menu files will go.
    (Say /usr/local/lib/rolo).  Edit the Makefile and change the definition
    of ROLOLIB to that path.  (Do not leave it as is!).

3.  Create the directory and move all the files in helplib to this directory.

4.  Pick the appropriate place in your manual hierarchy where the man
    page should go.  Adjust MS and MAN in the Makefile accordingly.

5.  Pick the appropriate place where the executable should live.  Adjust
    BIN in the Makefile accordingly.

6.  Edit the manual page (ctools.1) if you wish to change the FILES
    section to point to the directories you selected.

7.  Type 'make man' and read the manual page.

8.  Type 'make'.  

9.  Type 'rolo' and try out the rolodex program!

10.  Type 'make install'.

11. Type 'make clean'.


The files ctools.c and ctools.h in the toolsdir directory are useful in
their own right, as they contain many little useful string manipulation
routines and other goodies.  You might wish to install it as <ctools.h>
and -lctools as is done here.

Problems, bugs and hacks to:

massar@think.com
ihnp4!think!massar
SHAR_EOF
if test 1693 -ne "`wc -c < 'README'`"
then
	echo shar: error transmitting "'README'" '(should have been 1693 characters)'
fi
fi
echo shar: extracting "'rolo.1'" '(1935 characters)'
if test -f 'rolo.1'
then
	echo shar: will not over-write existing file "'rolo.1'"
else
cat << \SHAR_EOF > 'rolo.1'
.TH ROLO 1 "6 December 1984"
.UC 4
.SH NAME
rolo \- use an online rolodex, containing information about people.
.SH SYNOPSIS
.B rolo
[ name1 name2 ... \-u otheruser \-s \-l ]
.SH DESCRIPTION
By default
.I rolo
reads in a rolodex data file from the user's home directory, prints
out a menu of choices, and lets the user scan, update, delete and add to
his personal database of people.  If no rolodex database exists one
is created.
.I rolo
checks to see that the rolodex database is not already in use.
.PP
The command line options are:
.TP
.B \-u otheruser
Uses the rolodex database in the 'otheruser' home directory.  This may
not be possible if the directory or the database is read or write protected.
.TP
.B \-s
Prints people's names, work phone numbers and home phone numbers in a nice
format to standard output.
.TP
.B \-l
Normally the rolodex database is locked when being used.  This option
unlocks the database as soon as it is read in.  The \-s option implies this.
.PP
Invoking 
.I rolo
followed by a list of names causes 
.I
rolo
to search the database for all people whose names or company
affiliations contain any of the name arguments as substrings.  All the
information about each person is printed to standard output, the program
pausing after each record is printed.  Using this feature causes the
database to become unlocked, since this is a read-only mode.
.PP
Extensive help is available on-line.  Typing '?' or 'help' will generally
print a help file for you.
.SH FILES
/usr/src/local/cmd/rolo     for the source.
.PP
/usr/local/lib/rolo     for help files.
.PP
/usr/local/rolo         the executable image.
.PP
.PP
.SH AUTHOR
Peter Webb wrote the first rolodex program.
.PP
JP Massar revised and then complete rewrote this older version.
Net address: massar@think.com, ihnp4!think!massar.
.SH BUGS
There is no way to keep certain entries private.
.PP
You can't get a short summary of only a subset of people.



SHAR_EOF
if test 1935 -ne "`wc -c < 'rolo.1'`"
then
	echo shar: error transmitting "'rolo.1'" '(should have been 1935 characters)'
fi
fi
echo shar: extracting "'Makefile'" '(1178 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
# Makefile for rolo

# Configure for your type of terminal capability database.  
#  if you have termcap,  set TERMSTUFF= -DTERMCAP,  and LIBS= -ltermcap
#  if you have terminfo, set TERMSTUFF= -DTERMINFO, and LIBS= -lterminfo
#  if you dont have either, leave them both blank (only "clear_screen" is used)
TERMSTUFF=
LIBS=
#
CC = cc
ROLOLIB = \"./helplib\"
TOOLDIR = ./toolsdir
CFLAGS = -DBSD42 -DROLOLIB=$(ROLOLIB) $(TERMSTUFF) -I$(TOOLDIR) -O
DBGFLAG = 
SOURCES = clear.c io.c menuaux.c operations.c options.c \
	rlist.c rolo.c search.c update.c
OBJECTS = clear.o io.o menuaux.o operations.o options.o \
	rlist.o rolo.o search.o update.o
TOOLOBJ = $(TOOLDIR)/mem.o $(TOOLDIR)/args.o $(TOOLDIR)/ctools.o \
	$(TOOLDIR)/menu.o
BIN = /usr/local
MS = 1
MAN = /usr/man/man$(MS)

rolo: $(OBJECTS)
	cd $(TOOLDIR) ; make tools ; cd ..
	$(CC) -o rolo $(DBGFLAG) $(CFLAGS) $(OBJECTS) $(TOOLOBJ) $(LIBS)
install: rolo
	rm -f $(BIN)/rolo
	mv rolo $(BIN)/rolo
man: 
	rm -f $(MAN)/rolo.1
	cp rolo.1 $(MAN)/rolo.$(MS)
	man rolo
clean:
	rm -f $(OBJECTS) rolo *~ foo $(TOOLDIR)/*.o

shar:
	cshar README rolo.1 Makefile helplib > roloshar1
	cshar *.[ch] > roloshar2
	cshar toolsdir > roloshar3
SHAR_EOF
if test 1178 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 1178 characters)'
fi
fi
if test ! -d 'helplib'
then
	echo shar: creating directory "'helplib'"
	mkdir 'helplib'
fi
echo shar: extracting "'helplib/addhelp'" '(1408 characters)'
if test -f 'helplib/addhelp'
then
	echo shar: will not over-write existing file "'helplib/addhelp'"
else
cat << \SHAR_EOF > 'helplib/addhelp'
You are adding a new entry to your rolodex database.  If you want to
get back to the main menu type the character '\' followed by RETURN.

Each entry is composed of 7 fixed items, which are Name, Work Phone,
Home Phone, Company, Work Address, Home Address, and Remarks.  You are
being prompted to give a value to each item, one after the other.  Simply
type in some characters and end with a RETURN.  If you realize you've made
a mistake after hitting RETURN, type '^' RETURN, which will prompt you
again for the item you just entered.  If you have no information for a 
particular item, simply type RETURN and you will be prompted for the next
item.   Finally, the program will prompt you with 'Other fields? '.   At
this point type 'no' RETURN unless you know what you are doing (see below).

     (Advanced feature) If you have entered all the information about a person
you have, and the program is still prompting you for fields, type '!' RETURN
and it will assume that all the remaining fields are to be left empty.
     (Advanced feature) You can add items in addition to those listed above.
To do so answer 'yes' to the 'Other fields? ' prompt and then ask for help.
     (Advanced feature) The character ';' is used as a line separator.  If
you typed in '245 First St.,; Cambridge, MA 02139', when this information was
displayed the street address and city/state would print out on different lines.
SHAR_EOF
if test 1408 -ne "`wc -c < 'helplib/addhelp'`"
then
	echo shar: error transmitting "'helplib/addhelp'" '(should have been 1408 characters)'
fi
fi
echo shar: extracting "'helplib/addinfo'" '(66 characters)'
if test -f 'helplib/addinfo'
then
	echo shar: will not over-write existing file "'helplib/addinfo'"
else
cat << \SHAR_EOF > 'helplib/addinfo'
Add a rolodex entry:  (? for help, ^ to back up, \ to abort add)

SHAR_EOF
if test 66 -ne "`wc -c < 'helplib/addinfo'`"
then
	echo shar: error transmitting "'helplib/addinfo'" '(should have been 66 characters)'
fi
fi
echo shar: extracting "'helplib/entrymenu'" '(222 characters)'
if test -f 'helplib/entrymenu'
then
	echo shar: will not over-write existing file "'helplib/entrymenu'"
else
cat << \SHAR_EOF > 'helplib/entrymenu'

   RETURN  : continue the scan.             %   : scan rolodex from this point.
   +       : update or add to the entry.    <   : display previous entry.
   -       : delete the entire entry.       \   : abort the scan.

SHAR_EOF
if test 222 -ne "`wc -c < 'helplib/entrymenu'`"
then
	echo shar: error transmitting "'helplib/entrymenu'" '(should have been 222 characters)'
fi
fi
echo shar: extracting "'helplib/escanhelp'" '(846 characters)'
if test -f 'helplib/escanhelp'
then
	echo shar: will not over-write existing file "'helplib/escanhelp'"
else
cat << \SHAR_EOF > 'helplib/escanhelp'
The rolodex program is displaying each entry in your rolodex database
(the entries are ordered alphabetically) one by one.  After an entry
has been displayed, you have the option to

  -- have the next entry displayed (type RETURN)
  -- have the previous entry displayed by (type '<' RETURN)
  -- delete the entry from your rolodex (type '-' RETURN)
  -- change the information contained in this entry (type '+' RETURN)
  -- abort this sequential display mode and go back to the main menu 
     (type '\' RETURN)

If you elect to delete the entry, the message 'Entry deleted' will be
displayed briefly, and then the next entry will be displayed.

If you elect to update the entry, after you have completed the update
operation the message 'Displaying next entry in scan list' will be
displayed briefly, and then the next entry will be displayed.
SHAR_EOF
if test 846 -ne "`wc -c < 'helplib/escanhelp'`"
then
	echo shar: error transmitting "'helplib/escanhelp'" '(should have been 846 characters)'
fi
fi
echo shar: extracting "'helplib/esearchhelp'" '(1071 characters)'
if test -f 'helplib/esearchhelp'
then
	echo shar: will not over-write existing file "'helplib/esearchhelp'"
else
cat << \SHAR_EOF > 'helplib/esearchhelp'
The rolodex program is displaying each entry that matches the search string
you provided, one by one.  After an entry has been displayed, you have
the option to

  -- have the next entry displayed (type RETURN)
  -- have the previous entry displayed by (type '<' RETURN)
  -- delete the entry from your rolodex (type '-' RETURN)
  -- change the information contained in this entry (type '+' RETURN)
  -- abort this sequential display mode and go back to the main menu 
     (type '\' RETURN)

     If you elect to delete the entry, the message 'Entry deleted' will
be displayed briefly, and then the next entry will be displayed.
     If you elect to update the entry, after you have completed the
update operation the message 'Displaying next entry in scan list' will
be displayed briefly, and then the next entry will be displayed.
     If only one entry matched your search string, or the entry being
displayed is the last entry which matches, if you try to continue the
program will inform you that there are no more matching entries and
return you to the main menu.
SHAR_EOF
if test 1071 -ne "`wc -c < 'helplib/esearchhelp'`"
then
	echo shar: error transmitting "'helplib/esearchhelp'" '(should have been 1071 characters)'
fi
fi
echo shar: extracting "'helplib/fieldsearchhelp'" '(1034 characters)'
if test -f 'helplib/fieldsearchhelp'
then
	echo shar: will not over-write existing file "'helplib/fieldsearchhelp'"
else
cat << \SHAR_EOF > 'helplib/fieldsearchhelp'
You have asked to search the rolodex database by some other item than name.
For instance, if you wanted to find people who worked in Cambridge, you could
select the 'Work Address' item and use as a search string 'Cambridge'.  If
this is not what you want to do type '\' RETURN to get back to the main menu.

To select an item to search by, type the number of the item.  It will
then prompt you for a search string.  Type in what you want to search
for followed by RETURN.  The program will then show you the entries that
it has found that match your search criteria.

(Advanced feature) You can search by items which you have defined, as well as
the standard items.  The last choice is not a standard item but an option to
allow you to type in the name of your own user-defined item name.  For
instance, if your rolodex database contained 'Net Address' items, you could
search for Net Addresses containing 'ihnp4' by selecting the last choice
and typing in 'Net Address' RETURN, followed by 'ihnp4' RETURN at the
appropriate prompts.
SHAR_EOF
if test 1034 -ne "`wc -c < 'helplib/fieldsearchhelp'`"
then
	echo shar: error transmitting "'helplib/fieldsearchhelp'" '(should have been 1034 characters)'
fi
fi
echo shar: extracting "'helplib/lockinfo'" '(734 characters)'
if test -f 'helplib/lockinfo'
then
	echo shar: will not over-write existing file "'helplib/lockinfo'"
else
cat << \SHAR_EOF > 'helplib/lockinfo'
Your rolodex is already in use!

Either someone else is using and possibly modifying your rolodex, or else
you forgot to exit a previous use of your rolodex, or possibly the system
crashed while you were using your rolodex the last time.

You can find out who is using your rolodex by typing

ls -l ~/.rolodexdata.lock

The third column of the output will be a user's name.  If the name is
not yours, then you should find out what that person is doing with your
rolodex and ask him/her to let you know when they are finished.

If the name is your own, then it is probably safe to remove the lock file.
(It is possible that someone else is logged in as you, however...)
Type

rm ~/.rolodexdata.lock

and then you can use your rolodex.
SHAR_EOF
if test 734 -ne "`wc -c < 'helplib/lockinfo'`"
then
	echo shar: error transmitting "'helplib/lockinfo'" '(should have been 734 characters)'
fi
fi
echo shar: extracting "'helplib/mainmenu'" '(395 characters)'
if test -f 'helplib/mainmenu'
then
	echo shar: will not over-write existing file "'helplib/mainmenu'"
else
cat << \SHAR_EOF > 'helplib/mainmenu'
        TOP LEVEL MENU

  +  :  add a new entry
  %  :  scan the rolodex entry by entry
  $  :  search by some item other than 'Name'
  *  :  save any changes made so far
  !  :  pretty print the rolodex database to a disk file
  \  :  exit (any changes you've made will be saved)

To search for an entry by name, just type in the name.
To update or delete an entry, first find it by searching.
SHAR_EOF
if test 395 -ne "`wc -c < 'helplib/mainmenu'`"
then
	echo shar: error transmitting "'helplib/mainmenu'" '(should have been 395 characters)'
fi
fi
echo shar: extracting "'helplib/moptionhelp'" '(1390 characters)'
if test -f 'helplib/moptionhelp'
then
	echo shar: will not over-write existing file "'helplib/moptionhelp'"
else
cat << \SHAR_EOF > 'helplib/moptionhelp'
     This is the TMC Rolodex, an online way to store and retrieve information
about people you know, and other important pieces of data.
     Data is stored in units called entries..  There will generally be an entry
for each person in your rolodex.  Inside entries are items.  Items store such
things as a person's name, his phone number(s), and address(es).  You can
change items or add new ones.  You can create or delete entire entries also.
     At any time you can type the character '\' followed by RETURN to abort
what you are currently doing.  Most of the time '?' or 'help' followed by
RETURN will get you more information on what you are expected to type in next.
     If for some reason you wish to terminate the rolodex program without
saving any changes you have made, hold down the CTRL key and type 'c'.

     When you are searching for information, typing in any part of the
information that uniquely identifies it is good enough.  For instance, if you
were looking for John Finklesnort, typing 'John' is probably not a good idea
because you probably have a few names that contain 'John', but typing 'Finkle'
or 'snort' will probably uniquely identify the entry you want.  The search
program is completely case-insensitive.
     The rolodex search is completely case-insensitive (e.g., searching for
'Finkle' is the same as searching for 'finkle' is the same as 'fInKLe').
SHAR_EOF
if test 1390 -ne "`wc -c < 'helplib/moptionhelp'`"
then
	echo shar: error transmitting "'helplib/moptionhelp'" '(should have been 1390 characters)'
fi
fi
echo shar: extracting "'helplib/moptionshelp'" '(747 characters)'
if test -f 'helplib/moptionshelp'
then
	echo shar: will not over-write existing file "'helplib/moptionshelp'"
else
cat << \SHAR_EOF > 'helplib/moptionshelp'
This is the TMC Rolodex, an online way to store and retrieve information
about people you know, and other important pieces of data.

At any time you can type the character '\' followed by RETURN to abort
what you are currently doing.  Most of the time '?' or 'help' followed by
RETURN will get you more information on what you are expected to type in
next.

At the Top Level Menu, which you are currently at, you can type the following:

'+'     to begin entering information about a new person.
'%'     to begin scanning your rolodex, entry by entry.
'!'     to print out your rolodex in a nice format.
'*'     to save any changes you have made to your rolodex.
'\'     to exit the rolodex program.

If you wish to find an already existing entry
SHAR_EOF
if test 747 -ne "`wc -c < 'helplib/moptionshelp'`"
then
	echo shar: error transmitting "'helplib/moptionshelp'" '(should have been 747 characters)'
fi
fi
echo shar: extracting "'helplib/pickentrymenu'" '(130 characters)'
if test -f 'helplib/pickentrymenu'
then
	echo shar: will not over-write existing file "'helplib/pickentrymenu'"
else
cat << \SHAR_EOF > 'helplib/pickentrymenu'
Type number of the entry you wish to view,
or type RETURN to view each entry one by one,
or type '\' to go back to the main menu.
SHAR_EOF
if test 130 -ne "`wc -c < 'helplib/pickentrymenu'`"
then
	echo shar: error transmitting "'helplib/pickentrymenu'" '(should have been 130 characters)'
fi
fi
echo shar: extracting "'helplib/poptionmenu'" '(150 characters)'
if test -f 'helplib/poptionmenu'
then
	echo shar: will not over-write existing file "'helplib/poptionmenu'"
else
cat << \SHAR_EOF > 'helplib/poptionmenu'
OPTIONS:
   RETURN  -- continue looking for same name.
   'n'     -- look for the next name you asked about.
   '\'     -- abort the rolodex program.
SHAR_EOF
if test 150 -ne "`wc -c < 'helplib/poptionmenu'`"
then
	echo shar: error transmitting "'helplib/poptionmenu'" '(should have been 150 characters)'
fi
fi
echo shar: extracting "'helplib/poptionshelp'" '(648 characters)'
if test -f 'helplib/poptionshelp'
then
	echo shar: will not over-write existing file "'helplib/poptionshelp'"
else
cat << \SHAR_EOF > 'helplib/poptionshelp'
At this point you can type the following:

the RETURN key.
the 'n' key followed by RETURN.
the '\' (backslash) key followed by RETURN.

If you used the rolodex program by typing something like 'rolo john'
then typing RETURN will find for you the next person in your rolodex
who has the letters 'john' as part of their name.

If you used the rolodex program by typing something like 'rolo john mary'
then typing 'n' after the program had displayed one of the people whose
name contained 'john' would stop the program from looking for any more
'john's and start looking for 'mary'.

If you just wish to exit the program type the backslash character.
SHAR_EOF
if test 648 -ne "`wc -c < 'helplib/poptionshelp'`"
then
	echo shar: error transmitting "'helplib/poptionshelp'" '(should have been 648 characters)'
fi
fi
echo shar: extracting "'helplib/updatehelp'" '(1253 characters)'
if test -f 'helplib/updatehelp'
then
	echo shar: will not over-write existing file "'helplib/updatehelp'"
else
cat << \SHAR_EOF > 'helplib/updatehelp'
You have asked to change some information contained in the entry that was
being displayed before you typed '+'.  If this is not what you want type '\'
RETURN to get back to the main menu.

Currently, the program is displaying the name of each item in the entry and
its contents (some items may have no contents).  Each item is numbered.
Simply type the number of the item whose contents you wish to change.  The
program will then display the old contents of the item and ask you to type in
some text which will become the new contents.  Once you have done this for
each item you wish to change, type RETURN when it again asks for you an item
number.  It will then print out the revised entry one more time, and ask you
to confirm all your changes.  You can abort all your changes for this entry at
any time by typing '\' RETURN.

You can also add new items to this entry.  The last numbered choice is not an
item name but an option to allow you to do this.  Type this number (now 8) and
you will be prompted for the name and contents of a new field.  For instance
you might want to add an item called 'Net Address' with a value 'cca!alex'.
When prompted you would type 'Net Address: cca!alex' RETURN.  You stop adding
new items by typing just a RETURN.
SHAR_EOF
if test 1253 -ne "`wc -c < 'helplib/updatehelp'`"
then
	echo shar: error transmitting "'helplib/updatehelp'" '(should have been 1253 characters)'
fi
fi
echo shar: extracting "'helplib/updatemenu'" '(125 characters)'
if test -f 'helplib/updatemenu'
then
	echo shar: will not over-write existing file "'helplib/updatemenu'"
else
cat << \SHAR_EOF > 'helplib/updatemenu'
Type number of the item you wish to change,
or type RETURN to finalize your changes,
or type '\' to cancel all your changes.
SHAR_EOF
if test 125 -ne "`wc -c < 'helplib/updatemenu'`"
then
	echo shar: error transmitting "'helplib/updatemenu'" '(should have been 125 characters)'
fi
fi
echo shar: done with directory "'helplib'"
exit 0
#	End of shell archive