;-----------------------------------------------------------------------
; OPTION TYPE
; -----------
; This identifies the Option type we are dealing with.  The different
; possible types are:
;
; COMPUTER, DISPLAY, MOUSE, KEYBOARD, LAYOUT, SCSI, PRINTER, ...
;
;  Types specific to networking:
;
; NetAdapter,        a netcard / adapter combination or just a netcard
; NetDriver,         just a netcard driver
; NetTransport,      a complete NDIS-compliant TDI transport stack
; NetService,        an NT networking service
; NetWork,           a complete network ensemble.
; NetProvider        a complete network which supports NT MPR protocol
;-----------------------------------------------------------------------

[Identification]
    OptionType = NetAdapter

;-----------------------------------------------------------------------
; PlatformsSupported
; ------------------
; This identifies the platforms supported by the adapter card.
; Possible types are:
;
; ISA, EISA and MCA
;-----------------------------------------------------------------------

[PlatformsSupported]
    ISA
    EISA
    "Jazz-Internal Bus"
    MCA

;-----------------------------------------------------------------------
; 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]
    ChiliPORTS4i
    ChiliPORTS8i
    ChiliPORTS16i

[OptionsMCA]
    ChiliPORTS4m
    ChiliPORTS8m
    ChiliPORTS16m


[AdapterInfo]
;                     Title      Hardware    Hardware  Hardware  EISA
;                                Name        Driver    Type      ID
;                     --------   --------    --------  --------  ------
    ChiliPORTS4i    = "/4i",       cp4i,      Chili,     1,      {0}
    ChiliPORTS8i    = "/8i",       cp8i,      Chili,     1,      {0}
    ChiliPORTS16i   = "/16i",     cp16i,      Chili,     1,      {0}
    ChiliPORTS8e    = "/8e",       cp8e,      Chili,     2,      {71330060}

[AdapterInfoMCA]
;                     Title    Hardware    Hardware  Hardware  MCA POS         MCA POS     MCA POS
;                              Name        Driver    Type        ID            Byte 1      Byte 2
;                     -------- --------    --------  --------  -------         -------     -------
    ChiliPORTS4m    = "MC/4m",   cp4m,     ChiliMC,     3,     {26304},         {127},      {127}
    ChiliPORTS8m    = "MC/8m",   cp8m,     ChiliMC,     3,     {26304},         {127},      {127}
    ChiliPORTS16m   = "MC/16m", cp16m,     ChiliMC,     3,     {26304},         {127},      {127}

[FileConstants]
;
; Misc. variables
;
    ExitState   = "Active"
    OldVersionExisted = $(FALSE)
    HdwDriverComponentExists = $(FALSE)

    DriverPath      = $(!STF_NTPATH)"\drivers"

;
;  File names, etc.
;
    UtilityInf     = "UTILITY.INF"
    subroutninf    = "SUBROUTN.INF"
    ParamInf        = "NCPARAM.INF"
    HandleNull   = ""
    CHILI_CONFIG_HANDLE = $(HandleNull)

;
; Adapter information
;
AdapterList = ^(AdapterInfo$(BusType),0)
AdapterTitleList = ^(AdapterInfo$(BusType), 1)
AdapterHardwareNameList = ^(AdapterInfo$(BusType), 2)
AdapterHardwareDriverList = ^(AdapterInfo$(BusType), 3)
AdapterHardwareTypeList = ^(AdapterInfo$(BusType), 4)
AdapterHardwareAdapterIDList = ^(AdapterInfo$(BusType), 5)
AdapterIDByte1List = ^(AdapterInfo$(BusType), 6)
AdapterIDByte2List = ^(AdapterInfo$(BusType), 7)
AdapterTitle = *($(AdapterTitleList), ~($(AdapterList), $(Option)))
AdapterHardwareName = *($(AdapterHardwareNameList), ~($(AdapterList), $(Option)))
AdapterHardwareDriver = *($(AdapterHardwareDriverList), ~($(AdapterList), $(Option)))
AdapterHardwareType = *($(AdapterHardwareTypeList), ~($(AdapterList), $(Option)))
AdapterHardwareAdapterID = *($(AdapterHardwareAdapterIDList), ~($(AdapterList), $(Option)))
AdapterIDByte1 = *($(AdapterIDByte1List), ~($(AdapterList), $(Option)))
AdapterIDByte2 = *($(AdapterIDByte2List), ~($(AdapterList), $(Option)))
AdapterRule = *($(AdapterHardwareDriverList), ~($(AdapterList), $(Option)))
AdapterServiceName = ""
AdapterName = ""

;
; EventLog Message File
;
    NetEventDLL     = "%SystemRoot%\System32\netevent.dll"
    IoLogMsgDLL     = "%SystemRoot%\System32\IoLogMsg.dll"
;
; Product Info
;
    Manufacturer    = "Consensys"
    ProductMajorVersion     = "1"
    ProductMinorVersion     = "0"
    ProductVersion  = $(ProductMajorVersion)"."$(ProductMinorVersion)
;
; Software
;
    SoftwareType    = "driver"
    ProductSoftwareName     = "ChiliPORTS Service"
    ProductSoftwareImagePath = "%SystemRoot%\System32\ChiliSrv.exe"
;    NetRuleSoftwareType     = "ChiliSrvExe ChiliService ChiliDriver"
;    NetRuleSoftwareUse      = $(SoftwareType)
;    NetRuleSoftwareBindForm = """ChiliObsDriver"" yes no container"
;    NetRuleSoftwareClass    = {"ChiliService basic","ChiliObsDriver basic"}
;    NetRuleSoftwareHiddenDriver   = 1

;
;   Hardware Dependent Software
;
    ProductMajorVersionHdwDriver     = "1"
    ProductMinorVersionHdwDriver     = "0"
    ProductVersionHdwDriver  = $(ProductMajorVersionHdwDriver)"."$(ProductMinorVersionHdwDriver)

    SoftwareTypeHdwDriver	 = "driver"
    ProductSoftwareNameHdwDriver = $(AdapterHardwareDriver)
    ProductSoftwareImagePathHdwDriver = "%SystemRoot%\System32\drivers\"$(AdapterHardwareDriver)".sys"

    NetRuleSoftwareTypeHdwDriver     = $(AdapterHardwareDriver)"sys "$(AdapterHardwareDriver)"Driver"
    NetRuleSoftwareUseHdwDriver      = $(SoftwareTypeHdwDriver)
    NetRuleSoftwareBindFormHdwDriver = """"$(AdapterHardwareDriver)"Driver"" yes no container"
    NetRuleSoftwareClassHdwDriver    = {$(AdapterHardwareDriver)"Driver basic"}
    NetRuleSoftwareHiddenHdwDriver   = 1

;
; Hardware
;
    NetRuleHardwareType     = $(AdapterRule)" "$(AdapterRule)"Adapter"
    NetRuleHardwareBindForm = " yes yes container"
    NetRuleHardwareClass    = {$(AdapterHardwareDriver)"Adapter basic"}
    ProductHardwareName     = $(AdapterHardwareDriver)

    AdapterParameters = {}

; Registry Key
;
    ProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
    ProductKeyNameHdwDriver  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareNameHdwDriver)"\CurrentVersion"
    ParamKeyName    = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"


[GeneralConstants]
;
;  Return codes; Exit_Code is set to one of these
;
    ExitCodeOk     = 0
    ExitCodeCancel = 1
    ExitCodeFatal  = 2

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

    TRUE         = 1
    FALSE        = 0
    NoTitle      = 0

    fRemoveChili = TRUE

[DebugOptions]
;
;   Debugging variables
;
    !DebugOutputControl = 1

[UiVars]
;
;  Program flow control variables.
;
from      = ""
to        = ""
    !STF_NTDRIVE        = ""
    !STF_NTPATH         = ""
    !STF_WINDOWSPATH    = "" ? $(!LIBHANDLE) GetWindowsNtDir
    !STF_WINDOWSSYSPATH = "" ? $(!LIBHANDLE) GetWindowsNtSysDir
    !STF_FLOPPYLIST     = {} ? $(!LIBHANDLE) GetFloppyDriveLetters
    !STF_UNUSEDDRIVES   = {} ? $(!LIBHANDLE) GetUnusedDrives
    !STF_LANGUAGE       = "ENG"
    !STF_DISPLAYDEBUGOUTPUT = 1
    VolumeList      = {} ? $(!LIBHANDLE) GetHardDriveLetters
    VolumeFreeList  = {} ? $(!LIBHANDLE) GetHardDriveFreeSpace
    VolumeFSList    = {} ? $(!LIBHANDLE) GetHardDriveFileSystems
    DestVolume      = ""
    MinHelpID   = 25000
    MaxHelpID   = 25999


[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)
    Debug-Output "Identify: Identifier = "$(Identifier)" Media = "$(Media)
    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 | ... )
;                $($1):  Bus Type
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL |
;                                STATUS_NOLANGUAGE
;                                STATUS_FAILED
;                                STATUS_NOTSUPPORTED
;
;                $($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)
        ;
        ; Check if the platforms requested is supported
        ;
        ifstr(i) $($1) == ""
            goto returnoptions
        endif

        set PlatformList = ^(PlatformsSupported, 1)
        Ifcontains(i) $($1) in $(PlatformList)
            goto returnoptions
        else
            set Status = STATUS_NOTSUPPORTED
            goto finish_ReturnOptions
        endif
    Else
        set Status = STATUS_NOLANGUAGE
        goto finish_ReturnOptions
    Endif

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

returnoptions = +
    ifstr(i) $($1) == "MCA"
      set OptionList     = ^(OptionsMCA, 1)
      set OptionTextList = ^(OptionsTextMCA$($0), 1)
      set Status         = STATUS_SUCCESSFUL
    else
      set OptionList     = ^(Options, 1)
      set OptionTextList = ^(OptionsText$($0), 1)
      set Status         = STATUS_SUCCESSFUL
    endif
finish_ReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)

[Shell Commands]
    set-title "Serial Setup"
    set-subst LF = "\n"
    set Exit_Code = $(ExitCodeOk)
    Debug-Output "OEMSETUP.INF: STF_CWDDIR is "$(!STF_CWDDIR)
    Debug-Output "OEMSETUP.INF: STF_RANFROM is "$(!STF_RANFROM)
    ifstr(i) $(!STF_RANFROM) != ""
        ifstr(i) $(!STF_RANFROM) != $(!STF_CWDDIR)"SERIAL\"
           set !STF_SRCDIR = $(!STF_RANFROM)
        endif
    endif
    LoadLibrary "x" $(!STF_CWDDIR)setupdll.dll !LIBHANDLE
    shell "" InstallOption ENG Consensys $(!STF_SRCDIR)
    FreeLibrary $(!LIBHANDLE)
    set Status = $($R0)
    Return $(Status)

;------------------------------------------------------------------------
;
; InstallOption:
;
;      This section is shelled to by main installation processing
;      or by NCPASHEL.INF during reconfig, removal, update, etc.
;
;
; 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]
    read-syms DebugOptions
    Debug-Output "OEMSETUP.INF: In [InstallOption] section"
    ;
    ; Set default values for
    ;
    set Status = STATUS_FAILED
    ;
    ; extract parameters
    ;
    set Option    = $($1)
    set SrcDir    = $($2)
    set AddCopy   = $($3)
    set DoCopy    = $($4)
    set DoConfig  = $($5)

    set !SourceDir = $($2)

    set BusType = ""
    ifstr(i) $(!STF_BUSTYPE) == "MCA"
      set BusType = "MCA"
    endif

    ; Determine Machine Platform
    shell "" SetPlatform
    set !STF_PLATFORM = $($R1)
    Debug-Output "OEMSETUP.INF: STF_PLATFORM = "$(!STF_PLATFORM)" $R1 = "$($R1)

    read-syms GeneralConstants
    read-syms FileConstants

    Debug-Output "OEMSETUP.INF: Language = "$($0)
    Debug-Output "OEMSETUP.INF: OptionID = "$($1)
    Debug-Output "OEMSETUP.INF: SourceDirectory = "$($2)
    Debug-Output "OEMSETUP.INF: AddCopy = "$(AddCopy)
    Debug-Output "OEMSETUP.INF: DoCopy = "$(DoCopy)
    Debug-Output "OEMSETUP.INF: DoConfig = "$(DoConfig)
;    shell "" DebugExternalGlobals

    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
        Debug-Output "OEMSETUP.INF: returning STATUS_NO_LANGUAGE"
        return STATUS_NOLANGUAGE
    Endif
    set-subst LF = "\n"

;--------------------------------------------------------------------------
;    LoadLibrary "x" chiliCui.dll CHILI_CONFIG_HANDLE
;
;               set TmpAdapterName = ntxall
;               set TmpBusNumber = 0
;               set NewIOBaseAddress = 4005
;
;               LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), +
;                  DoesControllerExist, $(TmpAdapterName), +
;                                       $(TmpBusNumber),        +
;                                       $(NewIOBaseAddress)
;               Debug-Output "DoesControllerExist return: "$(Result)
;
;;               set CommonStatus = STATUS_USERCANCEL
;;               goto end
;
;--------------------------------------------------------------------------

    Debug-Output "OEMSETUP.INF: AdapterTitle = "$(AdapterTitle)
    Debug-Output "OEMSETUP.INF: AdapterHardwareName = "$(AdapterHardwareName)
    Debug-Output "OEMSETUP.INF: AdapterHardwareDriver = "$(AdapterHardwareDriver)

;    read-syms BindingInfo-ChiliSrv
;    set NetRuleSoftwareBindable = $(BindingInfo)
    read-syms BindingInfo-$(AdapterHardwareDriver)
    set NetRuleSoftwareBindableHdwDriver = $(BindingInfo)

    read-syms DialogConstants$(!STF_LANGUAGE)
    ifstr(i) $(!NTN_Origination) == "NCPA"
        set Continue = "OK"
    endif
    read-syms FileConstants$(!STF_LANGUAGE)

    detect date
    set-title  $(FunctionTitle)

    set to   = Begin
    set from = Begin

;
;  Assume all is well.
;
    set CommonStatus = STATUS_SUCCESSFUL

    EndWait

;
;   Set up the operation-mode-based variables and gaily welcome
;   the user.  If the "install mode" variable is improperly set,
;   assume this is a new installation.
;

;    Debug-Output "OEMSETUP.INF: [InstallOption]:Begin"
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 = getAdapterSettings
        ;
        ;   You cannot config the software component
        ;
        Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
            Debug-Output "Cannot configure the ChiliPORTS Service software."
            Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "ShellCode error: cannot get an error string."
                goto ShellCodeError
            endif
            set Error = $($R0)
            set from = end
            set to = end
            goto nonfatalinfo
        endif

        Ifstr(i) $(ProductKeyNameHdwDriver) == $(!NTN_RegBase)
            Debug-Output "This should not have happened!  Cannot configure the "$(AdapterHardwareName)" driver software."
            Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "ShellCode error: cannot get an error string."
                goto ShellCodeError
            endif
            set Error = $($R0)
            set from = end
            set to = end
            goto nonfatalinfo
        endif
        ;
        ; If we get to this point, then we can be sure that we are being
        ; asked to configure the adapter.
        ;
        Debug-Output "We need to determine how to find out which adapter"
        Debug-Output "  we should be configuring!!!!!!"
        set from = writeparameters
        Debug-Output "setting from = "$(from)
    else
        ;
        ; Assume we are installing
        ;
        set StartLabel = installadapter
        set OEM_ABANDON_OPTIONS = {}
        set OEM_ABANDON_SOFTWARE = FALSE
        set OEM_ABANDON_ON = TRUE
    endif

    Debug-Output "OEMSETUP.INF: =================================================="
    Debug-Output "OEMSETUP.INF: STF_CWDIR is: "$(!STF_CWDIR)
    Debug-Output "OEMSETUP.INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)
    Debug-Output "OEMSETUP.INF: StartLabel is: "$(StartLabel)
    Debug-Output "OEMSETUP.INF: Option is: "$(Option)
;    Debug-Output "OEMSETUP.INF: !STF_NCDETECT  is: "$(!STF_NCDETECT)
;    Debug-Output "OEMSETUP.INF: !STF_NCOPTION  is: "$(!STF_NCOPTION)
;    Debug-Output "OEMSETUP.INF: !STF_NCDETCARD is: "$(!STF_NCDETCARD)
;    Debug-Output "OEMSETUP.INF: !STF_NCDETINFO is: "$(!STF_NCDETINFO)
    Debug-Output "OEMSETUP.INF: =================================================="

    set to = $(fatal)
    Goto $(StartLabel)

;-----------------------------------------------
; Installation Section
;-----------------------------------------------
installadapter = +
    Debug-Output "******************Entering installadapter******************"
;
;   First, check whether the same version of the software exists
;
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

    Ifstr $(KeyProduct) != $(KeyNull)
        ;
        ; Same version of ChiliPORTS Service already exists on the local machine
        ; Popup the dialog and ask the user whether he wants to continue
        ;
        Debug-Output "***"$(ProductKeyName)" already exists! ***"
        CloseRegKey $(KeyProduct)

        ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
           ;
           ; Don't allow multiple installs of the same software again
           ;
           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
            OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyNameHdwDriver) +
                       $(MAXIMUM_ALLOWED) KeyProductHdwDriver

            Ifstr $(KeyProductHdwDriver) != $(KeyNull)
                ;
                ; Add a new adapter card?
                ;
                CloseRegKey $(KeyProductHdwDriver)
                Shell $(UtilityInf), CardExistedDlg

                ifint $($ShellCode) != $(!SHELL_CODE_OK)
                    Debug-Output "ShellCode error: --One adapter all ready exists, install another-- FAILED."
                    goto ShellCodeError
                endif

                ifstr(i) $($R1) != "OK"
                    goto end
                endif
                set HdwDriverComponentExists = $(TRUE)
            EndIf   ; end Ifstr $(KeyProductHdwDriver) != $(KeyNull)
            set OldVersionExisted = $(TRUE)
        endif
    endif

    goto skipoptions

skipoptions = +
    Debug-Output "******************Entering skipoptions******************"
    ifint $(HdwDriverComponentExists) == $(TRUE)
        ifstr(i) $(!NTN_InstallMode) == configure
            ;
            ; The user just wants to configure an existing adapter
            ;
            goto getAdapterSettings
        endif
    endif
    StartWait
    Debug-Output "HdwDriverComponentExists = "$(HdwDriverComponentExists)
    ifint $(HdwDriverComponentExists) == $(FALSE)
        ;
        ; A version of the software does not exist yet in the registry.
        ;
        ifstr(i) $(!NTN_InstallMode) == "install"
           shell $(UtilityInf) AssignAdapterNumber
           set AdapterName = $(ProductHardwareName)$($R1)

           set DoCopy = NO
           ;
           ; Check for presence of existing driver components
           ;   
           LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\drivers\"chili.sys
           ifstr(i) $(STATUS) == NO
               set DoCopy = YES
               goto addfiles
           endif
           LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\drivers\"chiliObs.sys
           ifstr(i) $(STATUS) == NO
               set DoCopy = YES
               goto addfiles
           endif
           LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\"chiliSrv.exe
           ifstr(i) $(STATUS) == NO
               set DoCopy = YES
               goto addfiles
           endif
           LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\"chiliCui.dll
           ifstr(i) $(STATUS) == NO
              set DoCopy = YES
              goto addfiles
           endif

addfiles = +
           Ifstr(i) $(DoCopy) == "YES"
               Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES
               Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                   Debug-Output"Shell code error: DoAskSource"
                   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 fatal
               Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
                   set CommonStatus = STATUS_USERCANCEL
                   Goto successful
               Endif
               Set SrcDir = $($R1)
               ;
               ; Make sure that a trailing \ is present.
               ;
               Split-String $(SrcDir) "\" JunkList
               QueryListSize JunkSize $(JunkList)
               Set JunkItem = *($(JunkList),$(JunkSize))
               set JunkItem2 = "foo"
               ifstr $(JunkItem2)$(JunkItem)$(JunkItem2) != $(JunkItem2)"\"$(JunkItem2)
                   Debug-Output "In ifstr"
                   set SrcDir = $(SrcDir)"\"
               endif
               Debug-Output "Reassigning SourceDirectory = "$(SrcDir)
           Endif
           Debug-Output "call install with Install-Option..."
           install "Install-Option"
           Debug-Output "STF_INSTALL_OUTCOME = "$(STF_INSTALL_OUTCOME)
           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
    endif

    set from = addChiliSrvComponent
    goto getAdapterSettings

addChiliSrvComponent = +
    Debug-Output "******************Entering addChiliSrvComponent******************"
    Ifint $(OldVersionExisted) == $(TRUE)
        ; The ChiliSrv driver is all ready installed.
        goto addHdwDriverComponent
    Endif
    Debug-Output "OEMSETUP.INF: Adding ChiliSrvComponent"
        ;
        ; Install the Chili Service
        ;
        set ConsensysSpecificString = $(ProductSoftwareName)
        set TypeofService = "serviceauto"
        set ServiceOrderGroup = "Extended base"
        set Dependencies = { $(ProductSoftwareNameHdwDriver) }
        set ObjectName = ""
        set TypeSupported = "7"
        set EventLogLocation = "System"
        set ErrorControlValue = 1
        Debug-Output "OEMSETUP.INF: [InstallOption]:skipoptions: About to call AddSoftwareComponent"
        Debug-Output "OEMNADID.INF:     Paramters passed in:"
        Debug-Output "OEMSETUP.INF:         Manufacturer = "$(Manufacturer)
        Debug-Output "OEMSETUP.INF:         Product = "$(ProductSoftwareName)
        Debug-Output "OEMSETUP.INF:         Service = "$(ProductSoftwareName)
        Debug-Output "OEMSETUP.INF:         Display name = "$(ProductSoftwareTitle)
        Debug-Output "OEMSETUP.INF:         INFfile = "$(STF_CONTEXTINFNAME)
        Debug-Output "OEMSETUP.INF:         ImagePath = "$(ProductSoftwareImagePath)
        Debug-Output "OEMSETUP.INF:         TypeOfService = "$(TypeofService)
        Debug-Output "OEMSETUP.INF:         Service Order group = "$(ServiceOrderGroup)
        Debug-Output "OEMSETUP.INF:         Dependencies = "$(Dependencies)
        Debug-Output "OEMSETUP.INF:         ObjectName = "$(ObjectName)
        Debug-Output "OEMSETUP.INF:         EventMessageFile = "$(IoLogMsgDLL)";"$(ProductSoftwareImagePath)
        Debug-Output "OEMSETUP.INF:         TypeSupported = "$(TypeSupported)
        Debug-Output "OEMSETUP.INF:         Event log location = "$(EventLogLocation)
        Debug-Output "OEMSETUP.INF:         Error control value = "$(ErrorControlValue)
        Shell $(UtilityInf), AddSoftwareComponent, +
                                    $(Manufacturer), +
                                    $(ProductSoftwareName), +
                                    $(ProductSoftwareName), +
                                    $(ProductSoftwareTitle), +
                                    $(STF_CONTEXTINFNAME), +
                                    $(ProductSoftwareImagePath), +
                                    $(TypeofService), +
                                    $(ServiceOrderGroup), +
                                    $(Dependencies), +
                                    $(ObjectName), +
                                    $(IoLogMsgDLL)";"$(ProductSoftwareImagePath), +
                                    $(TypeSupported), +
                                    $(EventLogLocation), +
                                    $(ErrorControlValue)
            ;
            ; Return values from AddSoftwareComponent
            ;
            ; $($R0) = error code or zero if no error
            ; $($R1) = Registry key variable for
            ;            SOFTWARE\Manufacturer\Product\Version key
            ; $($R2) = Registry key variable for
            ;            SOFTWARE\...\NetRules
            ; $($R3) = Registry key handle for Services key
            ; $($R4) = "Parameters" key handle for Services area
            ; $($R5) = "Linkage" key handle for Services area
            ;

        Set OEM_ABANDON_SOFTWARE = TRUE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error: Add software component FAILED!"
            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)},+
                           {hidden,$(NoTitle),$(!REG_VT_DWORD),$(NetRuleSoftwareHiddenDriver)}, +
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
        ;
        ; Add the proper values to the
        ;   SOFTWARE\Consensys\ChiliPORTS Service\CurrentVersion key.
        ;
        Shell  $(UtilityInf), AddValueList, $(SoftProductKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error: AddValueList FAILED!  --"$(SoftProductKey)
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "Registry 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)}, +
;                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindForm)}, +
;                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClass)}, +
;                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareBindable)}, +
;                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
;        ;
;        ; Add the proper values to the
;        ;   SOFTWARE\Consensys\ChiliSrv\CurrentVersion\NetRules key.
;        ;
;        Shell  $(UtilityInf), AddValueList, $(SoftNetRuleKey), $(NewValueList)
;        ifint $($ShellCode) != $(!SHELL_CODE_OK)
;            Debug-Output "ShellCode error: AddValueList FAILED! --"$(SoftNetRuleKey)
;            goto ShellCodeError
;        endif
;        set RegistryErrorIndex = $($R0)

        FlushRegKey $(SoftProductKey)
;        FlushRegKey $(SoftNetRuleKey)
        FlushRegKey $(SoftServiceKey)
        FlushRegKey $(SoftParameterKey)
        FlushRegKey $(SoftLinkageKey)

        CloseRegKey $(SoftProductKey)
;        CloseRegKey $(SoftNetRuleKey)
        CloseRegKey $(SoftServiceKey)
        CloseRegKey $(SoftParameterKey)
        CloseRegKey $(SoftLinkageKey)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "Registry error: add value list."
            goto fatalregistry
        endif
        goto addHdwDriverComponent

addHdwDriverComponent = +
    Debug-Output "******************Entering addHdwDriverComponent******************"
    set ConsensysSpecificString = $(AdapterHardwareName)

    Ifint $(HdwDriverComponentExists) == $(TRUE)
        goto addAdapterComponent
    Endif
    Debug-Output "OEMSETUP.INF: Adding HdwDriverComponent"
        ;
        ; Install the Hardware dependent driver
        ;
        set TypeofService = "kernelautostart"
        set ServiceOrderGroup = "Extended base"
        set Dependencies = {}
        set ObjectName = ""
        set TypeSupported = "7"
        set EventLogLocation = "System"
        set ErrorControlValue = 1
        Debug-Output "OEMSETUP.INF: [InstallOption]:addHardwareComponent: About to call AddSoftwareComponent"
        Debug-Output "OEMNADID.INF:     Paramters passed in:"
        Debug-Output "OEMSETUP.INF:         Manufacturer = "$(Manufacturer)
        Debug-Output "OEMSETUP.INF:         Product = "$(ProductSoftwareNameHdwDriver)
        Debug-Output "OEMSETUP.INF:         Service = "$(ProductSoftwareNameHdwDriver)
        Debug-Output "OEMSETUP.INF:         Display name = "$(ProductSoftwareTitleHdwDriver)
        Debug-Output "OEMSETUP.INF:         INFfile = "$(STF_CONTEXTINFNAME)
        Debug-Output "OEMSETUP.INF:         ImagePath = "$(ProductSoftwareImagePathHdwDriver)
        Debug-Output "OEMSETUP.INF:         Type of software = "$(TypeofService)
        Debug-Output "OEMSETUP.INF:         Service Order group = "$(ServiceOrderGroup)
        Debug-Output "OEMSETUP.INF:         Dependencies = "$(Dependencies)
        Debug-Output "OEMSETUP.INF:         ObjectName = "$(ObjectName)
        Debug-Output "OEMSETUP.INF:         EventMessageFile = "$(IoLogMsgDLL)";"$(ProductSoftwareImagePath)
        Debug-Output "OEMSETUP.INF:         TypeSupported = "$(TypeSupported)
        Debug-Output "OEMSETUP.INF:         Event log location = "$(EventLogLocation)
        Debug-Output "OEMSETUP.INF:         Error control value = "$(ErrorControlValue)
        Shell $(UtilityInf), AddSoftwareComponent, +
                                    $(Manufacturer), +
                                    $(ProductSoftwareNameHdwDriver), +
                                    $(ProductSoftwareNameHdwDriver), +
                                    $(ProductSoftwareTitleHdwDriver), +
                                    $(STF_CONTEXTINFNAME), +
                                    $(ProductSoftwareImagePathHdwDriver), +
                                    $(TypeofService), +
                                    $(ServiceOrderGroup), +
                                    $(Dependencies), +
                                    $(ObjectName), +
                                    $(IoLogMsgDLL)";"$(ProductSoftwareImagePathHdwDriver), +
                                    $(TypeSupported), +
                                    $(EventLogLocation), +
                                    $(ErrorControlValue)
            ;
            ; Return values from AddSoftwareComponent
            ;
            ; $($R0) = error code or zero if no error
            ; $($R1) = Registry key variable for
            ;            SOFTWARE\Manufacturer\Product\Version key
            ; $($R2) = Registry key variable for
            ;            SOFTWARE\...\NetRules
            ; $($R3) = Registry key handle for Services key
            ; $($R4) = "Parameters" key handle for Services area
            ; $($R5) = "Linkage" key handle for Services area
            ;

        Set OEM_ABANDON_SOFTWARE = TRUE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error: AddSoftwareComponent FAILED! -- "$(ProductSoftwareNameHdwDriver)
            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),$(ProductMajorVersionHdwDriver)},+
                           {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersionHdwDriver)},+
                           {Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitleHdwDriver)},+
                           {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescriptionHdwDriver)},+
                           {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareNameHdwDriver)},+
                           {hidden,$(NoTitle),$(!REG_VT_DWORD),$(NetRuleSoftwareHiddenHdwDriver)}, +
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
        ;
        ; Add the proper values to the
        ;   SOFTWARE\Consensys\<HdwDriver>\CurrentVersion key.
        ;
        Shell  $(UtilityInf), AddValueList, $(SoftProductKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error: AddValueList FAILED!  -- "$(SoftProductKey)
            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),$(NetRuleSoftwareTypeHdwDriver)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareUseHdwDriver)}, +
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindFormHdwDriver)}, +
                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClassHdwDriver)}, +
                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareBindableHdwDriver)}, +
                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
        ;
        ; Add the proper values to the
        ;   SOFTWARE\Consensys\<HdwDriver>\CurrentVersion\NetRules key.
        ;
        Shell  $(UtilityInf), AddValueList, $(SoftNetRuleKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error. AddValueList FAILED!  -- "$(SoftNetRuleKey)
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)

        FlushRegKey $(SoftProductKey)
        FlushRegKey $(SoftNetRuleKey)
        FlushRegKey $(SoftServiceKey)
        FlushRegKey $(SoftParameterKey)
        FlushRegKey $(SoftLinkageKey)

        CloseRegKey $(SoftProductKey)
        CloseRegKey $(SoftNetRuleKey)
        CloseRegKey $(SoftServiceKey)
        CloseRegKey $(SoftParameterKey)
        CloseRegKey $(SoftLinkageKey)

        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "Registry error: add value list."
            goto fatalregistry
        endif

addAdapterComponent = +
    Debug-Output "******************Entering addAdapterComponent******************"
    ;
    ; Install Adapter specific information
    ;
    Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName), +
                                    $(STF_CONTEXTINFNAME), $(ProductKeyNameHdwDriver)
    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"
        Debug-Output $(RegistryErrorIndex)
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
        goto fatalregistry
    endif
    set KeyParameters = $($R3)
    set KeyAdapterRules = $($R2)
    set AdapterNumber = $($R4)
    set AdapterServiceName = $($R5)
    set AdapterName = $(AdapterServiceName)
    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: AddValueList FAILED  -- "$($R1)
        goto ShellCodeError
    endif
    ; Increment the reference count in the ChiliSrv software component
    shell $(UtilityInf) IncrementRefCount $(ProductKeyName)
    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 "Resgitry error: add value list."
        CloseRegKey $(KeyParameters)
        CloseRegKey $(KeyAdapterRules)
        goto fatalregistry
    endif
    FlushRegKey $(KeyParameters)
    FlushRegKey $(KeyAdapterRules)

    CloseRegKey $(KeyParameters)
    CloseRegKey $(KeyAdapterRules)
    goto writeparameters

;
;   Put up the adapter configuration dialog if necessary.
;
configureadapter = +
    Debug-Output "******************Entering configureadapter******************"
    set !STF_DISPLAYDEBUGOUTPUT = 1

;    Shell "" DebugConfiguration "before displaying dialog"
    Debug-Output "OEMSETUP.INF: PortNameList = "$(PortNameList)

    QueryListSize IRQRangeListSize $(IRQRangeList)
    QueryListSize IORangeListSize $(IORangeList)
    QueryListSize PortNameListSize $(PortNameList)

    ;
    ; Call our custom DLL for more configuration
    ;
    LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), +
            ChiliConfigEntryPoint, $(!STF_HWND), $(AdapterHardwareType), +
                $(ConfigurationTitle), +
                $(IRQRangeList), +
                $(IRQRangeListSize), +
                $(IRQDefault), +
                $(IORangeList), +
                $(IORangeListSize), +
                $(IODefault), +
                $(CtrlList), +
                $(AdapterName)

    Debug-Output "Result="$(Result)

    Ifstr $(Result) == "{}"
        ; The user cancelled the configuration request.
        set CommonStatus = STATUS_USERCANCEL
        goto successful
    Endif

    Split-String $(Result) ":" AdapterParametersList
    set AdapterParameters = { *($(AdapterParametersList),1) , *($(AdapterParametersList),3) }

    read-syms UpdatingConfiguration$(!STF_LANGUAGE)
    shell $(subroutninf) PushBillBoard NETSTATUSDLG $(UpdatingConfiguration)

    ; Go back to where we came from
    Debug-Output "jumping to "$(from)
    goto $(from)

getAdapterSettings = +
    Debug-Output "******************Entering getAdapterSettings******************"
    ;
    ; Read the registry to determine what the current adapter settings
    ; are.
    ;
    Debug-Output "from value = "$(from)
    set IRQDefault = 0
    set IODefault = 1

    LoadLibrary "x" chiliCui.dll CHILI_CONFIG_HANDLE

    read-syms AdapterSettings-$(AdapterHardwareName)

    ; Look for the service name
    Ifstr $(!NTN_RegBase) != $(KeyNull)
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) SoftwareKey
        Ifstr $(SoftwareKey) == $(KeyNull)
            Debug-Output "Unable to open "$(!NTN_RegBase)" key!!!!"
            goto getAdapterSettingsExit
        Else
            GetRegValue $(SoftwareKey), "ServiceName", ServiceNameList
            Debug-Output "ServiceNameList = "$ServiceNameList
            set AdapterServiceName = *($(ServiceNameList),4)
            set AdapterName = $(AdapterServiceName)
            CloseRegKey $(SoftwareKey)
        Endif
    Endif

    Debug-Output "AdapterServiceName = "$(AdapterServiceName)
    Debug-Output "AdapterName = "$(AdapterName)
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(AdapterServiceName) $(MAXIMUM_ALLOWED) BaseKey

    Ifstr $(BaseKey) == $(KeyNull)
        Debug-Output "Error opening BaseKey "$(!NTN_ServiceBase)"\"$(AdapterServiceName)
        CloseRegKey $(BaseKey)
        goto fatalregistry
    Endif

    ; Set the BusTypeNum default to ISA
    set BusTypeNum = 1

    set ParametersKey = $(KeyNull)
    OpenRegKey $(BaseKey) "" "Parameters" $(MAXIMUM_ALLOWED) ParametersKey
    Ifstr $(ParametersKey) == $(KeyNull)
        Debug-Output "Assuming Parameters key does not exist!!!"
        ifstr(i) $(BusType) == "MCA"
            ;
            ; Look for a MCA controller.
            ;
            ForListDo $(AdapterHardwareAdapterID)
               Debug-Output "Calling MCAFindBus, "*($(AdapterIDByte1),$(#))", "*($(AdapterIDByte2),$(#))
               Shell $(UtilityInf), MCAFindBus, *($(AdapterIDByte1),$(#)), *($(AdapterIDByte2),$(#))
               Debug-Output "MCAFindBus returned "$($R1)
               set CardInfo = {}
               ifstr(i) $($R1) != {}
                  set CardInfo = $($R1)
                  Debug-Output "MCA controller found!"
                  Debug-Output "CardInfo = "$(CardInfo)

;--------------------------------------------------------------------------
                  ForListDo $(CardInfo)
                     Debug-Output "Current CardInfo Entry = "$($)
                     set TmpBusNumber = *($($), 1)
                     set SlotNumber = *($($), 2)
                     set MCAPosId = *($($), 3)

                     Debug-Output "Calling DoesControllerExist:"
                     Debug-Output "    AdapterHardwareName = "$(AdapterHardwareName)
                     Debug-Output "    BusNumber = "$(TmpBusNumber)
                     Debug-Output "    Slot # = "$(SlotNumber)
                     Debug-Output " CHILI_CONFIG_HANDLE = "$(CHILI_CONFIG_HANDLE)
                     LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), +
                        DoesControllerExist, $(AdapterHardwareName), +
                                             $(TmpBusNumber),        +
                                             $(SlotNumber)
                     Debug-Output "DoesControllerExist return: "$(Result)
                     ifstr(i) $(Result) == "FALSE"
                        Debug-Output "Before resetting IORangeList for MCA: "$(IORangeList)
                        set IORangeList = {Slot$(SlotNumber)}
                        set IODefault = 0
                        Debug-Output "After resetting IORangeList for MCA: "$(IORangeList)
                        ; Reset the BusTypeNum default to MCA
                        set BusTypeNum = 3
                        goto getAdapterSettingsExit
                     endif
                  EndForListDo
;--------------------------------------------------------------------------
               endif
            EndForListDo
        else
            ;
            ; Look for an EISA controller.
            ;
            Debug-Output "Look for an EISA controller: "$(AdapterHardwareAdapterID)
            ForListDo $(AdapterHardwareAdapterID)
              ifint $($) != 0
                  Debug-Output "Calling EISAFindBus, "$($)
                  Shell $(UtilityInf), EISAFindBus, $($)
                  set CardInfo = {}
                  ifstr(i) $($R1) != {}
                     set CardInfo = $($R1)
                     Debug-Output "EISA controller found!"
                     Debug-Output "CardInfo = "$(CardInfo)

                      ForListDo $(CardInfo)
                         Debug-Output "Current CardInfo Entry = "$($)
                         set TmpBusNumber = *($($), 1)
                         ;
                         ; Convert slot number to IOBaseAddress
                         ;
                         set SlotNumber = *($($), 2)
                         set-mul NewIOBaseAddress = $(SlotNumber), 4096
                         set-add NewIOBaseAddress = $(NewIOBaseAddress), 5
                         set-dectohex NewIOBaseAddress = $(NewIOBaseAddress)

                         Debug-Output "Calling DoesControllerExist:"
                         Debug-Output "    AdapterHardwareName = "$(AdapterHardwareName)
                         Debug-Output "    BusNumber = "$(TmpBusNumber)
                         Debug-Output "    NewIOBaseAddress = "$(NewIOBaseAddress)
                         Debug-Output " CHILI_CONFIG_HANDLE = "$(CHILI_CONFIG_HANDLE)
                         LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), +
                            DoesControllerExist, $(AdapterHardwareName), +
                                                 $(TmpBusNumber),        +
                                                 $(NewIOBaseAddress)
                         Debug-Output "DoesControllerExist return: "$(Result)
                         ifstr(i) $(Result) == "FALSE"
                            Debug-Output "Before resetting IORangeList for EISA: "$(IORangeList)
                            set IORangeList = {$(NewIOBaseAddress)}
                            set IODefault = 0
                            Debug-Output "After resetting IORangeList for EISA: "$(IORangeList)
                            ; Reset the BusTypeNum default to EISA
                            set BusTypeNum = 2
                            goto getAdapterSettingsExit
                         endif
                      EndForListDo
                  endif
               endif
            EndForListDo
        endif

        CloseRegKey $(BaseKey)
        goto configureadapter
    Endif

    GetRegValue $(ParametersKey) "InterruptNumber" IRQValueList
    GetRegValue $(ParametersKey) "IOBaseAddress" IOBaseValueList

    ;
    ; For now, we don't support IRQ's, so don't do anything special for them.
    ;
;    ifstr(i) $(BusType) != "MCA"
       set-dectohex TmpHex = *($(IRQValueList),4)
       Debug-Output "Current InterruptNumber = "$(TmpHex)
       ForListDo $(IRQRangeList)
           Ifstr(i) $(TmpHex) == "0x"$($)
               set-sub IRQDefault = $(#),1
           Endif
       EndForListDo
;    else
;       set IRQRangeList = {*($(SlotNumber),4)}
;       set IRQDefault = 0
;    endif

    ifstr(i) $(BusType) != "MCA"
       set IOFound = $(FALSE)
       set-dectohex TmpHex = *($(IOBaseValueList),4)
       Debug-Output "Current IOBaseAddress = "$(TmpHex)
       ForListDo $(IORangeList)
           Ifstr(i) $(TmpHex) == "0x"$($)
               set-sub IODefault = $(#),1
               set IOFound = $(TRUE)
           Endif
       EndForListDo

       ifint $(IOFound) == $(FALSE)
         ;
         ; The controller is probably an EISA
         ;
         set IORangeList = {$(TmpHex)}
         set IODefault = 0
         set BusTypeNum = 2
       endif
    else
       set IORangeList = {Slot*($(SlotNumber),4)}
       set IODefault = 0
    endif

    set CtrlList = {}
    set LineList = {}
    ForListDo {"1","2"}
      set CurrentLine = "Line"$($)
      Debug-Output "CurrentLine = "$(CurrentLine)
      OpenRegKey $(ParametersKey) "" $(CurrentLine) $(MAXIMUM_ALLOWED) LineKey
            Ifstr $(LineKey) != $(KeyNull)
               set ConcList = {}
               ForListDo {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"}
                  set CurrentConc = "Concentrator"$($)
                  ; Debug-Output "CurrentConc = "$(CurrentConc)
                  OpenRegKey $(LineKey) "" $(CurrentConc) $(MAXIMUM_ALLOWED) ConcKey
                  Ifstr $(ConcKey) != $(KeyNull)
                     ; Look for Port Keys and Conc values
                     set PortNameList = {}
                     set CurrentPort = ""
                     set PortName = {}
                     ForListDo {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"}
                        set CurrentPort = "Port"$($)
                        ; Debug-Output "CurrentPort = "$(CurrentPort)
                        OpenRegKey $(ConcKey) "" $(CurrentPort) $(MAXIMUM_ALLOWED) PortKey
                        Ifstr $(PortKey) != $(KeyNull)
                           ; Look for Port values
                           GetRegValue $(PortKey) "DosDevices" PortName
                           Ifstr $(PortNameList) == $(KeyNull)
                              set PortNameList = *($(PortName),4)
                           Else
                              set PortNameList = >($(PortNameList), >($(CurrentPort),*($(PortName),4)))
                           Endif
                           ; Debug-Output $(CurrentPort)"->"*($(PortName),4)
                           CloseRegKey $(PortKey)
                        EndIf
                     EndForListDo
                     CloseRegKey $(ConcKey)
                     ; Debug-Output "PortNameList = "$(PortNameList)
                     set ConcList = >($(ConcList),>($(CurrentConc),$(PortNameList)))
                     ; Debug-Output "ConcList = "$(ConcList)
                  EndIf
               EndForListDo
               CloseRegKey $(LineKey)
;               Debug-Output "LineList = "$(LineList)
;               Debug-Output "CurrentLine = "$(CurrentLine)
;               Debug-Output "ConcList = "$(ConcList)
;               Debug-Output "ConcList[1] = "*($(ConcList),1)
               set TmpLine = >($(CurrentLine),$(ConcList))
;               Debug-Output "TmpLine = "$(TmpLine)

               set LineList = >($(LineList),$(TmpLine))
            Endif
            Debug-Output "LineList = "$(LineList)
;            Ifstr(i) $(LineList) != {}
;               set CtrlList = >($(CtrlList),>("Ctrl",$(LineList)))
;            Endif
            set CtrlList = $(LineList)
    EndForListDo
;    LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(CtrlList)

    CloseRegKey $(ParametersKey)
    CloseRegKey $(BaseKey)

getAdapterSettingsExit = +
    goto configureadapter


writeparameters = +
    Debug-Output "******************Entering writeparameters******************"
    StartWait
    Debug-Output "Trying to open: "$(!NTN_ServiceBase)"\"$(AdapterServiceName)
    Debug-Output "AdapterParameters: "$(AdapterParameters)

    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(AdapterServiceName) $(MAXIMUM_ALLOWED) BaseKey
    Ifstr $(BaseKey) == $(KeyNull)
        Debug-Output "Error opening BaseKey "$(!NTN_ServiceBase)"\"$(AdapterServiceName)
        CloseRegKey $(BaseKey)
        goto fatal
    Endif
    OpenRegKey $(BaseKey) "" "Parameters" $(MAXIMUM_ALLOWED) ParametersKey
    Ifstr $(ParametersKey) == $(KeyNull)
        Debug-Output "Assuming Parameters key does not exist!!!"
        CloseRegKey $(BaseKey)
        goto fatal
    Endif

;    Debug-Output "AdapterParameters = "
;    LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(AdapterParameters)

    Debug-Output "AdapterParameters parsed: "
    set InterruptNumber = *($(AdapterParameters),1)
    set IOBaseAddress = *($(AdapterParameters),2)
    set HdwDeviceName = "\Device\"$(AdapterHardwareDriver)"Board0"
    Debug-Output "InterruptNumber = "$(InterruptNumber)
    Debug-Output "IOBaseAddress = "$(IOBaseAddress)
    Debug-Output "HdwDeviceName = "$(HdwDeviceName)
    SetRegValue $(ParametersKey) {IOBaseAddress,$(NoTitle),$(!REG_VT_DWORD),$(IOBaseAddress)}
    SetRegValue $(ParametersKey) {InterruptNumber,$(NoTitle),$(!REG_VT_DWORD),$(InterruptNumber)}
    SetRegValue $(ParametersKey) {HdwDeviceName,$(NoTitle),$(!REG_VT_SZ),$(HdwDeviceName)}
    SetRegValue $(ParametersKey) {BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeNum)}

    ifstr(i) $(BusType) == "MCA"
      SetRegValue $(ParametersKey) {MCAPosId,$(NoTitle),$(!REG_VT_DWORD),$(MCAPosId)}
      SetRegValue $(ParametersKey) {SlotNumber,$(NoTitle),$(!REG_VT_DWORD),$(SlotNumber)}
    endif
    FlushRegKey $(ParametersKey)

;    set LineList = *($(AdapterParameters),4)
    set LineList = {}
    Debug-Output "LineList = "$(LineList)
;    LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(LineList)

    ForListDo $(LineList)
      set LineObject = $($)
      Debug-Output "LineObject = "
;      LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(LineObject)

      ; SetRegValue $(BaseKey) {LineObject,$(NoTitle),$(!REG_VT_SZ),$(LineObject)}
      set LineName = *($(LineObject),1)
;      Debug-Output "LineName = "
;      LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(LineName)

      DeleteRegTree $(ParametersKey) $(LineName)

      set ConcList = *($(LineObject),2)
;      Debug-Output "ConcList = "
;      LibraryProcedure Result, $(CHILI_CONFIG_HANDLE), DumpList, $(ConcList)

      Ifstr $(ConcList) != "{}"
         shell "" ExCreateRegKey $(ParametersKey) $(LineName)

         Ifstr(i) $($R0) != NO_ERROR
             Debug-Output "Error creating registry key!"
             set KeyHandle = $($R1)
             CloseRegKey $(BaseKey)
             goto fatal
         Endif
         set LineKey = $($R1)
      Endif

      ForListDo $(ConcList)
         set ConcObject = $($)
         set ConcName = *($(ConcObject),1)
         set PortList = *($(ConcObject),2)
         ; SetRegValue $(BaseKey) {ConcObject,$(NoTitle),$(!REG_VT_SZ),$(ConcObject)}
         ; SetRegValue $(BaseKey) {ConcName,$(NoTitle),$(!REG_VT_SZ),$(ConcName)}
         ; SetRegValue $(BaseKey) {PortList,$(NoTitle),$(!REG_VT_SZ),$(PortList)}
         Debug-Output "   "$(ConcName)
         Debug-Output "   "$(PortList)

         shell "" ExCreateRegKey $(LineKey) $(ConcName)

         Ifstr(i) $($R0) != NO_ERROR
             Debug-Output "Error creating registry key!"
             set KeyHandle = $($R1)
             CloseRegKey $(LineKey)
             goto fatal
         Endif
         set ConcKey = $($R1)

         ForListDo $(PortList)
            set PortObject = $($)
            set PortName = *($(PortObject),1)
            set PortDosDevices = *($(PortObject),2)
            ; SetRegValue $(BaseKey) {PortName,$(NoTitle),$(!REG_VT_SZ),$(PortName)}
            ; SetRegValue $(BaseKey) {PortDosDevices,$(NoTitle),$(!REG_VT_SZ),$(PortDosDevices)}
            Debug-Output "      "$(PortName)"  -> "$(PortDosDevices)
            shell "" ExCreateRegKey $(ConcKey) $(PortName)

            Ifstr(i) $($R0) != NO_ERROR
                Debug-Output "Error creating registry key!"
                set KeyHandle = $($R1)
                CloseRegKey $(LineKey)
                goto fatal
            Endif
            set PortKey = $($R1)
            SetRegValue $(PortKey) {DosDevices,$(NoTitle),$(!REG_VT_SZ),$(PortDosDevices)}
         EndForListDo
      EndForListDo
    EndForListDo

    FlushRegKey $(ParametersKey)
    CloseRegKey $(ParametersKey)
    EndWait
    goto successful

bindingadapter = +
    Debug-Output "******************Entering bindingadapter******************"
    LoadLibrary "x" chiliCui.dll CHILI_CONFIG_HANDLE
    set Error = "Binding: Sorry, not yet implemented."
    goto fatal

removeadapter = +
    read-syms DebugOptions
    Debug-Output "******************Entering removeadapter******************"
;    Debug-Output "OEMSETUP.INF: removeadapter"
;    Debug-Output "OEMSETUP.INF: Removing Hardware Components"
;    Debug-Output "OEMSETUP.INF: ProductKeyName = "$(ProductKeyName)
;    Debug-Output "OEMSETUP.INF: ProductSoftwareName = "$(ProductSoftwareName)
;    Debug-Output "OEMSETUP.INF: ProductSoftwareNameHdwDriver = "$(ProductSoftwareNameHdwDriver)
;    Debug-Output "OEMSETUP.INF: NTN_RegBase = "$(!NTN_RegBase)

    ifstr(i) $(fRemoveChili) == FALSE
      install RemoveFiles
      goto removeadapterExit
    endif

    LoadLibrary "x" chiliCui.dll CHILI_CONFIG_HANDLE

    Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
        $(ProductSoftwareNameHdwDriver), $(!NTN_RegBase)
    Debug-Output "OEMSETUP.INF: RemoveHardwareComponent return value = "$($R0)

    Ifstr(i) $($R0) != NO_ERROR
        Debug-Output "OEMSETUP.INF: RemoveHardwareComponent != NO_ERROR"
    Endif

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

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "fatal registry error"
        goto fatalregistry
    endif

    ; Deinstall the primary ChiliSrv driver, if reference count
    ; goes to zero.
    shell $(UtilityInf), DecrementRefCount, $(ProductKeyName)
    Debug-Output "OEMSETUP.INF: DecrementRefCount return value = "$($R0)
    Ifstr(i) $($R0) != NO_ERROR
        Debug-Output "OEMSETUP.INF: DecrementRefCount != NO_ERROR"
    Endif

    Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
        $(ProductSoftwareName), TRUE

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

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Ifstr(i) $(RegistryErrorIndex) != REF_COUNT_NOT_ZERO
            goto fatalregistry
        endif
    endif
;
;    Uncomment next line if driver files are to be deleted.
;    install RemoveFiles

removeadapterExit = +
    Debug-Output "OEMSETUP.INF: Exiting removeadapter"
    goto end

UpgradeSoftware = +
    Debug-Output "******************Entering UpgradeSoftware******************"
    LoadLibrary "x" chiliCui.dll CHILI_CONFIG_HANDLE
    ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
        OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
        Ifstr $(KeyProduct) != $(KeyNull)
            GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
            set Version = *($(VersionInfo), 4)
            Split-String $(!NTN_Infname), "\", FilenameList
            QueryListSize ListSize $(FilenameList)
            set !UG_Filename = *($(FilenameList), $(ListSize))
            install "Install-Update"
            ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
                goto fatal
            endif
            SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
            SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}
            ifint $(Version) != $(ProductVersion)
            endif
            CloseRegKey $(KeyProduct)
        else
            goto fatalregistry
        endif
    else
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
              $(MAXIMUM_ALLOWED) NetworkCardKey
        Ifstr(i) $(NetworkCardKey) != $(KeyNull)
            GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
            set ServiceName = *($(ServiceNameInfo), 4)
            OpenRegKey $(NetworkCardKey) "" "NetRules" +
                $(MAXIMUM_ALLOWED) NetRuleKey
            Ifstr $(NetRuleKey) != $(KeyNull)
            else
                goto fatalregistry
            endif
            CloseRegKey $(NetRules)
            CloseRegKey $(NetworkCardKey)
        else
            goto fatalregistry
        endif
        OpenRegKey $(!REG_H_LOCAL) "" +
              $(!NTN_ServiceBase)"\"$(ServiceName) +
              $(MAXIMUM_ALLOWED) ServiceKey
        Ifstr $(ServiceKey) != $(KeyNull)
            CloseRegKey $(ServiceKey)
        else
            goto fatalregistry
        endif
    endif
    goto end

successful = +
    Debug-Output "******************Entering successful******************"
    goto end
abandon = +
    Debug-Output "******************Entering 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
        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 = +
    Debug-Output "******************Entering 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
nonfatalinfo = +
    Debug-Output "******************Entering nonfatalinfo******************"
    Set CommonStatus = STATUS_USERCANCEL
    Set Severity = STATUS
    goto nonfatalmsg
nonfatal = +
    Debug-Output "******************Entering nonfatal******************"
    Set Severity = NONFATAL
    goto nonfatalmsg
nonfatalmsg = +
    Debug-Output "******************Entering 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
fatalregistry = +
    Debug-Output "******************Entering fatalregistry******************"
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
       Debug-Output "fatalregistry: shell to find RegistryErrorString failed."
       goto ShellCodeError
    endif
    set Error = $($R0)" - service "$(ConsensysSpecificString)"."
    ifstr(i) $(fRemoveChili) == TRUE
        read-syms AbortMessage$(!STF_LANGUAGE)
        set Error = $(Error)$(!LF)$(!LF)$(AbortText)
    endif
    goto fatal
fataldetect = +
    Debug-Output "******************Entering 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 = +
    Debug-Output "******************Entering fatal******************"
    Debug-Output "OEMSETUP.INF: ---- fatal called"
    Shell $(subroutninf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "fatal: shell to SetupMessage failed."
        goto ShellCodeError
    endif
    goto setfailed
ShellCodeError = +
    Debug-Output "******************Entering ShellCodeError******************"
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = "Error: "$(FunctionTitle)
    set STF_MB_TEXT  = "Shell Code Error"
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed
setfailed = +
    Debug-Output "******************Entering setfailed******************"
    set CommonStatus = STATUS_FAILED
    ifstr(i) $(fRemoveChili) == TRUE
        set fRemoveChili = FALSE
        goto removeadapter
    endif
    goto end
end = +
    Debug-Output "******************Entering end******************"
    goto term
term = +
    ifstr(i) $(CHILI_CONFIG_HANDLE) != $(HandleNull)
      FreeLibrary $(CHILI_CONFIG_HANDLE)
    endif
    Debug-Output "******************Entering term -- GoodBye!!!******************"
    Return $(CommonStatus)

[RemoveFiles]
   Debug-Output "******************Entering [RemoveFiles]******************"
   set RemoveList = {}
   set RenameList = {}
   ;
   ; First determine if the hardware component has be completely
   ; uninstalled.  If it has, then we add the components to our
   ; rename list.
   ;

   OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyNameHdwDriver) +
              $(MAXIMUM_ALLOWED) KeyProductHdwDriver
   ifstr $(KeyProductHdwDriver) == $(KeyNull)
      CloseRegKey $(KeyProductHdwDriver)
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(AdapterHardwareDriver)".sys")
   endif

   ;
   ; Determine if the ChiliPORTS Service component has been completely
   ; uninstalled.  If it has, then we add the components to our
   ; rename list, and add the config stuff to our remove list.
   ;
   OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) +
              $(MAXIMUM_ALLOWED) KeyProduct
   ifstr $(KeyProduct) == $(KeyNull)
      CloseRegKey $(KeyProduct)
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\chiliObs.sys")
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\chiliCui.dll")
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\chiliSrv.exe")
;      set RemoveList = >($(RemoveList), $(!STF_WINDOWSSYSPATH)"\chiliCui.hlp")
   endif

   Debug-Output "RemoveList = "$(RemoveList)
   Debug-Output "RenameList = "$(RenameList)

   ForListDo $(RemoveList)
       Debug-Output "Removing "$($)
       LibraryProcedure Status , $(!LIBHANDLE), DelFile $($)
       Debug-Output "Status is "$(Status)
   EndForListDo

   ForListDo $(RenameList)
       Debug-Output "RenameList entry = "$($)
       Split-String $($) "\" FilePath
       QueryListSize PathLen $(FilePath)
       Split-String *($(FilePath),$(PathLen)) "." FullFileName
       set-sub DirIndex = $(PathLen), 2
       Set Directory = *($(FilePath),$(DirIndex))"\"
       Set FileName = *($(FullFileName),1)
       ifstr(i) $(Directory) != "drivers\"
           Set Directory = ""
       endif
       LibraryProcedure STATUS, $(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\"$(Directory)$(FileName)".old"
       Debug-Output "CheckFile Status = "$(STATUS)
       ifstr(i) $(STATUS) == YES
           LibraryProcedure STATUS, $(!LIBHANDLE), DelFile $(!STF_WINDOWSSYSPATH)"\"$(Directory)$(FileName)".old"
           Debug-Output "Delfile Status = "$(STATUS)
           LibraryProcedure STATUS, $(!LIBHANDLE), DelFile $($)
           Debug-Output "Delfile Status = "$(STATUS)
       endif
       ifstr(i) $(fRemoveChili) == TRUE
         Debug-Output "Renaming from "$($)
         Debug-Output "Renaming to "$(!STF_WINDOWSSYSPATH)"\"$(Directory)$(FileName)".old"
         LibraryProcedure Status1 , $(!LIBHANDLE), RenFile $($), $(!STF_WINDOWSSYSPATH)"\"$(Directory)$(FileName)".old"
         Debug-Output "Status is "$(Status1)
         AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\"$(Directory)$(FileName)".old"
       endif
   EndForListDo
   exit


;*************************************************************************
;
;     SECTION:  ExCreateRegKey
;
;     PURPOSE:  Opens and creates registry keys
;
;   ARGUMENTS:  $0   Open handle to registry key in which to create new key
;               $1   Registry path to create
;
;    RETURNS:   $R0  error code or zero if no error
;               $R1  Registry key handle of the newly created path
;
;  REFERENCES:  none
;
;    MODIFIES:  none
;
;*************************************************************************
[ExCreateRegKey]
    Debug-Output "******************Entering [ExCreateRegKey]******************"
    set ECR_Result          = NO_ERROR
    set ECR_BaseKeyHandle   = $($0)
    set ECR_NewPath         = $($1)
    set KeyNull         = ""
    set MAXIMUM_ALLOWED   = 33554432

    Debug-Output "ExCreateRegKey - ECR_BaseKeyHandle = "$(ECR_BaseKeyHandle)
    Debug-Output "                 ECR_NewPath = "$(ECR_NewPath)
    Debug-Output "                 MAXIMUM_ALLOWED = "$(MAXIMUM_ALLOWED)
    Debug-Output "                 KeyNull = "$(KeyNull)

    OpenRegKey $(ECR_BaseKeyHandle) "" $(ECR_NewPath) $(MAXIMUM_ALLOWED) +
               ECR_BaseKey
    Debug-Output "ECR_BaseKey = "$(ECR_BaseKey)
    Debug-Output "    OpenRegKey returned "$($R0)
    Ifstr $(ECR_BaseKey) == $(KeyNull)
        Debug-Output "ECR_BaseKey == KeyNull"
    Else
        ; The key all ready exists.
        Debug-Output "ECR_BaseKey != KeyNull"
        set ECR_KeyHandle = $(ECR_BaseKey)
        goto  ECR_Return
    Endif

    set ECR_TmpPath = ""
    Split-String $(ECR_NewPath) "\" ECR_PList
    Debug-Output "ECR_PList = "$(ECR_PList)
    ForListDo $(ECR_PList)
        Ifstr(i) $($) != "\"
            Ifint $(#) == 1
                set ECR_TmpPath = $($)
            Else
                set ECR_TmpPath = $(ECR_TmpPath)"\"$($)
            Endif
            Debug-Output "Determining if "$(ECR_TmpPath)" exists"
            OpenRegKey $(ECR_BaseKeyHandle) "" $(ECR_TmpPath) $(MAXIMUM_ALLOWED) ECR_BaseKey
            Ifstr $(ECR_BaseKey) == $(KeyNull)
                Debug-Output "Creating "$(ECR_TmpPath)
                CreateRegKey $(ECR_BaseKeyHandle)  {$(ECR_TmpPath),0,GenericClass} "" $(MAXIMUM_ALLOWED) "" ECR_KeyHandle
                Ifstr(i) $(ECR_KeyHandle) == $(KeyNull)
                    set ECR_Result = $($R0)
                    goto ECR_Return
                Endif
            Endif
        Endif
    EndForListDo

ECR_Return = +
    return $(ECR_Result) $(ECR_KeyHandle)

[DebugExternalGlobals]
    Set InfName = "OEMSETUP.INF"
    Debug-Output $(InfName)" NTN_Origination = "$(!NTN_Origination)
    Debug-Output $(InfName)" NTN_InstallMode = "$(!NTN_InstallMode)
    Debug-Output $(InfName)" NTN_RegBase = "$(!NTN_RegBase)
    Debug-Output $(InfName)" NTN_SoftwareBase = "$(!NTN_SoftwareBase)
    Debug-Output $(InfName)" NTN_ServiceBase = "$(!NTN_ServiceBase)
    Debug-Output $(InfName)" STF_NTPATH = "$(!STF_NTPATH)
    Debug-Output $(InfName)" STF_NTWINDOWSSYSPATH = "$(!STF_WINDOWSSYSPATH)
    Debug-Output $(InfName)" STF_CWDIR = "$(!STF_CWDIR)
    Debug-Output $(InfName)" STF_LANGUAGE = "$(!STF_LANGUAGE)
    Debug-Output $(InfName)" STF_NCDETECT  = "$(!STF_NCDETECT)
    Debug-Output $(InfName)" STF_NCOPTION  = "$(!STF_NCOPTION)
    Debug-Output $(InfName)" STF_NCDETCARD = "$(!STF_NCDETCARD)
    Debug-Output $(InfName)" STF_NCDETINFO = "$(!STF_NCDETINFO)
    Debug-Output $(InfName)" STF_INSTALL_MODE = "$(!STF_INSTALL_MODE)
    Debug-Output $(InfName)" STF_CONTEXTINFNAME = "$(!STF_CONTEXTINFNAME)
    return

[DebugConfiguration]
    Set InfName = "OEMSETUP.INF"
    Debug-Output $(InfName)" **CONFIGURATION STATE: "$($0)
    Debug-Output $(InfName)" IRQ_Level is "$(!p:IRQ_Level)
    Debug-Output $(InfName)" IOBaseAddrValue is "$(!p:IOBaseAddrValue)
    Debug-Output $(InfName)" TransceiverValue is "$(!p:TransceiverValue)
    Debug-Output $(InfName)" MemBaseAddrDec is "$(!p:MemBaseAddrDec)
    Debug-Output $(InfName)" MappedValue is "$(!p:MappedValue)
    return

;
; The AdapterSettings-<Hardware dependent modules> section has
; the following entries with there corresponding definitions:
;
;   IRQRangeList -
;   IORangeList -
;


[AdapterSettings-cp4i]
;IRQRangeList = {"3","5","7","10","11","12","15","Disabled"}
IRQRangeList = {"Disabled"}
IORangeList = {"204","208"}
IRQDefault = 0
IODefault = 2

[AdapterSettings-cp8i]
;IRQRangeList = {"3","5","7","10","11","12","15","Disabled"}
IRQRangeList = {"Disabled"}
IORangeList = {"204","208"}
IRQDefault = 0
IODefault = 2

[AdapterSettings-cp16i]
;IRQRangeList = {"3","5","7","10","11","12","15","Disabled"}
IRQRangeList = {"Disabled"}
IORangeList = {"204","208"}
IRQDefault = 0
IODefault = 2

[AdapterSettings-cp8e]
;IRQRangeList = {"3","5","7","10","11","12","15","Disabled"}
IRQRangeList = {"Disabled"}
IORangeList = {"204","208"}
IRQDefault = 0
IODefault = 2


[BindingInfo-chili]
BindingInfo     = {+
                  $(AdapterHardwareDriver)"Driver "$(AdapterHardwareDriver)"Adapter non exclusive 100", +
                  }

[MyGetProcessor]
    PROCESSOR = "" ? $(!LIBHANDLE) GetProcessor

[SetPlatform]
    detect MyGetProcessor
    ifstr(i) $(PROCESSOR) == I386
        set Platform = I386
    else-ifstr(i) $(PROCESSOR) == I486
        set Platform = I386
    else-ifstr(i) $(PROCESSOR) == I586
        set Platform = I386
    else-ifstr(i) $(PROCESSOR) == R4000
        set Platform = Mips
    else-ifstr(i) $(PROCESSOR) == Alpha_AXP
        set Platform = Alpha
    else
        set Platform = $(PROCESSOR)
    endif
    Debug-Output "SetPlatform: PROCESSOR = "$(PROCESSOR)" Platform = "$(Platform)
    Return STATUS_SUCCESSFUL $(Platform)



[InstallResources]
    set STF_VITAL = ""
    Debug-Output "OEMSETUP.INF: [InstallResources]"
;    AddSectionFilesToCopyList Files-Resource $(!SourceDir)$(!STF_PLATFORM) $(!STF_WINDOWSSYSPATH)
    AddSectionFilesToCopyList Files-Resource $(!SourceDir) $(!STF_WINDOWSSYSPATH)
    CopyFilesInCopyList
    Debug-Output "OEMSETUP.INF: [InstallResources] - Exiting"
    exit

[Install-Option]
    set STF_VITAL = ""
    Debug-Output "Install-Option: SrcDir = "$(SrcDir)" STF_PLATFORM = "$(!STF_PLATFORM)
    Debug-Output "Option = "$(Option)" AddCopy = "$(AddCopy)" DoCopy = "$(DoCopy)
    ifstr(i) $(AddCopy) == "YES"
;        AddSectionFilesToCopyList Files-Resource $(SrcDir)$(!STF_PLATFORM) $(!STF_WINDOWSSYSPATH)
        AddSectionFilesToCopyList Files-Resource $(SrcDir) $(!STF_WINDOWSSYSPATH)
        AddSectionFilesToCopyList Files-ChiliSrv $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
;        AddSectionFilesToCopyList Files-$(Option) $(SrcDir)$(!STF_PLATFORM) $(!STF_WINDOWSSYSPATH)\drivers
        AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
    endif
    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    ifstr(i) $(DoConfig) == "YES"
    endif
    Exit

[Source Media Descriptions]
    1  = "ChiliPORTS Setup Disk"  , TAGFILE = disk1
    2  = "Windows NT Setup CD-ROM Disk"  , TAGFILE = disk2

[ProductType]
STF_PRODUCT  = Winnt
;STF_PLATFORM = I386

[Files-Inf]
1,	oemsetup.inf,	 SIZE=1000,	RENAME=$(!UG_Filename)

[Files-Resource]
1,chiliCui.dll , SIZE=17408
1,chiliSrv.exe , SIZE=78336

[Files-ChiliSrv]
1,chiliObs.sys , SIZE=35840

[Files-ChiliPORTS8e]
1,chili.sys , SIZE=133120

[Files-ChiliPORTS4i]
1,chili.sys , SIZE=133120

[Files-ChiliPORTS8i]
1,chili.sys , SIZE=133120

[Files-ChiliPORTS16i]
1,chili.sys , SIZE=133120

;-----------------------------------------------------------------------
; 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]
    ChiliPORTS4i     = "ChiliPORTS /4 RAS Adapter"
    ChiliPORTS8i     = "ChiliPORTS /8 RAS Adapter"
    ChiliPORTS16i    = "ChiliPORTS/16 RAS Adapter"

[OptionsTextMCAENG]
    ChiliPORTS4m     = "ChiliPORTS MC/4 RAS Adapter"
    ChiliPORTS8m     = "ChiliPORTS MC/8 RAS Adapter"
    ChiliPORTS16m    = "ChiliPORTS MC/16 RAS Adapter"

;***********************************************************************
; Language-Dependent Dialog Constants
;***********************************************************************
[FileConstantsENG]
;
;  Variables to support thermometer gauge and error dialogs
;
    ProCaption   = "ChiliPORTS Setup"
    ProCancel    = "Cance&l"
    ProCancelMsg = "ChiliPORTS Adapters and/or Drivers are not correctly installed. "+
                   "Are you sure you want to cancel copying files?"
    ProCancelCap = "ChiliPORTS Setup Message"
    ProText1     = "Copying:"
    ProText2     = "To:"
    Error         = "Unable to determine proper source disk location; copy cannot be performed."
;
; Product Info
;
    FunctionTitle   ="ChiliPORTS Setup"
;
; Software
;
    ProductSoftwareDescription          = "ChiliPORTS Service"
    ProductSoftwareDescriptionHdwDriver = "ChiliPORTS "$(AdapterTitle)" Driver"
    ProductSoftwareTitle    = "ChiliPORTS Service"
    ProductSoftwareTitleHdwDriver = "ChiliPORTS "$(AdapterTitle)" Driver"

;
; Configuration Information
;
   ConfigurationTitle = "ChiliPORTS "$(AdapterTitle)" Adapter Setup"

;
; Hardware
;
    ProductHardwareDescription  = "ChiliPORTS "$(AdapterTitle)" RAS Adapter"
    ProductHardwareTitle        = "ChiliPORTS "$(AdapterTitle)" RAS Adapter"

[DialogConstantsENG]
;
; Common button names, etc.
;
    Help        = "&Help"
    Exit        = "E&xit"
    OK          = "OK"
    HelpContext = ""
    Continue    = "C&ontinue"
    Cancel      = "C&ancel"

[UpdatingConfigurationENG]
    UpdatingConfiguration      = "Updating new configuration..."

[AbortMessageENG]
  AbortText  =  "Aborting ChiliPORTS Setup. Please reboot the system "+
                "to fix the problem."

