diff --context --recurs m:\bind494rel/BSD/named-xfer/Makefile m:\bind/BSD/named-xfer/Makefile
*** m:\bind494rel/BSD/named-xfer/Makefile	Thu Jun 27 19:27:58 1996
--- m:\bind/BSD/named-xfer/Makefile	Thu May 23 15:45:14 1996
***************
*** 1,4 ****
! # $Id: Makefile,v 8.3 1996/01/09 20:23:48 vixie Exp $
  
  .PATH:	${.CURDIR}/../BIND/named \
  	${.CURDIR}/../named/obj \
--- 1,4 ----
! # $Id: Makefile,v 8.3 1995/12/31 23:28:01 vixie Exp $
  
  .PATH:	${.CURDIR}/../BIND/named \
  	${.CURDIR}/../named/obj \
Only in m:\bind494rel: INSTALL
Only in m:\bind: MIRRORS
Only in m:\bind: WINNTPORT
Only in m:\bind: bind-4.9.3-BETA26.tar.gz
Only in m:\bind: bind-4.9.3-BETA27.tar.gz
Only in m:\bind: bind-4.9.3-BETA29.tar.gz
Only in m:\bind: bind-4.9.3-BETA30.tar.gz
Only in m:\bind: bind-4.9.3-BETA31.tar.gz
Only in m:\bind: bind-4.9.3-BETA32.tar.gz
Only in m:\bind: bind-4.9.3-REL.tar.gz
Only in m:\bind494rel: bind-4.9.4-REL.tar
Only in m:\bind: bind-4.9.4-REL.tar.gz
Only in m:\bind: bind-4.9.4-T3B.tar.gz
Only in m:\bind: bind-4.9.4-T4B.tar.gz
Only in m:\bind: bind-4.9.4-T5B.tar.gz
Only in m:\bind: bs
Only in m:\bind: buildallnt.bat
diff --context --recurs m:\bind494rel/compat/include/sys/cdefs.h m:\bind/compat/include/sys/cdefs.h
*** m:\bind494rel/compat/include/sys/cdefs.h	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/include/sys/cdefs.h	Thu May 23 15:45:20 1996
***************
*** 97,121 ****
  #define	__CONCAT(x,y)	x/**/y
  #define	__STRING(x)	"x"
  
! #ifndef __GNUC__
! #define	__const				/* delete pseudo-ANSI C keywords */
! #define	__inline
! #define	__signed
! #define	__volatile
! /*
!  * In non-ANSI C environments, new programs will want ANSI-only C keywords
!  * deleted from the program and old programs will want them left alone.
!  * When using a compiler other than gcc, programs using the ANSI C keywords
!  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
   * When using "gcc -traditional", we assume that this is the intent; if
   * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
   */
! #ifndef	NO_ANSI_KEYWORDS
  #define	const				/* delete ANSI C keywords */
  #define	inline
  #define	signed
  #define	volatile
! #endif
  #endif	/* !__GNUC__ */
  #endif	/* !(__STDC__ || __cplusplus) */
  
--- 97,123 ----
  #define	__CONCAT(x,y)	x/**/y
  #define	__STRING(x)	"x"
  
! #ifndef WINNT
! #ifndef __GNUC__
! #define	__const				/* delete pseudo-ANSI C keywords */
! #define	__inline
! #define	__signed
! #define	__volatile
! #endif
! /*
!  * In non-ANSI C environments, new programs will want ANSI-only C keywords
!  * deleted from the program and old programs will want them left alone.
!  * When using a compiler other than gcc, programs using the ANSI C keywords
!  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
   * When using "gcc -traditional", we assume that this is the intent; if
   * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
   */
! #ifndef NO_ANSI_KEYWORDS
  #define	const				/* delete ANSI C keywords */
  #define	inline
  #define	signed
  #define	volatile
! #endif /* WINNT */
  #endif	/* !__GNUC__ */
  #endif	/* !(__STDC__ || __cplusplus) */
  
Only in m:\bind/compat/lib: MSG00001.bin
Only in m:\bind/compat/lib: WinRel
diff --context --recurs m:\bind494rel/compat/lib/ftruncate.c m:\bind/compat/lib/ftruncate.c
*** m:\bind494rel/compat/lib/ftruncate.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/ftruncate.c	Thu May 23 15:45:20 1996
***************
*** 41,56 ****
  		}
  		return (0);
  	}
! 
! 	/* maybe shorten... */
! 	if (wantsize < cursize) {
! 		struct flock fl;
! 
! 		fl.l_whence = 0;
! 		fl.l_len = 0;
! 		fl.l_start = wantsize;
! 		fl.l_type = F_WRLCK;
! 		return (fcntl(fd, F_FREESP, &fl));
  	}
  	return (0);
  }
--- 41,59 ----
  		}
  		return (0);
  	}
! 	/* maybe shorten... */
! 	if (wantsize < cursize) {
! #ifndef WINNT
! 		struct flock fl;
! 
! 		fl.l_whence = 0;
! 		fl.l_len = 0;
! 		fl.l_start = wantsize;
! 		fl.l_type = F_WRLCK;
! 		return (fcntl(fd, F_FREESP, &fl));
! #else
! 		return (lseek(fd, wantsize, 0) && SetEndOfFile((HANDLE)fd));
! #endif
  	}
  	return (0);
  }
diff --context --recurs m:\bind494rel/compat/lib/gettimeofday.c m:\bind/compat/lib/gettimeofday.c
*** m:\bind494rel/compat/lib/gettimeofday.c	Thu Jun 27 19:27:58 1996
--- m:\bind/compat/lib/gettimeofday.c	Thu May 23 15:45:22 1996
***************
*** 12,29 ****
  	struct timeval *tvp;
  	struct _TIMEZONE *tzp;
  {
! 	time_t clock, time __P((time_t *));
! 
! 	if (time(&clock) == (time_t) -1)
! 		return (-1);
! 	if (tvp) {
! 		tvp->tv_sec = clock;
! 		tvp->tv_usec = 0;
  	}
! 	if (tzp) {
! 		tzp->tz_minuteswest = 0;
  		tzp->tz_dsttime = 0;
  	}
  	return (0);
  }
  
--- 12,36 ----
  	struct timeval *tvp;
  	struct _TIMEZONE *tzp;
  {
! #ifndef WINNT
! 	time_t clock, time __P((time_t *));
! 
! 	if (time(&clock) == (time_t) -1)
! 		return (-1);
! 	if (tvp) {
! 		tvp->tv_sec = clock;
! 		tvp->tv_usec = 0;
  	}
! 	if (tzp) {
! 		tzp->tz_minuteswest = 0;
  		tzp->tz_dsttime = 0;
  	}
+ #else
+ 	struct _timeb timebuffer;
+ 	_ftime(&timebuffer);
+ 	tvp->tv_sec = (long) timebuffer.time;
+ 	tvp->tv_usec = (long) (1000 * (timebuffer.millitm));
+ #endif
  	return (0);
  }
  
Only in m:\bind/compat/lib: lib44bsd.mak
Only in m:\bind/compat/lib: lib44bsd.mdp
Only in m:\bind/compat/lib: lib44bsd.ncb
Only in m:\bind/compat/lib: lib44bsd.vcp
Only in m:\bind/compat/lib: log.c
Only in m:\bind/compat/lib: log.h
Only in m:\bind/compat/lib: makemc.bat
Only in m:\bind/compat/lib: messages.aps
Only in m:\bind/compat/lib: messages.h
Only in m:\bind/compat/lib: messages.mc
Only in m:\bind/compat/lib: messages.rc
diff --context --recurs m:\bind494rel/compat/lib/mktemp.c m:\bind/compat/lib/mktemp.c
*** m:\bind494rel/compat/lib/mktemp.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/mktemp.c	Thu May 23 15:45:28 1996
***************
*** 98,113 ****
  	char *path;
  	register int *doopen;
  {
! 	extern int errno;
! 	register char *start, *trv;
! 	struct stat sbuf;
! 	u_int pid;
  
! 	pid = getpid();
! 	for (trv = path; *trv; ++trv);		/* extra X's get set to 0's */
! 	while (*--trv == 'X') {
! 		*trv = (pid % 10) + '0';
! 		pid /= 10;
  	}
  
  	/*
--- 98,115 ----
  	char *path;
  	register int *doopen;
  {
! #ifndef WINNT
! 	extern int errno;
! #endif
! 	register char *start, *trv;
! 	struct stat sbuf;
! 	u_int pid;
  
! 	pid = getpid();
! 	for (trv = path; *trv; ++trv);		/* extra X's get set to 0's */
! 	while (*--trv == 'X') {
! 		*trv = (pid % 10) + '0';
! 		pid /= 10;
  	}
  
  	/*
***************
*** 122,128 ****
--- 124,134 ----
  			if (stat(path, &sbuf))
  				return(0);
  			if (!S_ISDIR(sbuf.st_mode)) {
+ #ifndef WINNT
  				errno = ENOTDIR;
+ #else
+ 				WSASetLastError(ENOTDIR);
+ #endif
  				return(0);
  			}
  			*trv = '/';
Only in m:\bind/compat/lib: ntmisc.c
diff --context --recurs m:\bind494rel/compat/lib/strcasecmp.c m:\bind/compat/lib/strcasecmp.c
*** m:\bind494rel/compat/lib/strcasecmp.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/strcasecmp.c	Thu May 23 15:45:30 1996
***************
*** 58,73 ****
  static char rcsid[] = "$Id: strcasecmp.c,v 8.2 1995/04/17 06:38:14 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/cdefs.h>
! #if (!defined(BSD)) || (BSD < 199306)
! #include "../../conf/portability.h"
  #else
! #include <string.h>
! #endif
  
! #ifndef NEED_STRCASECMP
  int __strcasecmp_unneeded__;
  #else
  
--- 58,75 ----
  static char rcsid[] = "$Id: strcasecmp.c,v 8.2 1995/04/17 06:38:14 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/cdefs.h>
! #endif
! #if (!defined(BSD)) || (BSD < 199306)
! #include "../../conf/portability.h"
  #else
! #include <string.h>
! #endif
  
! #ifndef NEED_STRCASECMP
  int __strcasecmp_unneeded__;
  #else
  
***************
*** 113,119 ****
  
  int
  strcasecmp(s1, s2)
! 	const char  *s1, *s2;
  {
  	register const u_char *cm = charmap,
  			*us1 = (const u_char *)s1,
--- 115,121 ----
  
  int
  strcasecmp(s1, s2)
! 	const char *s1, *s2;
  {
  	register const u_char *cm = charmap,
  			*us1 = (const u_char *)s1,
diff --context --recurs m:\bind494rel/compat/lib/strerror.c m:\bind/compat/lib/strerror.c
*** m:\bind494rel/compat/lib/strerror.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/strerror.c	Thu May 23 15:45:32 1996
***************
*** 58,64 ****
  static char rcsid[] = "$Id: strerror.c,v 8.1 1994/12/15 06:23:51 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
  #if defined(BSD) && (BSD >= 199306)
  #include <string.h>
  #else
--- 58,66 ----
  static char rcsid[] = "$Id: strerror.c,v 8.1 1994/12/15 06:23:51 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #endif
  #if defined(BSD) && (BSD >= 199306)
  #include <string.h>
  #else
Only in m:\bind/compat/lib: strip.bat
diff --context --recurs m:\bind494rel/compat/lib/strpbrk.c m:\bind/compat/lib/strpbrk.c
*** m:\bind494rel/compat/lib/strpbrk.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/strpbrk.c	Thu May 23 15:45:34 1996
***************
*** 58,64 ****
  static char rcsid[] = "$Id: strpbrk.c,v 8.1 1994/12/15 06:23:51 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
  #if defined(BSD) && (BSD >= 199306)
  #include <sys/cdefs.h>
  #include <string.h>
--- 58,66 ----
  static char rcsid[] = "$Id: strpbrk.c,v 8.1 1994/12/15 06:23:51 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #endif
  #if defined(BSD) && (BSD >= 199306)
  #include <sys/cdefs.h>
  #include <string.h>
diff --context --recurs m:\bind494rel/compat/lib/strtoul.c m:\bind/compat/lib/strtoul.c
*** m:\bind494rel/compat/lib/strtoul.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/strtoul.c	Thu May 23 15:45:36 1996
***************
*** 61,67 ****
  #include <limits.h>
  #include <ctype.h>
  #include <errno.h>
! #include <sys/param.h>
  #if defined(BSD) && (BSD >= 199306)
  #include <stdlib.h>
  #else
--- 61,69 ----
  #include <limits.h>
  #include <ctype.h>
  #include <errno.h>
! #ifndef WINNT
! #include <sys/param.h>
! #endif
  #if defined(BSD) && (BSD >= 199306)
  #include <stdlib.h>
  #else
diff --context --recurs m:\bind494rel/compat/lib/writev.c m:\bind/compat/lib/writev.c
*** m:\bind494rel/compat/lib/writev.c	Thu Jun 27 19:27:57 1996
--- m:\bind/compat/lib/writev.c	Thu May 23 15:45:38 1996
***************
*** 6,19 ****
   *
   *	Cray UNICOS
   *	SCO
!  */
  
! #if defined(_CRAY)
  #define OWN_WRITEV
  #include <sys/types.h>
  #include <sys/uio.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
  
  int
  __writev(int fd, struct iovec *iov, int iovlen)
--- 6,20 ----
   *
   *	Cray UNICOS
   *	SCO
!  *  WindowsNT
!  */
  
! #if defined(_CRAY)
  #define OWN_WRITEV
  #include <sys/types.h>
  #include <sys/uio.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
  
  int
  __writev(int fd, struct iovec *iov, int iovlen)
***************
*** 80,85 ****
--- 81,130 ----
  		vp++;
  	}
  	return (count);
+ }
+ #endif
+ 
+ #ifdef WINNT
+ #define OWN_WRITEV
+ #define TIMEOUT_SEC 120
+ #include <stdarg.h>
+ #include "../../conf/portability.h"
+ 
+ 
+ /*
+  * writev --
+  * simplistic writev implementation for WindowsNT using the WriteFile WIN32API.
+  */	
+ int
+ writev(fd, iov, iovcnt)
+ 	int fd;
+ 	struct iovec *iov;
+ 	int iovcnt;
+ {
+ 	int i;
+ 	char *base;
+ 	DWORD BytesWritten, TotalBytesWritten = 0, len, dwWait;
+ 	extern HANDLE hReadWriteEvent;
+ 	OVERLAPPED overlap;
+ 	BOOL ret; 
+ 
+ 	for (i=0; i<iovcnt; i++) {
+ 		base = iov[i].iov_base;
+ 		len = (DWORD)iov[i].iov_len;
+ 		overlap.Offset = overlap.OffsetHigh = (DWORD)0;
+ 		overlap.hEvent = hReadWriteEvent;
+ 		ret = WriteFile((HANDLE)fd, (char *)base, len,
+ 		              (LPDWORD)&BytesWritten, (LPOVERLAPPED)&overlap);
+ 		if ((ret == FALSE) && (errno != ERROR_IO_PENDING)) {
+ 				return (-1);
+ 		}
+ 		dwWait = WaitForSingleObject((HANDLE)hReadWriteEvent, (DWORD)TIMEOUT_SEC * 1000);
+ 		if ((dwWait == WAIT_FAILED) || (dwWait == WAIT_TIMEOUT)){
+ 			return (-1);
+ 		}
+ 		TotalBytesWritten += BytesWritten;
+ 	}
+ 	return((int)TotalBytesWritten);
  }
  #endif
  
diff --context --recurs m:\bind494rel/conf/options.h m:\bind/conf/options.h
*** m:\bind494rel/conf/options.h	Thu Jun 27 19:27:53 1996
--- m:\bind/conf/options.h	Fri May 24 01:53:00 1996
***************
*** 115,121 ****
  #define CLEANCACHE	/* useful and necessary in the face of NCACHE */
  #define PURGE_ZONE	/* remove all traces of a zone when reloading (mpa) */
  #define STATS		/* keep nameserver statistics; uses more memory */
! #define RENICE  	/* named-xfer should run at normal priority */
  /*#define XSTATS	/* extended statistics, syslogged periodically (bg) */
  /*#define BIND_NOTIFY	/* experimental - do not enable in customer products */
  #define LOC_RR		/* support for LOC record parsing (ckd/vix) */
--- 115,123 ----
  #define CLEANCACHE	/* useful and necessary in the face of NCACHE */
  #define PURGE_ZONE	/* remove all traces of a zone when reloading (mpa) */
  #define STATS		/* keep nameserver statistics; uses more memory */
! #ifndef WINNT
! #define RENICE  	/* named-xfer should run at normal priority */
! #endif
  /*#define XSTATS	/* extended statistics, syslogged periodically (bg) */
  /*#define BIND_NOTIFY	/* experimental - do not enable in customer products */
  #define LOC_RR		/* support for LOC record parsing (ckd/vix) */
diff --context --recurs m:\bind494rel/conf/portability.h m:\bind/conf/portability.h
*** m:\bind494rel/conf/portability.h	Thu Jun 27 19:27:53 1996
--- m:\bind/conf/portability.h	Sat Jun 08 01:49:31 1996
***************
*** 64,77 ****
  #include <string.h>
  #include <signal.h>
  #include <sys/types.h>
! #include <sys/param.h>
! #ifndef TIME_H_INCLUDED
! # include <sys/time.h>
! # define TIME_H_INCLUDED
! #endif
  
! #ifdef ISC
! # ifndef _POSIX_SOURCE
  #  define _POSIX_SOURCE
  # endif
  # define SYSV
--- 64,162 ----
  #include <string.h>
  #include <signal.h>
  #include <sys/types.h>
! #ifndef WINNT
! #include <sys/param.h>
! #ifndef TIME_H_INCLUDED
! # include <sys/time.h>
! # define TIME_H_INCLUDED
! #endif
! #endif /* WINNT */
! 
! #ifdef WINNT
! #ifndef _PORTABILITY_H
! #define _PORTABILITY_H
! #include <stdio.h>
! #ifdef BUFSIZ
! #undef BUFSIZ
! #endif
! #define BUFSIZ 1024  /* GMS - added since Unix used 1K and NT 512B */
! #include <string.h>
! #include <process.h>
! #include <sys/timeb.h>
! #include <time.h>
! #include <io.h>
! #include <stdlib.h>
! #define FD_SETSIZE 512
! #include <winsock.h>
! #include <windows.h>
! 
! #define NOWAIT
! #define HAVE_SETVBUF
! #define NEED_GETTIMEOFDAY
! #define USE_MEMCPY
! #undef IP_OPTIONS
! #define PATH_MAX MAX_PATH
! #define ETIMEDOUT WSAETIMEDOUT
! #define ECONNRESET WSAECONNRESET
! #define ECONNREFUSED WSAECONNREFUSED
! #define EADDRINUSE WSAEADDRINUSE
! #define PORT_WOULDBLK WSAEWOULDBLOCK
! #define _TIMEZONE timezoneBSD
  
! struct timezoneBSD {
! 	int tz_minuteswest;
! 	int tz_dsttime;
! };
! struct iovec {
! 	char *  iov_base;
! 	int 	iov_len;
! };
! typedef char *	caddr_t;
! typedef long pid_t;
! #define sleep(t) Sleep(t*1000)
! #ifdef errno
! #undef errno
! #endif
! #define errno WSAGetLastError()
! /* #define close(s) closesocket(s) */
! #define chdir(path) SetCurrentDirectory(path)
! #define dup2(s1, s2) DuplicateHandle(GetCurrentProcess(), (HANDLE)(s1), \
! 					GetCurrentProcess(), (LPHANDLE)&(s2), \
! 					0, FALSE, DUPLICATE_SAME_ACCESS);
! #define strcasecmp(x, y) stricmp(x, y)
! #define strncasecmp(x, y, z) strnicmp(x, y, z)
! 
! void  	service_main(DWORD, LPTSTR *);
! void  	service_ctrl(DWORD);
! void    worker_thread(void *);
! void syslog(int, char *, ...);
! void expand_paths(void);
! int writev(int, struct iovec *, int);
! int mkstemp(char *);
! 
! #define MAXALIASES 35
! #define LOG_EMERG       0       /* system is unusable */
! #define LOG_ALERT       1       /* action must be taken immediately */
! #define LOG_CRIT        2       /* critical conditions */
! #define LOG_ERR         3       /* error conditions */
! #define LOG_WARNING     4       /* warning conditions */
! #define LOG_NOTICE      5       /* normal but signification condition */
! #define LOG_INFO        6       /* informational */
! #define LOG_DEBUG       7       /* debug-level messages */
! /* control codes that the service will accept */
! #define SERVICE_CONTROL_DUMPDB  128
! #define SERVICE_CONTROL_RELOAD  129
! #define SERVICE_CONTROL_STATS   130
! #define SERVICE_CONTROL_TRACE   131
! #define SERVICE_CONTROL_NOTRACE 132
! #define SERVICE_CONTROL_QRYLOG  133
! #define SERVICE_CONTROL_CHKPT   134
! #define SERVICE_CONTROL_EXIT    135
! #endif /* _PORTABILITY_H */
! #endif /* WINNT */
! 
! #ifdef ISC
! # ifndef _POSIX_SOURCE
  #  define _POSIX_SOURCE
  # endif
  # define SYSV
***************
*** 186,192 ****
  #endif
  
  #if !defined(BSD) || (BSD <= 199006)
! # if !defined(NeXT)
  #  define NEED_INETADDR
  # endif
  # define NEED_INETATON
--- 271,277 ----
  #endif
  
  #if !defined(BSD) || (BSD <= 199006)
! # if !defined(NeXT)	&& !defined(WINNT)
  #  define NEED_INETADDR
  # endif
  # define NEED_INETATON
***************
*** 253,266 ****
  # define STDIN_FILENO	0
  # define STDOUT_FILENO	1
  # define STDERR_FILENO	2
! # ifndef NeXT
  extern char *getenv __P((char *));
  # else
  extern char *getenv __P((const char *));
  # endif
  extern int errno;
  
! # if !defined(DMALLOC) && !defined(NeXT)
  extern char *malloc(), *realloc(), *calloc();
  #  if defined(sun)
  extern int free();
--- 338,353 ----
  # define STDIN_FILENO	0
  # define STDOUT_FILENO	1
  # define STDERR_FILENO	2
! # if !defined(NeXT) && !defined(WINNT)
  extern char *getenv __P((char *));
  # else
  extern char *getenv __P((const char *));
  # endif
+ #ifndef WINNT
  extern int errno;
+ #endif
  
! # if !defined(DMALLOC) && !defined(NeXT) && !defined(WINNT)
  extern char *malloc(), *realloc(), *calloc();
  #  if defined(sun)
  extern int free();
***************
*** 306,312 ****
  #undef IP_OPTIONS
  #endif
  
! #if !defined(__STDC__) && !defined(const)
  # define const /*constant*/
  #endif
  
--- 393,399 ----
  #undef IP_OPTIONS
  #endif
  
! #if !defined(__STDC__) && !defined(const) && !defined(WINNT)
  # define const /*constant*/
  #endif
  
***************
*** 317,322 ****
--- 404,410 ----
  /* is USE_POSIX the right thing to use here? */
  #if (!defined(BSD) || (BSD <= 43)) && \
  	!defined(NeXT) && \
+ 	!defined(WINNT) && \
  	!defined(__convex__) && \
  	!defined(USE_POSIX)
  # if !defined(NCR)
***************
*** 329,337 ****
  #endif
  
  #if !defined(bcopy)	/* some machines have their own macros for this */
! # if defined(USE_POSIX) || \
  	 (defined(__STDC__) && !defined(sun) && !defined(sequent) \
! 	  && !defined(M_UNIX))
  /* use ANSI C3.159-1989 (``ANSI C'') functions if possible;
   * ideally we would change the code to use them and then
   * define them in terms of bcopy et al if !defined(__STDC__)
--- 417,425 ----
  #endif
  
  #if !defined(bcopy)	/* some machines have their own macros for this */
! # if defined(USE_POSIX) || defined(WINNT) ||\
  	 (defined(__STDC__) && !defined(sun) && !defined(sequent) \
!  	  && !defined(M_UNIX))
  /* use ANSI C3.159-1989 (``ANSI C'') functions if possible;
   * ideally we would change the code to use them and then
   * define them in terms of bcopy et al if !defined(__STDC__)
***************
*** 353,359 ****
  
  #if (!defined(BSD) || (BSD < 43) || defined(RISCOS_BSD)) \
  	&& !defined(USE_POSIX) && !defined(apollo) && !defined(sequent) \
! 	&& !defined(M_UNIX)
  # define NEED_STRERROR
  #if !defined(ultrix) && !defined(NCR)
  # define NEED_PUTENV
--- 441,447 ----
  
  #if (!defined(BSD) || (BSD < 43) || defined(RISCOS_BSD)) \
  	&& !defined(USE_POSIX) && !defined(apollo) && !defined(sequent) \
! 	&& !defined(M_UNIX)	&& !defined(WINNT)
  # define NEED_STRERROR
  #if !defined(ultrix) && !defined(NCR)
  # define NEED_PUTENV
***************
*** 370,376 ****
  
  #if (!defined(BSD) || (BSD < 43))
  # define NEED_MKSTEMP
! # if !defined(__ultrix) && !defined(apollo)
  #  define NEED_STRCASECMP
  #  define NEED_MKTEMP
  #  if !defined(SVR4)
--- 458,464 ----
  
  #if (!defined(BSD) || (BSD < 43))
  # define NEED_MKSTEMP
! # if !defined(__ultrix) && !defined(apollo) && !defined(WINNT)
  #  define NEED_STRCASECMP
  #  define NEED_MKTEMP
  #  if !defined(SVR4)
***************
*** 420,428 ****
--- 508,518 ----
  # define PORT_NONBLOCK	O_NONBLOCK
  # define PORT_WOULDBLK	EAGAIN
  #else
+ #if !defined(WINNT)
  # define PORT_NONBLOCK	O_NDELAY
  # define PORT_WOULDBLK	EWOULDBLOCK
  #endif
+ #endif
  
  #if defined(USE_POSIX)
  # define USE_SETSID
***************
*** 432,438 ****
  #define USE_WAITPID
  #endif
  
! #if !defined(USE_POSIX)
  #define waitpid(x,y,z) (wait3(y,z,(struct rusage *)NULL))
  #endif
  
--- 522,528 ----
  #define USE_WAITPID
  #endif
  
! #if !defined(USE_POSIX) && !defined(WINNT)
  #define waitpid(x,y,z) (wait3(y,z,(struct rusage *)NULL))
  #endif
  
***************
*** 448,453 ****
--- 538,544 ----
  #define WTERMSIG(x)	((x).w_termsig)
  #endif /* sequent */
  
+ #ifndef WINNT
  #if !defined(WIFEXITED)
  # define WIFEXITED(x) (!(x & 0177))
  #endif
***************
*** 460,465 ****
--- 551,557 ----
  #if !defined(WTERMSIG)
  # define WTERMSIG(x) (x & 0177)
  #endif
+ #endif
  
  #ifndef S_ISDIR
  # ifndef S_IFMT
***************
*** 492,498 ****
  #endif
  
  #if defined(NEED_STRTOUL) && \
! 	(defined(__ultrix) || defined(__osf__) || defined(NeXT))
  # undef NEED_STRTOUL
  #endif
  
--- 584,590 ----
  #endif
  
  #if defined(NEED_STRTOUL) && \
! 	(defined(__ultrix) || defined(__osf__) || defined(NeXT) || defined(WINNT))
  # undef NEED_STRTOUL
  #endif
  
***************
*** 551,557 ****
  /*
   * Assume that a system has fchmod() unless something above says otherwise.
   */
! #if !defined(HAVE_FCHMOD)
  # define HAVE_FCHMOD 1
  #endif
  
--- 643,649 ----
  /*
   * Assume that a system has fchmod() unless something above says otherwise.
   */
! #if !defined(HAVE_FCHMOD) && !defined(WINNT)
  # define HAVE_FCHMOD 1
  #endif
  
***************
*** 592,595 ****
--- 684,693 ----
  
  #ifdef NEED_STRDUP
  extern char *strdup __P((const char *));
+ #endif
+ 
+ #ifdef WINNT /* l kahn new definitions needed for vc++4.0 */
+ #define fstat _fstat
+ #define stat _stat
+ #define fileno _fileno
  #endif
Only in m:\bind/contrib/decwrl: gethost
Only in m:\bind/contrib/decwrl: gethost.o
Only in m:\bind/contrib/nutshell: ch09.check_del.c~
diff --context --recurs m:\bind494rel/contrib/old/nstest.c m:\bind/contrib/old/nstest.c
*** m:\bind494rel/contrib/old/nstest.c	Thu Jun 27 19:27:56 1996
--- m:\bind/contrib/old/nstest.c	Thu May 23 15:45:48 1996
***************
*** 65,80 ****
  static char rcsid[] = "$Id: nstest.c,v 8.1 1994/12/15 06:24:29 vixie Exp $";
  #endif /* not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <stdio.h>
! #include <resolv.h>
! #include "../conf/portability.h"
  
! char *progname;
  FILE *log;
  #define MAXDATA		256   /* really should get this from named/db.h */
  main(argc, argv)
--- 65,87 ----
  static char rcsid[] = "$Id: nstest.c,v 8.1 1994/12/15 06:24:29 vixie Exp $";
  #endif /* not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <stdio.h>
! #include <resolv.h>
! #include "../../conf/portability.h"
! 
! #ifdef WINNT
! void usage();
! HANDLE hReadWriteEvent;
! #endif
  
! char *progname;
  FILE *log;
  #define MAXDATA		256   /* really should get this from named/db.h */
  main(argc, argv)
***************
*** 94,101 ****
  	NewRR.r_data = (char *) malloc(MAXDATA);
  	progname = argv[0];
  	dump_packet = 0;
- 	_res.options |= RES_DEBUG|RES_RECURSE;
  	(void) res_init();
  	while (argc > 1 && argv[1][0] == '-') {
  		argc--;
  		cp = *++argv;
--- 101,108 ----
  	NewRR.r_data = (char *) malloc(MAXDATA);
  	progname = argv[0];
  	dump_packet = 0;
  	(void) res_init();
+ 	_res.options |= RES_DEBUG|RES_RECURSE;
  	while (argc > 1 && argv[1][0] == '-') {
  		argc--;
  		cp = *++argv;
***************
*** 128,134 ****
  			}
  	}
  	_res.nsaddr.sin_family = AF_INET;
! 	_res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
  	_res.nsaddr.sin_port = port;
   	if (argc > 1) {
  		if (!inet_aton(argv[1],
--- 135,142 ----
  			}
  	}
  	_res.nsaddr.sin_family = AF_INET;
! //	_res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
! 	_res.nsaddr.sin_addr.s_addr = inet_addr("132.233.186.51");
  	_res.nsaddr.sin_port = port;
   	if (argc > 1) {
  		if (!inet_aton(argv[1],
***************
*** 316,321 ****
--- 324,330 ----
  				    for (i = 0; i < oldnbytes; i++) {
  					    OldRRData[i] = (char) i;
  				    }
+ 					_res.options |= RES_DEBUG|RES_RECURSE;
  					n = res_mkquery(UPDATEM, cp,
  							C_IN, Type,
  							OldRRData, oldnbytes,
***************
*** 418,423 ****
--- 427,433 ----
  	}
  }
  
+ void
  usage()
  {
  	fprintf(stderr, "Usage: %s [-v] [-i] [-r] [-d] [-p port] hostaddr\n",
Only in m:\bind/contrib: winnt-dist
Only in m:\bind: cpl
Only in m:\bind: creadme.bat
Only in m:\bind: diffs.ksh
Only in m:\bind: diffs493relP1tont_context.txt
Only in m:\bind: diffs493relP1tont_nocontext.txt
Only in m:\bind: diffs493relP2tont_context.txt
Only in m:\bind: diffs493relP2tont_nocontext.txt
Only in m:\bind: diffs493reltont_nocontext.txt
Only in m:\bind: diffs494t4atot4b_context.txt
Only in m:\bind: diffs494t4atot4b_nocontext.txt
Only in m:\bind: diffs494t4btont_context.txt
Only in m:\bind: diffs494t4btont_nocontext.txt
Only in m:\bind: diffs494t5b_to_494rel_context.txt
Only in m:\bind: diffs494t5btont_context.txt
Only in m:\bind: diffs494t5btont_nocontext.txt
Only in m:\bind/doc/info: Linux-ELF
Only in m:\bind/doc/info: Linux-again
Only in m:\bind/doc/info: Linux-and-more
Only in m:\bind/doc/info: Linux-more
Only in m:\bind/doc/info: Linux-still-more
Only in m:\bind494rel/doc/info: Solaris
Only in m:\bind/doc/info: solaris
Only in m:\bind/doc/info: sunshlib.3
Only in m:\bind/doc/misc: notify.txt
Only in m:\bind494rel/doc/rfc: rfc1713
Only in m:\bind: eventlib.zip
diff --context --recurs m:\bind494rel/include/arpa/inet.h m:\bind/include/arpa/inet.h
*** m:\bind494rel/include/arpa/inet.h	Thu Jun 27 19:27:50 1996
--- m:\bind/include/arpa/inet.h	Fri May 24 02:00:56 1996
***************
*** 63,88 ****
  
  /* External definitions for functions in inet(3) */
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #else
! # include <sys/types.h>
! #endif
! #include <sys/cdefs.h>
! 
! __BEGIN_DECLS
! unsigned long	 inet_addr __P((const char *));
  int		 inet_aton __P((const char *, struct in_addr *));
  unsigned long	 inet_lnaof __P((struct in_addr));
  struct in_addr	 inet_makeaddr __P((u_long , u_long));
  unsigned long	 inet_netof __P((struct in_addr));
  unsigned long	 inet_network __P((const char *));
  char		*inet_ntoa __P((struct in_addr));
  int		 inet_pton __P((int af, const char *src, void *dst));
  const char	*inet_ntop __P((int af, const void *src, char *dst, size_t s));
  u_int		 inet_nsap_addr __P((const char *, u_char *, int maxlen));
  char		*inet_nsap_ntoa __P((int, const u_char *, char *ascii));
  __END_DECLS
  
  #endif /* !_INET_H_ */
--- 63,98 ----
  
  /* External definitions for functions in inet(3) */
  
! 
! #ifndef WINNT
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! #include <sys/bitypes.h>
! #else
! #include <sys/types.h>
! #endif
! #else
! #define FD_SETSIZE 512
! #include <winsock.h>
! #endif /* WINNT */
! #include <sys/cdefs.h>
!  
! __BEGIN_DECLS
! #ifndef WINNT
! unsigned long	 inet_addr __P((const char *));
! #endif
  int		 inet_aton __P((const char *, struct in_addr *));
  unsigned long	 inet_lnaof __P((struct in_addr));
  struct in_addr	 inet_makeaddr __P((u_long , u_long));
  unsigned long	 inet_netof __P((struct in_addr));
  unsigned long	 inet_network __P((const char *));
+ #ifndef WINNT
  char		*inet_ntoa __P((struct in_addr));
  int		 inet_pton __P((int af, const char *src, void *dst));
  const char	*inet_ntop __P((int af, const void *src, char *dst, size_t s));
  u_int		 inet_nsap_addr __P((const char *, u_char *, int maxlen));
  char		*inet_nsap_ntoa __P((int, const u_char *, char *ascii));
+ #endif 
  __END_DECLS
  
  #endif /* !_INET_H_ */
diff --context --recurs m:\bind494rel/include/arpa/nameser.h m:\bind/include/arpa/nameser.h
*** m:\bind494rel/include/arpa/nameser.h	Thu Jun 27 19:27:50 1996
--- m:\bind/include/arpa/nameser.h	Fri May 24 02:01:08 1996
***************
*** 61,76 ****
  #ifndef _NAMESER_H_
  #define	_NAMESER_H_
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
  #else
! # include <sys/types.h>
  #endif
! #include <sys/cdefs.h>
  
! #ifdef _AUX_SOURCE
! #include <sys/types.h>			/* ech for A/UX */
  #define res_send ucb_res_send		/* already def'd in libc */
  #define _res_close _ucb_res_close    /* removing res_send.o from the library */
  #endif				     /* gives an undefined symbol... */
--- 61,78 ----
  #ifndef _NAMESER_H_
  #define	_NAMESER_H_
  
! #ifndef WINNT
! #include <sys/param.h>
! #endif
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
  #else
! # include <sys/types.h>
  #endif
! #include <sys/cdefs.h>
  
! #ifdef _AUX_SOURCE
! #include <sys/types.h>			/* ech for A/UX */
  #define res_send ucb_res_send		/* already def'd in libc */
  #define _res_close _ucb_res_close    /* removing res_send.o from the library */
  #endif				     /* gives an undefined symbol... */
***************
*** 127,133 ****
--- 129,137 ----
  /*
   * Currently defined response codes
   */
+ #if !(defined(WINNT) && defined(NOERROR))
  #define NOERROR		0		/* no error */
+ #endif
  #define FORMERR		1		/* format error */
  #define SERVFAIL	2		/* server failure */
  #define NXDOMAIN	3		/* non existent domain */
***************
*** 328,335 ****
  #define PUTSHORT(s, cp) { \
  	register u_int16_t t_s = (u_int16_t)(s); \
  	register u_char *t_cp = (u_char *)(cp); \
! 	*t_cp++ = t_s >> 8; \
! 	*t_cp   = t_s; \
  	(cp) += INT16SZ; \
  }
  
--- 332,339 ----
  #define PUTSHORT(s, cp) { \
  	register u_int16_t t_s = (u_int16_t)(s); \
  	register u_char *t_cp = (u_char *)(cp); \
! 	*t_cp++ = (char) (t_s >> 8); \
! 	*t_cp   = (char) t_s; \
  	(cp) += INT16SZ; \
  }
  
diff --context --recurs m:\bind494rel/include/netdb.h m:\bind/include/netdb.h
*** m:\bind494rel/include/netdb.h	Thu Jun 27 19:27:50 1996
--- m:\bind/include/netdb.h	Fri May 24 05:16:58 1996
***************
*** 61,80 ****
  #ifndef _NETDB_H_
  #define _NETDB_H_
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #endif
! #include <sys/cdefs.h>
! 
! #define	_PATH_HEQUIV	"/etc/hosts.equiv"
! #define	_PATH_HOSTS	"/etc/hosts"
! #define	_PATH_NETWORKS	"/etc/networks"
! #define	_PATH_PROTOCOLS	"/etc/protocols"
  #define	_PATH_SERVICES	"/etc/services"
  
  extern int h_errno;
  
  /*
   * Structures returned by network data base library.  All addresses are
   * supplied in host order, and returned in network order (suitable for
--- 61,90 ----
  #ifndef _NETDB_H_
  #define _NETDB_H_
  
! #ifndef WINNT
! #include <sys/param.h>
! #endif /* WINNT */
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #endif
! #include <sys/cdefs.h>
! 
! #ifndef WINNT
! #define	_PATH_HEQUIV	"/etc/hosts.equiv"
! #define	_PATH_HOSTS	"/etc/hosts"
! #define	_PATH_NETWORKS	"/etc/networks"
! #define	_PATH_PROTOCOLS	"/etc/protocols"
  #define	_PATH_SERVICES	"/etc/services"
  
  extern int h_errno;
+ #else /* WINNT */
+ #define	_PATH_HOSTS	"%windir%\\SYSTEM32\\DRIVERS\\ETC\\HOSTS"
+ #define	_PATH_NETWORKS	"%windir%\\SYSTEM32\\DRIVERS\\ETC\\NETWORKS"
+ #define	_PATH_PROTOCOL	"%windir%\\SYSTEM32\\DRIVERS\\ETC\\PROTOCOL"
+ #define	_PATH_SERVICES	"%windir%\\SYSTEM32\\DRIVERS\\ETC\\SERVICES"
+ #endif /* WINNT */
  
+ #ifndef WINNT
  /*
   * Structures returned by network data base library.  All addresses are
   * supplied in host order, and returned in network order (suitable for
***************
*** 112,117 ****
--- 122,128 ----
  	char	**p_aliases;	/* alias list */
  	int	p_proto;	/* protocol # */
  };
+ #endif /* WINNT */
  
  /*
   * Error return codes from gethostbyname() and gethostbyaddr()
***************
*** 120,148 ****
  
  #define	NETDB_INTERNAL	-1	/* see errno */
  #define	NETDB_SUCCESS	0	/* no problem */
  #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
  #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
  #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  #define	NO_DATA		4 /* Valid name, no data record of requested type */
  #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
  
  __BEGIN_DECLS
  void		endhostent __P((void));
  void		endnetent __P((void));
  void		endprotoent __P((void));
  void		endservent __P((void));
  struct hostent	*gethostbyaddr __P((const char *, int, int));
  struct hostent	*gethostbyname __P((const char *));
  struct hostent	*gethostbyname2 __P((const char *, int));
  struct hostent	*gethostent __P((void));
! struct netent	*getnetbyaddr __P((unsigned long, int));
  struct netent	*getnetbyname __P((const char *));
  struct netent	*getnetent __P((void));
  struct protoent	*getprotobyname __P((const char *));
  struct protoent	*getprotobynumber __P((int));
  struct protoent	*getprotoent __P((void));
  struct servent	*getservbyname __P((const char *, const char *));
  struct servent	*getservbyport __P((int, const char *));
  struct servent	*getservent __P((void));
  void		herror __P((const char *));
  const char	*hstrerror __P((int));
--- 131,175 ----
  
  #define	NETDB_INTERNAL	-1	/* see errno */
  #define	NETDB_SUCCESS	0	/* no problem */
+ #ifndef WINNT
  #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
  #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
  #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  #define	NO_DATA		4 /* Valid name, no data record of requested type */
  #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
+ #endif /* WINNT */
  
  __BEGIN_DECLS
  void		endhostent __P((void));
  void		endnetent __P((void));
  void		endprotoent __P((void));
  void		endservent __P((void));
+ #ifndef WINNT
  struct hostent	*gethostbyaddr __P((const char *, int, int));
  struct hostent	*gethostbyname __P((const char *));
  struct hostent	*gethostbyname2 __P((const char *, int));
  struct hostent	*gethostent __P((void));
! struct netent	*getnetbyaddr __P((unsigned long, int)); /* u_long? */
! struct netent	*getnetbyname __P((const char *));
! #else
! struct hostent	*gethostbyaddr_nt __P((const char *, int, int));
! struct hostent	*gethostbyname_nt __P((const char *));
! struct hostent	*gethostbyname2 __P((const char *, int));
! struct hostent	*gethostent __P((void));
! struct netent	*getnetbyaddr __P((unsigned long, int)); /* u_long? */
  struct netent	*getnetbyname __P((const char *));
+ #endif
+ 
  struct netent	*getnetent __P((void));
+ #ifndef WINNT
  struct protoent	*getprotobyname __P((const char *));
  struct protoent	*getprotobynumber __P((int));
+ #endif
  struct protoent	*getprotoent __P((void));
+ #ifndef WINNT
  struct servent	*getservbyname __P((const char *, const char *));
  struct servent	*getservbyport __P((int, const char *));
+ #endif
  struct servent	*getservent __P((void));
  void		herror __P((const char *));
  const char	*hstrerror __P((int));
diff --context --recurs m:\bind494rel/include/resolv.h m:\bind/include/resolv.h
*** m:\bind494rel/include/resolv.h	Thu Jun 27 19:27:50 1996
--- m:\bind/include/resolv.h	Sat Jun 08 01:49:20 1996
***************
*** 61,74 ****
  #ifndef _RESOLV_H_
  #define	_RESOLV_H_
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #else
! # include <sys/types.h>
! #endif
! #include <sys/cdefs.h>
! #include <stdio.h>
  
  /*
   * revision information.  this is the release date in YYYYMMDD format.
--- 61,80 ----
  #ifndef _RESOLV_H_
  #define	_RESOLV_H_
  
! #ifndef WINNT
! #include <sys/param.h>
! #endif
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #else
! # include <sys/types.h>
! #endif
! #include <sys/cdefs.h>
! #include <stdio.h>
! #ifdef WINNT
! #define FD_SETSIZE 512
! #include <winsock.h>
! #endif
  
  /*
   * revision information.  this is the release date in YYYYMMDD format.
***************
*** 87,93 ****
--- 93,104 ----
   */
  
  #ifndef _PATH_RESCONF
+ #ifndef WINNT
  #define _PATH_RESCONF        "/etc/resolv.conf"
+ #else
+ #define _PATH_RESCONF		 "%windir%\\RESOLV.CONF"
+ #define _ALT_PATH_RESCONF	 "%windir%\\RESOLV.INI"
+ #endif /* WINNT */
  #endif
  
  /*
Only in m:\bind: install
Only in m:\bind: install.txt
Only in m:\bind: mk2.bat
Only in m:\bind: mkdist.bat
Only in m:\bind: mksrc.bat
Only in m:\bind: mktxt.bat
Only in m:\bind/named: TAGS
Only in m:\bind494rel/named: Version.c
Only in m:\bind/named: WinDebug
Only in m:\bind/named: WinRel
diff --context --recurs m:\bind494rel/named/db_defs.h m:\bind/named/db_defs.h
*** m:\bind494rel/named/db_defs.h	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_defs.h	Sat Jun 01 03:48:38 1996
***************
*** 76,82 ****
   */
  struct databuf {
  	struct databuf	*d_next;	/* linked list */
! 	u_int32_t	d_ttl;		/* time to live */
  					/* if d_zone == DB_Z_CACHE, then
  					 * d_ttl is actually the time when
  					 * the record will expire.
--- 76,86 ----
   */
  struct databuf {
  	struct databuf	*d_next;	/* linked list */
! #ifndef WINNT
! 	u_int32_t	d_ttl;		/* time to live */
! #else
! 	int32_t	        d_ttl;		/* time to live */
! #endif
  					/* if d_zone == DB_Z_CACHE, then
  					 * d_ttl is actually the time when
  					 * the record will expire.
diff --context --recurs m:\bind494rel/named/db_dump.c m:\bind/named/db_dump.c
*** m:\bind494rel/named/db_dump.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_dump.c	Sat Jun 08 01:48:53 1996
***************
*** 58,73 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <netdb.h>
! #include <stdio.h>
! #include <syslog.h>
! #include <resolv.h>
  #include <errno.h>
  
  #include "named.h"
--- 58,77 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <netdb.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <resolv.h>
  #include <errno.h>
  
  #include "named.h"
***************
*** 79,84 ****
--- 83,91 ----
  static void		putbyte __P((int, char **));
  #endif
  
+ char * inet_nsap_ntoa();
+ const char * inet_ntop();
+ 
  /*
   * Dump current cache in a format similar to RFC 883.
   *
***************
*** 422,428 ****
  				    fprintf(fp, "%d\t",
  				        (int)(dp->d_ttl - tt.tv_sec));
  			} else if (dp->d_ttl != USE_MINIMUM &&
! 			    dp->d_ttl != zones[dp->d_zone].z_minimum)
  				fprintf(fp, "%d\t", (int)dp->d_ttl);
  			else if (tab)
  			    (void) putc('\t', fp);
--- 429,435 ----
  				    fprintf(fp, "%d\t",
  				        (int)(dp->d_ttl - tt.tv_sec));
  			} else if (dp->d_ttl != USE_MINIMUM &&
! 			    (u_int32_t)dp->d_ttl != zones[dp->d_zone].z_minimum)
  				fprintf(fp, "%d\t", (int)dp->d_ttl);
  			else if (tab)
  			    (void) putc('\t', fp);
***************
*** 588,594 ****
  				if (dp->d_size == INT32SZ) {
  					GETLONG(n, cp);
  				} else {
! 					n = -2;		/* XXX - hack */
  				}
  				fprintf(fp, "%u", n);
  				break;
--- 595,601 ----
  				if (dp->d_size == INT32SZ) {
  					GETLONG(n, cp);
  				} else {
! 					n = (u_int32_t) -2;		/* XXX - hack */
  				}
  				fprintf(fp, "%u", n);
  				break;
diff --context --recurs m:\bind494rel/named/db_glue.c m:\bind/named/db_glue.c
*** m:\bind494rel/named/db_glue.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_glue.c	Sat Jun 08 01:49:03 1996
***************
*** 59,74 ****
   */
  
  #include <sys/types.h>
! #include <sys/uio.h>
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <stdio.h>
! #include <syslog.h>
! #include <ctype.h>
! #include <netdb.h>
  #include <resolv.h>
  #include <errno.h>
  #include <signal.h>
--- 59,78 ----
   */
  
  #include <sys/types.h>
! #ifndef WINNT
! #include <sys/uio.h>
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <ctype.h>
! #include <netdb.h>
  #include <resolv.h>
  #include <errno.h>
  #include <signal.h>
***************
*** 122,129 ****
--- 126,140 ----
  		syslog(LOG_CRIT, "%s - ABORT", msg);
  	else
  		syslog(LOG_CRIT, "%s: %s - ABORT", msg, strerror(err));
+ #ifndef WINNT
  	signal(SIGIOT, SIG_DFL);	/* no POSIX needed here. */
  	abort();
+ #else
+   	/* under Windows, abort() does not call raise(SIGABRT)
+   	 * or flush stream buffers
+   	 */
+   	 exit(3);
+   #endif
  }
  
  void
***************
*** 139,151 ****
  #endif
  	while (sp = getservent()) {
  		slp = (struct valuelist *)malloc(sizeof(struct valuelist));
! 		if (!slp)
! 			panic(errno, "malloc(servent)");
! 		slp->name = savestr(sp->s_name);
  		slp->proto = savestr(sp->s_proto);
! 		slp->port = ntohs((u_int16_t)sp->s_port);  /* host byt order */
! 		slp->next = servicelist;
! 		slp->prev = NULL;
  		if (servicelist)
  			servicelist->prev = slp;
  		servicelist = slp;
--- 150,162 ----
  #endif
  	while (sp = getservent()) {
  		slp = (struct valuelist *)malloc(sizeof(struct valuelist));
!  		if (!slp)
!   			panic(errno, "malloc(servent)");
!  		slp->name  = savestr(sp->s_name);
  		slp->proto = savestr(sp->s_proto);
! 		slp->port = ntohs((u_int16_t)sp->s_port); /* host byte order */
! 		slp->next  = servicelist;
! 		slp->prev  = NULL;
  		if (servicelist)
  			servicelist->prev = slp;
  		servicelist = slp;
***************
*** 368,378 ****
--- 379,402 ----
  	int s;
  
  	do {
+ #ifndef WINNT
  		errno = 0;
+ #else
+ 		WSASetLastError(0);
+ #endif
+ #ifndef WINNT
  		s = close(fd);
  	} while (s < 0 && errno == EINTR);
+ #else
+ 		s = closesocket(fd);
+ 	} while (s < 0 && errno == WSAEINTR);
+ #endif
  
+ #ifndef WINNT
  	if (s < 0 && errno != EBADF)
+ #else
+ 	if (s < 0 && errno != WSAEBADF)
+ #endif
  		syslog(LOG_INFO, "close(%d) failed: %m", fd);
  	else
  		dprintf(3, (ddt, "close(%d) succeeded\n", fd));
***************
*** 790,795 ****
--- 814,820 ----
  }
  
  /* Signal abstraction. */
+ #ifndef WINNT
  
  void
  setsignal(catch, block, handler)
***************
*** 833,835 ****
--- 858,861 ----
  	setsignal(catch, block, handler);
  #endif
  }
+ #endif /* WINNT */
diff --context --recurs m:\bind494rel/named/db_load.c m:\bind/named/db_load.c
*** m:\bind494rel/named/db_load.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_load.c	Sat Jun 01 03:48:18 1996
***************
*** 62,77 ****
   * Load data base from ascii backupfile.  Format similar to RFC 883.
   */
  
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #include <syslog.h>
! #include <ctype.h>
! #include <netdb.h>
  #include <resolv.h>
  #include <errno.h>
  
--- 62,84 ----
   * Load data base from ascii backupfile.  Format similar to RFC 883.
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #else
! #include <sys/types.h>
! #include <sys/stat.h>
! #endif
! #include <ctype.h>
! #include <netdb.h>
  #include <resolv.h>
  #include <errno.h>
  
***************
*** 90,95 ****
--- 97,104 ----
  
  static int		empty_token = 0;
  int	getnum_error;
+ u_int inet_nsap_addr();
+ int inet_pton();
  
  /*
   * Map class and type names to number
***************
*** 200,206 ****
--- 209,219 ----
  	FILE *fp;
  	int slineno, i, errs, didinclude;
  	register u_int32_t n;
+ #ifndef WINNT
  	struct stat sb;
+ #else
+ 	struct _stat sb;
+ #endif
  	struct in_addr ina;
  	int escape;
  	enum transport transport;
***************
*** 239,245 ****
  	(void) strcpy(origin, in_origin);
  	if ((fp = fopen(filename, "r")) == NULL) {
  		syslog(LOG_WARNING, "%s: %m", filename);
! 		dprintf(1, (ddt, "db_load: error opening file %s\n",
  			    filename));
  		return (-1);
  	}
--- 252,258 ----
  	(void) strcpy(origin, in_origin);
  	if ((fp = fopen(filename, "r")) == NULL) {
  		syslog(LOG_WARNING, "%s: %m", filename);
! 		dprintf(1, (ddt, "db_load: error opening file %s \n",
  			    filename));
  		return (-1);
  	}
***************
*** 256,262 ****
--- 269,279 ----
  		dataflags = 0;
  	}
  	gettime(&tt);
+ #ifndef WINNT
  	if (fstat(fileno(fp), &sb) < 0) {
+ #else
+ 	if (_fstat(fileno(fp), &sb) < 0) {
+ #endif
  		syslog(LOG_WARNING, "%s: %m", filename);
  		sb.st_mtime = (int)tt.tv_sec;
  	}
***************
*** 325,331 ****
  			if (isdigit(*cp)) {
  				n = 0;
  				do {
! 				    if (n > (INT_MAX - (*cp - '0')) / 10) {
  					syslog(LOG_INFO, 
  					   "%s: line %d: number > %lu\n",
  					   filename, lineno, (u_long)INT_MAX);
--- 342,348 ----
  			if (isdigit(*cp)) {
  				n = 0;
  				do {
! 				    if (n > (((u_int32_t)INT_MAX - (u_int32_t)(*cp - '0')) / (u_int32_t)10)) {
  					syslog(LOG_INFO, 
  					   "%s: line %d: number > %lu\n",
  					   filename, lineno, (u_long)INT_MAX);
***************
*** 338,344 ****
  				if (zp->z_type == Z_CACHE) {
  				    /* this allows the cache entry to age */
  				    /* while sitting on disk (powered off) */
! 				    if (n > max_cache_ttl)
  					n = max_cache_ttl;
  				    n += sb.st_mtime;
  				}
--- 355,361 ----
  				if (zp->z_type == Z_CACHE) {
  				    /* this allows the cache entry to age */
  				    /* while sitting on disk (powered off) */
! 				    if (n > (u_int32_t)max_cache_ttl)
  					n = max_cache_ttl;
  				    n += sb.st_mtime;
  				}
***************
*** 577,583 ****
--- 594,604 ----
  						goto err;
  				}
                                  read_soa++;
+ #ifndef WINNT
  				if (zp->z_expire < zp->z_refresh ) {
+ #else
+ 				if ((u_int32_t)zp->z_expire < zp->z_refresh ) {
+ #endif
  				    syslog(LOG_WARNING,
      "%s: WARNING SOA expire value is less then SOA refresh (%lu < %lu)",
  				    filename, zp->z_expire, zp->z_refresh);
***************
*** 723,729 ****
  				    i = (sizeof data) * 255 / 256;
  				}
  				while (i > 255) {
! 				    *cp++ = 255;
  				    bcopy(cp1, cp, 255);
  				    cp += 255;
  				    cp1 += 255;
--- 744,750 ----
  				    i = (sizeof data) * 255 / 256;
  				}
  				while (i > 255) {
! 				    *cp++ = (char)255;
  				    bcopy(cp1, cp, 255);
  				    cp += 255;
  				    cp1 += 255;
diff --context --recurs m:\bind494rel/named/db_lookup.c m:\bind/named/db_lookup.c
*** m:\bind494rel/named/db_lookup.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_lookup.c	Sat Jun 01 03:48:19 1996
***************
*** 62,71 ****
   * Table lookup routines.
   */
  
! #include <syslog.h>
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
  #include <arpa/nameser.h>
  #include <stdio.h>
  #include <ctype.h>
--- 62,73 ----
   * Table lookup routines.
   */
  
! #ifndef WINNT
! #include <syslog.h>
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
  #include <arpa/nameser.h>
  #include <stdio.h>
  #include <ctype.h>
diff --context --recurs m:\bind494rel/named/db_reload.c m:\bind/named/db_reload.c
*** m:\bind494rel/named/db_reload.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_reload.c	Sat Jun 01 03:48:19 1996
***************
*** 58,69 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <stdio.h>
! #include <syslog.h>
  
  #include "named.h"
  
--- 58,73 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
  
  #include "named.h"
  
diff --context --recurs m:\bind494rel/named/db_save.c m:\bind/named/db_save.c
*** m:\bind494rel/named/db_save.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_save.c	Sat Jun 01 03:48:20 1996
***************
*** 62,72 ****
   * Buffer allocation and deallocation routines.
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <syslog.h>
  #include <stdio.h>
  #include <errno.h>
  #include <assert.h>
--- 62,76 ----
   * Buffer allocation and deallocation routines.
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
  #include <stdio.h>
  #include <errno.h>
  #include <assert.h>
diff --context --recurs m:\bind494rel/named/db_secure.c m:\bind/named/db_secure.c
*** m:\bind494rel/named/db_secure.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_secure.c	Sat Jun 01 03:48:21 1996
***************
*** 6,17 ****
  
  #include <stdio.h>
  #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <syslog.h>
! #include <errno.h>
  
  #include "named.h"
  
--- 6,22 ----
  
  #include <stdio.h>
  #include <sys/types.h>
! #ifndef WINNT
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #ifndef WINNT
! #include <syslog.h>
! #include <errno.h>
! 
! #endif
  
  #include "named.h"
  
diff --context --recurs m:\bind494rel/named/db_update.c m:\bind/named/db_update.c
*** m:\bind494rel/named/db_update.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/db_update.c	Sat Jun 01 03:48:22 1996
***************
*** 59,69 ****
   */
  
  #include <stdio.h>
! #include <syslog.h>
! 
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  #include <resolv.h>
--- 59,70 ----
   */
  
  #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  #include <resolv.h>
Only in m:\bind/named: ipaddr.mak
Only in m:\bind/named: ipaddr.mdp
Only in m:\bind/named: ipaddr.ncb
Only in m:\bind/named: ipaddr.vcp
Only in m:\bind/named: ipadr.c
diff --context --recurs m:\bind494rel/named/named-xfer.c m:\bind/named/named-xfer.c
*** m:\bind494rel/named/named-xfer.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/named-xfer.c	Sat Jun 08 01:49:09 1996
***************
*** 73,103 ****
  static char rcsid[] = "$Id: named-xfer.c,v 8.14 1996/06/06 20:19:14 vixie Exp $";
  #endif /* not lint */
  
! #include <sys/param.h>
! #include <sys/file.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! 
! #include <netinet/in.h>
! #if defined(__osf__)
! # include <sys/mbuf.h>
! # include <net/route.h>
  #endif
  #if defined(_AIX)
  # include <sys/time.h>
  # define TIME_H_INCLUDED
  #endif
  #include <net/if.h>
  #include <netdb.h>
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
- 
  #include <errno.h>
  #include <resolv.h>
  #include <stdio.h>
  #include <syslog.h>
  #if !defined(SVR4) || !defined(sun)
! # include <math.h>
  #endif
  #include <ctype.h>
  #include <signal.h>
--- 73,111 ----
  static char rcsid[] = "$Id: named-xfer.c,v 8.14 1996/06/06 20:19:14 vixie Exp $";
  #endif /* not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/file.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #if defined(__osf__)
! # include <sys/mbuf.h>
! # include <net/route.h>
  #endif
  #if defined(_AIX)
  # include <sys/time.h>
  # define TIME_H_INCLUDED
  #endif
  #include <net/if.h>
+ 
+ #else
+ #include <sys/stat.h>
+ #include <limits.h>
+ #endif /* WINNT */
  #include <netdb.h>
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  #include <errno.h>
  #include <resolv.h>
  #include <stdio.h>
+ #ifndef WINNT
  #include <syslog.h>
+ #else
+ #include <stdlib.h>
+ #endif
  #if !defined(SVR4) || !defined(sun)
! #include <math.h>
  #endif
  #include <ctype.h>
  #include <signal.h>
***************
*** 110,119 ****
--- 118,139 ----
  # define LOG_PERROR 0
  #endif
  
+ #ifdef WINNT
+ #define exit(x) ExitProcess(x);
+ HANDLE hReadWriteEvent = NULL;
+ char pathtmpxfer[MAX_PATH], pathtmpdir[MAX_PATH];
+ #endif
+ 
  static	struct zoneinfo	zone;		/* zone information */
+ char * inet_nsap_ntoa();
+ const char * inet_ntop();
  
+ #ifndef WINNT
  static	char		ddtfilename[] = _PATH_TMPXFER,
  			*ddtfile = ddtfilename,
+ #else
+ static char	*ddtfile = pathtmpxfer,
+ #endif
  			*tmpname,
  			*domain;		/* domain being xfered */
  
***************
*** 131,137 ****
--- 151,159 ----
  static	int		getzone __P((struct zoneinfo *, u_int32_t, int)),
  			print_output __P((u_char *, int, u_char *)),
  			netread __P((int, char *, int, int));
+ #ifndef WINNT
  static	SIG_FN		read_alarm __P(());
+ #endif
  static	const char	*soa_zinfo __P((struct zoneinfo *, u_char *, u_char*));
  
  extern char *optarg;
***************
*** 145,151 ****
  	register struct zoneinfo *zp;
  	register struct hostent *hp;
   	char *dbfile = NULL, *tracefile = NULL, *tm = NULL;
! 	int dbfd, ddtd, result, c, fd, closed = 0;
  	u_int32_t serial_no = 0;
  	u_int16_t port = htons(NAMESERVER_PORT);
  	struct stat statbuf;
--- 167,176 ----
  	register struct zoneinfo *zp;
  	register struct hostent *hp;
   	char *dbfile = NULL, *tracefile = NULL, *tm = NULL;
! 	int dbfd, ddtd, result, c, closed = 0;
! #ifndef WINNT
! 	int fd;
! #endif
  	u_int32_t serial_no = 0;
  	u_int16_t port = htons(NAMESERVER_PORT);
  	struct stat statbuf;
***************
*** 156,161 ****
--- 181,198 ----
  	int class = C_IN;
  #endif
  
+ #ifdef WINNT
+  	WORD wVersionRequested;
+ 	WSADATA wsaData;
+ 
+ 	wVersionRequested = MAKEWORD(1,1);
+ 	if (WSAStartup(wVersionRequested, &wsaData)) {
+ 		syslog(LOG_ERR, "No useable winsock.dll: %m");
+ 		exit(XFER_FAIL); 
+ 	}
+ 
+ #endif
+ 
  	if (ProgName = strrchr(argv[0], '/'))
  		ProgName++;
  	else
***************
*** 163,183 ****
--- 200,233 ----
  
  	(void) umask(022);
  
+ #ifndef WINNT
  	/* this is a hack; closing everything in the parent is hard. */
  	for (fd = getdtablesize()-1;  fd > STDERR_FILENO;  fd--)
  		closed += (close(fd) == 0);
+ #endif
  
  #ifdef RENICE
  	nice(-40);	/* this is the recommended procedure to        */
  	nice(20);	/*   reset the priority of the current process */
  	nice(0);	/*   to "normal" (== 0) - see nice(3)          */
  #endif
+ #ifdef WINNT
+ 	(void) SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
+ 	if (!GetTempPath(MAX_PATH, pathtmpdir))
+ 		syslog(LOG_ERR, "GetTempPath() failed: %m");
+ 	else {
+ 		strcpy(pathtmpxfer, pathtmpdir);
+ 		strcat(pathtmpxfer, _PATH_TMPXFER);
+ 	}
+ #endif
  
+ #ifndef WINNT
  #ifdef LOG_DAEMON
  	openlog(ProgName, LOG_PID|LOG_CONS|LOG_PERROR, LOGFAC);
  #else
  	openlog(ProgName, LOG_PID);
  #endif
+ #endif /* WINNT */
  #ifdef STUBS
  	while ((c = getopt(argc, argv, "C:d:l:s:t:z:f:p:P:qS")) != EOF)
  #else
***************
*** 325,330 ****
--- 375,381 ----
  	 * considers important- if not, the user controlling named with
  	 * signals usually kills us.
  	 */
+ #ifndef WINNT
  	(void) signal(SIGHUP, SIG_IGN);
  #ifdef SIGSYS
  	(void) signal(SIGSYS, SIG_IGN);
***************
*** 345,357 ****
  	(void) signal(SIGEMT, SIG_IGN);
  	(void) signal(SIGFPE, SIG_IGN);
  #endif /* SIGUSR1&&SIGUSR2 */
  
  	dprintf(1, (ddt,
  		    "domain `%s'; file `%s'; serial %lu; closed %d\n",
  		    domain, dbfile, (u_long)serial_no, closed));
  
! 	buildservicelist();
! 	buildprotolist();
  
  	/* init zone data */
   
--- 396,409 ----
  	(void) signal(SIGEMT, SIG_IGN);
  	(void) signal(SIGFPE, SIG_IGN);
  #endif /* SIGUSR1&&SIGUSR2 */
+ #endif /* WINNT */
  
  	dprintf(1, (ddt,
  		    "domain `%s'; file `%s'; serial %lu; closed %d\n",
  		    domain, dbfile, (u_long)serial_no, closed));
  
! 	  buildservicelist();
! 	  buildprotolist();
  
  	/* init zone data */
   
***************
*** 378,394 ****
  	for (;  optind != argc;  optind++) {
  		tm = argv[optind];
  		if (!inet_aton(tm, &zp->z_addr[zp->z_addrcnt])) {
! 			hp = gethostbyname(tm);
  			if (hp == NULL) {
  				syslog(LOG_NOTICE,
  				       "uninterpretable server (%s) for %s\n",
! 				       tm, zp->z_origin);
  				continue;
  			}
! 			bcopy(hp->h_addr,
  			      (char *)&zp->z_addr[zp->z_addrcnt],
  			      INADDRSZ);
  			dprintf(1, (ddt, "Arg: \"%s\"\n", tm));
  		}
  		if (zp->z_addr[zp->z_addrcnt].s_addr == 0) {
  			syslog(LOG_NOTICE,
--- 430,458 ----
  	for (;  optind != argc;  optind++) {
  		tm = argv[optind];
  		if (!inet_aton(tm, &zp->z_addr[zp->z_addrcnt])) {
! /*#ifndef WINNT
! 		   hp = gethostbyname(tm);
! #else
! 		   hp = gethostbyname_nt(tm);
! #endif
! */
! /* lgk we may want the above code someday but for now use gethostbyname under nt
! (not the new version which will not resolve locahost or names in the host file ..
! this means ip6 will not work with xfer for now */
! 
!             hp = gethostbyname(tm);
  			if (hp == NULL) {
  				syslog(LOG_NOTICE,
  				       "uninterpretable server (%s) for %s\n",
! 				       tm, zp->z_origin); 
! 
  				continue;
  			}
!                   bcopy(hp->h_addr,
  			      (char *)&zp->z_addr[zp->z_addrcnt],
  			      INADDRSZ);
  			dprintf(1, (ddt, "Arg: \"%s\"\n", tm));
+ 
  		}
  		if (zp->z_addr[zp->z_addrcnt].s_addr == 0) {
  			syslog(LOG_NOTICE,
***************
*** 408,417 ****
--- 472,498 ----
  	_res.options &= ~(RES_DEFNAMES | RES_DNSRCH | RES_RECURSE);
  	result = getzone(zp, serial_no, port);
  	(void) my_fclose(dbfp);
+ 
+     /* lgk add code to close ddtfile here */
+ #ifdef DEBUG
+ 	if (debug)
+       (void) my_fclose(ddt);
+ #endif
+ 
  	switch (result) {
  
  	case XFER_SUCCESS:			/* ok exit */
+ #ifndef WINNT
  		if (rename(tmpname, dbfile) == -1) {
+ #else /* lgk get rid of the ddt file if txfer ok in debug mode */
+ #ifdef DEBUG
+         if (debug)
+           (void) unlink(ddtfile);
+ #endif
+ 
+ 		/* C run time rename function under NT does not overwrite */
+ 		if(!MoveFileEx(tmpname, dbfile, MOVEFILE_REPLACE_EXISTING)) {
+ #endif
  			perror("rename");
  			if (!quiet)
  			    syslog(LOG_ERR, "rename %s to %s: %m",
***************
*** 420,442 ****
  		}
  		exit(XFER_SUCCESS);
  
  	case XFER_UPTODATE:		/* the zone was already uptodate */
  		(void) unlink(tmpname);
  		exit(XFER_UPTODATE);
  
  	case XFER_TIMEOUT:
  #ifdef DEBUG
  		if (!debug)
  #endif
! 		    (void) unlink(tmpname);
  		exit(XFER_TIMEOUT);	/* servers not reachable exit */
  
  	case XFER_FAIL:
  	default:
  #ifdef DEBUG
  		if (!debug)
! #endif
! 		    (void) unlink(tmpname);
  		exit(XFER_FAIL);	/* yuck exit */
  	}
  	/*NOTREACHED*/
--- 501,528 ----
  		}
  		exit(XFER_SUCCESS);
  
+ /* lgk add code to get rid of the ddt files if not in debug mode.. */
  	case XFER_UPTODATE:		/* the zone was already uptodate */
  		(void) unlink(tmpname);
+ #ifdef DEBUG
+         if (debug)
+           (void) unlink(ddtfile);
+ #endif
  		exit(XFER_UPTODATE);
  
  	case XFER_TIMEOUT:
  #ifdef DEBUG
  		if (!debug)
  #endif
! 		(void) unlink(tmpname);
  		exit(XFER_TIMEOUT);	/* servers not reachable exit */
  
  	case XFER_FAIL:
  	default:
  #ifdef DEBUG
  		if (!debug)
! #endif      
! 		(void) unlink(tmpname);
  		exit(XFER_FAIL);	/* yuck exit */
  	}
  	/*NOTREACHED*/
***************
*** 475,481 ****
  
  #define DEF_DNAME	'\001'		/* '\0' means the root domain */
  /* XXX: The following variables should probably all be "static" */
! int	minimum_ttl = 0, got_soa = 0;
  int	prev_comment = 0;		/* was previous record a comment? */
  char	zone_top[MAXDNAME];		/* the top of the zone */
  char	prev_origin[MAXDNAME];		/* from most recent $ORIGIN line */
--- 561,568 ----
  
  #define DEF_DNAME	'\001'		/* '\0' means the root domain */
  /* XXX: The following variables should probably all be "static" */
! u_int32_t	minimum_ttl = 0;
! int	got_soa = 0;
  int	prev_comment = 0;		/* was previous record a comment? */
  char	zone_top[MAXDNAME];		/* the top of the zone */
  char	prev_origin[MAXDNAME];		/* from most recent $ORIGIN line */
***************
*** 499,512 ****
  	char name[MAXDNAME], name2[MAXDNAME];
  	struct sockaddr_in sin;
  	struct zoneinfo zp_start, zp_finish;
  #ifdef POSIX_SIGNALS
  	struct sigaction sv, osv;
  #else
  	struct sigvec sv, osv;
  #endif
! 	int qdcount, ancount, aucount, class, type;
  	const char *badsoa_msg = "Nil";
  
  #ifdef DEBUG
  	if (debug) {
  		(void)fprintf(ddt,"getzone() %s ", zp->z_origin);
--- 586,608 ----
  	char name[MAXDNAME], name2[MAXDNAME];
  	struct sockaddr_in sin;
  	struct zoneinfo zp_start, zp_finish;
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  	struct sigaction sv, osv;
  #else
  	struct sigvec sv, osv;
  #endif
! #endif
! 	u_short qdcount, ancount, aucount;
! 	int class, type;
  	const char *badsoa_msg = "Nil";
  
+ #ifdef WINNT
+ /* lgk moved startup to beginning.. */
+ 
+ 	hReadWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ #endif /* WINNT */
+ 
  #ifdef DEBUG
  	if (debug) {
  		(void)fprintf(ddt,"getzone() %s ", zp->z_origin);
***************
*** 522,527 ****
--- 618,625 ----
  		}
  	}
  #endif
+ 
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  	bzero((char *)&sv, sizeof sv);
  	sv.sa_handler = (SIG_FN (*)()) read_alarm;
***************
*** 536,541 ****
--- 634,640 ----
  	sv.sv_mask = ~0;
  	(void) sigvec(SIGALRM, &sv, &osv);
  #endif
+ #endif /* WINNT */
  
  	strcpy(zone_top, zp->z_origin);
  	if ((l = strlen(zone_top)) != 0 && zone_top[l - 1] == '.')
***************
*** 558,563 ****
--- 657,663 ----
  			}
  			bufsize = 2 * PACKETSZ;
  		}
+ 
  		bzero((char *)&sin, sizeof(sin));
  		sin.sin_family = AF_INET;
  		sin.sin_port = (u_int16_t)port;
***************
*** 566,572 ****
  			syslog(LOG_INFO, "socket: %m");
  			error++;
  			break;
! 		}	
  		dprintf(2, (ddt, "connecting to server #%d [%s].%d\n",
  			    cnt+1, inet_ntoa(sin.sin_addr),
  			    ntohs(sin.sin_port)));
--- 666,672 ----
  			syslog(LOG_INFO, "socket: %m");
  			error++;
  			break;
! 		}
  		dprintf(2, (ddt, "connecting to server #%d [%s].%d\n",
  			    cnt+1, inet_ntoa(sin.sin_addr),
  			    ntohs(sin.sin_port)));
***************
*** 590,600 ****
--- 690,702 ----
  				       "zone %s: res_mkquery T_SOA failed",
  				       zp->z_origin);
  			(void) my_close(s);
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  			(void) sigaction(SIGALRM, &osv, (struct sigaction *)0);
  #else
  			(void) sigvec(SIGALRM, &osv, (struct sigvec *)0);
  #endif
+ #endif /* WINNT */
  			return (XFER_FAIL);
  		}
  		/*
***************
*** 642,650 ****
  		}
  #endif
  		hp = (HEADER *) buf;
! 		qdcount = ntohs(hp->qdcount);
! 		ancount = ntohs(hp->ancount);
! 		aucount = ntohs(hp->nscount);
  
  		/*
  		 * close socket if any of these apply:
--- 744,752 ----
  		}
  #endif
  		hp = (HEADER *) buf;
! 		qdcount = ntohs( (u_short) hp->qdcount);
! 		ancount = ntohs( (u_short) hp->ancount);
! 		aucount = ntohs( (u_short) hp->nscount);
  
  		/*
  		 * close socket if any of these apply:
***************
*** 791,796 ****
--- 893,899 ----
  							       zp->z_origin);
  						}
  						(void) my_close(s);
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  						sigaction(SIGALRM, &osv,
  							(struct sigaction *)0);
***************
*** 798,803 ****
--- 901,907 ----
  						sigvec(SIGALRM, &osv,
  						       (struct sigvec *)0);
  #endif
+ #endif /* WINNT */
  						return (XFER_FAIL);
  					}
  					/*
***************
*** 858,879 ****
  				tmp = cp + n;
  #ifdef STUBS
  			if (zp->z_type == Z_STUB) {
! 				ancount = ntohs(hp->ancount);
! 				for (cnt = 0 ; cnt < ancount ; cnt++) {
  
  					n = print_output(buf, bufsize, cp);
  					cp += n;
  				}
  				if (hp->nscount) {
  					/* we should not get here */
! 					ancount = ntohs(hp->nscount);
! 					for (cnt = 0 ; cnt < ancount ; cnt++) {
  					    n = print_output(buf, bufsize, cp);
  						cp += n;
  					}
  				}
! 				ancount = ntohs(hp->arcount);
! 				for (cnt = 0 ; cnt < ancount ; cnt ++) {
  					n = print_output(buf, bufsize, cp);
  					cp += n;
  				}
--- 962,983 ----
  				tmp = cp + n;
  #ifdef STUBS
  			if (zp->z_type == Z_STUB) {
! 				ancount = ntohs( (u_short) hp->ancount);
! 				for (cnt = 0 ; cnt < (u_int) ancount ; cnt++) {
  
  					n = print_output(buf, bufsize, cp);
  					cp += n;
  				}
  				if (hp->nscount) {
  					/* we should not get here */
! 					ancount = ntohs( (u_short) hp->nscount);
! 					for (cnt = 0 ; cnt < (u_int) ancount ; cnt++) {
  					    n = print_output(buf, bufsize, cp);
  						cp += n;
  					}
  				}
! 				ancount = ntohs( (u_short) hp->arcount);
! 				for (cnt = 0 ; cnt < (u_int) ancount ; cnt ++) {
  					n = print_output(buf, bufsize, cp);
  					cp += n;
  				}
***************
*** 887,893 ****
  		
  			} else {
  #endif /*STUBS*/
! 				ancount = ntohs(hp->ancount);
  				for (cnt = 0; cnt < ancount; cnt++) {
  					n = print_output(buf, bufsize, cp);
  					cp += n;
--- 991,997 ----
  		
  			} else {
  #endif /*STUBS*/
! 				ancount = ntohs((u_short)hp->ancount);
  				for (cnt = 0; cnt < ancount; cnt++) {
  					n = print_output(buf, bufsize, cp);
  					cp += n;
***************
*** 978,984 ****
--- 1082,1093 ----
  					 * and seek to beginning to restart.
  					 */
  					fflush(dbfp);
+ #ifndef WINNT
  					if (ftruncate(fileno(dbfp), 0) != 0) {
+ #else
+ 					if (fseek(dbfp, 0L, SEEK_SET) || 
+ 						!SetEndOfFile((HANDLE)fileno(dbfp))) {
+ #endif
  						if (!quiet)
  						    syslog(LOG_INFO,
  							  "ftruncate %s: %m\n",
***************
*** 998,1009 ****
--- 1107,1120 ----
  		}
  		(void) my_close(s);
  		if (error == 0) {
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  			(void) sigaction(SIGALRM, &osv,
  					 (struct sigaction *)0);
  #else
  			(void) sigvec(SIGALRM, &osv, (struct sigvec *)0);
  #endif
+ #endif /* WINNT */
  			return (XFER_SUCCESS);
  		}
  		dprintf(2, (ddt, "error receiving zone transfer\n"));
***************
*** 1023,1033 ****
--- 1134,1146 ----
  		return (XFER_FAIL);
  	    }
  	}
+ #ifndef WINNT
  #ifdef POSIX_SIGNALS
  	(void) sigaction(SIGALRM, &osv, (struct sigaction *)0);
  #else
  	(void) sigvec(SIGALRM, &osv, (struct sigvec *)0);
  #endif
+ #endif /* WINNT */
  	if (error)
  		return (XFER_TIMEOUT);
  	return (XFER_FAIL);
***************
*** 1051,1071 ****
  	int timeout;
  {
  	static const char setitimerStr[] = "setitimer: %m";
- 	struct itimerval ival, zeroival;
  	register int n;
  #if defined(NETREAD_BROKEN)
  	int retries = 0;
  #endif
  
  	memset(&zeroival, 0, sizeof zeroival);
  	ival = zeroival;
  	ival.it_value.tv_sec = timeout;
  	while (len > 0) {
  		if (setitimer(ITIMER_REAL, &ival, NULL) < 0) {
  			syslog(LOG_INFO, setitimerStr);
  			return (-1);
  		}
  		errno = 0;
  		n = recv(fd, buf, len, 0);
  		if (n == 0 && errno == 0) {
  #if defined(NETREAD_BROKEN)
--- 1164,1192 ----
  	int timeout;
  {
  	static const char setitimerStr[] = "setitimer: %m";
  	register int n;
  #if defined(NETREAD_BROKEN)
  	int retries = 0;
  #endif
+ #ifndef WINNT
+ 	struct itimerval ival, zeroival;
  
  	memset(&zeroival, 0, sizeof zeroival);
  	ival = zeroival;
  	ival.it_value.tv_sec = timeout;
+ #else
+ 	int ret;
+ 	struct timeval tvout;
+ 	fd_set fdset;	
+ #endif
  	while (len > 0) {
+ #ifndef WINNT
  		if (setitimer(ITIMER_REAL, &ival, NULL) < 0) {
  			syslog(LOG_INFO, setitimerStr);
  			return (-1);
  		}
  		errno = 0;
+ 		
  		n = recv(fd, buf, len, 0);
  		if (n == 0 && errno == 0) {
  #if defined(NETREAD_BROKEN)
***************
*** 1097,1109 ****
--- 1218,1265 ----
  			syslog(LOG_INFO, "recv(len=%d): %m", len);
  			return (-1);
  		}
+ #else /* WINNT */
+ 		/* our socket is kept nonblocking due to timeout considerations
+ 		 * there are two ways to ensure that a recv on the nonblocking
+ 		 * socket will not return prematurely:
+ 		 * 1) use select() to wait (with timeout) for the socket to be ready
+ 		 * 2) use the ReadFile() win32 API to do asynchronous I/O using
+ 		 *    signalled events (as has been done in writev() implementation
+ 		 * The first is being used here because it will work for Unix
+ 		 * systems also, and some day the setitimer() alarms may be 
+ 		 * replaced by select() to create a single scheme for both
+ 		 * Unix and NT
+ 		 */
+ 		 tvout.tv_sec = timeout;
+ 		 tvout.tv_usec = 0;
+ 		 FD_ZERO(&fdset);
+ 		 FD_SET(fd, &fdset);
+ 		 ret = select(fd+1, &fdset, (fd_set *)0, (fd_set *)0, &tvout);
+ 		 if (ret != SOCKET_ERROR && ret > 0) {
+ 		 	n = recv(fd, buf, len, 0);
+ 			if (n == SOCKET_ERROR)
+ 				if (WSAGetLastError() == WSAEWOULDBLOCK)
+ 					continue;
+ 				else {
+ 					syslog(LOG_INFO, "recv(len=%d): %m", len);
+ 					return (-1);
+ 				}
+ 		 } else {
+ 		 	if (ret == 0)
+ 				WSASetLastError(WSAETIMEDOUT);
+ 			syslog(LOG_INFO, "select error: %m");
+ 			return (-1);
+ 		}
+ #endif /* WINNT */
  		buf += n;
  		len -= n;
  	}
+ #ifndef WINNT
  	if (setitimer(ITIMER_REAL, &zeroival, NULL) < 0) {
  		syslog(LOG_INFO, setitimerStr);
  		return (-1);
  	}
+ #endif
  	return (0);
  }
  
Only in m:\bind/named: named.mak
Only in m:\bind/named: named.mdp
Only in m:\bind/named: named.ncb
Only in m:\bind/named: named.vcp
Only in m:\bind/named: ndc.c
Only in m:\bind/named: ndc.mak
Only in m:\bind/named: ndc.mdp
Only in m:\bind/named: ndc.ncb
Only in m:\bind/named: ndc.vcp
Only in m:\bind/named: ndcold.c
diff --context --recurs m:\bind494rel/named/ns_defs.h m:\bind/named/ns_defs.h
*** m:\bind494rel/named/ns_defs.h	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_defs.h	Sat Jun 01 03:48:42 1996
***************
*** 119,135 ****
  	time_t		z_lastupdate;	/* time of last refresh */
  	u_int32_t	z_refresh;	/* refresh interval */
  	u_int32_t	z_retry;	/* refresh retry interval */
! 	u_int32_t	z_expire;	/* expiration time for cached info */
! 	u_int32_t	z_minimum;	/* minimum TTL value */
! 	u_int32_t	z_serial;	/* changes if zone modified */
! 	char		*z_source;	/* source location of data */
! 	time_t		z_ftime;	/* modification time of source file */
! 	struct in_addr	z_xaddr;	/* override server for next xfer */
! 	struct in_addr	z_addr[NSMAX];	/* list of master servers for zone */
! 	u_char		z_addrcnt;	/* number of entries in z_addr[] */
! 	u_char		z_type;		/* type of zone; see below */
! 	u_int16_t	z_flags;	/* state bits; see below */
  	pid_t		z_xferpid;	/* xfer child pid */
  	int		z_class;	/* class of zone */
  #ifdef SECURE_ZONES
  	struct netinfo *secure_nets;	/* list of secure networks for zone */
--- 119,143 ----
  	time_t		z_lastupdate;	/* time of last refresh */
  	u_int32_t	z_refresh;	/* refresh interval */
  	u_int32_t	z_retry;	/* refresh retry interval */
! #ifndef WINNT
! 	u_int32_t	z_expire;	/* expiration time for cached info */
! #else
! 	int32_t	z_expire;	/* expiration time for cached info */
! #endif
! 	u_int32_t	z_minimum;	/* minimum TTL value Changes */
! 	u_int32_t	z_serial;	/* changes if zone modified */
! 	char		*z_source;	/* source location of data */
! 	time_t		z_ftime;	/* modification time of source file */
! 	struct in_addr	z_xaddr;	/* override server for next xfer */
! 	struct in_addr	z_addr[NSMAX];	/* list of master servers for zone */
! 	u_char		z_addrcnt;	/* number of entries in z_addr[] */
! 	u_char		z_type;		/* type of zone; see below */
! 	u_int16_t	z_flags;	/* state bits; see below */
! #ifndef WINNT
  	pid_t		z_xferpid;	/* xfer child pid */
+ #else
+ 	HANDLE		z_xferpid;	/* handle for thread doing xfer */
+ #endif
  	int		z_class;	/* class of zone */
  #ifdef SECURE_ZONES
  	struct netinfo *secure_nets;	/* list of secure networks for zone */
***************
*** 180,187 ****
--- 188,200 ----
  #define	XFER_SUCCESS	1		/* performed transfer successfully */
  #define	XFER_TIMEOUT	2		/* no server reachable/xfer timeout */
  #define	XFER_FAIL	3		/* other failure, has been logged */
+ #ifdef WINNT
+ #define XFER_KILLED 	4
+ #endif
  
+ #ifndef WINNT
  #include <sys/time.h>
+ #endif
  
  /* XXX - "struct qserv" is deprecated in favor of "struct nameser" */
  struct qserv {
***************
*** 255,261 ****
--- 268,278 ----
  #define	FW_SERVFAIL	3
  
  struct qstream {
+ #ifndef WINNT
  	int		s_rfd;		/* stream file descriptor */
+ #else
+ 	SOCKET	s_rfd;
+ #endif
  	int		s_size;		/* expected amount of data to recive */
  	int		s_bufsize;	/* amount of data recived in s_buf */
  	u_char		*s_buf;		/* buffer of received data */
***************
*** 270,276 ****
--- 287,297 ----
  #define QSTREAM_NULL	((struct qstream *)0)
  
  struct qdatagram {
+ #ifndef WINNT
  	int		dq_dfd;		/* datagram file descriptor */
+ #else
+ 	u_int		dq_dfd;		/* datagram file descriptor */
+ #endif
  	time_t		dq_gen;		/* generation number */
  	struct qdatagram
  			*dq_next;	/* next datagram */
diff --context --recurs m:\bind494rel/named/ns_forw.c m:\bind/named/ns_forw.c
*** m:\bind494rel/named/ns_forw.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_forw.c	Thu Jun 27 19:37:38 1996
***************
*** 58,76 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <syslog.h>
! #include <resolv.h>
! #include <stdio.h>
! #include <errno.h>
  
  #include "named.h"
  
  /*
   * Forward the query to get the answer since its not in the database.
   * Returns FW_OK if a request struct is allocated and the query sent.
--- 58,87 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #ifndef WINNT
! #include <syslog.h>
! #else
! #include <stdlib.h>
! #include <search.h>
! #endif
! #include <resolv.h>
! #include <stdio.h>
! #include <errno.h>
  
  #include "named.h"
  
+ #ifdef WINNT
+ int qcomp(const void *, const void *);
+ #endif
+ 
  /*
   * Forward the query to get the answer since its not in the database.
   * Returns FW_OK if a request struct is allocated and the query sent.
***************
*** 374,380 ****
  	register struct namebuf *np;
  	register struct databuf *dp, *nsdp;
  	register struct qserv *qs;
! 	register int n;
  	register unsigned int i;
  	struct hashbuf *tmphtp;
  	char *dname;
--- 385,391 ----
  	register struct namebuf *np;
  	register struct databuf *dp, *nsdp;
  	register struct qserv *qs;
! 	register unsigned int n;
  	register unsigned int i;
  	struct hashbuf *tmphtp;
  	char *dname;
***************
*** 655,662 ****
--- 666,677 ----
  	}
  #endif
  	if (n > 1) {
+ #ifndef WINNT
  		qsort((char *)qp->q_addr, n, sizeof(struct qserv),
  		      (int (*)__P((const void *, const void *)))qcomp);
+ #else
+ 		qsort((char *)qp->q_addr, n, sizeof(struct qserv), qcomp);
+ #endif
  	}
  	return (n - naddr);
  }
diff --context --recurs m:\bind494rel/named/ns_func.h m:\bind/named/ns_func.h
*** m:\bind494rel/named/ns_func.h	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_func.h	Sat Jun 01 03:48:43 1996
***************
*** 105,114 ****
  			loadxfer __P((void)),
  			qserial_query __P((struct zoneinfo *)),
  			qserial_answer __P((struct qinfo *, u_int32_t));
! extern void		holdsigchld __P((void));
! extern void		releasesigchld __P((void));
! extern SIG_FN		reapchild __P(());
! extern void		endxfer __P((void));
  extern const char *	zoneTypeString __P((const struct zoneinfo *));
  #ifdef DEBUG
  extern void		printzoneinfo __P((int));
--- 105,118 ----
  			loadxfer __P((void)),
  			qserial_query __P((struct zoneinfo *)),
  			qserial_answer __P((struct qinfo *, u_int32_t));
! #ifndef WINNT
! extern void		holdsigchld __P((void));
! extern void		releasesigchld __P((void));
! extern SIG_FN		reapchild __P(());
! extern void		endxfer __P((void));
! #else
! extern	void		endxfer __P((DWORD));
! #endif
  extern const char *	zoneTypeString __P((const struct zoneinfo *));
  #ifdef DEBUG
  extern void		printzoneinfo __P((int));
diff --context --recurs m:\bind494rel/named/ns_glob.h m:\bind/named/ns_glob.h
*** m:\bind494rel/named/ns_glob.h	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_glob.h	Sat Jun 01 03:48:44 1996
***************
*** 86,93 ****
  DECL	int			ds		INIT(-1);
  
  	/* listening TCP socket */
! DECL	int			vs		INIT(-1);
! 
  	/* received SIGHUP, need to reload db */
  DECL	int			needreload	INIT(0);
  
--- 86,96 ----
  DECL	int			ds		INIT(-1);
  
  	/* listening TCP socket */
! #ifndef WINNT
! DECL	int			vs		INIT(-1);
! #else
! DECL	int			vs		INIT(INVALID_SOCKET);
! #endif
  	/* received SIGHUP, need to reload db */
  DECL	int			needreload	INIT(0);
  
diff --context --recurs m:\bind494rel/named/ns_init.c m:\bind/named/ns_init.c
*** m:\bind494rel/named/ns_init.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_init.c	Sat Jun 01 03:48:26 1996
***************
*** 58,73 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/stat.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <syslog.h>
! #include <resolv.h>
! #include <stdio.h>
! #include <errno.h>
  #include <ctype.h>
  
  #include "named.h"
--- 58,77 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <sys/stat.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <resolv.h>
! #include <stdio.h>
! #include <errno.h>
  #include <ctype.h>
  
  #include "named.h"
***************
*** 103,112 ****
  ns_refreshtime(zp, timebase)
  	struct zoneinfo	*zp;
  	time_t		timebase;
! {
! 	u_long refresh = (zp->z_refresh > 0) ? zp->z_refresh : INIT_REFRESH;
! 	time_t half = (refresh + 1) / 2;
! 
  	zp->z_time = timebase + half + (rand() % half);
  }
  
--- 107,116 ----
  ns_refreshtime(zp, timebase)
  	struct zoneinfo	*zp;
  	time_t		timebase;
!    {
!   	u_long refresh = (zp->z_refresh > 0) ? zp->z_refresh : INIT_REFRESH;
!   	time_t half = (refresh + 1) / 2;
!  
  	zp->z_time = timebase + half + (rand() % half);
  }
  
***************
*** 242,250 ****
--- 246,267 ----
  #ifdef ALLOW_UPDATES
  	char *flag;
  #endif
+ #ifdef WINNT
+ 	extern char *pathtmpdir;
+ #endif
  	int slineno;			/* Saved global line number. */
  	int i;
+ 	
+ #if defined(WINNT) && defined(REGISTRY_PATHS)
+ 	/* software.com specific 
+ 	   PIW:  change to the temp dir that we got from the registry */
+ 	if (chdir(pathtmpdir) != TRUE)
+ 	{
+ 		syslog(LOG_CRIT, "Can't chdir to %s: %m\n",buf);
+ 		exit(1);
+ 	}
  
+ #endif
  	if ((fp = fopen(filename, "r")) == NULL) {
  		syslog(LOG_ERR, "%s: %m", filename);
  		if (includefile)
***************
*** 266,274 ****
  		}
  		if (strcasecmp(buf, "directory") == 0) {
  			(void) getword(buf, sizeof(buf), fp, 0);
  			if (chdir(buf) < 0) {
! 				syslog(LOG_CRIT, "directory %s: %m\n",
! 					buf);
  				exit(1);
  			}
  			continue;
--- 283,305 ----
  		}
  		if (strcasecmp(buf, "directory") == 0) {
  			(void) getword(buf, sizeof(buf), fp, 0);
+ #ifndef WINNT
  			if (chdir(buf) < 0) {
! #else
! #ifdef REGISTRY_PATHS
!             /* software.com specific 
! 		       PIW Software.com: ignore the directory, we got it from
! 			   the registry already in ns_main.c, and it is stored
! 			   in the global 'pathtmpdir'. */
! 
! 			syslog(LOG_INFO,"Ignoring directory entry in startup\n");
! 
! 			if (chdir(pathtmpdir) != TRUE) {
! #else
! 			if (chdir(buf) != TRUE) {
! #endif /* registry paths */
! #endif /* winnt */
! 				syslog(LOG_CRIT, "directory %s: %m\n",buf);
  				exit(1);
  			}
  			continue;
***************
*** 587,593 ****
--- 618,628 ----
  				 * We will always transfer this zone again
  				 * after a reload.
  				 */
+ #ifndef WINNT
  				sprintf(buf, "%s/NsTmp%ld.%d", _PATH_TMPDIR,
+ #else
+ 				sprintf(buf, "%sNsTmp%ld.%d", pathtmpdir,
+ #endif
  					(long)getpid(), tmpnum++);
  				source = savestr(buf);
  				zp->z_flags |= Z_TMP_FILE;
diff --context --recurs m:\bind494rel/named/ns_main.c m:\bind/named/ns_main.c
*** m:\bind494rel/named/ns_main.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_main.c	Sat Jun 01 03:48:27 1996
***************
*** 70,89 ****
   * Internet Name server (see RCF1035 & others).
   */
  
! #include <sys/param.h>
! #include <sys/file.h>
! #include <sys/stat.h>
! #if !defined(SYSV) && defined(XXX)
! #include <sys/wait.h>
! #endif /* !SYSV */
  #if defined(__osf__)
! # define _SOCKADDR_LEN		/* XXX - should be in portability.h but that
! 				 * would need to be included before socket.h
! 				 */
  #endif
  #include <sys/ioctl.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #if defined(__osf__)
  # include <sys/mbuf.h>
  # include <net/route.h>
--- 70,93 ----
   * Internet Name server (see RCF1035 & others).
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/file.h>
! #endif
! #include <sys/stat.h>
! #if !defined(SYSV) && defined(XXX)
! #include <sys/wait.h>
! #endif /* !SYSV */
  #if defined(__osf__)
! # define _SOCKADDR_LEN		/* XXX - should be in portability.h but that
! 				 * would need to be included before socket.h
! 				 */
  #endif
+ #ifndef WINNT
  #include <sys/ioctl.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
+ #endif
  #if defined(__osf__)
  # include <sys/mbuf.h>
  # include <net/route.h>
***************
*** 92,103 ****
--- 96,113 ----
  # include <sys/time.h>
  # define TIME_H_INCLUDED
  #endif
+ #ifndef WINNT
  #include <net/if.h>
+ #else
+ #include "ntif.h" /* hacked version for nt only */
+ #endif
  #include <arpa/nameser.h>
  #include <arpa/inet.h>
  #include <fcntl.h>
  #include <stdio.h>
+ #ifndef WINNT
  #include <syslog.h>
+ #endif
  #include <errno.h>
  #include <signal.h>
  #include <netdb.h>
***************
*** 112,117 ****
--- 122,132 ----
  
  #undef nsaddr
  
+ #ifdef WINNT
+ #include <process.h> 
+ #include "../compat/lib/log.h"
+ #endif
+ 
  				/* UDP receive, TCP send buffer size */
  static	const int		rbufsize = 8 * 1024,
  				/* TCP send window size */
***************
*** 124,129 ****
--- 139,176 ----
  static	char			**Argv = NULL;
  static	char			*LastArg = NULL;	/* end of argv */
  
+ #ifdef WINNT
+ 	/* handles for various threads, process, and objects */
+ 	HANDLE hReadWriteEvent = NULL, hServDoneEvent = NULL, hWorkerThread = NULL;
+ 	/* variables used to inform the Service Control Manager of our current state */
+ 	SERVICE_STATUS ServiceStatus;
+ 	SERVICE_STATUS_HANDLE   hServiceStatus;
+ 	OVERLAPPED overlap; 
+ 	int was_stopped = 0;
+ 	char *pathboot, *pathxfer, *pathdebug,
+ 	 	 *pathdumpfile, *pathpidfile, *pathstats,
+ 	 	 *pathxfertrace, *pathxferddt, *pathtmpdir;
+     CRITICAL_SECTION protected_zp;
+     CRITICAL_SECTION maint_section;
+     /* critical section used to synchronize the named xfers */
+ #define exit(x) { if (hServDoneEvent != NULL) \
+ 						SetEvent(hServDoneEvent);\
+ 				  ExitThread(x); \
+ 				}
+ char szMsgPath[255];
+ #ifdef NOWAIT
+ 	char loopbuf[] = "";
+ 	struct sockaddr_in loopback;
+ #endif
+ 	
+ #ifdef REGISTRY_PATHS
+ 	/* software.com specific
+ 	   PIW Software.com change to get path from registry */
+ 	static int GetRegistryPath(int max_len, char *directory);
+ #endif /* registry paths */
+ #endif /* WINNT */
+ 
+ 
  static	struct qstream		*sqadd __P((void));
  static	void			sq_query __P((struct qstream *)),
  				opensocket __P((struct qdatagram *)),
***************
*** 133,138 ****
--- 180,186 ----
  				setdebug __P((int));
  static	int			sq_here __P((struct qstream *));
  
+ #ifndef WINNT
  static	SIG_FN			onintr __P(()),
  				maint_alarm __P(()),
  				setdumpflg __P(()),
***************
*** 147,152 ****
--- 195,201 ----
  #endif /* SIGSYS */
  				setchkptflg __P(()),
  				setstatsflg __P(());
+ #endif /* WINNT */
  
  static void
  usage()
***************
*** 162,174 ****
  	int argc;
  	char *argv[], *envp[];
  {
! 	register int n, udpcnt;
! 	register char *arg;
  	register struct qstream *sp;
  	register struct qdatagram *dqp;
  	struct qstream *nextsp;
  	int nfds;
- 	const int on = 1;
  	int rfd, size, len;
  	time_t lasttime, maxctime;
  	u_char buf[BUFSIZ];
--- 211,226 ----
  	int argc;
  	char *argv[], *envp[];
  {
!   	register int n;
! 	register char *arg;	
! 	const int on = 1;
! 
! #ifndef WINNT
!     register int udpcnt;
  	register struct qstream *sp;
  	register struct qdatagram *dqp;
  	struct qstream *nextsp;
  	int nfds;
  	int rfd, size, len;
  	time_t lasttime, maxctime;
  	u_char buf[BUFSIZ];
***************
*** 178,189 ****
  #ifndef SYSV
  	struct sigvec vec;
  #endif
! #endif
  #ifdef NeXT
  	int old_sigmask;
  #endif
  	fd_set tmpmask;
! 	struct timeval t, *tp;
  	struct qstream *candidate = QSTREAM_NULL;
  	char **argp;
  #ifdef PID_FIX
--- 230,244 ----
  #ifndef SYSV
  	struct sigvec vec;
  #endif
! #endif 
  #ifdef NeXT
  	int old_sigmask;
  #endif
  	fd_set tmpmask;
! 	struct timeval *tp;
! #endif /* WINNT */
! 
! 	struct timeval t;
  	struct qstream *candidate = QSTREAM_NULL;
  	char **argp;
  #ifdef PID_FIX
***************
*** 196,201 ****
--- 251,281 ----
  	u_char ip_opts[50];		/* arbitrary size */
  #endif
  
+ #ifdef WINNT
+  	WORD wVersionRequested;
+ 	WSADATA wsaData;
+ 
+ 	/* initialize the winsock dll version needed */
+ 	wVersionRequested = MAKEWORD(1,1);
+ 	if (WSAStartup(wVersionRequested, &wsaData)) {
+ 		syslog(LOG_ERR, "No useable winsock.dll: %m");
+ 		return;
+ 	}
+ 
+     /* initialize the critical section */
+    InitializeCriticalSection(&protected_zp);
+    InitializeCriticalSection(&maint_section);
+ 	/* initialize all pathnames */
+ 	expand_paths();
+ 
+        /* lgk add startup code here */
+          /* Set the Event-ID message-file name. */
+           GetCurrentDirectory(sizeof(szMsgPath), szMsgPath);
+           strcat(szMsgPath, "\\named.exe");
+           addSourceToRegistry("DNS", szMsgPath);
+ 
+ #endif /* WINNT */
+ 
  	local_ns_port = ns_port = htons(NAMESERVER_PORT);
  
  	/* BSD has a better random number generator but it's not clear
***************
*** 305,315 ****
--- 385,397 ----
  	if (debug)
  		n = LOG_PERROR;
  #endif
+ #ifndef WINNT
  #ifdef LOG_DAEMON
  	openlog("named", LOG_PID|LOG_CONS|LOG_NDELAY|n, LOGFAC);
  #else
  	openlog("named", LOG_PID);
  #endif
+ #endif /* WINNT */
  
  #ifdef WANT_PIDFILE
  	/* tuck my process id away */
***************
*** 343,349 ****
--- 425,435 ----
  	** Open stream port.
  	*/
  	for (n = 0; ; n++) {
+ #ifndef WINNT
  		if ((vs = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ #else
+ 		if ((vs = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
+ #endif
  			syslog(LOG_ERR, "socket(SOCK_STREAM): %m");
  			exit(1);
  		}	
***************
*** 386,391 ****
--- 472,478 ----
  		exit(1);
  	}
  
+ #ifndef WINNT
    	/*
  	 * named would be terminated if one of these is sent and no handler.
  	 */
***************
*** 398,403 ****
--- 485,491 ----
  #if defined(SIGWINCH) && defined(QRYLOG)
  	setsignal(SIGWINCH, -1, setQrylogFlg);
  #endif
+ #endif /* WINNT */
  
  	/*
  	 * Get list of local addresses and set up datagram sockets.
***************
*** 423,428 ****
--- 511,517 ----
  	time(&boottime);
  	resettime = boottime;
  
+ #ifndef WINNT
  	setsignal(SIGALRM, SIGCHLD, maint_alarm);
  	setsignal(SIGCHLD, SIGALRM, reapchild);
  	setsignal(SIGPIPE, -1, (SIG_FN (*)())SIG_IGN);
***************
*** 447,452 ****
--- 536,542 ----
          /* Catch SIGTERM so we can write stats before exiting. */
  	setsignal(SIGTERM, -1, onintr);
  #endif
+ #endif /* WINNT */
  
  	dprintf(1, (ddt, "database initialized\n"));
  	t.tv_usec = 0;
***************
*** 456,461 ****
--- 546,552 ----
  	 * we've done any slow initialization
  	 * and are ready to answer queries.
  	 */
+ #ifndef WINNT
  #ifdef USE_SETSID
  	if (
  #ifdef DEBUG
***************
*** 534,539 ****
--- 625,791 ----
  #endif /* HAVE_DAEMON */
  	}
  #endif /* USE_SETSID */
+ 
+ #else /* WINNT */
+ #ifdef DEBUG
+ 	if (!debug)
+ #endif
+ 	{
+ 		SERVICE_TABLE_ENTRY dispatchTable[] = {
+         	{ TEXT("DomainNameService"), (LPSERVICE_MAIN_FUNCTION)service_main },
+         	{ NULL, NULL }
+     	};
+ 
+ 	/* daemonize */
+     	if (!StartServiceCtrlDispatcher(dispatchTable)) {
+ 			if (!was_stopped) {
+ 				syslog(LOG_ERR, "StartServiceCtrlDispatcher: %m");
+ 				ExitProcess(2);
+ 			} else {
+ 				syslog(LOG_INFO, "StartServiceCtrlDispatcher: service stopped");
+ 				ExitProcess(0);
+ 			}
+ 		}
+ 	}
+ #ifdef DEBUG
+ 	else
+ 	   service_main(argc, argv);
+ #endif /* DEBUG */
+ } /* end main */
+ 
+ /*
+  * If this runs as a service under NT, the main thread will block at StartServiceCtrlDispatcher()
+  * and another thread will be started by the Service Control Dispatcher which will begin execution 
+  * at the routine specified in that call (viz. service_main) 
+  */
+ void
+ service_main(argc, argv)
+ 	DWORD argc;
+ 	LPTSTR *argv;
+ {
+ 	DWORD dwWait;
+ 
+ #ifdef DEBUG
+ 	if(!debug) {
+ #endif /* DEBUG */
+ 
+ #ifdef NOWAIT
+ 	loopback.sin_family = AF_INET;
+ 	loopback.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ 	loopback.sin_port = local_ns_port;
+ #endif
+     	/* register our service control handler */
+ 		if (!(hServiceStatus = RegisterServiceCtrlHandler( TEXT("DomainNameService"),
+                         			(LPHANDLER_FUNCTION)service_ctrl))) {
+ 			syslog(LOG_ERR, "RegisterServiceCtrlHandler() failed: %m");
+ 			return;
+ 		}
+ 
+ 		/* report pending status to Service Control Manager */
+ 		ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ 		ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
+ 		ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+ 		ServiceStatus.dwWin32ExitCode = NO_ERROR;
+     	        ServiceStatus.dwServiceSpecificExitCode = 0;
+ 		ServiceStatus.dwCheckPoint = 1;
+ 		ServiceStatus.dwWaitHint = 5000;
+ 		if (!SetServiceStatus(hServiceStatus, &ServiceStatus)) {
+ 			syslog(LOG_ERR, "SetServiceStatus(): %m");
+         	ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ 			SetServiceStatus(hServiceStatus, &ServiceStatus);
+ 			return;
+     	}
+ 
+ 		/* create an event object that the control handler function
+ 	 	* will signal when it receives the "stop" control code */
+ 		if (!(hServDoneEvent = CreateEvent(
+         				NULL,    /* no security attributes */
+         				FALSE,   /* auto-reset event */
+         				FALSE,   /* not-signalled */
+         				NULL))){ /* no name */
+ 				syslog(LOG_ERR, "CreateEvent() failed: %m");
+         		ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ 				SetServiceStatus(hServiceStatus, &ServiceStatus);
+ 				return;
+     	}
+ 
+ 	/* 
+ 	 * the service_main() thread will have to wait for start/stop/pause/continue requests
+ 	 * from the services icon in the Control Panel or from any WIN32 application
+      * start a new thread to perform all the work of the NTP service 
+      */
+         if (!(hWorkerThread = (HANDLE)_beginthread(
+                     worker_thread,
+                     0,       /* stack size			*/
+                     NULL))){    /* argument to thread	*/
+ 			syslog(LOG_ERR, "_beginthread: %m");
+ 			if (hServDoneEvent != NULL)
+ 				CloseHandle(hServDoneEvent);
+         	ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ 			SetServiceStatus(hServiceStatus, &ServiceStatus);
+ 			return;
+ 		}
+ 
+     	/* report to the service control manager that the service is running */
+ 		ServiceStatus.dwCurrentState = SERVICE_RUNNING;
+ 		ServiceStatus.dwWin32ExitCode = NO_ERROR;
+ 		if (!SetServiceStatus(hServiceStatus, &ServiceStatus)) {
+ 			syslog(LOG_ERR, "SetServiceStatus(): %m");
+ 			if (hServDoneEvent != NULL)
+ 				CloseHandle(hServDoneEvent);
+         	ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ 			SetServiceStatus(hServiceStatus, &ServiceStatus);
+ 			return;
+ 		}
+ 
+     	/* wait indefinitely until hServDoneEvent is signaled */
+     	dwWait = WaitForSingleObject(hServDoneEvent,INFINITE);
+ 		if (hServDoneEvent != NULL)
+ 			CloseHandle(hServDoneEvent);
+ 		if (hWorkerThread != NULL)
+ 	        CloseHandle(hWorkerThread);
+ 
+     	ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ 		SetServiceStatus(hServiceStatus, &ServiceStatus);
+ 	return;
+ 	}
+ #ifdef DEBUG
+ 	else 
+ 	    worker_thread(NULL);
+ #endif /* DEBUG */
+ } /* end service_main() */
+ 
+ 
+ /*
+  * worker_thread - perform all remaining functions after initialization and and becoming a service
+  */
+ void
+ worker_thread(notUsed)
+ 	void *notUsed;
+ {
+ #ifdef WANT_PIDFILE
+ 	FILE *fp;
+ #endif
+ 	register int n, udpcnt;
+ 	register struct qstream *sp;
+ 	register struct qdatagram *dqp;
+ 	struct qstream *nextsp;
+ 	int nfds;
+ 	const int on = 1;
+ 	int size;
+ 	SOCKET rfd;
+ 	time_t lasttime, maxctime;
+ 	u_char buf[BUFSIZ];
+ 	struct timeval t, *tp;
+ 	fd_set tmpmask;
+ 	struct qstream *candidate = QSTREAM_NULL;
+ 
+ 	hReadWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ 	overlap.Offset = overlap.OffsetHigh = (DWORD)0;
+ 	overlap.hEvent = hReadWriteEvent;
+ 
+ #endif /* WINNT */
+ 
  #ifdef WANT_PIDFILE
  	/* tuck my process id away again */
  	fp = fopen(PidFile, "w");
***************
*** 591,602 ****
--- 843,865 ----
  			needStatsDump = 0;
  			ns_stats();
  		}
+ /* this should never be called from nt as the needendxfer is only set
+  * vai a call to reapchild in ns_maint.c through a signal
+  */
  		if (needendxfer) {
+ #ifndef WINNT
  			holdsigchld();
  			needendxfer = 0; /* should be safe even if not held */
  			endxfer(); /* releases SIGCHLD */
+ #else
+                 needendxfer = 0;
+ 		syslog(LOG_ERR, "Needendxfer was Set under Windows NT... Shouldn't happen!");
+ #endif
  		}
+ 
+ #ifndef WINNT 
  		releasesigchld();
+ #endif
  		if (needzoneload) {
  			needzoneload = 0;
  			loadxfer();
***************
*** 638,644 ****
--- 901,911 ----
  #ifdef NeXT
  		old_sigmask = sigblock(sigmask(SIGCHLD));
  #endif
+ #ifndef WINNT
  		if (n < 0 && errno != EINTR) {
+ #else
+ 		if (n < 0 && errno != WSAEINTR) {
+ #endif
  			syslog(LOG_ERR, "select: %m");
  			sleep(60);
  		}
***************
*** 667,672 ****
--- 934,947 ----
  			    }
  			    if (n == 0)
  				break;
+ #if defined(WINNT) && defined(NOWAIT)
+ 				if ((n ==1) && !strcmp(buf, "")) {
+ 				/* dummy packet intended to terminate select
+ 				 * because a control code has been received or
+ 				 * needmaint flag has been set by the timer thread */
+ 					break;
+ 				}
+ #endif
  			    gettime(&tt);
  			    dprintf(1, (ddt,
  			     "\ndatagram from [%s].%d, fd %d, len %d; now %s",
***************
*** 698,706 ****
--- 973,989 ----
  			rfd = accept(vs,
  				     (struct sockaddr *)&from_addr,
  				     &from_len);
+ #ifndef WINNT
  			if (rfd < 0 && errno == EINTR)
+ #else
+ 			if (rfd == INVALID_SOCKET && WSAGetLastError() == WSAEINTR)
+ #endif
  				continue;
+ #ifndef WINNT
  			if (rfd < 0 && errno == EMFILE && streamq) {
+ #else
+ 			if (rfd == INVALID_SOCKET && WSAGetLastError() == WSAEMFILE && streamq) {
+ #endif
  				maxctime = 0;
  				candidate = NULL;
  				for (sp = streamq; sp; sp = nextsp) {
***************
*** 720,729 ****
--- 1003,1017 ----
  					sqrm(candidate);
  				continue;
  			}
+ #ifndef WINNT
  			if (rfd < 0) {
+ #else
+ 			if (rfd == INVALID_SOCKET) {
+ #endif
  				syslog(LOG_INFO, "accept: %m");
  				continue;
  			}
+ #ifndef WINNT 
  			if ((n = fcntl(rfd, F_GETFL, 0)) < 0) {
  				syslog(LOG_INFO, "fcntl(rfd, F_GETFL): %m");
  				(void) my_close(rfd);
***************
*** 734,739 ****
--- 1022,1034 ----
  				(void) my_close(rfd);
  				continue;
  			}
+ #else
+ 			if(ioctlsocket(rfd, FIONBIO, (u_long *)&on) == SOCKET_ERROR) {
+ 				syslog(LOG_INFO, "ioctlsocket(rfd, NONBLOCK): %m");
+ 				(void) my_close(rfd);
+ 				continue;
+ 			}
+ #endif
  #if defined(IP_OPTIONS)
  			len = sizeof ip_opts;
  			if (getsockopt(rfd, IPPROTO_IP, IP_OPTIONS,
***************
*** 813,819 ****
--- 1108,1119 ----
  				size = INT16SZ
  				    - (sp->s_bufp - (u_char *)&sp->s_tempsize);
  			        while (size > 0 &&
+ #ifndef WINNT
  			           (n = read(sp->s_rfd, sp->s_bufp, size)) > 0
+ #else
+  			           (n = recv(sp->s_rfd, sp->s_bufp, size, 0)) >0
+ 
+ #endif
  				       ) {
  					sp->s_bufp += n;
  					size -= n;
***************
*** 857,866 ****
--- 1157,1173 ----
  			gettime(&tt);
  			sp->s_time = tt.tv_sec;
  			while (sp->s_size > 0 &&
+ #ifndef WINNT
  			      (n = read(sp->s_rfd,
  					sp->s_bufp,
  					sp->s_size)
  			       ) > 0
+ #else
+ 				  (n = recv(sp->s_rfd,
+ 					sp->s_bufp,
+ 					sp->s_size, 0)
+ 			       ) > 0
+ #endif
  			) {
  				sp->s_bufp += n;
  				sp->s_size -= n;
***************
*** 886,892 ****
--- 1193,1203 ----
  						HFIXEDSZ);
  				continue;
  			}
+ #ifndef WINNT
  			if ((n == -1) && (errno == PORT_WOULDBLK))
+ #else
+ 			if ((n == SOCKET_ERROR) && (errno == PORT_WOULDBLK))
+ #endif
  				continue;
  			if (n <= 0) {
  				sqrm(sp);
***************
*** 931,940 ****
--- 1242,1261 ----
  
  	ifc.ifc_len = sizeof buf;
  	ifc.ifc_buf = buf;
+ #ifndef WINNT /* nt dos not have this functionality so call our new fx */
  	if (ioctl(vs, SIOCGIFCONF, (char *)&ifc) < 0) {
  		syslog(LOG_ERR, "get interface configuration: %m - exiting");
  		exit(1);
  	}
+ #else
+         if (get_winnt_interfaces(&ifc) < 0)
+ 
+          {
+ 	   syslog(LOG_ERR, "get interface configuration: %m - exiting");
+ 	   exit(1);
+ 	}
+ #endif
+ 
  	ntp = NULL;
  #if defined(AF_LINK) && !defined(RISCOS_BSD) && !defined(M_UNIX)
  #define my_max(a, b) (a > b ? a : b)
***************
*** 945,953 ****
  	cplim = buf + ifc.ifc_len;    /* skip over if's with big ifr_addr's */
  	for (cp = buf;
  	     cp < cplim;
  	     cp += sizeof (ifr->ifr_name) + my_size(ifr->ifr_addr)) {
  #undef my_size
! 		ifr = (struct ifreq *)cp;
  		if (ifr->ifr_addr.sa_family != AF_INET ||
  		   ((struct sockaddr_in *)
  		    &ifr->ifr_addr)->sin_addr.s_addr == 0) {
--- 1266,1279 ----
  	cplim = buf + ifc.ifc_len;    /* skip over if's with big ifr_addr's */
  	for (cp = buf;
  	     cp < cplim;
+ #ifndef WINNT
  	     cp += sizeof (ifr->ifr_name) + my_size(ifr->ifr_addr)) {
+ #else
+              
+ 	     cp += sizeof (ifr->ifr_name) + my_size(ifr->ifr_addr) + sizeof(ifr->ifr_mask)) {
+ #endif
  #undef my_size
! 		 ifr = (struct ifreq *)cp;
  		if (ifr->ifr_addr.sa_family != AF_INET ||
  		   ((struct sockaddr_in *)
  		    &ifr->ifr_addr)->sin_addr.s_addr == 0) {
***************
*** 958,972 ****
  		 * Don't test IFF_UP, packets may still be received at this
  		 * address if any other interface is up.
  		 */
! #if !defined(BSD) || (BSD < 199103)
  		if (ioctl(vs, SIOCGIFADDR, (char *)&ifreq) < 0) {
  			syslog(LOG_NOTICE, "get interface addr: %m");
  			continue;
  		}
  #endif
  		dprintf(1, (ddt, "considering [%s]\n",
! 			    inet_ntoa(((struct sockaddr_in *)
  				       &ifreq.ifr_addr)->sin_addr)));
  		/* build datagram queue */
  		/* 
  		 * look for an already existing source interface address.
--- 1284,1299 ----
  		 * Don't test IFF_UP, packets may still be received at this
  		 * address if any other interface is up.
  		 */
! #if (!defined(BSD) || (BSD < 199103)) && !defined(WINNT)
  		if (ioctl(vs, SIOCGIFADDR, (char *)&ifreq) < 0) {
  			syslog(LOG_NOTICE, "get interface addr: %m");
  			continue;
  		}
  #endif
  		dprintf(1, (ddt, "considering [%s]\n",
! 			    inet_ntoa(((struct sockaddr_in *)   
  				       &ifreq.ifr_addr)->sin_addr)));
+ 
  		/* build datagram queue */
  		/* 
  		 * look for an already existing source interface address.
***************
*** 1023,1028 ****
--- 1350,1356 ----
  		}
  		ntp->my_addr = ((struct sockaddr_in *)
  				&ifreq.ifr_addr)->sin_addr;
+ #ifndef WINNT				
  #ifdef SIOCGIFNETMASK
  		if (ioctl(vs, SIOCGIFNETMASK, (char *)&ifreq) < 0) {
  			syslog(LOG_NOTICE, "get netmask: %m");
***************
*** 1034,1043 ****
--- 1362,1379 ----
  		/* 4.2 does not support subnets */
  		ntp->mask = net_mask(ntp->my_addr);
  #endif
+ #else /* nt masks are supported */
+                    ntp->mask = inet_addr(ifreq.ifr_mask);
+ #endif
+ 
+ #ifndef WINNT /* no interface flags on NT */
+ 
  		if (ioctl(vs, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
  			syslog(LOG_NOTICE, "get interface flags: %m");
  			continue;
  		}
+ #endif
+ 
  #ifdef IFF_LOOPBACK
  		if (ifreq.ifr_flags & IFF_LOOPBACK)
  #else
***************
*** 1053,1069 ****
  					    (u_long)netloop.my_addr.s_addr));
  			}
  			continue;
- 		} else if ((ifreq.ifr_flags & IFF_POINTOPOINT)) {
- 			if (ioctl(vs, SIOCGIFDSTADDR, (char *)&ifreq) < 0) {
- 				syslog(LOG_NOTICE, "get dst addr: %m");
- 				continue;
- 			}
- 			ntp->mask = 0xffffffff;
- 			ntp->addr = ((struct sockaddr_in *)
- 				     &ifreq.ifr_addr)->sin_addr.s_addr;
- 		} else {
- 			ntp->addr = ntp->mask & ntp->my_addr.s_addr;
  		}
  		/*
  		 * Place on end of list of locally-attached (sub)nets,
  		 * but before logical nets for subnetted nets.
--- 1389,1414 ----
  					    (u_long)netloop.my_addr.s_addr));
  			}
  			continue;
  		}
+ #ifndef WINNT /* no interface flags on NT */
+                      else if ((ifreq.ifr_flags & IFF_POINTOPOINT))
+                             {
+ 			      if (ioctl(vs, SIOCGIFDSTADDR, (char *)&ifreq) < 0)
+                                 {
+ 			    	   syslog(LOG_NOTICE, "get dst addr: %m");
+ 				    continue;
+ 			        }
+ 			      ntp->mask = 0xffffffff;
+ 		  	      ntp->addr = ((struct sockaddr_in *)
+ 			   	          &ifreq.ifr_addr)->sin_addr.s_addr;
+ 			    } else
+                             {
+ 			     ntp->addr = ntp->mask & ntp->my_addr.s_addr;
+ 			    }
+ #else
+ 			     ntp->addr = ntp->mask & ntp->my_addr.s_addr;
+ 
+ #endif
  		/*
  		 * Place on end of list of locally-attached (sub)nets,
  		 * but before logical nets for subnetted nets.
***************
*** 1125,1130 ****
--- 1470,1482 ----
  			enettab = &ontp->next;
  		}
  	}
+ 	/* don't know how to get interface information on multihomed NT
+ 	 * machines. I'm told that gethostbyname(gethostname()) should
+ 	 * return all IP addresses of the local machine (except 127.0.0.1)
+ 	 * but there still remains the question of netmasks and flags etc
+ 	 * This whole issue needs to be addressed more thoroughly.
+ 	 * Implications of this???
+ 	 */
  	first = 0;
  }
  
***************
*** 1171,1177 ****
--- 1523,1534 ----
  	/*
  	 * Open datagram sockets bound to interface address.
  	 */
+ #ifndef WINNT
  	if ((dqp->dq_dfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ #else
+ 	if ((dqp->dq_dfd = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) {
+ #endif
+ 	 
  		syslog(LOG_ERR, "socket(SOCK_DGRAM): %m - exiting");
  		exit(1);
  	}	
***************
*** 1192,1197 ****
--- 1549,1555 ----
  				  (char *)&rbufsize, sizeof(rbufsize));
  	}
  #endif /* SO_RCVBUF */
+ #ifndef WINNT
  	if ((n = fcntl(dqp->dq_dfd, F_GETFL, 0)) < 0) {
  		syslog(LOG_NOTICE, "fcntl(dfd, F_GETFL): %m");
  		/* XXX press on regardless, but this really is a problem. */
***************
*** 1199,1204 ****
--- 1557,1567 ----
  		syslog(LOG_NOTICE, "fcntl(dqp->dq_dfd, non-blocking): %m");
  		/* XXX press on regardless, but this really is a problem. */
  	}
+ #else
+ 	if(ioctlsocket(dqp->dq_dfd, FIONBIO, (u_long *)&on) == SOCKET_ERROR) {
+ 		syslog(LOG_NOTICE, "ioctlsocket(dqp->dq_dfd, nonblocking): %m");
+ 	}
+ #endif
  	/*
  	 *   NOTE: Some versions of SunOS have problems with the following
  	 *   call to bind.  Bind still seems to function on these systems
***************
*** 1218,1223 ****
--- 1581,1587 ----
  	FD_SET(dqp->dq_dfd, &mask);
  }
  
+ #ifndef WINNT
  /*
  ** Set flag saying to reload database upon receiving SIGHUP.
  ** Must make sure that someone isn't walking through a data
***************
*** 1297,1305 ****
          needToDoadump = 1;
  	errno = save_errno;
  }
  
  /*
! ** Turn on or off debuging by open or closeing the debug file
  */
  
  static void
--- 1661,1670 ----
          needToDoadump = 1;
  	errno = save_errno;
  }
+ #endif /* WINNT */
  
  /*
! ** Turn on or off debuging by open or closing the debug file
  */
  
  static void
***************
*** 1312,1318 ****
--- 1677,1685 ----
  #ifdef DEBUG
  
  	if (code) {
+ #ifndef WINNT
  		int n;
+ #endif
  
  		ddt = freopen(debugfile, "w+", stderr);
  		if ( ddt == NULL) {
***************
*** 1325,1336 ****
--- 1692,1705 ----
  #else
  			setlinebuf(ddt);
  #endif
+ #ifndef WINNT
  			if ((n = fcntl(fileno(ddt), F_GETFL, 0)) < 0) {
  				syslog(LOG_INFO,
  				       "fcntl(ddt, F_GETFL): %m");
  			} else {
  				(void) fcntl(fileno(ddt), F_SETFL, n|O_APPEND);
  			}
+ #endif /* WINNT */
  		}
  	} else
  		debug = 0;
***************
*** 1338,1343 ****
--- 1707,1713 ----
  #endif
  }
  
+ #ifndef WINNT
  /*
  ** Catch a special signal and set debug level.
  **
***************
*** 1442,1447 ****
--- 1812,1819 ----
  }
  #endif /* SIGSYS */
  
+ #endif /* WINNT */
+ 
  /*
  ** Routines for managing stream queue
  */
***************
*** 1544,1550 ****
  			syslog(LOG_NOTICE, "interface [%s] missing; deleting",
  			       inet_ntoa(this->dq_addr));
  		}
! 		FD_CLR(this->dq_dfd, &mask);
  		my_close(this->dq_dfd);
  		free(this);
  		if (prev == NULL)
--- 1916,1922 ----
  			syslog(LOG_NOTICE, "interface [%s] missing; deleting",
  			       inet_ntoa(this->dq_addr));
  		}
!  		FD_CLR(this->dq_dfd, &mask);
  		my_close(this->dq_dfd);
  		free(this);
  		if (prev == NULL)
***************
*** 1666,1668 ****
--- 2038,2491 ----
  extern char *dn_skipname();
  char *(*hack_skipname)() = dn_skipname;
  #endif
+ 
+ 
+ #ifdef WINNT
+ /* service_ctrl - control handler for NTP service
+  * signals the service_main routine of start/stop requests
+  * from the control panel or other applications making
+  * win32API calls
+  */
+ void
+ service_ctrl(dwCtrlCode)
+ 	DWORD dwCtrlCode;
+ {
+     DWORD  dwState = SERVICE_RUNNING;
+ 	int len;
+ 
+     /* Handle the requested control code */
+     switch(dwCtrlCode) {
+ 
+         case SERVICE_CONTROL_PAUSE:
+ 		/* see no reason to support this */
+ 		break;
+ 
+         case SERVICE_CONTROL_CONTINUE:
+  		/* see no reason to support this */
+   		break;
+ 
+         case SERVICE_CONTROL_STOP:
+             dwState = SERVICE_STOP_PENDING;
+             /* Report the status, specifying the checkpoint and waithint,
+              *  before setting the termination event.
+              */
+ 			ServiceStatus.dwCurrentState = dwState;
+ 			ServiceStatus.dwWin32ExitCode = NO_ERROR;
+ 			ServiceStatus.dwWaitHint = 1000;
+ 			if (!SetServiceStatus(hServiceStatus, &ServiceStatus)) {
+ 				syslog(LOG_ERR, "SetServiceStatus(): %m");
+ 			}
+ 			was_stopped = 1;
+             SetEvent(hServDoneEvent);
+             return;
+ 
+         case SERVICE_CONTROL_INTERROGATE:
+             	/* Update the service status */
+ 			break;
+ 
+         case SERVICE_CONTROL_DUMPDB:
+             needToDoadump = 1;
+ 			break;
+ 
+         case SERVICE_CONTROL_RELOAD:
+ 			needreload = 1;
+ 			break;
+ 
+         case SERVICE_CONTROL_STATS:
+ 			needStatsDump = 1;
+ 			break;
+ 
+         case SERVICE_CONTROL_TRACE:
+ 			debug++;
+ 			if (debug == 1)
+ 				setdebug(1);
+ 			fprintf(ddt, "Debug turned ON, Level %d\n", debug);
+ 			break;
+ 
+         case SERVICE_CONTROL_NOTRACE:
+ 			setdebug(0);
+ 			break;
+ 
+         case SERVICE_CONTROL_QRYLOG:
+ 			qrylog = !qrylog;
+ 			syslog(LOG_NOTICE, "querylog %s\n", qrylog ? "on":"off");
+ 			break;
+ 
+         case SERVICE_CONTROL_CHKPT:
+ 			needToChkpt = 1;
+ 			break;
+ 
+         case SERVICE_CONTROL_EXIT:
+  #ifdef XSTATS
+             needToExit = 1;
+  #endif
+         	was_stopped = 1;	
+             break;
+ 
+         default:
+         	/* invalid control code */
+ 			syslog(LOG_ERR, "invalid control code: %d", dwCtrlCode);
+             break;
+ 
+     }
+ 
+ #ifdef NOWAIT
+ 	if((len = sendto(datagramq->dq_dfd, loopbuf, 1, 0, (struct sockaddr *)&loopback,
+ 	          sizeof(struct sockaddr_in))) == SOCKET_ERROR)
+ 		syslog(LOG_ERR, "failed to send the control code immediately: %m");
+  
+ #endif
+ 
+ 	ServiceStatus.dwCurrentState = dwState;
+ 	ServiceStatus.dwWin32ExitCode = NO_ERROR;
+ 	if (!SetServiceStatus(hServiceStatus, &ServiceStatus)) {
+ 		syslog(LOG_ERR, "SetServiceStatus(): %m");
+ 	}
+ }
+ 
+ 
+ /* Expand environmental variables in file pathnames */
+ void expand_paths(void)
+ {
+   FILE *fp;
+ 
+         /* change name back to named.boot but for backwards compat. this fails go back to the
+            alternate name named.ini... unfort. since bootfile is passed a few layers down it
+            would be a pain to changeall these calls in the stock bind so attempt to open the
+            file here and decide which name to use */
+            
+ 	pathtmpdir = (char *)malloc(MAX_PATH);
+ 
+ #ifdef REGISTRY_PATHS
+     /* software.com specific */
+ 	if (GetRegistryPath(MAX_PATH, pathtmpdir))
+ 	  {
+ 	    syslog(LOG_ERR, "GetRegistryPath() failed: %m");
+ #endif
+ 
+ 	if (!GetTempPath(MAX_PATH, pathtmpdir))
+ 		syslog(LOG_ERR, "GetTempPath() failed: %m");
+ 
+ #ifdef REGISTRY_PATHS
+ 	}
+       	else
+ 		syslog(LOG_INFO,"Get registry info okay: %s",pathtmpdir);
+ 	/* software.com specific
+ 	    PIW:  use the directory we found from the registry for ALL files
+ 	          relating to the DNS:  */
+ 	pathboot = (char *)malloc(MAX_PATH);
+ 	strcpy(pathboot,pathtmpdir);
+ 	strcat(pathboot,"NAMED.BOOT");
+     bootfile = pathboot;
+ 
+ 	pathpidfile = (char *)malloc(MAX_PATH);
+ 	strcpy(pathpidfile,pathtmpdir);
+ 	strcat(pathpidfile,"NAMED.PID");
+ 
+ 	pathxfer = (char *)malloc(MAX_PATH);
+ 	strcpy(pathxfer,pathtmpdir);
+ 	strcat(pathxfer,"NAMED.XFER");
+ 
+ #else /* don't use registry paths */
+ 
+ 	pathboot = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_BOOT, pathboot, MAX_PATH)) {
+ 		syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_BOOT) failed: %m\n");
+ 	} else
+            {
+ 	     if ((fp = fopen(pathboot, "r")) == NULL)
+ 	       {
+                  /* try alternate name */
+ 
+ 	         if (!ExpandEnvironmentStrings(_ALT_PATH_BOOT, pathboot, MAX_PATH))
+                    {
+ 		   syslog(LOG_ERR, "ExpandEnvironmentStrings(_ALT_PATH_BOOT) failed: %m\n");
+ 	           }
+                   else bootfile = pathboot;
+ 	       } /* else it opened ok so close it */
+ 	      else
+                {
+                  fclose(fp);
+                  bootfile = pathboot;
+                }
+            }
+                
+ 	pathpidfile = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_PIDFILE, pathpidfile, MAX_PATH))
+           {
+ 	       syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_PIDFILE) failed: %m\n");
+ 	      } else PidFile = pathpidfile;
+ 		 
+ 	pathxfer = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_XFER, pathxfer, MAX_PATH))
+           {
+ 	       syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_XFER) failed: %m\n");
+ 	      }
+ #endif 
+ 
+ 	pathdebug = (char *)malloc(MAX_PATH);
+ 	strcpy(pathdebug, pathtmpdir);
+ 	debugfile = strcat(pathdebug, _PATH_DEBUG);
+ 	
+ 	pathdumpfile = (char *)malloc(MAX_PATH);
+ 	strcpy(pathdumpfile, pathtmpdir);
+ 	dumpfile = strcat(pathdumpfile, _PATH_DUMPFILE);
+ 	 
+ 	pathstats = (char *)malloc(MAX_PATH);
+ 	strcpy(pathstats, pathtmpdir);
+ 	statsfile = strcat(pathstats, _PATH_STATS);
+ 	 
+ 	pathxfertrace = (char *)malloc(MAX_PATH);
+ 	strcpy(pathxfertrace, pathtmpdir);
+ 	strcat(pathxfertrace, _PATH_XFERTRACE);
+ 
+ 	pathxferddt = (char *)malloc(MAX_PATH);
+ 	strcpy(pathxferddt, pathtmpdir);
+ 	strcat(pathxferddt, _PATH_XFERDDT);
+ }
+ 
+ /* software.com specific */
+ #ifdef REGISTRY_PATHS
+ 
+ /*----------------------------------------------------------------------------------------
+ /
+ /	Function:		GetRegistryPath
+ /
+ /	Description:	given a char buffer to fill (and a max length allowed) look in the
+ /					NT registry for the directory entry under Software.Com/DNS.
+ /
+ /	Returns:		0 means it worked, -1 if it didn't
+ /
+ /	History:		Paul W.		11/24/95	Created
+ /
+ /---------------------------------------------------------------------------------------*/
+ static int GetRegistryPath(int max_len, char *directory)
+ {
+ 	HKEY hk;
+ 	int bSuccess;
+ 	DWORD dw_maxlen = max_len;
+ 
+     /* get key for our application */
+     bSuccess = RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\ISC\\DomainNameService",&hk);
+     if (bSuccess != ERROR_SUCCESS)
+       {
+     	syslog(LOG_ERR, "Cannot open the default directory registry key: %m");
+     	return -1;
+       }
+ 
+     bSuccess = RegQueryValueEx(hk,
+          "Directory",
+           NULL,
+           NULL,
+           (LPBYTE) directory,
+           &dw_maxlen);
+     if (bSuccess != ERROR_SUCCESS)
+       {
+ 	    syslog(LOG_ERR, "Error in RegQueryValueEx fetching service name parameter: %m");
+ 	    RegCloseKey(hk);
+ 	    return -1;
+       }
+ 
+ 	if (directory[dw_maxlen-1] != '\\')	/* if the directory does NOT have a trailing backslash */
+  	  {  
+ 		directory[dw_maxlen] = '\\';	/* put one on, and terminate a little longer */
+ 		directory[dw_maxlen+1] = '\0';	/* terminate at given length plus slash-space */
+ 	  }
+ 	else
+ 		directory[dw_maxlen] = '\0';	/* terminate at given length, already has slash */
+ 		
+     RegCloseKey(hk);
+ 	return 0;
+ }
+ #endif
+ 
+ 
+ 
+ /* ------------------------------------------------------------------------------------------------------------------ */
+ /* modified with suggestions from Kevin Dunlap so we only pick out netcards bound to tcpip */
+   int get_winnt_interfaces(ifc)
+ 
+     struct ifconf *ifc;
+     
+ 
+   {
+         char *ifc_buffer = ifc->ifc_buf;
+ 
+     	struct ifreq *ifr;
+         int maxsize = sizeof(ifc_buffer);
+         HKEY hk, hksub;                      /* registry key handle */
+         BOOL bSuccess;
+         char newkey[200];
+ 
+         char servicename[50];
+         DWORD sizeofservicename = 50;
+         int Done = 0;
+         
+         /* these need to be big as they are multi_sz in type and hold all ip addresses and subnet mask for a
+            given interface */
+         char IpAddresses[10000];
+         char *ipptr = IpAddresses;
+         DWORD sizeofipaddresses = 10000;
+         char SubNetMasks[10000];
+         char *subptr = SubNetMasks;
+         DWORD sizeofsubnetmasks = 10000;
+         char bindservicenames[1000];
+         DWORD sizeofbindnames = 1000;
+ 
+        char oneIpAddress[16];
+        char oneSubNetMask[16];
+        int count = 0;
+        char *onenetcard;
+ 
+     /* now get all the netcard values which are bound to tcpip */ 
+ 
+     strcpy(newkey,"SYSTEM\\Currentcontrolset\\Services\\");
+     strcat(newkey,"tcpip\\linkage");
+        
+     bSuccess = RegOpenKey(HKEY_LOCAL_MACHINE,newkey,&hk);
+     if(bSuccess != ERROR_SUCCESS)
+     {
+         syslog(LOG_ERR, "failed to Open TCP/IP Linkage Registry key: %m");
+         dprintf(1, (ddt, "Cannot get TCP/IP Linkage from registery.\n"));
+         return -1;
+     }
+ 
+     /* now get the bind value */
+         sizeofbindnames = 1000;
+         bSuccess = RegQueryValueEx(hk,     /* subkey handle         */
+         "Bind",                            /* value name            */
+         NULL,                              /* must be zero          */
+         NULL,                              /* value type          not required  */
+         (LPBYTE) &bindservicenames,        /* address of value data */
+         &sizeofbindnames);                 /* length of value data  */
+         if(bSuccess != ERROR_SUCCESS)
+         {
+             syslog(LOG_ERR, "Error in RegQueryValueEx fetching Bind Service names parameter: %m");
+             RegCloseKey(hk);
+             return -1;
+         }
+ 
+ 
+     /* now loop through and get all the values which are bound to tcpip */ 
+     /* we can also close the key here as we have the values now */
+     RegCloseKey(hk);
+     onenetcard = bindservicenames;
+     while(1)
+     {
+ 
+        onenetcard = onenetcard + 8;
+        if  ((onenetcard < (bindservicenames + sizeofbindnames)) &&
+            (sscanf(onenetcard,"%s",servicename) != EOF))
+          {
+             onenetcard+= strlen(servicename) + 1;
+          }
+         else { /* no more */
+                break;
+              }
+ 
+         /* skip services that are NDISWAN... since these are temporary interfaces like ras and if we bind to these
+            we would have to check if the socket is still ok everytime before using it as when the link goes down
+            and comes back up the socket is no longer any good... and the server eventually crashes if we don't check
+            this.. and to check it entails a lot of overhead... shouldn't be a problem with machines with only a RAS
+            interface anyway as we can bind to the loopback or 0.0.0.0 */
+ 
+         if ((strlen(servicename) >= 7) && (strncmp(strupr(servicename),"NDISWAN",7) == 0))
+           {
+             /* skip it */
+ 	    dprintf(1, (ddt, "Skippping temporary interface [%s]\n",servicename));
+           }
+         else {
+   
+            /* if opening this key fails we can assume it is not a network card ie digiboard and go on.. */
+            /* ok now that we have the service name parameter close the key and go get the ipaddress and subnet mask */
+ 
+            strcpy(newkey,"SYSTEM\\Currentcontrolset\\Services\\");
+            strcat(newkey,servicename);
+            strcat(newkey,"\\parameters\\tcpip");
+ 
+            bSuccess = RegOpenKey(HKEY_LOCAL_MACHINE,newkey,&hksub);
+            if(bSuccess != ERROR_SUCCESS)
+             {
+               dprintf(1, (ddt, "Skipping interface [%s] ... It is not a network card.\n",servicename));
+             }
+ 
+            else { /* ok it is a network card */            
+            /* ok now get the ipaddress and subnetmask */
+            sizeofipaddresses = 10000;
+            bSuccess = RegQueryValueEx(hksub,  /* subkey handle         */
+            "IpAddress",                       /* value name            */
+             NULL,                             /* must be zero          */
+             NULL,                             /* value type          not required  */
+             (LPBYTE) &IpAddresses,               /* address of value data */
+             &sizeofipaddresses);                /* length of value data  */
+             if(bSuccess != ERROR_SUCCESS)
+               {
+                syslog(LOG_ERR, "Error in RegQueryValueEx fetching IpAddress parameter: %m");
+                RegCloseKey(hksub);
+                return -1;
+               }
+            /* ok now get the ipaddress and subnetmask */
+            sizeofsubnetmasks = 10000;
+            bSuccess = RegQueryValueEx(hksub,  /* subkey handle         */
+            "SubNetMask",                      /* value name            */
+             NULL,                             /* must be zero          */
+             NULL,                             /* value type          not required  */
+             (LPBYTE) &SubNetMasks,              /* address of value data */
+             &sizeofsubnetmasks);               /* length of value data  */
+             if(bSuccess != ERROR_SUCCESS)
+               {
+                syslog(LOG_ERR, "Error in RegQueryValueEx fetching SubNetMask parameter: %m");
+                RegCloseKey(hksub);
+                return -1;
+               }
+ 
+           RegCloseKey(hksub);
+           /* ok now that we have some addresses and subnet masks go through each one and add to our structure... */
+           /* multi_sz strings are terminated by two \0 in a row */
+ 
+ 
+         ipptr = IpAddresses;
+         subptr = SubNetMasks;
+         Done = 0;
+         while (!Done)
+         {
+          ifr = (struct ifreq *)ifc_buffer;
+          if (sscanf(ipptr,"%s",oneIpAddress) != EOF)
+            ipptr+= strlen(oneIpAddress) + 1; /* add one for terminator \0 */
+          else Done = 1;
+          
+          if (sscanf(subptr,"%s",oneSubNetMask) != EOF)
+            subptr += strlen(oneSubNetMask) + 1;
+          else Done = 1;
+ 
+          /* now add to interface structure */
+          if (!Done)                  
+           {
+            ifr->ifr_addr.sa_family = AF_INET;
+            ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr = inet_addr(oneIpAddress);
+            strcpy(ifr->ifr_mask,oneSubNetMask);
+ 
+            if (strlen(servicename) > 15)
+              strncpy(ifr->ifr_name,servicename,15);
+            else strcpy(ifr->ifr_name,servicename);
+ 
+            /* now increment pointer */
+ 	       ifc_buffer += sizeof (ifr->ifr_name) + sizeof(ifr->ifr_addr) + sizeof(ifr->ifr_mask);
+            ++count;
+            if (((char *)ipptr == '\0') || ((char *)subptr == '\0')) 
+              Done = 1;
+           }
+           
+         }
+            } /* it is a network card */
+         } /* it is/not a temporary ndiswan name */ 
+     } /* end of loop  */
+ 
+     /* now reset the length */
+     ifc->ifc_len = count * (sizeof(ifr->ifr_name) + sizeof(ifr->ifr_addr) + sizeof(ifr->ifr_mask));
+     return 0;
+ }
+ 
+ #endif /* WINNT */
+ 
+ 
diff --context --recurs m:\bind494rel/named/ns_maint.c m:\bind/named/ns_maint.c
*** m:\bind494rel/named/ns_maint.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_maint.c	Thu Jun 27 19:37:33 1996
***************
*** 19,34 ****
   *    documentation and/or other materials provided with the distribution.
   * 3. All advertising materials mentioning features or use of this software
   *    must display the following acknowledgement:
!  * 	This product includes software developed by the University of
!  * 	California, Berkeley and its contributors.
!  * 4. Neither the name of the University nor the names of its contributors
!  *    may be used to endorse or promote products derived from this software
!  *    without specific prior written permission.
   * 
!  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
!  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
!  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
--- 19,34 ----
   *    documentation and/or other materials provided with the distribution.
   * 3. All advertising materials mentioning features or use of this software
   *    must display the following acknowledgement:
!  *      This product includes software developed by the University of
!  *      California, Berkeley and its contributors.
!  * 4. Neither the name of the University nor the names of its contributors
!  *    may be used to endorse or promote products derived from this software
!  *    without specific prior written permission.
   * 
!  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
!  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
!  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
***************
*** 58,72 ****
--- 58,78 ----
   * --Copyright--
   */
  
+ #ifndef WINNT
  #include <sys/param.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
+ #endif
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
+ #ifndef WINNT
  #include <sys/wait.h>
+ #endif
  #include <stdio.h>
+ #ifndef WINNT
  #include <syslog.h>
+ #endif
  #include <signal.h>
  #include <errno.h>
  #include <sys/stat.h>
***************
*** 74,101 ****
  #include "named.h"
  
  #ifdef USE_UTIME
  # include <utime.h>
  #endif
  
! static int		xfers_running,	/* # of xfers running */
! 			xfers_deferred,	/* # of needed xfers not run yet */
  			qserials_running,
! 			alarm_pending,	/* flag */
  			nxfers __P((struct zoneinfo *, int));
  
! static void		startxfer __P((struct zoneinfo *)),
  			abortxfer __P((struct zoneinfo *)),
  			addxfer __P((struct zoneinfo *)),
  			tryxfer __P((void));
  
! #define	qserial_qfull()	(qserials_running == MAXQSERIAL)
  
  #ifdef CLEANCACHE
! static time_t cache_time;
  #endif
  #ifdef XSTATS
! static time_t stats_time;
  #endif
  /*
   * Invoked at regular intervals by signal interrupt; refresh all secondary
   * zones from primary name server and remove old cache entries.  Also,
--- 80,185 ----
  #include "named.h"
  
  #ifdef USE_UTIME
+ #ifndef WINNT
  # include <utime.h>
+ #else
+ # include <sys/utime.h>
+ #endif
  #endif
  
! static int              xfers_running,  /* # of xfers running */
! 			xfers_deferred, /* # of needed xfers not run yet */
  			qserials_running,
! 			alarm_pending,  /* flag */
  			nxfers __P((struct zoneinfo *, int));
  
! static void             startxfer __P((struct zoneinfo *)),
  			abortxfer __P((struct zoneinfo *)),
  			addxfer __P((struct zoneinfo *)),
  			tryxfer __P((void));
  
! #define qserial_qfull() (qserials_running == MAXQSERIAL)
  
  #ifdef CLEANCACHE
! static time_t cache_time = 0;
  #endif
  #ifdef XSTATS
! static time_t stats_time = 0;
  #endif
+ 
+ #ifdef WINNT
+ /* lgk since timer resolution on nt (at least my box) only goes to 1000 seconds
+  * our method using mmedia times is no good therefore use a thread that
+  * we create that sleeps the timeout period and then when done calls maint_alarm
+  * and exits...
+  * lgk dec. 95 change again to use a waitforsingleobject on an event for the specified
+  * timeout instead of sleep so it can be signaled with a reschedule request..
+  */
+     
+ DWORD pending_delay = 0;
+ volatile HANDLE rescheduleevent = 0x00;
+ DWORD threadid;
+ HANDLE threadhandle = 0x00;
+ HANDLE threadhandle2 = 0x00;
+ static void named_xfer __P((HANDLE *));
+ static void CALLBACK maint_alarm __P((UINT,UINT,DWORD,DWORD,DWORD));
+ extern CRITICAL_SECTION protected_zp;
+ extern CRITICAL_SECTION maint_section;
+ volatile BOOLEAN maint_thread_running = FALSE;
+ 
+ DWORD thread_timer_fx(DWORD timeout)
+   {
+ 
+     DWORD rvalue;
+ 
+     /* now wait on the handle */
+     rvalue = WaitForSingleObject(rescheduleevent,timeout);
+ 
+     /* now check reason we woke up */
+     switch (rvalue)
+      {
+ 
+       case WAIT_FAILED:
+         dprintf(1, (ddt, "Wait for thread timer event object failed!\n")); 
+         syslog(LOG_ERR, "Wait for thread timer event object failed!");
+         EnterCriticalSection(&maint_section);
+         maint_thread_running = FALSE;
+         LeaveCriticalSection(&maint_section);
+         ExitThread(0);
+         break;
+       
+       case WAIT_OBJECT_0:
+         dprintf(1, (ddt, "In Maintenance thread... current thread is exiting for reschedule request!\n"));
+         /* don't set thread running to false here as by the time this gets hit and the
+            thread terminates we may overwrite someone else setting it to true */
+         ExitThread(0);
+         break;
+ 
+       case WAIT_TIMEOUT:
+         dprintf(1, (ddt, "In Maintenance thread... timer has expired!\n"));
+         break;
+       
+       default:
+         dprintf(1, (ddt, "Unknown return type from WaitForSingleObject in thread_timer_fx (%d)!\n",rvalue));
+         syslog(LOG_ERR, "Unknown return type from WaitForSingleObject in thread_timer_fx (%d)!\n",rvalue);
+         EnterCriticalSection(&maint_section);
+         maint_thread_running = FALSE;
+         LeaveCriticalSection(&maint_section);
+         ExitThread(0);
+         break;
+       
+      }
+ 
+     EnterCriticalSection(&maint_section);
+     maint_thread_running = FALSE;
+     LeaveCriticalSection(&maint_section);
+     maint_alarm(0,0,0,0,0);
+     return 0;
+ }
+ 
+ 
+ #endif /* WINNT */
+ 
  /*
   * Invoked at regular intervals by signal interrupt; refresh all secondary
   * zones from primary name server and remove old cache entries.  Also,
***************
*** 109,123 ****
  	int zonenum;
  
  	gettime(&tt);
- 
  	dprintf(1, (ddt, "\nns_maint(); now %s", ctimel(tt.tv_sec)));
- 
  	alarm_pending = 0;
  	for (zp = zones, zonenum = 0; zp < &zones[nzones]; zp++, zonenum++) {
  #ifdef DEBUG
  		if (debug >= 2)
  			printzoneinfo(zonenum);
  #endif
  		if (tt.tv_sec >= zp->z_time && zp->z_refresh > 0) {
  			switch (zp->z_type) {
  
--- 193,208 ----
  	int zonenum;
  
  	gettime(&tt);
  	dprintf(1, (ddt, "\nns_maint(); now %s", ctimel(tt.tv_sec)));
  	alarm_pending = 0;
  	for (zp = zones, zonenum = 0; zp < &zones[nzones]; zp++, zonenum++) {
  #ifdef DEBUG
  		if (debug >= 2)
  			printzoneinfo(zonenum);
  #endif
+                 dprintf(1, (ddt, "debug tt.tv_sec = %d , zp->z_time = %d, zp->z_refresh = %d \n",
+                                  tt.tv_sec,zp->z_time, zp->z_refresh));
+                 dprintf(1, (ddt, "want tv_sec > = z_time and z_refresh > 0 \n"));
  		if (tt.tv_sec >= zp->z_time && zp->z_refresh > 0) {
  			switch (zp->z_type) {
  
***************
*** 142,147 ****
--- 227,233 ----
  					break;
  				}
  				if (zp->z_flags & Z_XFER_RUNNING) {
+ 				        dprintf(1, (ddt, "calling abort\n"));
  					abortxfer(zp);
  					break;
  				}
***************
*** 164,184 ****
  		}
  	}
  #ifdef CLEANCACHE
! 	if ((cache_time + cache_interval) <= tt.tv_sec) {
  		if (cache_time && !NoRecurse && !NoFetchGlue)
! 			remove_zone(hashtab, 0, 0);
  		cache_time = tt.tv_sec;
! 	}
  #endif
  #ifdef XSTATS
! 	if (stats_time + stats_interval <= tt.tv_sec) {
  		if (stats_time)
! 			ns_logstats();
  		stats_time = tt.tv_sec;
! 	}
  #endif
  	if (!needmaint)
! 		sched_maint();
  	dprintf(1, (ddt, "exit ns_maint()\n"));
  }
  
--- 250,273 ----
  		}
  	}
  #ifdef CLEANCACHE
! 	if ((cache_time + cache_interval) <= tt.tv_sec)
! 	  {
  		if (cache_time && !NoRecurse && !NoFetchGlue)
! 		  remove_zone(hashtab, 0, 0);
  		cache_time = tt.tv_sec;
! 	  }
  #endif
  #ifdef XSTATS
!     dprintf(1, (ddt, "\nns_maint(); stats interval is %d\n",stats_interval));
! 	if (stats_time + stats_interval <= tt.tv_sec)
! 	  {
  		if (stats_time)
! 		  ns_logstats();
  		stats_time = tt.tv_sec;
! 	  }
  #endif
  	if (!needmaint)
! 	  sched_maint();
  	dprintf(1, (ddt, "exit ns_maint()\n"));
  }
  
***************
*** 190,212 ****
  sched_maint()
  {
  	register struct zoneinfo *zp;
  	struct itimerval ival;
! #ifdef	CLEANCACHE
  	time_t next_refresh = cache_time + cache_interval;
  #else
  	time_t next_refresh = 0;
  #endif
! 	static time_t next_alarm;
  
  	for (zp = zones; zp < &zones[nzones]; zp++)
  		if (zp->z_time != 0 &&
  		    (next_refresh == 0 || next_refresh > zp->z_time))
  			next_refresh = zp->z_time;
!         /*
  	 *  Schedule the next call to ns_maint.
  	 *  Don't visit any sooner than maint_interval.
  	 */
! 	bzero((char *)&ival, sizeof ival);
  	if (next_refresh != 0) {
  		if (next_refresh == next_alarm && alarm_pending) {
  			dprintf(1, (ddt, "sched_maint: no schedule change\n"));
--- 279,307 ----
  sched_maint()
  {
  	register struct zoneinfo *zp;
+ #ifndef WINNT
  	struct itimerval ival;
! #else
! 	DWORD wDelay;
! #endif
! #ifdef  CLEANCACHE
  	time_t next_refresh = cache_time + cache_interval;
  #else
  	time_t next_refresh = 0;
  #endif
! 	static time_t next_alarm  ;
  
  	for (zp = zones; zp < &zones[nzones]; zp++)
  		if (zp->z_time != 0 &&
  		    (next_refresh == 0 || next_refresh > zp->z_time))
  			next_refresh = zp->z_time;
! 	/*
  	 *  Schedule the next call to ns_maint.
  	 *  Don't visit any sooner than maint_interval.
  	 */
! #ifndef WINNT
! 	bzero((char *)&ival, sizeof (ival));
! #endif
  	if (next_refresh != 0) {
  		if (next_refresh == next_alarm && alarm_pending) {
  			dprintf(1, (ddt, "sched_maint: no schedule change\n"));
***************
*** 218,232 ****
--- 313,388 ----
  		 */
  		if (next_refresh < tt.tv_sec)
  			next_refresh = tt.tv_sec;
+ #ifndef WINNT
  		ival.it_value.tv_sec = next_refresh - tt.tv_sec;
  		if ((long) ival.it_value.tv_sec < maint_interval)
  			ival.it_value.tv_sec = maint_interval;
+ #else
+ 		wDelay = (next_refresh - tt.tv_sec) * 1000;
+ 		if ((long) wDelay < (maint_interval * 1000))
+ 			wDelay = maint_interval * 1000;
+ #endif
  		next_alarm = next_refresh;
  		alarm_pending = 1;
  	}
+ #ifndef WINNT
  	(void) setitimer(ITIMER_REAL, &ival, (struct itimerval *)NULL);
  	dprintf(1, (ddt, "sched_maint: Next interrupt in %lu sec\n",
  		    (u_long)ival.it_value.tv_sec));
+ #else
+       /* lgk under my h/w for nt maximum timer values are 1000 seconds... the above values are not for resolution
+        * as the original author supposed but for the minimum and maximum timer values that mm timers supports..
+        * and since they don't supprt 1 hour... the create of the timer object was failing... therefore the only
+        * way I figured out to do this was create a thread that sleeps for the timeout and then waits up and calls
+        * maint alarm... seems to work ok now... 
+        * lgk dec. 95 change again to use a waitforsingleobject on an event for the specified
+        * timeout instead of sleep so it can be signaled with a reschedule request..
+        */
+ 
+        /* lgk 12/95 there is a problem here were it tries to reschedule
+           when a timer thread is already running... under nt now see comment above */
+ 
+       if (rescheduleevent == 0x00)
+         {
+           if ((rescheduleevent = CreateEvent(NULL,TRUE,FALSE,NULL)) == 0x00)
+             {
+              syslog(LOG_ERR,"Error: Couldn't create the maint. reschedule event object!");
+              dprintf(1, (ddt, "Error: Couldn't create the maint. reschedule event object!"));
+              return;
+             }
+         }
+ 
+       /* first check if already one running */
+       EnterCriticalSection(&maint_section);
+       
+       if (maint_thread_running)
+         { /* ok now check if we have a smaller time */
+           dprintf(1,(ddt,"sched_maint: Rescheduling maint. from %d sec to %d sec.\n",pending_delay/1000,wDelay/1000));
+           /* signal other waiting thread to exit */
+           PulseEvent(rescheduleevent);
+         }
+ 
+        maint_thread_running = TRUE;
+ 
+        if (threadhandle != 0x00)
+          CloseHandle(threadhandle );
+        /* reset the event */
+        ResetEvent(rescheduleevent);   
+ 
+        threadhandle = NULL;
+        threadhandle = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thread_timer_fx,(LPVOID)wDelay,0,&threadid);
+ 
+        if (threadhandle == NULL)
+ 	     {
+            syslog(LOG_ERR, "CreateThread() for maintenance: %m");
+ 	     }
+ 
+        
+        pending_delay = wDelay;
+  	   dprintf(1, (ddt, "sched_maint: Next interrupt in %d sec\n",wDelay/1000));
+        LeaveCriticalSection(&maint_section);
+ 
+ #endif
  }
  
  /*
***************
*** 292,298 ****
  	if (!qp) {
  		syslog(LOG_INFO, "qserial_query(%s): sysquery FAILED",
  		       zp->z_origin);
! 		return;		/* XXX - this is bad, we should do something */
  	}
  	qp->q_flags |= Q_ZSERIAL;
  	qp->q_zquery = zp;
--- 448,454 ----
  	if (!qp) {
  		syslog(LOG_INFO, "qserial_query(%s): sysquery FAILED",
  		       zp->z_origin);
! 		return;         /* XXX - this is bad, we should do something */
  	}
  	qp->q_flags |= Q_ZSERIAL;
  	qp->q_zquery = zp;
***************
*** 313,319 ****
  	dprintf(1, (ddt, "qserial_answer(%s, %lu)\n",
  		    zp->z_origin, (u_long)serial));
  	zp->z_flags &= ~Z_QSERIAL;
! 	qp->q_flags &= ~Q_ZSERIAL;	/* keeps us from being called twice */
  	qserials_running--;
  	if (serial == 0) {
  		/* an error occurred, or the query timed out.
--- 469,475 ----
  	dprintf(1, (ddt, "qserial_answer(%s, %lu)\n",
  		    zp->z_origin, (u_long)serial));
  	zp->z_flags &= ~Z_QSERIAL;
! 	qp->q_flags &= ~Q_ZSERIAL;      /* keeps us from being called twice */
  	qserials_running--;
  	if (serial == 0) {
  		/* an error occurred, or the query timed out.
***************
*** 354,359 ****
--- 510,516 ----
  #endif
  #endif /* POSIX_SIGNALS */
  
+ #ifndef WINNT
  void holdsigchld()
  {
  #ifdef POSIX_SIGNALS
***************
*** 380,385 ****
--- 537,543 ----
  #endif /* POSIX_SIGNALS */
  }
  
+ #endif
  	/* State of all running zone transfers */
  static struct {
  	pid_t 	xfer_pid;
***************
*** 404,410 ****
  	struct zoneinfo *zp;
  {
  	static char *argv[NSMAX + 20], argv_ns[NSMAX][MAXDNAME];
! 	int argc = 0, argc_ns = 0, pid, i;
  	unsigned int cnt;
  	char debug_str[10];
  	char serial_str[10];
--- 562,571 ----
  	struct zoneinfo *zp;
  {
  	static char *argv[NSMAX + 20], argv_ns[NSMAX][MAXDNAME];
! 	int argc = 0, argc_ns = 0, i;
! #ifdef WINNT
! 	extern char *pathxferddt, *pathxfertrace;
! #endif
  	unsigned int cnt;
  	char debug_str[10];
  	char serial_str[10];
***************
*** 412,421 ****
  #ifdef GEN_AXFR
  	char class_str[10];
  #endif
  
  	dprintf(1, (ddt, "startxfer() %s\n", zp->z_origin));
  
! 	argv[argc++] = _PATH_XFER;
  	argv[argc++] = "-z";
  	argv[argc++] = zp->z_origin;
  	argv[argc++] = "-f";
--- 573,597 ----
  #ifdef GEN_AXFR
  	char class_str[10];
  #endif
+ #ifdef WINNT
+ 	char *pos;
+ 	DWORD xfer_thread_id;
+ 	STARTUPINFO sui;
+ 	static char CommandLine[NSMAX*(MAXDNAME+1)+20*10];
+ 	PROCESS_INFORMATION *proc_info_copy;
+     
+ 
+ #else
+ 	int pid;
+ #endif
  
  	dprintf(1, (ddt, "startxfer() %s\n", zp->z_origin));
  
! #ifndef WINNT
! 	argv[argc++] = "_PATH_XFER";
! #else
! 	argv[argc++] = "xfer";
! #endif
  	argv[argc++] = "-z";
  	argv[argc++] = zp->z_origin;
  	argv[argc++] = "-f";
***************
*** 428,434 ****
  	sprintf(class_str, "%d", zp->z_class);
  	argv[argc++] = class_str;
  #endif
!  	if (zp->z_flags & Z_SYSLOGGED)
  		argv[argc++] = "-q";
  	argv[argc++] = "-P";
  	sprintf(port_str, "%d", ns_port);
--- 604,610 ----
  	sprintf(class_str, "%d", zp->z_class);
  	argv[argc++] = class_str;
  #endif
! 	if (zp->z_flags & Z_SYSLOGGED)
  		argv[argc++] = "-q";
  	argv[argc++] = "-P";
  	sprintf(port_str, "%d", ns_port);
***************
*** 443,452 ****
--- 619,636 ----
  		sprintf(debug_str, "%d", debug);
  		argv[argc++] = debug_str;
  		argv[argc++] = "-l";
+ #ifndef WINNT
  		argv[argc++] = _PATH_XFERDDT;
+ #else
+ 		argv[argc++] = pathxferddt;
+ #endif
  		if (debug > 5) {
  			argv[argc++] = "-t";
+ #ifndef WINNT
  			argv[argc++] = _PATH_XFERTRACE;
+ #else
+ 			argv[argc++] = pathxfertrace;
+ #endif
  		}
  	}
  #endif
***************
*** 474,503 ****
  			argv[argc++] = strcpy(argv_ns[argc_ns++],
  					      inet_ntoa(a));
  		}
!         }
  
  	argv[argc] = 0;
  
  #ifdef DEBUG
  #ifdef ECHOARGS
  	if (debug) {
  		for (i = 0; i < argc; i++) 
  			fprintf(ddt, "Arg %d=%s\n", i, argv[i]);
!         }
  #endif /* ECHOARGS */
  #endif /* DEBUG */
  
  	gettime(&tt);
! 	holdsigchld();
! 	for (i = 0; i < MAX_XFERS_RUNNING; i++) {
! 		if (xferstatus[i].xfer_pid == 0) {
! 			xferstatus[i].xfer_state = XFER_RUNNING;
! 			break;
! 		}
! 	}
  	if ((pid = vfork()) == -1) {
  		syslog(LOG_ERR, "xfer vfork: %m");
! 		releasesigchld();
  		zp->z_time = tt.tv_sec + 10;
  		return;
  	}
--- 658,708 ----
  			argv[argc++] = strcpy(argv_ns[argc_ns++],
  					      inet_ntoa(a));
  		}
! 	}
  
  	argv[argc] = 0;
  
+ #ifdef WINNT
+ 	/* need the arguments in the form of a string not in argv format */
+ 	pos = CommandLine;
+ 	for (i = 0; i < argc; i++) {
+ 		sprintf(pos, argv[i]);
+ 		pos += strlen(pos);
+ 		*pos++ = ' ';
+ 	}
+ 	*pos = '\0';
+ #endif 
+ 
  #ifdef DEBUG
  #ifdef ECHOARGS
  	if (debug) {
  		for (i = 0; i < argc; i++) 
  			fprintf(ddt, "Arg %d=%s\n", i, argv[i]);
! 	}
  #endif /* ECHOARGS */
  #endif /* DEBUG */
  
  	gettime(&tt);
! #ifndef WINNT
!    	holdsigchld();
! #else
!     /* make sure we don't have two accessing the same structures */
!     /* lgk use critical section here for this and in endxfer where this is read to make sure that not more
!        than one is trying to start a xfer process at a time */
!     EnterCriticalSection(&protected_zp);
!     proc_info_copy = (PROCESS_INFORMATION *)malloc(sizeof(PROCESS_INFORMATION));
!  
! #endif
!   	for (i = 0; i < MAX_XFERS_RUNNING; i++) {
!   		if (xferstatus[i].xfer_pid == 0) {
!   			xferstatus[i].xfer_state = XFER_RUNNING;
!   			break;
!   		}
!   	}
! #ifndef WINNT
  	if ((pid = vfork()) == -1) {
  		syslog(LOG_ERR, "xfer vfork: %m");
!   		releasesigchld();
  		zp->z_time = tt.tv_sec + 10;
  		return;
  	}
***************
*** 506,538 ****
  		/* Child. */
  		execv(_PATH_XFER, argv);
  		syslog(LOG_ERR, "can't exec %s: %m", _PATH_XFER);
! 		_exit(XFER_FAIL);	/* Avoid duplicate buffer flushes. */
  	}
! 	/* Parent. */
! 	xferstatus[i].xfer_pid = pid;  /* XXX - small race condition here if we
! 					* can't hold signals */
  	dprintf(1, (ddt, "started xfer child %d\n", pid));
  	zp->z_flags &= ~Z_NEED_XFER;
  	zp->z_flags |= Z_XFER_RUNNING;
! 	zp->z_xferpid = pid;
  	xfers_running++;
  	zp->z_time = tt.tv_sec + MAX_XFER_TIME;
! 	releasesigchld();
  }
  
  const char *
  zoneTypeString(zp)
  	const struct zoneinfo *zp;
  {
! 	static char ret[sizeof "(4294967296?)"];	/* 2^32 */
  
  	switch (zp->z_type) {
! 	case Z_PRIMARY:		return ("primary");
! 	case Z_SECONDARY:	return ("secondary");
  #ifdef STUBS
! 	case Z_STUB:		return ("stub");
  #endif
! 	case Z_CACHE:		return ("cache");
  	default:
  		sprintf(ret, "(%lu?)", (u_long)zp->z_type);
  		return (ret);
--- 711,785 ----
  		/* Child. */
  		execv(_PATH_XFER, argv);
  		syslog(LOG_ERR, "can't exec %s: %m", _PATH_XFER);
! 		_exit(XFER_FAIL);       /* Avoid duplicate buffer flushes. */
  	}
! #else /* WINNT */
! 	bzero((char *)&sui, sizeof(STARTUPINFO));
! 	sui.cb = sizeof(STARTUPINFO);
! 	if (!CreateProcess(NULL, CommandLine, NULL, NULL, FALSE, DETACHED_PROCESS, NULL,
! 					   NULL, &sui, (LPPROCESS_INFORMATION)proc_info_copy))
!       {
! 	     syslog(LOG_ERR, "CreateProcess() for xfer: %m");
!              LeaveCriticalSection(&protected_zp);
! 	     return;
! 	  }
! 
! 	threadhandle2 = NULL;
! 	threadhandle2 = CreateThread(
! 	         NULL,                                /* no security attributes  */
! 	         0,                                   /* use default stack size  */
! 	         (LPTHREAD_START_ROUTINE) named_xfer, /* thread function         */
! 	         (LPVOID) proc_info_copy,             /* argument to thread function   */
! 	         0,                                   /* use default creation flags    */
! 	         (LPDWORD) &xfer_thread_id);
! 
!     if (threadhandle2 == NULL)
! 	  {
!         syslog(LOG_ERR, "CreateThread() for xfer status: %m");
!         LeaveCriticalSection(&protected_zp);
! 	return;
! 	  }
! 	CloseHandle(threadhandle2); /* no handle to this needed */
! 	
! #endif /* WINNT */
! 	/* parent */
! #ifdef WINNT
! 	dprintf(1, (ddt, "started xfer child %d\n", proc_info_copy->hProcess));
!     zp->z_xferpid = proc_info_copy->hProcess;
!   	xferstatus[i].xfer_pid = (long)proc_info_copy->hProcess;
! #else
! 	zp->z_xferpid = pid;
!   	xferstatus[i].xfer_pid = pid;  /* XXX - small race condition here if we
!   					* can't hold signals */
  	dprintf(1, (ddt, "started xfer child %d\n", pid));
+ #endif
  	zp->z_flags &= ~Z_NEED_XFER;
  	zp->z_flags |= Z_XFER_RUNNING;
! 
  	xfers_running++;
  	zp->z_time = tt.tv_sec + MAX_XFER_TIME;
! 
! #ifdef WINNT
!     LeaveCriticalSection(&protected_zp);
! #else
!   	releasesigchld();
! #endif
!     
  }
  
  const char *
  zoneTypeString(zp)
  	const struct zoneinfo *zp;
  {
! 	static char ret[sizeof "(4294967296?)"];        /* 2^32 */
  
  	switch (zp->z_type) {
! 	case Z_PRIMARY:         return ("primary");
! 	case Z_SECONDARY:       return ("secondary");
  #ifdef STUBS
! 	case Z_STUB:            return ("stub");
  #endif
! 	case Z_CACHE:           return ("cache");
  	default:
  		sprintf(ret, "(%lu?)", (u_long)zp->z_type);
  		return (ret);
***************
*** 560,566 ****
  #ifdef GEN_AXFR
  	fprintf(ddt, ", class = %d", zp->z_class);
  #endif
!  	fprintf(ddt, ", type = %s", zoneTypeString(zp));
  	if (zp->z_source)
  		fprintf(ddt,", source = %s\n", zp->z_source);
  	fprintf(ddt, "z_refresh = %lu", (u_long)zp->z_refresh);
--- 807,813 ----
  #ifdef GEN_AXFR
  	fprintf(ddt, ", class = %d", zp->z_class);
  #endif
! 	fprintf(ddt, ", type = %s", zoneTypeString(zp));
  	if (zp->z_source)
  		fprintf(ddt,", source = %s\n", zp->z_source);
  	fprintf(ddt, "z_refresh = %lu", (u_long)zp->z_refresh);
***************
*** 590,596 ****
  #endif
  	register struct hashbuf *htp;
  	register int zone;
! #ifdef	CLEANCACHE
  	register int all;
  #endif
  {
--- 837,843 ----
  #endif
  	register struct hashbuf *htp;
  	register int zone;
! #ifdef  CLEANCACHE
  	register int all;
  #endif
  {
***************
*** 660,666 ****
  	    !ns_wildcard(NAME(*np))) {
  		for (pdp = NULL, dp = np->n_data; dp != NULL; ) {
  			if (dp->d_class == class)
! 				dp = rm_datum(dp, np, pdp);
  			else {
  				pdp = dp;
  				dp = dp->d_next;
--- 907,913 ----
  	    !ns_wildcard(NAME(*np))) {
  		for (pdp = NULL, dp = np->n_data; dp != NULL; ) {
  			if (dp->d_class == class)
! 			    dp = rm_datum(dp, np, pdp);
  			else {
  				pdp = dp;
  				dp = dp->d_next;
***************
*** 766,772 ****
  		if (dp->d_zone == 0)
  			continue;
  #ifdef NCACHE
! 		if (dp->d_rcode)	/* this should not occur */
  			continue;
  #endif
  		if (dp->d_type == T_SOA)
--- 1013,1019 ----
  		if (dp->d_zone == 0)
  			continue;
  #ifdef NCACHE
! 		if (dp->d_rcode)        /* this should not occur */
  			continue;
  #endif
  		if (dp->d_type == T_SOA)
***************
*** 790,825 ****
  	int ret;
  
  	if (zp->z_xaddr.s_addr)
! 		nsa = zp->z_xaddr;	/* qserial overrode address */
  	else if (!zp->z_addrcnt)
  		return (-1);
  	else
! 		nsa = zp->z_addr[0];	/* first ns holds zone's xfer limit */
  
  	if (!(nsp = nameserFind(nsa, NS_F_INSERT)))
! 		return (-1);		/* probably ENOMEM */
  
  	ret = nsp->xfers;
  	if (delta < 0 && -delta > ret)
! 		return (-1);		/* taking more than we have */
  
  	nsp->xfers += delta;
  	return (ret);
  }
  
  /*
   * Abort an xfer that has taken too long.
   */
  static void
  abortxfer(zp)
  	struct zoneinfo *zp;
! {
  	if (zp->z_flags & (Z_XFER_GONE|Z_XFER_ABORTED)) {
  		int i;
  
  		for (i = 0; i < MAX_XFERS_RUNNING; i++) {
! 			if (xferstatus[i].xfer_pid == zp->z_xferpid) {
! 				xferstatus[i].xfer_pid = 0;
  				xferstatus[i].xfer_state = XFER_IDLE;
  				break;
  			}
--- 1037,1090 ----
  	int ret;
  
  	if (zp->z_xaddr.s_addr)
! 		nsa = zp->z_xaddr;      /* qserial overrode address */
  	else if (!zp->z_addrcnt)
  		return (-1);
  	else
! 		nsa = zp->z_addr[0];    /* first ns holds zone's xfer limit */
  
  	if (!(nsp = nameserFind(nsa, NS_F_INSERT)))
! 		return (-1);            /* probably ENOMEM */
  
  	ret = nsp->xfers;
  	if (delta < 0 && -delta > ret)
! 		return (-1);            /* taking more than we have */
  
  	nsp->xfers += delta;
  	return (ret);
  }
  
+ 
  /*
   * Abort an xfer that has taken too long.
   */
+ 
  static void
  abortxfer(zp)
  	struct zoneinfo *zp;
!    {
! 
! #ifdef WINNT
! 	    TerminateProcess(zp->z_xferpid, (UINT)XFER_KILLED);
! 
! 	    syslog(LOG_WARNING,
! 		"zone transfer timeout for \"%s\"; pid %lu killed",
! 		zp->z_origin, (u_long)zp->z_xferpid);
!              dprintf(1, (ddt, "zone transfer timeout for %s pid %lu killed\n",
! 		zp->z_origin, (u_long)zp->z_xferpid));
! 
! 		zp->z_flags |= Z_XFER_ABORTED;
! 	     ns_retrytime(zp, tt.tv_sec);
!  	     (void) nxfers(zp, -1);        
! 
! #else
! 
  	if (zp->z_flags & (Z_XFER_GONE|Z_XFER_ABORTED)) {
  		int i;
  
  		for (i = 0; i < MAX_XFERS_RUNNING; i++) {
! 			if (xferstatus[i].xfer_pid == (long)zp->z_xferpid) {
! 			    xferstatus[i].xfer_pid = 0;
  				xferstatus[i].xfer_state = XFER_IDLE;
  				break;
  			}
***************
*** 829,849 ****
  			syslog(LOG_WARNING,
  			   "zone transfer timeout for \"%s\"; pid %lu missing",
  			       zp->z_origin, (u_long)zp->z_xferpid);
  		else if (kill(zp->z_xferpid, SIGKILL) == -1)
  			syslog(LOG_WARNING,
  			  "zone transfer timeout for \"%s\"; kill pid %lu: %m",
  			       zp->z_origin, (u_long)zp->z_xferpid);
  		else
  			syslog(LOG_WARNING,
! "zone transfer timeout for \"%s\"; second kill\
! pid %lu - forgetting, processes may accumulate",
! 			       zp->z_origin, (u_long)zp->z_xferpid);
  
  		zp->z_xferpid = 0;
  		xfers_running--;
  		(void)nxfers(zp, -1);
  		zp->z_flags &= ~(Z_XFER_RUNNING|Z_XFER_ABORTED|Z_XFER_GONE);
! 	} else if (kill(zp->z_xferpid, SIGKILL) == -1) {
  		if (errno == ESRCH)
  			/* No warning on first time, it may have just exited */
  			zp->z_flags |= Z_XFER_GONE;
--- 1094,1117 ----
  			syslog(LOG_WARNING,
  			   "zone transfer timeout for \"%s\"; pid %lu missing",
  			       zp->z_origin, (u_long)zp->z_xferpid);
+ 
  		else if (kill(zp->z_xferpid, SIGKILL) == -1)
  			syslog(LOG_WARNING,
  			  "zone transfer timeout for \"%s\"; kill pid %lu: %m",
  			       zp->z_origin, (u_long)zp->z_xferpid);
  		else
  			syslog(LOG_WARNING,
!                             "zone transfer timeout for \"%s\"; second kill\
!                              pid %lu - forgetting, processes may accumulate",
! 			     zp->z_origin, (u_long)zp->z_xferpid);
  
  		zp->z_xferpid = 0;
  		xfers_running--;
  		(void)nxfers(zp, -1);
  		zp->z_flags &= ~(Z_XFER_RUNNING|Z_XFER_ABORTED|Z_XFER_GONE);
! 	}
! 
!         else if (kill(zp->z_xferpid, SIGKILL) == -1) {
  		if (errno == ESRCH)
  			/* No warning on first time, it may have just exited */
  			zp->z_flags |= Z_XFER_GONE;
***************
*** 859,866 ****
  		       zp->z_origin, (u_long)zp->z_xferpid);
  		zp->z_flags |= Z_XFER_ABORTED;
  	}
! }
  
  /*
   * SIGCHLD signal handler: process exit of xfer's.
   * (Note: also called when outgoing transfer completes.)
--- 1127,1138 ----
  		       zp->z_origin, (u_long)zp->z_xferpid);
  		zp->z_flags |= Z_XFER_ABORTED;
  	}
! 	
! #endif
!    }
! 
  
+ #ifndef WINNT
  /*
   * SIGCHLD signal handler: process exit of xfer's.
   * (Note: also called when outgoing transfer completes.)
***************
*** 898,936 ****
  	errno = save_errno;
  }
  
  /*
!  * Finish processing of of finished xfers
   */
  void
  endxfer()
  {
!     	register struct zoneinfo *zp;   
! 	int exitstatus, pid, i;
  #if defined(sequent)
  	union wait status;
  #else
  	int status;
  #endif /* sequent */
  
! 	gettime(&tt);
  
! 	for (i = 0; i < MAX_XFERS_RUNNING; i++) {
! 		if (xferstatus[i].xfer_state != XFER_DONE)
! 			continue;
! 		pid = xferstatus[i].xfer_pid;
! 		status = xferstatus[i].xfer_status;
! 		exitstatus = WIFEXITED(status) ?WEXITSTATUS(status) :0;
  
! 		for (zp = zones; zp < &zones[nzones]; zp++) {
  			if (zp->z_xferpid != pid)
  				continue;
  			xfers_running--;
  			(void) nxfers(zp, -1);
  			zp->z_xferpid = 0;
! 			zp->z_flags &=
! 				~(Z_XFER_RUNNING|Z_XFER_ABORTED|Z_XFER_GONE);
  			dprintf(1, (ddt,
! 		 "\nendxfer: child %d zone %s returned status=%d termsig=%d\n",
  				    pid, zp->z_origin, exitstatus,
  				    WIFSIGNALED(status) ?WTERMSIG(status) :-1
  				    )
--- 1170,1267 ----
  	errno = save_errno;
  }
  
+ }
+ #endif
+ 
  /*
!  * SIGCHLD signal handler: process exit of xfer's.
!  * (Note: also called when outgoing transfer completes.)
   */
+ /* the semantics here have changed now we call reapchild when a transfer ends which sets the
+    variable needendxfer ... however under nt since there are no signals endxfer is called
+    directly when a transfer ends... therefore we need to clear out the entry here under 
+    nt, also under nt we determine the pid to clear because it is passed in ... lgk */
+ 
+ #ifndef WINNT
  void
  endxfer()
+ #else
+ void
+ endxfer(pid)
+ 	HANDLE pid;
+ #endif
  {
!     register struct zoneinfo *zp;
! #ifndef WINNT   
!  	int exitstatus, pid;
  #if defined(sequent)
  	union wait status;
  #else
  	int status;
  #endif /* sequent */
+ #else
+ 	DWORD exitstatus;
+ #endif
+     int i;
  
! gettime(&tt);
  
! /* under Win NT this should not get called unless a transfer has completed 
!  * or aborted
!  */
! #ifndef WINNT
!   	for (i = 0; i < MAX_XFERS_RUNNING; i++) {
!   		if (xferstatus[i].xfer_state != XFER_DONE)
!   			continue;
!   		pid = xferstatus[i].xfer_pid;
!   		status = xferstatus[i].xfer_status;
  
!     		exitstatus = WIFEXITED(status) ?WEXITSTATUS(status) :0;
! #else
!  
! 	if (!GetExitCodeProcess(pid, &exitstatus))
!           {
! 	    syslog(LOG_ERR, "endxfer: cannot determine return code of the xfer (%d) process: %m",pid);
! 	    dprintf(1, (ddt, "endxfer: cannot determine return code of the xfer (%d) process: %d",pid,GetLastError()));
!             /* lgk new code here if we cannot figure this out dummy it up so it gets rescheduled anyway */
!             /* dont return as previously or the zone does not get rescheduled */
!             exitstatus = XFER_FAIL;
! 	  }
! #endif /* WINNT */
! 
! 		for (zp = zones; zp < &zones[nzones]; zp++)
!                    {
  			if (zp->z_xferpid != pid)
  				continue;
+             /* ok found our zone */
+ #ifdef WINNT
+             /* regardless of how it terminated if under NT clear it out here
+              * first find the entry 
+              */
+              
+   	         for (i = 0; i < MAX_XFERS_RUNNING; i++) {
+ 			    if (xferstatus[i].xfer_pid == (long)pid) {
+ 				    xferstatus[i].xfer_status = exitstatus;
+                     xferstatus[i].xfer_state = XFER_IDLE;
+ 			    	xferstatus[i].xfer_pid = 0;
+ 			    	
+ 			   } 
+ 		      }
+ 		     /* lgk problem is here we cannot close the handle here as it will reuse it and then close it again later
+ 		        don't think we need to close this handle anyway as it is the same handle that is closed before the free
+ 		        in named_xfer  the problem was that critical sections allow the same thread
+ 		        to go into the same critical section more than once and since this handle was
+ 		        already closed here it was re-allocated and closed again in named-xfer after the call to endxfer  
+ 		     CloseHandle(zp->z_xferpid); */
+ #endif
  			xfers_running--;
  			(void) nxfers(zp, -1);
  			zp->z_xferpid = 0;
!   			zp->z_flags &=
!   				~(Z_XFER_RUNNING|Z_XFER_ABORTED|Z_XFER_GONE);
! #ifndef WINNT
  			dprintf(1, (ddt,
! 		            "\nendxfer: child %d zone %s returned status=%d termsig=%d\n", 
  				    pid, zp->z_origin, exitstatus,
  				    WIFSIGNALED(status) ?WTERMSIG(status) :-1
  				    )
***************
*** 943,948 ****
--- 1274,1284 ----
  				}
  				ns_retrytime(zp, tt.tv_sec);
  			} else {
+ #else /* WINNT */
+ 			dprintf(1, (ddt,
+ 		            "\nendxfer: child %d zone %s returned status=%d \n", 
+ 				    pid, zp->z_origin, exitstatus));
+ #endif /* WINNT */
  				switch (exitstatus) {
  				case XFER_UPTODATE:
  					markUpToDate(zp);
***************
*** 953,992 ****
  					zp->z_flags |= Z_NEED_RELOAD;
  					zp->z_flags &= ~Z_SYSLOGGED;
  					needzoneload++;
  					break;
  
  				case XFER_TIMEOUT:
  					if (!(zp->z_flags & Z_SYSLOGGED)) {
  						zp->z_flags |= Z_SYSLOGGED;
  						syslog(LOG_NOTICE,
! 		      "zoneref: Masters for secondary zone \"%s\" unreachable",
  						       zp->z_origin);
  					}
  					ns_retrytime(zp, tt.tv_sec);
  					break;
! 
  				default:
  					if (!(zp->z_flags & Z_SYSLOGGED)) {
  						zp->z_flags |= Z_SYSLOGGED;
  						syslog(LOG_NOTICE,
! 					     "named-xfer for \"%s\" exited %d",
! 						       zp->z_origin,
! 						       exitstatus);
  					}
  					/* FALLTHROUGH */
  				case XFER_FAIL:
  					zp->z_flags |= Z_SYSLOGGED;
  					ns_retrytime(zp, tt.tv_sec);
  					break;
! 				}
  				break;
! 			}
! 		}
! 		xferstatus[i].xfer_state = XFER_IDLE;
! 		xferstatus[i].xfer_pid = 0;
! 	}
  	releasesigchld();
  	tryxfer();
  }
  
  /*
--- 1289,1343 ----
  					zp->z_flags |= Z_NEED_RELOAD;
  					zp->z_flags &= ~Z_SYSLOGGED;
  					needzoneload++;
+                     dprintf(1, (ddt, "named-xfer for %s ended successfully (child = %d)\n",zp->z_origin,pid));
  					break;
  
  				case XFER_TIMEOUT:
  					if (!(zp->z_flags & Z_SYSLOGGED)) {
  						zp->z_flags |= Z_SYSLOGGED;
  						syslog(LOG_NOTICE,
! 		                      "zoneref: Masters for secondary zone \"%s\" unreachable",
  						       zp->z_origin);
  					}
+                     dprintf(1, (ddt, "Masters for secondary zone %s unreachable (xfer timed out) (child = %d)\n",zp->z_origin,pid));
  					ns_retrytime(zp, tt.tv_sec);
  					break;
! #ifdef WINNT
! 				case XFER_KILLED:
! 					ns_retrytime(zp, tt.tv_sec);
! 					break;
! #endif
  				default:
  					if (!(zp->z_flags & Z_SYSLOGGED)) {
  						zp->z_flags |= Z_SYSLOGGED;
  						syslog(LOG_NOTICE,
! 					         "named-xfer for \"%s\" exited %d",
! 						    zp->z_origin, exitstatus);
  					}
  					/* FALLTHROUGH */
  				case XFER_FAIL:
  					zp->z_flags |= Z_SYSLOGGED;
+                     dprintf(1, (ddt, "(xfer for %s failed in endxfer) (child = %d)\n",zp->z_origin,pid));
+                     syslog(LOG_NOTICE, "(xfer for %s failed) (child = %d) - rescheduling!\n",zp->z_origin,pid);
  					ns_retrytime(zp, tt.tv_sec);
  					break;
! 				} /*switch*/
  				break;
! #ifndef WINNT
! 			} /*if/else*/
! #endif
! 		   } /* inner for */
! 
! #ifndef WINNT
!  	 xferstatus[i].xfer_state = XFER_IDLE;
! 	 xferstatus[i].xfer_pid = 0;
! 	} /* outter for */
! 
  	releasesigchld();
+ #endif
+ 
  	tryxfer();
+ 
  }
  
  /*
***************
*** 1060,1066 ****
   */
  void
  loadxfer() {
!     	register struct zoneinfo *zp;   
  
  	gettime(&tt);
  	for (zp = zones; zp < &zones[nzones]; zp++) {
--- 1411,1417 ----
   */
  void
  loadxfer() {
! 	register struct zoneinfo *zp;   
  
  	gettime(&tt);
  	for (zp = zones; zp < &zones[nzones]; zp++) {
***************
*** 1099,1101 ****
--- 1450,1533 ----
  		tryxfer();
  	}
  }
+ 
+ 
+ #ifdef WINNT
+ void CALLBACK maint_alarm (UINT wTimerID, UINT msg,
+     DWORD dwUser, DWORD dw1, DWORD dw2)
+ {
+ 	int len;
+ 	char loopbuf[] = "";
+ 	    struct sockaddr_in loopback; 
+ 	    needmaint = 1;
+ 	dprintf(1, (ddt, "in maint_alarm ...\n"));
+ 	printf("in maint_alarm ...\n");
+ 
+ #ifdef NOWAIT
+ 	loopback.sin_family = AF_INET;
+ 	loopback.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ 	loopback.sin_port = htons(NAMESERVER_PORT);
+ 	if(len = sendto(datagramq->dq_dfd, loopbuf, 1, 0, (struct sockaddr *)&loopback,
+ 		  sizeof(struct sockaddr_in)) == SOCKET_ERROR)
+ 		{
+ 		syslog(LOG_ERR, "failed to break select for maintenance: %m, maintenance delayed");
+ 		syslog(LOG_ERR, "WSA ERRORCODE WAS: %d", WSAGetLastError());
+ 		}
+ #endif
+ 
+ 
+     UNREFERENCED_PARAMETER(dw1);
+     UNREFERENCED_PARAMETER(dw2);
+     UNREFERENCED_PARAMETER(dwUser);
+     UNREFERENCED_PARAMETER(msg);
+     UNREFERENCED_PARAMETER(wTimerID);
+ }
+ 
+ void
+ named_xfer(PROCESS_INFORMATION *proc_info)
+ {
+ 	DWORD dwWait;
+ 
+ 	dwWait = WaitForSingleObject((*proc_info).hProcess, (DWORD) MAX_XFER_TIME * 1000);
+ 
+ 
+     /* now check reason we woke up */
+     /* remove the return now so let it go into endxfer even if the wait fails so we can resched. the xfer */
+     switch (dwWait)
+      {
+ 
+       case WAIT_TIMEOUT:
+            syslog(LOG_ERR, "WaitForSingleObject() on named-xfer process (%d) status timed out!",(*proc_info).hProcess);
+            dprintf(1,(ddt, "WaitForSingleObject() on named-xfer process (%d) status timed out!\n",(*proc_info).hProcess));
+ 	       break;
+ 
+       case WAIT_FAILED:
+            syslog(LOG_ERR, "WaitForSingleObject() on named-xfer process (%d) status failed: %m",(*proc_info).hProcess);
+            dprintf(1,(ddt, "WaitForSingleObject() on named-xfer process (%d) status failed: %d\n",(*proc_info).hProcess,GetLastError()));
+ 	       break;
+ 
+       case WAIT_OBJECT_0:
+            /* normal case */
+            break;
+        
+       default:
+         dprintf(1, (ddt, "Unknown return type from WaitForSingleObject on named-xfer (%d) status! (%d)\n",(*proc_info).hProcess,dwWait));
+         syslog(LOG_ERR, "Unknown return type from WaitForSingleObject on named-xfer (%d) status %d:",(*proc_info).hProcess,dwWait);
+         break;
+       
+      }
+     
+     /* lgk new code using critical section to synchronize */
+     EnterCriticalSection(&protected_zp);
+     endxfer((*proc_info).hProcess);
+     /* dont try the close if the wait failed for some reason */
+     /* if we have an extra handle around so be it but if the handle is bad ie wait failed not sure what close will do */
+     if (dwWait == WAIT_OBJECT_0)
+       {
+        CloseHandle((*proc_info).hProcess);
+        CloseHandle((*proc_info).hThread);
+       }
+     free((char *)proc_info);
+     LeaveCriticalSection(&protected_zp);
+ }
+ #endif /* WINNT */
diff --context --recurs m:\bind494rel/named/ns_ncache.c m:\bind/named/ns_ncache.c
*** m:\bind494rel/named/ns_ncache.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_ncache.c	Sat Jun 01 03:48:29 1996
***************
*** 6,20 ****
   * implements negative caching
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <syslog.h>
! #include <errno.h>
! #include <stdio.h>
! #include <resolv.h>
  
  #include "named.h"
  
--- 6,24 ----
   * implements negative caching
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <errno.h>
! #include <stdio.h>
! #include <resolv.h>
  
  #include "named.h"
  
***************
*** 31,37 ****
--- 35,43 ----
  	char dname[MAXDNAME];
  	int n;
  	int type, class;
+ #ifdef VALIDATE
  	int Vcode;
+ #endif
  	int flags;
  
  	nameserIncr(from_addr.sin_addr, nssRcvdNXD);
diff --context --recurs m:\bind494rel/named/ns_req.c m:\bind/named/ns_req.c
*** m:\bind494rel/named/ns_req.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_req.c	Sat Jun 01 03:48:30 1996
***************
*** 58,73 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/uio.h>
! #include <sys/file.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <fcntl.h>
! #include <syslog.h>
! #include <errno.h>
  #include <stdio.h>
  #include <resolv.h>
  
--- 58,77 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/uio.h>
! #include <sys/file.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <fcntl.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <errno.h>
  #include <stdio.h>
  #include <resolv.h>
  
***************
*** 80,85 ****
--- 84,100 ----
  	u_int16_t	a_class;		/* class for address */
  };
  
+ #ifdef WINNT
+ #define _exit(x) ExitThread(x)
+ struct ntxfr {
+ 	struct qstream *qsp;
+ 	struct namebuf *np;
+ 	u_char *soa;
+ 	int soalen;
+ 	int class;
+ };
+ #endif
+ 
  enum req_action { Finish, Refuse, Return };
  
  static enum req_action	req_query __P((HEADER *hp, u_char **cpp, u_char *eom,
***************
*** 97,110 ****
--- 112,137 ----
  					u_char *msg,struct sockaddr_in *from));
  #endif
  
+ #ifndef WINNT
  static void		fwritemsg __P((FILE *, u_char *, int)),
+ #else
+ static void		fwritemsg __P((SOCKET, u_char *, int)),
+ #endif
  #ifdef DEBUG
  			printSOAdata __P((struct databuf)),
  #endif
+ #ifndef WINNT
  			doaxfr __P((struct namebuf *, FILE *,
  				    struct namebuf *, int)),
+ #else
+ 			doaxfr __P((struct namebuf *, SOCKET,
+ 				    struct namebuf *, int)),
+ #endif
  			startxfr __P((struct qstream *, struct namebuf *,
  				      u_char *, int, int, const char *));
+ #ifdef WINNT
+ static void startxfr_child __P((struct ntxfr *));
+ #endif
  
  #ifdef ALLOW_UPDATES
  static int		InitDynUpdate __P((register HEADER *hp,
***************
*** 267,279 ****
  
  #ifdef DEBUG
  #ifdef SORT_RESPONSE
! 	sortmsgtxt = local(from) == NULL ? "Remote" : "Local";
  #else /*SORT*/
! 	sortmsgtxt = "(not sorting)";
  #endif /*SORT*/
! 	dprintf(1, (ddt, "ns_req: answer -> %s fd=%d id=%d size=%d %s\n",
! 		    sin_ntoa(from), (qsp == QSTREAM_NULL) ? dfd : qsp->s_rfd,
! 		    ntohs(hp->id), cp - msg, sortmsgtxt));
  	if (debug >= 10)
  		fp_nquery(msg, cp - msg, ddt);
  #endif /*DEBUG*/
--- 294,307 ----
  
  #ifdef DEBUG
  #ifdef SORT_RESPONSE
!    	sortmsgtxt = local(from) == NULL ? "Remote" : "Local";
  #else /*SORT*/
!   	sortmsgtxt = "(not sorting)";
  #endif /*SORT*/
!   	dprintf(1, (ddt, "ns_req: answer -> %s fd=%d id=%d size=%d %s\n",
!   		    sin_ntoa(from), (qsp == QSTREAM_NULL) ? dfd : qsp->s_rfd,
!   		    ntohs((u_short)hp->id), cp - msg, sortmsgtxt));
! 
  	if (debug >= 10)
  		fp_nquery(msg, cp - msg, ddt);
  #endif /*DEBUG*/
***************
*** 461,475 ****
  	*dpp = NULL;
  
  	/* valid queries have one question and zero answers */
! 	if ((ntohs(hp->qdcount) != 1)
! 	    || ntohs(hp->ancount) != 0
! 	    || ntohs(hp->nscount) != 0
! 	    || ntohs(hp->arcount) != 0) {
  		dprintf(1, (ddt, "FORMERR Query header counts wrong\n"));
! 		hp->qdcount = htons(0);
! 		hp->ancount = htons(0);
! 		hp->nscount = htons(0);
! 		hp->arcount = htons(0);
  		hp->rcode = FORMERR;
  		return (Finish);
  	}
--- 489,503 ----
  	*dpp = NULL;
  
  	/* valid queries have one question and zero answers */
! 	if ((ntohs((u_short)  hp->qdcount) != 1)
!  	    || ntohs((u_short) hp->ancount) != 0
!  	    || ntohs((u_short) hp->nscount) != 0
!  	    || ntohs((u_short) hp->arcount) != 0) {
  		dprintf(1, (ddt, "FORMERR Query header counts wrong\n"));
!  		hp->qdcount = htons(0);
!  		hp->ancount = htons(0);
!  		hp->nscount = htons(0);
!  		hp->arcount = htons(0);
  		hp->rcode = FORMERR;
  		return (Finish);
  	}
***************
*** 552,558 ****
  
  try_again:
  	dprintf(1, (ddt, "req: nlookup(%s) id %d type=%d class=%d\n",
! 		    dname, ntohs(hp->id), type, class));
  	htp = hashtab;		/* lookup relative to root */
  	if ((anp = np = nlookup(dname, &htp, &fname, 0)) == NULL)
  		fname = "";
--- 580,586 ----
  
  try_again:
  	dprintf(1, (ddt, "req: nlookup(%s) id %d type=%d class=%d\n",
! 		    dname, ntohs((u_short)hp->id), type, class));
  	htp = hashtab;		/* lookup relative to root */
  	if ((anp = np = nlookup(dname, &htp, &fname, 0)) == NULL)
  		fname = "";
***************
*** 690,696 ****
  	*cpp += n;
  	*buflenp -= n;
  	*msglenp += n;
! 	hp->ancount = htons(ntohs(hp->ancount) + (u_int16_t)count);
  	if (fname != dname && type != T_CNAME && type != T_ANY) {
  		if (cname++ >= MAXCNAMES) {
  			dprintf(3, (ddt,
--- 718,724 ----
  	*cpp += n;
  	*buflenp -= n;
  	*msglenp += n;
! 	hp->ancount = htons((u_short)(ntohs((u_short)hp->ancount) + (u_int16_t)count));
  	if (fname != dname && type != T_CNAME && type != T_ANY) {
  		if (cname++ >= MAXCNAMES) {
  			dprintf(3, (ddt,
***************
*** 734,739 ****
--- 762,769 ----
  #endif /*BIND_NOTIFY*/
  	if (type == T_AXFR) {
  		startxfr(qsp, np, msg, *cpp - msg, class, dname);
+ #ifndef WINNT
+ #endif
  		return (Return);
  	}
  
***************
*** 780,786 ****
  				*cpp += n;
  				*buflenp -= n;
  #ifdef ADDAUTH
! 			} else if (ntohs(hp->ancount) != 0) {
  				/* don't add NS records for NOERROR NODATA
  				   as some servers can get confused */
  #ifdef DATUMREFCNT
--- 810,816 ----
  				*cpp += n;
  				*buflenp -= n;
  #ifdef ADDAUTH
! 			} else if (ntohs((u_short)hp->ancount) != 0) {
  				/* don't add NS records for NOERROR NODATA
  				   as some servers can get confused */
  #ifdef DATUMREFCNT
***************
*** 981,995 ****
  	nameserIncr(from->sin_addr, nssRcvdIQ);
  #endif
  
! 	if (ntohs(hp->ancount) != 1
! 	    || ntohs(hp->qdcount) != 0
! 	    || ntohs(hp->nscount) != 0
! 	    || ntohs(hp->arcount) != 0) {
  		dprintf(1, (ddt, "FORMERR IQuery header counts wrong\n"));
! 		hp->qdcount = htons(0);
! 		hp->ancount = htons(0);
! 		hp->nscount = htons(0);
! 		hp->arcount = htons(0);
  		hp->rcode = FORMERR;
  		return (Finish);
  	}
--- 1011,1025 ----
  	nameserIncr(from->sin_addr, nssRcvdIQ);
  #endif
  
! 	if (ntohs((u_short) hp->ancount) != 1
! 	    || ntohs((u_short) hp->qdcount) != 0
! 	    || ntohs((u_short) hp->nscount) != 0
! 	    || ntohs((u_short) hp->arcount) != 0) {
  		dprintf(1, (ddt, "FORMERR IQuery header counts wrong\n"));
!  		hp->qdcount = htons(0);
!  		hp->ancount = htons(0);
!  		hp->nscount = htons(0);
!  		hp->arcount = htons(0);
  		hp->rcode = FORMERR;
  		return (Finish);
  	}
***************
*** 1124,1139 ****
--- 1154,1181 ----
  }
  
  static void
+ #ifndef WINNT
  fwritemsg(rfp, msg, msglen)
  	FILE *rfp;
  	u_char *msg;
  	int msglen;
+ #else
+ fwritemsg(rfd, msg, msglen)
+ 	SOCKET rfd;
+ 	u_char *msg;
+ 	int msglen;
+ #endif
  {
  	u_char len[INT16SZ];
  
  	__putshort(msglen, len);
+ #ifndef WINNT
  	if (fwrite((char *)len, INT16SZ, 1, rfp) != 1 ||
  	    fwrite((char *)msg, msglen, 1, rfp) != 1) {
+ #else
+ 	if (send(rfd, len, INT16SZ, 0) != INT16SZ ||
+ 		send(rfd, msg, msglen, 0) != msglen) {
+ #endif
  		syslog(LOG_ERR, "fwritemsg: %m");
  		_exit(1);
  	}
***************
*** 1242,1248 ****
  	/* check for outdated RR before updating dnptrs by dn_comp() (?) */
  	if (zp->z_type == Z_CACHE) {
  		if ((dp->d_flags & DB_F_HINT) != 0
! 		    || dp->d_ttl < (u_int32_t)tt.tv_sec) {
  			ttl = 0;
  		} else
  			ttl = dp->d_ttl - (u_int32_t) tt.tv_sec;
--- 1284,1294 ----
  	/* check for outdated RR before updating dnptrs by dn_comp() (?) */
  	if (zp->z_type == Z_CACHE) {
  		if ((dp->d_flags & DB_F_HINT) != 0
! #ifndef WINNT
! 	        || dp->d_ttl < (u_int32_t)tt.tv_sec) {
! #else
!      		|| dp->d_ttl < (int32_t)tt.tv_sec) {
! #endif
  			ttl = 0;
  		} else
  			ttl = dp->d_ttl - (u_int32_t) tt.tv_sec;
***************
*** 1584,1590 ****
  		}
  		return (0);
  	}
! 	hp->nscount = htons(ntohs(hp->nscount) + 1);
  	return (n);
  }
  
--- 1630,1636 ----
  		}
  		return (0);
  	}
! 	hp->nscount = htons((u_short)(ntohs((u_short)hp->nscount) + 1));
  	return (n);
  }
  
***************
*** 1599,1609 ****
--- 1645,1663 ----
   * rfp is a stdio file to which output is sent.
   */
  static void
+ #ifndef WINNT
  doaxfr(np, rfp, top, class)
  	register struct namebuf *np;
  	FILE *rfp;
  	struct namebuf *top;
  	int class;		/* Class to transfer */
+ #else
+ doaxfr(np, rfd, top, class)
+ 	register struct namebuf *np;
+ 	SOCKET rfd;
+ 	struct namebuf *top;
+ 	int class;		/* Class to transfer */
+ #endif
  {
  	register struct databuf *dp;
  	register int n;
***************
*** 1647,1653 ****
--- 1701,1711 ----
  		n = make_rr(dname, dp, cp, sizeof(msg)-HFIXEDSZ, 0);
  		if (n < 0)
  			continue;
+ #ifndef WINNT
  		fwritemsg(rfp, msg, n + HFIXEDSZ);
+ #else
+ 		fwritemsg(rfd, msg, n + HFIXEDSZ);
+ #endif
  #ifdef NO_GLUE
  		if ((np != top) || (NAME(*top)[0] == '\0')) {
  #endif /*NO_GLUE*/
***************
*** 1705,1711 ****
--- 1763,1773 ----
   			n = make_rr(fname, gdp, cp, sizeof(msg)-HFIXEDSZ, 0);
  			if (n < 0)
  			    continue;
+ #ifndef WINNT
   			fwritemsg(rfp, msg, n + HFIXEDSZ);
+ #else
+  			fwritemsg(rfd, msg, n + HFIXEDSZ);
+ #endif
   		    }
  #ifdef NO_GLUE
  		}
***************
*** 1737,1743 ****
--- 1799,1809 ----
  #endif
  		if ((n = make_rr(dname, dp, cp, sizeof(msg)-HFIXEDSZ, 0)) < 0)
  			continue;
+ #ifndef WINNT
  		fwritemsg(rfp, msg, n + HFIXEDSZ);
+ #else
+ 		fwritemsg(rfd, msg, n + HFIXEDSZ);
+ #endif
  	}
  
  	/* Finally do non-delegated subdomains.  Delegated subdomains
***************
*** 1782,1788 ****
--- 1848,1858 ----
  	while (npp < nppend) {
  		for (np = *npp++; np != NULL; np = np->n_next) {
  		    if (NAME(*np)[0] != '\0') { /* don't redo root domain */
+ #ifndef WINNT
  			doaxfr(np, rfp, top, class);
+ #else
+ 			doaxfr(np, rfd, top, class);
+ #endif
  		    }
  		}
  	}
***************
*** 2021,2026 ****
--- 2091,2097 ----
  	int		class;
  	const char	*dname;
  {
+ #ifndef WINNT
  	FILE *rfp;
  	int fdstat;
  	pid_t pid;
***************
*** 2035,2043 ****
--- 2106,2121 ----
  #ifdef SO_LINGER
  	static const struct linger ll = { 1, 120 };
  #endif
+ #else /* WINNT */
+ 	HANDLE xfr_thread_handle;
+ 	struct ntxfr *xfr_child;
+ 	char *xfrbuf;
+ 	DWORD id;	
+ #endif /* WINNT */
  
  	dprintf(5, (ddt, "startxfr()\n"));
  
+ #ifndef WINNT
  	/* create a pipe to synchronize parent and child */
  	if (pipe(pipefd) != 0) {
  		sqrm(qsp);
***************
*** 2054,2116 ****
  	case -1:
  		syslog(LOG_NOTICE, "startxfr(%s -> %s) failing; fork: %m",
  		       dname, sin_ntoa(&qsp->s_from));
! 		close(pipefd[0]);
! 		close(pipefd[1]);
! 		sqrm(qsp);
  		return;
  	case 0:
  		/* child */
  		break;
  	default:
  		/* parent */
! 		close(pipefd[0]);	/* close the read end */
! 		sqrm(qsp);
! 		/* close the write end to release the child */
! 		close(pipefd[1]);
! 		syslog(LOG_DEBUG, "zone transfer of \"%s\" to %s (pid %lu)",
! 		       dname, sin_ntoa(&qsp->s_from), (u_long)pid);
  		return;
  	}
  
  	/*
  	 * Child.
  	 *
  	 * XXX:	this should be a vfork/exec since on non-copy-on-write
  	 *	systems with huge nameserver images, this is very expensive.
  	 */
  	close(vs);
  	sqflush(/*allbut*/ qsp);
  	dqflush((time_t)0);
  
! 	close(pipefd[1]);		/* close the write end */
! 	/*
! 	 * Wait for parent to close the write end of the pipe which
! 	 * we'll see as an EOF.  The parent won't close the write end
! 	 * until it has closed the fd we'll be writing to, at which
! 	 * point it will be safe for us to proceed.
!          *
! 	 * We shouldn't get interrupted, but ...
! 	 */
! 	while (read(pipefd[0], &c, 1) == -1 && errno == EINTR)
! 		; /* nothing */
! 	close(pipefd[0]);
  
  #ifdef RENICE
  	nice(-40);  nice(20);  nice(0);		/* back to "normal" */
  #endif
  	dprintf(5, (ddt, "startxfr: child pid %lu\n", (u_long)pid));
  
  	if (!(rfp = fdopen(qsp->s_rfd, "w"))) {
  		syslog(LOG_ERR, "fdopen: %m");
  		_exit(1);
  	}
  	ns_setproctitle("zone XFR to", qsp->s_rfd);
  	if (-1 == (fdstat = fcntl(qsp->s_rfd, F_GETFL, 0))) {
  		syslog(LOG_ERR, "fcntl(F_GETFL): %m");
  		_exit(1);
  	}
  	(void) fcntl(qsp->s_rfd, F_SETFL, fdstat & ~PORT_NONBLOCK);
! #ifdef HAVE_SETVBUF
  	/* some systems (DEC OSF/1, SunOS) don't initialize the stdio buffer
  	 * if all you do between fdopen() and fclose() are fwrite()'s.  even
  	 * on systems where the buffer is correctly set, it is too small.
--- 2132,2267 ----
  	case -1:
  		syslog(LOG_NOTICE, "startxfr(%s -> %s) failing; fork: %m",
  		       dname, sin_ntoa(&qsp->s_from));
!  		close(pipefd[0]);
!  		close(pipefd[1]);
!  		sqrm(qsp);
  		return;
  	case 0:
  		/* child */
  		break;
  	default:
  		/* parent */
!  		close(pipefd[0]);	/* close the read end */
!  		sqrm(qsp);
!  		/* close the write end to release the child */
!  		close(pipefd[1]);
!   		syslog(LOG_DEBUG, "zone transfer of \"%s\" to %s (pid %lu)",
!  		       dname, sin_ntoa(&qsp->s_from), (u_long)pid);
! 		return;
! 	}
! #else
! 	if ((xfr_child = (struct ntxfr *)malloc(sizeof(struct ntxfr))) == NULL) {
! 		syslog(LOG_ERR, "startxfr: malloc: %m");
! 		return;
! 	}
! 	if ((xfrbuf = (u_char *)malloc(BUFSIZ)) == NULL) {
! 		syslog(LOG_ERR, "startxfr: malloc: %m");
  		return;
  	}
+ 	xfr_child->qsp = qsp;
+ 	xfr_child->np = np;
+ 	bcopy(soa, xfrbuf, soalen);
+ 	soa[soalen+1] = '\0';
+ 	xfr_child->soa = xfrbuf;
+ 	xfr_child->soalen = soalen;
+ 	xfr_child->class = class;
+ 
+ 	xfr_thread_handle = CreateThread(NULL, 0,
+ 									(LPTHREAD_START_ROUTINE)startxfr_child,
+ 									(LPVOID)xfr_child, 0, &id);
+ 	if(xfr_thread_handle == NULL)
+ 		syslog(LOG_NOTICE, "startxfr(%s -> %s) failing; CreateThread(): %m",
+ 		       dname, sin_ntoa(&qsp->s_from));
+ 	else
+ 		/* probably should store the thread handle and/or thread id
+ 		 * and identify and kill a hung outgoing zone transfer thread
+ 		 */
+ 		syslog(LOG_DEBUG, "zone transfer of \"%s\" to %s (threadId %d)",
+ 		       dname, sin_ntoa(&qsp->s_from), id);
+         /* lgk close errant handle here so we don't get too many */
+         CloseHandle(xfr_thread_handle);
+ 	return;
+ }
+ 
+ static void
+ startxfr_child(pxfr_child)
+ 	struct ntxfr *pxfr_child;
+ {
+ 	DWORD pid;
+ #if defined(HAVE_SETVBUF) && !defined(WINNT)
+ 	char *buf;
+ #endif
+ #ifdef SO_SNDBUF
+ 	static const int sndbuf = XFER_BUFSIZE * 2;
+ #endif
+ #ifdef SO_LINGER
+ 	static const struct linger ll = { 1, 120 };
+ #endif
+ 	struct qstream	*qsp = pxfr_child->qsp;
+ 	struct namebuf	*np = pxfr_child->np;
+ 	u_char		*soa = pxfr_child->soa;
+ 	int		soalen = pxfr_child->soalen;
+ 	int		class = pxfr_child->class;
+ 	int off = 0;
  
+ 	pid = GetCurrentThreadId();
+ #endif /* WINNT */
+ 
  	/*
  	 * Child.
  	 *
  	 * XXX:	this should be a vfork/exec since on non-copy-on-write
  	 *	systems with huge nameserver images, this is very expensive.
  	 */
+ #ifndef WINNT
  	close(vs);
  	sqflush(/*allbut*/ qsp);
  	dqflush((time_t)0);
+  
+  	close(pipefd[1]);		/* close the write end */
+  	/*
+  	 * Wait for parent to close the write end of the pipe which
+  	 * we'll see as an EOF.  The parent won't close the write end
+  	 * until it has closed the fd we'll be writing to, at which
+  	 * point it will be safe for us to proceed.
+           *
+  	 * We shouldn't get interrupted, but ...
+  	 */
+  	while (read(pipefd[0], &c, 1) == -1 && errno == EINTR)
+  		; /* nothing */
+  	close(pipefd[0]);
  
! #endif
  
  #ifdef RENICE
  	nice(-40);  nice(20);  nice(0);		/* back to "normal" */
  #endif
+ #ifdef WINNT
+ 	(void) SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
+ #endif
  	dprintf(5, (ddt, "startxfr: child pid %lu\n", (u_long)pid));
  
+ #ifndef WINNT
  	if (!(rfp = fdopen(qsp->s_rfd, "w"))) {
  		syslog(LOG_ERR, "fdopen: %m");
  		_exit(1);
  	}
+ #endif
  	ns_setproctitle("zone XFR to", qsp->s_rfd);
+ #ifndef WINNT
  	if (-1 == (fdstat = fcntl(qsp->s_rfd, F_GETFL, 0))) {
  		syslog(LOG_ERR, "fcntl(F_GETFL): %m");
  		_exit(1);
  	}
  	(void) fcntl(qsp->s_rfd, F_SETFL, fdstat & ~PORT_NONBLOCK);
! #else
! 	/* set the socket to be blocking again */
! 	if(ioctlsocket(qsp->s_rfd, FIONBIO, (u_long *)&off) == SOCKET_ERROR) {
! 		syslog(LOG_INFO, "ioctlsocket(rfd, BLOCK): %m");
! 		exit(1);
! 	}
! #endif /* WINNT */
! #if defined(HAVE_SETVBUF) && !defined(WINNT)
  	/* some systems (DEC OSF/1, SunOS) don't initialize the stdio buffer
  	 * if all you do between fdopen() and fclose() are fwrite()'s.  even
  	 * on systems where the buffer is correctly set, it is too small.
***************
*** 2130,2139 ****
--- 2281,2302 ----
  	 *	when we fill a 64K DNS/AXFR "message" rather than on each RR.
  	 *	(PVM@ISI gets credit for this idea.)
  	 */
+ #ifndef WINNT
  	fwritemsg(rfp, soa, soalen);
+ #else
+ 	fwritemsg(qsp->s_rfd, soa, soalen);
+ #endif
+ #ifndef WINNT
  	doaxfr(np, rfp, np, class);
+ #else
+ 	doaxfr(np, qsp->s_rfd, np, class);
+ #endif
+ #ifndef WINNT
  	fwritemsg(rfp, soa, soalen);
  	(void) fflush(rfp);
+ #else
+ 	fwritemsg(qsp->s_rfd, soa, soalen);
+ #endif
  #ifdef SO_LINGER
  	/* kernels that map pages for IO end up failing if the pipe is full
  	 * at exit and we take away the final buffer.  this is really a kernel
***************
*** 2141,2149 ****
--- 2304,2323 ----
  	 */
  	setsockopt(qsp->s_rfd, SOL_SOCKET, SO_LINGER,
  		   (char *)&ll, sizeof ll);
+ #ifndef WINNT
  	close(qsp->s_rfd);
+ #else
+ 	sqrm(qsp);
+ #endif /* WINNT */
+ #endif /* SO_LINGER */
+ #ifdef WINNT
+ 	/* endxfer(GetCurrentThread());	*/
  #endif
+ #ifndef WINNT
  	_exit(0);
+ #else
+ 	ExitThread(0);
+ #endif
  	/* NOTREACHED */
  }
  
diff --context --recurs m:\bind494rel/named/ns_resp.c m:\bind/named/ns_resp.c
*** m:\bind494rel/named/ns_resp.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_resp.c	Thu Jun 27 19:37:30 1996
***************
*** 58,73 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <syslog.h>
! #include <errno.h>
! #include <stdio.h>
! #include <resolv.h>
  
  #include "named.h"
  
--- 58,77 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <errno.h>
! #include <stdio.h>
! #include <resolv.h>
  
  #include "named.h"
  
***************
*** 188,194 ****
  	struct databuf *nsp[NSMAX];
  	int i, c, n, qdcount, ancount, aucount, nscount, arcount;
  	int qtype, qclass, dbflags;
! 	int restart;	/* flag for processing cname response */
  	int validanswer;
  	int cname;
  	int count, founddata, foundname;
--- 192,198 ----
  	struct databuf *nsp[NSMAX];
  	int i, c, n, qdcount, ancount, aucount, nscount, arcount;
  	int qtype, qclass, dbflags;
! 	int restart; /* flag for processing cname response */
  	int validanswer;
  	int cname;
  	int count, founddata, foundname;
***************
*** 212,218 ****
  #endif
  	hp = (HEADER *) msg;
  	if ((qp = qfindid(hp->id)) == NULL ) {
! 		dprintf(1, (ddt, "DUP? dropped (id %d)\n", ntohs(hp->id)));
  		nameserIncr(from_addr.sin_addr, nssRcvdDupR);
  		return;
  	}
--- 216,222 ----
  #endif
  	hp = (HEADER *) msg;
  	if ((qp = qfindid(hp->id)) == NULL ) {
! 		dprintf(1, (ddt, "DUP? dropped (id %d)\n", ntohs( (u_short) hp->id)));
  		nameserIncr(from_addr.sin_addr, nssRcvdDupR);
  		return;
  	}
***************
*** 226,235 ****
  	/*
  	 * Here we handle high level formatting problems by parsing the header.
  	 */
! 	qdcount = ntohs(hp->qdcount);
! 	ancount = ntohs(hp->ancount);
! 	aucount = ntohs(hp->nscount);	/* !!! */
! 	arcount = ntohs(hp->arcount);
  	free_addinfo();		/* sets addcount to zero */
  	cp = msg + HFIXEDSZ;
  	dpp = dnptrs;
--- 230,239 ----
  	/*
  	 * Here we handle high level formatting problems by parsing the header.
  	 */
! 	qdcount = ntohs( (u_short) hp->qdcount);
! 	ancount = ntohs( (u_short) hp->ancount);
! 	aucount = ntohs( (u_short) hp->nscount);	/* !!! */
! 	arcount = ntohs( (u_short) hp->arcount);
  	free_addinfo();		/* sets addcount to zero */
  	cp = msg + HFIXEDSZ;
  	dpp = dnptrs;
***************
*** 506,511 ****
--- 510,516 ----
  	}
  #endif
  
+ 
  #ifdef LAME_DELEGATION
  	/*
  	 *  Non-authoritative, no answer, no error
***************
*** 723,729 ****
--- 728,736 ----
  	for (i = 0; i < count; i++) {
  		struct databuf *ns3 = NULL;
  		u_char cred;
+ #ifdef VALIDATE
  		int VCode;
+ #endif
  		u_int16_t type, class;
  
  		if (cp >= eom) {
***************
*** 814,820 ****
  			}
  		} else {
  #endif
! 		if (i < ancount) {
  			/*
  			 * If there are any non-CNAME RRs (or
  			 * CNAME RRs if they are an acceptable)
--- 821,827 ----
  			}
  		} else {
  #endif
! 		if ( i < ancount ) {
  			/*
  			 * If there are any non-CNAME RRs (or
  			 * CNAME RRs if they are an acceptable)
***************
*** 825,832 ****
  			if (type != T_CNAME || qtype == T_CNAME ||
  			    qtype == T_ANY)
  				validanswer = 1;
! 			else
! 				cname = 1;
  		}
  		n = doupdate(msg, msglen, cp, 0, &ns3, dbflags, cred);
  #ifdef VALIDATE
--- 832,839 ----
  			if (type != T_CNAME || qtype == T_CNAME ||
  			    qtype == T_ANY)
  				validanswer = 1;
!   			else
!   				cname = 1;
  		}
  		n = doupdate(msg, msglen, cp, 0, &ns3, dbflags, cred);
  #ifdef VALIDATE
***************
*** 935,941 ****
  	 * An answer to a T_ANY query or a successful answer to a
  	 * regular query with no indirection, then just return answer.
  	 */
! 	if (!restart && ancount && (qtype == T_ANY || !qp->q_cmsglen)) {
  		dprintf(3, (ddt, "resp: got as much answer as there is\n"));
  		goto return_msg;
  	}
--- 942,948 ----
  	 * An answer to a T_ANY query or a successful answer to a
  	 * regular query with no indirection, then just return answer.
  	 */
!    	if (!restart && ancount && (qtype == T_ANY || !qp->q_cmsglen)) {
  		dprintf(3, (ddt, "resp: got as much answer as there is\n"));
  		goto return_msg;
  	}
***************
*** 982,991 ****
  	 * is not cacheable (TTL==0 or unknown RR type), since all of the
  	 * answer must pass through the cache and be re-assembled.
  	 */
! 	if ((!restart || !cname) && qp->q_cmsglen && ancount) {
  		dprintf(1, (ddt, "Cname second pass\n"));
  		newmsglen = MIN(PACKETSZ, qp->q_cmsglen);
! 		bcopy(qp->q_cmsg, newmsg, newmsglen);
  	} else {
  		newmsglen = MIN(PACKETSZ, msglen);
  		bcopy(msg, newmsg, newmsglen);
--- 989,998 ----
  	 * is not cacheable (TTL==0 or unknown RR type), since all of the
  	 * answer must pass through the cache and be re-assembled.
  	 */
!   	if ((!restart || !cname) && qp->q_cmsglen && ancount) {
  		dprintf(1, (ddt, "Cname second pass\n"));
  		newmsglen = MIN(PACKETSZ, qp->q_cmsglen);
!  		bcopy(qp->q_cmsg, newmsg, newmsglen);
  	} else {
  		newmsglen = MIN(PACKETSZ, msglen);
  		bcopy(msg, newmsg, newmsglen);
***************
*** 1019,1026 ****
  	}
  	cp += n + QFIXEDSZ;
  	buflen = sizeof(newmsg) - (cp - newmsg);
- 
  	cname = 0;
   try_again:
  	dprintf(1, (ddt, "resp: nlookup(%s) qtype=%d\n", dname, qtype));
  	fname = "";
--- 1026,1033 ----
  	}
  	cp += n + QFIXEDSZ;
  	buflen = sizeof(newmsg) - (cp - newmsg);
  	cname = 0;
+ 
   try_again:
  	dprintf(1, (ddt, "resp: nlookup(%s) qtype=%d\n", dname, qtype));
  	fname = "";
***************
*** 1038,1044 ****
  		goto fetch_ns;		/* NO data available */
  	cp += n;
  	buflen -= n;
! 	hp->ancount = htons(ntohs(hp->ancount) + (u_int16_t)count);
  	if (fname != dname && qtype != T_CNAME && qtype != T_ANY) {
  		cname++;
  		goto try_again;
--- 1045,1051 ----
  		goto fetch_ns;		/* NO data available */
  	cp += n;
  	buflen -= n;
!   	hp->ancount = htons((u_short)(ntohs((u_short)hp->ancount) + (u_int16_t)count));
  	if (fname != dname && qtype != T_CNAME && qtype != T_ANY) {
  		cname++;
  		goto try_again;
***************
*** 1119,1124 ****
--- 1126,1132 ----
  		static const char freed[] = "freed", busy[] = "busy";
  		const char *result;
  
+ 
  		if (qp->q_addr[i].ns != NULL) {
  			if ((--(qp->q_addr[i].ns->d_rcnt)))
  				result = busy;
***************
*** 2522,2529 ****
  			 * used often.
  			 */
  			dp->d_ttl = tt.tv_sec
! 					+
! 				0.95 * (int) (dp->d_ttl - tt.tv_sec);
  		}
  #ifdef NCACHE
  		/* -ve $ing stuff, anant@isi.edu
--- 2530,2537 ----
  			 * used often.
  			 */
  			dp->d_ttl = tt.tv_sec
! 					+ (int) (
! 				0.95 * (int) (dp->d_ttl - tt.tv_sec));
  		}
  #ifdef NCACHE
  		/* -ve $ing stuff, anant@isi.edu
***************
*** 2740,2742 ****
--- 2748,2751 ----
  		dp = dp->d_next;
  	}
  }
+ 
diff --context --recurs m:\bind494rel/named/ns_sort.c m:\bind/named/ns_sort.c
*** m:\bind494rel/named/ns_sort.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_sort.c	Sat Jun 01 03:48:32 1996
***************
*** 58,72 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #include <syslog.h>
  #include <resolv.h>
  
  #include "named.h"
--- 58,76 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
  #include <resolv.h>
  
  #include "named.h"
diff --context --recurs m:\bind494rel/named/ns_stats.c m:\bind/named/ns_stats.c
*** m:\bind494rel/named/ns_stats.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_stats.c	Sat Jun 01 03:48:33 1996
***************
*** 63,78 ****
  /*            dumps a bunch of values into a well-known file              */
  /**************************************************************************/
  
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #include <syslog.h>
! #include <errno.h>
  
! #include "named.h"
! #include "tree.h"
  
  static u_long typestats[T_ANY+1];
  static const char *typenames[T_ANY+1] = {
--- 63,82 ----
  /*            dumps a bunch of values into a well-known file              */
  /**************************************************************************/
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <stdio.h>
! #ifndef WINNT
! #include <syslog.h>
! #endif
! #include <errno.h>
  
! #include "named.h"
! #include "tree.h"
  
  static u_long typestats[T_ANY+1];
  static const char *typenames[T_ANY+1] = {
***************
*** 246,252 ****
--- 250,260 ----
  		if (!tree_add(&nameserTree, nameserCompar, (tree_t)ns, NULL)) {
  			int save = errno;
  			free(ns);
+ #ifndef WINNT
  			errno = save;
+ #else
+ 			SetLastError(save);
+ #endif
  			goto nomem;
  		}
  	}
diff --context --recurs m:\bind494rel/named/ns_validate.c m:\bind/named/ns_validate.c
*** m:\bind494rel/named/ns_validate.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/ns_validate.c	Sat Jun 01 03:48:34 1996
***************
*** 7,21 ****
   * response to a query.
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! 
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! 
! #include <syslog.h>
  #include <errno.h>
  #include <stdio.h>
  #include <resolv.h>
--- 7,23 ----
   * response to a query.
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/file.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #ifndef WINNT
! #include <arpa/inet.h>
! #include <syslog.h>
! #endif
  #include <errno.h>
  #include <stdio.h>
  #include <resolv.h>
Only in m:\bind/named: ntif.h
diff --context --recurs m:\bind494rel/named/pathnames.h m:\bind/named/pathnames.h
*** m:\bind494rel/named/pathnames.h	Thu Jun 27 19:27:51 1996
--- m:\bind/named/pathnames.h	Thu May 23 15:47:08 1996
***************
*** 58,71 ****
   * --Copyright--
   */
  
! #ifdef _PATH_XFER
! # define _PATH_XFER_PREDEFINED	/* probably from Makefile */
  #endif
  
! #if defined (__sgi) && !defined(_SYSTYPE_SVR4) && !defined(__SYSTYPE_SVR4)
! #define	_PATH_BOOT	"/usr/etc/named.d/named.boot"
  #else
! #define	_PATH_BOOT	"/etc/named.boot"
  #endif
  
  #if defined(BSD) && BSD >= 198810
--- 58,90 ----
   * --Copyright--
   */
  
! 
! #ifdef _PATH_XFER
! # define _PATH_XFER_PREDEFINED	/* probably from Makefile */
  #endif
  
! #ifdef WINNT
! #define	_PATH_BOOT	"%windir%\\NAMED.BOOT"
! #define	_ALT_PATH_BOOT	"%windir%\\NAMED.INI"
! #ifndef _PATH_XFER
! # define _PATH_XFER	"%windir%\\SYSTEM32\\XFER.EXE"
! #endif
! #ifndef _PATH_PIDFILE
! # define _PATH_PIDFILE	"%windir%\\NAMED.PID"
! #endif
! /* following paths prepended with GetTempPath() */
! #define	_PATH_DEBUG		"NAMED.RUN" 
! #define	_PATH_DUMPFILE	"NAMDUMP.DB"
! #define	_PATH_STATS		"NAMED.STS"
! #define	_PATH_XFERTRACE	"XFER.TRC"
! #define _PATH_XFERDDT	"XFER.DDT"
! #define	_PATH_TMPXFER	"XFER.DDT.XXXXXX"
  #else
! 
! #if defined (__sgi) && !defined(_SYSTYPE_SVR4) && !defined(__SYSTYPE_SVR4)
! #define	_PATH_BOOT	"/usr/etc/named.d/named.boot"
! #else
! #define	_PATH_BOOT	"/etc/named.boot"
  #endif
  
  #if defined(BSD) && BSD >= 198810
***************
*** 120,122 ****
--- 139,143 ----
  #else
  # undef _PATH_XFER_PREDEFINED
  #endif /*_PATH_XFER_PREDEFINED*/
+ 
+ #endif /* WINNT */
Only in m:\bind/named: save.zip
diff --context --recurs m:\bind494rel/named/storage.c m:\bind/named/storage.c
*** m:\bind494rel/named/storage.c	Thu Jun 27 19:27:51 1996
--- m:\bind/named/storage.c	Sat Jun 01 03:48:35 1996
***************
*** 53,60 ****
   * --Copyright--
   */
  
! #include <sys/param.h>
! #include <syslog.h>
  
  #include "../conf/portability.h"
  #include "../conf/options.h"
--- 53,62 ----
   * --Copyright--
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <syslog.h>
! #endif
  
  #include "../conf/portability.h"
  #include "../conf/options.h"
Only in m:\bind/named: strip.bat
Only in m:\bind/named: versav.c
Only in m:\bind/named: version.c
Only in m:\bind/named: xfer.mak
Only in m:\bind/named: xfer.mdp
Only in m:\bind/named: xfer.ncb
Only in m:\bind/named: xfer.vcp
Only in m:\bind: ntbind49326_vc22.zip
Only in m:\bind: ntbind49327.zip
Only in m:\bind: ntbind49332.zip
Only in m:\bind: ntbind493rel.zip
Only in m:\bind: ntbind493relo3.zip
Only in m:\bind: ntbind493relo5.zip
Only in m:\bind: ntbind493relp2.zip
Only in m:\bind: ntbind494beta2.zip
Only in m:\bind: ntbind494t3b2.zip
Only in m:\bind: ntbind494t4a.zip
Only in m:\bind: ntbind494t4b.zip
Only in m:\bind: ntbind494t5b.zip
Only in m:\bind: ntdns49326bin_vc22.zip
Only in m:\bind: ntdns493relbin-nongui.zip
Only in m:\bind: ntdns493relbin.zip
Only in m:\bind: ntdns493relbino5.zip
Only in m:\bind: ntdns493relp2bin-nongui.zip
Only in m:\bind: ntdns493relp2bin.zip
Only in m:\bind: ntdns494beta2bin-nongui.zip
Only in m:\bind: ntdns494beta2bin.zip
Only in m:\bind: ntdns494relbin-nongui.zip
Only in m:\bind: ntdns494relbin.zip
Only in m:\bind: ntdns494t3b2bin.zip
Only in m:\bind: ntdns494t4abin-nongui.zip
Only in m:\bind: ntdns494t4abin.zip
Only in m:\bind: ntdns494t4bbin-nongui.zip
Only in m:\bind: ntdns494t4bbin.zip
Only in m:\bind: ntdns494t5bbin-nongui.zip
Only in m:\bind: ntdns494t5bbin.zip
Only in m:\bind: p2c1
Only in m:\bind: p2c2
Only in m:\bind: p2c3.gz
Only in m:\bind: p2c4
Only in m:\bind: readme.nt
Only in m:\bind/res: WinRel
diff --context --recurs m:\bind494rel/res/gethnamaddr.c m:\bind/res/gethnamaddr.c
*** m:\bind494rel/res/gethnamaddr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/gethnamaddr.c	Thu Jun 27 19:35:55 1996
***************
*** 58,75 ****
  static char rcsid[] = "$Id: gethnamaddr.c,v 8.16 1996/06/26 23:17:26 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>
  #include <errno.h>
  #include <syslog.h>
  
  #ifndef LOG_AUTH
  # define LOG_AUTH 0
--- 58,79 ----
  static char rcsid[] = "$Id: gethnamaddr.c,v 8.16 1996/06/26 23:17:26 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>	 
  #include <errno.h>
+ #ifndef WINNT
  #include <syslog.h>
+ #endif
  
  #ifndef LOG_AUTH
  # define LOG_AUTH 0
***************
*** 92,97 ****
--- 96,107 ----
  # define SPRINTF(x) sprintf x
  #endif
  
+ #ifdef WINNT
+ extern char *pathhosts;
+ extern int res_paths_initialized;
+ extern init_res_paths();
+ #endif
+ 
  #define	MAXALIASES	35
  #define	MAXADDRS	35
  
***************
*** 108,113 ****
--- 118,124 ----
  static FILE *hostf = NULL;
  static int stayopen = 0;
  
+ int inet_pton();
  static void map_v4v6_address __P((const char *src, char *dst));
  static void map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len));
  
***************
*** 131,137 ****
--- 142,150 ----
      char ac;
  } align;
  
+ #ifndef WINNT
  extern int h_errno;
+ #endif
  
  #ifdef DEBUG
  static void
***************
*** 143,149 ****
--- 156,167 ----
  		int save = errno;
  
  		printf(msg, num);
+ #ifndef WINNT
  		errno = save;
+ #else
+ 		WSASetLastError(save);
+ 		SetLastError(save);
+ #endif
  	}
  }
  #else
***************
*** 187,204 ****
  	 * find first satisfactory answer
  	 */
  	hp = &answer->hdr;
! 	ancount = ntohs(hp->ancount);
! 	qdcount = ntohs(hp->qdcount);
  	bp = hostbuf;
  	buflen = sizeof hostbuf;
  	cp = answer->buf + HFIXEDSZ;
  	if (qdcount != 1) {
  		h_errno = NO_RECOVERY;
  		return (NULL);
  	}
  	n = dn_expand(answer->buf, eom, cp, bp, buflen);
  	if ((n < 0) || !(*name_ok)(bp)) {
  		h_errno = NO_RECOVERY;
  		return (NULL);
  	}
  	cp += n + QFIXEDSZ;
--- 205,230 ----
  	 * find first satisfactory answer
  	 */
  	hp = &answer->hdr;
! 	ancount = ntohs( (u_short) hp->ancount);
! 	qdcount = ntohs( (u_short) hp->qdcount);
  	bp = hostbuf;
  	buflen = sizeof hostbuf;
  	cp = answer->buf + HFIXEDSZ;
  	if (qdcount != 1) {
+ #ifndef WINNT
  		h_errno = NO_RECOVERY;
+ #else
+ 		WSASetLastError(NO_RECOVERY);
+ #endif
  		return (NULL);
  	}
  	n = dn_expand(answer->buf, eom, cp, bp, buflen);
  	if ((n < 0) || !(*name_ok)(bp)) {
+ #ifndef WINNT
  		h_errno = NO_RECOVERY;
+ #else
+ 		WSASetLastError(NO_RECOVERY);
+ #endif
  		return (NULL);
  	}
  	cp += n + QFIXEDSZ;
***************
*** 297,303 ****
  		case T_PTR:
  			if (strcasecmp(tname, bp) != 0) {
  				syslog(LOG_NOTICE|LOG_AUTH,
! 				       AskedForGot, qname, bp);
  				cp += n;
  				continue;	/* XXX - had_error++ ? */
  			}
--- 323,329 ----
  		case T_PTR:
  			if (strcasecmp(tname, bp) != 0) {
  				syslog(LOG_NOTICE|LOG_AUTH,
! 				       (char *) AskedForGot, qname, bp);
  				cp += n;
  				continue;	/* XXX - had_error++ ? */
  			}
***************
*** 328,341 ****
  				buflen -= n;
  				map_v4v6_hostent(&host, &bp, &buflen);
  			}
! 			h_errno = NETDB_SUCCESS;
  			return (&host);
  #endif
  		case T_A:
  		case T_AAAA:
  			if (strcasecmp(host.h_name, bp) != 0) {
  				syslog(LOG_NOTICE|LOG_AUTH,
! 				       AskedForGot, host.h_name, bp);
  				cp += n;
  				continue;	/* XXX - had_error++ ? */
  			}
--- 354,371 ----
  				buflen -= n;
  				map_v4v6_hostent(&host, &bp, &buflen);
  			}
! #ifndef WINNT
!    		       h_errno = NETDB_SUCCESS;
! #else
!  		       WSASetLastError(NETDB_SUCCESS);
! #endif
  			return (&host);
  #endif
  		case T_A:
  		case T_AAAA:
  			if (strcasecmp(host.h_name, bp) != 0) {
  				syslog(LOG_NOTICE|LOG_AUTH,
! 				       (char *)AskedForGot, host.h_name, bp);
  				cp += n;
  				continue;	/* XXX - had_error++ ? */
  			}
***************
*** 401,429 ****
  		}
  		if (_res.options & RES_USE_INET6)
  			map_v4v6_hostent(&host, &bp, &buflen);
! 		h_errno = NETDB_SUCCESS;
  		return (&host);
  	}
   try_again:
  	h_errno = TRY_AGAIN;
  	return (NULL);
  }
  
  struct hostent *
- gethostbyname(name)
- 	const char *name;
- {
- 	struct hostent *hp;
- 
- 	if (_res.options & RES_USE_INET6) {
- 		hp = gethostbyname2(name, AF_INET6);
- 		if (hp)
- 			return (hp);
- 	}
- 	return (gethostbyname2(name, AF_INET));
- }
- 
- struct hostent *
  gethostbyname2(name, af)
  	const char *name;
  	int af;
--- 431,453 ----
  		}
  		if (_res.options & RES_USE_INET6)
  			map_v4v6_hostent(&host, &bp, &buflen);
! #ifndef WINNT
!    		       h_errno = NETDB_SUCCESS;
! #else
!  		       WSASetLastError(NETDB_SUCCESS);
! #endif
  		return (&host);
  	}
   try_again:
+ #ifndef WINNT
  	h_errno = TRY_AGAIN;
+ #else
+         WSASetLastError(TRY_AGAIN);
+ #endif
  	return (NULL);
  }
  
  struct hostent *
  gethostbyname2(name, af)
  	const char *name;
  	int af;
***************
*** 435,441 ****
--- 459,469 ----
  	extern struct hostent *_gethtbyname2();
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (NULL);
  	}
  
***************
*** 449,456 ****
--- 477,489 ----
  		type = T_AAAA;
  		break;
  	default:
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
  		errno = EAFNOSUPPORT;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ 		SetLastError(WSAEAFNOSUPPORT);
+ #endif
  		return (NULL);
  	}
  
***************
*** 480,486 ****
--- 513,523 ----
  				 * done a lookup.
  				 */
  				if (inet_pton(af, name, host_addr) <= 0) {
+ #ifndef WINNT
  					h_errno = HOST_NOT_FOUND;
+ #else
+                     WSASetLastError(HOST_NOT_FOUND);
+ #endif
  					return (NULL);
  				}
  				strncpy(hostbuf, name, MAXDNAME);
***************
*** 495,501 ****
  				host.h_addr_list = h_addr_ptrs;
  				if (_res.options & RES_USE_INET6)
  					map_v4v6_hostent(&host, &bp, &len);
! 				h_errno = NETDB_SUCCESS;
  				return (&host);
  			}
  			if (!isdigit(*cp) && *cp != '.') 
--- 532,542 ----
  				host.h_addr_list = h_addr_ptrs;
  				if (_res.options & RES_USE_INET6)
  					map_v4v6_hostent(&host, &bp, &len);
! #ifndef WINNT
!    		       h_errno = NETDB_SUCCESS;
! #else
!  		       WSASetLastError(NETDB_SUCCESS);
! #endif
  				return (&host);
  			}
  			if (!isdigit(*cp) && *cp != '.') 
***************
*** 512,518 ****
--- 553,581 ----
  }
  
  struct hostent *
+ #ifndef WINNT
+ gethostbyname(name)
+ #else
+ gethostbyname_nt(name)
+ #endif
+ 	const char *name;
+ {
+ 	struct hostent *hp;
+ 
+ 	if (_res.options & RES_USE_INET6) {
+ 		hp = gethostbyname2(name, AF_INET6);
+ 		if (hp)
+ 			return (hp);
+ 	}
+ 	return (gethostbyname2(name, AF_INET));
+ }
+ 
+ struct hostent *
+ #ifndef WINNT
  gethostbyaddr(addr, len, af)
+ #else
+ gethostbyaddr_nt(addr, len, af)
+ #endif
  	const char *addr;	/* XXX should have been def'd as u_char! */
  	int len, af;
  {
***************
*** 529,539 ****
  	u_long old_options;
  	char hname2[MAXDNAME+1];
  #endif /*SUNSECURITY*/
! 	extern struct hostent *_gethtbyaddr();
  	
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
  		h_errno = NETDB_INTERNAL;
! 		return (NULL);
  	}
  	if (af == AF_INET6 && len == IN6ADDRSZ &&
  	    (!bcmp(uaddr, mapped, sizeof mapped) ||
--- 592,606 ----
  	u_long old_options;
  	char hname2[MAXDNAME+1];
  #endif /*SUNSECURITY*/
! extern struct hostent *_gethtbyaddr();
  	
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
! #else
! 		WSASetLastError(NETDB_INTERNAL);
! #endif
! 		return (0);
  	}
  	if (af == AF_INET6 && len == IN6ADDRSZ &&
  	    (!bcmp(uaddr, mapped, sizeof mapped) ||
***************
*** 552,565 ****
  		size = IN6ADDRSZ;
  		break;
  	default:
  		errno = EAFNOSUPPORT;
  		h_errno = NETDB_INTERNAL;
! 		return (NULL);
  	}
  	if (size != len) {
  		errno = EINVAL;
  		h_errno = NETDB_INTERNAL;
! 		return (NULL);
  	}
  	switch (af) {
  	case AF_INET:
--- 619,642 ----
  		size = IN6ADDRSZ;
  		break;
  	default:
+ #ifndef WINNT
  		errno = EAFNOSUPPORT;
  		h_errno = NETDB_INTERNAL;
! #else
!  		SetLastError(WSAEAFNOSUPPORT);
! 		WSASetLastError(NETDB_INTERNAL);
! #endif
! 		return (0);
  	}
  	if (size != len) {
+ #ifndef WINNT
  		errno = EINVAL;
  		h_errno = NETDB_INTERNAL;
! #else
!  		SetLastError(WSAEINVAL);
! 		WSASetLastError(NETDB_INTERNAL);
! #endif
! 		return (0);
  	}
  	switch (af) {
  	case AF_INET:
***************
*** 586,595 ****
  		dprintf("res_query failed (%d)\n", n);
  		if (errno == ECONNREFUSED)
  			return (_gethtbyaddr(addr, len, af));
! 		return (NULL);
  	}
  	if (!(hp = getanswer(&buf, n, qbuf, T_PTR)))
! 		return (NULL);	/* h_errno was set by getanswer() */
  #ifdef SUNSECURITY
  	if (af == AF_INET) {
  	    /*
--- 663,672 ----
  		dprintf("res_query failed (%d)\n", n);
  		if (errno == ECONNREFUSED)
  			return (_gethtbyaddr(addr, len, af));
! 		return (0);
  	}
  	if (!(hp = getanswer(&buf, n, qbuf, T_PTR)))
! 		return (0);	/* h_errno was set by getanswer() */
  #ifdef SUNSECURITY
  	if (af == AF_INET) {
  	    /*
***************
*** 601,612 ****
  	    old_options = _res.options;
  	    _res.options &= ~RES_DNSRCH;
  	    _res.options |= RES_DEFNAMES;
! 	    if (!(rhp = gethostbyname(hname2))) {
  		syslog(LOG_NOTICE|LOG_AUTH,
  		       "gethostbyaddr: No A record for %s (verifying [%s])",
  		       hname2, inet_ntoa(*((struct in_addr *)addr)));
  		_res.options = old_options;
! 		h_errno = HOST_NOT_FOUND;
  		return (NULL);
  	    }
  	    _res.options = old_options;
--- 678,693 ----
  	    old_options = _res.options;
  	    _res.options &= ~RES_DNSRCH;
  	    _res.options |= RES_DEFNAMES;
! 	    if (!(rhp = gethostbyname_nt(hname2))) {
  		syslog(LOG_NOTICE|LOG_AUTH,
  		       "gethostbyaddr: No A record for %s (verifying [%s])",
  		       hname2, inet_ntoa(*((struct in_addr *)addr)));
  		_res.options = old_options;
! #ifndef WINNT
! 					h_errno = HOST_NOT_FOUND;
! #else
!                     WSASetLastError(HOST_NOT_FOUND);
! #endif
  		return (NULL);
  	    }
  	    _res.options = old_options;
***************
*** 617,623 ****
  		syslog(LOG_NOTICE|LOG_AUTH,
  		       "gethostbyaddr: A record of %s != PTR record [%s]",
  		       hname2, inet_ntoa(*((struct in_addr *)addr)));
! 		h_errno = HOST_NOT_FOUND;
  		return (NULL);
  	    }
  	}
--- 698,708 ----
  		syslog(LOG_NOTICE|LOG_AUTH,
  		       "gethostbyaddr: A record of %s != PTR record [%s]",
  		       hname2, inet_ntoa(*((struct in_addr *)addr)));
! #ifndef WINNT
! 					h_errno = HOST_NOT_FOUND;
! #else
!                     WSASetLastError(HOST_NOT_FOUND);
! #endif
  		return (NULL);
  	    }
  	}
***************
*** 632,638 ****
  		hp->h_addrtype = AF_INET6;
  		hp->h_length = IN6ADDRSZ;
  	}
! 	h_errno = NETDB_SUCCESS;
  	return (hp);
  }
  
--- 717,727 ----
  		hp->h_addrtype = AF_INET6;
  		hp->h_length = IN6ADDRSZ;
  	}
! #ifndef WINNT
!    		       h_errno = NETDB_SUCCESS;
! #else
!  		       WSASetLastError(NETDB_SUCCESS);
! #endif
  	return (hp);
  }
  
***************
*** 640,647 ****
--- 729,746 ----
  _sethtent(f)
  	int f;
  {
+     
+ #ifndef WINNT
  	if (!hostf)
  		hostf = fopen(_PATH_HOSTS, "r" );
+ #else
+         if (!res_paths_initialized)
+           init_res_paths();
+ 
+ 	if (!hostf)
+ 		hostf = fopen(pathhosts, "r" );
+ #endif
+ 
  	else
  		rewind(hostf);
  	stayopen = f;
***************
*** 663,675 ****
  	register char *cp, **q;
  	int af, len;
  
! 	if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
  		h_errno = NETDB_INTERNAL;
  		return (NULL);
  	}
   again:
  	if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
! 		h_errno = HOST_NOT_FOUND;
  		return (NULL);
  	}
  	if (*p == '#')
--- 762,790 ----
  	register char *cp, **q;
  	int af, len;
  
! #ifndef WINNT
!  	if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
! #else
!         if (!res_paths_initialized)
!            init_res_paths();
!  
!  	if (!hostf && !(hostf = fopen(pathhosts, "r" ))) {
! #endif
!  
! #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (NULL);
  	}
   again:
  	if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
! #ifndef WINNT
! 					h_errno = HOST_NOT_FOUND;
! #else
!                     WSASetLastError(HOST_NOT_FOUND);
! #endif
  		return (NULL);
  	}
  	if (*p == '#')
***************
*** 724,730 ****
  
  		map_v4v6_hostent(&host, &bp, &buflen);
  	}
! 	h_errno = NETDB_SUCCESS;
  	return (&host);
  }
  
--- 839,849 ----
  
  		map_v4v6_hostent(&host, &bp, &buflen);
  	}
! #ifndef WINNT
!    		       h_errno = NETDB_SUCCESS;
! #else
!  		       WSASetLastError(NETDB_SUCCESS);
! #endif
  	return (&host);
  }
  
diff --context --recurs m:\bind494rel/res/getnetbyaddr.c m:\bind/res/getnetbyaddr.c
*** m:\bind494rel/res/getnetbyaddr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/getnetbyaddr.c	Fri May 24 05:18:34 1996
***************
*** 37,42 ****
--- 37,45 ----
  #endif /* LIBC_SCCS and not lint */
  
  #include <netdb.h>
+ #ifdef WINNT
+ #include "../conf/portability.h"
+ #endif
  
  extern int _net_stayopen;
  
diff --context --recurs m:\bind494rel/res/getnetbyname.c m:\bind/res/getnetbyname.c
*** m:\bind494rel/res/getnetbyname.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/getnetbyname.c	Fri May 24 05:18:34 1996
***************
*** 39,44 ****
--- 39,47 ----
  
  #include <netdb.h>
  #include <string.h>
+ #ifdef WINNT
+ #include "../conf/portability.h"
+ #endif
  
  extern int _net_stayopen;
  
diff --context --recurs m:\bind494rel/res/getnetent.c m:\bind/res/getnetent.c
*** m:\bind494rel/res/getnetent.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/getnetent.c	Fri May 24 05:18:36 1996
***************
*** 46,66 ****
  static char rcsid[] = "$Id: getnetent.c,v 8.2 1996/03/03 17:43:14 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <string.h>
  
  #ifndef _PATH_NETWORKS 
  #define _PATH_NETWORKS  "/etc/networks"
  #endif
  
  #define	MAXALIASES	35
  
  static FILE *netf;
--- 46,76 ----
  static char rcsid[] = "$Id: getnetent.c,v 8.2 1996/03/03 17:43:14 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <string.h>
! #ifdef WINNT
! #include "../conf/portability.h"
! extern char *pathnetworks;
! extern int res_paths_initialized;
! extern init_res_paths();
! #endif
  
  #ifndef _PATH_NETWORKS 
  #define _PATH_NETWORKS  "/etc/networks"
  #endif
  
+ 
+ 
  #define	MAXALIASES	35
  
  static FILE *netf;
***************
*** 94,101 ****
--- 104,119 ----
  	int f;
  {
  
+ #ifndef WINNT
  	if (netf == NULL)
  		netf = fopen(_PATH_NETWORKS, "r" );
+ #else
+        if (!res_paths_initialized)
+          init_res_paths();
+ 
+ 	if (netf == NULL)
+ 		netf = fopen(pathnetworks, "r" );
+ #endif
  	else
  		rewind(netf);
  	_net_stayopen |= f;
***************
*** 118,124 ****
--- 136,150 ----
  	char *p;
  	register char *cp, **q;
  
+ #ifndef WINNT
  	if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL)
+ #else
+        if (!res_paths_initialized)
+          init_res_paths();
+ 
+ 	if (netf == NULL && (netf = fopen(pathnetworks, "r" )) == NULL)
+ #endif
+ 
  		return (NULL);
  again:
  	p = fgets(line, BUFSIZ, netf);
diff --context --recurs m:\bind494rel/res/getnetnamadr.c m:\bind/res/getnetnamadr.c
*** m:\bind494rel/res/getnetnamadr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/getnetnamadr.c	Fri May 24 05:18:36 1996
***************
*** 44,69 ****
  static char rcsid[] = "$Id: getnetnamadr.c,v 8.6 1996/05/17 09:10:52 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>
  #include <errno.h>
  #include <string.h>
  
  extern int h_errno;
  
  #if defined(mips) && defined(SYSTYPE_BSD43)
  extern int errno;
  #endif
  
! struct netent *_getnetbyaddr __P((long net, int type));
  struct netent *_getnetbyname __P((const char *name));
  
  #define BYADDR 0
--- 44,75 ----
  static char rcsid[] = "$Id: getnetnamadr.c,v 8.6 1996/05/17 09:10:52 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>
  #include <errno.h>
  #include <string.h>
  
+ #ifndef WINNT
  extern int h_errno;
+ #else
+ #include "../conf/portability.h"
+ #endif
  
  #if defined(mips) && defined(SYSTYPE_BSD43)
  extern int errno;
  #endif
  
! struct netent *_getnetbyaddr __P((u_long net, int type));
  struct netent *_getnetbyname __P((const char *name));
  
  #define BYADDR 0
***************
*** 119,134 ****
  	 */
  	eom = answer->buf + anslen;
  	hp = &answer->hdr;
! 	ancount = ntohs(hp->ancount); /* #/records in the answer section */
! 	qdcount = ntohs(hp->qdcount); /* #/entries in the question section */
  	bp = netbuf;
  	buflen = sizeof(netbuf);
  	cp = answer->buf + HFIXEDSZ;
  	if (!qdcount) {
  		if (hp->aa)
  			h_errno = HOST_NOT_FOUND;
  		else
  			h_errno = TRY_AGAIN;
  		return (NULL);
  	}
  	while (qdcount-- > 0)
--- 125,148 ----
  	 */
  	eom = answer->buf + anslen;
  	hp = &answer->hdr;
! 	ancount = ntohs( (u_short) hp->ancount); /* #/records in the answer section */
! 	qdcount = ntohs( (u_short) hp->qdcount); /* #/entries in the question section */
  	bp = netbuf;
  	buflen = sizeof(netbuf);
  	cp = answer->buf + HFIXEDSZ;
  	if (!qdcount) {
  		if (hp->aa)
+ #ifndef WINNT
  			h_errno = HOST_NOT_FOUND;
+ #else
+ 			WSASetLastError(HOST_NOT_FOUND);
+ #endif
  		else
+ #ifndef WINNT
  			h_errno = TRY_AGAIN;
+ #else
+ 			WSASetLastError(HOST_NOT_FOUND);
+ #endif
  		return (NULL);
  	}
  	while (qdcount-- > 0)
***************
*** 196,202 ****
--- 210,220 ----
  		net_entry.n_aliases++;
  		return (&net_entry);
  	}
+ #ifndef WINNT
  	h_errno = TRY_AGAIN;
+ #else
+ 	WSASetLastError(TRY_AGAIN);
+ #endif
  	return (NULL);
  }
  
***************
*** 266,272 ****
--- 284,294 ----
  	struct netent *net_entry;
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (NULL);
  	}
  	strcpy(&qbuf[0], net);
diff --context --recurs m:\bind494rel/res/herror.c m:\bind/res/herror.c
*** m:\bind494rel/res/herror.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/herror.c	Fri May 24 05:18:38 1996
***************
*** 58,72 ****
  static char rcsid[] = "$Id: herror.c,v 8.2 1995/06/19 08:35:01 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/uio.h>
! #include <netdb.h>
! #if defined(BSD) && (BSD >= 199103)
! # include <unistd.h>
! # include <string.h>
! #else
! # include "../conf/portability.h"
! #endif
  
  const char *h_errlist[] = {
  	"Resolver Error 0 (no error)",
--- 58,74 ----
  static char rcsid[] = "$Id: herror.c,v 8.2 1995/06/19 08:35:01 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/uio.h>
! #endif
! #include <netdb.h>
! #if defined(BSD) && (BSD >= 199103)
! # include <unistd.h>
! # include <string.h>
! #else
! # include "../conf/portability.h"
! #endif
  
  const char *h_errlist[] = {
  	"Resolver Error 0 (no error)",
***************
*** 77,83 ****
--- 79,87 ----
  };
  int	h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
  
+ #ifndef WINNT
  extern int	h_errno;
+ #endif
  
  /*
   * herror --
***************
*** 89,94 ****
--- 93,101 ----
  {
  	struct iovec iov[4];
  	register struct iovec *v = iov;
+ #ifdef WINNT
+ 	char err[50];
+ #endif
  
  	if (s && *s) {
  		v->iov_base = (char *)s;
***************
*** 98,104 ****
--- 105,117 ----
  		v->iov_len = 2;
  		v++;
  	}
+ #ifndef WINNT
  	v->iov_base = (char *)hstrerror(h_errno);
+ #else
+ 	/* XXX - map the error number to the corresponding message here */
+ 	sprintf(err, "%d", h_errno);
+ 	v->iov_base = err;
+ #endif
  	v->iov_len = strlen(v->iov_base);
  	v++;
  	v->iov_base = "\n";
***************
*** 106,111 ****
--- 119,125 ----
  	writev(STDERR_FILENO, iov, (v - iov) + 1);
  }
  
+ #ifndef WINNT
  const char *
  hstrerror(err)
  	int err;
***************
*** 116,118 ****
--- 130,133 ----
  		return (h_errlist[err]);
  	return ("Unknown resolver error");
  }
+ #endif
diff --context --recurs m:\bind494rel/res/hostnamelen.c m:\bind/res/hostnamelen.c
*** m:\bind494rel/res/hostnamelen.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/hostnamelen.c	Fri May 24 05:18:38 1996
***************
*** 57,65 ****
  static char rcsid[] = "$Id: hostnamelen.c,v 8.2 1995/08/22 05:01:47 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <netinet/in.h>
  #include <arpa/nameser.h>
  #include <resolv.h>
  
--- 57,68 ----
  static char rcsid[] = "$Id: hostnamelen.c,v 8.2 1995/08/22 05:01:47 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <netinet/in.h>
! #endif
! 
  #include <arpa/nameser.h>
  #include <resolv.h>
  
diff --context --recurs m:\bind494rel/res/inet_addr.c m:\bind/res/inet_addr.c
*** m:\bind494rel/res/inet_addr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/inet_addr.c	Fri May 24 03:02:10 1996
***************
*** 58,73 ****
  static char rcsid[] = "$Id: inet_addr.c,v 8.4 1995/08/21 01:27:23 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <ctype.h>
! #include "../conf/portability.h"
  
- /* these are compatibility routines, not needed on recent BSD releases */
  
! /*
!  * Ascii internet address interpretation routine.
   * The value returned is in network order.
   */
  u_long
--- 58,79 ----
  static char rcsid[] = "$Id: inet_addr.c,v 8.4 1995/08/21 01:27:23 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <ctype.h>
! #include "../conf/portability.h"
  
  
! #ifndef NEED_INETADDR
! int __inet_addr_unneeded__;
! #else
! /* these are compatibility routines, not needed on recent BSD releases */
! 
! /*
!  * Ascii internet address interpretation routine.
   * The value returned is in network order.
   */
  u_long
***************
*** 80,85 ****
--- 86,92 ----
  		return (val.s_addr);
  	return (INADDR_NONE);
  }
+ #endif  /* NEED_INETADDR */
  
  /* 
   * Check whether "cp" is a valid ascii representation
diff --context --recurs m:\bind494rel/res/inet_ntop.c m:\bind/res/inet_ntop.c
*** m:\bind494rel/res/inet_ntop.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/inet_ntop.c	Fri May 24 05:31:02 1996
***************
*** 18,33 ****
  static char rcsid[] = "$Id: inet_ntop.c,v 8.5 1996/05/22 04:56:30 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <string.h>
! #include <errno.h>
! #include <stdio.h>
! #include "../conf/portability.h"
  
  #ifdef SPRINTF_CHAR
  # define SPRINTF(x) strlen(sprintf/**/x)
--- 18,35 ----
  static char rcsid[] = "$Id: inet_ntop.c,v 8.5 1996/05/22 04:56:30 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <string.h>
! #include <errno.h>
! #include <stdio.h>
! #include "../conf/portability.h"
  
  #ifdef SPRINTF_CHAR
  # define SPRINTF(x) strlen(sprintf/**/x)
***************
*** 64,70 ****
--- 66,77 ----
  	case AF_INET6:
  		return (inet_ntop6(src, dst, size));
  	default:
+ #ifndef WINNT
  		errno = EAFNOSUPPORT;
+ #else
+ 		SetLastError(WSAEAFNOSUPPORT);
+ 		WSASetLastError(WSAEAFNOSUPPORT);
+ #endif
  		return (NULL);
  	}
  	/* NOTREACHED */
***************
*** 90,97 ****
  	static const char fmt[] = "%u.%u.%u.%u";
  	char tmp[sizeof "255.255.255.255"];
  
! 	if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
  		errno = ENOSPC;
  		return (NULL);
  	}
  	strcpy(dst, tmp);
--- 97,109 ----
  	static const char fmt[] = "%u.%u.%u.%u";
  	char tmp[sizeof "255.255.255.255"];
  
! 	if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > (int)size) {
! #ifndef WINNT
  		errno = ENOSPC;
+ #else
+ 		SetLastError(ENOSPC);
+ 		WSASetLastError(ENOSPC);
+ #endif
  		return (NULL);
  	}
  	strcpy(dst, tmp);
***************
*** 186,193 ****
  	/*
  	 * Check for overflow, copy, and we're done.
  	 */
! 	if ((tp - tmp) > size) {
  		errno = ENOSPC;
  		return (NULL);
  	}
  	strcpy(dst, tmp);
--- 198,210 ----
  	/*
  	 * Check for overflow, copy, and we're done.
  	 */
! 	if ((tp - tmp) > (int)size) {
! #ifndef WINNT
  		errno = ENOSPC;
+ #else
+ 		SetLastError(ENOSPC);
+ 		WSASetLastError(ENOSPC);
+ #endif
  		return (NULL);
  	}
  	strcpy(dst, tmp);
diff --context --recurs m:\bind494rel/res/inet_pton.c m:\bind/res/inet_pton.c
*** m:\bind494rel/res/inet_pton.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/inet_pton.c	Thu Jun 27 19:36:04 1996
***************
*** 18,32 ****
  static char rcsid[] = "$Id: inet_pton.c,v 8.6 1996/06/26 23:17:26 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <string.h>
! #include <errno.h>
! #include "../conf/portability.h"
  
  /*
   * WARNING: Don't even consider trying to compile this on a system where
--- 18,34 ----
  static char rcsid[] = "$Id: inet_pton.c,v 8.6 1996/06/26 23:17:26 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! #include <string.h>
! #include <errno.h>
! #include "../conf/portability.h"
  
  /*
   * WARNING: Don't even consider trying to compile this on a system where
***************
*** 59,65 ****
--- 61,71 ----
  	case AF_INET6:
  		return (inet_pton6(src, dst));
  	default:
+ #ifndef WINNT
  		errno = EAFNOSUPPORT;
+ #else
+         SetLastError(WSAEAFNOSUPPORT);
+ #endif
  		return (-1);
  	}
  	/* NOTREACHED */
diff --context --recurs m:\bind494rel/res/nsap_addr.c m:\bind/res/nsap_addr.c
*** m:\bind494rel/res/nsap_addr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/nsap_addr.c	Fri May 24 05:18:42 1996
***************
*** 2,17 ****
  static char rcsid[] = "$Id: nsap_addr.c,v 8.2 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <ctype.h>
! #include <resolv.h>
  
! #include "../conf/portability.h"
  
! #if !defined(isxdigit)	/* XXX - could be a function */
  static int
  isxdigit(c)
  	register int c;
--- 2,19 ----
  static char rcsid[] = "$Id: nsap_addr.c,v 8.2 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <ctype.h>
! #include <resolv.h>
  
! #include "../conf/portability.h"
  
! #if !defined(isxdigit)	/* XXX - could be a function */
  static int
  isxdigit(c)
  	register int c;
***************
*** 31,37 ****
  inet_nsap_addr(ascii, binary, maxlen)
  	const char *ascii;
  	u_char *binary;
! 	int maxlen;
  {
  	register u_char c, nib;
  	u_int len = 0;
--- 33,39 ----
  inet_nsap_addr(ascii, binary, maxlen)
  	const char *ascii;
  	u_char *binary;
! 	u_int maxlen;
  {
  	register u_char c, nib;
  	u_int len = 0;
diff --context --recurs m:\bind494rel/res/res_comp.c m:\bind/res/res_comp.c
*** m:\bind494rel/res/res_comp.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_comp.c	Fri May 24 05:18:42 1996
***************
*** 58,65 ****
  static char rcsid[] = "$Id: res_comp.c,v 8.7 1996/05/20 15:10:03 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <netinet/in.h>
  #include <arpa/nameser.h>
  
  #include <stdio.h>
--- 58,67 ----
  static char rcsid[] = "$Id: res_comp.c,v 8.7 1996/05/20 15:10:03 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
  #include <arpa/nameser.h>
  
  #include <stdio.h>
diff --context --recurs m:\bind494rel/res/res_data.c m:\bind/res/res_data.c
*** m:\bind494rel/res/res_data.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_data.c	Fri May 24 05:18:44 1996
***************
*** 57,66 ****
  static char rcsid[] = "$Id: res_data.c,v 8.1 1995/12/22 10:21:29 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/time.h>
! #include <netinet/in.h>
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  
--- 57,68 ----
  static char rcsid[] = "$Id: res_data.c,v 8.1 1995/12/22 10:21:29 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/time.h>
! #include <netinet/in.h>
! #endif /* WINNT */
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  
diff --context --recurs m:\bind494rel/res/res_debug.c m:\bind/res/res_debug.c
*** m:\bind494rel/res/res_debug.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_debug.c	Sat Jun 08 01:48:41 1996
***************
*** 58,86 ****
  static char rcsid[] = "$Id: res_debug.c,v 8.11 1996/06/02 08:20:40 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
  #if defined(BSD) && (BSD >= 199103) && defined(AF_INET6)
  # include <string.h>
  #else
! # include "../conf/portability.h"
  #endif
  
  #if defined(USE_OPTIONS_H)
! # include "../conf/options.h"
  #endif
  
  extern const char *_res_opcodes[];
  extern const char *_res_resultcodes[];
  
  /* XXX: we should use getservbyport() instead. */
  static const char *
  dewks(wks)
--- 58,91 ----
  static char rcsid[] = "$Id: res_debug.c,v 8.11 1996/06/02 08:20:40 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
  #if defined(BSD) && (BSD >= 199103) && defined(AF_INET6)
  # include <string.h>
  #else
! #include "../conf/portability.h"
  #endif
  
  #if defined(USE_OPTIONS_H)
! #include "../conf/options.h"
  #endif
  
  extern const char *_res_opcodes[];
  extern const char *_res_resultcodes[];
+ char * inet_nsap_ntoa();
+ const char * inet_ntop();
  
+ 
  /* XXX: we should use getservbyport() instead. */
  static const char *
  dewks(wks)
***************
*** 177,183 ****
  	 * Print answer records.
  	 */
  	sflag = (_res.pfcode & pflag);
! 	if (n = ntohs(cnt)) {
  		if ((!_res.pfcode) ||
  		    ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
  			fprintf(file, hs);
--- 182,188 ----
  	 * Print answer records.
  	 */
  	sflag = (_res.pfcode & pflag);
! 	if (n = ntohs( (u_short) cnt)) {
  		if ((!_res.pfcode) ||
  		    ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
  			fprintf(file, hs);
***************
*** 273,279 ****
  		fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
  			_res_opcodes[hp->opcode],
  			_res_resultcodes[hp->rcode],
! 			ntohs(hp->id));
  		putc('\n', file);
  	}
  	if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
--- 278,284 ----
  		fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
  			_res_opcodes[hp->opcode],
  			_res_resultcodes[hp->rcode],
! 			ntohs( (u_short) hp->id));
  		putc('\n', file);
  	}
  	if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
***************
*** 292,301 ****
  			fprintf(file, " ra");
  	}
  	if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
! 		fprintf(file, "; Ques: %d", ntohs(hp->qdcount));
! 		fprintf(file, ", Ans: %d", ntohs(hp->ancount));
! 		fprintf(file, ", Auth: %d", ntohs(hp->nscount));
! 		fprintf(file, ", Addit: %d", ntohs(hp->arcount));
  	}
  	if ((!_res.pfcode) || (_res.pfcode & 
  		(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
--- 297,306 ----
  			fprintf(file, " ra");
  	}
  	if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
! 		fprintf(file, "; Ques: %d", ntohs( (u_short) hp->qdcount));
! 		fprintf(file, ", Ans: %d", ntohs( (u_short) hp->ancount));
! 		fprintf(file, ", Auth: %d", ntohs( (u_short) hp->nscount));
! 		fprintf(file, ", Addit: %d", ntohs( (u_short) hp->arcount));
  	}
  	if ((!_res.pfcode) || (_res.pfcode & 
  		(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
***************
*** 304,310 ****
  	/*
  	 * Print question records.
  	 */
! 	if (n = ntohs(hp->qdcount)) {
  		if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
  			fprintf(file, ";; QUESTIONS:\n");
  		while (--n >= 0) {
--- 309,315 ----
  	/*
  	 * Print question records.
  	 */
! 	if (n = ntohs( (u_short) hp->qdcount)) {
  		if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
  			fprintf(file, ";; QUESTIONS:\n");
  		while (--n >= 0) {
***************
*** 441,447 ****
--- 446,456 ----
  	int lcnt;
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (NULL);
  	}
  	if ((cp = p_fqname(cp, msg, file)) == NULL)
***************
*** 1161,1167 ****
  	longval = (templ - ((unsigned)1<<31));
  
  	GETLONG(templ, cp);
! 	if (templ < referencealt) { /* below WGS 84 spheroid */
  		altval = referencealt - templ;
  		altsign = -1;
  	} else {
--- 1170,1176 ----
  	longval = (templ - ((unsigned)1<<31));
  
  	GETLONG(templ, cp);
! 	if (templ < (u_int32_t)referencealt) { /* below WGS 84 spheroid */
  		altval = referencealt - templ;
  		altsign = -1;
  	} else {
diff --context --recurs m:\bind494rel/res/res_init.c m:\bind/res/res_init.c
*** m:\bind494rel/res/res_init.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_init.c	Fri May 24 05:18:44 1996
***************
*** 58,81 ****
  static char rcsid[] = "$Id: res_init.c,v 8.4 1996/05/21 07:04:36 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/time.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! 
! #include <stdio.h>
! #include <ctype.h>
! #include <resolv.h>
  #if defined(BSD) && (BSD >= 199103)
  # include <unistd.h>
  # include <stdlib.h>
  # include <string.h>
  #else
! # include "../conf/portability.h"
  #endif
  
  /*-------------------------------------- info about "sortlist" --------------
   * Marc Majka		1994/04/16
   * Allan Nathanson	1994/10/29 (BIND 4.9.3.x)
--- 58,91 ----
  static char rcsid[] = "$Id: res_init.c,v 8.4 1996/05/21 07:04:36 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <sys/time.h>
! #include <netinet/in.h>
! #endif /* WINNT */
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
! 
! #include <stdio.h>
! #include <ctype.h>
! #include <resolv.h>
  #if defined(BSD) && (BSD >= 199103)
  # include <unistd.h>
  # include <stdlib.h>
  # include <string.h>
  #else
! #include "../conf/portability.h"
  #endif
  
+ #ifdef WINNT
+ #include <netdb.h>
+ #include "../conf/portability.h"
+ extern char *pathresconf;
+ extern int res_paths_initialized;
+ extern init_res_paths();
+ #endif
+ 
  /*-------------------------------------- info about "sortlist" --------------
   * Marc Majka		1994/04/16
   * Allan Nathanson	1994/10/29 (BIND 4.9.3.x)
***************
*** 166,171 ****
--- 176,193 ----
  	int dots;
  #endif
  
+ 
+ #ifdef WINNT
+  	WORD wVersionRequested;
+ 	WSADATA wsaData;
+ 
+ 	wVersionRequested = MAKEWORD(1,1);
+ 	if (WSAStartup(wVersionRequested, &wsaData)) {
+ 		syslog(LOG_ERR, "No useable winsock.dll: %m");
+ 		return (-1);
+ 	}
+ #endif /* WINNT */
+ 
  	/*
  	 * These three fields used to be statically initialized.  This made
  	 * it hard to use this code in a shared library.  It is necessary,
***************
*** 252,258 ****
--- 274,288 ----
  #ifdef	NeXT
  	if (netinfo_res_init(&haveenv, &havesearch) == 0)
  #endif
+ #ifndef WINNT
  	if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+ #else
+        if (!res_paths_initialized)
+          init_res_paths();
+ 
+ 	if ((fp = fopen(pathresconf, "r")) != NULL) {
+ 
+ #endif
  	    /* read the config file */
  	    while (fgets(buf, sizeof(buf), fp) != NULL) {
  		/* skip comments */
diff --context --recurs m:\bind494rel/res/res_mkquery.c m:\bind/res/res_mkquery.c
*** m:\bind494rel/res/res_mkquery.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_mkquery.c	Fri May 24 05:18:46 1996
***************
*** 58,73 ****
  static char rcsid[] = "$Id: res_mkquery.c,v 8.3 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #if defined(BSD) && (BSD >= 199103)
! # include <string.h>
! #else
  # include "../conf/portability.h"
  #endif
  
--- 58,75 ----
  static char rcsid[] = "$Id: res_mkquery.c,v 8.3 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #if defined(BSD) && (BSD >= 199103)
! # include <string.h>
! #else
  # include "../conf/portability.h"
  #endif
  
***************
*** 99,105 ****
--- 101,111 ----
  	u_char *dnptrs[20], **dpp, **lastdnptr;
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (-1);
  	}
  #ifdef DEBUG
Only in m:\bind/res: res_nt_misc.c
diff --context --recurs m:\bind494rel/res/res_query.c m:\bind/res/res_query.c
*** m:\bind494rel/res/res_query.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_query.c	Fri May 24 05:18:48 1996
***************
*** 58,73 ****
  static char rcsid[] = "$Id: res_query.c,v 8.6 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>
! #include <errno.h>
  #if defined(BSD) && (BSD >= 199306)
  # include <stdlib.h>
  # include <string.h>
--- 58,75 ----
  static char rcsid[] = "$Id: res_query.c,v 8.6 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <netdb.h>
! #include <resolv.h>
! #include <ctype.h>
! #include <errno.h>
  #if defined(BSD) && (BSD >= 199306)
  # include <stdlib.h>
  # include <string.h>
***************
*** 86,92 ****
--- 88,96 ----
  #endif
  
  char *__hostalias __P((const char *));
+ #ifndef WINNT
  int h_errno;
+ #endif
  
  /*
   * Formulate a normal query, send, and await answer.
***************
*** 112,118 ****
--- 116,126 ----
  	hp->rcode = NOERROR;	/* default */
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (-1);
  	}
  #ifdef DEBUG
***************
*** 127,133 ****
--- 135,145 ----
  		if (_res.options & RES_DEBUG)
  			printf(";; res_query: mkquery failed\n");
  #endif
+ #ifndef WINNT
  		h_errno = NO_RECOVERY;
+ #else
+ 		WSASetLastError(NO_RECOVERY);
+ #endif
  		return (n);
  	}
  	n = res_send(buf, n, answer, anslen);
***************
*** 136,166 ****
  		if (_res.options & RES_DEBUG)
  			printf(";; res_query: send error\n");
  #endif
  		h_errno = TRY_AGAIN;
  		return (n);
  	}
  
! 	if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
  #ifdef DEBUG
  		if (_res.options & RES_DEBUG)
  			printf(";; rcode = %d, ancount=%d\n", hp->rcode,
! 			    ntohs(hp->ancount));
  #endif
  		switch (hp->rcode) {
  		case NXDOMAIN:
  			h_errno = HOST_NOT_FOUND;
  			break;
  		case SERVFAIL:
  			h_errno = TRY_AGAIN;
  			break;
  		case NOERROR:
  			h_errno = NO_DATA;
  			break;
  		case FORMERR:
  		case NOTIMP:
  		case REFUSED:
  		default:
  			h_errno = NO_RECOVERY;
  			break;
  		}
  		return (-1);
--- 148,198 ----
  		if (_res.options & RES_DEBUG)
  			printf(";; res_query: send error\n");
  #endif
+ #ifndef WINNT
  		h_errno = TRY_AGAIN;
+ #else
+ 		WSASetLastError(TRY_AGAIN);
+ #endif
  		return (n);
  	}
  
! 	if (hp->rcode != NOERROR || ntohs( (u_short) hp->ancount) == 0) {
  #ifdef DEBUG
  		if (_res.options & RES_DEBUG)
  			printf(";; rcode = %d, ancount=%d\n", hp->rcode,
! 			    ntohs( (u_short) hp->ancount));
  #endif
  		switch (hp->rcode) {
  		case NXDOMAIN:
+ #ifndef WINNT
  			h_errno = HOST_NOT_FOUND;
+ #else
+ 			WSASetLastError(HOST_NOT_FOUND);
+ #endif
  			break;
  		case SERVFAIL:
+ #ifndef WINNT
  			h_errno = TRY_AGAIN;
+ #else
+ 			WSASetLastError(TRY_AGAIN);
+ #endif
  			break;
  		case NOERROR:
+ #ifndef WINNT
  			h_errno = NO_DATA;
+ #else
+ 			WSASetLastError(NO_DATA);
+ #endif
  			break;
  		case FORMERR:
  		case NOTIMP:
  		case REFUSED:
  		default:
+ #ifndef WINNT
  			h_errno = NO_RECOVERY;
+ #else
+ 			WSASetLastError(NO_RECOVERY);
+ #endif
  			break;
  		}
  		return (-1);
***************
*** 188,198 ****
--- 220,239 ----
  	int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (-1);
  	}
+ #ifndef WINNT
  	errno = 0;
  	h_errno = HOST_NOT_FOUND;	/* default, if we never query */
+ #else
+ 	WSASetLastError(HOST_NOT_FOUND);
+ 	SetLastError(0);
+ #endif
  	dots = 0;
  	for (cp = name; *cp; cp++)
  		dots += (*cp == '.');
***************
*** 215,221 ****
--- 256,266 ----
  		ret = res_querydomain(name, NULL, class, type, answer, anslen);
  		if (ret > 0)
  			return (ret);
+ #ifndef WINNT
  		saved_herrno = h_errno;
+ #else
+                 saved_herrno = WSAGetLastError();
+ #endif
  		tried_as_is++;
  	}
  
***************
*** 252,258 ****
--- 297,307 ----
  			 * fully-qualified.
  			 */
  			if (errno == ECONNREFUSED) {
+ #ifndef WINNT
  				h_errno = TRY_AGAIN;
+ #else
+ 				WSASetLastError(TRY_AGAIN);
+ #endif
  				return (-1);
  			}
  
***************
*** 300,311 ****
--- 349,369 ----
  	 * else send back meaningless h_errno, that being the one from
  	 * the last DNSRCH we did.
  	 */
+ #ifndef WINNT
  	if (saved_herrno != -1)
  		h_errno = saved_herrno;
  	else if (got_nodata)
  		h_errno = NO_DATA;
  	else if (got_servfail)
  		h_errno = TRY_AGAIN;
+ #else
+ 	if (saved_herrno != -1)
+ 		WSASetLastError(saved_herrno);
+ 	else if (got_nodata)
+ 		WSASetLastError(NO_DATA);
+ 	else if (got_servfail)
+ 		WSASetLastError(TRY_AGAIN);
+ #endif
  	return (-1);
  }
  
***************
*** 325,331 ****
--- 383,393 ----
  	int n;
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ #ifndef WINNT
  		h_errno = NETDB_INTERNAL;
+ #else
+ 		WSASetLastError(NETDB_INTERNAL);
+ #endif
  		return (-1);
  	}
  #ifdef DEBUG
diff --context --recurs m:\bind494rel/res/res_send.c m:\bind/res/res_send.c
*** m:\bind494rel/res/res_send.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/res_send.c	Fri May 24 05:18:48 1996
***************
*** 69,84 ****
   * Send query to name server and wait for reply.
   */
  
! #include <sys/param.h>
! #include <sys/time.h>
! #include <sys/socket.h>
! #include <sys/uio.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
  
! #include <stdio.h>
! #include <netdb.h>
  #include <errno.h>
  #include <resolv.h>
  #if defined(BSD) && (BSD >= 199306)
--- 69,86 ----
   * Send query to name server and wait for reply.
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/time.h>
! #include <sys/socket.h>
! #include <sys/uio.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
  
! #include <stdio.h>
! #include <netdb.h>
  #include <errno.h>
  #include <resolv.h>
  #if defined(BSD) && (BSD >= 199306)
***************
*** 95,101 ****
--- 97,108 ----
  
  void _res_close __P((void));
  
+ #ifndef WINNT
  static int s = -1;	/* socket used for communications */
+ #else
+ static SOCKET s = INVALID_SOCKET;
+ typedef char * caddr_t;
+ #endif
  static int connected = 0;	/* is the socket connected */
  static int vc = 0;	/* is the socket a virtual ciruit? */
  
***************
*** 143,149 ****
--- 150,161 ----
  			ntohs(address.sin_port),
  			strerror(error));
  	}
+ #ifndef WINNT
  	errno = save;
+ #else
+ 	WSASetLastError(save);
+ 	SetLastError(save);
+ #endif
      }
      static void
      Perror(file, string, error)
***************
*** 157,163 ****
--- 169,179 ----
  		fprintf(file, "res_send: %s: %s\n",
  			string, strerror(error));
  	}
+ #ifndef WINNT
  	errno = save;
+ #else
+  	SetLastError(save);
+ #endif
      }
  #endif
  
***************
*** 229,235 ****
  	const u_char *buf, *eom;
  {
  	register const u_char *cp = buf + HFIXEDSZ;
! 	int qdcount = ntohs(((HEADER*)buf)->qdcount);
  
  	while (qdcount-- > 0) {
  		char tname[MAXDNAME+1];
--- 245,251 ----
  	const u_char *buf, *eom;
  {
  	register const u_char *cp = buf + HFIXEDSZ;
! 	int qdcount = ntohs( (u_short) ((HEADER*)buf)->qdcount);
  
  	while (qdcount-- > 0) {
  		char tname[MAXDNAME+1];
***************
*** 266,274 ****
  	const u_char *buf2, *eom2;
  {
  	register const u_char *cp = buf1 + HFIXEDSZ;
! 	int qdcount = ntohs(((HEADER*)buf1)->qdcount);
  
! 	if (qdcount != ntohs(((HEADER*)buf2)->qdcount))
  		return (0);
  	while (qdcount-- > 0) {
  		char tname[MAXDNAME+1];
--- 282,290 ----
  	const u_char *buf2, *eom2;
  {
  	register const u_char *cp = buf1 + HFIXEDSZ;
! 	int qdcount = ntohs( (u_short) ((HEADER*)buf1)->qdcount);
  
! 	if (qdcount != ntohs( (u_short) ((HEADER*)buf2)->qdcount))
  		return (0);
  	while (qdcount-- > 0) {
  		char tname[MAXDNAME+1];
***************
*** 298,303 ****
--- 314,323 ----
  	int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns;
  	register int n;
  	u_int badns;	/* XXX NSMAX can't exceed #/bits in this var */
+ #ifdef WINNT
+ 	int optionValue = SO_SYNCHRONOUS_NONALERT;
+ 	DWORD BytesRead;
+ #endif
  
  	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
  		/* errno should have been set by res_init() in this case. */
***************
*** 362,368 ****
  			struct iovec iov[2];
  			u_short len;
  			u_char *cp;
! 
  			/*
  			 * Use virtual circuit;
  			 * at most one attempt per server.
--- 382,397 ----
  			struct iovec iov[2];
  			u_short len;
  			u_char *cp;
! #ifdef WINNT
! 			/* set up things so that subsequent socket()
! 			   calls will open blocking sockets */
! 			if (setsockopt(INVALID_SOCKET, SOL_SOCKET,
! 				  	SO_OPENTYPE, (char *)&optionValue,
! 					sizeof(optionValue)) != NO_ERROR) {
! 						Perror(stderr, "cannot open nonoverlapped socket", errno);
! 						return (-1);
! 			}
! #endif
  			/*
  			 * Use virtual circuit;
  			 * at most one attempt per server.
***************
*** 374,385 ****
--- 403,422 ----
  					_res_close();
  
  				s = socket(PF_INET, SOCK_STREAM, 0);
+ #ifndef WINNT
  				if (s < 0) {
+ #else
+ 				if (s == INVALID_SOCKET) {
+ #endif
  					terrno = errno;
  					Perror(stderr, "socket(vc)", errno);
  					return (-1);
  				}
+ #ifndef WINNT
  				errno = 0;
+ #else
+ 				SetLastError(0);
+ #endif
  				if (connect(s, (struct sockaddr *)nsap,
  					    sizeof(struct sockaddr)) < 0) {
  					terrno = errno;
***************
*** 412,418 ****
--- 449,461 ----
  read_len:
  			cp = ans;
  			len = INT16SZ;
+ #ifndef WINNT
  			while ((n = read(s, (char *)cp, (int)len)) > 0) {
+ #else
+ 			while (ReadFile((HANDLE)s, (char *)cp, (DWORD)len,
+ 				             &BytesRead, NULL) &&
+ 				   (n = (int)BytesRead) > 0) {
+ #endif
  				cp += n;
  				if ((len -= n) <= 0)
  					break;
***************
*** 449,455 ****
--- 492,504 ----
  				len = resplen;
  			cp = ans;
  			while (len != 0 &&
+ #ifndef WINNT
  			       (n = read(s, (char *)cp, (int)len)) > 0) {
+ #else
+ 					ReadFile((HANDLE)s, (char *)cp, (DWORD)len,
+ 				             &BytesRead, NULL) &&
+ 				    (n = (int)BytesRead) > 0) {
+ #endif
  				cp += n;
  				len -= n;
  			}
***************
*** 472,478 ****
--- 521,533 ----
  					n = (len > sizeof(junk)
  					     ? sizeof(junk)
  					     : len);
+ #ifndef WINNT
  					if ((n = read(s, junk, n)) > 0)
+ #else
+ 					if (ReadFile((HANDLE)s, (char *)junk, (DWORD)n,
+ 				             &BytesRead, NULL) &&
+ 				        (n = (int)BytesRead) > 0)
+ #endif
  						len -= n;
  					else
  						break;
***************
*** 500,511 ****
  			fd_set dsmask;
  			struct sockaddr_in from;
  			int fromlen;
! 
  			if ((s < 0) || vc) {
  				if (vc)
  					_res_close();
  				s = socket(PF_INET, SOCK_DGRAM, 0);
  				if (s < 0) {
  #if !CAN_RECONNECT
   bad_dg_sock:
  #endif
--- 555,573 ----
  			fd_set dsmask;
  			struct sockaddr_in from;
  			int fromlen;
! #ifndef WINNT
  			if ((s < 0) || vc) {
+ #else
+ 			if ((s == INVALID_SOCKET) || vc) {
+ #endif
  				if (vc)
  					_res_close();
  				s = socket(PF_INET, SOCK_DGRAM, 0);
+ #ifndef WINNT
  				if (s < 0) {
+ #else
+ 				if (s == INVALID_SOCKET) {
+ #endif
  #if !CAN_RECONNECT
   bad_dg_sock:
  #endif
***************
*** 530,535 ****
--- 592,598 ----
  			 * as we wish to receive answers from the first
  			 * server to respond.
  			 */
+ #ifndef WINNT
  			if (_res.nscount == 1 || (try == 0 && ns == 0)) {
  				/*
  				 * Connect only if we are sure we won't
***************
*** 555,560 ****
--- 618,624 ----
  					goto next_ns;
  				}
  			} else {
+ #endif /* WINNT */
  				/*
  				 * Disconnect if we want to listen
  				 * for responses from more than one server.
***************
*** 572,578 ****
--- 636,646 ----
  						       sizeof(no_addr));
  #else
  					int s1 = socket(PF_INET, SOCK_DGRAM,0);
+ #ifndef WINNT
  					if (s1 < 0)
+ #else
+ 					if (s1 == INVALID_SOCKET)
+ #endif
  						goto bad_dg_sock;
  					(void) dup2(s1, s);
  					(void) close(s1);
***************
*** 580,586 ****
--- 648,658 ----
  					       (stdout, ";; new DG socket\n"))
  #endif
  					connected = 0;
+ #ifndef WINNT
  					errno = 0;
+ #else
+ 					SetLastError(0);
+ #endif
  				}
  				if (sendto(s, (char*)buf, buflen, 0,
  					   (struct sockaddr *)nsap,
***************
*** 591,597 ****
--- 663,671 ----
  					_res_close();
  					goto next_ns;
  				}
+ #ifndef WINNT
  			}
+ #endif
  
  			/*
  			 * Wait for reply
***************
*** 608,614 ****
--- 682,692 ----
  			n = select(s+1, &dsmask, (fd_set *)NULL,
  				   (fd_set *)NULL, &timeout);
  			if (n < 0) {
+ #ifndef WINNT
  				if (errno == EINTR)
+ #else
+ 				if (errno == WSAEINTR)
+ #endif
  					goto wait;
  				Perror(stderr, "select", errno);
  				_res_close();
***************
*** 624,635 ****
--- 702,722 ----
  				_res_close();
  				goto next_ns;
  			}
+ #ifndef WINNT
  			errno = 0;
+ #else
+ 			WSASetLastError(0);
+ 			SetLastError(0);
+ #endif
  			fromlen = sizeof(struct sockaddr_in);
  			resplen = recvfrom(s, (char*)ans, anssiz, 0,
  					   (struct sockaddr *)&from, &fromlen);
  			if (resplen <= 0) {
+ #ifndef WINNT
  				Perror(stderr, "recvfrom", errno);
+ #else
+ 				Perror(stderr, "recvfrom", WSAGetLastError());
+ #endif
  				_res_close();
  				goto next_ns;
  			}
***************
*** 753,766 ****
  	   } /*foreach ns*/
  	} /*foreach retry*/
  	_res_close();
! 	if (!v_circuit)
! 		if (!gotsomewhere)
  			errno = ECONNREFUSED;	/* no nameservers found */
! 		else
  			errno = ETIMEDOUT;	/* no answer obtained */
! 	else
  		errno = terrno;
! 	return (-1);
  }
  
  /*
--- 840,869 ----
  	   } /*foreach ns*/
  	} /*foreach retry*/
  	_res_close();
! 	if (!v_circuit) 
! 		if (!gotsomewhere) {
! #ifndef WINNT
  			errno = ECONNREFUSED;	/* no nameservers found */
! #else
! 			WSASetLastError(ECONNREFUSED);
! 			SetLastError(ECONNREFUSED);
! #endif
! 
!      } else {
! #ifndef WINNT
  			errno = ETIMEDOUT;	/* no answer obtained */
! #else
! 			WSASetLastError(ETIMEDOUT);
! 			SetLastError(ETIMEDOUT);
! #endif
!   }	else {
! #ifndef WINNT
  		errno = terrno;
! #else
! 		WSASetLastError(terrno);
! 		SetLastError(terrno);
! #endif
!  }	return (-1);
  }
  
  /*
***************
*** 775,781 ****
--- 878,888 ----
  {
  	if (s >= 0) {
  		(void) close(s);
+ #ifndef WINNT
  		s = -1;
+ #else
+ 		s = INVALID_SOCKET;
+ #endif
  		connected = 0;
  		vc = 0;
  	}
Only in m:\bind/res: resolv.mak
Only in m:\bind/res: resolv.mdp
Only in m:\bind/res: resolv.ncb
Only in m:\bind/res: resolv.vcp
diff --context --recurs m:\bind494rel/res/sethostent.c m:\bind/res/sethostent.c
*** m:\bind494rel/res/sethostent.c	Thu Jun 27 19:27:52 1996
--- m:\bind/res/sethostent.c	Fri May 24 05:18:50 1996
***************
*** 36,43 ****
  static char rcsid[] = "$Id: sethostent.c,v 8.3 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <netinet/in.h>
  #include <arpa/nameser.h>
  #include <netdb.h>
  #include <resolv.h>
--- 36,45 ----
  static char rcsid[] = "$Id: sethostent.c,v 8.3 1995/06/29 09:26:28 vixie Exp $";
  #endif /* LIBC_SCCS and not lint */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
  #include <arpa/nameser.h>
  #include <netdb.h>
  #include <resolv.h>
Only in m:\bind/res: strip.bat
Only in m:\bind/shres/netbsd: .cvsignore
Only in m:\bind/shres/netbsd: Letter
Only in m:\bind: t3b-t4a
Only in m:\bind: t4b-t5b
Only in m:\bind/tools: WinRel
Only in m:\bind/tools: bdlltest.c
Only in m:\bind/tools: bdltest.exe
Only in m:\bind/tools: bdltest.mak
Only in m:\bind/tools: bdltest.vcp
Only in m:\bind/tools: binddll.def
Only in m:\bind/tools: binddll.mak
Only in m:\bind/tools: binddll.mdp
Only in m:\bind/tools: binddll.ncb
Only in m:\bind/tools: binddll.vcp
Only in m:\bind/tools: bindll.c
Only in m:\bind/tools: dig.c.sav
Only in m:\bind/tools: dig_nt.c
Only in m:\bind/tools: instsrv.c
Only in m:\bind/tools: instsrv.mak
Only in m:\bind/tools: instsrv.mdp
Only in m:\bind/tools: instsrv.ncb
Only in m:\bind/tools: instsrv.vcp
Only in m:\bind/tools/nslookup: BOG.WRI
Only in m:\bind/tools/nslookup: WINNTPORT
Only in m:\bind/tools/nslookup: WinRel
diff --context --recurs m:\bind494rel/tools/nslookup/commands.l m:\bind/tools/nslookup/commands.l
*** m:\bind494rel/tools/nslookup/commands.l	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/commands.l	Thu May 23 15:47:42 1996
***************
*** 207,219 ****
  					    LookupHostWithServer(yytext, 0);
  					    return(1);
  					}
! ^{WS}*\n				{
! 					    return(1);
! 					}
! ^.*\n					{
! 					    printf("Unrecognized command: %s",
! 							yytext);
! 					    return(1);
! 					}
! \n					{ ; }
! %%
--- 207,219 ----
  					    LookupHostWithServer(yytext, 0);
  					    return(1);
  					}
! ^{WS}*\n   				{
! 					    return(1);
! 					}
! ^.*\n					{
! 					    printf("Unrecognized command: %s",
! 							yytext);
! 					    return(1);
! 					}
! \n					{ ; }
! %%                                      
diff --context --recurs m:\bind494rel/tools/nslookup/debug.c m:\bind/tools/nslookup/debug.c
*** m:\bind494rel/tools/nslookup/debug.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/debug.c	Fri May 24 07:07:44 1996
***************
*** 70,91 ****
   *******************************************************************************
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <stdio.h>
! #include "res.h"
! #include "../../conf/portability.h"
  
  /*
   *  Imported from res_debug.c
   */
  extern char *_res_resultcodes[];
  extern char *_res_opcodes[];
  
  /*
   *  Used to highlight the start of a record when printing it.
--- 70,102 ----
   *******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <stdio.h>
! #include "res.h"
! #include "../../conf/portability.h"
  
  /*
   *  Imported from res_debug.c
   */
  extern char *_res_resultcodes[];
  extern char *_res_opcodes[];
+ char * inet_nsap_ntoa();
+ const char * inet_ntop();
+ 
+ /*
+  *  Forward references
+  */
+ 
+ void Fprint_query(u_char *msg, u_char *eom, int printHeader, FILE *file);
+ 
  
  /*
   *  Used to highlight the start of a record when printing it.
***************
*** 99,111 ****
   * This is intended to be primarily a debugging routine.
   */
  
  Print_query(msg, eom, printHeader)
  	char *msg, *eom;
  	int printHeader;
  {
! 	Fprint_query(msg, eom, printHeader,stdout);
  }
  
  Fprint_query(msg, eom, printHeader,file)
  	u_char *msg, *eom;
  	int printHeader;
--- 110,124 ----
   * This is intended to be primarily a debugging routine.
   */
  
+ void
  Print_query(msg, eom, printHeader)
  	char *msg, *eom;
  	int printHeader;
  {
! 	Fprint_query(msg, eom, printHeader, stdout);
  }
  
+ void
  Fprint_query(msg, eom, printHeader,file)
  	u_char *msg, *eom;
  	int printHeader;
***************
*** 125,131 ****
  	if (printHeader || (_res.options & RES_DEBUG2)) {
  	    fprintf(file,"    HEADER:\n");
  	    fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
! 	    fprintf(file,", id = %d", ntohs(hp->id));
  	    fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]);
  	    fprintf(file,"\theader flags: ");
  	    if (hp->qr) {
--- 138,144 ----
  	if (printHeader || (_res.options & RES_DEBUG2)) {
  	    fprintf(file,"    HEADER:\n");
  	    fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
! 	    fprintf(file,", id = %d", ntohs( (u_short) hp->id));
  	    fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]);
  	    fprintf(file,"\theader flags: ");
  	    if (hp->qr) {
***************
*** 141,156 ****
  		    fprintf(file,", want recursion");
  	    if (hp->ra)
  		    fprintf(file,", recursion avail.");
! 	    fprintf(file,"\n\tquestions = %d", ntohs(hp->qdcount));
! 	    fprintf(file,",  answers = %d", ntohs(hp->ancount));
! 	    fprintf(file,",  authority records = %d", ntohs(hp->nscount));
! 	    fprintf(file,",  additional = %d\n\n", ntohs(hp->arcount));
  	}
  
  	/*
  	 * Print question records.
  	 */
! 	if (n = ntohs(hp->qdcount)) {
  		fprintf(file,"    QUESTIONS:\n");
  		while (--n >= 0) {
  			fprintf(file,"\t");
--- 154,169 ----
  		    fprintf(file,", want recursion");
  	    if (hp->ra)
  		    fprintf(file,", recursion avail.");
! 	    fprintf(file,"\n\tquestions = %d", ntohs( (u_short) hp->qdcount));
! 	    fprintf(file,",  answers = %d", ntohs( (u_short) hp->ancount));
! 	    fprintf(file,",  authority records = %d", ntohs( (u_short) hp->nscount));
! 	    fprintf(file,",  additional = %d\n\n", ntohs( (u_short) hp->arcount));
  	}
  
  	/*
  	 * Print question records.
  	 */
! 	if (n = ntohs( (u_short) hp->qdcount)) {
  		fprintf(file,"    QUESTIONS:\n");
  		while (--n >= 0) {
  			fprintf(file,"\t");
***************
*** 168,174 ****
  	/*
  	 * Print authoritative answer records
  	 */
! 	if (n = ntohs(hp->ancount)) {
  		fprintf(file,"    ANSWERS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
--- 181,187 ----
  	/*
  	 * Print authoritative answer records
  	 */
! 	if (n = ntohs( (u_short) hp->ancount)) {
  		fprintf(file,"    ANSWERS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
***************
*** 180,186 ****
  	/*
  	 * print name server records
  	 */
! 	if (n = ntohs(hp->nscount)) {
  		fprintf(file,"    AUTHORITY RECORDS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
--- 193,199 ----
  	/*
  	 * print name server records
  	 */
! 	if (n = ntohs( (u_short) hp->nscount)) {
  		fprintf(file,"    AUTHORITY RECORDS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
***************
*** 192,198 ****
  	/*
  	 * print additional records
  	 */
! 	if (n = ntohs(hp->arcount)) {
  		fprintf(file,"    ADDITIONAL RECORDS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
--- 205,211 ----
  	/*
  	 * print additional records
  	 */
! 	if (n = ntohs( (u_short) hp->arcount)) {
  		fprintf(file,"    ADDITIONAL RECORDS:\n");
  		while (--n >= 0) {
  			fprintf(file, INDENT);
***************
*** 553,559 ****
  				struct servent *s;
  
   				if (c & 0200) {
! 					s = getservbyport((int)htons(n),
  					    protoPtr ? protoPtr->p_name : NULL);
  					if (s != NULL) {
  					    fprintf(file,"  %s", s->s_name);
--- 566,572 ----
  				struct servent *s;
  
   				if (c & 0200) {
! 					s = getservbyport((int)htons( (u_short) n),
  					    protoPtr ? protoPtr->p_name : NULL);
  					if (s != NULL) {
  					    fprintf(file,"  %s", s->s_name);
Only in m:\bind/tools/nslookup: dig.c
Only in m:\bind/tools/nslookup: dig.mak
Only in m:\bind/tools/nslookup: dig.mdp
Only in m:\bind/tools/nslookup: dig.ncb
Only in m:\bind/tools/nslookup: dig.vcp
diff --context --recurs m:\bind494rel/tools/nslookup/getinfo.c m:\bind/tools/nslookup/getinfo.c
*** m:\bind494rel/tools/nslookup/getinfo.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/getinfo.c	Thu May 23 15:47:44 1996
***************
*** 71,86 ****
   ******************************************************************************
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <stdio.h>
! #include <ctype.h>
! #include "res.h"
! #include "../../conf/portability.h"
  
  extern char *_res_resultcodes[];
  extern char *res_skip();
--- 71,89 ----
   ******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif 
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <stdio.h>
! #include <ctype.h>
! #include "res.h"
! #include "../../conf/portability.h"
! 
  
  extern char *_res_resultcodes[];
  extern char *res_skip();
***************
*** 118,123 ****
--- 121,135 ----
  
  #define GetShort(cp)	_getshort(cp); cp += INT16SZ;
  
+ /*
+  * Forward references
+  */
+ 
+ int GetHostDomain(struct in_addr *nsAddrPtr, int queryClass, int queryType, char *name, 
+               char *domain, HostInfo *hostPtr, Boolean isServer);
+ static int GetAnswer(struct in_addr	*nsAddrPtr, int queryType, char *msg, int msglen, Boolean iquery, 
+                      register HostInfo	*hostPtr, Boolean isServer);
+ 
  
  /*
   ******************************************************************************
***************
*** 190,199 ****
  	return (headerPtr->rcode);
      }
  
!     qdcount = ntohs(headerPtr->qdcount);
!     ancount = ntohs(headerPtr->ancount);
!     arcount = ntohs(headerPtr->arcount);
!     nscount = ntohs(headerPtr->nscount);
  
      /*
       * If there are no answer, n.s. or additional records
--- 202,211 ----
  	return (headerPtr->rcode);
      }
  
!     qdcount = ntohs( (u_short) headerPtr->qdcount);
!     ancount = ntohs( (u_short) headerPtr->ancount);
!     arcount = ntohs( (u_short) headerPtr->arcount);
!     nscount = ntohs( (u_short) headerPtr->nscount);
  
      /*
       * If there are no answer, n.s. or additional records
***************
*** 644,650 ****
  	    if ((result != NXDOMAIN && result != NO_INFO) ||
  		(_res.options & RES_DNSRCH) == 0)
  		    break;
! 	}
      /* if we have not already tried the name "as is", do that now.
       * note that we do this regardless of how many dots were in the
       * name or whether it ends with a dot.
--- 656,662 ----
  	    if ((result != NXDOMAIN && result != NO_INFO) ||
  		(_res.options & RES_DNSRCH) == 0)
  		    break;
!     }
      /* if we have not already tried the name "as is", do that now.
       * note that we do this regardless of how many dots were in the
       * name or whether it ends with a dot.
***************
*** 663,668 ****
--- 675,681 ----
   * Perform a query on the concatenation of name and domain,
   * removing a trailing dot from name if domain is NULL.
   */
+ int
  GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer)
      struct in_addr	*nsAddrPtr;
      int			queryClass;
diff --context --recurs m:\bind494rel/tools/nslookup/list.c m:\bind/tools/nslookup/list.c
*** m:\bind494rel/tools/nslookup/list.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/list.c	Fri May 24 07:07:40 1996
***************
*** 70,85 ****
   *******************************************************************************
   */
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <stdio.h>
! #include <limits.h>
! #include <ctype.h>
  #include <errno.h>
  #include "res.h"
  #include "../../conf/portability.h"
--- 70,87 ----
   *******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <netdb.h>
! #include <stdio.h>
! #include <limits.h>
! #include <ctype.h>
  #include <errno.h>
  #include "res.h"
  #include "../../conf/portability.h"
***************
*** 98,103 ****
--- 100,116 ----
  extern int	queryType;
  extern int	queryClass;
  
+ char * inet_nsap_ntoa();
+ const char * inet_ntop();
+ 
+ /*
+  * Forward references
+  */
+ 
+ int
+ PrintListInfo(FILE *file, u_char *msg, u_char *eom, int qtype, char *domain);
+ 
+ 
  static int sockFD = -1;
  int ListSubr();
  
***************
*** 310,318 ****
  	 */
  
  	__putshort(msglen, (u_char *)&len);
! 
          if (write(sockFD, (char *)&len, INT16SZ) != INT16SZ ||
              write(sockFD, (char *) &buf, msglen) != msglen) {
  		perror("ls: write");
  		(void) close(sockFD);
  		sockFD = -1;
--- 323,338 ----
  	 */
  
  	__putshort(msglen, (u_char *)&len);
!     
!   #ifndef WINNT
          if (write(sockFD, (char *)&len, INT16SZ) != INT16SZ ||
              write(sockFD, (char *) &buf, msglen) != msglen) {
+   #else
+ 
+         if (send(sockFD,(const char *)&len,INT16SZ,0) != INT16SZ  ||
+             send(sockFD,(const char *)&buf,msglen,0) != msglen) {
+   #endif
+ 
  		perror("ls: write");
  		(void) close(sockFD);
  		sockFD = -1;
***************
*** 326,332 ****
  	if (cmd == NULL) {
  	    filePtr = stdout;
  	} else {
! 	    filePtr = OpenFile(cmd, file);
              if (filePtr == NULL) {
                  fprintf(stderr, "*** Can't open %s for writing\n", file);
  		(void) close(sockFD);
--- 346,352 ----
  	if (cmd == NULL) {
  	    filePtr = stdout;
  	} else {
! 	    filePtr = AppOpenFile(cmd, file);
              if (filePtr == NULL) {
                  fprintf(stderr, "*** Can't open %s for writing\n", file);
  		(void) close(sockFD);
***************
*** 440,446 ****
--- 460,470 ----
  
  	    cp = (u_char *)&tmp;
  	    amtToRead = INT16SZ;
+ #ifndef WINNT
  	    while ((numRead = read(sockFD, cp, amtToRead)) > 0) {
+ #else
+ 	    while ((numRead = recv(sockFD, cp, amtToRead,0)) > 0) {
+ #endif
  		cp += numRead;
  		if ((amtToRead -= numRead) <= 0)
  			break;
***************
*** 472,478 ****
--- 496,507 ----
  
  	    amtToRead = len;
  	    cp = answer;
+         #ifndef WINNT
  	    while (amtToRead > 0 && (numRead=read(sockFD, cp, amtToRead)) > 0) {
+ #else
+ 	    while (amtToRead > 0 && (numRead=recv(sockFD, cp, amtToRead,0)) > 0) {
+ 
+ #endif
  		cp += numRead;
  		amtToRead -= numRead;
  	    }
***************
*** 486,537 ****
  		error = ERR_PRINTING;
  		break;
  	    }
! 	    numRecords += htons(((HEADER *)answer)->ancount);
  	    numAnswers++;
  	    if (cmd != NULL && ((numAnswers % HASH_SIZE) == 0)) {
  		fprintf(stdout, "#");
  		fflush(stdout);
  	    }
! 	    /* Header. */
! 	    cp = answer + HFIXEDSZ;
! 	    /* Question. */
! 	    for (count = ntohs(((HEADER* )answer)->qdcount);
! 		 count > 0;
! 		 count--)
! 		    cp += dn_skipname(cp, answer + len) + QFIXEDSZ;
! 	    /* Answer. */
! 	    for (count = ntohs(((HEADER* )answer)->ancount);
! 		 count > 0;
! 		 count--) {
! 		int type, class, rlen;
! 
! 		n = dn_expand(answer, answer + len, cp,
! 			      dname[soacnt], sizeof dname[0]);
! 		if (n < 0) {
! 		    error = ERR_PRINTING;
! 		    done++;
! 		    break;
! 		}
! 		cp += n;
! 		GETSHORT(type, cp);
! 		GETSHORT(class, cp);
! 		cp += INT32SZ;	/* ttl */
! 		GETSHORT(rlen, cp);
! 		cp += rlen;
! 		if (type == T_SOA && soacnt++ &&
! 		    !strcasecmp(dname[0], dname[1])) {
! 		    done++;
! 		    break;
! 		}
! 	    }
! 	}
! 
! 	if (cmd != NULL) {
! 	    fprintf(stdout, "%sReceived %d answer%s (%d record%s).\n",
! 		(numAnswers >= HASH_SIZE) ? "\n" : "",
! 		numAnswers, (numAnswers != 1) ? "s" : "",
! 		numRecords, (numRecords != 1) ? "s" : "");
! 	}
  
  	(void) close(sockFD);
  	sockFD = -1;
--- 515,566 ----
  		error = ERR_PRINTING;
  		break;
  	    }
! 	    numRecords += htons((u_short)((HEADER *)answer)->ancount);
  	    numAnswers++;
  	    if (cmd != NULL && ((numAnswers % HASH_SIZE) == 0)) {
  		fprintf(stdout, "#");
  		fflush(stdout);
  	    }
!  	    /* Header. */
!   	    cp = answer + HFIXEDSZ;
!  	    /* Question. */
!  	    for (count = ntohs((u_short)((HEADER* )answer)->qdcount);
!  		 count > 0;
!  		 count--)
!  		    cp += dn_skipname((u_char *)cp, (u_char *)answer + len) + QFIXEDSZ;
!  	    /* Answer. */
!  	    for (count = ntohs((u_short)((HEADER* )answer)->ancount);
!  		 count > 0;
!  		 count--) {
!  		int type, class, rlen;
!  
!  		n = dn_expand(answer, answer + len, cp,
!  			      dname[soacnt], sizeof dname[0]);
!  		if (n < 0) {
!  		    error = ERR_PRINTING;
!  		    done++;
!  		    break;
!  		}
!  		cp += n;
!  		GETSHORT(type, cp);
!  		GETSHORT(class, cp);
!  		cp += INT32SZ;	/* ttl */
!  		GETSHORT(rlen, cp);
!  		cp += rlen;
!  		if (type == T_SOA && soacnt++ &&
!  		    !strcasecmp(dname[0], dname[1])) {
!  		    done++;
!  		    break;
!  		}
!   	    }
!   	}
!   
!   	if (cmd != NULL) {
!  	    fprintf(stdout, "%sReceived %d answer%s (%d record%s).\n",
!   		(numAnswers >= HASH_SIZE) ? "\n" : "",
!  		numAnswers, (numAnswers != 1) ? "s" : "",
!  		numRecords, (numRecords != 1) ? "s" : "");
!   	}
  
  	(void) close(sockFD);
  	sockFD = -1;
***************
*** 556,569 ****
  		fprintf(stderr,
  	       "  result: %s, answers = %d, authority = %d, additional = %d\n",
  			_res_resultcodes[headerPtr->rcode],
! 			ntohs(headerPtr->ancount), ntohs(headerPtr->nscount),
! 			ntohs(headerPtr->arcount));
  		return(ERROR);
  	    default:
  		return(ERROR);
  	}
  }
- 
  
  /*
   *******************************************************************************
--- 585,597 ----
  		fprintf(stderr,
  	       "  result: %s, answers = %d, authority = %d, additional = %d\n",
  			_res_resultcodes[headerPtr->rcode],
! 			ntohs( (u_short) headerPtr->ancount), ntohs( (u_short) headerPtr->nscount),
! 			ntohs( (u_short) headerPtr->arcount));
  		return(ERROR);
  	    default:
  		return(ERROR);
  	}
  }
  
  /*
   *******************************************************************************
***************
*** 604,609 ****
--- 632,638 ----
  }
  
  
+ int
  PrintListInfo(file, msg, eom, qtype, domain)
      FILE	*file;
      u_char	*msg, *eom;
***************
*** 635,652 ****
       *  there aren't any question records.
       */
  
!     if (ntohs(headerPtr->ancount) == 0) {
  	return(NO_INFO);
!     }
!     for (n = ntohs(headerPtr->qdcount); n > 0; n--) {
! 	nameLen = dn_skipname(cp, eom);
! 	if (nameLen < 0)
! 	    return (ERROR);
! 	cp += nameLen + QFIXEDSZ;
!     }
!     for (count = ntohs(headerPtr->ancount); count > 0; count--) {
! 	nameLen = dn_expand(msg, eom, cp, name, sizeof name);
! 	if (nameLen < 0)
  	    return (ERROR);
  	cp += nameLen;
  
--- 664,681 ----
       *  there aren't any question records.
       */
  
!     if (ntohs( (u_short) headerPtr->ancount) == 0) {
  	return(NO_INFO);
!       }
!       for (n = ntohs((u_short) headerPtr->qdcount); n > 0; n--) {
!  	nameLen = dn_skipname(cp, eom);
!  	if (nameLen < 0)
!  	    return (ERROR);
!  	cp += nameLen + QFIXEDSZ;
!       }
!       for (count = ntohs((u_short)headerPtr->ancount); count > 0; count--) {
!   	nameLen = dn_expand(msg, eom, cp, name, sizeof name);
!   	if (nameLen < 0)
  	    return (ERROR);
  	cp += nameLen;
  
***************
*** 924,929 ****
--- 953,959 ----
   *******************************************************************************
   */
  
+ void
  ViewList(string)
      char *string;
  {
***************
*** 959,965 ****
--- 989,1001 ----
  {
  	struct servent		*sp;
  	struct sockaddr_in	sin;
+     #ifndef WINNT
  	register FILE		*f;
+     #else
+     char f[5000];
+     int numread = 0;
+     int i;
+     #endif
  	register int		c;
  	register int		lastc;
  	char			name[NAME_LEN];
***************
*** 1015,1021 ****
  	if (!putToFile) {
  	    filePtr = stdout;
  	} else {
! 	    filePtr = OpenFile(string, file);
  	    if (filePtr == NULL) {
  		fprintf(stderr, "*** Can't open %s for writing\n", file);
  		close(sockFD);
--- 1051,1057 ----
  	if (!putToFile) {
  	    filePtr = stdout;
  	} else {
! 	    filePtr = AppOpenFile(string, file);
  	    if (filePtr == NULL) {
  		fprintf(stderr, "*** Can't open %s for writing\n", file);
  		close(sockFD);
***************
*** 1027,1037 ****
  	fprintf(filePtr, "[%s]\n", curHostInfo.name);
  
  	if (name[0] != '\0') {
  	    write(sockFD, "/W ", 3);
! 	}
  	write(sockFD, name, strlen(name));
  	write(sockFD, "\r\n", 2);
! 	f = fdopen(sockFD, "r");
  	lastc = '\n';
  	while ((c = getc(f)) != EOF) {
  	    switch (c) {
--- 1063,1081 ----
  	fprintf(filePtr, "[%s]\n", curHostInfo.name);
  
  	if (name[0] != '\0') {
+ #ifndef WINNT
  	    write(sockFD, "/W ", 3);
!         	}
  	write(sockFD, name, strlen(name));
  	write(sockFD, "\r\n", 2);
! #else
!    /* send(sockFD,"/W",3,0); */
!          }
! 	send(sockFD, name, strlen(name),0);
! 	send(sockFD, "\r\n", 2,0);
! 	#endif
! #ifndef WINNT	
! 	f = fdopen(sockFD, "r"); 
  	lastc = '\n';
  	while ((c = getc(f)) != EOF) {
  	    switch (c) {
***************
*** 1047,1056 ****
  	    }
  	    putc(lastc = c, filePtr);
  	}
! 	if (lastc != '\n') {
  	    putc('\n', filePtr);
! 	}
! 	putc('\n', filePtr);
  
  	close(sockFD);
  	sockFD = -1;
--- 1091,1124 ----
  	    }
  	    putc(lastc = c, filePtr);
  	}
! #else
!     while ((numread = recv(sockFD,(char *)f,4999,0)) != 0)
!       {
! 
! 	   for (i=0; i<=numread; i++)
!         {
!           c = f[i];
!           switch (c) 
!           {
! 		    case 0210:
! 		    case 0211:
! 		    case 0212:
! 		    case 0214:
! 	  		      c -= 0200;
! 			      break;
! 		    case 0215:
! 			     c = '\n';
! 			     break;
! 	       }
! 	        putc(lastc = c, filePtr);
!       }       
!       }
!  #endif
! 	if (lastc != '\n') 
! 	  {
  	    putc('\n', filePtr);
! 	  }
! 	  putc('\n', filePtr);
  
  	close(sockFD);
  	sockFD = -1;
***************
*** 1062,1067 ****
--- 1130,1136 ----
  	return (SUCCESS);
  }
  
+ void
  ListHost_close()
  {
      if (sockFD != -1) {
diff --context --recurs m:\bind494rel/tools/nslookup/main.c m:\bind/tools/nslookup/main.c
*** m:\bind494rel/tools/nslookup/main.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/main.c	Sat Jun 08 01:48:28 1996
***************
*** 79,94 ****
   ******************************************************************************
   */
  
! #include <sys/param.h>
! #include <netdb.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <signal.h>
! #include <setjmp.h>
! #include <ctype.h>
  #include <stdio.h>
  #include <errno.h>
  #include <limits.h>
--- 79,98 ----
   ******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <setjmp.h>
! #endif
! #include <netdb.h>
! #ifndef WINNT
! #include <sys/socket.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <resolv.h>
! #include <signal.h>
! #include <ctype.h>
  #include <stdio.h>
  #include <errno.h>
  #include <limits.h>
***************
*** 96,102 ****
  #include "pathnames.h"
  #include "../../conf/portability.h"
  
! 
  /*
   * Name of a top-level name server. Can be changed with 
   * the "set root" command.
--- 100,115 ----
  #include "pathnames.h"
  #include "../../conf/portability.h"
  
!   /* 
!    * Forward references
!    */
!   void Usage();
!   void LocalServer(HostInfo *defaultPtr);
!   int  LookupHost(char *string, Boolean putToFile);
!   void res_re_init();
!   void res_dnsrch(register char *cp);
!   int  SetOption(register char *option);
!   
  /*
   * Name of a top-level name server. Can be changed with 
   * the "set root" command.
***************
*** 107,112 ****
--- 120,128 ----
  #endif
  char		rootServerName[NAME_LEN] = ROOT_SERVER;
  
+   #ifdef WINNT
+   HANDLE hReadWriteEvent = NULL;
+   #endif
  
  /*
   *  Import the state information from the resolver library.
***************
*** 140,152 ****
  int		queryClass = C_IN;
  
  /*
!  * Stuff for Interrupt (control-C) signal handler.
   */
  
  extern SIG_FN	IntrHandler();
- FILE		*filePtr;
  jmp_buf		env;
! 
  
  /*
   * Browser command for help and view.
--- 156,171 ----
  int		queryClass = C_IN;
  
  /*
!  * Stuff for Interrupt (control-C) signal handler.                    
   */
  
+ #ifndef WINNT
  extern SIG_FN	IntrHandler();
  jmp_buf		env;
! #else
! 	char *pathnslookuprc, *pathpagercmd, *pathhelpfile;
! #endif
! FILE		*filePtr;
  
  /*
   * Browser command for help and view.
***************
*** 156,161 ****
--- 175,206 ----
  static void CvtAddrToPtr();
  static void ReadRC();
  
+ #ifdef WINNT
+ /* Expand environmental variables in file pathnames */
+ /* XXX - Would it be better to store/retrieve pathnames from the registry? */
+ void
+ expand_paths(void)
+ {
+ 
+ 	pathnslookuprc = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_NSLOOKUPRC, pathnslookuprc, MAX_PATH)) {
+ 		syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_NSLOOKUPRC) failed: %m\n");
+ 	} else
+ 
+ 	pathpagercmd = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_PAGERCMD, pathpagercmd, MAX_PATH)) {
+ 		syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_PAGERCMD) failed: %m\n");
+ 	} else
+ 		 
+ 	pathhelpfile = (char *)malloc(MAX_PATH);
+ 	if (!ExpandEnvironmentStrings(_PATH_HELPFILE, pathhelpfile, MAX_PATH)) {
+ 		syslog(LOG_ERR, "ExpandEnvironmentStrings(_PATH_HELPFILE) failed: %m\n");
+ 	}
+ 
+ }
+ #endif /* WINNT */
+ 
+ 
  
  /*
   ******************************************************************************
***************
*** 182,187 ****
--- 227,253 ----
      /*
       *  Initialize the resolver library routines.
       */
+      
+ #ifdef WINNT
+ /* lgk moved startup to beginning.. */
+ 
+ 
+ 
+ 
+ 	hReadWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+    {
+  	WORD wVersionRequested;
+ 	WSADATA wsaData;
+ 
+         expand_paths();
+ 	wVersionRequested = MAKEWORD(1,1);
+ 	if (WSAStartup(wVersionRequested, &wsaData)) {
+ 		syslog(LOG_ERR, "No useable winsock.dll: %m");
+ 		return (-1);
+ 	}
+ 
+    }
+ #endif /* WINNT */
  
      if (res_init() == -1) {
  	fprintf(stderr,"*** Can't initialize resolver.\n");
***************
*** 244,250 ****
--- 310,320 ----
  	    _res.nscount = 1;
  	    _res.nsaddr.sin_addr = addr;
  	} else {
+ #ifndef WINNT
  	    hp = gethostbyname(*argv);
+ #else
+ 	    hp = gethostbyname_nt(*argv);
+ #endif
  	    if (hp == NULL) {
  		fprintf(stderr, "*** Can't find server address for '%s': ", 
  			*argv);
***************
*** 320,332 ****
  
  	pager = getenv("PAGER");
  	if (pager == NULL) {
  	    pager = _PATH_PAGERCMD;
  	}
- 
  	/*
  	 * Setup the environment to allow the interrupt handler to return here.
  	 */
! 
  	(void) setjmp(env);
  
  	/* 
--- 390,405 ----
  
  	pager = getenv("PAGER");
  	if (pager == NULL) {
+ #ifndef WINNT 
  	    pager = _PATH_PAGERCMD;
+ #else
+             pager = pathpagercmd;
+ #endif
  	}
  	/*
  	 * Setup the environment to allow the interrupt handler to return here.
  	 */
! #ifndef WINNT
  	(void) setjmp(env);
  
  	/* 
***************
*** 335,341 ****
  
  	signal(SIGINT, IntrHandler);
  	signal(SIGPIPE, SIG_IGN);
! 
  	/*
  	 * Read and evaluate commands. The commands are described in commands.l
  	 * Yylex returns 0 when ^D or 'exit' is typed. 
--- 408,414 ----
  
  	signal(SIGINT, IntrHandler);
  	signal(SIGPIPE, SIG_IGN);
! #endif
  	/*
  	 * Read and evaluate commands. The commands are described in commands.l
  	 * Yylex returns 0 when ^D or 'exit' is typed. 
***************
*** 343,348 ****
--- 416,422 ----
  
  	printf("> ");
  	fflush(stdout);
+ 
  	while(yylex()) {
  	    printf("> ");
  	    fflush(stdout);
***************
*** 352,357 ****
--- 426,432 ----
  }
  
  
+ void
  LocalServer(defaultPtr)
      HostInfo *defaultPtr;
  {
***************
*** 359,367 ****
  
      (void) gethostname(hostName, sizeof(hostName));
  
!     defaultAddr.s_addr = htonl(INADDR_ANY);
!     (void) GetHostInfoByName(&defaultAddr, C_IN, T_A,
  			     "0.0.0.0", defaultPtr, 1);
      free(defaultPtr->name);
      defaultPtr->name = Calloc(1, sizeof(hostName)+1);
      strcpy(defaultPtr->name, hostName);
--- 434,450 ----
  
      (void) gethostname(hostName, sizeof(hostName));
  
! #ifndef WINNT
!     defaultAddr.s_addr = htonl(INADDR_ANY); 
!       (void) GetHostInfoByName(&defaultAddr, C_IN, T_A,
  			     "0.0.0.0", defaultPtr, 1);
+ #else /* lgk the 0.0.0.0 doesn't work for nt so set to loopback */
+     defaultAddr.s_addr = htonl(INADDR_LOOPBACK);
+           (void) GetHostInfoByName(&defaultAddr, C_IN, T_A,
+ 			     "127.0.0.1", defaultPtr, 1);
+ 
+ #endif
+   
      free(defaultPtr->name);
      defaultPtr->name = Calloc(1, sizeof(hostName)+1);
      strcpy(defaultPtr->name, hostName);
***************
*** 378,383 ****
--- 461,467 ----
   ******************************************************************************
   */
  
+ void 
  Usage()
  {
      fprintf(stderr, "Usage:\n");
***************
*** 682,688 ****
      if (!putToFile) {
  	filePtr = stdout;
      } else {
! 	filePtr = OpenFile(string, file);
  	if (filePtr == NULL) {
  	    fprintf(stderr, "*** Can't open %s for writing\n", file);
  	    return(ERROR);
--- 766,772 ----
      if (!putToFile) {
  	filePtr = stdout;
      } else {
! 	filePtr = AppOpenFile(string, file);
  	if (filePtr == NULL) {
  	    fprintf(stderr, "*** Can't open %s for writing\n", file);
  	    return(ERROR);
***************
*** 743,749 ****
      if (!putToFile) {
  	filePtr = stdout;
      } else {
! 	filePtr = OpenFile(string, file);
  	if (filePtr == NULL) {
  	    fprintf(stderr, "*** Can't open %s for writing\n", file);
  	    return(ERROR);
--- 827,833 ----
      if (!putToFile) {
  	filePtr = stdout;
      } else {
! 	filePtr = AppOpenFile(string, file);
  	if (filePtr == NULL) {
  	    fprintf(stderr, "*** Can't open %s for writing\n", file);
  	    return(ERROR);
***************
*** 932,937 ****
--- 1016,1022 ----
  /*
   * Fake a reinitialization when the domain is changed.
   */
+ void
  res_re_init()
  {
      register char *cp, **pp;
***************
*** 954,959 ****
--- 1039,1045 ----
  
  #define SRCHLIST_SEP '/'
  
+ void
  res_dnsrch(cp)
      register char *cp;
  {
***************
*** 1050,1057 ****
  PrintHelp()
  {
  	char cmd[PATH_MAX];
! 
  	sprintf(cmd, "%s %s", pager, _PATH_HELPFILE);
  	system(cmd);
  }
  
--- 1136,1148 ----
  PrintHelp()
  {
  	char cmd[PATH_MAX];
! #ifndef WINNT
  	sprintf(cmd, "%s %s", pager, _PATH_HELPFILE);
+ #else
+ 	sprintf(cmd, "%s < %s", pager, pathhelpfile);
+ #endif
+ 
+         /* printf("path helpfile = %s ",pathhelpfile); */
  	system(cmd);
  }
  
***************
*** 1104,1110 ****
--- 1195,1205 ----
  
      if ((cp = getenv("HOME")) != NULL) {
  	(void) strcpy(buf, cp);
+ #ifndef WINNT
  	(void) strcat(buf, _PATH_NSLOOKUPRC);
+ #else
+ 	(void) strcat(buf, pathnslookuprc);
+ #endif
  
  	if ((fp = fopen(buf, "r")) != NULL) {
  	    while (fgets(buf, sizeof(buf), fp) != NULL) {
Only in m:\bind/tools/nslookup: nslookup.exe
Only in m:\bind/tools/nslookup: nslookup.mak
Only in m:\bind/tools/nslookup: nslookup.mdp
Only in m:\bind/tools/nslookup: nslookup.ncb
Only in m:\bind/tools/nslookup: nslookup.vcp
Only in m:\bind/tools/nslookup: nslookupnt.zip
diff --context --recurs m:\bind494rel/tools/nslookup/pathnames.h m:\bind/tools/nslookup/pathnames.h
*** m:\bind494rel/tools/nslookup/pathnames.h	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/pathnames.h	Thu May 23 15:47:48 1996
***************
*** 59,71 ****
   */
  
  #define	_PATH_NSLOOKUPRC	"/.nslookuprc"
! #define _PATH_PAGERCMD		"more"
! 
! #ifndef _PATH_HELPFILE
! #if defined(BSD) && BSD >= 198810
! #define	_PATH_HELPFILE		"/usr/share/misc/nslookup.help"
! #else
! #define _PATH_HELPFILE		"/usr/lib/nslookup.help"
  #endif
  #endif
  
--- 59,80 ----
   */
  
  #define	_PATH_NSLOOKUPRC	"/.nslookuprc"
! 
! #ifndef WINNT
! #define _PATH_PAGERCMD		"more"
! #else
! #define _PATH_PAGERCMD		"more"
! #endif
! 
! #ifndef _PATH_HELPFILE
! #if defined(BSD) && BSD >= 198810
! #define	_PATH_HELPFILE		"/usr/share/misc/nslookup.help"
! #else
! #ifdef WINNT
! #define _PATH_HELPFILE		"%windir%\\system32\\nslookup.help"
! #else
! #define _PATH_HELPFILE		"/usr/lib/nslookup.help"
! #endif
  #endif
  #endif
  
Only in m:\bind/tools/nslookup: readme.nt
diff --context --recurs m:\bind494rel/tools/nslookup/res.h m:\bind/tools/nslookup/res.h
*** m:\bind494rel/tools/nslookup/res.h	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/res.h	Thu May 23 15:47:50 1996
***************
*** 73,88 ****
   *******************************************************************************
   */
  
! #define TRUE	1
! #define FALSE	0
! typedef int Boolean;
  
  /*
!  *  Define return statuses in addtion to the ones defined in namserv.h
!  *   let SUCCESS be a synonym for NOERROR
   *
!  *	TIME_OUT	- a socket connection timed out.
!  *	NO_INFO		- the server didn't find any info about the host.
   *	ERROR		- one of the following types of errors:
   *			   dn_expand, res_mkquery failed
   *			   bad command line, socket operation failed, etc.
--- 73,97 ----
   *******************************************************************************
   */
  
! #ifndef _RES_H_
! #define _RES_H_
! 
! #ifdef WINNT
! #include <winsock.h>
! #include "../../conf/portability.h"
! #include <stdio.h>
! #endif
! 
! #define TRUE	1
! #define FALSE	0
! typedef int Boolean;
  
  /*
!  *  Define return statuses in addtion to the ones defined in namserv.h
!  *   let SUCCESS be a synonym for NOERROR
   *
!  *	TIME_OUT	- a socket connection timed out.
!  *	NO_INFO		- the server didn't find any info about the host.
   *	ERROR		- one of the following types of errors:
   *			   dn_expand, res_mkquery failed
   *			   bad command line, socket operation failed, etc.
***************
*** 155,172 ****
   */
  
  extern Boolean IsAddr();
! extern int  Print_query();
  extern unsigned char *Print_cdname();
  extern unsigned char *Print_cdname2();	/* fixed width */
  extern unsigned char *Print_rr();
  extern char *DecodeType();	/* descriptive version of p_type */
- extern char *DecodeError();
  extern char *Calloc();
! extern char *Malloc();
  extern void NsError();
  extern void PrintServer();
! extern void PrintHostInfo();
  extern void ShowOptions();
- extern void FreeHostInfoPtr();
- extern FILE *OpenFile();
  extern char *res_skip();
--- 164,230 ----
   */
  
  extern Boolean IsAddr();
! 
! /*
!  * debug.c definitions
!  */
! 
! void Print_query(char *msg, char *eom, int printHeader);
! 
  extern unsigned char *Print_cdname();
  extern unsigned char *Print_cdname2();	/* fixed width */
  extern unsigned char *Print_rr();
  extern char *DecodeType();	/* descriptive version of p_type */
  extern char *Calloc();
! 
  extern void NsError();
  extern void PrintServer();
! 
  extern void ShowOptions();
  extern char *res_skip();
+ 
+ /*
+  * subr.c definitions
+  */
+ 
+ char * Malloc(int size);
+ void PrintHostInfo(FILE	*file, char	*title, register HostInfo *hp);
+ FILE * AppOpenFile(char *string, char *file);
+ char * DecodeError(int result);
+ int StringToType(char *type, int dflt, FILE *errorfile);
+ int StringToClass(char *class, int dflt, FILE *errorfile);
+ char * DecodeType(int type);
+ 
+ 
+ /*
+  * getinfo.c definitions
+  */
+ 
+ static int GetAnswer(struct in_addr *nsAddrPtr, int queryType, char *msg, int msglen,
+                      Boolean iquery, register HostInfo *hostPtr, Boolean isServer);
+ int GetHostInfoByName(struct in_addr	*nsAddrPtr, int queryClass, int queryType,
+                       char *name, HostInfo *hostPtr, Boolean isServer);
+ int GetHostInfoByAddr(struct in_addr *nsAddrPtr, struct in_addr	*address, HostInfo *hostPtr);
+ void FreeHostInfoPtr( register HostInfo *hostPtr);
+ 
+ 
+ /*
+  * send.c definitions
+  */
+ 
+ int SendRequest(struct in_addr	*nsAddrPtr, char *buf, int buflen,
+ 	            char *answer, u_int anslen, int *trueLenPtr);
+ 
+ 
+ /* lgk new definitions */
+ extern int SetDefaultServer();
+ extern int Finger();
+ extern void ViewList();
+ extern void ListHosts();
+ extern void ListHostsByType();
+ extern int SetOption();
+ extern int LookupHost();
+ extern int LookupHostWithServer();
+ extern int yylex();
+ 
+ #endif /* _RES_H_ */
diff --context --recurs m:\bind494rel/tools/nslookup/send.c m:\bind/tools/nslookup/send.c
*** m:\bind494rel/tools/nslookup/send.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/send.c	Thu May 23 15:47:52 1996
***************
*** 74,92 ****
  /*
   * Send query to name server and wait for reply.
   */
! 
! #include <sys/param.h>
! #include <sys/time.h>
! #include <sys/socket.h>
! #include <sys/uio.h>
! #include <netinet/in.h>
! #include <stdio.h>
! #include <errno.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
  #include <resolv.h>
- #include "res.h"
  #include "../../conf/portability.h"
  
  static int s = -1;	/* socket used for communications */
  
--- 74,94 ----
  /*
   * Send query to name server and wait for reply.
   */
! #ifndef WINNT
! #include <sys/param.h>
! #include <sys/time.h>
! #include <sys/socket.h>
! #include <sys/uio.h>
! #include <netinet/in.h>
! #endif 
! #include <stdio.h>
! #include <errno.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
  #include <resolv.h>
  #include "../../conf/portability.h"
+ #include "res.h"
+ 
  
  static int s = -1;	/* socket used for communications */
  
***************
*** 236,242 ****
  				continue;
  			}
  			cp = answer;
! 			if ((resplen = _getshort((u_char*)cp)) > anslen) {
  				if (_res.options & RES_DEBUG)
  					fprintf(stderr, "response truncated\n");
  				len = anslen;
--- 238,244 ----
  				continue;
  			}
  			cp = answer;
! 			if ( (u_int)(resplen = _getshort((u_char*)cp)) > anslen) {
  				if (_res.options & RES_DEBUG)
  					fprintf(stderr, "response truncated\n");
  				len = anslen;
***************
*** 403,408 ****
--- 405,411 ----
   *
   * Called from the interrupt handler.
   */
+ void
  SendRequest_close()
  {
  	if (s != -1) {
diff --context --recurs m:\bind494rel/tools/nslookup/skip.c m:\bind/tools/nslookup/skip.c
*** m:\bind494rel/tools/nslookup/skip.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/skip.c	Thu May 23 15:47:54 1996
***************
*** 75,90 ****
   *******************************************************************************
   */
  
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <resolv.h>
! #include <stdio.h>
! #include "../../conf/portability.h"
  
! char *res_skip_rr();
  
! 
  /*
   *******************************************************************************
   *
--- 75,92 ----
   *******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/param.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <resolv.h>
! #include <stdio.h>
! #include "../../conf/portability.h"
  
! char *res_skip_rr();
  
! 
  /*
   *******************************************************************************
   *
***************
*** 126,132 ****
  	/*
  	 * skip question records.
  	 */
! 	if (n = ntohs(hp->qdcount) ) {
  		while (--n >= 0 && cp < eom) {
  			tmp = dn_skipname((u_char *)cp, (u_char *)eom);
  			if (tmp == -1) return(NULL);
--- 128,134 ----
  	/*
  	 * skip question records.
  	 */
! 	if (n = ntohs( (u_short) hp->qdcount) ) {
  		while (--n >= 0 && cp < eom) {
  			tmp = dn_skipname((u_char *)cp, (u_char *)eom);
  			if (tmp == -1) return(NULL);
***************
*** 140,146 ****
  	/*
  	 * skip authoritative answer records
  	 */
! 	if (n = ntohs(hp->ancount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
--- 142,148 ----
  	/*
  	 * skip authoritative answer records
  	 */
! 	if (n = ntohs( (u_short) hp->ancount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
***************
*** 151,157 ****
  	/*
  	 * skip name server records
  	 */
! 	if (n = ntohs(hp->nscount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
--- 153,159 ----
  	/*
  	 * skip name server records
  	 */
! 	if (n = ntohs( (u_short) hp->nscount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
***************
*** 162,168 ****
  	/*
  	 * skip additional records
  	 */
! 	if (n = ntohs(hp->arcount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
--- 164,170 ----
  	/*
  	 * skip additional records
  	 */
! 	if (n = ntohs( (u_short) hp->arcount)) {
  		while (--n >= 0 && cp < eom) {
  			cp = res_skip_rr(cp, eom);
  			if (cp == NULL) return(NULL);
diff --context --recurs m:\bind494rel/tools/nslookup/subr.c m:\bind/tools/nslookup/subr.c
*** m:\bind494rel/tools/nslookup/subr.c	Thu Jun 27 19:27:52 1996
--- m:\bind/tools/nslookup/subr.c	Thu May 23 15:47:54 1996
***************
*** 74,89 ****
   *******************************************************************************
   */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <netdb.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <signal.h>
! #include <setjmp.h>
! #include <stdio.h>
  #include "res.h"
  #include "../../conf/portability.h"
  
--- 74,95 ----
   *******************************************************************************
   */
  
! #ifndef WINNT
! #include <sys/types.h>
! #include <sys/param.h>
! #endif
! #include <netdb.h>
! #ifndef WINNT
! #include <sys/socket.h>
! #include <netinet/in.h>
! #endif
! #include <arpa/nameser.h>
! #include <arpa/inet.h>
! #include <signal.h>
! #ifndef WINNT
! #include <setjmp.h>
! #endif
! #include <stdio.h>
  #include "res.h"
  #include "../../conf/portability.h"
  
***************
*** 112,117 ****
--- 118,124 ----
   *
   *******************************************************************************
   */
+  #ifndef WINNT
  
  SIG_FN
  IntrHandler()
***************
*** 135,141 ****
      longjmp(env, 1);
  }
  
! 
  /*
   *******************************************************************************
   *
--- 142,148 ----
      longjmp(env, 1);
  }
  
!  #endif
  /*
   *******************************************************************************
   *
***************
*** 186,195 ****
        sigprocmask(SIG_UNBLOCK,&sset,NULL);
      }
  #else
!     { int saveMask;
        saveMask = sigblock(sigmask(SIGINT));
        ptr = malloc((unsigned) size);
        (void) sigsetmask(saveMask);
      }
  #endif
  #endif
--- 193,207 ----
        sigprocmask(SIG_UNBLOCK,&sset,NULL);
      }
  #else
!     { 
!       #ifndef WINNT
! 	  int saveMask;
        saveMask = sigblock(sigmask(SIGINT));
+       #endif
        ptr = malloc((unsigned) size);
+      #ifndef WINNT
        (void) sigsetmask(saveMask);
+      #endif
      }
  #endif
  #endif
***************
*** 316,322 ****
  /*
   *******************************************************************************
   *
!  *  OpenFile --
   *
   *	Parses a command string for a file name and opens
   *	the file.
--- 328,334 ----
  /*
   *******************************************************************************
   *
!  *  AppOpenFile --
   *
   *	Parses a command string for a file name and opens
   *	the file.
***************
*** 330,336 ****
   */
  
  FILE *
! OpenFile(string, file)
      char *string;
      char *file;
  {
--- 342,348 ----
   */
  
  FILE *
! AppOpenFile(string, file)
      char *string;
      char *file;
  {
Only in m:\bind/tools/nslookup: winntport.txt
Only in m:\bind/tools/nslookup: yylex.c
Only in m:\bind: winntport.txt
