[comp.sources.d] rolo enhancement

nerd@percival.UUCP (Michael Galassi) (03/28/88)

Howdy,
	I have been using rolo on my machine since it's first posting
to the net and have found it very usefull.  There is however one feature
that has been missing to make it "right" for me.  That is the capability
to maintain multiple rolodex databases in my own directory.  I have
fixed that with this set of diffs.  I have been running this code on my
machine for several weeks now with no problems so it should be ok.  Of
course if you improve this or find bugs with it I would love to hear
from you.  The diffs do patch the apropriate files in helplib, but I
never saw a man page for the current rolo so I don't have patches for
that.  If you have a manpage for the current rolo I would LOVE to get
a copy of it from you.  To apply these save this article to a file and
type.
patch -p0 -d<sourcedir> < <file>

NOTE:  Keep these patches around as future oficial upgrades may not
be based on rolo with this change in it so you may have to run
patch -p0 -d<sourcedir> -R < <file>patch -p0 -d<sourcedir> < <file>.

NOTE 2:  If lwall is reading this, should patch -R reverse all the
patches or only the first one it encounters?  Currently it only
reverses the first one.


        Michael Galassi           | If my opinions happen to be the same as
...!tektronix!tessi!percival!nerd | my employer's it is ONLY a coincidence,
...!uunet!littlei!percival!nerd   | of cource coincidences DO happen.

*** orig/rolo.c	Sun Mar 13 07:42:50 1988
--- rolo.c	Sun Mar 13 13:02:09 1988
***************
*** 21,27 ****
  #ifdef MSDOS
  #include <fcntl.h>
  #	ifdef MSC
! #	include <sys	ypes.h>
  #	endif	/* MSC */
  #include <sys/stat.h>
  #include <errno.h>
--- 21,27 ----
  #ifdef MSDOS
  #include <fcntl.h>
  #	ifdef MSC
! #	include <sys/types.h>
  #	endif	/* MSC */
  #include <sys/stat.h>
  #include <errno.h>
***************
*** 81,86 ****
--- 81,95 ----
  int in_search_mode = 0;
  int read_only = 0;
  
+ #define NAMELEN BASENAMELEN+5
+ 
+ char	ROLOBAK[NAMELEN],
+ 		ROLODATA[NAMELEN],
+ 		ROLOLOCK[NAMELEN],
+ 		ROLOTEMP[NAMELEN],
+ 		ROLOCOPY[NAMELEN],
+ 		ROLOPRINT[NAMELEN];
+ 
  char *rolo_emalloc (size) int size;
  
  /* error handling memory allocator */
***************
*** 557,562 ****
--- 566,607 ----
  	}
  }
  
+ init_fnames()
+ {
+ 	Bool alt_name;
+ 	char basename[BASENAMELEN+1];
+ 	char *bn;
+ 	char *rolo_str = "rolodex";
+ 
+ 	alt_name = option_present(ALTNAMEFLAG);
+ 	if (!alt_name)    {		/* default if no -n flag */
+ 		bn = rolo_str;
+ 	}
+ 	else    {
+     	if ((n_option_args(ALTNAMEFLAG) != 1) ||
+ 			(NIL == (bn = option_arg(ALTNAMEFLAG, 1))))    {
+ 			fprintf(stderr,"Illegal syntax using -n name\nusage: %s\n",USAGE);
+ 			roloexit(-1);
+ 		}
+ 	}
+ 	strncpy(basename, bn, BASENAMELEN);
+ 	basename[BASENAMELEN] = '\0';		/* make sure this gets truncated */
+ 
+ 	strcpy(ROLOBAK, basename);	/* copy the basenames in */
+ 	strcpy(ROLODATA, basename);
+ 	strcpy(ROLOLOCK, basename);
+ 	strcpy(ROLOTEMP, basename);
+ 	strcpy(ROLOCOPY, basename);
+ 	strcpy(ROLOPRINT, basename);
+ 
+ 	strcat(ROLOBAK, EXTBAK);	/* then add the extensions */
+ 	strcat(ROLODATA, EXTDAT);
+ 	strcat(ROLOLOCK, EXTLCK);
+ 	strcat(ROLOTEMP, EXTTMP);
+ 	strcat(ROLOCOPY, EXTCPY);
+ 	strcat(ROLOPRINT, EXTTXT);
+ }
+ 
  main (argc,argv) int argc; char *argv[];
  
  {
***************
*** 582,587 ****
--- 627,636 ----
            }
      }
      
+ 	/* init file names rolo will use */
+ 
+ 	init_fnames();
+ 
      /* find the directory in which the rolodex file we want to use is */
      
      not_own_rolodex = option_present(OTHERUSERFLAG);        
*** orig/rolodefs.h	Sun Mar 13 07:59:38 1988
--- rolodefs.h	Sun Mar 13 07:59:09 1988
***************
*** 17,32 ****
  #define SUMMARYFLAG 's'
  #define OTHERUSERFLAG 'u'
  #define READONLYFLAG 'r'
  
! #define LEGAL_OPTIONS "lsru"
  #ifdef VMS
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u use_dir ] "
  #endif
  
  #ifdef UNIX
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u user ] "
  #endif
  
  #ifdef MSDOS
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u use_dir ] "
  #endif
--- 17,33 ----
  #define SUMMARYFLAG 's'
  #define OTHERUSERFLAG 'u'
  #define READONLYFLAG 'r'
+ #define ALTNAMEFLAG 'n'
  
! #define LEGAL_OPTIONS "lsrun"
  #ifdef VMS
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u use_dir -n name] "
  #endif
  
  #ifdef UNIX
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u user -n name] "
  #endif
  
  #ifdef MSDOS
! #define USAGE "rolo [ person1 person2 ...] [ -l -s -r -u use_dir -n name] "
  #endif
*** orig/rolofilz.h	Sun Mar 13 07:52:55 1988
--- rolofilz.h	Sun Mar 13 10:57:00 1988
***************
*** 1,30 ****
  /* rolofilz.h */
  #ifdef UNIX
! #define ROLOBAK ".rolodex~"
! #define ROLODATA ".rolodex.dat"
! #define ROLOPRINT "roloprint.text"
! #define ROLOLOCK ".rolodexdata.lock"
! #define ROLOTEMP ".rolotemp"
! #define ROLOCOPY ".rolocopy"
  #endif
  
! #ifdef VMS
! #define ROLOBAK "rolodex.bak"
! #define ROLODATA "rolodex.data"
! #define ROLOPRINT "roloprint.text"
! #define ROLOLOCK "rolodexdata.lock"
! #define ROLOTEMP "rolotemp.data"
! #define ROLOCOPY "rolocopy.data"
! #endif
! 
! #ifdef MSDOS
! #define ROLOBAK "rolodex.bak"
! #define ROLODATA "rolodex.dat"
! #define ROLOPRINT "roloprnt.txt"
! #define ROLOLOCK "rolodata.lck"
! #define ROLOTEMP "rolotemp.dat"
! #define ROLOCOPY "rolocopy.dat"
! #endif
  
  /* This is now defined in the Makefile (except for VMS) */
  
--- 1,18 ----
  /* rolofilz.h */
+ 
  #ifdef UNIX
! #define BASENAMELEN 9
! #else
! #define BASENAMELEN 8
  #endif
  
! /* these endings are apended to the basename for the database */
! #define EXTBAK	".bak"
! #define EXTDAT	".dat"
! #define EXTTXT	".txt"
! #define EXTLCK	".lck"
! #define EXTTMP	".tmp"
! #define EXTCPY	".cpy"
  
  /* This is now defined in the Makefile (except for VMS) */
  
*** helplib/lockinfo.dos.old	Sat Mar 26 17:26:48 1988
--- helplib/lockinfo.dos	Sun Mar 27 07:58:44 1988
***************
*** 7,16 ****
  
  You can check on the lock file by typing:
  
! DIR <d:>\ROLODATA.LCK  (Where <d:> is your current disk drive, i.e., A:)
  
  If you're on a networked system, and this file is present and you're not
  running rolodex, find out who may be running it.  Otherwise, you can clean up
  by simply typing:
  
! DEL <d:>\ROLODATA.LCK
--- 7,17 ----
  
  You can check on the lock file by typing:
  
! dir <d:>\<name>.lck  (Where <d:> is your current disk drive, i.e., a:,
! and <name> is the name of your rolodex).
  
  If you're on a networked system, and this file is present and you're not
  running rolodex, find out who may be running it.  Otherwise, you can clean up
  by simply typing:
  
! del <d:>\<name>.lck
*** helplib/lockinfo.unx.old	Sat Mar 26 17:27:07 1988
--- helplib/lockinfo.unx	Sun Mar 27 08:04:03 1988
***************
*** 6,12 ****
  
  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
--- 6,12 ----
  
  You can find out who is using your rolodex by typing
  
! ls -l ~/<name>.lck (where <name> is the name of your rolodex).
  
  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
***************
*** 16,22 ****
  (It is possible that someone else is logged in as you, however...)
  Type
  
! rm ~/.rolodexdata.lock
  
  and then you can use your rolodex.
  
--- 16,22 ----
  (It is possible that someone else is logged in as you, however...)
  Type
  
! rm ~/<name>.lck
  
  and then you can use your rolodex.
  
-- 
        Michael Galassi           | If my opinions happen to be the same as
...!tektronix!tessi!percival!nerd | my employer's it is ONLY a coincidence,
...!uunet!littlei!percival!nerd   | of cource coincidences DO happen.