*** CHANGES	1996/05/23 08:21:20	8.35
--- CHANGES	1996/05/31 17:42:49
***************
*** 1,4 ****
--- 1,12 ----
  $Id: CHANGES,v 8.35 1996/05/23 08:21:20 vixie Exp vixie $
  
+ 	--- 4.9.4-t4a released ---
+ 
+ 631. [bug]	nslookup was dumping core on bad 'server' commands.
+ 
+ 630. [bug]	dig was not able to print SRV RRs.
+ 
+ 629. [bug]	dig was seeing artificial protocol errors printing AAAA RRs.
+ 
  	--- 4.9.4-t3b released ---
  
*** Makefile	1996/05/23 08:21:20	8.34
--- Makefile	1996/05/31 17:42:39
***************
*** 57,61 ****
  ## --Copyright--
  
! VER = 4.9.4-T3B
  SHELL = /bin/sh
  MAKE = make
--- 57,61 ----
  ## --Copyright--
  
! VER = 4.9.4-T4A
  SHELL = /bin/sh
  MAKE = make
*** compat/lib/Makefile	1995/06/19 20:55:25	8.4
--- compat/lib/Makefile	1996/05/31 17:43:46
***************
*** 73,80 ****
  AROBJS= ${ARPREF} ${OBJS} ${ARSUFF}
  
! SRCS=	mktemp.c strcasecmp.c strerror.c strpbrk.c strtoul.c \
  	putenv.c setenv.c setitimer.c writev.c ftruncate.c gettimeofday.c
  
! OBJS=	mktemp.o strcasecmp.o strerror.o strpbrk.o strtoul.o \
  	putenv.o setenv.o setitimer.o writev.o ftruncate.o gettimeofday.o
  
--- 73,80 ----
  AROBJS= ${ARPREF} ${OBJS} ${ARSUFF}
  
! SRCS=	mktemp.c strcasecmp.c strerror.c strpbrk.c strtoul.c strdup.c \
  	putenv.c setenv.c setitimer.c writev.c ftruncate.c gettimeofday.c
  
! OBJS=	mktemp.o strcasecmp.o strerror.o strpbrk.o strtoul.o strdup.o \
  	putenv.o setenv.o setitimer.o writev.o ftruncate.o gettimeofday.o
  
*** compat/lib/strdup.c	1996/05/31 18:06:25	8.1
--- compat/lib/strdup.c	1996/05/31 17:48:01
***************
*** 0 ****
--- 1,40 ----
+ #include "../../conf/portability.h"
+ 
+ #if !defined(NEED_STRDUP)
+ int __bindcompat_strdup;
+ #else
+ /* Copyright (c) 1996 by Internet Software Consortium.
+  *
+  * Permission to use, copy, modify, and distribute this software for any
+  * purpose with or without fee is hereby granted, provided that the above
+  * copyright notice and this permission notice appear in all copies.
+  *
+  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+  * SOFTWARE.
+  */
+ 
+ #if defined(LINT) && !defined(CODECENTER)
+ static char rcsid[] = "$Id:$";
+ #endif
+ 
+ /*
+  * Make a copy of a string and return a pointer to it.
+  */
+ char *
+ strdup(str)
+ 	const char *str;
+ {
+ 	char *cp = (char *) malloc(strlen(str) + sizeof '\0');
+ 
+ 	if (cp)
+ 		strcpy(cp, str);
+ 	return (cp);
+ }
+ 
+ #endif
*** conf/portability.h	1996/05/20 15:09:55	8.12
--- conf/portability.h	1996/05/31 17:50:43
***************
*** 246,249 ****
--- 246,250 ----
  
  # define NEED_STRTOUL
+ # define NEED_STRDUP
  
  # define STDIN_FILENO	0
***************
*** 585,587 ****
--- 586,592 ----
  #if defined(SVR4) && defined(sun)
  extern int gethostname __P((char *, size_t));
+ #endif
+ 
+ #ifdef NEED_STRDUP
+ extern char *strdup __P((const char *));
  #endif
*** include/resolv.h	1996/05/22 04:56:29	8.10
--- include/resolv.h	1996/05/31 16:07:09
***************
*** 190,193 ****
--- 190,195 ----
  #define	res_mailok	__res_mailok
  #define	res_dnok	__res_dnok
+ #define	loc_ntoa	__loc_ntoa
+ #define	loc_aton	__loc_aton
  #define	dn_skipname	__dn_skipname
  #define	fp_query	__fp_query
***************
*** 213,216 ****
--- 215,220 ----
  int	 __res_mailok __P((const char *));
  int	 __res_dnok __P((const char *));
+ int	 __loc_aton __P((const char *ascii, u_char *binary));
+ char *	 __loc_ntoa __P((const u_char *binary, char *ascii));
  int	 __dn_skipname __P((const u_char *, const u_char *));
  void	 __fp_resstat __P((struct __res_state *, FILE *));
*** named/db_dump.c	1996/05/21 07:04:34	8.12
--- named/db_dump.c	1996/05/31 16:14:14
***************
*** 573,579 ****
  			}
  #ifdef LOC_RR
! 			case T_LOC:
! 				(void) fputs(loc_ntoa(dp->d_data, NULL), fp);
  				break;
  #endif /* LOC_RR */
  			case T_UINFO:
--- 573,582 ----
  			}
  #ifdef LOC_RR
! 			case T_LOC: {
! 				char t[256];
! 
! 				(void) fputs(loc_ntoa(dp->d_data, t), fp);
  				break;
+ 			}
  #endif /* LOC_RR */
  			case T_UINFO:
*** named/db_func.h	1996/05/09 05:59:10	8.8
--- named/db_func.h	1996/05/31 16:04:16
***************
*** 94,101 ****
  struct invbuf		*saveinv __P((void));
  #endif
- #ifdef LOC_RR
- extern u_int32_t	loc_aton __P((const char *ascii, u_char *binary));
- extern char *		loc_ntoa __P((const u_char *binary, char *ascii));
- #endif
  extern char *		ctimel __P((long));
  extern struct in_addr	data_inaddr __P((const u_char *data));
--- 94,97 ----
*** named/db_glue.c	1996/05/21 07:32:38	8.12
--- named/db_glue.c	1996/05/31 17:47:55
***************
*** 432,441 ****
  	const char *str;
  {
! 	char *cp;
  
- 	cp = (char *)malloc(strlen(str) + 1);
  	if (!cp)
  		panic(errno, "malloc(savestr)");
- 	strcpy(cp, str);
  	return (cp);
  }
--- 432,439 ----
  	const char *str;
  {
! 	char *cp = strdup(str);
  
  	if (!cp)
  		panic(errno, "malloc(savestr)");
  	return (cp);
  }
***************
*** 761,1151 ****
  	return (strncasecmp(cp, b, lb)==0);
  }
- 
- #ifdef LOC_RR
- /*
-  * routines to convert between on-the-wire RR format and zone file format.
-  * Does not contain conversion to/from decimal degrees; divide or multiply
-  * by 60*60*1000 for that.
-  */
- 
- static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
- 				      1000000,10000000,100000000,1000000000};
- 
- /* takes an XeY precision/size value, returns a string representation. */
- static const char *
- precsize_ntoa(prec)
- 	u_int8_t prec;
- {
- 	static char retbuf[sizeof("90000000.00")];
- 	unsigned long val;
- 	int mantissa, exponent;
- 
- 	mantissa = (int)((prec >> 4) & 0x0f) % 10;
- 	exponent = (int)((prec >> 0) & 0x0f) % 10;
- 
- 	val = mantissa * poweroften[exponent];
- 
- 	(void) sprintf(retbuf, "%ld.%.2ld", val/100, val%100);
- 	return (retbuf);
- }
- 
- /* converts ascii size/precision X * 10**Y(cm) to 0xXY.  moves pointer. */
- static u_int8_t
- precsize_aton(strptr)
- 	char **strptr;
- {
- 	unsigned int mval = 0, cmval = 0;
- 	u_int8_t retval = 0;
- 	register char *cp;
- 	register int exponent;
- 	register int mantissa;
- 
- 	cp = *strptr;
- 
- 	while (isdigit(*cp))
- 		mval = mval * 10 + (*cp++ - '0');
- 
- 	if (*cp == '.') {		/* centimeters */
- 		cp++;
- 		if (isdigit(*cp)) {
- 			cmval = (*cp++ - '0') * 10;
- 			if (isdigit(*cp)) {
- 				cmval += (*cp++ - '0');
- 			}
- 		}
- 	}
- 	cmval = (mval * 100) + cmval;
- 
- 	for (exponent = 0; exponent < 9; exponent++)
- 		if (cmval < poweroften[exponent+1])
- 			break;
- 
- 	mantissa = cmval / poweroften[exponent];
- 	if (mantissa > 9)
- 		mantissa = 9;
- 
- 	retval = (mantissa << 4) | exponent;
- 
- 	*strptr = cp;
- 
- 	return (retval);
- }
- 
- /* converts ascii lat/lon to unsigned encoded 32-bit number.  moves pointer. */
- static u_int32_t
- latlon2ul(latlonstrptr,which)
- 	char **latlonstrptr;
- 	int *which;
- {
- 	register char *cp;
- 	u_int32_t retval;
- 	int deg = 0, min = 0, secs = 0, secsfrac = 0;
- 
- 	cp = *latlonstrptr;
- 
- 	while (isdigit(*cp))
- 		deg = deg * 10 + (*cp++ - '0');
- 
- 	while (isspace(*cp))
- 		cp++;
- 
- 	if (!(isdigit(*cp)))
- 		goto fndhemi;
- 
- 	while (isdigit(*cp))
- 		min = min * 10 + (*cp++ - '0');
- 
- 	while (isspace(*cp))
- 		cp++;
- 
- 	if (!(isdigit(*cp)))
- 		goto fndhemi;
- 
- 	while (isdigit(*cp))
- 		secs = secs * 10 + (*cp++ - '0');
- 
- 	if (*cp == '.') {		/* decimal seconds */
- 		cp++;
- 		if (isdigit(*cp)) {
- 			secsfrac = (*cp++ - '0') * 100;
- 			if (isdigit(*cp)) {
- 				secsfrac += (*cp++ - '0') * 10;
- 				if (isdigit(*cp)) {
- 					secsfrac += (*cp++ - '0');
- 				}
- 			}
- 		}
- 	}
- 
- 	while (!isspace(*cp))	/* if any trailing garbage */
- 		cp++;
- 
- 	while (isspace(*cp))
- 		cp++;
- 
-  fndhemi:
- 	switch (*cp) {
- 	case 'N': case 'n':
- 	case 'E': case 'e':
- 		retval = ((unsigned)1<<31)
- 			+ (((((deg * 60) + min) * 60) + secs) * 1000)
- 			+ secsfrac;
- 		break;
- 	case 'S': case 's':
- 	case 'W': case 'w':
- 		retval = ((unsigned)1<<31)
- 			- (((((deg * 60) + min) * 60) + secs) * 1000)
- 			- secsfrac;
- 		break;
- 	default:
- 		retval = 0;	/* invalid value -- indicates error */
- 		break;
- 	}
- 
- 	switch (*cp) {
- 	case 'N': case 'n':
- 	case 'S': case 's':
- 		*which = 1;	/* latitude */
- 		break;
- 	case 'E': case 'e':
- 	case 'W': case 'w':
- 		*which = 2;	/* longitude */
- 		break;
- 	default:
- 		*which = 0;	/* error */
- 		break;
- 	}
- 
- 	cp++;			/* skip the hemisphere */
- 
- 	while (!isspace(*cp))	/* if any trailing garbage */
- 		cp++;
- 
- 	while (isspace(*cp))	/* move to next field */
- 		cp++;
- 
- 	*latlonstrptr = cp;
- 
- 	return (retval);
- }
- 
- /* converts a zone file representation in a string to an RDATA on-the-wire
-  * representation. */
- u_int32_t
- loc_aton(ascii, binary)
- 	const char *ascii;
- 	u_char *binary;
- {
- 	const char *cp, *maxcp;
- 	u_char *bcp;
- 
- 	u_int32_t latit = 0, longit = 0, alt = 0;
- 	u_int32_t lltemp1 = 0, lltemp2 = 0;
- 	int altmeters = 0, altfrac = 0, altsign = 1;
- 	u_int8_t hp = 0x16;	/* default = 1e6 cm = 10000.00m = 10km */
- 	u_int8_t vp = 0x13;	/* default = 1e3 cm = 10.00m */
- 	u_int8_t siz = 0x12;	/* default = 1e2 cm = 1.00m */
- 	int which1 = 0, which2 = 0;
- 
- 	cp = ascii;
- 	maxcp = cp + strlen(ascii);
- 
- 	lltemp1 = latlon2ul(&cp, &which1);
- 
- 	lltemp2 = latlon2ul(&cp, &which2);
- 
- 	switch (which1 + which2) {
- 	case 3:			/* 1 + 2, the only valid combination */
- 		if ((which1 == 1) && (which2 == 2)) { /* normal case */
- 			latit = lltemp1;
- 			longit = lltemp2;
- 		} else if ((which1 == 2) && (which2 == 1)) { /* reversed */
- 			longit = lltemp1;
- 			latit = lltemp2;
- 		} else {	/* some kind of brokenness */
- 			return 0;
- 		}
- 		break;
- 	default:		/* we didn't get one of each */
- 		return 0;
- 	}
- 
- 	/* altitude */
- 	if (*cp == '-') {
- 		altsign = -1;
- 		cp++;
- 	}
-     
- 	if (*cp == '+')
- 		cp++;
- 
- 	while (isdigit(*cp))
- 		altmeters = altmeters * 10 + (*cp++ - '0');
- 
- 	if (*cp == '.') {		/* decimal meters */
- 		cp++;
- 		if (isdigit(*cp)) {
- 			altfrac = (*cp++ - '0') * 10;
- 			if (isdigit(*cp)) {
- 				altfrac += (*cp++ - '0');
- 			}
- 		}
- 	}
- 
- 	alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));
- 
- 	while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
- 		cp++;
- 
- 	while (isspace(*cp) && (cp < maxcp))
- 		cp++;
- 
- 	if (cp >= maxcp)
- 		goto defaults;
- 
- 	siz = precsize_aton(&cp);
- 	
- 	while (!isspace(*cp) && (cp < maxcp))	/* if trailing garbage or m */
- 		cp++;
- 
- 	while (isspace(*cp) && (cp < maxcp))
- 		cp++;
- 
- 	if (cp >= maxcp)
- 		goto defaults;
- 
- 	hp = precsize_aton(&cp);
- 
- 	while (!isspace(*cp) && (cp < maxcp))	/* if trailing garbage or m */
- 		cp++;
- 
- 	while (isspace(*cp) && (cp < maxcp))
- 		cp++;
- 
- 	if (cp >= maxcp)
- 		goto defaults;
- 
- 	vp = precsize_aton(&cp);
- 
-  defaults:
- 
- 	bcp = binary;
- 	*bcp++ = (u_int8_t) 0;	/* version byte */
- 	*bcp++ = siz;
- 	*bcp++ = hp;
- 	*bcp++ = vp;
- 	PUTLONG(latit,bcp);
- 	PUTLONG(longit,bcp);
- 	PUTLONG(alt,bcp);
-     
- 	return (16);		/* size of RR in octets */
- }
- 
- /* takes an on-the-wire LOC RR and prints it in zone file (human readable)
-    format. */
- char *
- loc_ntoa(binary,ascii)
- 	const u_char *binary;
- 	char *ascii;
- {
- 	static char tmpbuf[255*3];
- 
- 	register char *cp;
- 	register const u_char *rcp;
- 
- 	int latdeg, latmin, latsec, latsecfrac;
- 	int longdeg, longmin, longsec, longsecfrac;
- 	char northsouth, eastwest;
- 	int altmeters, altfrac, altsign;
- 
- 	const int referencealt = 100000 * 100;
- 
- 	int32_t latval, longval, altval;
- 	u_int32_t templ;
- 	u_int8_t sizeval, hpval, vpval, versionval;
-     
- 	char *sizestr, *hpstr, *vpstr;
- 
- 	rcp = binary;
- 	cp = (ascii != NULL) ? ascii : tmpbuf;
- 
- 	versionval = *rcp++;
- 
- 	if (versionval) {
- 		sprintf(cp,"; error: unknown LOC RR version");
- 		return (cp);
- 	}
- 
- 	sizeval = *rcp++;
- 
- 	hpval = *rcp++;
- 	vpval = *rcp++;
- 
- 	GETLONG(templ,rcp);
- 	latval = (templ - ((unsigned)1<<31));
- 
- 	GETLONG(templ,rcp);
- 	longval = (templ - ((unsigned)1<<31));
- 
- 	GETLONG(templ,rcp);
- 	if (templ < referencealt) { /* below WGS 84 spheroid */
- 		altval = referencealt - templ;
- 		altsign = -1;
- 	} else {
- 		altval = templ - referencealt;
- 		altsign = 1;
- 	}
- 
- 	if (latval < 0) {
- 		northsouth = 'S';
- 		latval = -latval;
- 	}
- 	else
- 		northsouth = 'N';
- 
- 	latsecfrac = latval % 1000;
- 	latval = latval / 1000;
- 	latsec = latval % 60;
- 	latval = latval / 60;
- 	latmin = latval % 60;
- 	latval = latval / 60;
- 	latdeg = latval;
- 
- 	if (longval < 0) {
- 		eastwest = 'W';
- 		longval = -longval;
- 	}
- 	else
- 		eastwest = 'E';
- 
- 	longsecfrac = longval % 1000;
- 	longval = longval / 1000;
- 	longsec = longval % 60;
- 	longval = longval / 60;
- 	longmin = longval % 60;
- 	longval = longval / 60;
- 	longdeg = longval;
- 
- 	altfrac = altval % 100;
- 	altmeters = (altval / 100) * altsign;
- 
- 	sizestr = savestr(precsize_ntoa(sizeval));
- 	hpstr = savestr(precsize_ntoa(hpval));
- 	vpstr = savestr(precsize_ntoa(vpval));
- 
- 	sprintf(cp,
- 		"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",
- 		latdeg, latmin, latsec, latsecfrac, northsouth,
- 		longdeg, longmin, longsec, longsecfrac, eastwest,
- 		altmeters, altfrac, sizestr, hpstr, vpstr);
- 
- 	free(sizestr);
- 	free(hpstr);
- 	free(vpstr);
- 
- 	return (cp);
- }
- 
- #endif /* LOC_RR */
  
  /*
--- 759,762 ----
*** res/res_debug.c	1996/05/21 07:51:24	8.10
--- res/res_debug.c	1996/05/31 18:00:05
***************
*** 597,600 ****
--- 597,609 ----
  
  		fprintf(file, "\t%s\n", inet_ntop(AF_INET6, cp, t, sizeof t));
+ 		cp += dlen;
+ 		break;
+ 	}
+ 
+ 	case T_LOC: {
+ 		char t[255];
+ 
+ 		(void) fprintf(file, "\t%s\n", loc_ntoa(cp, t));
+ 		cp += dlen;
  		break;
  	}
***************
*** 831,833 ****
--- 840,1224 ----
  	}
  	return (nbuf);
+ }
+ 
+ /*
+  * routines to convert between on-the-wire RR format and zone file format.
+  * Does not contain conversion to/from decimal degrees; divide or multiply
+  * by 60*60*1000 for that.
+  */
+ 
+ static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
+ 				      1000000,10000000,100000000,1000000000};
+ 
+ /* takes an XeY precision/size value, returns a string representation. */
+ static const char *
+ precsize_ntoa(prec)
+ 	u_int8_t prec;
+ {
+ 	static char retbuf[sizeof("90000000.00")];
+ 	unsigned long val;
+ 	int mantissa, exponent;
+ 
+ 	mantissa = (int)((prec >> 4) & 0x0f) % 10;
+ 	exponent = (int)((prec >> 0) & 0x0f) % 10;
+ 
+ 	val = mantissa * poweroften[exponent];
+ 
+ 	(void) sprintf(retbuf, "%ld.%.2ld", val/100, val%100);
+ 	return (retbuf);
+ }
+ 
+ /* converts ascii size/precision X * 10**Y(cm) to 0xXY.  moves pointer. */
+ static u_int8_t
+ precsize_aton(strptr)
+ 	char **strptr;
+ {
+ 	unsigned int mval = 0, cmval = 0;
+ 	u_int8_t retval = 0;
+ 	register char *cp;
+ 	register int exponent;
+ 	register int mantissa;
+ 
+ 	cp = *strptr;
+ 
+ 	while (isdigit(*cp))
+ 		mval = mval * 10 + (*cp++ - '0');
+ 
+ 	if (*cp == '.') {		/* centimeters */
+ 		cp++;
+ 		if (isdigit(*cp)) {
+ 			cmval = (*cp++ - '0') * 10;
+ 			if (isdigit(*cp)) {
+ 				cmval += (*cp++ - '0');
+ 			}
+ 		}
+ 	}
+ 	cmval = (mval * 100) + cmval;
+ 
+ 	for (exponent = 0; exponent < 9; exponent++)
+ 		if (cmval < poweroften[exponent+1])
+ 			break;
+ 
+ 	mantissa = cmval / poweroften[exponent];
+ 	if (mantissa > 9)
+ 		mantissa = 9;
+ 
+ 	retval = (mantissa << 4) | exponent;
+ 
+ 	*strptr = cp;
+ 
+ 	return (retval);
+ }
+ 
+ /* converts ascii lat/lon to unsigned encoded 32-bit number.  moves pointer. */
+ static u_int32_t
+ latlon2ul(latlonstrptr,which)
+ 	char **latlonstrptr;
+ 	int *which;
+ {
+ 	register char *cp;
+ 	u_int32_t retval;
+ 	int deg = 0, min = 0, secs = 0, secsfrac = 0;
+ 
+ 	cp = *latlonstrptr;
+ 
+ 	while (isdigit(*cp))
+ 		deg = deg * 10 + (*cp++ - '0');
+ 
+ 	while (isspace(*cp))
+ 		cp++;
+ 
+ 	if (!(isdigit(*cp)))
+ 		goto fndhemi;
+ 
+ 	while (isdigit(*cp))
+ 		min = min * 10 + (*cp++ - '0');
+ 
+ 	while (isspace(*cp))
+ 		cp++;
+ 
+ 	if (!(isdigit(*cp)))
+ 		goto fndhemi;
+ 
+ 	while (isdigit(*cp))
+ 		secs = secs * 10 + (*cp++ - '0');
+ 
+ 	if (*cp == '.') {		/* decimal seconds */
+ 		cp++;
+ 		if (isdigit(*cp)) {
+ 			secsfrac = (*cp++ - '0') * 100;
+ 			if (isdigit(*cp)) {
+ 				secsfrac += (*cp++ - '0') * 10;
+ 				if (isdigit(*cp)) {
+ 					secsfrac += (*cp++ - '0');
+ 				}
+ 			}
+ 		}
+ 	}
+ 
+ 	while (!isspace(*cp))	/* if any trailing garbage */
+ 		cp++;
+ 
+ 	while (isspace(*cp))
+ 		cp++;
+ 
+  fndhemi:
+ 	switch (*cp) {
+ 	case 'N': case 'n':
+ 	case 'E': case 'e':
+ 		retval = ((unsigned)1<<31)
+ 			+ (((((deg * 60) + min) * 60) + secs) * 1000)
+ 			+ secsfrac;
+ 		break;
+ 	case 'S': case 's':
+ 	case 'W': case 'w':
+ 		retval = ((unsigned)1<<31)
+ 			- (((((deg * 60) + min) * 60) + secs) * 1000)
+ 			- secsfrac;
+ 		break;
+ 	default:
+ 		retval = 0;	/* invalid value -- indicates error */
+ 		break;
+ 	}
+ 
+ 	switch (*cp) {
+ 	case 'N': case 'n':
+ 	case 'S': case 's':
+ 		*which = 1;	/* latitude */
+ 		break;
+ 	case 'E': case 'e':
+ 	case 'W': case 'w':
+ 		*which = 2;	/* longitude */
+ 		break;
+ 	default:
+ 		*which = 0;	/* error */
+ 		break;
+ 	}
+ 
+ 	cp++;			/* skip the hemisphere */
+ 
+ 	while (!isspace(*cp))	/* if any trailing garbage */
+ 		cp++;
+ 
+ 	while (isspace(*cp))	/* move to next field */
+ 		cp++;
+ 
+ 	*latlonstrptr = cp;
+ 
+ 	return (retval);
+ }
+ 
+ /* converts a zone file representation in a string to an RDATA on-the-wire
+  * representation. */
+ int
+ loc_aton(ascii, binary)
+ 	const char *ascii;
+ 	u_char *binary;
+ {
+ 	const char *cp, *maxcp;
+ 	u_char *bcp;
+ 
+ 	u_int32_t latit = 0, longit = 0, alt = 0;
+ 	u_int32_t lltemp1 = 0, lltemp2 = 0;
+ 	int altmeters = 0, altfrac = 0, altsign = 1;
+ 	u_int8_t hp = 0x16;	/* default = 1e6 cm = 10000.00m = 10km */
+ 	u_int8_t vp = 0x13;	/* default = 1e3 cm = 10.00m */
+ 	u_int8_t siz = 0x12;	/* default = 1e2 cm = 1.00m */
+ 	int which1 = 0, which2 = 0;
+ 
+ 	cp = ascii;
+ 	maxcp = cp + strlen(ascii);
+ 
+ 	lltemp1 = latlon2ul(&cp, &which1);
+ 
+ 	lltemp2 = latlon2ul(&cp, &which2);
+ 
+ 	switch (which1 + which2) {
+ 	case 3:			/* 1 + 2, the only valid combination */
+ 		if ((which1 == 1) && (which2 == 2)) { /* normal case */
+ 			latit = lltemp1;
+ 			longit = lltemp2;
+ 		} else if ((which1 == 2) && (which2 == 1)) { /* reversed */
+ 			longit = lltemp1;
+ 			latit = lltemp2;
+ 		} else {	/* some kind of brokenness */
+ 			return 0;
+ 		}
+ 		break;
+ 	default:		/* we didn't get one of each */
+ 		return 0;
+ 	}
+ 
+ 	/* altitude */
+ 	if (*cp == '-') {
+ 		altsign = -1;
+ 		cp++;
+ 	}
+     
+ 	if (*cp == '+')
+ 		cp++;
+ 
+ 	while (isdigit(*cp))
+ 		altmeters = altmeters * 10 + (*cp++ - '0');
+ 
+ 	if (*cp == '.') {		/* decimal meters */
+ 		cp++;
+ 		if (isdigit(*cp)) {
+ 			altfrac = (*cp++ - '0') * 10;
+ 			if (isdigit(*cp)) {
+ 				altfrac += (*cp++ - '0');
+ 			}
+ 		}
+ 	}
+ 
+ 	alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));
+ 
+ 	while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
+ 		cp++;
+ 
+ 	while (isspace(*cp) && (cp < maxcp))
+ 		cp++;
+ 
+ 	if (cp >= maxcp)
+ 		goto defaults;
+ 
+ 	siz = precsize_aton(&cp);
+ 	
+ 	while (!isspace(*cp) && (cp < maxcp))	/* if trailing garbage or m */
+ 		cp++;
+ 
+ 	while (isspace(*cp) && (cp < maxcp))
+ 		cp++;
+ 
+ 	if (cp >= maxcp)
+ 		goto defaults;
+ 
+ 	hp = precsize_aton(&cp);
+ 
+ 	while (!isspace(*cp) && (cp < maxcp))	/* if trailing garbage or m */
+ 		cp++;
+ 
+ 	while (isspace(*cp) && (cp < maxcp))
+ 		cp++;
+ 
+ 	if (cp >= maxcp)
+ 		goto defaults;
+ 
+ 	vp = precsize_aton(&cp);
+ 
+  defaults:
+ 
+ 	bcp = binary;
+ 	*bcp++ = (u_int8_t) 0;	/* version byte */
+ 	*bcp++ = siz;
+ 	*bcp++ = hp;
+ 	*bcp++ = vp;
+ 	PUTLONG(latit,bcp);
+ 	PUTLONG(longit,bcp);
+ 	PUTLONG(alt,bcp);
+     
+ 	return (16);		/* size of RR in octets */
+ }
+ 
+ /* takes an on-the-wire LOC RR and formats it in a human readable format. */
+ char *
+ loc_ntoa(binary, ascii)
+ 	const u_char *binary;
+ 	char *ascii;
+ {
+ 	static char *error = "?";
+ 	register const u_char *cp = binary;
+ 
+ 	int latdeg, latmin, latsec, latsecfrac;
+ 	int longdeg, longmin, longsec, longsecfrac;
+ 	char northsouth, eastwest;
+ 	int altmeters, altfrac, altsign;
+ 
+ 	const int referencealt = 100000 * 100;
+ 
+ 	int32_t latval, longval, altval;
+ 	u_int32_t templ;
+ 	u_int8_t sizeval, hpval, vpval, versionval;
+     
+ 	char *sizestr, *hpstr, *vpstr;
+ 
+ 	versionval = *cp++;
+ 
+ 	if (versionval) {
+ 		sprintf(ascii, "; error: unknown LOC RR version");
+ 		return (ascii);
+ 	}
+ 
+ 	sizeval = *cp++;
+ 
+ 	hpval = *cp++;
+ 	vpval = *cp++;
+ 
+ 	GETLONG(templ, cp);
+ 	latval = (templ - ((unsigned)1<<31));
+ 
+ 	GETLONG(templ, cp);
+ 	longval = (templ - ((unsigned)1<<31));
+ 
+ 	GETLONG(templ, cp);
+ 	if (templ < referencealt) { /* below WGS 84 spheroid */
+ 		altval = referencealt - templ;
+ 		altsign = -1;
+ 	} else {
+ 		altval = templ - referencealt;
+ 		altsign = 1;
+ 	}
+ 
+ 	if (latval < 0) {
+ 		northsouth = 'S';
+ 		latval = -latval;
+ 	} else
+ 		northsouth = 'N';
+ 
+ 	latsecfrac = latval % 1000;
+ 	latval = latval / 1000;
+ 	latsec = latval % 60;
+ 	latval = latval / 60;
+ 	latmin = latval % 60;
+ 	latval = latval / 60;
+ 	latdeg = latval;
+ 
+ 	if (longval < 0) {
+ 		eastwest = 'W';
+ 		longval = -longval;
+ 	} else
+ 		eastwest = 'E';
+ 
+ 	longsecfrac = longval % 1000;
+ 	longval = longval / 1000;
+ 	longsec = longval % 60;
+ 	longval = longval / 60;
+ 	longmin = longval % 60;
+ 	longval = longval / 60;
+ 	longdeg = longval;
+ 
+ 	altfrac = altval % 100;
+ 	altmeters = (altval / 100) * altsign;
+ 
+ 	if ((sizestr = strdup(precsize_ntoa(sizeval))) == NULL)
+ 		sizestr = error;
+ 	if ((hpstr = strdup(precsize_ntoa(hpval))) == NULL)
+ 		hpstr = error;
+ 	if ((vpstr = strdup(precsize_ntoa(vpval))) == NULL)
+ 		vpstr = error;
+ 
+ 	sprintf(ascii,
+ 	      "%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",
+ 		latdeg, latmin, latsec, latsecfrac, northsouth,
+ 		longdeg, longmin, longsec, longsecfrac, eastwest,
+ 		altmeters, altfrac, sizestr, hpstr, vpstr);
+ 
+ 	if (sizestr != error)
+ 		free(sizestr);
+ 	if (hpstr != error)
+ 		free(hpstr);
+ 	if (vpstr != error)
+ 		free(vpstr);
+ 
+ 	return (ascii);
  }
*** tools/nslookup/main.c	1995/12/22 10:20:42	8.2
--- tools/nslookup/main.c	1996/05/31 17:51:23
***************
*** 517,521 ****
      }
  
!     if (result == SUCCESS || result == NONAUTH) {
  	    /*
  	     *  Found info about the new server. Free the resources for
--- 517,528 ----
      }
  
!     /* If we ask for an A record and get none back, but get an NS
!        record for the NS server, this is the NONAUTH case.
!        We must check whether we got an IP address for the NS
!        server or not.  */
!     if ((result == SUCCESS || result == NONAUTH) &&
! 	((newDefPtr->addrList && newDefPtr->addrList[0] != 0) || 
! 	 (newDefPtr->servers && newDefPtr->servers[0] &&
! 			newDefPtr->servers[0]->addrList[0] != 0))) {
  	    /*
  	     *  Found info about the new server. Free the resources for
