[Identification]
    OptionType = NetAdapter

;-----------------------------------------------------------------------
; LANGUAGES SUPPORTED
; -------------------
;
; The languages supported by the OEM INF, For every language supported
; we need to have a separate text section for every displayable text
; section.
;
;-----------------------------------------------------------------------

[LanguagesSupported]
    ENG

;-----------------------------------------------------------------------
; OPTION LIST
; -----------
; This section lists the OEM Option key names.  These keys are locale
; independent and used to represent the option in a locale independent
; manner.
;
;-----------------------------------------------------------------------

[Options]
    RAYON

;-----------------------------------------------------------------------
; OPTION TEXT SECTION
; -------------------
; These are text strings used to identify the option to the user.  There
; are separate sections for each language supported.  The format of the
; section name is "OptionsText" concatenated with the Language represented
; by the section.
;
;-----------------------------------------------------------------------

[OptionsTextENG]
    "RAYON P584 MultiSerial ADAPTER"        =  "RAYON p584 4-ports serials adapter "
[FileConstants]

UtilityInf     = "UTILITY.INF"
subroutninf    = "SUBROUTN.INF"
ParamInf        = "NCPARAM.INF"
FunctionTitle   = "RAYON SETUP"

; Product Info
;
Manufacturer    = "RAYON TECH"
ProductMajorVersion     = "2"
ProductMinorVersion     = "22"
ProductVersion  = $(ProductMajorVersion)"."$(ProductMinorVersion)
;
; Software
;
SoftwareType    = "driver"
ProductSoftwareName     = "PCI584"
ProductSoftwareImagePath = "\SystemRoot\System32\drivers\pci584.sys"
ProductSoftwareTitle    = "RAYON P584  Driver"
ProductSoftwareDescription = "RAYON P584 Driver"
NetRuleSoftwareType     = "rayonSys serialDriver pci584Driver"
NetRuleSoftwareUse      = $(SoftwareType)
NetRuleSoftwareBindForm = """P584Driver"" yes no container"
NetRuleSoftwareClass    = {"serialDriver basic","gviopDriver basic"}
NetRuleSoftwareHiddenDriver   = 1
;
; Hardware
;
ProductHardwareName     = "PCI584"
ProductHardwareDescription = "RAYON P584 4-Port Adapter V2.2.2"
ProductHardwareTitle    = "RAYON P584 MultiSerial Adapter"
NetRuleHardwareType     = "RAYON P584 4Port Adapter"
NetRuleHardwareBindForm = " yes yes container"
NetRuleHardwareClass    = {"pci584Adapt basic"}
;
; Registry Key
;
ProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
ParamKeyName    = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"

ShellCodeErrorTitle     = "!Setup Error!"
ShellCodeErrorText      = "!Shutdown and Setup again!"

[GeneralConstants]
from      = ""
to        = ""

KeyNull         = ""
MAXIMUM_ALLOWED   = 33554432
RegistryErrorIndex = NO_ERROR
KeyProduct      = ""
KeyParameters   = ""

[date]
    ; Now is a list which contains { Sec from 1-1-1970, Year, Month, Day, Hour,
    ; Minute, Second }
    Now = {} ? $(!LIBHANDLE) GetSystemDate

;---------------------------------------------------------------------------
; 1. Identify
;
; DESCRIPTION:   To verify that this INF deals with the same type of options
;                as we are choosing currently.
;
; INPUT:         None
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL
;                $($R1): Option Type (COMPUTER ...)
;                $($R2): Diskette description
;---------------------------------------------------------------------------

[Identify]
    ;
    ;
    read-syms Identification

    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)

    Return $(Status) $(Identifier) $(Media)



;------------------------------------------------------------------------
; 2. ReturnOptions:
;
; DESCRIPTION:   To return the option list supported by this INF and the
;                localised text list representing the options.
;
;
; INPUT:         $($0):  Language used. ( ENG | FRN | ... )
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL |
;                                STATUS_NOLANGUAGE
;                                STATUS_FAILED
;
;                $($R1): Option List
;                $($R2): Option Text List
;------------------------------------------------------------------------

[ReturnOptions]
    ;
    ;
    set Status        = STATUS_FAILED
    set OptionList     = {}
    set OptionTextList = {}

    ;
    ; Check if the language requested is supported
    ;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
	goto returnoptions
    else
	set Status = STATUS_NOLANGUAGE
	goto finish_ReturnOptions
    endif

    ;
    ; form a list of all the options and another of the text representing
    ;

returnoptions = +
     set OptionList     = ^(Options, 1)
     set OptionTextList = ^(OptionsText$($0), 1)
     set Status         = STATUS_SUCCESSFUL

finish_ReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)

;
; InstallOption:
;
; FUNCTION:  To copy files representing Options
;            To configure the installed option
;            To update the registry for the installed option
;
; INPUT:     $($0):  Language to use
;            $($1):  OptionID to install
;            $($2):  SourceDirectory
;            $($3):  AddCopy  (YES | NO)
;            $($4):  DoCopy   (YES | NO)
;            $($5):  DoConfig (YES | NO)
;
; OUTPUT:    $($R0): STATUS: STATUS_SUCCESSFUL |
;                            STATUS_NOLANGUAGE |
;                            STATUS_USERCANCEL |
;                            STATUS_FAILED
;

[InstallOption]

    ;
    ; Set default values for
    ;
    set Status       = STATUS_FAILED
    set DrivesToFree = {}

    ;
    ; extract parameters
    ;
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)

    ;
    ; Check if the language requested is supported
    ;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
    else
	set Status = STATUS_NOLANGUAGE
	goto finish_InstallOption
    endif

    read-syms GeneralConstants
    read-syms FileConstants
    detect date

    set-title  $(FunctionTitle)
;
;  Assume all is well.
;
    set CommonStatus = STATUS_SUCCESSFUL

Begin = +

    Ifstr(i) $(!NTN_InstallMode) == deinstall
	set StartLabel = removeadapter
    else-Ifstr(i) $(!NTN_InstallMode) == Update
	set StartLabel = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == bind
	set StartLabel = bindingadapter
    else-Ifstr(i) $(!NTN_InstallMode) == configure
	set StartLabel = configureadapter
    else
	set StartLabel = installadapter
	set OEM_ABANDON_OPTIONS = {}
	set OEM_ABANDON_SOFTWARE = FALSE
	set OEM_ABANDON_ON = TRUE
    endif

    set ComStartChoice = "5"
    Goto $(StartLabel)

;-----------------------------------------------
; Installation Section
;-----------------------------------------------

installadapter = +

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

    Ifstr $(KeyProduct) != $(KeyNull)
	CloseRegKey $(KeyProduct)
	ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
	   Shell $(UtilityInf), VerExistedDlg, $(ProductSoftwareTitle),+
	       $(ProductVersion)
	   ifint $($ShellCode) != $(!SHELL_CODE_OK)
	       Debug-Output "ShellCode error: Don't allow installation of software."
	       goto ShellCodeError
	   endif
	   goto end
	else
	   Shell $(UtilityInf), CardExistedDlg
	   ifint $($ShellCode) != $(!SHELL_CODE_OK)
	       Debug-Output "ShellCode error: cannot get an error string."
	       goto ShellCodeError
	   endif
	   set CommonStatus = STATUS_USERCANCEL
	   goto end
  ;         ifstr(i) $($R1) != "OK"
  ;             set CommonStatus = STATUS_USERCANCEL
  ;             goto end
  ;         endif
  ;         set OldVersionExisted = $(TRUE)
	endif
    endif
    goto skipoptions
;    goto adapteroptions

adapteroptions = +

    read-syms ComStartDlg
    ui start "ComStart"
    ifstr(i) $(DLGEVENT) == "CONTINUE"
	set ComStartChoice = $(EditTextOut)
	ui pop 1
    else-ifstr(i) $(DLGEVENT) == "BACK"
	set CommonStatus = STATUS_USERCANCEL
	ui pop 1
	goto end
    endif

skipoptions = +
    StartWait
    Ifint $(OldVersionExisted) != $(FALSE)
	Goto installhardware
    Endif
    ;
    ; Add Software Component
    ;
    ifint $(OldVersionExisted) == $(FALSE)
	ifstr(i) $(!NTN_InstallMode) == "install"
	   Ifstr(i) $(DoCopy) == "YES"

	      Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES

	      Ifint $($ShellCode) != $(!SHELL_CODE_OK)
		  goto ShellCodeError
	      Else-Ifstr(i) $($R0) == STATUS_FAILED
		  Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
		  ifint $($ShellCode) != $(!SHELL_CODE_OK)
		      goto ShellCodeError
		  endif
		  set Error = $($R0)
		  Goto fatel
	      Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
		  Goto successful
	      Endif

	      Set SrcDir = $($R1)

	   Endif

	   install "Install-Option"
	   ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
	      Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
	      ifint $($ShellCode) != $(!SHELL_CODE_OK)
		  goto ShellCodeError
	      endif
	      set Error = $($R0)
	      goto fatal
	   endif
	endif

    Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
	$(ProductSoftwareName), +
	$(ProductSoftwareName), +
	$(ProductSoftwareName), $(STF_CONTEXTINFNAME), +
	$(ProductSoftwareImagePath), "kernelauto", "Extended base", {}, "",+
	$(NetEventDLL)
    Set OEM_ABANDON_SOFTWARE = TRUE

    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
    endif

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    EndWait
	    Debug-Output "Registry error: add software components"
	    CloseRegKey $($R1)
	    CloseRegKey $($R2)
	    CloseRegKey $($R3)
	    CloseRegKey $($R4)
	CloseRegKey $($R5)
	goto fatalregistry
    endif


    set SoftProductKey   = $($R1)
    Set SoftNetRuleKey   = $($R2)
    Set SoftServiceKey   = $($R3)
    Set SoftParameterKey = $($R4)
    Set SoftLinkageKey   = $($R5)

    set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
		       {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
		       {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
		       {Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitle)},+
		       {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescription)},+
		       {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
		       {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
    Shell  $(UtilityInf), AddValueList, $(SoftProductKey), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error."
	    goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    EndWait
	    Debug-Output "Resgitry error: add value list."
	    CloseRegKey $(SoftProductKey)
	    CloseRegKey $(SoftNetRuleKey)
	   CloseRegKey $(SoftServiceKey)
	    CloseRegKey $(SoftParameterKey)
	CloseRegKey $(SoftLinkageKey)
	goto fatalregistry
    endif
    set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareType)},+
			{use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareUse)}, +
			{class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClass)}, +
			{bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareBindable)}, +
			{bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindForm)}, +
			{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
    Shell  $(UtilityInf), AddValueList, $(SoftNetRuleKey), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error."
	    goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    EndWait
	    CloseRegKey $(SoftProductKey)
	    CloseRegKey $(SoftNetRuleKey)
	    CloseRegKey $(SoftServiceKey)
	    CloseRegKey $(SoftParameterKey)
	    CloseRegKey $(SoftLinkageKey)
	goto fatalregistry
    endif
    set NewValueList = { {StartNum0,$(NoTitle),$(!REG_VT_DWORD),$(ComStartChoice)},+
			 {StartNum1,$(NoTitle),$(!REG_VT_DWORD),0},+
			 {StartNum2,$(NoTitle),$(!REG_VT_DWORD),0},+
			 {StartNum3,$(NoTitle),$(!REG_VT_DWORD),0},+
			 {ID,$(NoTitle),$(!REG_VT_SZ),"RAYON"}}
    Shell  $(UtilityInf), AddValueList, $(SoftParameterKey), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error."
	    goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    CloseRegKey $(SoftProductKey)
    CloseRegKey $(SoftNetRuleKey)
    CloseRegKey $(SoftServiceKey)
    CloseRegKey $(SoftParameterKey)
    CloseRegKey $(SoftLinkageKey)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	EndWait
	goto fatalregistry
    endif
;
;   Create the HARDWARE\Netcard region and its corresponding service
;

installhardware =+
    Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName),$(STF_CONTEXTINFNAME),$(ProductKeyName)

    ifint $($R4) != -1
	Set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$($R4))
    endif

    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "Cannot add hardware component"
	goto ShellCodeError
    endif

    set RegistryErrorIndex = $($R0)

    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	EndWait
	Debug-Output "Registry error: add hardware component"
	CloseRegKey $($R1)
	CloseRegKey $($R2)
	CloseRegKey $($R3)
	goto fatalregistry
    endif
;
;   At this point:
;     $R1  Registry key variable for HARDWARE\Netcard\(n)
;     $R2  Registry key variable for HARDWARE\Netcard\(n)\\NetRules
;     $R3  Registry key handle for <service>\Parameters key
;     $R4  Adapter number assigned to adapter
;     $R5  Service name generated by combining svc name with adapter number
;
    set KeyParameters = $($R3)
    set KeyAdapterRules = $($R2)
    set AdapterNumber = $($R4)

    set NewValueList = {{Manufacturer,$(NoTitle),$(!REG_VT_SZ),$(Manufacturer)},+
		       {Title,$(NoTitle),$(!REG_VT_SZ),"["$($R4)"] "$(ProductHardwareTitle)},+
		       {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareDescription)},+
		       {ProductName,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareName)},+
		       {ServiceName,$(NoTitle),$(!REG_VT_SZ),$($R5)},+
		       {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

    Shell  $(UtilityInf), AddValueList, $($R1), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "ShellCode error"
	goto ShellCodeError
    endif

    CloseRegKey $($R1)

    set TempProdName = """"$(ProductHardwareName)$(AdapterNumber)""""
    set TempBindForm = $(TempProdName)$(NetRuleHardwareBindForm)
    set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleHardwareType)},+
			{bindform,$(NoTitle),$(!REG_VT_SZ),$(TempBindForm)}, +
			{class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleHardwareClass)}, +
			{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
    Shell  $(UtilityInf), AddValueList, $(KeyAdapterRules), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "ShellCode error."
	goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	EndWait
	Debug-Output "Registry error: add value list."
	CloseRegKey $(KeyParameters)
	CloseRegKey $(KeyAdapterRules)
	goto fatalregistry
    endif
    CloseRegKey $(KeyAdapterRules)
    CloseRegKey $(KeyParameters)

    RunProgram Status "" "" pci584.exe

    EndWait

    goto successful

;-----------------------------------------------
; Binding section
;-----------------------------------------------
bindingadapter =+
    set Error = "Binding: Sorry, not yet implemented."
    goto fatal

;-----------------------------------------------
; Configure section
;-----------------------------------------------

configureadapter =+

      set Status = STATUS_SUCCESSFUL
      RunProgram Status "" "" pci584.exe
      goto end

     set OldVersionExisted = $(TRUE)
     read-syms ComSetupDlg
     ui start "ComSetupDlg"

    ifstr(i) $(DLGEVENT) == "CONTINUE"
	set ComStartChoice = $(EditTextOut)
	ui pop 1
	goto skipoptions 
    else-ifstr(i) $(DLGEVENT) == "BACK"
	set CommonStatus = STATUS_USERCANCEL
	ui pop 1
	goto end


   goto skipoptions

;-----------------------------------------------
; Upgrade Software section
;-----------------------------------------------

UpgradeSoftware = +
    ; Upgrade software component
    ;

   install "Install-Option"

    read-syms ComStartDlg
    ui start "ComStart"

    goto successful

;-----------------------------------------------
; Removeadapter section
;-----------------------------------------------

removeadapter = +
    install UpdateEachInf
    Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	; Remove Software Component
	Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    else
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $(!NTN_RegBase)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    endif

    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase) $(MAXIMUM_ALLOWED) SKN
    DeleteRegTree $(SKN) $(ProductHardwareName)
    CloseRegKey $(SKN)


    install RemoveFiles

    goto end

;
;  Escape hatches
;
successful = +
    goto end

abandon = +
    ForListDo $(OEM_ABANDON_OPTIONS)
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $($)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    EndForListDo

    Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
	; Remove Software Component
	Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), FALSE
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    endif

    goto end
;
; warning display
;
warning = +
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
	goto $(to)
    else-ifstr(i) $($R1) == "CANCEL"
	goto $(from)
    else
	goto "end"
    endif

;
; non fatal error display
;
nonfatalinfo = +
    Set Severity = STATUS
    Set CommonStatus = STATUS_USERCANCEL
    goto nonfatalmsg
nonfatal = +
    Set Severity = NONFATAL
    goto nonfatalmsg
nonfatalmsg = +
    ifstr(i) $(Error) == ""
	Set Severity = NONFATAL
	Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    goto ShellCodeError
	endif
	set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
	goto $(from)
    else
	goto "end"
    endif
;
;  Registry is broken
;
fatalregistry = +
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    set Error = $($R0)
    goto fatal

;
;  Netcard detection failure
;
fataldetect = +
    Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "ShellCode error: cannot get an error string."
	goto ShellCodeError
    endif
    set Error = $($R0)
    Goto fatal

;
; fatal error display
;
fatal = +
    ifstr(i) $(Error) == ""
	Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    goto ShellCodeError
	endif
	set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif

    goto setfailed

;
;  Test Point error

testCodeError = +
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = $(ShellCodeErrorTitle)
    set STF_MB_TEXT  = "Test error Point"
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed1

setfailed1 = +
    set CommonStatus = STATUS_FAILED
    ;
    ; if OEM_ABANDON_ON == TRUE, then remove the registry entries
    ;
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
	set OEM_ABANDON_ON = FALSE
	goto abandon
    endif
    goto end1

end1 = +
    goto term1

term1 = +

    Return $(CommonStatus)


;

;
;  Shelling error
;
ShellCodeError = +
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = $(ShellCodeErrorTitle)
    set STF_MB_TEXT  = $(ShellCodeErrorText)
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed
    install RemoveFiles

setfailed = +
    set CommonStatus = STATUS_FAILED
    ;
    ; if OEM_ABANDON_ON == TRUE, then remove the registry entries
    ;
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
	set OEM_ABANDON_ON = FALSE
	goto abandon
    endif
    goto end

end = +
    goto term

term = +

    Return $(CommonStatus)

[Install-Option]
    set STF_VITAL = ""
    ifstr(i) $(AddCopy) == "YES"
	AddSectionFilesToCopyList Files-Resource $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
	AddSectionFilesToCopyList Files-images $(SrcDir) $(!STF_WINDOWSSYSPATH)drivers
	AddSectionFilesToCopyList Dll-Resource $(SrcDir) $(!STF_WINDOWSSYSPATH)
    endif
    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    Exit

[Source Media Descriptions]
    1  = "RAYON DEVICE DIRVER P584 ADAPTER"  , TAGFILE = disk1

[Files-Resource]
1,pci584.sys, SIZE=11800
1,oemsetup.inf, SIZE=96746, RENAME=OEMNADGV.INF

[Dll-Resource]
1,pci584.ray, SIZE=158000,RENAME=PCI584.EXE

[Files-images]
1,pci584.sys, SIZE=11000

[RemoveFiles]
   set RenameList = {}
   set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\pci584.sys")

   ForListDo $(RenameList)
       LibraryProcedure Status , $(!LIBHANDLE), DelFile $($)
   EndForListDo
   exit

[UpdateEachInf]
   set SoftwareName = "Software\GlobalView"
   OpenRegKey $(!REG_H_LOCAL) "" $(SoftwareName) $(MAXIMUM_ALLOWED) KeySoftware
   ifstr(i) $(KeySoftware) != ""
	    EnumRegKey $(KeySoftware) SoftwareList
	    ForListDo $(SoftwareList)
		set ComponentName = $(SoftwareName)"\"*($($),1)
		OpenRegKey $(!REG_H_LOCAL) "" $(ComponentName) $(MAXIMUM_ALLOWED) KeyComponent
		ifstr(i) $(KeyComponent) != ""
		    set NetRulesName = $(ComponentName)"\CurrentVersion\NetRules"
		    OpenRegKey $(!REG_H_LOCAL) "" $(NetRulesName) $(MAXIMUM_ALLOWED) KeyNetRules
		    ifstr(i) $(KeyNetRules) != ""
			GetRegValue $(KeyNetRules),"InfName", InfNameInfo
			GetRegValue $(KeyNetRules),"InfOption", InfOptionInfo
			set ComponentInfName = *($(InfNameInfo),4)
			set ComponentInfOption = *($(InfOptionInfo),4)

			ifstr(i) $(ComponentInfOption) == "GVIOP"
			    LibraryProcedure Status1, $(!LIBHANDLE), DelFile, $(!STF_WINDOWSSYSPATH)"\"$(ComponentInfName)
			endif

			CloseRegKey $(KeyNetRules)
		    endif
		    CloseRegKey $(KeyComponent)
		endif
	    EndForListDo
	    CloseRegKey $(KeySoftware)
	endif
    exit



[ComStartDlg]

	DlgType	=	"MessageBox"
	STF_MB_TITLE =	"RAYON UPGRADE"
	STF_MB_TEXT	="Upgrade Software Processed."
	STF_MB_TYPE	=1
	STF_MB_ICON	=1
	STF_MB_DEF	=2
 