Replied: Sat, 26 Oct 1996 22:21:36 -0400
Replied: "schueman@ix.netcom.com "
Received: from copland.udel.edu by huey.udel.edu id aa06631; 26 Oct 96 3:19 EDT
Received: from dfw-ix11.ix.netcom.com (dfw-ix11.ix.netcom.com [206.214.98.11]) by copland.udel.edu (8.7.6/8.7.3) with SMTP id DAA28854 for <mills@udel.edu>; Sat, 26 Oct 1996 03:19:49 -0400 (EDT)
Received: from sverige (pas-ca13-13.ix.netcom.com [204.32.164.45]) by dfw-ix11.ix.netcom.com (8.6.13/8.6.12) with SMTP id AAA24869 for <mills@udel.edu>; Sat, 26 Oct 1996 00:19:04 -0700
Message-ID: <3271BAEE.6926@ix.netcom.com>
Date: Sat, 26 Oct 1996 00:17:02 -0700
From: Greg Schueman <schueman@ix.netcom.com>
Reply-To: schueman@ix.netcom.com
X-Mailer: Mozilla 3.0Gold (Win95; U)
MIME-Version: 1.0
To: mills@udel.edu
Subject: XNTP 3.5-86 NT patches

David,
   I'm finally in a position to finish the NT mods.
Here are the diffs against 3.5-86 to get a working NT version
again.

I plan to do two more things this Fall:
1. Add local clock support to the port
2. Redo build environment to use Autoconfig under NT
   (This depends on the Cygnus portability project to Windows NT,
    but they seem very close to what I need to do this.  Beta 17
    of their project should make this approach possible.)

Please include the diffs that are attached in your next 
release (3.5-87?).

-Greg Schueman

diff -N -x *.mak -c -r xntp3-5.86/blddbg.bat xntp/blddbg.bat
*** xntp3-5.86/blddbg.bat	Wed Dec 31 23:59:19 1969
--- xntp/blddbg.bat	Sat Oct 26 06:08:14 1996
***************
*** 1,6 ****
  @echo off
  REM
! REM File: buildalldbg.bat
  REM Purpose: To compile the XNTP source tree for Win NT.
  REM Date: 05/03/1996
  REM
--- 1,6 ----
  @echo off
  REM
! REM File: blddbg.bat
  REM Purpose: To compile the XNTP source tree for Win NT.
  REM Date: 05/03/1996
  REM
***************
*** 54,78 ****
  @echo -----------------------------------------
  @echo Compiling the service installer
  @echo -----------------------------------------
! @cd ..\util
  nmake  /f instsrv.mak CFG="instsrv - Win32 Debug"
  
  @echo -----------------------------------------
  @echo Compiling the InstallShield support DLL
  @echo -----------------------------------------
! @cd ..\scripts\wininstall
  nmake  /f ntpdll.mak CFG="ntpdll - Win32 Debug"
  
  @echo -----------------------------------------
  @echo Now copying all executables to the scripts\wininstall\distrib directory
  @echo -----------------------------------------
! @cd ..
  copy xntpd\windebug\*.exe    scripts\wininstall\distrib
  copy xntpdc\windebug\*.exe   scripts\wininstall\distrib
  copy ntpq\windebug\*.exe     scripts\wininstall\distrib
  copy ntpdate\windebug\*.exe  scripts\wininstall\distrib
  copy ntptrace\windebug\*.exe scripts\wininstall\distrib
! copy scripts\windebug\*.exe  scripts\wininstall\distrib
  @echo -----------------------------------------
  @echo -----------------------------------------
  @echo
--- 54,79 ----
  @echo -----------------------------------------
  @echo Compiling the service installer
  @echo -----------------------------------------
! @cd ..\scripts\wininstall\instsrv
  nmake  /f instsrv.mak CFG="instsrv - Win32 Debug"
  
  @echo -----------------------------------------
  @echo Compiling the InstallShield support DLL
  @echo -----------------------------------------
! @cd ..
  nmake  /f ntpdll.mak CFG="ntpdll - Win32 Debug"
  
  @echo -----------------------------------------
  @echo Now copying all executables to the scripts\wininstall\distrib directory
  @echo -----------------------------------------
! @cd ..\..
  copy xntpd\windebug\*.exe    scripts\wininstall\distrib
  copy xntpdc\windebug\*.exe   scripts\wininstall\distrib
  copy ntpq\windebug\*.exe     scripts\wininstall\distrib
  copy ntpdate\windebug\*.exe  scripts\wininstall\distrib
  copy ntptrace\windebug\*.exe scripts\wininstall\distrib
! copy scripts\wininstall\instsrv\windebug\*.exe  scripts\wininstall\distrib
! copy scripts\wininstall\windebug\*.dll  scripts\wininstall
  @echo -----------------------------------------
  @echo -----------------------------------------
  @echo
diff -N -x *.mak -c -r xntp3-5.86/bldrel.bat xntp/bldrel.bat
*** xntp3-5.86/bldrel.bat	Wed Dec 31 23:57:19 1969
--- xntp/bldrel.bat	Sat Oct 26 06:09:06 1996
***************
*** 1,6 ****
  @echo off
  REM
! REM File: buildallnt.bat
  REM Purpose: To compile the XNTP source tree for Win NT.
  REM Date: 05/03/1996
  REM
--- 1,6 ----
  @echo off
  REM
! REM File: bldrel.bat
  REM Purpose: To compile the XNTP source tree for Win NT.
  REM Date: 05/03/1996
  REM
***************
*** 54,66 ****
  @echo -----------------------------------------
  @echo Compiling the service installer
  @echo -----------------------------------------
! @cd ..\util
  nmake  /f instsrv.mak CFG="instsrv - Win32 Release"
  
  @echo -----------------------------------------
  @echo Compiling the InstallShield support DLL
  @echo -----------------------------------------
! @cd ..\scripts\wininstall
  nmake  /f ntpdll.mak CFG="ntpdll - Win32 Release"
  
  @echo -----------------------------------------
--- 54,66 ----
  @echo -----------------------------------------
  @echo Compiling the service installer
  @echo -----------------------------------------
! @cd ..\scripts\wininstall\instsrv
  nmake  /f instsrv.mak CFG="instsrv - Win32 Release"
  
  @echo -----------------------------------------
  @echo Compiling the InstallShield support DLL
  @echo -----------------------------------------
! @cd ..
  nmake  /f ntpdll.mak CFG="ntpdll - Win32 Release"
  
  @echo -----------------------------------------
***************
*** 72,78 ****
  copy ntpq\winrel\*.exe     scripts\wininstall\distrib
  copy ntpdate\winrel\*.exe  scripts\wininstall\distrib
  copy ntptrace\winrel\*.exe scripts\wininstall\distrib
! copy scripts\winrel\*.exe  scripts\wininstall\distrib
  @echo -----------------------------------------
  @echo -----------------------------------------
  @echo
--- 72,79 ----
  copy ntpq\winrel\*.exe     scripts\wininstall\distrib
  copy ntpdate\winrel\*.exe  scripts\wininstall\distrib
  copy ntptrace\winrel\*.exe scripts\wininstall\distrib
! copy scripts\wininstall\instsrv\winrel\*.exe  scripts\wininstall\distrib
! copy scripts\wininstall\winrel\*.dll  scripts\wininstall
  @echo -----------------------------------------
  @echo -----------------------------------------
  @echo
diff -N -x *.mak -c -r xntp3-5.86/html/build.html xntp/html/build.html
*** xntp3-5.86/html/build.html	Wed Dec 31 23:59:11 1969
--- xntp/html/build.html	Sat Oct 26 06:33:23 1996
***************
*** 121,135 ****
  
  <p>See the <code>./scripts/wininstall/readme.nt</code> file for
  directions to compile the sources, build the libraries and link the
! executables. This will compile all of the source and will create an
  <code>InstallShield</code> based graphical installation package.
  
  <p>To install the executables, make sure that you are logged in as a
  system account, or one with administrator privileges such as the
  "administrator" account. As part of the build an
  <code>InstallShield</code> based graphical installer was created. Run
! <code>\ntp\install\intel\disk1\setup.exe</code> to begin the
  installation. This installer will prompt for basic defaults, copy the
! binaries, install the service, and start it up.
  
  <hr><address>David L. Mills (mills@udel.edu)</address></body></html>
--- 121,138 ----
  
  <p>See the <code>./scripts/wininstall/readme.nt</code> file for
  directions to compile the sources, build the libraries and link the
! executables. Initiate the build by running either <code>bldrel.bat<code> 
! or <code>blddbg.bat<code> to compile all of the source and create an 
  <code>InstallShield</code> based graphical installation package.
  
  <p>To install the executables, make sure that you are logged in as a
  system account, or one with administrator privileges such as the
  "administrator" account. As part of the build an
  <code>InstallShield</code> based graphical installer was created. Run
! <code>\xntp\scripts\wininstall\intel\disk1\setup.exe</code> to begin the
  installation. This installer will prompt for basic defaults, copy the
! binaries, install the service, and start it up.  The other option is
! to run <code>\xntp\scripts\wininstall\distrib\install.bat</code> which
! will do the basic installation from the command line.
  
  <hr><address>David L. Mills (mills@udel.edu)</address></body></html>
diff -N -x *.mak -c -r xntp3-5.86/html/hints/winnt xntp/html/hints/winnt
*** xntp3-5.86/html/hints/winnt	Thu Jan 01 00:03:19 1970
--- xntp/html/hints/winnt	Mon Oct 21 01:58:01 1996
***************
*** 1,6 ****
--- 1,95 ----
  -------------
  INTRODUCTION:
  -------------
+ Last revision:  20-Oct-1996
+ 
+ This version corrects problems with building the XNTP 
+ version 3.5-86 distribution under Windows NT.
+ 
+ The following files were modified:
+ 	blddbg.bat
+ 	bldrel.bat
+ 	include\ntp_machine.h
+ 	xntpd\ntp_unixclock.c
+ 	xntpd\ntp_refclock.c
+ 	scripts\wininstall\build.bat
+ 	scripts\wininstall\setup.rul
+ 	scripts\wininstall\readme.nt
+ 	scripts\wininstall\distrib\ntpog.wri
+ 	html\hints\winnt (this file)
+ 
+ In order to build the entire Windows NT distribution you
+ need to modify the file scripts\wininstall\build.bat
+ with the installation directory of the InstallShield 
+ software.  Then, simply type "bldrel" for non-debug 
+ or "blddbg" for debug executables.
+ 
+ 
+ 
+ Greg Schueman
+     <schueman@acm.org>
+ 
+ 
+ Last revision:  07-May-1996
+ 
+ This set of changes fixes all known bugs, and it includes 
+ several major enhancements.
+ 
+ Many changes have been made both to the build environment as
+ well as the code.  There is no longer an ntp.mak file, instead
+ there is a buildntall.bat file that will build the entire 
+ release in one shot.  The batch file requires Perl.  Perl
+ is easily available from the NT Resource Kit or on the Net.
+ 
+ The multiple interface support was adapted from Larry Kahn's
+ work on the BIND NT port.  I have not been able to test it
+ adequately as I only have NT servers with one network 
+ interfaces on which to test.  
+ 
+ Enhancements:
+ *	Event Logging now works correctly.
+ *	Version numbers now work (requires Perl during build)
+ *	Support for multiple network interface cards (untested)
+ *	NTP.CONF now default, but supports ntp.ini if not found
+ *	Installation procedure automated.
+ *	All paths now allow environment variables such as %windir%
+ 
+ Bug fixes:
+ *	INSTSRV replaced, works correctly
+ *	Cleaned up many warnings
+ *	Corrected use of an uninitialized variable in XNTPD
+ *	Fixed ntpdate -b option
+ *	Fixed ntpdate to accept names as well as IP addresses
+         (Winsock WSAStartup was called after a gethostbyname())
+ *	Fixed problem with "longjmp" in xntpdc/ntpdc.c that 
+         caused a software exception on doing a Control-C in xntpdc.
+ 	A Cntrl-C now terminates the program. 
+ 
+ See below for more detail:
+ 
+       Note: SIGINT is not supported for any Win32 application including 
+       Windows NT and Windows 95. When a CTRL+C interrupt occurs, Win32 
+       operating systems generate a new thread to specifically handle that 
+       interrupt. This can cause a single-thread application such as UNIX, 
+       to become multithreaded, resulting in unexpected behavior. 
+ 
+ 
+ Possible enhancements and things left to do:
+ *	Reference clock drivers for NT (at least Local Clock support)
+ *	Control Panel Applet
+ *	InstallShield based installation, like NT BIND has
+ *	Integration with NT Performance Monitor
+ *	SNMP integration
+ *	Fully test multiple interface support
+ 
+ 
+ Known problems:
+ *       bug in ntptrace - if no Stratum 1 servers are available,
+                 such as on an IntraNet, the application crashes.
+ 
+ 
+ 
+ 
  Last revision:  12-Apr-1995
  
  
diff -N -x *.mak -c -r xntp3-5.86/include/ntp_machine.h xntp/include/ntp_machine.h
*** xntp3-5.86/include/ntp_machine.h	Wed Dec 31 23:59:30 1969
--- xntp/include/ntp_machine.h	Sun Oct 20 22:40:30 1996
***************
*** 194,203 ****
--- 194,209 ----
   * Windows NT 3.5
   */
  #if defined(SYS_WINNT)
+ # define STDC_HEADERS
+ # define NEED_S_CHAR_TYPEDEF
+ # define SIZEOF_SIGNED_CHAR 1
  # define HAVE_NO_NICE
  # define NOKMEM
+ # define PRESET_TICKADJ 50
  # define RETSIGTYPE void
  # define NTP_POSIX_SOURCE
+ # define HAVE_SETVBUF
+ # define HAVE_VSPRINTF
  # ifndef STR_SYSTEM
  #  define STR_SYSTEM "WINDOWS/NT3.5"
  # endif
diff -N -x *.mak -c -r xntp3-5.86/ntptrace/save xntp/ntptrace/save
*** xntp3-5.86/ntptrace/save	Thu Jan 01 00:00:01 1970
--- xntp/ntptrace/save	Thu Jan 01 00:00:00 1970
***************
*** 1,236 ****
- # Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
- # ** DO NOT EDIT **
- 
- # TARGTYPE "Win32 (x86) Console Application" 0x0103
- 
- !IF "$(CFG)" == ""
- CFG=ntptrace - Win32 Debug
- !MESSAGE No configuration specified.  Defaulting to ntptrace - Win32 Debug.
- !ENDIF 
- 
- !IF "$(CFG)" != "ntptrace - Win32 Release" && "$(CFG)" !=\
-  "ntptrace - Win32 Debug"
- !MESSAGE Invalid configuration "$(CFG)" specified.
- !MESSAGE You can specify a configuration when running NMAKE on this makefile
- !MESSAGE by defining the macro CFG on the command line.  For example:
- !MESSAGE 
- !MESSAGE NMAKE /f "ntptrace.mak" CFG="ntptrace - Win32 Debug"
- !MESSAGE 
- !MESSAGE Possible choices for configuration are:
- !MESSAGE 
- !MESSAGE "ntptrace - Win32 Release" (based on\
-  "Win32 (x86) Console Application")
- !MESSAGE "ntptrace - Win32 Debug" (based on "Win32 (x86) Console Application")
- !MESSAGE 
- !ERROR An invalid configuration is specified.
- !ENDIF 
- 
- !IF "$(OS)" == "Windows_NT"
- NULL=
- !ELSE 
- NULL=nul
- !ENDIF 
- ################################################################################
- # Begin Project
- # PROP Target_Last_Scanned "ntptrace - Win32 Debug"
- RSC=rc.exe
- CPP=cl.exe
- 
- !IF  "$(CFG)" == "ntptrace - Win32 Release"
- 
- # PROP BASE Use_MFC 0
- # PROP BASE Use_Debug_Libraries 0
- # PROP BASE Output_Dir "Release"
- # PROP BASE Intermediate_Dir "Release"
- # PROP BASE Target_Dir ""
- # PROP Use_MFC 0
- # PROP Use_Debug_Libraries 0
- # PROP Output_Dir "Release"
- # PROP Intermediate_Dir "Release"
- # PROP Target_Dir ""
- OUTDIR=.\Release
- INTDIR=.\Release
- 
- ALL : "$(OUTDIR)\ntptrace.exe"
- 
- CLEAN : 
- 	-@erase ".\Release\ntptrace.exe"
- 	-@erase ".\Release\ntptrace.obj"
- 
- "$(OUTDIR)" :
-     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
- 
- # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
- # ADD CPP /nologo /MLd /W3 /GX /O2 /I "..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "SYS_WINNT" /YX /c
- CPP_PROJ=/nologo /MLd /W3 /GX /O2 /I "..\include" /D "NDEBUG" /D "WIN32" /D\
-  "_CONSOLE" /D "SYS_WINNT" /Fp"$(INTDIR)/ntptrace.pch" /YX /Fo"$(INTDIR)/" /c 
- CPP_OBJS=.\Release/
- CPP_SBRS=
- # ADD BASE RSC /l 0x409 /d "NDEBUG"
- # ADD RSC /l 0x409 /d "NDEBUG"
- BSC32=bscmake.exe
- # ADD BASE BSC32 /nologo
- # ADD BSC32 /nologo
- BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntptrace.bsc" 
- BSC32_SBRS=
- LINK32=link.exe
- # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
- # ADD LINK32 ..\lib\windebug\libntp.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
- # SUBTRACT LINK32 /nodefaultlib
- LINK32_FLAGS=..\lib\windebug\libntp.lib wsock32.lib kernel32.lib user32.lib\
-  gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib\
-  oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console\
-  /incremental:no /pdb:"$(OUTDIR)/ntptrace.pdb" /machine:I386\
-  /out:"$(OUTDIR)/ntptrace.exe" 
- LINK32_OBJS= \
- 	"$(INTDIR)/ntptrace.obj"
- 
- "$(OUTDIR)\ntptrace.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-     $(LINK32) @<<
-   $(LINK32_FLAGS) $(LINK32_OBJS)
- <<
- 
- !ELSEIF  "$(CFG)" == "ntptrace - Win32 Debug"
- 
- # PROP BASE Use_MFC 0
- # PROP BASE Use_Debug_Libraries 1
- # PROP BASE Output_Dir "Debug"
- # PROP BASE Intermediate_Dir "Debug"
- # PROP BASE Target_Dir ""
- # PROP Use_MFC 0
- # PROP Use_Debug_Libraries 1
- # PROP Output_Dir "Debug"
- # PROP Intermediate_Dir "Debug"
- # PROP Target_Dir ""
- OUTDIR=.\Debug
- INTDIR=.\Debug
- 
- ALL : "$(OUTDIR)\ntptrace.exe" "$(OUTDIR)\ntptrace.bsc"
- 
- CLEAN : 
- 	-@erase ".\Debug\vc40.pdb"
- 	-@erase ".\Debug\vc40.idb"
- 	-@erase ".\Debug\ntptrace.bsc"
- 	-@erase ".\Debug\ntptrace.sbr"
- 	-@erase ".\Debug\ntptrace.exe"
- 	-@erase ".\Debug\ntptrace.obj"
- 	-@erase ".\Debug\ntptrace.ilk"
- 	-@erase ".\Debug\ntptrace.pdb"
- 
- "$(OUTDIR)" :
-     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
- 
- # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
- # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "SYS_WINNT" /FR /YX /c
- CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\include" /D "_DEBUG" /D\
-  "WIN32" /D "_CONSOLE" /D "SYS_WINNT" /FR"$(INTDIR)/"\
-  /Fp"$(INTDIR)/ntptrace.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c 
- CPP_OBJS=.\Debug/
- CPP_SBRS=.\Debug/
- # ADD BASE RSC /l 0x409 /d "_DEBUG"
- # ADD RSC /l 0x409 /d "_DEBUG"
- BSC32=bscmake.exe
- # ADD BASE BSC32 /nologo
- # ADD BSC32 /nologo
- BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntptrace.bsc" 
- BSC32_SBRS= \
- 	"$(INTDIR)/ntptrace.sbr"
- 
- "$(OUTDIR)\ntptrace.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
-     $(BSC32) @<<
-   $(BSC32_FLAGS) $(BSC32_SBRS)
- <<
- 
- LINK32=link.exe
- # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
- # ADD LINK32 ..\lib\windebug\libntp.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
- # SUBTRACT LINK32 /nodefaultlib
- LINK32_FLAGS=..\lib\windebug\libntp.lib wsock32.lib kernel32.lib user32.lib\
-  gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib\
-  oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console\
-  /incremental:yes /pdb:"$(OUTDIR)/ntptrace.pdb" /debug /machine:I386\
-  /out:"$(OUTDIR)/ntptrace.exe" 
- LINK32_OBJS= \
- 	"$(INTDIR)/ntptrace.obj"
- 
- "$(OUTDIR)\ntptrace.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-     $(LINK32) @<<
-   $(LINK32_FLAGS) $(LINK32_OBJS)
- <<
- 
- !ENDIF 
- 
- .c{$(CPP_OBJS)}.obj:
-    $(CPP) $(CPP_PROJ) $<  
- 
- .cpp{$(CPP_OBJS)}.obj:
-    $(CPP) $(CPP_PROJ) $<  
- 
- .cxx{$(CPP_OBJS)}.obj:
-    $(CPP) $(CPP_PROJ) $<  
- 
- .c{$(CPP_SBRS)}.sbr:
-    $(CPP) $(CPP_PROJ) $<  
- 
- .cpp{$(CPP_SBRS)}.sbr:
-    $(CPP) $(CPP_PROJ) $<  
- 
- .cxx{$(CPP_SBRS)}.sbr:
-    $(CPP) $(CPP_PROJ) $<  
- 
- ################################################################################
- # Begin Target
- 
- # Name "ntptrace - Win32 Release"
- # Name "ntptrace - Win32 Debug"
- 
- !IF  "$(CFG)" == "ntptrace - Win32 Release"
- 
- !ELSEIF  "$(CFG)" == "ntptrace - Win32 Debug"
- 
- !ENDIF 
- 
- ################################################################################
- # Begin Source File
- 
- SOURCE=.\ntptrace.c
- DEP_CPP_NTPTR=\
- 	{$(INCLUDE)}"\sys\TYPES.H"\
- 	".\..\include\ntp_select.h"\
- 	".\..\include\ntp_fp.h"\
- 	".\..\include\ntp.h"\
- 	".\..\include\ntp_io.h"\
- 	".\..\include\ntp_unixtime.h"\
- 	".\ntptrace.h"\
- 	".\..\include\ntp_string.h"\
- 	".\..\include\ntp_stdlib.h"\
- 	".\..\include\ntp_syslog.h"\
- 	".\..\include\ntp_types.h"\
- 	".\..\include\ntp_machine.h"\
- 	{$(INCLUDE)}"\sys\TIMEB.H"\
- 	".\..\include\l_stdlib.h"\
- 	
- NODEP_CPP_NTPTR=\
- 	".\..\include\gizmo_syslog.h"\
- 	
- 
- !IF  "$(CFG)" == "ntptrace - Win32 Release"
- 
- 
- "$(INTDIR)\ntptrace.obj" : $(SOURCE) $(DEP_CPP_NTPTR) "$(INTDIR)"
- 
- 
- !ELSEIF  "$(CFG)" == "ntptrace - Win32 Debug"
- 
- 
- "$(INTDIR)\ntptrace.obj" : $(SOURCE) $(DEP_CPP_NTPTR) "$(INTDIR)"
- 
- "$(INTDIR)\ntptrace.sbr" : $(SOURCE) $(DEP_CPP_NTPTR) "$(INTDIR)"
- 
- 
- !ENDIF 
- 
- # End Source File
- # End Target
- # End Project
- ################################################################################
--- 0 ----
Binary files xntp3-5.86/scripts/wininstall/SETUP.DBG and xntp/scripts/wininstall/SETUP.DBG differ
Binary files xntp3-5.86/scripts/wininstall/SETUP.INS and xntp/scripts/wininstall/SETUP.INS differ
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/SETUP.RUL xntp/scripts/wininstall/SETUP.RUL
*** xntp3-5.86/scripts/wininstall/SETUP.RUL	Thu Jan 01 00:01:02 1970
--- xntp/scripts/wininstall/SETUP.RUL	Thu Jan 01 00:00:00 1970
***************
*** 1,788 ****
- /*---------------------------------------------------------------------------*\
-  *  Fileg Name:  SETUP.RUL
-  *
-  *  Description:  XNTP - NT Install, BIND version by Larry Kahn... using ideas 
-  *   from Paul Wren's (PIW) version.  Reworked by Greg Schueman for XNTP.
-  *
- \* ----------------------------------------------------------------------------*/
- declare
- 	// Constant declarations.
- 	#define SPACE_REQUIRED          1300000          // Disk space in bytes.
- 	#define APP_NAME                "NetworkTimeProtocol"
- 	#define APP_NAME2               "XNTP 3.5f Freeware"
- 	#define APPBASE_PATH            "\\var\\ntp\\"
- 	#define PRODUCT_VERSION         "3.5fRel"
- 	#define DEINSTALL_KEY           "NTP3.5f"
- 	#define UNINSTALL_NAME          "NTP"
- 	#define PRODUCT_KEY             "xntpd.exe"
- 	#define NTP_PORT                123
- 	#define ONETIMESOURCE           1
- 	#define TWOTIMESOURCES          2
- 	#define NOTIMEYET               3
- 	
- 	// Global variable declarations
- 	STRING  svDir, szMsg, szFileSet,szTitle,  szMessage, svUninstLogFile;
- 	STRING  szProgram, szParam, szTemp, szTemp2, szAppPath;
- 	STRING  svFileName;
- 	STRING  svTempStr;
-     STRING  svModuleDir;
-     STRING  svAnswer;
-     STRING  dummy;
- 	
- 	BOOL    bRemoveNTP, bUpdateModules;
- 	
- 
- 	STRING  svNTPAddress;                   // the IP address of "1st" time source
- 	STRING  svNTPAddress2;                  // the IP address of "2nd" time source
- 	STRING  szDllNTPInst;
- 	NUMBER  nReturnValue;
-     INT     nReturnValue2;
-     INT     nValue;
- 	
- 	//--------Custom Dialog in Ishield-------------------------
- 	BOOL bDone;
- 	LIST lNames, lAddrs;
- 
- 	//------- NTPInst.DLL defines------------------------
- 	#define k_PrivilegeErr                  1
- 	#define k_CreateKeyErr                  2
- 	#define k_RestoreKeyErr                 3
- 	#define k_ErrUnableToOpenWriteOwner     4
- 	#define k_ErrUnableToSetOwner           5
- 	#define k_ErrUnableToOpenDAC            6
- 	#define k_ErrUnableToWriteDACL          7
- 	#define k_OpenKeyError                  8
- 	#define k_ModifySetAccountFail          10
- 	#define k_SCMErr                        11
- 	#define k_SCMpoErr                      12
- 	#define k_DeleteServiceFail             13
- 	#define k_DeleteKeyFail                 14
- 	#define k_DeleteValueFail               15
- 	#define k_DirSecurityErr                16
- 	#define k_DirSetDACLErr                 17
- 	#define k_DirSetSecurityErr             18
- 	#define k_SCMpoStopErr                  19
- 	#define k_SaveKeyErr                    20
- 	#define k_ServiceUnknownErr             50
- 	#define k_ServiceDependency             51
- 	#define k_ServiceDependencyFail         52
- 	#define k_ServiceLogonFail              53
- 
-     #define k_BadPath                       101
- 	#define k_AccessDenied                  102
- 	#define k_ServiceExists                 103
-     #define k_createservicefailed           104
-     #define k_removeservicefailed           105
- 	#define k_ServicenoExists               106
- 	
- 	//--------Function declarations----------------------------
- 	prototype SetupScreen                   ();
- 	prototype CheckRequirements             ();
- 	prototype RemoveNTP                     ();
- 	prototype UpdateModules                 ();
- 	
- 	prototype ReportError                   (INT, BYREF STRING);
- 	prototype DoConfigType                  ();
- 	prototype CreateConfigFiles             (INT);
- 	prototype InstallNTPFiles               (STRING, INT);
- 	prototype RegisterEventlogMessages	    (STRING);
-     prototype CheckForService               ();
-     prototype GetImagePath                  (BYREF STRING);
-     prototype LaunchAppAndWait              (STRING,STRING, INT);
-     prototype ReverseOctet                  (BYREF STRING, STRING);
-     prototype FixDirectory                  (BYREF STRING, STRING);
-        
- 
- //--------------------------------------------------------------------------
- program
- 
- StartHere:
-     Disable( BACKGROUND );
- 
-     dummy = "   ";
-     // Set default registry tree
-     RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
- 
-     // Set up the installation screen.
-     SetupScreen();
-     Enable( DIALOGCACHE );
- 
- 	TARGETDIR = SUPPORTDIR;
- 	szDllNTPInst = SUPPORTDIR ^ "NTPDLL.DLL";  // NTP-specific helper library
- 
-     svDir = WINSYSDISK + "\\";
-     
-     // Module locations, XNTP - NT location
- 	svModuleDir = WINDISK^"\\win32app\\ntp";
- 
- 
- OfferReadmeFile:
- 
- if (AskYesNo("Would you like to see the readme file before proceeding? \n",NO ) = YES) then
- 	LaunchAppAndWait("NOTEPAD",SUPPORTDIR ^ "README.NT",1);
- endif;
- 	
- CheckForService1:
-     // Look for service
-     if (CheckForService() != 0) then                    // Not clean install
- 	Disable(BACKBUTTON);
- 		bUpdateModules = TRUE;
- 	szMessage = "Setup has determined that the NTP - NT service is\n" +
- 		    "already present.  Do you want to:\n";
- 	AskOptions(EXCLUSIVE, szMessage,
-                 
- 		   "&Remove NTP service", bRemoveNTP,
- 		   "&Update NTP to this version", bUpdateModules);
- 				   
- 	Enable(BACKBUTTON);
- 	if (bRemoveNTP) then
- 		if (AskYesNo("Are you certain you wish to remove the NTP service\n" +
- 				 "and registry entries? \n",NO ) = YES) then
- 		   RemoveNTP();
- 		endif;
- 	endif;
- 	if (bUpdateModules) then
- 			UpdateModules();
- 	endif;
- 	exit;
-     endif;           
- // install drops through
- 
- DoCleanInstall:
- 
-     // Defaults
- 
-     // Create a Welcome dialog.
- WelcomeDlg:
-     Disable( BACKBUTTON );
-     Welcome( "", 0 );
-     Enable( BACKBUTTON );
-  
-     // Test target system for proper configuration.
-     CheckRequirements();
- 
- ModuleDir:  
-     if (AskDestPath("Network Time Protocol Server program file location",
- 		    "Choose the directory for storage of the NTP support files",
- 		    svModuleDir,0) = BACK) then
-        goto WelcomeDlg;
-     endif;
- 	
- ThatsItDoIt:    
-     
- 	InstallNTPFiles(svModuleDir,0);  // uncompress & place files in directories
- 	
- GetConfigurationType:
-     Disable(BACKBUTTON);
- 	TARGETDIR = svModuleDir;                // point back to ntp directory
- 
- 	SetStatusWindow( 85, "Creating Configuration Files..." );
- 	DoConfigType();                         // do the configuration for user-spec'd type
-     Enable(BACKBUTTON);
- 
- RegistryInit:
- 
- 	SetStatusWindow( 90, "Creating NTP Service..." );
-     
- CreateService:
-         // was svModuleDir^"\\xntpd.exe"
-         nReturnValue2 = CallDLLFx(szDllNTPInst,"CreateNTPService",nValue,WINSYSDIR^"\\xntpd.exe");
- 	if (nReturnValue2 != 0) then
- 		ReportError(nReturnValue2,szMessage);
- 		szMessage = "Unable to install NTP - NT Service entry in Service Control Manager.\n" + szMessage;
- 		MessageBox(szMessage,SEVERE);
- 		exit;
- 	endif;
- 
- 
- 	SetStatusWindow( 95, "Adding Additional Registry Keys..." );
- 
-         nReturnValue2 = CallDLLFx(szDllNTPInst,"addKeysToRegistry",nValue,dummy);
- 	if (nReturnValue2 != 0) then
- 		szMessage = "Unable to add the Depend on service key in the NT registry\n";
- 		MessageBox(szMessage,SEVERE);
- 		exit;
- 	endif;
- 
- 
- 	SetStatusWindow( 98, "Starting the Service..." );
- 
- StartService:
-     nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);
-     if (nReturnValue2 != 0) then
- 		ReportError(nReturnValue2,szMessage);
- 		szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;
- 		MessageBox(szMessage,SEVERE);
- 		exit;
-     endif;
- 
-    	// Announce setup complete and offer to read README file.e
-    	FinalInstallProcess:
-    	SetStatusWindow( 100, "Installation complete." );
-    	Delay( 2 );
- 
-    	if (AskYesNo("Setup is complete.  The NTP service is running.\n"+
- 				"Do you want to look at the documentation for NTP?\n",
- 				 YES) = YES) then
- 	    LaunchAppAndWait("WRITE.EXE",TARGETDIR ^ "ntpog.wri",1);
-    	endif;
- exit;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  InstallNTPFiles()
-  *
-  *  Purpose:  Uncompress the IShield package, and put files in the directory
-  *            passed as an argument.
-  *
-  *              This function used both for new installations, and for the 
-  *              "update modules" function.
-  *
- \*---------------------------------------------------------------------------*/
- function InstallNTPFiles(svInstDir,updateonly)
- 	NUMBER  nResult;
- 	STRING szBitmapPath;
- begin
- 	// szBitmapPath = SUPPORTDIR^"ishield.bmp";
- 	// PlaceBitmap(szBitmapPath,1,10,10,UPPER_RIGHT);
- 
- 	// Insure that directories have sufficient permissions
- 	//	ReleaseModuleDirSecurity(svInstDir);
-     
- 	szFileSet = "NetworkTimeProtocolServer";
- 	FileSetBeginDefine(szFileSet);
- 
- 	TARGETDIR = WINSYSDIR;
- 	SetStatusWindow( -1, "Copying modules..." );
-     //	MessageBox("decompressing data.z: sourcedir = " + SRCDIR + " target dir = " +
-     //                  TARGETDIR,INFORMATION);
-     //  change this to comp update date eventually
- 
-     if (updateonly != 0)  // update case
-     then
- 	  // uncomment if adding a Control Panel Applet to package
-  	  //nResult = CompressGet("data.z","*.cpl",COMP_UPDATE_DATE);
-       //if (nResult < 0) then
-       //   NumToStr( szTemp, nResult );
- 	  //   MessageBox("File Decompression1 failed! ecode = " + szTemp, SEVERE);
- 	  //   exit;
- 	  // endif;
- 
-  	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
-       if (nResult < 0) then
-          NumToStr( szTemp, nResult );
- 		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
- 		 exit;
- 	  endif;
- 
-     else // not update install all
-  	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
-       if (nResult < 0) then
-          NumToStr( szTemp, nResult );
- 		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
- 		 exit;
- 	  endif;
- 
- 	  TARGETDIR = svInstDir;  // set destination directory
- 
-  	  nResult = CompressGet("data.z","readme.nt",COMP_UPDATE_DATE);
-       if (nResult < 0) then
-          NumToStr( szTemp, nResult );
- 		 MessageBox("File Decompression3 failed! ecode = " + szTemp, SEVERE);
- 		 exit;
-       endif;
- 
-  	  nResult = CompressGet("data.z","ntpog.wri",COMP_UPDATE_DATE);
-       if (nResult < 0) then
-          NumToStr( szTemp, nResult );
- 		 MessageBox("File Decompression4 failed! ecode = " + szTemp, SEVERE);
- 		 exit;
-       endif;
- 
-     endif; // Decompress File end
- 
- 	FileSetEndDefine(szFileSet);
- 	
-     // Set up progress indicator and information gauge.
-     Disable( DIALOGCACHE );
-     Enable( STATUSDLG );
- 
-     StatusUpdate( ON, 80 );
- 
-     // Perform the file set.
-     SetStatusWindow( 0, "Copying program files..." );
-     nResult = FileSetPerformEz( szFileSet, 0 );
- 
-     switch (nResult)
- 	    case FS_DONE:      // Successful completion.
- 	    case FS_CREATEDIR: // Create directory error.
- 		MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
- 			"Please check write access to this directory.", SEVERE );
- 		exit;
- 	default:               // Group all other errors under default label.
- 		NumToStr( szTemp, nResult );
- 		MessageBox( "General file transfer error."+
- 			"Please check your target location and try again."+
- 			"\n\n Error Number:"+ szTemp +
- 			"\n Related File: "+ ERRORFILENAME,SEVERE);
- 		exit;
-     endswitch;
- 	
- 	RegisterEventlogMessages(svInstDir);	// put EventLog reg entries in
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  RegisterEventlogMessages
-  *
-  *  Purpose:  Put an entry under the Eventlog registry information, so that
-  *            it understands where to find messages that come from NTP.
-  *
-  *  History:  PIW	Created		12/14/95
-  *
- \*---------------------------------------------------------------------------*/
- #define	EVENTLOG_ENTRY "\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\NTP"
- #define	SERVICE_ENTRY  "\\SYSTEM\\CurrentControlSet\\Services\\NetworkTimeProtocol"
- 
- function RegisterEventlogMessages(svTemp)
- 	NUMBER nvSize;
- begin
- 	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
- 	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"EventMessageFile",
- 				REGDB_STRING,svTemp^"xntpd.exe",nvSize);
- 	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"TypeSupported",REGDB_NUMBER,"7",nvSize);
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  DoConfigType
-  *
-  *  Purpose:  Find out what type of installation the user is planning,
-  *            and then create and/or show the configuration files to them.
-  *
- \*---------------------------------------------------------------------------*/
- function DoConfigType()
- 	BOOL bSingleSourceNTP,bSecondarySourceNTP, bNoSourceNTP;
- begin
- 	bSingleSourceNTP = FALSE;
- 	bSecondarySourceNTP = TRUE;
- 	bNoSourceNTP = FALSE;
-     szMessage = "For creation of configuration files, please select the setup\n" +
- 		"you want for NTP.  Do you want to set up a:\n";
-     AskOptions(EXCLUSIVE, szMessage,
- 	       "&Single Time Source", bSingleSourceNTP,
- 	       "&Two Time Sources", bSecondarySourceNTP,
- 		   "&Specify No Time Sources", bNoSourceNTP);
- 			   
-     Enable(BACKBUTTON);
-     if (bSingleSourceNTP) then
- 	    szMessage = "Please enter the IP address of the Time Source.\n";
- 	    AskText(szMessage, svNTPAddress, svNTPAddress);
- 		CreateConfigFiles(ONETIMESOURCE);   // create ntp.conf
-     endif;
- 	
-     if (bSecondarySourceNTP) then
- 	    szMessage = "Please enter the IP address of the First Time Source from\n" +
- 		    "which you will RECEIVE synchronization\n";
- 	    AskText(szMessage, svNTPAddress, svNTPAddress);
- 		szMessage = "Please enter the IP address of the Second Time Source from\n" +
- 			"which you will RECEIVE synchronization\n";
- 		AskText(szMessage, svNTPAddress2, svNTPAddress2);
- 		CreateConfigFiles(TWOTIMESOURCES);   // create ntp.conf
-     endif;
- 	
- 	if (bNoSourceNTP) then
- 		CreateConfigFiles(NOTIMEYET);   // create ntp.conf and ntp.drift
- 	endif;          
- 	
-     if (AskYesNo("Do you want to see the NTP configuration file which has\n" + 
- 		     "been created for this host?\n", YES) = YES) then
- 		// Let them see/edit the files, if they want to:
- 		LaunchAppAndWait("NOTEPAD.EXE", WINDIR ^ "ntp.conf",1);
- 	endif;
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  CreateConfigFiles
-  *
-  *  Purpose:  Now that we know the domain name, host name, and IP Address,
-  *            create the configuration files for this NTP to be of type 
-  *            specified by parameter:
-  *                                  ONETIMESOURCE
-  *                                  TWOTIMESOURCES
-  *                                  NOTIMEYET
-  *                        
-  *
-  *    Need to have filled in:  
-  *                              svNTPAddress
-  *                              svNTPAddress2
-  *
- \*---------------------------------------------------------------------------*/
- function CreateConfigFiles(nType)
- 	NUMBER nvFileHandle;
- 	STRING svInAddrArpa;
-         STRING saveddir;
-         STRING svIP;
- begin
- 
-     CreateFile(nvFileHandle,WINDIR,"ntp.conf");
-     WriteLine(nvFileHandle,"#");
-     WriteLine(nvFileHandle,"#    File:       ntp.conf");
-     WriteLine(nvFileHandle,"#    Purpose:    give the NTP Service its startup parameters and");
-     WriteLine(nvFileHandle,"#                list of startup files.");
-     WriteLine(nvFileHandle,"# ");
-     WriteLine(nvFileHandle,"# ");
- 
- 	WriteLine(nvFileHandle,"#");
- 	WriteLine(nvFileHandle,"# Miscellaneous stuff");
- 	WriteLine(nvFileHandle,"#");
- 	WriteLine(nvFileHandle,"driftfile %windir%\\ntp.drift        # path for drift file");
- 	WriteLine(nvFileHandle,"# statsdir c:\\var\\ntp\\stats\\     # directory for statistics files");
- 	WriteLine(nvFileHandle,"# filegen peerstats file peerstats type day enable");
- 	WriteLine(nvFileHandle,"# filegen loopstats file loopstats type day enable");
- 	WriteLine(nvFileHandle,"# filegen clockstats file clockstats type day enable");
- 
- 	if (nType != NOTIMEYET) then 
- 	    WriteLine(nvFileHandle,"#    Need to set up time sources...");
- 	    WriteLine(nvFileHandle,"#    server ip-address");
-         WriteLine(nvFileHandle,"# ");
- 	    WriteLine(nvFileHandle,"# ");
- 	endif;  
- 	
- 	
- 	if (nType = TWOTIMESOURCES) then 
- 		WriteLine(nvFileHandle,"# ");
- 		WriteLine(nvFileHandle,"server " + svNTPAddress);
- 	    WriteLine(nvFileHandle,"server " + svNTPAddress2);
-         WriteLine(nvFileHandle,"# ");
-   	    WriteLine(nvFileHandle,"# ");
- 	endif;
- 
- 	if (nType = ONETIMESOURCE) then
- 		WriteLine(nvFileHandle," ");
- 		WriteLine(nvFileHandle,"server " + svNTPAddress);
-         WriteLine(nvFileHandle," ");
-   	    WriteLine(nvFileHandle," ");
- 	endif;
-     
-     CloseFile(nvFileHandle);
- 	
- 	CreateFile(nvFileHandle,WINDIR,"ntp.drift");
-     WriteLine(nvFileHandle,"0 0");
- 	CloseFile(nvFileHandle);
- 
- end;    
- 
- 	
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  SetupScreen
-  *
-  *  Purpose:  This function will set up the screen look.  This includes
-  *            colors, fonts, text to be displayed, etc.
-  *
- \*---------------------------------------------------------------------------*/
- function SetupScreen()
- 	INT nDx, nDy;
- begin
- 	Enable( DEFWINDOWMODE );
-     Enable( INDVFILESTATUS );
- 
- 	//----------------------------------------------------------
- 	//      If you want to downsize the Blue-fade background:
- 	//
- 	//      GetExtents(nDx,nDy);
- 	//
- 	//      
- 	//      PlaceWindow(BACKGROUND,nDx/2,0,UPPER_LEFT);
- 	//      SizeWindow(BACKGROUND,nDx/2,nDy/2);
- 	//
- 	//  However will also have to move all the dialogs/bitmaps
- 	//  around to make this work correctly...
- 	//----------------------------------------------------------
- 	
-     SetTitle( APP_NAME2 + " Setup", 24, WHITE );
- 
- //    SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
- //    SetColor( STATUSBAR, BLUE );     // Bright blue.
-     SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
- 
-     Enable( BACKGROUND );
-     Delay( 1 );
- 
-    // Show the bitmap.
-    // PlaceBitmap( SUPPORTDIR ^ "NTPNT.BMP",1,10,10,UPPER_RIGHT);
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  * Function:  CheckRequirements
-  *  Purpose:  This function will make sure we are on NT, not Win95.
- \*---------------------------------------------------------------------------*/
- function CheckRequirements()
- 	number nvVersion;
- 	STRING szResult, svVersion;
- begin
-     // Determine the target system's operating system.
-     GetSystemInfo( OS, nvVersion, svVersion );
-     if (nvVersion =  IS_WINDOWSNT) then
- 
- 	    MessageBox("This product can only run on Windows NT",SEVERE);
- 		exit;
-     endif;
- end;
- 
- //+---------------------------------------------------------------------------
- //  Member:             ReportError()
- //----------------------------------------------------------------------------
- function ReportError(n_Err, sz_Message)
- 
- begin
-   switch(n_Err)
- 	case k_PrivilegeErr:              sz_Message = "Privilege Error";
- 	case k_CreateKeyErr:              sz_Message = "Create Key Failed";
- 	case k_RestoreKeyErr:             sz_Message = "Restore Default Key Failed";
- 	case k_ErrUnableToOpenWriteOwner: sz_Message = "Unable to Open and Write Owner Information";
- 	case k_ErrUnableToSetOwner:       sz_Message = "Unable to Set Owner Information";
- 	case k_ErrUnableToOpenDAC:        sz_Message = "Unable to Open Access Control List";
- 	case k_ErrUnableToWriteDACL:      sz_Message = "Unable to Write Access Control List";
- 	case k_OpenKeyError:              sz_Message = "Unable to Open Registry Key Entry";
- 	case k_ModifySetAccountFail:      sz_Message = "Unable to Setup Account Parameters";
- 	case k_SCMErr:                    sz_Message = "Unable to Open Service Control Manager Database";
- 	case k_SCMpoErr:                  sz_Message = "Unable to Open NTP - NT service entries in the Service Control Manager";
- 	case k_DeleteServiceFail:         sz_Message = "Unable to delete NTP - NT service";
- 	case k_DeleteKeyFail:             sz_Message = "Unable to delete registry key information";
- 	case k_DeleteValueFail:           sz_Message = "Unable to delete registry value information";
- 	case k_DirSecurityErr:            sz_Message = "Unable to retreive Security information on directory";
- 	case k_DirSetDACLErr:             sz_Message = "Unable to add security information on directory";
- 	case k_DirSetSecurityErr:         sz_Message = "Unable to set directory security information";
- 	case k_SCMpoStopErr:              sz_Message = "Unable to stop the NTP - NT service";
- 	case k_SaveKeyErr:                sz_Message = "Unable to save registry key.";
- 	case k_ServiceUnknownErr:         sz_Message = "The service control manager could not start the NTP - NT service - please check the event log";
- 	case k_ServiceDependency:         sz_Message = "The NTP - NT service depends on several other services which are not installed.";
- 	case k_ServiceDependencyFail:     sz_Message = "The NTP - NT service depends on other services which failed to start.";
- 	case k_ServiceLogonFail:          sz_Message = "The service manager was unable to login the NTP - NT service - Please check the password and logon as service privilege";
-     case k_BadPath:                   sz_Message = "Bad Path Specified."; 
- 	case k_AccessDenied:              sz_Message = "Access Denied.";
- 	case k_ServiceExists:             sz_Message = "NTP - NT service already exists so cannot be re-installed";
-     case k_createservicefailed:       sz_Message = "Creation of the NTP - NT service failed.";
-     case k_removeservicefailed:       sz_Message = "Unable to remove the NTP - NT service.";
- 	case k_ServicenoExists:           sz_Message = "NTP - NT service is not installed so cannot be removed.";
- 	default:                          sz_Message = "Unknown Error";
-   endswitch;
- end;
- 
- //+---------------------------------------------------------------------------
- //
- //  Member:             RemoveNTP()
- //
- //  Synopsis:   Remove the NTP service entry and registry entries
- //
- //----------------------------------------------------------------------------
- function RemoveNTP()
- 	NUMBER n_Result;
- begin
- 	
-     dummy = APP_NAME;
-     SetStatusWindow( 0, "Stopping and removing NTP service..." );
- 	// Remove the NTP service entry & Registry but first stop the service
-  
-         nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
- 
- 	if (nReturnValue2 != 0) then
- 		ReportError(nReturnValue2,szMessage);
- 		NumToStr( szTemp, nReturnValue2 );
- 		szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is installed?\n" + szMessage;
- 		MessageBox(szMessage,SEVERE);
- 		exit;
- 	endif;
-    	Delay( 3 ); // delay for xntpd.exe file to free up so delete works
- 
- 
-   	// have to get the currently install directory from the dll by pulling it off of the imagepath param
-     //if (GetImagePath(svModuleDir) != 0) then
- 	//    szMessage = "Unable to retrieve the path to Remove NTP Files \n" + svModuleDir + 
-     //                    "\nAre you sure it is installed?\n";
- 	//    MessageBox(szMessage,SEVERE);
- 	//    exit;
- 	//endif;
- 
- 	n_Result = CallDLLFx(szDllNTPInst,"RemoveNTPService",nValue,dummy);
- 
- 	if (n_Result != 0) then            
- 		MessageBox("Unable to remove NTP - NT service from the registry.",SEVERE);
-                 exit;
- 	else
- 	    if (AskYesNo("Service Removed\n Do you want to delete all the NTP Executables and config files also?\n",
- 				 NO) = YES) then
- 
- 			TARGETDIR = WINSYSDIR;                  // pick off the files we put in the 
- 			DeleteFile("ntpdate.exe");
- 			DeleteFile("ntpq.exe");
- 			DeleteFile("ntptrace.exe");
- 			DeleteFile("xntpdc.exe");
- 			DeleteFile("xntpd.exe");
- 			DeleteFile("instsrv.exe");
- 
- 			TARGETDIR = svModuleDir;
- 			DeleteFile("ntpog.wri");
- 			DeleteFile("readme.nt");
- 			DeleteDir(svModuleDir, ONLYDIR);
- 									
- 
-             TARGETDIR = WINDIR;
-             DeleteFile("ntp.conf");
-             DeleteFile("ntp.drift");
- 
- 			MessageBox("NTP - NT service and registry entries are removed.\n" +
- 					   "All Executable/Config files have been deleted.",INFORMATION);
- 		else
- 			MessageBox("NTP - NT service and registry entries are removed.\n" +
- 					   "All Executable/Config files are retained.",INFORMATION);
- 		endif;  
- 	endif;
- end;
- 
-  
- //+---------------------------------------------------------------------------
- //
- //  Member:             UpdateModules()
- //
- //----------------------------------------------------------------------------
- function UpdateModules()
- 	STRING szFileSet;
- 	STRING szMessage;
- 	NUMBER nvSize, nvType;
- begin
-     SetStatusWindow( 0, "Updating NTP installation..." );
- 
-         nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
- 
- 	if (nReturnValue2 != 0) then
- 		ReportError(nReturnValue2,szMessage);
- 		NumToStr( szTemp, nReturnValue2 );
- 		szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is running?\n" + szMessage;
- 		MessageBox(szMessage,SEVERE);
- 		exit;
- 	endif;
-    	Delay( 3 ); // delay for xntpd.exe file to free up so copy works
- 
- 	// have to get the currently install directory from the dll by pulling it off of the imagepath param
-     if (GetImagePath(svModuleDir) != 0) then
- 		szMessage = "Unable to retrieve the path to Update NTP Files \n" + svModuleDir + 
-                   "\nAre you sure it is installed?\n";
- 		MessageBox(szMessage,SEVERE);
- 		exit;
- 	endif;
- 
- 	InstallNTPFiles(svModuleDir,1);
- 	
-     nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);
- 
-     if (nReturnValue2 != 0) then
- 		ReportError(nReturnValue2,szMessage);
- 		szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;
- 		MessageBox(szMessage,SEVERE);
- 		exit;
-     endif;
- 
- 	SetStatusWindow( 100, "Update completed." );
- 	Delay( 2 );
-    
- 	MessageBox("Your Network Time Protocol Server modules have been updated and\n" +
- 			   "the service restarted.  You should check the event log\n" +
- 			   "to make sure everything came back up properly.",INFORMATION);
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  GetImagePAth
-  *
-  * Purpose:  Get the given value, under the given key, from the registry.
-  *   l. kahn
- \*---------------------------------------------------------------------------*/
- function GetImagePath(svValue)
- 	NUMBER nvSize;
- 	NUMBER nvType;
- begin
- 
-         RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
-         if (RegDBGetKeyValueEx(SERVICE_ENTRY,
-               "ImagePath",nvType,svValue,nvSize) < 0) then
- 		return -1;
- 	endif;
- 			
- 	StrSub(svValue,svValue,0,nvSize - 10);                       // trim to REAL length   
-         return 0;
- end;
- 
- function CheckForService()
-         STRING temp;
- 	NUMBER nvSize;
- 	NUMBER nvType;
- begin
- 
- 
- 	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
-         if (RegDBGetKeyValueEx(SERVICE_ENTRY,
- 			"ImagePath",nvType,temp,nvSize) < 0) then
- 		return 0;
- 	endif;
-  return -1;
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  LaunchAppAndWait
-  *
-  *  Purpose:  replace predefined function in more expensive InstallShield 
-  *            with C function.
-  *	l. kahn
- \*---------------------------------------------------------------------------*/
- function LaunchAppAndWait(svApp, svData, waitval)
-   STRING tstring;
- begin
-         nValue = waitval;
-         tstring = svApp+" "+svData;
-         nReturnValue2 = CallDLLFx(szDllNTPInst,"LaunchApp",nValue,tstring);
-         return 0;
- end;
- 
- 
- /*---------------------------------------------------------------------------*\
-  *
-  * Function:  FixDirectory
-  *
-  *  Purpose:  put the double slashes in the directory
-  *  l. kahn
- \*---------------------------------------------------------------------------*/
- function FixDirectory(svOut,svIn)
- 
- INT len;
- INT ctr;
- NUMBER letter;
- INT i;
- 
- begin
-  len = StrLength(svIn) - 1;
-  ctr = 0;
- 
-  for i = 0 to len
-     GetByte(letter,svIn,i);
-     if (letter = 92)
-       then
-        SetByte(svOut,ctr,letter);
-        ctr = ctr + 1;
-     endif;
- 
-     SetByte(svOut,ctr,letter);
-     ctr = ctr + 1;
-  endfor;
- end;
\ No newline at end of file
--- 0 ----
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/build.bat xntp/scripts/wininstall/build.bat
*** xntp3-5.86/scripts/wininstall/build.bat	Wed Dec 31 23:58:26 1969
--- xntp/scripts/wininstall/build.bat	Sun Oct 20 23:43:20 1996
***************
*** 28,34 ****
  echo Building INTEL version...
  :skip_intel
  
! set IPRG=f:\ishield\program
  set INST=%INSTDIR%\data
  
  rem 
--- 28,34 ----
  echo Building INTEL version...
  :skip_intel
  
! set IPRG=c:\msdev\ishield\program
  set INST=%INSTDIR%\data
  
  rem 
Binary files xntp3-5.86/scripts/wininstall/distrib/ntpog.wri and xntp/scripts/wininstall/distrib/ntpog.wri differ
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/distrib/readme.nt xntp/scripts/wininstall/distrib/readme.nt
*** xntp3-5.86/scripts/wininstall/distrib/readme.nt	Wed Dec 31 23:57:18 1969
--- xntp/scripts/wininstall/distrib/readme.nt	Mon Oct 21 02:00:19 1996
***************
*** 1,23 ****
! Building/compiling XNTP 3.5 for Windows NT
  
! To automate the build run the file buildallnt.bat... then run the
! file install.bat in the contrib\winnt-dist directory (i.e. step 10 below)...
! or to build XNTP manually review the buildntall.bat file...
  
! NOTE: For installing binaries only do step 1
  
  
- 1) Run         ntp\contrib\winnt-dist\install.bat (To install it all)
- 2) Run         ntp\mkdist.bat (To package it via ZIP)
  
! NOTE: You will now have to modify the configuration files installed by the
! install.bat program and also the ntp.conf file (config file) installed in
! the WinNT home directory.  Also see the NTP operations guide (ntpog.wri)
! in the system32 directory.
  
  ****YOU MUST ****** modify the directory line in the ntp.conf or ntp.ini 
! (it will accept either name)... and change the single slash to double slashes
! ie. c:\winnt\ntp.conf becomes c:\\winnt\\ntp.conf
  
  
  
--- 1,139 ----
! ----------------------------------------------------------------------------
! XNTP v3.5-86 Release (w/ NT patches)                      October 20th, 1996
! 						  
! ----------------------------------------------------------------------------
! 	This software is user supported freeware.
  
! 	For support post to the UseNet newsgroup: comp.protocols.time.ntp
  
! 	More detailed information can also be found at:
! 		http://www.eecis.udel.edu/~ntp
  
  
  
!         NOTE: Don't run uninstall to remove or update the Network Time 
!               Protocol service to a new version, just run the setup program 
!               again.
! --------------------------------------------------------------------------------
! 
! 
! Brief Installation Instructions
! 
! 1.  If you currently have XNTP on this machine (any older version that was NOT
!     installed using this GUI) you must STOP NOW, and REMOVE IT from your system
!     before running this install program.  
! 
! 2.  This installation program will create what it thinks are sensible defaults
!     for the configuration files for XNTP.  If you have a tricky setup, let it 
!     finish, then go back and stop the service (try the control panel applet) 
!     and edit the configuration files.  The files will all be in the directory 
!     you install into (default is %windir%\) and will be named as follows:
!     
!     	ntp.conf  - 	the NTP configuration file.
!     	ntp.drift -	the NTP drift file
! 	
! 
! --------------------------------------------------------------------------------
! 
! Building/compiling XNTP for Windows NT
! 
! To automate the build run either bldrel.bat or blddbg.bat... then run the
! file install.bat in the scripts\wininstall\distrib directory for a 
! manual installation. Run scripts\wininstall\intel\disk1\setup.exe
! for the InstallShield based GUI installation.
  
  ****YOU MUST ****** modify the directory line in the ntp.conf or ntp.ini 
! (it will accept either name)... and change the single slashes to double 
! slashes ie. c:\winnt\ntp.conf becomes c:\\winnt\\ntp.conf
! 
! 
! --------------------------------------------------------------------------------
! May 07 1996
! 
! 
! ANNOUNCE: Enhancements to the Windows NT port of XNTP 3.5
!                                     (Network Time Protocol)
! 
! 
! 
! This set of changes fixes all known bugs, and it includes 
! several major enhancements.
! 
! Many changes have been made both to the build environment as
! well as the code.  There is no longer an ntp.mak file, instead
! there is a buildntall.bat file that will build the entire 
! release in one shot.  The batch file requires Perl.  Perl
! is easily available from the NT Resource Kit or on the Net.
! 
! The multiple interface support was adapted from Larry Kahn's
! work on the BIND NT port.  I have not been able to test it
! adequately as I only have NT servers with one network 
! interfaces on which to test.  
! 
! Enhancements:
! *	Event Logging now works correctly.
! *	Version numbers now work (requires Perl during build)
! *	Support for multiple network interface cards (untested)
! *	NTP.CONF now default, but supports ntp.ini if not found
! *	Installation procedure automated.
! *	All paths now allow environment variables such as %windir%
! 
! Bug fixes:
! *	INSTSRV replaced, works correctly
! *	Cleaned up many warnings
! *	Corrected use of an uninitialized variable in XNTPD
! *	Fixed ntpdate -b option
! *	Fixed ntpdate to accept names as well as IP addresses
!         (Winsock WSAStartup was called after a gethostbyname())
! *	Fixed problem with "longjmp" in xntpdc/ntpdc.c that 
!         caused a software exception on doing a Control-C in xntpdc.
! 	A Cntrl-C now terminates the program. 
! 
! See below for more detail:
! 
!       Note: SIGINT is not supported for any Win32 application including 
!       Windows NT and Windows 95. When a CTRL+C interrupt occurs, Win32 
!       operating systems generate a new thread to specifically handle that 
!       interrupt. This can cause a single-thread application such as UNIX, 
!       to become multithreaded, resulting in unexpected behavior. 
! 
! 
! Possible enhancements and things left to do:
! *	Reference clock drivers for NT (at least Local Clock support)
! *	Control Panel Applet
! *	InstallShield based installation, like NT BIND has
! *	Integration with NT Performance Monitor
! *	SNMP integration
! *	Fully test multiple interface support
! 
! 
! Known problems:
! *       bug in ntptrace - if no Stratum 1 servers are available,
!                 such as on an IntraNet, the application crashes.
! 
! 
! 
! Greg Schueman  [schueman@acm.org]
! 
! 
! --------------------------------------------------------------------------------
  
+ Disclaimer of Warranties. THE SOFTWARE AND ASSOCIATED DOCUMENTATION ARE 
+ PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, 
+ INCLUDING WITHOUT LIMITATION ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR 
+ ANY PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  THE ENTIRE RISK AS TO THE 
+ QUALITY AND PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION IS WITH YOU. NO 
+ ONE WARRANTS THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE 
+ OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS 
+ IN THE SOFTWARE WILL BE CORRECTED.
  
+ Limitations of Warranty.  IN NO EVENT SHALL ANYONE INVOLVED IN THE CREATION, 
+ PRODUCTION, OR DISTRIBUTION OF THE SOFTWARE BE LIABLE TO YOU ON ACCOUNT OF 
+ ANY CLAIM FOR ANY SPECIAL EXEMPLARY OR PUNITIVE DAMAGES, INCLUDING ANY LOST 
+ PROFITS, LOST SAVINGS, BUSINESS INTERRUPTION, LOSS OF BUSINESS OR PERSONAL 
+ INFORMATION OR ANY OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 
+ THE USE, THE INABILITY TO USE, QUALITY, OR PERFORMANCE OF THE SOFTWARE AND 
+ DOCUMENTATION, EVEN IF SAID AUTHORS, HAVE BEEN ADVISED OF THE POSSIBILITY 
+ OF SUCH DAMAGES.
  
+ --------------------------------------------------------------------------------
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/instsrv/instsrv.c xntp/scripts/wininstall/instsrv/instsrv.c
*** xntp3-5.86/scripts/wininstall/instsrv/instsrv.c	Thu Jan 01 00:00:00 1970
--- xntp/scripts/wininstall/instsrv/instsrv.c	Sat Oct 26 06:04:38 1996
***************
*** 0 ****
--- 1,459 ----
+ /*
+  *  File: instsrv.c
+  *  Purpose: To install a new service and to insert registry entries.
+  *
+  */
+ 
+ #include <windows.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #define PERR(api) printf("\n%s: Error %d from %s on line %d",  \
+     __FILE__, GetLastError(), api, __LINE__);
+ 
+ #define MSG_FOR_ACCESS_DENIED "You aren't authorized to do this - please see your system Administrator"
+ #define MSG_1_FOR_BAD_PATH "The fully qualified path name to the .exe must be given, and"
+ #define MSG_2_FOR_BAD_PATH "  the drive letter must be for a fixed disk (e.g., not a net drive)"
+ 
+ SC_HANDLE schService;
+ SC_HANDLE schSCManager;
+ int ok2;
+ 
+ VOID DisplayHelp(VOID);
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ int InstallService(LPCTSTR serviceName, LPCTSTR serviceExe)
+ {
+   LPCTSTR lpszBinaryPathName = serviceExe;
+   LPTSTR  lpszRootPathName="?:\\";
+ 
+   if ( (':' != *(lpszBinaryPathName+1)) || ('\\' != *(lpszBinaryPathName+2)) )
+   { printf("\n%s",MSG_1_FOR_BAD_PATH);
+     printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+     return 1;
+   }
+ 
+   #define DRIVE_TYPE_INDETERMINATE 0
+   #define ROOT_DIR_DOESNT_EXIST    1
+ 
+   *lpszRootPathName = *(lpszBinaryPathName+0) ;
+ 
+   switch (  GetDriveType(lpszRootPathName)  )
+   {
+     case DRIVE_FIXED :
+     { // OK
+       break;
+     }
+     case  ROOT_DIR_DOESNT_EXIST :
+     { printf("\n%s",MSG_1_FOR_BAD_PATH);
+       printf("\n  the root directory where the .exe is specified to be must exist, and");
+       printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+       return 1;
+     }
+     case  DRIVE_TYPE_INDETERMINATE :
+     case  DRIVE_REMOVABLE          :
+     case  DRIVE_REMOTE             :
+     case  DRIVE_CDROM              :
+     case  DRIVE_RAMDISK            :
+     { printf("\n%s",MSG_1_FOR_BAD_PATH);
+       printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+       return 1;
+     }
+     default :
+     { printf("\n%s",MSG_1_FOR_BAD_PATH);
+       printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+       return 1;
+     }
+   }
+ 
+   if (INVALID_HANDLE_VALUE == CreateFile(lpszBinaryPathName,
+                                          GENERIC_READ,
+                                          FILE_SHARE_READ,
+                                          NULL,
+                                          OPEN_EXISTING,
+                                          FILE_ATTRIBUTE_NORMAL,
+                                          NULL))
+   { 
+     printf("\n%s",MSG_1_FOR_BAD_PATH);
+     printf("\n  the file must exist, and");
+     printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+     return 1;
+   }
+ 
+   schService = CreateService(
+         schSCManager,               // SCManager database
+         serviceName,                // name of service
+         serviceName,                // name to display (new parameter after october beta)
+         SERVICE_ALL_ACCESS,         // desired access
+         SERVICE_WIN32_OWN_PROCESS,  // service type
+         SERVICE_AUTO_START,         // start type
+         SERVICE_ERROR_NORMAL,       // error control type
+         lpszBinaryPathName,         // service's binary
+         NULL,                       // no load ordering group
+         NULL,                       // no tag identifier
+         NULL,                       // no dependencies
+         NULL,                       // Local System account
+         NULL);                      // null password
+ 
+   if (NULL == schService)
+   { switch (GetLastError())
+     {
+       case ERROR_ACCESS_DENIED :
+       { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+         break;
+       }
+       case ERROR_SERVICE_EXISTS :
+       { printf("\nThe %s service is already installed",serviceName);
+         printf("\nRemove it first if you need to re-install a new version\n");
+         break;
+       }
+       default :
+       { PERR("CreateService");
+       }
+     }
+     return 1;
+   }
+   else
+ 
+   CloseServiceHandle(schService);
+   return 0;
+ }
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ int RemoveService(LPCTSTR serviceName)
+ {
+   {
+     #define                                     SZ_ENUM_BUF 4096
+     ENUM_SERVICE_STATUS        essServiceStatus[SZ_ENUM_BUF];
+     DWORD   dwBufSize = sizeof(essServiceStatus);
+     DWORD   dwBytesNeeded      = 0;
+     DWORD   dwServicesReturned = 0;
+     DWORD   dwResumeHandle     = 0;
+     DWORD   dwI                = 0;
+     BOOLEAN bFound = FALSE;
+ 
+     if (!EnumServicesStatus(schSCManager,
+                             SERVICE_WIN32,
+                             SERVICE_ACTIVE,
+                             (LPENUM_SERVICE_STATUS)&essServiceStatus,
+                             dwBufSize,
+                             &dwBytesNeeded,
+                             &dwServicesReturned,
+                             &dwResumeHandle))
+     { switch (GetLastError())
+       {
+         case ERROR_ACCESS_DENIED :
+         { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+           break;
+         }
+         default :
+         { PERR("EnumServicesStatus");
+         }
+       }
+       return 1;
+     }
+ 
+     for (dwI=0; dwI<dwServicesReturned; dwI++)
+     { if(0 == _stricmp(essServiceStatus[dwI].lpServiceName,serviceName))
+       { bFound = TRUE;
+         break;
+       }
+     }
+ 
+     if (bFound)
+     { printf("\nThe %s service cannot be removed until it has been stopped.",serviceName);
+       printf("\nTo stop the %s service, use the Stop button in the Control",serviceName);
+       printf("\n  Panel Services applet\n");
+       return 1;
+     }
+   }
+ 
+   schService = OpenService(schSCManager,
+                            serviceName,
+                            SERVICE_ALL_ACCESS);
+   if (NULL == schService)
+   { switch (GetLastError())
+     {
+       case ERROR_ACCESS_DENIED :
+       { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+         break;
+       }
+       case ERROR_SERVICE_DOES_NOT_EXIST :
+       { printf("\nThe %s service is not installed, so cannot be removed\n",serviceName);
+         break;
+       }
+       default :
+       { PERR("OpenService");
+       }
+     }
+     return 1;
+   }
+ 
+   if (DeleteService(schService))
+   { printf("\nDelete of Service \"NetworkTimeProtocol\" was SUCCESSFUL\n");
+    return 0;
+   }
+   else
+   { switch (GetLastError())
+     {
+       case ERROR_ACCESS_DENIED :
+       { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+         break;
+       }
+       default :
+       { PERR("DeleteService");
+       }
+     }
+    return 1;
+   }
+ }
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ int addSourceToRegistry(LPSTR pszAppname, LPSTR pszMsgDLL)
+ {
+   HKEY hk;                      /* registry key handle */
+   DWORD dwData;
+   BOOL bSuccess;
+   
+   /* When an application uses the RegisterEventSource or OpenEventLog
+      function to get a handle of an event log, the event loggging service
+      searches for the specified source name in the registry. You can add a
+      new source name to the registry by opening a new registry subkey
+      under the Application key and adding registry values to the new
+      subkey. */
+ 
+   /* Create a new key for our application */
+   bSuccess = RegCreateKey(HKEY_LOCAL_MACHINE,
+       "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\NTP", &hk);
+    if(bSuccess != ERROR_SUCCESS)
+     {
+       PERR("RegCreateKey");
+       return 1;
+     }
+     
+   /* Add the Event-ID message-file name to the subkey. */
+   bSuccess = RegSetValueEx(hk,  /* subkey handle         */
+       "EventMessageFile",       /* value name            */
+       0,                        /* must be zero          */
+       REG_EXPAND_SZ,            /* value type            */
+       (LPBYTE) pszMsgDLL,       /* address of value data */
+       strlen(pszMsgDLL) + 1);   /* length of value data  */
+  if(bSuccess != ERROR_SUCCESS)
+     {
+       PERR("RegSetValueEx");
+       return 1;
+     }
+   
+   /* Set the supported types flags and addit to the subkey. */
+   dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
+       EVENTLOG_INFORMATION_TYPE;
+   bSuccess = RegSetValueEx(hk,  /* subkey handle                */
+       "TypesSupported",         /* value name                   */
+       0,                        /* must be zero                 */
+       REG_DWORD,                /* value type                   */
+       (LPBYTE) &dwData,         /* address of value data        */
+       sizeof(DWORD));           /* length of value data         */
+   if(bSuccess != ERROR_SUCCESS)
+     {
+       PERR("RegSetValueEx");
+       return 1;
+     }
+   RegCloseKey(hk);
+   return 0;
+ }
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ int addKeysToRegistry()
+ 
+ {
+   HKEY hk;                      /* registry key handle */
+   BOOL bSuccess;
+   UCHAR   myarray[200];
+   char *lpmyarray = myarray;
+   int arsize = 0;
+ 
+   /* now add the depends on service key */
+  
+   /* Create a new key for our application */
+   bSuccess = RegCreateKey(HKEY_LOCAL_MACHINE,
+       "SYSTEM\\CurrentControlSet\\Services\\NetworkTimeProtocol", &hk);
+   if(bSuccess != ERROR_SUCCESS)
+     {
+       PERR("RegCreateKey");
+       return 1;
+     }
+ 
+   strcpy(lpmyarray,"TcpIp");
+   lpmyarray = lpmyarray + 6;
+   arsize = arsize + 6;
+   strcpy(lpmyarray,"Afd");
+   lpmyarray = lpmyarray + 4;
+   arsize = arsize + 4;
+   strcpy(lpmyarray,"LanManWorkstation");
+   lpmyarray = lpmyarray + 18;
+   arsize = arsize + 20;
+   strcpy(lpmyarray,"\0\0");
+   
+   bSuccess = RegSetValueEx(hk,  /* subkey handle         */
+       "DependOnService",        /* value name            */
+       0,                        /* must be zero          */
+       REG_MULTI_SZ,             /* value type            */
+       (LPBYTE) &myarray,        /* address of value data */
+       arsize);                  /* length of value data  */
+    if(bSuccess != ERROR_SUCCESS)
+     {
+       PERR("RegSetValueEx");
+       return 1;
+     }
+ 
+   RegCloseKey(hk);
+   return 0;
+ }
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ int main(int argc, char *argv[])
+ {
+   #define           SZ_NAME_BUF  270  // 256 is max, add a little
+   UCHAR   ucNameBuf[SZ_NAME_BUF] = "NetworkTimeProtocol";
+   LPTSTR  lpszServName = (LPTSTR)&ucNameBuf;
+ 
+   UCHAR   ucExeNBuf[SZ_NAME_BUF] = "";
+   LPTSTR  lpszExeName  = (LPTSTR)&ucExeNBuf;
+ 
+   BOOL    bRemovingService = FALSE;
+   char *p;
+ 
+   DWORD last_error = 0;
+   int timeout = 0;
+   DWORD rv = 0;
+   int ok = 0;  
+   
+   // check if Win32s, if so, display notice and terminate
+       if( GetVersion() & 0x80000000 )
+       {
+         MessageBox( NULL,
+            "This application cannot run on Windows 3.1.\n"
+            "This application will now terminate.",
+            "NAMED",
+            MB_OK | MB_ICONSTOP | MB_SETFOREGROUND );
+         return( 1 );
+       }
+   if (argc == 2)
+      bRemovingService = (!stricmp(argv[1], "remove"));
+ 
+   if(!bRemovingService)
+    {
+ 
+   
+   if (argc != 2)
+   {
+     DisplayHelp();
+     exit(1);
+   }
+ 
+   p=argv[1];
+   if (    ('/' == *p)
+        || ('-' == *p) )
+   {
+     DisplayHelp();
+     exit(1);
+   }
+         
+   
+    }
+ 
+   if (strlen(argv[1]) > 256)
+     {
+       printf("\nThe service name cannot be longer than 256 characters\n");
+       exit(1);
+     }
+ 
+ 
+ 
+   bRemovingService = (!stricmp(argv[1], "remove"));
+   schSCManager = OpenSCManager(
+                       NULL,                   // machine (NULL == local)
+                       NULL,                   // database (NULL == default)
+                       SC_MANAGER_ALL_ACCESS); // access required
+ 
+   if (NULL == schSCManager)
+   { switch (GetLastError())
+     {
+       case ERROR_ACCESS_DENIED :
+       { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+         break;
+       }
+       default :
+       { PERR("OpenSCManager");
+       }
+     }
+     return (0);
+   }
+    
+   if (bRemovingService)
+   {
+    ok = RemoveService(lpszServName);
+   }
+   else
+   {
+    /* get the exe name */
+    strcpy(lpszExeName,argv[1]);
+    ok = InstallService(lpszServName,lpszExeName);
+   }
+ 
+   CloseServiceHandle(schSCManager);
+ 
+   if (!bRemovingService)
+     {
+   if (ok == 0)
+    { /* Set the Event-ID message-file name. */
+     ok = addSourceToRegistry("NetworkTimeProtocol", lpszExeName);
+     if (ok == 0)
+       ok = addKeysToRegistry();
+     else return ok;
+ 
+     if (ok == 0)
+     {
+       printf("\nThe \"NetworkTimeProtocol\" service was successfully created.\n");
+       printf("\nDon't forget!!! You must now go to the Control Panel and");
+       printf("\n  use the Services applet to change the account name and");
+       printf("\n  password that the NTP Service will use when");
+       printf("\n  it starts.");
+       printf("\nTo do this: use the Startup button in the Services applet,");
+       printf("\n  and (for example) specify the desired account and");
+       printf("\n  correct password.");
+       printf("\nAlso, use the Services applet to ensure this newly installed");
+       printf("\n  service starts automatically on bootup.\n");
+      return 0;
+     }
+    }
+   else return ok;
+   }
+  else return 0;
+ }
+ 
+ /* --------------------------------------------------------------------------------------- */
+ 
+ VOID DisplayHelp(VOID)
+ {
+     printf("Installs or removes the NTP service.\n");
+     printf("To install the NTP service,\n");
+     printf("type INSTSRV <path> \n");
+     printf("Where:\n");
+     printf("    path    Absolute path to the NTP service, name.exe.  You must\n");
+     printf("            use a fully qualified path and the drive letter must be for a\n");
+     printf("            fixed, local drive.\n\n");
+     printf("For example, INSTSRV i:\\winnt\\system32\\xntpd.exe\n");
+     printf("To remove the NTP service,\n");
+     printf("type INSTSRV remove \n");
+ 
+ }
+ 
+ /* EOF */
\ No newline at end of file
Binary files xntp3-5.86/scripts/wininstall/instsrv/instsrv.mdp and xntp/scripts/wininstall/instsrv/instsrv.mdp differ
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/instsrv/instsrv.ncb xntp/scripts/wininstall/instsrv/instsrv.ncb
*** xntp3-5.86/scripts/wininstall/instsrv/instsrv.ncb	Thu Jan 01 00:00:00 1970
--- xntp/scripts/wininstall/instsrv/instsrv.ncb	Sat Oct 26 06:05:01 1996
***************
*** 0 ****
--- 1 ----
+ Microsoft C/C++ program database 2.00
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/intel/setup/setup.lst xntp/scripts/wininstall/intel/setup/setup.lst
*** xntp3-5.86/scripts/wininstall/intel/setup/setup.lst	Thu Jan 01 00:00:00 1970
--- xntp/scripts/wininstall/intel/setup/setup.lst	Thu Jan 01 00:01:48 1970
***************
*** 0 ****
--- 1,10 ----
+ 1;
+ \ntp\install\intel\data\ntpog.wri    ntpog.wri
+ \ntp\install\intel\data\readme.nt    readme.nt
+ \ntp\install\intel\data\COPYRIGHT    COPYRIGHT
+ \ntp\install\intel\data\ntpdate.exe  ntpdate.exe
+ \ntp\install\intel\data\ntpq.exe     ntpq.exe
+ \ntp\install\intel\data\ntptrace.exe ntptrace.exe
+ \ntp\install\intel\data\xntpdc.exe   xntpdc.exe
+ \ntp\install\intel\data\xntpd.exe    xntpd.exe
+ \ntp\install\intel\disk1\data.z      data.z
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/readme.nt xntp/scripts/wininstall/readme.nt
*** xntp3-5.86/scripts/wininstall/readme.nt	Thu Jan 01 00:02:59 1970
--- xntp/scripts/wininstall/readme.nt	Mon Oct 21 02:00:19 1996
***************
*** 1,53 ****
  ----------------------------------------------------------------------------
! XNTP v3.5f Release (w/ NT patches)                       May 7th, 1996
  						  
  ----------------------------------------------------------------------------
! 	NOTE:  This is user-supported, freeware
  
  	For support post to the UseNet newsgroup: comp.protocols.time.ntp
- 	There will also be documentation with this release, in the file 
- 	NTPOG.WRI.  It is in Windows Write format.
  
!         NOTE: don't run uninstall to remove or update the bind service to 
!               a new version just run the setup program again.
! ---------------------------------------------------------------------------------
  
  
  Brief Installation Instructions
  
  1.  If you currently have XNTP on this machine (any older version that was NOT
      installed using this GUI) you must STOP NOW, and REMOVE IT from your system
!     before running this install program.  There is no way for us to figure out
!     what every other version of XNTP might do when it installs itself.
  
! 2.  This installation program will create what it thinks are sensible defaults for
!     the configuration files for XNTP.  If you have a tricky setup, let it finish, 
!     then go back and stop the service (try the control panel applet) and edit the 
!     configuration files.  The files will all be in the directory you install 
!     (default is %windir%\) and will be named as follows:
      
!     	ntp.conf  - 	         the NTP configuration file.
!     	ntp.drift -		         the NTP drift file
  	
  
! ----------------------------------------------------------------------------------------
  
! Building/compiling XNTP 3.5 for Windows NT
  
! To automate the build run the file buildallnt.bat... then run the
! file install.bat in the contrib\winnt-dist directory (i.e. step 10 below)...
! or to build XNTP manually review the buildntall.bat file...
  
  ****YOU MUST ****** modify the directory line in the ntp.conf or ntp.ini 
! (it will accept either name)... and change the single slash to double slashes
! ie. c:\winnt\ntp.conf becomes c:\\winnt\\ntp.conf
  
  
! ----------------------------------------------------------------------------------------
  May 07 1996
  
  
! ANNOUNCE: Enhancements to the Windows NT port of XNTP 3.5f
                                      (Network Time Protocol)
  
  
--- 1,57 ----
  ----------------------------------------------------------------------------
! XNTP v3.5-86 Release (w/ NT patches)                      October 20th, 1996
  						  
  ----------------------------------------------------------------------------
! 	This software is user supported freeware.
  
  	For support post to the UseNet newsgroup: comp.protocols.time.ntp
  
! 	More detailed information can also be found at:
! 		http://www.eecis.udel.edu/~ntp
! 
! 
! 
!         NOTE: Don't run uninstall to remove or update the Network Time 
!               Protocol service to a new version, just run the setup program 
!               again.
! --------------------------------------------------------------------------------
  
  
  Brief Installation Instructions
  
  1.  If you currently have XNTP on this machine (any older version that was NOT
      installed using this GUI) you must STOP NOW, and REMOVE IT from your system
!     before running this install program.  
  
! 2.  This installation program will create what it thinks are sensible defaults
!     for the configuration files for XNTP.  If you have a tricky setup, let it 
!     finish, then go back and stop the service (try the control panel applet) 
!     and edit the configuration files.  The files will all be in the directory 
!     you install into (default is %windir%\) and will be named as follows:
      
!     	ntp.conf  - 	the NTP configuration file.
!     	ntp.drift -	the NTP drift file
  	
  
! --------------------------------------------------------------------------------
  
! Building/compiling XNTP for Windows NT
  
! To automate the build run either bldrel.bat or blddbg.bat... then run the
! file install.bat in the scripts\wininstall\distrib directory for a 
! manual installation. Run scripts\wininstall\intel\disk1\setup.exe
! for the InstallShield based GUI installation.
  
  ****YOU MUST ****** modify the directory line in the ntp.conf or ntp.ini 
! (it will accept either name)... and change the single slashes to double 
! slashes ie. c:\winnt\ntp.conf becomes c:\\winnt\\ntp.conf
  
  
! --------------------------------------------------------------------------------
  May 07 1996
  
  
! ANNOUNCE: Enhancements to the Windows NT port of XNTP 3.5
                                      (Network Time Protocol)
  
  
***************
*** 109,151 ****
  
  
  
! Binaries and source code are available at the following site:
! 
!     ftp://ftp.access.digex.net/pub/access/schueman/ntp
! 
! Files:
! 
!     ntxntp35f-src.tar.gz      - Sources  for enhanced NT port of XNTP v3.5f 
! 	intel/ntxntp35f-bin.zip   - Binaries for enhanced NT port of XNTP v3.5f 
!     intel/unzip.exe           - NT Unzip - handles long filenames
  
- Note: the zip file contains long file names and you will need an unzip
- that supports them (i.e. info-zip, or download the unzip.exe) on the same 
- ftp site.
  
! If just downloading the binaries run SETUP.EXE
  
! 
! Greg Schueman  schueman@access.digex.net  or schueman@acm.org
! 
! 
! ----------------------------------------------------------------------------------------
! 
! Disclaimer of Warranties. THE SOFTWARE AND ASSOCIATED DOCUMENTATION ARE PROVIDED "AS IS" 
! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 
! ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 
! THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION IS 
! WITH YOU. NO ONE WARRANTS THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR 
! THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS 
  IN THE SOFTWARE WILL BE CORRECTED.
  
  Limitations of Warranty.  IN NO EVENT SHALL ANYONE INVOLVED IN THE CREATION, 
! PRODUCTION, OR DISTRIBUTION OF THE SOFTWARE BE LIABLE TO YOU ON ACCOUNT OF ANY CLAIM 
! FOR ANY SPECIAL EXEMPLARY OR PUNITIVE DAMAGES, INCLUDING ANY LOST PROFITS, LOST SAVINGS,
! BUSINESS INTERRUPTION, LOSS OF BUSINESS OR PERSONAL INFORMATION OR ANY OTHER INCIDENTAL
! OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE, THE INABILITY TO USE, QUALITY, OR 
! PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION, EVEN IF SAID AUTHORS, HAVE BEEN ADVISED
! OF THE POSSIBILITY OF SUCH DAMAGES.
! ----------------------------------------------------------------------------------------
! 
  
--- 113,139 ----
  
  
  
! Greg Schueman  [schueman@acm.org]
  
  
! --------------------------------------------------------------------------------
  
! Disclaimer of Warranties. THE SOFTWARE AND ASSOCIATED DOCUMENTATION ARE 
! PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, 
! INCLUDING WITHOUT LIMITATION ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR 
! ANY PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  THE ENTIRE RISK AS TO THE 
! QUALITY AND PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION IS WITH YOU. NO 
! ONE WARRANTS THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE 
! OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS 
  IN THE SOFTWARE WILL BE CORRECTED.
  
  Limitations of Warranty.  IN NO EVENT SHALL ANYONE INVOLVED IN THE CREATION, 
! PRODUCTION, OR DISTRIBUTION OF THE SOFTWARE BE LIABLE TO YOU ON ACCOUNT OF 
! ANY CLAIM FOR ANY SPECIAL EXEMPLARY OR PUNITIVE DAMAGES, INCLUDING ANY LOST 
! PROFITS, LOST SAVINGS, BUSINESS INTERRUPTION, LOSS OF BUSINESS OR PERSONAL 
! INFORMATION OR ANY OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 
! THE USE, THE INABILITY TO USE, QUALITY, OR PERFORMANCE OF THE SOFTWARE AND 
! DOCUMENTATION, EVEN IF SAID AUTHORS, HAVE BEEN ADVISED OF THE POSSIBILITY 
! OF SUCH DAMAGES.
  
+ --------------------------------------------------------------------------------
diff -N -x *.mak -c -r xntp3-5.86/scripts/wininstall/setup.rul xntp/scripts/wininstall/setup.rul
*** xntp3-5.86/scripts/wininstall/setup.rul	Thu Jan 01 00:00:00 1970
--- xntp/scripts/wininstall/setup.rul	Mon Oct 21 01:40:14 1996
***************
*** 0 ****
--- 1,790 ----
+ /*---------------------------------------------------------------------------*\
+  *  File Name:  SETUP.RUL
+  *
+  *  Description:  XNTP - NT Install, 
+  *                Reworked by Greg Schueman for XNTP.
+  *
+  *   BIND version by Larry Kahn... using ideas from Paul Wren's (PIW) version.  
+  *
+ \* ----------------------------------------------------------------------------*/
+ declare
+ 	// Constant declarations.
+ 	#define SPACE_REQUIRED          1300000          // Disk space in bytes.
+ 	#define APP_NAME                "NetworkTimeProtocol"
+ 	#define APP_NAME2               "XNTP 3.5-86 Freeware"
+ 	#define APPBASE_PATH            "\\var\\ntp\\"
+ 	#define PRODUCT_VERSION         "3.5-86Rel"
+ 	#define DEINSTALL_KEY           "NTP3.5-86"
+ 	#define UNINSTALL_NAME          "NTP"
+ 	#define PRODUCT_KEY             "xntpd.exe"
+ 	#define NTP_PORT                123
+ 	#define ONETIMESOURCE           1
+ 	#define TWOTIMESOURCES          2
+ 	#define NOTIMEYET               3
+ 	
+ 	// Global variable declarations
+ 	STRING  svDir, szMsg, szFileSet,szTitle,  szMessage, svUninstLogFile;
+ 	STRING  szProgram, szParam, szTemp, szTemp2, szAppPath;
+ 	STRING  svFileName;
+ 	STRING  svTempStr;
+ 	STRING  svModuleDir;
+ 	STRING  svAnswer;
+ 	STRING  dummy;
+ 	
+ 	BOOL    bRemoveNTP, bUpdateModules;
+ 	
+ 
+ 	STRING  svNTPAddress;                   // the IP address of "1st" time source
+ 	STRING  svNTPAddress2;                  // the IP address of "2nd" time source
+ 	STRING  szDllNTPInst;
+ 	NUMBER  nReturnValue;
+     INT     nReturnValue2;
+     INT     nValue;
+ 	
+ 	//--------Custom Dialog in Ishield-------------------------
+ 	BOOL bDone;
+ 	LIST lNames, lAddrs;
+ 
+ 	//------- NTPInst.DLL defines------------------------
+ 	#define k_PrivilegeErr                  1
+ 	#define k_CreateKeyErr                  2
+ 	#define k_RestoreKeyErr                 3
+ 	#define k_ErrUnableToOpenWriteOwner     4
+ 	#define k_ErrUnableToSetOwner           5
+ 	#define k_ErrUnableToOpenDAC            6
+ 	#define k_ErrUnableToWriteDACL          7
+ 	#define k_OpenKeyError                  8
+ 	#define k_ModifySetAccountFail          10
+ 	#define k_SCMErr                        11
+ 	#define k_SCMpoErr                      12
+ 	#define k_DeleteServiceFail             13
+ 	#define k_DeleteKeyFail                 14
+ 	#define k_DeleteValueFail               15
+ 	#define k_DirSecurityErr                16
+ 	#define k_DirSetDACLErr                 17
+ 	#define k_DirSetSecurityErr             18
+ 	#define k_SCMpoStopErr                  19
+ 	#define k_SaveKeyErr                    20
+ 	#define k_ServiceUnknownErr             50
+ 	#define k_ServiceDependency             51
+ 	#define k_ServiceDependencyFail         52
+ 	#define k_ServiceLogonFail              53
+ 
+ 	#define k_BadPath                       101
+ 	#define k_AccessDenied                  102
+ 	#define k_ServiceExists                 103
+ 	#define k_createservicefailed           104
+ 	#define k_removeservicefailed           105
+ 	#define k_ServicenoExists               106
+ 	
+ 	//--------Function declarations----------------------------
+ 	prototype SetupScreen                   ();
+ 	prototype CheckRequirements             ();
+ 	prototype RemoveNTP                     ();
+ 	prototype UpdateModules                 ();
+ 	
+ 	prototype ReportError                   (INT, BYREF STRING);
+ 	prototype DoConfigType                  ();
+ 	prototype CreateConfigFiles             (INT);
+ 	prototype InstallNTPFiles               (STRING, INT);
+ 	prototype RegisterEventlogMessages	    (STRING);
+ 	prototype CheckForService               ();
+ 	prototype GetImagePath                  (BYREF STRING);
+ 	prototype LaunchAppAndWait              (STRING,STRING, INT);
+ 	prototype ReverseOctet                  (BYREF STRING, STRING);
+ 	prototype FixDirectory                  (BYREF STRING, STRING);
+        
+ 
+ //--------------------------------------------------------------------------
+ program
+ 
+ StartHere:
+     Disable( BACKGROUND );
+ 
+     dummy = "   ";
+     // Set default registry tree
+     RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
+ 
+     // Set up the installation screen.
+     SetupScreen();
+     Enable( DIALOGCACHE );
+ 
+ 	TARGETDIR = SUPPORTDIR;
+ 	szDllNTPInst = SUPPORTDIR ^ "NTPDLL.DLL";  // NTP-specific helper library
+ 
+     svDir = WINSYSDISK + "\\";
+     
+     // Module locations, XNTP - NT location
+ 	svModuleDir = WINDISK^"\\win32app\\ntp";
+ 
+ 
+ OfferReadmeFile:
+ 
+ if (AskYesNo("Would you like to see the readme file before proceeding? \n",NO ) = YES) then
+ 	LaunchAppAndWait("NOTEPAD",SUPPORTDIR ^ "README.NT",1);
+ endif;
+ 	
+ CheckForService1:
+     // Look for service
+     if (CheckForService() != 0) then                    // Not clean install
+ 	Disable(BACKBUTTON);
+ 		bUpdateModules = TRUE;
+ 	szMessage = "Setup has determined that the NTP - NT service is\n" +
+ 		    "already present.  Do you want to:\n";
+ 	AskOptions(EXCLUSIVE, szMessage,
+                 
+ 		   "&Remove NTP service", bRemoveNTP,
+ 		   "&Update NTP to this version", bUpdateModules);
+ 				   
+ 	Enable(BACKBUTTON);
+ 	if (bRemoveNTP) then
+ 		if (AskYesNo("Are you certain you wish to remove the NTP service\n" +
+ 				 "and registry entries? \n",NO ) = YES) then
+ 		   RemoveNTP();
+ 		endif;
+ 	endif;
+ 	if (bUpdateModules) then
+ 			UpdateModules();
+ 	endif;
+ 	exit;
+     endif;           
+ // install drops through
+ 
+ DoCleanInstall:
+ 
+     // Defaults
+ 
+     // Create a Welcome dialog.
+ WelcomeDlg:
+     Disable( BACKBUTTON );
+     Welcome( "", 0 );
+     Enable( BACKBUTTON );
+  
+     // Test target system for proper configuration.
+     CheckRequirements();
+ 
+ ModuleDir:  
+     if (AskDestPath("Network Time Protocol Server program file location",
+ 		    "Choose the directory for storage of the NTP support files",
+ 		    svModuleDir,0) = BACK) then
+        goto WelcomeDlg;
+     endif;
+ 	
+ ThatsItDoIt:    
+     
+ 	InstallNTPFiles(svModuleDir,0);  // uncompress & place files in directories
+ 	
+ GetConfigurationType:
+     Disable(BACKBUTTON);
+ 	TARGETDIR = svModuleDir;                // point back to ntp directory
+ 
+ 	SetStatusWindow( 85, "Creating Configuration Files..." );
+ 	DoConfigType();                         // do the configuration for user-spec'd type
+     Enable(BACKBUTTON);
+ 
+ RegistryInit:
+ 
+ 	SetStatusWindow( 90, "Creating NTP Service..." );
+     
+ CreateService:
+         // was svModuleDir^"\\xntpd.exe"
+         nReturnValue2 = CallDLLFx(szDllNTPInst,"CreateNTPService",nValue,WINSYSDIR^"\\xntpd.exe");
+ 	if (nReturnValue2 != 0) then
+ 		ReportError(nReturnValue2,szMessage);
+ 		szMessage = "Unable to install NTP - NT Service entry in Service Control Manager.\n" + szMessage;
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+ 	endif;
+ 
+ 
+ 	SetStatusWindow( 95, "Adding Additional Registry Keys..." );
+ 
+         nReturnValue2 = CallDLLFx(szDllNTPInst,"addKeysToRegistry",nValue,dummy);
+ 	if (nReturnValue2 != 0) then
+ 		szMessage = "Unable to add the Depend on service key in the NT registry\n";
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+ 	endif;
+ 
+ 
+ 	SetStatusWindow( 98, "Starting the Service..." );
+ 
+ StartService:
+     nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);
+     if (nReturnValue2 != 0) then
+ 		ReportError(nReturnValue2,szMessage);
+ 		szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+     endif;
+ 
+    	// Announce setup complete and offer to read README file.e
+    	FinalInstallProcess:
+    	SetStatusWindow( 100, "Installation complete." );
+    	Delay( 2 );
+ 
+    	if (AskYesNo("Setup is complete.  The NTP service is running.\n"+
+ 				"Do you want to look at the documentation for NTP?\n",
+ 				 YES) = YES) then
+ 	    LaunchAppAndWait("WRITE.EXE",TARGETDIR ^ "ntpog.wri",1);
+    	endif;
+ exit;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  InstallNTPFiles()
+  *
+  *  Purpose:  Uncompress the IShield package, and put files in the directory
+  *            passed as an argument.
+  *
+  *              This function used both for new installations, and for the 
+  *              "update modules" function.
+  *
+ \*---------------------------------------------------------------------------*/
+ function InstallNTPFiles(svInstDir,updateonly)
+ 	NUMBER  nResult;
+ 	STRING szBitmapPath;
+ begin
+ 	// szBitmapPath = SUPPORTDIR^"ishield.bmp";
+ 	// PlaceBitmap(szBitmapPath,1,10,10,UPPER_RIGHT);
+ 
+ 	// Insure that directories have sufficient permissions
+ 	//	ReleaseModuleDirSecurity(svInstDir);
+     
+ 	szFileSet = "NetworkTimeProtocolServer";
+ 	FileSetBeginDefine(szFileSet);
+ 
+ 	TARGETDIR = WINSYSDIR;
+ 	SetStatusWindow( -1, "Copying modules..." );
+     //	MessageBox("decompressing data.z: sourcedir = " + SRCDIR + " target dir = " +
+     //                  TARGETDIR,INFORMATION);
+     //  change this to comp update date eventually
+ 
+     if (updateonly != 0)  // update case
+     then
+ 	  // uncomment if adding a Control Panel Applet to package
+  	  //nResult = CompressGet("data.z","*.cpl",COMP_UPDATE_DATE);
+       //if (nResult < 0) then
+       //   NumToStr( szTemp, nResult );
+ 	  //   MessageBox("File Decompression1 failed! ecode = " + szTemp, SEVERE);
+ 	  //   exit;
+ 	  // endif;
+ 
+  	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
+       if (nResult < 0) then
+          NumToStr( szTemp, nResult );
+ 		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
+ 		 exit;
+ 	  endif;
+ 
+     else // not update install all
+  	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
+       if (nResult < 0) then
+          NumToStr( szTemp, nResult );
+ 		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
+ 		 exit;
+ 	  endif;
+ 
+ 	  TARGETDIR = svInstDir;  // set destination directory
+ 
+  	  nResult = CompressGet("data.z","readme.nt",COMP_UPDATE_DATE);
+       if (nResult < 0) then
+          NumToStr( szTemp, nResult );
+ 		 MessageBox("File Decompression3 failed! ecode = " + szTemp, SEVERE);
+ 		 exit;
+       endif;
+ 
+  	  nResult = CompressGet("data.z","ntpog.wri",COMP_UPDATE_DATE);
+       if (nResult < 0) then
+          NumToStr( szTemp, nResult );
+ 		 MessageBox("File Decompression4 failed! ecode = " + szTemp, SEVERE);
+ 		 exit;
+       endif;
+ 
+     endif; // Decompress File end
+ 
+ 	FileSetEndDefine(szFileSet);
+ 	
+     // Set up progress indicator and information gauge.
+     Disable( DIALOGCACHE );
+     Enable( STATUSDLG );
+ 
+     StatusUpdate( ON, 80 );
+ 
+     // Perform the file set.
+     SetStatusWindow( 0, "Copying program files..." );
+     nResult = FileSetPerformEz( szFileSet, 0 );
+ 
+     switch (nResult)
+ 	    case FS_DONE:      // Successful completion.
+ 	    case FS_CREATEDIR: // Create directory error.
+ 		MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
+ 			"Please check write access to this directory.", SEVERE );
+ 		exit;
+ 	default:               // Group all other errors under default label.
+ 		NumToStr( szTemp, nResult );
+ 		MessageBox( "General file transfer error."+
+ 			"Please check your target location and try again."+
+ 			"\n\n Error Number:"+ szTemp +
+ 			"\n Related File: "+ ERRORFILENAME,SEVERE);
+ 		exit;
+     endswitch;
+ 	
+ 	RegisterEventlogMessages(svInstDir);	// put EventLog reg entries in
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  RegisterEventlogMessages
+  *
+  *  Purpose:  Put an entry under the Eventlog registry information, so that
+  *            it understands where to find messages that come from NTP.
+  *
+  *  History:  PIW	Created		12/14/95
+  *
+ \*---------------------------------------------------------------------------*/
+ #define	EVENTLOG_ENTRY "\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\NTP"
+ #define	SERVICE_ENTRY  "\\SYSTEM\\CurrentControlSet\\Services\\NetworkTimeProtocol"
+ 
+ function RegisterEventlogMessages(svTemp)
+ 	NUMBER nvSize;
+ begin
+ 	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
+ 	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"EventMessageFile",
+ 				REGDB_STRING,svTemp^"xntpd.exe",nvSize);
+ 	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"TypeSupported",REGDB_NUMBER,"7",nvSize);
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  DoConfigType
+  *
+  *  Purpose:  Find out what type of installation the user is planning,
+  *            and then create and/or show the configuration files to them.
+  *
+ \*---------------------------------------------------------------------------*/
+ function DoConfigType()
+ 	BOOL bSingleSourceNTP,bSecondarySourceNTP, bNoSourceNTP;
+ begin
+ 	bSingleSourceNTP = FALSE;
+ 	bSecondarySourceNTP = TRUE;
+ 	bNoSourceNTP = FALSE;
+     szMessage = "For creation of configuration files, please select the setup\n" +
+ 		"you want for NTP.  Do you want to set up a:\n";
+     AskOptions(EXCLUSIVE, szMessage,
+ 	       "&Single Time Source", bSingleSourceNTP,
+ 	       "&Two Time Sources", bSecondarySourceNTP,
+ 		   "&Specify No Time Sources", bNoSourceNTP);
+ 			   
+     Enable(BACKBUTTON);
+     if (bSingleSourceNTP) then
+ 	    szMessage = "Please enter the IP address of the Time Source.\n";
+ 	    AskText(szMessage, svNTPAddress, svNTPAddress);
+ 		CreateConfigFiles(ONETIMESOURCE);   // create ntp.conf
+     endif;
+ 	
+     if (bSecondarySourceNTP) then
+ 	    szMessage = "Please enter the IP address of the First Time Source from\n" +
+ 		    "which you will RECEIVE synchronization\n";
+ 	    AskText(szMessage, svNTPAddress, svNTPAddress);
+ 		szMessage = "Please enter the IP address of the Second Time Source from\n" +
+ 			"which you will RECEIVE synchronization\n";
+ 		AskText(szMessage, svNTPAddress2, svNTPAddress2);
+ 		CreateConfigFiles(TWOTIMESOURCES);   // create ntp.conf
+     endif;
+ 	
+ 	if (bNoSourceNTP) then
+ 		CreateConfigFiles(NOTIMEYET);   // create ntp.conf and ntp.drift
+ 	endif;          
+ 	
+     if (AskYesNo("Do you want to see the NTP configuration file which has\n" + 
+ 		     "been created for this host?\n", YES) = YES) then
+ 		// Let them see/edit the files, if they want to:
+ 		LaunchAppAndWait("NOTEPAD.EXE", WINDIR ^ "ntp.conf",1);
+ 	endif;
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  CreateConfigFiles
+  *
+  *  Purpose:  Now that we know the domain name, host name, and IP Address,
+  *            create the configuration files for this NTP to be of type 
+  *            specified by parameter:
+  *                                  ONETIMESOURCE
+  *                                  TWOTIMESOURCES
+  *                                  NOTIMEYET
+  *                        
+  *
+  *    Need to have filled in:  
+  *                              svNTPAddress
+  *                              svNTPAddress2
+  *
+ \*---------------------------------------------------------------------------*/
+ function CreateConfigFiles(nType)
+ 	NUMBER nvFileHandle;
+ 	STRING svInAddrArpa;
+         STRING saveddir;
+         STRING svIP;
+ begin
+ 
+     CreateFile(nvFileHandle,WINDIR,"ntp.conf");
+     WriteLine(nvFileHandle,"#");
+     WriteLine(nvFileHandle,"#    File:       ntp.conf");
+     WriteLine(nvFileHandle,"#    Purpose:    give the NTP Service its startup parameters and");
+     WriteLine(nvFileHandle,"#                list of startup files.");
+     WriteLine(nvFileHandle,"# ");
+     WriteLine(nvFileHandle,"# ");
+ 
+ 	WriteLine(nvFileHandle,"#");
+ 	WriteLine(nvFileHandle,"# Miscellaneous stuff");
+ 	WriteLine(nvFileHandle,"#");
+ 	WriteLine(nvFileHandle,"driftfile %windir%\\ntp.drift        # path for drift file");
+ 	WriteLine(nvFileHandle,"# statsdir c:\\var\\ntp\\stats\\     # directory for statistics files");
+ 	WriteLine(nvFileHandle,"# filegen peerstats file peerstats type day enable");
+ 	WriteLine(nvFileHandle,"# filegen loopstats file loopstats type day enable");
+ 	WriteLine(nvFileHandle,"# filegen clockstats file clockstats type day enable");
+ 
+ 	if (nType != NOTIMEYET) then 
+ 	    WriteLine(nvFileHandle,"#    Need to set up time sources...");
+ 	    WriteLine(nvFileHandle,"#    server ip-address");
+         WriteLine(nvFileHandle,"# ");
+ 	    WriteLine(nvFileHandle,"# ");
+ 	endif;  
+ 	
+ 	
+ 	if (nType = TWOTIMESOURCES) then 
+ 		WriteLine(nvFileHandle,"# ");
+ 		WriteLine(nvFileHandle,"server " + svNTPAddress);
+ 	    WriteLine(nvFileHandle,"server " + svNTPAddress2);
+         WriteLine(nvFileHandle,"# ");
+   	    WriteLine(nvFileHandle,"# ");
+ 	endif;
+ 
+ 	if (nType = ONETIMESOURCE) then
+ 		WriteLine(nvFileHandle," ");
+ 		WriteLine(nvFileHandle,"server " + svNTPAddress);
+         WriteLine(nvFileHandle," ");
+   	    WriteLine(nvFileHandle," ");
+ 	endif;
+     
+     CloseFile(nvFileHandle);
+ 	
+ 	CreateFile(nvFileHandle,WINDIR,"ntp.drift");
+     WriteLine(nvFileHandle,"0 0");
+ 	CloseFile(nvFileHandle);
+ 
+ end;    
+ 
+ 	
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  SetupScreen
+  *
+  *  Purpose:  This function will set up the screen look.  This includes
+  *            colors, fonts, text to be displayed, etc.
+  *
+ \*---------------------------------------------------------------------------*/
+ function SetupScreen()
+ 	INT nDx, nDy;
+ begin
+ 	Enable( DEFWINDOWMODE );
+     Enable( INDVFILESTATUS );
+ 
+ 	//----------------------------------------------------------
+ 	//      If you want to downsize the Blue-fade background:
+ 	//
+ 	//      GetExtents(nDx,nDy);
+ 	//
+ 	//      
+ 	//      PlaceWindow(BACKGROUND,nDx/2,0,UPPER_LEFT);
+ 	//      SizeWindow(BACKGROUND,nDx/2,nDy/2);
+ 	//
+ 	//  However will also have to move all the dialogs/bitmaps
+ 	//  around to make this work correctly...
+ 	//----------------------------------------------------------
+ 	
+     SetTitle( APP_NAME2 + " Setup", 24, WHITE );
+ 
+ 	//    SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
+ 	//    SetColor( STATUSBAR, BLUE );     // Bright blue.
+     SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
+ 
+     Enable( BACKGROUND );
+     Delay( 1 );
+ 
+ 	// Show the bitmap.
+ 	// PlaceBitmap( SUPPORTDIR ^ "NTPNT.BMP",1,10,10,UPPER_RIGHT);
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  * Function:  CheckRequirements
+  *  Purpose:  This function will make sure we are on NT, not Win95.
+ \*---------------------------------------------------------------------------*/
+ function CheckRequirements()
+ 	number nvVersion;
+ 	STRING szResult, svVersion;
+ begin
+     // Determine the target system's operating system.
+     GetSystemInfo( OS, nvVersion, svVersion );
+     if (nvVersion = IS_WINDOWSNT) then
+ 
+ 	    MessageBox("This product can only run on Windows NT", SEVERE);
+ 		exit;
+     endif;
+ end;
+ 
+ //+---------------------------------------------------------------------------
+ //  Member:             ReportError()
+ //----------------------------------------------------------------------------
+ function ReportError(n_Err, sz_Message)
+ 
+ begin
+   switch(n_Err)
+ 	case k_PrivilegeErr:              sz_Message = "Privilege Error";
+ 	case k_CreateKeyErr:              sz_Message = "Create Key Failed";
+ 	case k_RestoreKeyErr:             sz_Message = "Restore Default Key Failed";
+ 	case k_ErrUnableToOpenWriteOwner: sz_Message = "Unable to Open and Write Owner Information";
+ 	case k_ErrUnableToSetOwner:       sz_Message = "Unable to Set Owner Information";
+ 	case k_ErrUnableToOpenDAC:        sz_Message = "Unable to Open Access Control List";
+ 	case k_ErrUnableToWriteDACL:      sz_Message = "Unable to Write Access Control List";
+ 	case k_OpenKeyError:              sz_Message = "Unable to Open Registry Key Entry";
+ 	case k_ModifySetAccountFail:      sz_Message = "Unable to Setup Account Parameters";
+ 	case k_SCMErr:                    sz_Message = "Unable to Open Service Control Manager Database";
+ 	case k_SCMpoErr:                  sz_Message = "Unable to Open NTP - NT service entries in the Service Control Manager";
+ 	case k_DeleteServiceFail:         sz_Message = "Unable to delete NTP - NT service";
+ 	case k_DeleteKeyFail:             sz_Message = "Unable to delete registry key information";
+ 	case k_DeleteValueFail:           sz_Message = "Unable to delete registry value information";
+ 	case k_DirSecurityErr:            sz_Message = "Unable to retreive Security information on directory";
+ 	case k_DirSetDACLErr:             sz_Message = "Unable to add security information on directory";
+ 	case k_DirSetSecurityErr:         sz_Message = "Unable to set directory security information";
+ 	case k_SCMpoStopErr:              sz_Message = "Unable to stop the NTP - NT service";
+ 	case k_SaveKeyErr:                sz_Message = "Unable to save registry key.";
+ 	case k_ServiceUnknownErr:         sz_Message = "The service control manager could not start the NTP - NT service - please check the event log";
+ 	case k_ServiceDependency:         sz_Message = "The NTP - NT service depends on several other services which are not installed.";
+ 	case k_ServiceDependencyFail:     sz_Message = "The NTP - NT service depends on other services which failed to start.";
+ 	case k_ServiceLogonFail:          sz_Message = "The service manager was unable to login the NTP - NT service - Please check the password and logon as service privilege";
+     case k_BadPath:                   sz_Message = "Bad Path Specified."; 
+ 	case k_AccessDenied:              sz_Message = "Access Denied.";
+ 	case k_ServiceExists:             sz_Message = "NTP - NT service already exists so cannot be re-installed";
+     case k_createservicefailed:       sz_Message = "Creation of the NTP - NT service failed.";
+     case k_removeservicefailed:       sz_Message = "Unable to remove the NTP - NT service.";
+ 	case k_ServicenoExists:           sz_Message = "NTP - NT service is not installed so cannot be removed.";
+ 	default:                          sz_Message = "Unknown Error";
+   endswitch;
+ end;
+ 
+ //+---------------------------------------------------------------------------
+ //
+ //  Member:             RemoveNTP()
+ //
+ //  Synopsis:   Remove the NTP service entry and registry entries
+ //
+ //----------------------------------------------------------------------------
+ function RemoveNTP()
+ 	NUMBER n_Result;
+ begin
+ 	
+     dummy = APP_NAME;
+     SetStatusWindow( 0, "Stopping and removing NTP service..." );
+ 	// Remove the NTP service entry & Registry but first stop the service
+  
+     nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
+ 
+ 	if (nReturnValue2 != 0) then
+ 		ReportError(nReturnValue2,szMessage);
+ 		NumToStr( szTemp, nReturnValue2 );
+ 		szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is installed?\n" + szMessage;
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+ 	endif;
+    	Delay( 3 ); // delay for xntpd.exe file to free up so delete works
+ 
+ 
+   	// have to get the currently install directory from the dll by pulling it off of the imagepath param
+     //if (GetImagePath(svModuleDir) != 0) then
+ 	//    szMessage = "Unable to retrieve the path to Remove NTP Files \n" + svModuleDir + 
+     //                    "\nAre you sure it is installed?\n";
+ 	//    MessageBox(szMessage,SEVERE);
+ 	//    exit;
+ 	//endif;
+ 
+ 	n_Result = CallDLLFx(szDllNTPInst,"RemoveNTPService",nValue,dummy);
+ 
+ 	if (n_Result != 0) then            
+ 		MessageBox("Unable to remove NTP - NT service from the registry.",SEVERE);
+                 exit;
+ 	else
+ 	    if (AskYesNo("Service Removed\n Do you want to delete all the NTP Executables and config files also?\n",
+ 				 NO) = YES) then
+ 
+ 			TARGETDIR = WINSYSDIR;                  // pick off the files we put in the 
+ 			DeleteFile("ntpdate.exe");
+ 			DeleteFile("ntpq.exe");
+ 			DeleteFile("ntptrace.exe");
+ 			DeleteFile("xntpdc.exe");
+ 			DeleteFile("xntpd.exe");
+ 			DeleteFile("instsrv.exe");
+ 
+ 			TARGETDIR = svModuleDir;
+ 			DeleteFile("ntpog.wri");
+ 			DeleteFile("readme.nt");
+ 			DeleteDir(svModuleDir, ONLYDIR);
+ 									
+ 
+             TARGETDIR = WINDIR;
+             DeleteFile("ntp.conf");
+             DeleteFile("ntp.drift");
+ 
+ 			MessageBox("NTP - NT service and registry entries are removed.\n" +
+ 					   "All Executable/Config files have been deleted.",INFORMATION);
+ 		else
+ 			MessageBox("NTP - NT service and registry entries are removed.\n" +
+ 					   "All Executable/Config files are retained.",INFORMATION);
+ 		endif;  
+ 	endif;
+ end;
+ 
+  
+ //+---------------------------------------------------------------------------
+ //
+ //  Member:             UpdateModules()
+ //
+ //----------------------------------------------------------------------------
+ function UpdateModules()
+ 	STRING szFileSet;
+ 	STRING szMessage;
+ 	NUMBER nvSize, nvType;
+ begin
+     SetStatusWindow( 0, "Updating NTP installation..." );
+ 
+         nReturnValue2 = CallDLLFx(szDllNTPInst,"StopNTPService",nValue,dummy);
+ 
+ 	if (nReturnValue2 != 0) then
+ 		ReportError(nReturnValue2,szMessage);
+ 		NumToStr( szTemp, nReturnValue2 );
+ 		szMessage = "Unable to Stop the NTP - NT Service. \n" + szTemp + "\nAre you sure it is running?\n" + szMessage;
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+ 	endif;
+    	Delay( 3 ); // delay for xntpd.exe file to free up so copy works
+ 
+ 	// have to get the currently install directory from the dll by pulling it off of the imagepath param
+     if (GetImagePath(svModuleDir) != 0) then
+ 		szMessage = "Unable to retrieve the path to Update NTP Files \n" + svModuleDir + 
+                   "\nAre you sure it is installed?\n";
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+ 	endif;
+ 
+ 	InstallNTPFiles(svModuleDir,1);
+ 	
+     nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);
+ 
+     if (nReturnValue2 != 0) then
+ 		ReportError(nReturnValue2,szMessage);
+ 		szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;
+ 		MessageBox(szMessage,SEVERE);
+ 		exit;
+     endif;
+ 
+ 	SetStatusWindow( 100, "Update completed." );
+ 	Delay( 2 );
+    
+ 	MessageBox("Your Network Time Protocol Server modules have been updated and\n" +
+ 			   "the service restarted.  You should check the event log\n" +
+ 			   "to make sure everything came back up properly.",INFORMATION);
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  GetImagePAth
+  *
+  * Purpose:  Get the given value, under the given key, from the registry.
+  *   l. kahn
+ \*---------------------------------------------------------------------------*/
+ function GetImagePath(svValue)
+ 	NUMBER nvSize;
+ 	NUMBER nvType;
+ begin
+ 
+         RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
+         if (RegDBGetKeyValueEx(SERVICE_ENTRY,
+               "ImagePath",nvType,svValue,nvSize) < 0) then
+ 		return -1;
+ 	endif;
+ 			
+ 	StrSub(svValue,svValue,0,nvSize - 10);                       // trim to REAL length   
+         return 0;
+ end;
+ 
+ function CheckForService()
+         STRING temp;
+ 	NUMBER nvSize;
+ 	NUMBER nvType;
+ begin
+ 
+ 
+ 	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
+         if (RegDBGetKeyValueEx(SERVICE_ENTRY,
+ 			"ImagePath",nvType,temp,nvSize) < 0) then
+ 		return 0;
+ 	endif;
+  return -1;
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  LaunchAppAndWait
+  *
+  *  Purpose:  replace predefined function in more expensive InstallShield 
+  *            with C function.
+  *	l. kahn
+ \*---------------------------------------------------------------------------*/
+ function LaunchAppAndWait(svApp, svData, waitval)
+   STRING tstring;
+ begin
+         nValue = waitval;
+         tstring = svApp+" "+svData;
+         nReturnValue2 = CallDLLFx(szDllNTPInst,"LaunchApp",nValue,tstring);
+         return 0;
+ end;
+ 
+ 
+ /*---------------------------------------------------------------------------*\
+  *
+  * Function:  FixDirectory
+  *
+  *  Purpose:  put the double slashes in the directory
+  *  l. kahn
+ \*---------------------------------------------------------------------------*/
+ function FixDirectory(svOut,svIn)
+ 
+ INT len;
+ INT ctr;
+ NUMBER letter;
+ INT i;
+ 
+ begin
+  len = StrLength(svIn) - 1;
+  ctr = 0;
+ 
+  for i = 0 to len
+     GetByte(letter,svIn,i);
+     if (letter = 92)
+       then
+        SetByte(svOut,ctr,letter);
+        ctr = ctr + 1;
+     endif;
+ 
+     SetByte(svOut,ctr,letter);
+     ctr = ctr + 1;
+  endfor;
+ end;
diff -N -x *.mak -c -r xntp3-5.86/xntpd/ntp_refclock.c xntp/xntpd/ntp_refclock.c
*** xntp3-5.86/xntpd/ntp_refclock.c	Thu Jan 01 00:00:35 1970
--- xntp/xntpd/ntp_refclock.c	Sun Oct 20 23:19:08 1996
***************
*** 110,115 ****
--- 110,123 ----
  extern	int	initializing;
  extern	int	debug;
  
+ #ifdef SYS_WINNT
+ /*
+  * Imported from the ntpd.c module.
+  */
+ extern HANDLE m_hListMutex;
+ #endif /* SYS_WINNT */
+ 
+ 
  /*
   * Type/unit peer index. Used to find the peer structure for control and
   * debugging. When all clock drivers have been converted to new style,
diff -N -x *.mak -c -r xntp3-5.86/xntpd/ntp_unixclock.c xntp/xntpd/ntp_unixclock.c
*** xntp3-5.86/xntpd/ntp_unixclock.c	Wed Dec 31 23:58:47 1969
--- xntp/xntpd/ntp_unixclock.c	Sun Oct 20 22:55:08 1996
***************
*** 396,402 ****
--- 396,404 ----
  # endif /* } not HAVE_K_OPEN */
  #endif /* not NOKMEM */
  #endif /* not SYS_WINNT */
+ #ifndef SYS_WINNT
      }
+ #endif /* SYS_WINNT */
  
      /* Skippy says we need to know TICK before handling TICKADJ */
      {
***************
*** 415,421 ****
  # endif /* HAVE_SYS_TIMEX_H && HAVE___ADJTIMEX */
  	*ptick = (u_long) PRESET_TICK;
  #else  /* PRESET_TICK */
! # ifdef NOKMEM
  #  include "Bletch: NOKMEM and no PRESET_TICK"
  # endif /* NOKMEM */
  # ifdef HAVE_K_OPEN
--- 417,426 ----
  # endif /* HAVE_SYS_TIMEX_H && HAVE___ADJTIMEX */
  	*ptick = (u_long) PRESET_TICK;
  #else  /* PRESET_TICK */
! # ifdef SYS_WINNT
! 	*ptick = (u_long) (every * 0.1);
! #else
! #ifdef NOKMEM
  #  include "Bletch: NOKMEM and no PRESET_TICK"
  # endif /* NOKMEM */
  # ifdef HAVE_K_OPEN
***************
*** 464,472 ****
  			exit(3);
  		}
  	}
! #   endif
! #  endif /* not HAVE_KVM_OPEN */
! # endif /* not HAVE_K_OPEN */
  #endif /* not PRESET_TICK */
  	
  	tick = *ptick;		/* This might be used by PRESET_TICKADJ */
--- 469,478 ----
  			exit(3);
  		}
  	}
! #    endif /* NLIST_EXTRA_INDIRECTION */
! #   endif /* not HAVE_KVM_OPEN */
! #  endif /* not HAVE_K_OPEN */
! # endif /* not SYS_WINNT */
  #endif /* not PRESET_TICK */
  	
  	tick = *ptick;		/* This might be used by PRESET_TICKADJ */
