Path: utzoo!attcan!uunet!husc6!rice!bcm!soma!masscomp-request
From: sob@cortex.neuro.bcm.tmc.edu (Stan Barber)
Newsgroups: comp.sys.masscomp
Subject: resolver library for MASSCOMP (part 7 of 7)
Message-ID: <1157@gazette.bcm.tmc.edu>
Date: 11 Jul 88 23:52:44 GMT
Sender: usenet@bcm.tmc.edu
Lines: 1201
Approved: masscomp@soma.neuro.bcm.tmc.edu

#! /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:
#	CHANGES
#	Makefile
#	README
#	include
#	res/named/Makefile
#	res/named/gethnamadr.c
#	res/named/sethostent.c
#	resolv.conf
# This archive created: Mon Jul  4 20:48:20 1988
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'CHANGES'" '(704 characters)'
if test -f 'CHANGES'
then
	echo shar: "will not over-write existing file 'CHANGES'"
else
sed 's/^	X//' << \SHAR_EOF > 'CHANGES'
	XChanges to the resolver library and tools for System V and EXCELAN EXOS 205
	Xfront end.
	X
	XBy Stan Barber, Baylor College of Medicine
	X
	XAdded two new compiler definitions. EXOS for EXCELAN specific changes and
	XSYS5 for System V specific changes.
	X
	XThe System V changes mostly involved the including of  instead of
	X and the use of memcpy for bcopy, memcmp for bcmp and memset
	Xfor bzero. One significant change was to change the name of gethostnamadr.c
	Xto gethnamadr.c to fit the filename into 14 characters.
	X
	XThe EXCELAN changes involved retrofiting BSD 4.1c sematics on the BSD 4.[2-3]
	Xsemantics.
	X
	XI added res_compat.c to include inet_ntoa and friends which are not supplied
	Xby EXCELAN.
	X
SHAR_EOF
if test 704 -ne "`wc -c < 'CHANGES'`"
then
	echo shar: "error transmitting 'CHANGES'" '(should have been 704 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(158 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^	X//' << \SHAR_EOF > 'Makefile'
	X#
	X#
	X# Master Makefile for bind
	X#
	X#
	XSHELL=/bin/sh
	X#
	X#
	Xall:
	X	cd res; make ; cd ..
	X	cd tools; make 
	X
	Xclean:
	X	cd res; make clean; cd ..
	X	cd tools; make clean
	X
	X
	X	
SHAR_EOF
if test 158 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 158 characters)'
fi
fi
echo shar: "extracting 'README'" '(1355 characters)'
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
sed 's/^	X//' << \SHAR_EOF > 'README'
	XThis is a revised version of the resolver library supplied with BIND 4.8
	Xplus patches supplied in the bind mailinglist. This version will work
	Xunder SYSTEM V on the Unisys 5000 series of computer with the NET-5000
	Xproduct. It may work on ATT 3B computers. It will also continue to work
	Xon BSD-style computers since none of that code has been changed.
	X
	XTo install this libarary on Unisys 5000 computers do the following:
	X
	XEdit Makefile.resol in both tools and res subdirectories. Make sure
	Xit looks like  the following:
	X
	XCFLAGS=-O -DDEBUG -DEXOS -DSYS5 -I../include -I/usr/include/NET-5000
	X
	XEdit Makefile in tools/nslookup subdirectory so that it looks like:
	X
	XCFLAGS=-O -DEXOS -DSYS5 -I../../include -I/usr/include/NET-5000
	X
	XWrite the files and type "make library" at the unix prompt.
	XGo get a snack. This will take about 20 minutes.
{_	X
	XBecome the super user.
	X
	XCreate a file called /etc/resolv.conf to contain the following information:
	XYour domain suffix ("tmc.edu" or "dec.com" or "nsf.net") and up to three
	Xnameserver addresses.
	X[An EXAMPLE file is called resolv.conf in this directory. DO NOT use this file.
	XCreate your own.]
	X
	XYou can now use the programs nstest and nsquery in the tools subdirectory
	Xto test the system. You do not need to be the superuser to do this.
	X
	XFor more information, see the bind distribution kit.
	X
	X
	XStan Barber
	Xsob@tmc.edu
	X
SHAR_EOF
if test 1355 -ne "`wc -c < 'README'`"
then
	echo shar: "error transmitting 'README'" '(should have been 1355 characters)'
fi
fi
if test ! -d 'include'
then
	echo shar: "creating directory 'include'"
	mkdir 'include'
fi
echo shar: "entering directory 'include'"
cd 'include'
if test ! -d 'arpa'
then
	echo shar: "creating directory 'arpa'"
	mkdir 'arpa'
fi
echo shar: "entering directory 'arpa'"
cd 'arpa'
echo shar: "extracting 'nameser.h'" '(6859 characters)'
if test -f 'nameser.h'
then
	echo shar: "will not over-write existing file 'nameser.h'"
else
sed 's/^	X//' << \SHAR_EOF > 'nameser.h'
	X/*
	X * Copyright (c) 1983 Regents of the University of California.
	X * All rights reserved.  The Berkeley software License Agreement
	X * specifies the terms and conditions for redistribution.
	X *
	X *	@(#)nameser.h	5.17 (Berkeley) 11/17/87
	X */
	X
	X/*
	X * Define constants based on rfc883
	X */
	X#define PACKETSZ	512		/* maximum packet size */
	X#define MAXDNAME	256		/* maximum domain name */
	X#define MAXCDNAME	255		/* maximum compressed domain name */
	X#define MAXLABEL	63		/* maximum length of domain label */
	X	/* Number of bytes of fixed size data in query structure */
	X#define QFIXEDSZ	4
	X	/* number of bytes of fixed size data in resource record */
	X#define RRFIXEDSZ	10
	X
	X/*
	X * Internet nameserver port number
	X */
	X#define NAMESERVER_PORT	53
	X
	X/*
	X * Currently defined opcodes
	X */
	X#define QUERY		0x0		/* standard query */
	X#define IQUERY		0x1		/* inverse query */
	X#define STATUS		0x2		/* nameserver status query */
	X/*#define xxx		0x3		/* 0x3 reserved */
	X	/* non standard */
	X#define UPDATEA		0x9		/* add resource record */
	X#define UPDATED		0xa		/* delete a specific resource record */
	X#define UPDATEDA	0xb		/* delete all nemed resource record */
	X#define UPDATEM		0xc		/* modify a specific resource record */
	X#define UPDATEMA	0xd		/* modify all named resource record */
	X
	X#define ZONEINIT	0xe		/* initial zone transfer */
	X#define ZONEREF		0xf		/* incremental zone referesh */
	X
	X/*
	X * Currently defined response codes
	X */
	X#define NOERROR		0		/* no error */
	X#define FORMERR		1		/* format error */
	X#define SERVFAIL	2		/* server failure */
	X#define NXDOMAIN	3		/* non existent domain */
	X#define NOTIMP		4		/* not implemented */
	X#define REFUSED		5		/* query refused */
	X	/* non standard */
	X#define NOCHANGE	0xf		/* update failed to change db */
	X
	X/*
	X * Type values for resources and queries
	X */
	X#define T_A		1		/* host address */
	X#define T_NS		2		/* authoritative server */
	X#define T_MD		3		/* mail destination */
	X#define T_MF		4		/* mail forwarder */
	X#define T_CNAME		5		/* connonical name */
	X#define T_SOA		6		/* start of authority zone */
	X#define T_MB		7		/* mailbox domain name */
	X#define T_MG		8		/* mail group member */
	X#define T_MR		9		/* mail rename name */
	X#define T_NULL		10		/* null resource record */
	X#define T_WKS		11		/* well known service */
	X#define T_PTR		12		/* domain name pointer */
	X#define T_HINFO		13		/* host information */
	X#define T_MINFO		14		/* mailbox information */
	X#define T_MX		15		/* mail routing information */
	X	/* non standard */
	X#define T_UINFO		100		/* user (finger) information */
	X#define T_UID		101		/* user ID */
	X#define T_GID		102		/* group ID */
	X#define T_UNSPEC	103		/* Unspecified format (binary data) */
	X	/* Query type values which do not appear in resource records */
	X#define T_AXFR		252		/* transfer zone of authority */
	X#define T_MAILB		253		/* transfer mailbox records */
	X#define T_MAILA		254		/* transfer mail agent records */
	X#define T_ANY		255		/* wildcard match */
	X
	X/*
	X * Values for class field
	X */
	X
	X#define C_IN		1		/* the arpa internet */
	X#define C_CHAOS		3		/* for chaos net at MIT */
	X	/* Query class values which do not appear in resource records */
	X#define C_ANY		255		/* wildcard match */
	X
	X/*
	X * Status return codes for T_UNSPEC conversion routines
	X */
	X#define CONV_SUCCESS 0
	X#define CONV_OVERFLOW -1
	X#define CONV_BADFMT -2
	X#define CONV_BADCKSUM -3
	X#define CONV_BADBUFLEN -4
	X
	X/*
	X * Structure for query header, the order of the fields is machine and
	X * compiler dependent, in our case, the bits within a byte are assignd 
	X * least significant first, while the order of transmition is most 
	X * significant first.  This requires a somewhat confusing rearrangement.
	X */
	X
	Xtypedef struct {
	X	u_short	id;		/* query identification number */
	X#if defined (sun) || defined (sel) || defined (pyr) || defined (is68k) \
	X|| defined (tahoe) || defined(tower) || defined(MASSCOMP) || defined (BIT_ZERO_ON_LEFT)
	X	/* Bit zero on left:  Gould and similar architectures */
	X			/* fields in third byte */
	X	u_char	qr:1;		/* response flag */
	X	u_char	opcode:4;	/* purpose of message */
	X	u_char	aa:1;		/* authoritive answer */
	X	u_char	tc:1;		/* truncated message */
	X	u_char	rd:1;		/* recursion desired */
	X			/* fields in fourth byte */
	X	u_char	ra:1;		/* recursion available */
	X	u_char	pr:1;		/* primary server required (non standard) */
	X	u_char	unused:2;	/* unused bits */
	X	u_char	rcode:4;	/* response code */
	X#else
	X#if defined (vax) || defined(ns32000) || defined (BIT_ZERO_ON_RIGHT)
	X	/* Bit zero on right:  VAX */
	X			/* fields in third byte */
	X	u_char	rd:1;		/* recursion desired */
	X	u_char	tc:1;		/* truncated message */
	X	u_char	aa:1;		/* authoritive answer */
	X	u_char	opcode:4;	/* purpose of message */
	X	u_char	qr:1;		/* response flag */
	X			/* fields in fourth byte */
	X	u_char	rcode:4;	/* response code */
	X	u_char	unused:2;	/* unused bits */
	X	u_char	pr:1;		/* primary server required (non standard) */
	X	u_char	ra:1;		/* recursion available */
	X#else
	X#if defined (pdp11) || defined (BIT_ZERO_ON_RIGHT_BUT_COMPILER_STUPID)
	X	/* Bit zero on right, compiler doesn't like u_char bit fields:  PDP */
	X			/* fields in third byte */
	X	u_int	rd:1;		/* recursion desired */
	X	u_int	tc:1;		/* truncated message */
	X	u_int	aa:1;		/* authoritive answer */
	X	u_int	opcode:4;	/* purpose of message */
	X	u_int	qr:1;		/* response flag */
	X			/* fields in fourth byte */
	X	u_int	rcode:4;	/* response code */
	X	u_int	unused:2;	/* unused bits */
	X	u_int	pr:1;		/* primary server required (non standard) */
	X	u_int	ra:1;		/* recursion available */
	X#else
	X	/* you must determine what the correct bit order is for your compiler */
	X	UNDEFINED_BIT_ORDER;
	X#endif
	X#endif
	X#endif
	X			/* remaining bytes */
	X	u_short	qdcount;	/* number of question entries */
	X	u_short	ancount;	/* number of answer entries */
	X	u_short	nscount;	/* number of authority entries */
	X	u_short	arcount;	/* number of resource entries */
	X} HEADER;
	X
	X/*
	X * Defines for handling compressed domain names
	X */
	X#define INDIR_MASK	0xc0
	X
	X/*
	X * Structure for passing resource records around.
	X */
	Xstruct rrec {
	X	short	r_zone;			/* zone number */
	X	short	r_class;		/* class number */
	X	short	r_type;			/* type number */
	X	u_long	r_ttl;			/* time to live */
	X	int	r_size;			/* size of data area */
	X	char	*r_data;		/* pointer to data */
	X};
	X
	Xextern	u_short	_getshort();
	Xextern	u_long	_getlong();
	X
	X/*
	X * Inline versions of get/put short/long.
	X * Pointer is advanced; we assume that both arguments
	X * are lvalues and will already be in registers.
	X * cp MUST be u_char *.
	X */
	X#define GETSHORT(s, cp) { \
	X	(s) = *(cp)++ << 8; \
	X	(s) |= *(cp)++; \
	X}
	X
	X#define GETLONG(l, cp) { \
	X	(l) = *(cp)++ << 8; \
	X	(l) |= *(cp)++; (l) <<= 8; \
	X	(l) |= *(cp)++; (l) <<= 8; \
	X	(l) |= *(cp)++; \
	X}
	X
	X
	X#define PUTSHORT(s, cp) { \
	X	*(cp)++ = (s) >> 8; \
	X	*(cp)++ = (s); \
	X}
	X
	X/*
	X * Warning: PUTLONG destroys its first argument.
	X */
	X#define PUTLONG(l, cp) { \
	X	(cp)[3] = l; \
	X	(cp)[2] = (l >>= 8); \
	X	(cp)[1] = (l >>= 8); \
	X	(cp)[0] = l >> 8; \
	X	(cp) += sizeof(u_long); \
	X}
SHAR_EOF
if test 6859 -ne "`wc -c < 'nameser.h'`"
then
	echo shar: "error transmitting 'nameser.h'" '(should have been 6859 characters)'
fi
fi
echo shar: "done with directory 'arpa'"
cd ..
echo shar: "extracting 'netdb.h'" '(2419 characters)'
if test -f 'netdb.h'
then
	echo shar: "will not over-write existing file 'netdb.h'"
else
sed 's/^	X//' << \SHAR_EOF > 'netdb.h'
	X/*	@(#)netdb.h 1.1 86/07/07 SMI; from UCB	*/
	X/* Modified 87.06.20, S. Levy, adding h_addr_list field to hostent
	X * allowing simultaneous 4.2 and 4.3 compatibility
	X * (including compatibility with existing 4.2 binary library routines).
	X * This file combines 4.2, 4.3, SUN and Cray definitions.
	X * Domain resolver routines set both h_addr and h_addr_list fields.
	X */
	X
	X/*
	X * Structures returned by network
	X * data base library.  All addresses
	X * are supplied in host order, and
	X * returned in network order (suitable
	X * for use in system calls).
	X */
	Xstruct	hostent {
	X	char	*h_name;	/* official name of host */
	X	char	**h_aliases;	/* alias list */
	X	int	h_addrtype;	/* host address type */
	X	int	h_length;	/* length of address */
	X#define	h_addr	h_addr_0	/* Dummy to make resolver think we're 4.3 */
	X	char	*h_addr;	/* This field for 4.2 binary compatibility. */
	X	char	**h_addr_list;	/* list of addresses from name server */
	X};
	X
	X/*
	X * Assumption here is that a network number
	X * fits in 32 bits -- probably a poor one.
	X */
	Xstruct	netent {
	X	char		*n_name;	/* official name of net */
	X	char		**n_aliases;	/* alias list */
	X	int		n_addrtype;	/* net address type */
	X	unsigned long	n_net;		/* network # */
	X};
	X
	Xstruct	servent {
	X	char	*s_name;	/* official service name */
	X	char	**s_aliases;	/* alias list */
	X	int	s_port;		/* port # */
	X	char	*s_proto;	/* protocol to use */
	X};
	X
	Xstruct	protoent {
	X	char	*p_name;	/* official protocol name */
	X	char	**p_aliases;	/* alias list */
	X	int	p_proto;	/* protocol # */
	X};
	X
	Xstruct rpcent {
	X	char	*r_name;	/* name of server for this rpc program */
	X	char	**r_aliases;	/* alias list */
	X	int	r_number;	/* rpc program number */
	X};
	X
	Xstruct hostent	*gethostbyname(), *gethostbyaddr(), *gethostent();
	Xstruct netent	*getnetbyname(), *getnetbyaddr(), *getnetent();
	Xstruct servent	*getservbyname(), *getservbyport(), *getservent();
	Xstruct protoent	*getprotobyname(), *getprotobynumber(), *getprotoent();
	Xstruct rpcent	*getrpcbyname(), *getrpcbynumber(), *getrpcent();
	X
	X/*
	X * Error return codes from gethostbyname() and gethostbyaddr()
	X */
	X
	Xextern  int h_errno;	
	X
	X#define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
	X#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
	X#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
	X#define	NO_DATA		4 /* Valid name, no data record of requested type */
	X#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
SHAR_EOF
if test 2419 -ne "`wc -c < 'netdb.h'`"
then
	echo shar: "error transmitting 'netdb.h'" '(should have been 2419 characters)'
fi
fi
echo shar: "extracting 'netdb.h.4.2'" '(1920 characters)'
if test -f 'netdb.h.4.2'
then
	echo shar: "will not over-write existing file 'netdb.h.4.2'"
else
sed 's/^	X//' << \SHAR_EOF > 'netdb.h.4.2'
	X/*
	X * Copyright (c) 1980 Regents of the University of California.
	X * All rights reserved.  The Berkeley software License Agreement
	X * specifies the terms and conditions for redistribution.
	X *
	X *	@(#)netdb.h	5.8 (Berkeley) 11/18/87
	X */
	X
	X/*
	X * Structures returned by network
	X * data base library.  All addresses
	X * are supplied in host order, and
	X * returned in network order (suitable
	X * for use in system calls).
	X */
	Xstruct	hostent {
	X	char	*h_name;	/* official name of host */
	X	char	**h_aliases;	/* alias list */
	X	int	h_addrtype;	/* host address type */
	X	int	h_length;	/* length of address */
	X	char	*h_addr;	/* address */
	X};
	X
	X/*
	X * Assumption here is that a network number
	X * fits in 32 bits -- probably a poor one.
	X */
	Xstruct	netent {
	X	char		*n_name;	/* official name of net */
	X	char		**n_aliases;	/* alias list */
	X	int		n_addrtype;	/* net address type */
	X	unsigned long	n_net;		/* network # */
	X};
	X
	Xstruct	servent {
	X	char	*s_name;	/* official service name */
	X	char	**s_aliases;	/* alias list */
	X	int	s_port;		/* port # */
	X	char	*s_proto;	/* protocol to use */
	X};
	X
	Xstruct	protoent {
	X	char	*p_name;	/* official protocol name */
	X	char	**p_aliases;	/* alias list */
	X	int	p_proto;	/* protocol # */
	X};
	X
	Xstruct hostent	*gethostbyname(), *gethostbyaddr(), *gethostent();
	Xstruct netent	*getnetbyname(), *getnetbyaddr(), *getnetent();
	Xstruct servent	*getservbyname(), *getservbyport(), *getservent();
	Xstruct protoent	*getprotobyname(), *getprotobynumber(), *getprotoent();
	X
	X/*
	X * Error return codes from gethostbyname() and gethostbyaddr()
	X * (left in extern int h_errno).
	X */
	X
	X#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
	X#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
	X#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
	X#define	NO_DATA		4 /* Valid name, no data record of requested type */
	X#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
SHAR_EOF
if test 1920 -ne "`wc -c < 'netdb.h.4.2'`"
then
	echo shar: "error transmitting 'netdb.h.4.2'" '(should have been 1920 characters)'
fi
fi
echo shar: "extracting 'resolv.h'" '(1773 characters)'
if test -f 'resolv.h'
then
	echo shar: "will not over-write existing file 'resolv.h'"
else
sed 's/^	X//' << \SHAR_EOF > 'resolv.h'
	X
	X/*
	X * Copyright (c) 1983, 1987 Regents of the University of California.
	X * All rights reserved.  The Berkeley software License Agreement
	X * specifies the terms and conditions for redistribution.
	X *
	X *	@(#)resolv.h	5.5 (Berkeley) 5/12/87
	X */
	X
	X/*
	X * Global defines and variables for resolver stub.
	X */
	X
	X
	X#define	MAXNS		3		/* max # name servers we'll track */
	X#define	MAXDNSRCH	3		/* max # default domain levels to try */
	X#define	LOCALDOMAINPARTS 2		/* min levels in name that is "local" */
	X
	X#define	RES_TIMEOUT	4		/* seconds between retries */
	X
	Xstruct state {
	X	int	retrans;	 	/* retransmition time interval */
	X	int	retry;			/* number of times to retransmit */
	X	long	options;		/* option flags - see below. */
	X	int	nscount;		/* number of name servers */
	X	struct	sockaddr_in nsaddr_list[MAXNS];	/* address of name server */
	X#define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
	X	u_short	id;			/* current packet id */
	X	char	defdname[MAXDNAME];	/* default domain */
	X	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
	X};
	X
	X/*
	X * Resolver options
	X */
	X#define RES_INIT	0x0001		/* address initialized */
	X#define RES_DEBUG	0x0002		/* print debug messages */
	X#define RES_AAONLY	0x0004		/* authoritative answers only */
	X#define RES_USEVC	0x0008		/* use virtual circuit */
	X#define RES_PRIMARY	0x0010		/* query primary server only */
	X#define RES_IGNTC	0x0020		/* ignore trucation errors */
	X#define RES_RECURSE	0x0040		/* recursion desired */
	X#define RES_DEFNAMES	0x0080		/* use default domain name */
	X#define RES_STAYOPEN	0x0100		/* Keep TCP socket open */
	X#define RES_DNSRCH	0x0200		/* search up local domain tree */
	X
	X#define RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
	X
	Xextern struct state _res;
	Xextern char *p_cdname(), *p_rr(), *p_type(), *p_class();
SHAR_EOF
if test 1773 -ne "`wc -c < 'resolv.h'`"
then
	echo shar: "error transmitting 'resolv.h'" '(should have been 1773 characters)'
fi
fi
echo shar: "done with directory 'include'"
cd ..
if test ! -d 'res'
then
	echo shar: "creating directory 'res'"
	mkdir 'res'
fi
echo shar: "entering directory 'res'"
cd 'res'
if test ! -d 'named'
then
	echo shar: "creating directory 'named'"
	mkdir 'named'
fi
echo shar: "entering directory 'named'"
cd 'named'
echo shar: "extracting 'Makefile'" '(1767 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^	X//' << \SHAR_EOF > 'Makefile'
	X#
	X# Copyright (c) 1983 Regents of the University of California.
	X# All rights reserved.  The Berkeley software License Agreement
	X# specifies the terms and conditions for redistribution.
	X#
	X#	@(#)Makefile	6.4 (Berkeley) 6/6/87
	X#
	X
	XOBJS=	gethostnamadr.o sethostent.o
	X
	XSRCS=	gethostnamadr.c sethostent.c
	X
	XCFLAGS= -O ${DEFS} -I../../include	# Craig Finseth, MSC, April 1988
	XTAGSFILE= tags
	XDESTDIR=
	X
	X.c.o:
	X	${CC} -p -c ${CFLAGS} $*.c
	X	-ld -X -r $*.o
	X	mv a.out profiled/$*.o
	X	${CC} ${CFLAGS} -c $*.c
	X	-ld -x -r $*.o
	X	mv a.out $*.o
	X
	Xhostlib hostlib_p: ${OBJS} 
	X	@echo "building profiled hostlib"
	X	@cd profiled; ar cru ../hostlib_p ${OBJS}
	X	@echo "building normal hostlib"
	X	@ar cru hostlib ${OBJS}
	X
	Xtags:
	X	cwd=`pwd`; \
	X	for i in ${SRCS}; do \
	X		ctags -a -f ${TAGSFILE} $$cwd/$$i; \
	X	done
	X
	Xclean:
	X	rm -f *.o errs a.out core hostlib hostlib_p profiled/*.o tags
	X
	Xdepend:
	X	mkdep ${CFLAGS} ${SRCS}
	X
	X# DO NOT DELETE THIS LINE -- mkdep uses it.
	X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
	X
	Xgethostnamadr.c:
	Xgethostnamadr.o: gethostnamadr.c /usr/include/sys/param.h
	Xgethostnamadr.o: /usr/include/machine/param.h /usr/include/signal.h
	Xgethostnamadr.o: /usr/include/sys/types.h /usr/include/sys/sysmacros.h
	Xgethostnamadr.o: /usr/include/sys/socket.h /usr/include/netinet/in.h
	Xgethostnamadr.o: /usr/include/ctype.h ../../include/netdb.h
	Xgethostnamadr.o: /usr/include/stdio.h /usr/include/errno.h
	Xgethostnamadr.o: /usr/include/sys/errno.h /usr/include/arpa/inet.h
	Xgethostnamadr.o: ../../include/arpa/nameser.h ../../include/resolv.h
	Xsethostent.c:
	Xsethostent.o: sethostent.c /usr/include/sys/types.h
	Xsethostent.o: /usr/include/sys/sysmacros.h ../../include/arpa/nameser.h
	Xsethostent.o: /usr/include/netinet/in.h ../../include/resolv.h
	X
	X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
SHAR_EOF
if test 1767 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 1767 characters)'
fi
fi
echo shar: "extracting 'gethnamadr.c'" '(8573 characters)'
if test -f 'gethnamadr.c'
then
	echo shar: "will not over-write existing file 'gethnamadr.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'gethnamadr.c'
	X/*
	X * Copyright (c) 1985, 1988 Regents of the University of California.
	X * All rights reserved.
	X *
	X * Redistribution and use in source and binary forms are permitted
	X * provided that this notice is preserved and that due credit is given
	X * to the University of California at Berkeley. The name of the University
	X * may not be used to endorse or promote products derived from this
	X * software without specific prior written permission. This software
	X * is provided ``as is'' without express or implied warranty.
	X */
	X
	X#if defined(LIBC_SCCS) && !defined(lint)
	Xstatic char sccsid[] = "@(#)gethostnamadr.c	6.32 (Berkeley) 4/12/88";
	X#endif /* LIBC_SCCS and not lint */
	X
	X#include 
	X#ifdef EXOS
	X#include 
	X#endif
	X#include 
	X#include 
	X#include 
	X#include 
	X#include 
	X#include 
	X#ifndef EXOS
	X#include 
	X#endif
	X#include 
	X#include 
	X
	X#define	MAXALIASES	35
	X#define	MAXADDRS	35
	X
	Xstatic char *h_addr_ptrs[MAXADDRS + 1];
	X
	Xstatic struct hostent host;
	Xstatic char *host_aliases[MAXALIASES];
	Xstatic char hostbuf[BUFSIZ+1];
	Xstatic struct in_addr host_addr;
	X#ifdef MASSCOMP
	Xstatic char HOSTDB[] = "/etc/net/hosts";
	X#else
	Xstatic char HOSTDB[] = "/etc/hosts";
	X#endif
	Xstatic FILE *hostf = NULL;
	Xstatic char hostaddr[MAXADDRS];
	Xstatic char *host_addrs[2];
	Xstatic int stayopen = 0;
	Xstatic char *any();
	X
	X#if PACKETSZ > 1024
	X#define	MAXPACKET	PACKETSZ
	X#else
	X#define	MAXPACKET	1024
	X#endif
	X
	Xtypedef union {
	X    HEADER hdr;
	X    u_char buf[MAXPACKET];
	X} querybuf;
	X
	Xstatic union {
	X    long al;
	X    char ac;
	X} align;
	X
	X
	Xint h_errno;
	Xextern errno;
	X
	Xstatic struct hostent *
	Xgetanswer(answer, anslen, iquery)
	X	querybuf *answer;
	X	int anslen;
	X	int iquery;
	X{
	X	register HEADER *hp;
	X	register u_char *cp;
	X	register int n;
	X	u_char *eom;
	X	char *bp, **ap;
	X	int type, class, buflen, ancount, qdcount;
	X	int haveanswer, getclass = C_ANY;
	X	char **hap;
	X
	X	eom = answer->buf + anslen;
	X	/*
	X	 * find first satisfactory answer
	X	 */
	X	hp = &answer->hdr;
	X	ancount = ntohs(hp->ancount);
	X	qdcount = ntohs(hp->qdcount);
	X	bp = hostbuf;
	X	buflen = sizeof(hostbuf);
	X	cp = answer->buf + sizeof(HEADER);
	X	if (qdcount) {
	X		if (iquery) {
	X			if ((n = dn_expand((char *)answer->buf, eom,
	X			     cp, bp, buflen)) < 0) {
	X				h_errno = NO_RECOVERY;
	X				return ((struct hostent *) NULL);
	X			}
	X			cp += n + QFIXEDSZ;
	X			host.h_name = bp;
	X			n = strlen(bp) + 1;
	X			bp += n;
	X			buflen -= n;
	X		} else
	X			cp += dn_skipname(cp, eom) + QFIXEDSZ;
	X		while (--qdcount > 0)
	X			cp += dn_skipname(cp, eom) + QFIXEDSZ;
	X	} else if (iquery) {
	X		if (hp->aa)
	X			h_errno = HOST_NOT_FOUND;
	X		else
	X			h_errno = TRY_AGAIN;
	X		return ((struct hostent *) NULL);
	X	}
	X	ap = host_aliases;
	X	host.h_aliases = host_aliases;
	X	hap = h_addr_ptrs;
	X#if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */
	X	host.h_addr_list = h_addr_ptrs;
	X#endif
	X	haveanswer = 0;
	X	while (--ancount >= 0 && cp < eom) {
	X		if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0)
	X			break;
	X		cp += n;
	X		type = _getshort(cp);
	X 		cp += sizeof(u_short);
	X		class = _getshort(cp);
	X 		cp += sizeof(u_short) + sizeof(u_long);
	X		n = _getshort(cp);
	X		cp += sizeof(u_short);
	X		if (type == T_CNAME) {
	X			cp += n;
	X			if (ap >= &host_aliases[MAXALIASES-1])
	X				continue;
	X			*ap++ = bp;
	X			n = strlen(bp) + 1;
	X			bp += n;
	X			buflen -= n;
	X			continue;
	X		}
	X		if (iquery && type == T_PTR) {
	X			if ((n = dn_expand((char *)answer->buf, eom,
	X			    cp, bp, buflen)) < 0) {
	X				cp += n;
	X				continue;
	X			}
	X			cp += n;
	X			host.h_name = bp;
	X			return(&host);
	X		}
	X		if (iquery || type != T_A)  {
	X#ifdef DEBUG
	X			if (_res.options & RES_DEBUG)
	X				printf("unexpected answer type %d, size %d\n",
	X					type, n);
	X#endif
	X			cp += n;
	X			continue;
	X		}
	X		if (haveanswer) {
	X			if (n != host.h_length) {
	X				cp += n;
	X				continue;
	X			}
	X			if (class != getclass) {
	X				cp += n;
	X				continue;
	X			}
	X		} else {
	X			host.h_length = n;
	X			getclass = class;
	X			host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC;
	X			if (!iquery) {
	X				host.h_name = bp;
	X				bp += strlen(bp) + 1;
	X			}
	X		}
	X
	X		bp += sizeof(align) - ((u_long)bp % sizeof(align));
	X
	X		if (bp + n >= &hostbuf[sizeof(hostbuf)]) {
	X#ifdef DEBUG
	X			if (_res.options & RES_DEBUG)
	X				printf("size (%d) too big\n", n);
	X#endif
	X			break;
	X		}
	X#ifdef SYS5
	X		(void)memcpy(*hap++ = bp, cp, n);
	X#else
	X		bcopy(cp, *hap++ = bp, n);
	X#endif
	X		bp +=n;
	X		cp += n;
	X		haveanswer++;
	X	}
	X	if (haveanswer) {
	X		*ap = NULL;
	X#if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */
	X		*hap = NULL;
	X#endif
	X		host.h_addr = h_addr_ptrs[0];
	X		return (&host);
	X	} else {
	X		h_errno = TRY_AGAIN;
	X		return ((struct hostent *) NULL);
	X	}
	X}
	X
	Xstruct hostent *
	Xgethostbyname(name)
	X	char *name;
	X{
	X	querybuf buf;
	X	register char *cp;
	X	int n;
	X	struct hostent *hp;
	X	extern struct hostent *_gethtbyname();
	X
	X	if (name == NULL || *name == '\0') {
	X		h_errno = HOST_NOT_FOUND;
	X		return ((struct hostent *) NULL);
	X	}
	X
	X	/*
	X	 * disallow names consisting only of digits/dots, unless
	X	 * they end in a dot.
	X	 */
	X	if (isdigit(name[0]))
	X		for (cp = name;; ++cp) {
	X			if (!*cp) {
	X				if (*--cp == '.')
	X					break;
	X				h_errno = HOST_NOT_FOUND;
	X				return ((struct hostent *) NULL);
	X			}
	X			if (!isdigit(*cp) && *cp != '.') 
	X				break;
	X		}
	X
	X	if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) {
	X#ifdef DEBUG
	X		if (_res.options & RES_DEBUG)
	X			printf("res_search failed\n");
	X#endif
	X		if (errno == ECONNREFUSED)
	X			return (_gethtbyname(name));
	X		else
	X			return ((struct hostent *) NULL);
	X	}
	X	return (getanswer(&buf, n, 0));
	X}
	X
	Xstruct hostent *
	Xgethostbyaddr(addr, len, type)
	X	char *addr;
	X	int len, type;
	X{
	X	int n;
	X	querybuf buf;
	X	register struct hostent *hp;
	X	char qbuf[MAXDNAME];
	X	extern struct hostent *_gethtbyaddr();
	X	
	X	if (type != AF_INET)
	X		return ((struct hostent *) NULL);
	X	(void)sprintf(qbuf, "%d.%d.%d.%d.in-addr.arpa",
	X		((unsigned)addr[3] & 0xff),
	X		((unsigned)addr[2] & 0xff),
	X		((unsigned)addr[1] & 0xff),
	X		((unsigned)addr[0] & 0xff));
	X	n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf));
	X	if (n < 0) {
	X#ifdef DEBUG
	X		if (_res.options & RES_DEBUG)
	X			printf("res_query failed\n");
	X#endif
	X		if (errno == ECONNREFUSED)
	X			return (_gethtbyaddr(addr, len, type));
	X		return ((struct hostent *) NULL);
	X	}
	X	hp = getanswer(&buf, n, 1);
	X	if (hp == NULL)
	X		return ((struct hostent *) NULL);
	X	hp->h_addrtype = type;
	X	hp->h_length = len;
	X	h_addr_ptrs[0] = (char *)&host_addr;
	X	h_addr_ptrs[1] = (char *)0;
	X	host_addr = *(struct in_addr *)addr;
	X	return(hp);
	X}
	X
	X_sethtent(f)
	X	int f;
	X{
	X	if (hostf == NULL)
	X		hostf = fopen(HOSTDB, "r" );
	X	else
	X		rewind(hostf);
	X	stayopen |= f;
	X}
	X
	X_endhtent()
	X{
	X	if (hostf && !stayopen) {
	X		(void) fclose(hostf);
	X		hostf = NULL;
	X	}
	X}
	X
	Xstruct hostent *
	X_gethtent()
	X{
	X	char *p;
	X	register char *cp, **q;
	X
	X	if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL)
	X		return (NULL);
	Xagain:
	X	if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL)
	X		return (NULL);
	X	if (*p == '#')
	X		goto again;
	X	cp = any(p, "#\n");
	X	if (cp == NULL)
	X		goto again;
	X	*cp = '\0';
	X	cp = any(p, " \t");
	X	if (cp == NULL)
	X		goto again;
	X	*cp++ = '\0';
	X	/* THIS STUFF IS INTERNET SPECIFIC */
	X#if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */
	X	host.h_addr_list = host_addrs;
	X#endif
	X	host.h_addr = hostaddr;
	X	*((u_long *)host.h_addr) = inet_addr(p);
	X	host.h_length = sizeof (u_long);
	X	host.h_addrtype = AF_INET;
	X	while (*cp == ' ' || *cp == '\t')
	X		cp++;
	X	host.h_name = cp;
	X	q = host.h_aliases = host_aliases;
	X	cp = any(cp, " \t");
	X	if (cp != NULL) 
	X		*cp++ = '\0';
	X	while (cp && *cp) {
	X		if (*cp == ' ' || *cp == '\t') {
	X			cp++;
	X			continue;
	X		}
	X		if (q < &host_aliases[MAXALIASES - 1])
	X			*q++ = cp;
	X		cp = any(cp, " \t");
	X		if (cp != NULL)
	X			*cp++ = '\0';
	X	}
	X	*q = NULL;
	X	return (&host);
	X}
	X
	Xstatic char *
	Xany(cp, match)
	X	register char *cp;
	X	char *match;
	X{
	X	register char *mp, c;
	X
	X	while (c = *cp) {
	X		for (mp = match; *mp; mp++)
	X			if (*mp == c)
	X				return (cp);
	X		cp++;
	X	}
	X	return ((char *)0);
	X}
	X
	Xstruct hostent *
	X_gethtbyname(name)
	X	char *name;
	X{
	X	register struct hostent *p;
	X	register char **cp;
	X	
	X	_sethtent(0);
	X	while (p = _gethtent()) {
	X		if (strcasecmp(p->h_name, name) == 0)
	X			break;
	X		for (cp = p->h_aliases; *cp != 0; cp++)
	X			if (strcasecmp(*cp, name) == 0)
	X				goto found;
	X	}
	Xfound:
	X	_endhtent();
	X	return (p);
	X}
	X
	Xstruct hostent *
	X_gethtbyaddr(addr, len, type)
	X	char *addr;
	X	int len, type;
	X{
	X	register struct hostent *p;
	X
	X	_sethtent(0);
	X	while (p = _gethtent())
	X#ifdef SYS5
	X		if (p->h_addrtype == type && !memcmp(p->h_addr, addr, len))
	X#else
	X		if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len))
	X#endif
	X			break;
	X	_endhtent();
	X	return (p);
	X}
SHAR_EOF
if test 8573 -ne "`wc -c < 'gethnamadr.c'`"
then
	echo shar: "error transmitting 'gethnamadr.c'" '(should have been 8573 characters)'
fi
fi
echo shar: "extracting 'sethostent.c'" '(698 characters)'
if test -f 'sethostent.c'
then
	echo shar: "will not over-write existing file 'sethostent.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'sethostent.c'
	X/*
	X * Copyright (c) 1985 Regents of the University of California.
	X * All rights reserved.  The Berkeley software License Agreement
	X * specifies the terms and conditions for redistribution.
	X */
	X
	X#if defined(LIBC_SCCS) && !defined(lint)
	Xstatic char sccsid[] = "@(#)sethostent.c	6.3 (Berkeley) 4/10/86";
	X#endif LIBC_SCCS and not lint
	X
	X#include 
	X#ifdef EXOS
	X#include 
	X#endif
	X#include 
	X#include 
	X#include 
	X
	Xsethostent(stayopen)
	X{
	X	if (stayopen)
	X		_res.options |= RES_STAYOPEN | RES_USEVC;
	X}
	X
	Xendhostent()
	X{
	X	_res.options &= ~(RES_STAYOPEN | RES_USEVC);
	X	_res_close();
	X}
	X
	Xsethostfile(name)
	Xchar *name;
	X{
	X#ifdef lint
	Xname = name;
	X#endif
	X}
SHAR_EOF
if test 698 -ne "`wc -c < 'sethostent.c'`"
then
	echo shar: "error transmitting 'sethostent.c'" '(should have been 698 characters)'
fi
fi
echo shar: "done with directory 'named'"
cd ..
echo shar: "done with directory 'res'"
cd ..
echo shar: "extracting 'resolv.conf'" '(508 characters)'
if test -f 'resolv.conf'
then
	echo shar: "will not over-write existing file 'resolv.conf'"
else
sed 's/^	X//' << \SHAR_EOF > 'resolv.conf'
	X#
	X# Sample resolv.conf file
	X#
	X# First, your domain suffix. This suffix will be appended to any
	X# hostname that does not contain dots.
	Xdomain snort.edu
	X# Now, the internet addresses of the name servers you want
	X# to use. A good rule here is to query servers on your local net first
	X# and this query those else where. You can have up to three servers here.
	Xnameserver 55.0.0.1
	Xnameserver 135.0.0.2
	Xnameserver 195.0.0.3
	X# note: these are not real internet addreses. Replace them with the
	X# real information!
	X#
	X
SHAR_EOF
if test 508 -ne "`wc -c < 'resolv.conf'`"
then
	echo shar: "error transmitting 'resolv.conf'" '(should have been 508 characters)'
fi
fi
exit 0
#	End of shell archive
The MASSCOMP USERS' SOCIETY newsgroup is comp.sys.masscomp.
Articles to: masscomp@soma.bcm.tmc.edu or uunet!soma.bcm.tmc.edu!masscomp
Administrative stuff: masscomp-request@soma.bcm.tmc.edu
Stan Barber, Moderator