//	services.inc

//
//	Setup required registry values for the Config DLL.
//
//		$0 = Line Type
//		$1 = Line Name
//		$2 = Line Key
//		$3 = Adapter Name 
//
[CopyPVCData]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set Type = $($0)
	set Line = $($1)
	set KeyLine = $($2)
	set AdapterName = $($3)
	_Enter("CopyPVCData", _Show(Type)_Show(Line)_Show(KeyLine)_Show(AdapterName))

	read-syms DriverConstants-$(Type)

   set KeyParams = KEY_NULL
   _OpenServiceParamKey($(AdapterName), KeyParams)
	_IfNotValidKey($(KeyParams))
      _AssertGoto(FALSE, Exit)
	endif

	_OpenRegKey($(KeyParams), $(LineServiceKeyName)\$(Line), KeyPVC)
	_IfNotValidKey($(KeyPVC))
      _AssertGoto(FALSE, Exit)
	endif

	_LocalShell EnumAdapters { $(Type) } TRUE
	set AdapterDataList = $($R0)

	ForListDo $(AdapterDataList)
		set ServiceName = *($($), 1)
		set NetworkCardKey = *($($), 3)

  		_OpenServiceParamKey($(ServiceName), KeyVirtualAdapterService)

		_GetRegSzByKey $(KeyVirtualAdapterService) DXB_REGVAL_ADAPTER
      _AssertGoto($($R0), NextNetCard)
		ifstr(i) $($R1) != $(AdapterName)
		  goto NextNetCard
		endif

		_GetRegSzByKey $(KeyVirtualAdapterService) "Line"
      _AssertGoto($($R0), NextNetCard)
		ifstr(i) $($R1) != $(Line)
		  goto NextNetCard
		endif

		_GetRegSzByKey $(NetworkCardKey) "Title"
      _AssertGoto($($R0), NextNetCard)
	   set Description = $($R1)

		_SetRegSzByKey $(KeyVirtualAdapterService) "Description" $(Description)
      _AssertGoto($($R0), NextNetCard)

		_GetRegSzByKey $(KeyVirtualAdapterService) DXB_REGVAL_REGPATH
      _AssertGoto($($R0), NextNetCard)
		set Circuit = $($R1)

		_MakeStdRegKey($(!REG_H_LOCAL), $(!NTN_ServiceBase)"\\"$(Circuit), PVCKey)
      _IfNotValidKey($(PVCKey))
         _AssertGoto(FALSE, NextNetCard)
      endif

		_LocalShell CopyRegTree $(KeyVirtualAdapterService) $(PVCKey)
      _AssertGoto($($R0), NextNetCard)
		
		CloseRegKey $(PVCKey)

NextNetCard = +	

	   CloseRegKey $(NetworkCardKey)
	EndForListDo

	CloseRegKey $(KeyParams)
	CloseRegKey $(KeyPVC)

Exit = +
	_Exit("CopyPVCData", "")
	Return

//
//	Find router adapter and copy parameters to the adapter.
//
//		$0 = Parameters key for adapter.
//
[CopyRouterData]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-X25

	set KeyParameters = $($0)
	_Enter("CopyRouterData", _Show(KeyParameters))

	set KeyX25Adapter = KEY_NULL
	set AdapterNumber = EMPTY_STR

	_LocalShell FindAdapter $(ProductSoftwareName)
	_If($($R0))
		set AdapterNumber = $($R1)

		_OpenServiceParamKey($(ProductHardwareName)$(AdapterNumber), KeyX25Adapter)
		_MakeStdRegKey($(KeyParameters), DXB_REGVAL_ROUTER_TYPE_WANX, KeyX25Route)

		_LocalShell CopyRegTree $(KeyX25Adapter) $(KeyX25Route)

		_CloseRegKey($(KeyX25Adapter))
		_CloseRegKey($(KeyX25Route))
	endif

	_Exit("CopyRouterData", "")
	Return

//
//	Look for routing adapters and copy their parameters to the adapter.
//
//		$0 = Parameters key for adapter.
//
[UpdateRouter]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-X25

	set KeyParameters = $($0)
	_Enter("UpdateRouter", _Show(KeyParameters))

	set KeyX25Adapter = KEY_NULL
	set AdapterNumber = EMPTY_STR

	_LocalShell FindAdapter $(ProductSoftwareName)
	_If($($R0))
		set AdapterNumber = $($R1)

		_OpenServiceParamKey($(ProductHardwareName)$(AdapterNumber), KeyX25Adapter)
		_OpenRegKey($(KeyParameters), DXB_REGVAL_ROUTER_TYPE_WANX, KeyX25Route)

      _IfValidKey($(KeyX25Route))
		   _LocalShell CopyRegTree $(KeyX25Route) $(KeyX25Adapter)
		   _CloseRegKey($(KeyX25Route))
      endif
	endif

	_Exit("UpdateRouter", "")
	Return

//
//	Sets the service's start value
//
//		$0 = Service name
//		$1 = On/Off
//
[ToggleServiceStartValue]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set ServiceName = $($0)
	set Toggle = $($1)
	_Enter("ToggleServiceStartValue", _Show(ServiceName)_Show(Toggle))

   set KeyService = KEY_NULL

   _OpenRegKey_HKLM($(!NTN_ServiceBase)"\\"$(ServiceName), KeyService)
   _IfValidKey($(KeyService))

#define SERVICE_START_DISABLED   4

      set Start = SERVICE_START_DISABLED

      ifstr(i) $(Toggle) == "On"
		   _GetRegDwordByKey $(KeyService) "PrevStart"
         _If($($R0))
		      set Start = $($R1)
         else
            _Warning("Couldn't read previous start value!","")
            goto Exit
         endif
      else
		   _GetRegDwordByKey $(KeyService) "Start"
			_AssertGoto($($R0), Exit)
			ifint $($R1) != 4
				_SetRegDwordByKey $(KeyService) "PrevStart" $($R1)
				_Assert($($R0))
			endif
      endif

      _Trace("Toggling", _Show(ServiceName)_Show(Start))
      _SetRegDwordByKey $(KeyService) "Start" $(Start)
      _Assert($($R0))
   endif

Exit = +

	_CloseRegKey($(KeyService))

	_Exit("ToggleServiceStartValue", "")
	Return

//
//	Cleanup registry values after the Config DLL.
//
//		$0 = Line Type
//		$1 = Line Name
//		$2 = Line Key
//
[CleanUpAfterConfig]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set Type = $($0)
	set Line = $($1)
	set LineKey = $($2)
	_Enter("CleanUpAfterConfig", _Show(Type)_Show(Line)_Show(LineKey))

	read-syms DriverConstants-$(Type)

	ifstr(i) $(Type) == "ASYN"

		_UtilityShell IsRefCountEqualZero $(ProductKeyName)
		_If($($R1))
   			_LocalShell ToggleServiceStartValue $(ProductSoftwareName) "Off"
		endif

	else

		_LocalShell FindAdapter $(ProductHardwareName)

		_IfNot($($R0))
			_Trace("No Adapter", _Show(ProductHardwareName))
   			_LocalShell ToggleServiceStartValue $(ProductSoftwareName) "Off"
		else
			_Trace("Found Adapter", _Show(ProductHardwareName))
   			_LocalShell ToggleServiceStartValue $(ProductSoftwareName) "On"
		endif

	endif

	_Exit("CleanUpAfterConfig", "")
	Return

//
//	Adds driver software and registry entries.
//
//		$0 = Option
//
//		$R0 = Boolean indicating success.
//
[AddService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms Identification

	set Option = $($0)
	_Enter("AddService", _Show(Option))

	read-syms DriverConstants-$(Option)
	read-syms $(Option)-Strings-$(!STF_LANGUAGE)

	set Installed = TRUE

	set SoftwareInstalled = FALSE

	set KeyProduct = KEY_NULL
	set KeyNetRules = KEY_NULL
	set KeyService = KEY_NULL
	set KeyParameters = KEY_NULL
	set KeyLinkage = KEY_NULL

   // Check to see if its already installed	
	_OpenRegKey_HKLM($(ProductKeyName), KeyProduct)
	_IfValidKey($(KeyProduct))
   	_LocalShell ToggleServiceStartValue $(ProductSoftwareName) "On"
		goto Exit
	endif

	StartWait

   //
   // From UTILITY.INF
   //
   // [AddSoftwareComponent]
   //    set MfgName       = $($0)
   //    set ProdName      = $($1)
   //    set SvcName       = $($2)
   //    set DisplayName   = $($3)
   //    set Infname       = $($4)
   //    set ImagePath     = $($5)
   //    set ServiceType   = $($6)
   //    set Group         = $($7)
   //    set Dependencies  = $($8)
   //    set ObjectName    = $($9)
   //    set EventFile     = $($10)
   //    set TypeSupported = $($11)
   //    set EventLocation = $($12)
   //    set ErrorCtlValue = $($13)
   //    set EventSource   = $($14)
   //    set ParamMsgFile  = $($15)
   //    set KeySrvcsArea  = $($16)

	_UtilityShell AddSoftwareComponent +
		$(Manufacturer), +
		$(ProductSoftwareName) +
		$(ProductSoftwareName) +
		$(DriverTitle) +
		$(STF_CONTEXTINFNAME) +
		$(ProductSoftwareImagePath) +
		$(ServiceType) +
		$(Group) +
		$(DependsOn) +
		EMPTY_STR +
		$(ProductSoftwareImagePath)";"$(IoLogMsgDLLPath)
   _OnShellErrorGoto(Error)
   _OnUtilityShellErrorGoto($($R0), Error)

	set KeyProduct = $($R1)
	set KeyNetRules = $($R2)
	set KeyService = $($R3)
	set KeyParameters = $($R4)
	set KeyLinkage = $($R5)

	set SoftwareInstalled = TRUE

	_LocalShell GetElapsedTime
	set CurrentTime = $($R0)

   // HKLM\SOFTWARE\$(Manufacturer)\$(ProductSoftwareName)\CurrentVersion
	set ProductValueList = { +
		_MakeSzData("SoftwareType", $(SoftwareType)), +
		_MakeSzData("SoftwareVersion", $(InstallVersion)), +
		_MakeSzData("ProductVersion", $(ProductVersion)), +
		_MakeSzData("MajorVersion", $(ProductMajorVersion)), +
		_MakeSzData("MinorVersion", $(ProductMinorVersion)), +
		_MakeSzData("BuildNumber",  $(ProductBuildNumber)), +
		_MakeSzData("Title", $(DriverTitle)), +
		_MakeSzData("Description", $(DriverDescription)), +
		_MakeSzData(DXB_REGVAL_SERVICENAME, $(ProductSoftwareName)), +
		_MakeDwordData("Review", $(Review)), +
		_MakeDwordData("InstallDate", $(CurrentTime)), +
		_MakeDwordData("Hidden", $(Hidden)) }

	_LocalShell SetValuesFromList $(KeyProduct) $(ProductValueList)
   _AssertGoto($($R0), Error)
		
   // HKLM\SOFTWARE\$(Manufacturer)\$(ProductSoftwareName)\CurrentVersion\NetRules
	set NetRulesValueList = { +
		_MakeSzData("type", $(NetRuleSoftwareType)), +
		_MakeSzData("use", $(NetRuleSoftwareUse)), +
		_MakeSzData("bindform", $(NetRuleSoftwareBindForm)), +
		_MakeMultiSzData("class", $(NetRuleSoftwareClass)), +
		_MakeMultiSzData("bindable", $(NetRuleSoftwareBindable)), +
		_MakeSzData("InfOption", $(Option)) }

	_LocalShell SetValuesFromList $(KeyNetRules) $(NetRulesValueList)
   _AssertGoto($($R0), Error)

   // HKLM\SOFTWARE\$(Manufacturer)\$(ProductSoftwareName)\CurrentVersion\Linkage
	ifstr(i) $(DependOnGroup) != EMPTY_LIST
		set OtherDependenciesList = { +
			_MakeMultiSzData("OtherDependencies", $(DependOnGroup)) }

		_LocalShell SetValuesFromList $(KeyLinkage) $(OtherDependenciesList)
	   _AssertGoto($($R0), Error)

	endif

	goto Exit

Error = +

	_If($(SoftwareInstalled))
		set SoftwareInstalled = FALSE
		_UtilityShell RemoveSoftwareComponent $(Manufacturer) $(ProductSoftwareName) "FALSE"
#if defined(_DEBUG)
      _ShellError(Dontcare)
      _UtilityShellError($($R0), Dontcare)
#endif
	endif

	set Installed = FALSE

Exit = +

	_CloseRegKey($(KeyProduct))
	_CloseRegKey($(KeyNetRules))
	_CloseRegKey($(KeyService))
	_CloseRegKey($(KeyParameters))
	_CloseRegKey($(KeyLinkage))

	EndWait

	_Exit("AddService", _Show(Installed))
	Return $(Installed)

//	Generic overview of main entry points:
//
//	[SetUp-<service>] shell section
//
//		Run before the config DLL is, but not on an install.
//
//		$0 = Line Name
//		$1 = Line key
//		$2 = Adapter service name
//
//	[CleanUp-<service>] shell section
//
//		Run after the config DLL, including on install.
//
//		$0 = Line Name
//		$1 = Line key
//		$2 = Adapter service name
//		$3 = Config result
//
//	[Add-<service>] shell section
//
//		Add a service on a line.
//
//		$0 = Line Name
//		$1 = Line key
//		$2 = Adapter service name
//		$3 = Line Number
//		$4 = Source dir
//		$5 = Option
//
//		$R0 = Boolean indicating service installed.
//
//	[Remove-<some service>] shell section
//
//		Remove a service from a line.
//
//		$0 = Line Name
//		$1 = Line key
//		$2 = Adapter service name
//
//	[Config-<service>] shell section
//
//		Post-config DLL stuff, only called if the user hits the OK button.
//
//		$0 = Line Name
//		$1 = Line key
//		$2 = Adapter service name
//		$3 = Option
//
//		$R0 = Boolean indicating success
//		$R1 = Needs binding review
//

#if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)
//	********************************************************************************
//	Frame Relay main entry points:
//	********************************************************************************

//
//	Scans registry for FR DLCIs belonging to a port and copys their params so the config DLL can change them.
//	Data is copied to System\CurrentControlSet\Services\DigiDxb#\nnnn\FR
//   nnnn is line/port number
//	 # is the adapter number from Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\#
//
[SetUp-FRService]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("SetUp-FRService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_LocalShell CopyPVCData "FR" $(Line) $(KeyLine) $(AdapterServiceName)

	_Exit("SetUp-FRService", "")
	Return

//
//	Deletes data copied DLCI params from the port
//
//		data is deleted from System\CurrentControlSet\Services\DigiDxb#\nnnn\FR
//
[CleanUp-FRService]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-FRService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_LocalShell CleanUpAfterConfig "FR" $(Line) $(KeyLine)

	_Exit("CleanUp-FRService", "")
	Return

//
//	Add DigiFR driver only if not already done
//
[Add-FRService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-FR

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-FRService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	_LocalShell AddService "FR"
	set Installed = $($R0)
   _AssertGoto($(Installed), Exit)

	_UtilityShell IncrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Add-FRService", _Show(Installed))
	Return $(Installed)

//
//	Removes all DLCIs from a port and DigiFR driver when no DLCIs anywhere exist.
//
[Remove-FRService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-FR

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-FR", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_LocalShell RemoveVirtualAdapters "FR" $(Line) $(AdapterServiceName) $(Manufacturer)

	_UtilityShell DecrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Remove-FRService", "")
	Return

//
//	Adds, removes, or copies config params to DLCIs
//
[Config-FRService]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-FRService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	_LocalShell CreateVirtualAdapters "FR" $(Line) $(AdapterServiceName) $(Option)
	set Success = $($R0)	
	set NeedBindingReview = $($R1)

   // This is pretty much a hack.  This is what happens; CreateVirtualAdapter above will
   // create any newly added adapters, copying any params from Dxb.  Then this call to
   // SetupUpForConfig will copy any params written in those new adapter keys back to the
   // Dxb key.  Pretty stupid, and probably a lot of work.
	_LocalShell CopyPVCData "FR" $(Line) $(KeyLine) $(AdapterServiceName)

	_Exit("Config-FRService", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)

#if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)
//	********************************************************************************
//	X.25 main entry points:
//	********************************************************************************

//
//	Removes a number TAPI device address used on a port.
//	Scans registry for X.25 PVCs belonging to a port and copys their params	so the config DLL can change them.
//
//		data is copied to System\CurrentControlSet\Services\DigiDxb#\nnnn\X25
//		nnnn is line/port number
//		# is the adapter number from Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\#
[SetUp-X25Service]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-X25Service", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_LocalShell CopyPVCData "X25L" $(Line) $(KeyLine) $(AdapterServiceName)

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))
	   _LocalShell CopyRouterData $(KeyAdapterParams)
   endif
	
	_Exit("SetUp-X25Service", "")
	Return

//
//	Adds a number TAPI device address used on a port
//	Deletes data copied PVCs params from the port
//		data is deleted from System\CurrentControlSet\Services\DigiDxb#\nnnn\X25
[CleanUp-X25Service]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-X25Service", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_LocalShell CleanUpAfterConfig "X25L" $(Line) $(KeyLine)
	
	_Exit("CleanUp-X25Service", "")
	Return

//
//	Add DigiX25 and DigiLAN driver only if not already done
//	Add X25 routing adapter only if not already done
//
[Add-X25Service]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-X25Service", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	_LocalShell AddService "X25"
	set Installed = $($R0)
   _AssertGoto($(Installed), Exit)

	read-syms DriverConstants-X25
	_LocalShell FindAdapter $(ProductHardwareName)

   _IfNot($($R0))
	   _LocalShell AddVirtualAdapter "X25" $(Line) $(AdapterServiceName) EMPTY_STR $(Option) EMPTY_STR
      _Assert($($R0))
   else
	   set VAdapterNum = $($R1)
	   _UtilityShell IncrementRefCount $(KEY_NETWORKCARDS)"\\"$(VAdapterNum)
   endif

	read-syms DriverConstants-X25L
	_LocalShell AddService "X25L"
	_UtilityShell IncrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Add-X25Service", _Show(Installed))
	Return $(Installed)

//
//	Removes all PVCs from a port and DigiLAN driver when no PVCs anywhere exist.
//	Removes a number TAPI device address used on a port.
//	Removes DigiX25 driver and routing adapter when X.25 is no longer used on any port
//
[Remove-X25Service]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-X25Service", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	read-syms DriverConstants-X25L
	_LocalShell	RemoveVirtualAdapters "X25L" $(Line) $(AdapterServiceName) $(Manufacturer)

	_UtilityShell DecrementRefCount $(ProductKeyName)

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), DXB_REGVAL_ROUTER_TYPE_WANX,  KeyWanX)
	   _IfValidKey($(KeyWanX))

	      _OpenRegKey($(KeyAdapterParams), $(Line)\\DXB_REGVAL_PROTOCOL_ENUM_X25, KeyX25Line)
	      _IfValidKey($(KeyX25Line))

	         _GetRegSzByKey $(KeyX25Line) "Alias"
            _Assert($($R0))
	         set ThisAlias = $($R1)

	         read-syms DriverConstants-X25
      	   _LocalShell FindAdapter $(ProductHardwareName)
            _Assert($($R0))
	         set RouterVAdapterNum = $($R1)

	         // Remove routing table and alias stuff.
	         _OpenServiceParamKey($(ProductHardwareName)$(RouterVAdapterNum), KeyX25Adapter)
   	      _IfValidKey($(KeyX25Adapter))

	            set AliasList = EMPTY_LIST
	            set DeviceList = EMPTY_LIST
	            set SnidList = EMPTY_LIST
	            set NumVCList = EMPTY_LIST

	            _GetRegMultiSzByKey $(KeyX25Adapter) "Alias"
               _If($($R0))
	               set AliasList = $($R1)
               endif

	            _GetRegMultiSzByKey $(KeyX25Adapter) "Device"
               _If($($R0))
	               set DeviceList = $($R1)
               endif

	            _GetRegMultiSzByKey $(KeyX25Adapter) "Snid"
               _If($($R0))
	               set SnidList = $($R1)
               endif

	            _GetRegMultiSzByKey $(KeyX25Adapter) "NumVC"
               _If($($R0))
	               set NumVCList = $($R1)
               endif

	            set NewAliasList = EMPTY_LIST
	            set NewDeviceList = EMPTY_LIST
	            set NewSnidList = EMPTY_LIST
	            set NewNumVCList = EMPTY_LIST

	            set NewTotal = 0
	            ForListDo $(AliasList)

		            set Alias = *($(AliasList), $(#))
		            set Device = *($(DeviceList), $(#))
		            set Snid = *($(SnidList), $(#))
		            set NumVC = *($(NumVCList), $(#))

		            ifstr(i) $(ThisAlias) != $(Alias)
			            set NewAliasList = >($(NewAliasList), $(Alias))
			            set NewDeviceList = >($(NewDeviceList), $(Device))
			            set NewSnidList = >($(NewSnidList), $(Snid))
			            set NewNumVCList = >($(NewNumVCList), $(NumVC))

			            set-add NewTotal = $(NewTotal), $(NumVC)
		            endif
	            EndForListDo

	            _SetRegMultiSzByKey $(KeyX25Adapter) "Alias" $(NewAliasList)
               _Assert($($R0))
	            _SetRegMultiSzByKey $(KeyX25Adapter) "Device" $(NewDeviceList)
               _Assert($($R0))
	            _SetRegMultiSzByKey $(KeyX25Adapter) "SNID" $(NewSnidList)
               _Assert($($R0))
	            _SetRegMultiSzByKey $(KeyX25Adapter) "NumVC" $(NewNumVCList)
               _Assert($($R0))

	            // Expose no more than 255 tapi key's in NT 3.51
	            ifint $(NewTotal) > 255
                  ifstr(i) $(!NTVER) == "3.51"
			            set NewTotal = 255
		            endif
	            endif

	            _SetRegDwordByKey $(KeyX25Adapter) "NumRASPorts" $(NewTotal)
               _Assert($($R0))


	            set RouteAddressList = EMPTY_LIST
	            set RouteAliasList = EMPTY_LIST)

	            _GetRegMultiSzByKey $(KeyX25Adapter) "RouteAddress"
               _If($($R0))
	               set RouteAddressList = $($R1)
               endif

	            _GetRegMultiSzByKey $(KeyX25Adapter) "RouteAlias"
               _If($($R0))
	               set RouteAliasList = $($R1)
               endif

	            set NewRouteAddressList = EMPTY_LIST
	            set NewRouteAliasList = EMPTY_LIST

	            ForListDo $(RouteAliasList)
		            set RouteAddress = *($(RouteAddressList), $(#))
		            set RouteAlias = *($(RouteAliasList), $(#))

		            ifstr(i) $(RouteAlias) != $(ThisAlias)
			            set NewRouteAddressList = >($(NewRouteAddressList), $(RouteAddress))
			            set NewRouteAliasList = >($(NewRouteAliasList), $(RouteAlias))
		            endif
	            EndForListDo
	            
	            _SetRegMultiSzByKey $(KeyX25Adapter) "RouteAddress" $(NewRouteAddressList)
               _Assert($($R0))
	            _SetRegMultiSzByKey $(KeyX25Adapter) "RouteAlias" $(NewRouteAliasList)
               _Assert($($R0))

	            CloseRegKey $(KeyX25Adapter)
            endif

	         CloseRegKey $(KeyX25Line)
			 DeleteRegTree $(KeyAdapterParams) $(Line)\\DXB_REGVAL_PROTOCOL_ENUM_X25
         endif

      	CloseRegKey $(KeyWanX)
      endif

	   CloseRegKey $(KeyAdapterParams)
   endif

	_LocalShell SetTapi "X25" $(RouterVAdapterNum) $(NewTotal) SETTAPI_ADDRSCHEME_ENDPOINT
	_LocalShell RemoveVirtual "X25" $(RouterVAdapterNum) $(Manufacturer)

	_Exit("Remove-X25Service", "")
	Return

//
//	Copies important data to X.25 routing adapter.
//
[Config-X25Service]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-X25Service", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	_LocalShell CreateVirtualAdapters "X25L" $(Line) $(AdapterServiceName) $(Option)
	set Success = $($R0)	
	set NeedBindingReview = $($R1)

   // This is pretty much a hack.  This is what happens; CreateVirtualAdapter above will
   // create any newly added adapters, copying any params from Dxb.  Then this call to
   // SetupUpForConfig will copy any params written in those new adapter keys back to the
   // Dxb key.  Pretty stupid, and probably a lot of work.
	_LocalShell CopyPVCData "X25L" $(Line) $(KeyLine) $(AdapterServiceName)

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))
	   _LocalShell UpdateRouter $(KeyAdapterParams)
   endif

	_Exit("Config-X25Service", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)

#if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)
//	********************************************************************************
//	SNA main entry points:
//	********************************************************************************

//
//
//
[SetUp-SNAService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-SNAService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_Exit("SetUp-SNAService", "")
	Return

//
//
//
[CleanUp-SNAService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-SNAService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_Exit("CleanUp-SNAService", "")
	Return

//
//
//
[Add-SNAService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-SNAService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	set Installed = TRUE

	_Exit("Add-SNAService", _Show(Installed))
	Return $(Installed)

//
//
//
[Remove-SNAService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-SNAService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_Exit("Remove-SNAService", "")
	Return

//
//
//
[Config-SNAService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-SNAService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-SNA

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName)"\\"$(Line),  KeyLineService)
	   _IfValidKey($(KeyLineService))
		set	DeviceName = $(AdapterServiceName)  
		ifcontains(i) $(Option) in $(OptionsThatNeedStreams)

			read-syms DriverConstants-Streams
			set DeviceName = $(ProductSoftwareName)

		endif 

	     _SetRegSzByKey $(KeyLineService) DXB_REGVAL_ADAPTER $(AdapterServiceName)
	     _SetRegSzByKey $(KeyLineService) DXB_REGVAL_DEVICE $(DeviceName)
         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	set Success = TRUE
	set NeedBindingReview = FALSE

	_Exit("Config-SNAService", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)

#if defined(SUPPORT_HOUSTON) || defined(SUPPORT_LONDON) || defined(SUPPORT_CHASKA) || defined(SUPPORT_ACCELEPORT_2000)
//	********************************************************************************
//	Asyn main entry points:
//	********************************************************************************

//
//
//
[SetUp-ASYN]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-ASYN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   // Nothing much to do here

	_Exit("SetUp-ASYN", "")
	Return

//
//
//
[CleanUp-ASYN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ASYN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-ASYN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_LocalShell CleanUpAfterConfig "ASYN" $(Line) $(KeyLine)

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

		   EnumRegKey $(KeyLineService) SubKeyList
         CloseRegKey $(KeyLineService)

         _Trace("Found", _Show(SubKeyList))
         _IfEmptyList($(SubKeyList))
            // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ASYN
            _Trace("DeleteRegTree", _Show(LineServiceKeyName))
	         DeleteRegTree $(KeyAdapterParams) $(LineServiceKeyName)
         endif
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_Exit("CleanUp-ASYN", "")
	Return

//
//
//
[Add-ASYN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ASYN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-ASYN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	_LocalShell AddService "ASYN"
	set Installed = $($R0)
   _AssertGoto($(Installed), Exit)

	_UtilityShell IncrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Add-ASYN", _Show(Installed))
	Return $(Installed)

//
//
//
[Remove-ASYN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ASYN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-ASYN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

         // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ASYN\#
	      DeleteRegTree $(KeyLineService) $(Line)

		   EnumRegKey $(KeyLineService) SubKeyList
         _IfEmptyList($(SubKeyList))

	         _OpenServiceParamKey($(ProductHardwareName), KeyAsynParams)
	         _IfValidKey($(KeyAsynParams))

               // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiAsyn\Parameters\$(AdapterServiceName)
	            DeleteRegTree $(KeyAsynParams) $(AdapterServiceName)

               CloseRegKey $(KeyAsynParams)
            endif

         endif

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_UtilityShell DecrementRefCount $(ProductKeyName)

	_Exit("Remove-ASYN", "")
	Return

//
//
//
[Config-ASYN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ASYN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-ASYN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	set Success = FALSE
	set NeedBindingReview = FALSE

   // Make sure HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ASYN\# exists
   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _MakeStdRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

	      _MakeStdRegKey($(KeyLineService), $(Line),  KeyLineServiceLine)
	      _IfValidKey($(KeyLineServiceLine))
            CloseRegKey $(KeyLineServiceLine)
         endif

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

   // Now link it up
	_OpenServiceParamKey($(ProductHardwareName), KeyAsynParams)
	_IfValidKey($(KeyAsynParams))

      _MakeStdRegKey($(KeyAsynParams), $(AdapterServiceName), KeyAsynParamsAdapter)
	   _IfValidKey($(KeyAsynParamsAdapter))

         _SetRegSzByKey $(KeyAsynParamsAdapter) DXB_REGVAL_ADAPTER $(AdapterServiceName)
         _SetRegSzByKey $(KeyAsynParamsAdapter) DXB_REGVAL_DEVICE $(AdapterServiceName)
         set RegPath = $(AdapterServiceName)"\\Parameters\\"$(LineServiceKeyName)
         _SetRegSzByKey $(KeyAsynParamsAdapter) DXB_REGVAL_REGPATH $(RegPath)

         CloseRegKey $(KeyAsynParamsAdapter)
      endif

      CloseRegKey $(KeyAsynParams)
   endif

	set Success = TRUE

Exit = +

	_Exit("Config-ASYN", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_HOUSTON) || defined(SUPPORT_LONDON) || defined(SUPPORT_CHASKA) || defined(SUPPORT_ACCELEPORT_2000)

#if defined(SUPPORT_HOUSTON) || defined(SUPPORT_LONDON) || defined(SUPPORT_PRIME)
//	********************************************************************************
//	ISDN main entry points:
//	********************************************************************************

//
//
//
[SetUp-ISDN]
	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-ISDN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   // Nothing much to do here

	_Exit("SetUp-ISDN", "")
	Return

//
//
//
[CleanUp-ISDN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ISDN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-ISDN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_LocalShell CleanUpAfterConfig "ISDN" $(Line) $(KeyLine)
   
   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

		   EnumRegKey $(KeyLineService) SubKeyList
         CloseRegKey $(KeyLineService)

         _Trace("Found", _Show(SubKeyList))
         _IfEmptyList($(SubKeyList))
            // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ISDN
            _Trace("DeleteRegTree", _Show(LineServiceKeyName))
	         DeleteRegTree $(KeyAdapterParams) $(LineServiceKeyName)
         endif
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_Exit("CleanUp-ISDN", "")
	Return

//
//
//
[Add-ISDN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ISDN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-ISDN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	_LocalShell AddService "ISDN"
	set Installed = $($R0)
   _AssertGoto($(Installed), Exit)

	_UtilityShell IncrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Add-ISDN", _Show(Installed))
	Return $(Installed)

//
//
//
[Remove-ISDN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ISDN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-ISDN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

	      _OpenRegKey($(KeyLineService), $(Line),  KeyLineServiceLine)
	      _IfValidKey($(KeyLineServiceLine))
	         set VAdapterNum = EMPTY_STR
	         _GetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE
            _If($($R0))
	            set VAdapterNum = $($R1)
            endif

            _IfNotEmptyStr($(VAdapterNum))
	            _LocalShell RemoveVirtual "ISDN" $(VAdapterNum) $(Manufacturer)
               _LocalShell SetTapi "ISDN" $(VAdapterNum) 0 SETTAPI_ADDRSCHEME_LINE
            endif

            CloseRegKey $(KeyLineServiceLine)
         endif

         // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ISDN\#
	      DeleteRegTree $(KeyLineService) $(Line)

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_UtilityShell DecrementRefCount $(ProductKeyName)

	_Exit("Remove-ISDN", "")
	Return

//
//
//
[Config-ISDN]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-ISDN

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-ISDN", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	set Success = FALSE
	set NeedBindingReview = FALSE

   // Make sure HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\ISDN\# exists
   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _MakeStdRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

	      _MakeStdRegKey($(KeyLineService), $(Line),  KeyLineServiceLine)
	      _IfValidKey($(KeyLineServiceLine))

	         set VAdapterNum = EMPTY_STR
	         _GetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE
            _If($($R0))
	            set VAdapterNum = $($R1)
            endif

            _IfEmptyStr($(VAdapterNum))

               set RegPath = $(AdapterServiceName)"\\Parameters\\"$(LineServiceKeyName)"\\"$(Line)
		         _LocalShell AddVirtualAdapter "ISDN" $(Line) $(AdapterServiceName) "" $(Option) $(RegPath)
               _Assert($($R0))
		         set VAdapterNum = $($R1)

		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE $(VAdapterNum)
               _Assert($($R0))

		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_ADAPTER $(AdapterServiceName)
		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_DEVICE $(AdapterServiceName)
               _Assert($($R0))

               // Ok, I know what you're thinking!  The next line belowe isn't really kosher.
               // But, we all know this is how it works.
               set VAServiceName = $(ProductHardwareName)$(VAdapterNum)
		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_SERVICENAME $(VAServiceName)
               _Assert($($R0))

            endif

            // Set up TAPI
		      set EndPoints = 0
		      _GetRegDwordByKey $(KeyLineServiceLine) DXB_REGVAL_ENDPOINTS
            _If($($R0))
		         set EndPoints = $($R1)
            endif
            _LocalShell SetTapi "ISDN" $(VAdapterNum) $(EndPoints) SETTAPI_ADDRSCHEME_LINE

	         set NeedBindingReview = TRUE

            CloseRegKey $(KeyLineServiceLine)
         endif

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	set Success = TRUE

Exit = +

	_Exit("Config-ISDN", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_HOUSTON) || defined(SUPPORT_LONDON) || defined(SUPPORT_PRIME)

#if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)
//	********************************************************************************
//	PPP main entry points:
//	********************************************************************************

//
//
//
[SetUp-PPPService]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-PPPService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   // Nothing much to do here

	_Exit("SetUp-PPPService", "")
	Return

//
//
//
[CleanUp-PPPService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-PPP

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-PPPService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_LocalShell CleanUpAfterConfig "PPP" $(Line) $(KeyLine)

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

		   EnumRegKey $(KeyLineService) SubKeyList
         CloseRegKey $(KeyLineService)

         _Trace("Found", _Show(SubKeyList))
         _IfEmptyList($(SubKeyList))
            // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\PPPService
            _Trace("DeleteRegTree", _Show(LineServiceKeyName))
	         DeleteRegTree $(KeyAdapterParams) $(LineServiceKeyName)
         endif
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_Exit("CleanUp-PPPService", "")
	Return

//
//
//
[Add-PPPService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-PPP

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-PPPService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	_LocalShell AddService "PPP"
	set Installed = $($R0)
   _AssertGoto($(Installed), Exit)

	_UtilityShell IncrementRefCount $(ProductKeyName)

Exit = +

	_Exit("Add-PPPService", _Show(Installed))
	Return $(Installed)

//
//
//
[Remove-PPPService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-PPP

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-PPPService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _OpenRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

	      _OpenRegKey($(KeyLineService), $(Line),  KeyLineServiceLine)
	      _IfValidKey($(KeyLineServiceLine))

	         set VAdapterNum = EMPTY_STR
	         _GetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE
            _If($($R0))
	            set VAdapterNum = $($R1)
            endif

            _IfNotEmptyStr($(VAdapterNum))

	            _LocalShell RemoveVirtual "PPP" $(VAdapterNum) $(Manufacturer)
               _LocalShell SetTapi "PPP" $(VAdapterNum) 0 SETTAPI_ADDRSCHEME_LINE
            endif

            CloseRegKey $(KeyLineServiceLine)
         endif

         // Delete HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\PPPService\#
	      DeleteRegTree $(KeyLineService) $(Line)

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	_UtilityShell DecrementRefCount $(ProductKeyName)

	_Exit("Remove-PPPService", "")
	Return

//
//
//
[Config-PPPService]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms DriverConstants-PPP

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-PPPService", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	set Success = TRUE
	set NeedBindingReview = FALSE

   // Make sure HKLM\\SYSTEM\CurrentControlSet\Services\DigiDxb?\Parameters\PPPService\# exists
   _OpenServiceParamKey($(AdapterServiceName), KeyAdapterParams)
	_IfValidKey($(KeyAdapterParams))

	   _MakeStdRegKey($(KeyAdapterParams), $(LineServiceKeyName),  KeyLineService)
	   _IfValidKey($(KeyLineService))

	      _MakeStdRegKey($(KeyLineService), $(Line),  KeyLineServiceLine)
	      _IfValidKey($(KeyLineServiceLine))

	         set VAdapterNum = EMPTY_STR
	         _GetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE
            _If($($R0))
	            set VAdapterNum = $($R1)
            endif

            _IfEmptyStr($(VAdapterNum))

               set RegPath = $(AdapterServiceName)"\\Parameters\\"$(LineServiceKeyName)"\\"$(Line)
		         _LocalShell AddVirtualAdapter "PPP" $(Line) $(AdapterServiceName) "" $(Option) $(RegPath)
               _Assert($($R0))
		         set VAdapterNum = $($R1)

		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_NDIS_ADAPTER_INSTANCE $(VAdapterNum)
               _Assert($($R0))

				set	DeviceName = $(AdapterServiceName)  
				ifcontains(i) $(Option) in $(OptionsThatNeedStreams)

					read-syms DriverConstants-Streams
					set DeviceName = $(ProductSoftwareName)

				endif 

		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_ADAPTER $(AdapterServiceName)
 				 _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_DEVICE $(DeviceName)
              _Assert($($R0))

               // Ok, I know what you're thinking!  The next line belowe isn't really kosher.
               // But, we all know this is how it works.
               set VAServiceName = $(ProductHardwareName)$(VAdapterNum)
		         _SetRegSzByKey $(KeyLineServiceLine) DXB_REGVAL_SERVICENAME $(VAServiceName)
               _Assert($($R0))

               // Set up TAPI
		         set EndPoints = 1
               _LocalShell SetTapi "PPP" $(VAdapterNum) $(EndPoints) SETTAPI_ADDRSCHEME_LINE

	            set NeedBindingReview = TRUE
            endif

            CloseRegKey $(KeyLineServiceLine)
         endif

         CloseRegKey $(KeyLineService)
      endif

      CloseRegKey $(KeyAdapterParams)
   endif

	set Success = TRUE

Exit = +

	_Exit("Config-PPPService", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)

#endif // #if defined(SUPPORT_CLYDESDALE) || defined(SUPPORT_SYNC570)

//	********************************************************************************
//	None main entry points:
//	********************************************************************************

//
//	Used when no service is defined.
//
[SetUp-None]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
 	_Enter("SetUp-None", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_Exit("SetUp-None", "")
	Return

//
//
//
[CleanUp-None]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set ConfigResult = $($3)
	_Enter("CleanUp-None", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(ConfigResult))

	_Exit("CleanUp-None", "")
	Return

//
//
//
[Add-None]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set LineNum = $($3)
	set SrcDir = $($4)
	set Option = $($5)
	_Enter("Add-None", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(LineNum)_Show(SrcDir)_Show(Option))

	set Installed = TRUE

	_Exit("Add-None", _Show(Installed))
	Return $(Installed)

//
//
//
[Remove-None]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	_Enter("Remove-None", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName))

	_Exit("Remove-None", "")
	Return

//
//
//
[Config-None]

	set Line = $($0)
	set KeyLine = $($1)
	set AdapterServiceName = $($2)
	set Option = $($3)
	_Enter("Config-None", _Show(Line)_Show(KeyLine)_Show(AdapterServiceName)_Show(Option))

	set Success = TRUE
	set NeedBindingReview = FALSE

	_Exit("Config-None", _Show(Success)_Show(NeedBindingReview))
	Return $(Success) $(NeedBindingReview)
