[net.sources] uupath

mark@cbosgd.UUCP (Mark Horton) (07/05/86)

Nice program, but let me show a 1 line shell script that does the
same thing AND doesn't depend on dbm.  (It does, however, depend
on the "look" command, which is in the same category as dbm, it's
from AT&T, in V7, but not in System III or V.  The program does a
binary search on a text file, is fairly short, and someone could
write a public domain version, possibly using public domain code
in smail as a starting point, easily.)  This also assumes your
paths file is sorted with "sort -f", which we recommend:

This program lives in /usr/local/bin/uur, and is used like this
	uur ucbvax
The argument can be any prefix to the name, thus
	uur dec
shows all hosts beginning with "dec".  Kind of like
	egrep ^dec /usr/lib/uucp/paths
but, due to the binary search, is MUCH faster.

	Mark

#! /bin/sh
exec look -f $* /usr/lib/uucp/paths

mikel@codas.ATT.UUCP (Mikel Manitius) (07/09/86)

> Nice program, but let me show a 1 line shell script that does the
> same thing AND doesn't depend on dbm.  (It does, however, depend
> on the "look" command, which is in the same category as dbm, it's
> from AT&T, in V7, but not in System III or V.  The program does a
> binary search on a text file, is fairly short, and someone could
> write a public domain version, possibly using public domain code
> in smail as a starting point, easily.)  This also assumes your
> paths file is sorted with "sort -f", which we recommend:
>  [ ... ]
> 
> 	Mark

That was the first thing I did when I got smail.
It is *very* kludgy, but easy and simple, and it
works!
---------begin route.c---------
main(argc, argv)
int	argc;
char	*argv[];
{
	char	user[BUFSIZ];
	char	domain[BUFSIZ];

	resolve(argv[1], user, domain);
	if(domain[0] == '\0')
		printf("%s\n", user);
	else if(user[0] == '\0')
		printf("%s\n", domain);
	else
		printf("%s!%s\n", user, domain);
}
----------end route.c----------

And add this to your smail Makefile:

----------begin
route:		$(OBJECTS)
		rm -f xmain.c
		sed -e 's/^main/niam/' < main.c > xmain.c
		cc $(CFLAGS) -c xmain.c
		cc $(ROBJECTS) xmain.o route.c -o route
		rm -f xmain.o xmain.c
-----------end

Then do a "make route".
-- 
    ___
   /   \		Mikel Manitius @ AT&T-IS Altamonte Springs, FL
  | RPI |		...{seismo!akgua|ihnp4|cbosgd|mcnc}!codas!mikel
  |  .  | 
\\-------//