[net.sources] Some more on Pathalias

bbanerje@sjuvax.UUCP (B. Banerjee) (12/23/83)

Many thanks to all who responded to my frenzied pleas for aid regarding
the dbm routines.  Some points about these. 


a.	The DBM routines are proprietary.  They are included with
   V7, 32V and 4.xBSD.  They are available if you are running USG III
   or V.  They are *not* available if you run V6, PWB or a UNIX lookalike

b.	I can't post the dbm routines because they're proprietary.
   However, a solution is available.  Included with this is are
		1) A (slightly) different version of paths/run, to
		   replace that sent out in my previous posting.

		2) A different version of uupath.c which mimics the
		   one posted previously, but doesn't utilize the
		   dbm routines.

		3) The man entry for uupath which was inadvertently
		   left out of the previous posting.

You should take the -DDBM out of CFLAGS in the Makefile.  You should
also delete the -ldbm loader option in the Makefile as well.  The
remainder of the process is as described previously.
You can still find the shortest route via pathalias with these.  However
you won't be able to use Bill Seboks mods to readnews and vnews to 
use this routing info. 

c.	The uudecode enquiry was just stupidity on my part.  I didn't
know where the dbm sources lived (I've just been using UNIX for a 
couple of months), so I had the brilliant idea of encoding libdbm.a
and mailing it.... I know! Before you jump on me for that; my excuse is
that I posted this late at night while in the throes of insomnia -
so I wasn't thinking too well.  That's also my excuse for the double
posting.

d.	The original version of uupath.c ( Bill's) has a minor error
in it.  The diff change is shown below.

	18c19
	<   if (argc <2 && argc >3) {
	---
	>   if (argc<2 || argc>3) {

e.	Bob Esposito (bpa!espo) got an out of memory error when
trying to compile pathalias.  As I couldn't duplicate the problem
on our VAX 780, I haven't the slightest idea as to what the solution
may be.  Mail him directly if you can help.

	Happy Holidays to all.
	(except poor me with 5 finals to grade!)

	Binayak Banerjee
{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje

---------------- Cut here and feed to /bin/sh ----------------
: Run this shell script with "sh" not "csh"
PATH=:/bin:/usr/bin:/usr/ucb
export PATH
all=FALSE
if [ $1x = -ax ]; then
	all=TRUE
fi
/bin/echo 'Extracting run'
sed 's/^X//' <<'//go.sysin dd *' >run

#! /bin/sh 
# run this shell script in this directory to update your mail database
SITE=sjuvax
T=/tmp/pa$$
D=/usr/lib/uucp
trap "rm -f $T; exit" 0 1 2 3 15
cat paths.sites/* > $T
pathalias -p -w -l${SITE} \
	$T \
	paths.std/path.uucp \
	paths.std/path.usenet \
	paths.misc/paths.kolstad \
 > alpath 2>unreach
  sort +1 alpath  >${D}/Mailroutes
( echo "	uucp"; echo "#sites	hops" ;\
	sed 's/[^!]//g' < alpath | sort | uniq -c ) >results
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 755 run
	/bin/echo -n '	'; /bin/ls -ld run
fi
/bin/echo 'Extracting uupath.1'
sed 's/^X//' <<'//go.sysin dd *' >uupath.1
X.TH UUPATH 1l local
X.SH NAME
uupath \- look up the network path to a computer in the system database.
X.SH SYNOPSIS
X.B uupath
site [ dbase ]
X.SH DESCRIPTION
X.PP
X.I Uupath
takes the site-name of a computer, looks it up in the system wide data base, and
prints out the network path to that site.  This is the same data base as is
used by 
X.I mail
to find network paths to other computers.
X.PP
One can specify an alternate data base with the optional 2nd parameter "dbase".
This data base must be a pair of files created by the
X.I dbm(3)
routines and have names of the form dbase.dir and dbase.pag.
X.SH FILES
X/usr/lib/uucp/alpath.dir,  /usr/lib/uucp/alpath.pag
X.SH SEE ALSO
pathalias(1l), dbm(3)
X.SH AUTHOR
William L. Sebok (Nov. 4, 1983)
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 uupath.1
	/bin/echo -n '	'; /bin/ls -ld uupath.1
fi
/bin/echo 'Extracting uupath.c'
sed 's/^X//' <<'//go.sysin dd *' >uupath.c
X/* uupath.c site [route file]
*
* Compile with 
* cc -O -s uupath.c -o uupath
*
* Use in order to find the path to a given site on the uucp network.
* The routefile is the output of Pathalias, sorted in ascending order
* on the second field.
*
* The code for this was my own.  The conception was stolen from 
* Bill Sebok (astrovax!wls).  Pathalias was authored by Steve Bellovin
* (ulysses!smb).
*
*	Enjoy,
*		Binayak Banerjee
*		St. Joseph's University
*	{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje
*		December 23, 1983
*/
#include <stdio.h>
#define ROUTES "/usr/lib/uucp/Mailroutes" /* default routes database */
#define SITE_SIZE 15
#define PATH_SIZE 100

main (argc, argv)

int argc;
char *argv[];
{	
	FILE *fp, *fopen();
	char site[SITE_SIZE], path[PATH_SIZE], *tp;
	short comp;
	if ((argc <2) || (argc > 3)) {
		fprintf(stderr,"usage : %s sitename [routefile]\n",argv[0]);
		exit(0);
	}
	if ((fp = fopen((argc > 2) ? argv[2] : ROUTES, "r")) == NULL) {
		fprintf(stderr, "cannot open database %s\n",
		(argc == 3)? argv[2] : ROUTES);
		exit(0);
	}
	while (fscanf(fp,"%*s %s %s \n", site, path) != EOF) {
		comp = strcmp(site, argv[1]);
		if (comp > 0) break;
		if (! comp) {
			tp = rindex(path, '!');
			*tp = '\0';
			fprintf(stdout,"%s\n", path);
			exit(0);
		}
	}
	fprintf(stderr,"%s not found\n", argv[1]);
	exit(0);
}
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 uupath.c
	/bin/echo -n '	'; /bin/ls -ld uupath.c
fi
-- 


				Binayak Banerjee
		{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje