Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

604 lines
24 KiB

  1. '////////////////////////////////////////////////////////////////////////////
  2. ' $Header:$
  3. ' Windows Embedded Default Prototype Script
  4. ' Version: 2.00
  5. ' Author: timhill
  6. ' Copyright (c) 1999-2000 Microsoft Corp. All Rights Reserved.
  7. '////////////////////////////////////////////////////////////////////////////
  8. Option Explicit
  9. ' Setup basic objects (reflect config objects)
  10. Dim g_oConfigScript : Set g_oConfigScript = cmiThis.Configuration.Script
  11. Dim g_oFSO : Set g_oFSO = g_oConfigScript.g_oFSO
  12. Dim g_oShell : Set g_oShell = g_oConfigScript.g_oShell
  13. Dim g_oEnv : Set g_oEnv = g_oConfigScript.g_oEnv
  14. Dim g_oNet : Set g_oNet = g_oConfigScript.g_oNet
  15. Dim g_oCMIUtil : Set g_oCMIUtil = g_oConfigScript.g_oCMIUtil
  16. '////////////////////////////////////////////////////////////////////////////
  17. ' Configuration handlers
  18. '////////////////////////////////////////////////////////////////////////////
  19. '////////////////////////////////////////////////////////////////////////////
  20. ' cmiOnOpenConfig
  21. ' Called from Config::cmiOnOpenConfig
  22. '
  23. Sub cmiOnOpenConfig
  24. TraceEnter "DefProto::cmiOnOpenConfig"
  25. TraceLeave "DefProto::cmiOnOpenConfig"
  26. End Sub
  27. '////////////////////////////////////////////////////////////////////////////
  28. ' cmiOnSaveConfig
  29. ' Called from Config::cmiOnSaveConfig
  30. '
  31. Sub cmiOnSaveConfig
  32. TraceEnter "DefProto::cmiOnSaveConfig"
  33. TraceLeave "DefProto::cmiOnSaveConfig"
  34. End Sub
  35. '////////////////////////////////////////////////////////////////////////////
  36. ' cmiOnCloseConfig
  37. ' Called from Config::cmiOnCloseConfig
  38. '
  39. Sub cmiOnCloseConfig
  40. TraceEnter "DefProto::cmiOnCloseConfig"
  41. TraceLeave "DefProto::cmiOnCloseConfig"
  42. End Sub
  43. '////////////////////////////////////////////////////////////////////////////
  44. ' Instance handlers
  45. '////////////////////////////////////////////////////////////////////////////
  46. '////////////////////////////////////////////////////////////////////////////
  47. ' cmiOnAddInstance (virtual)
  48. ' Called from Config::cmiOnAddInstance
  49. '
  50. ' We need to collapse the component chain properties, dependencies and
  51. ' resources, and also validate the instance. We always allow a resource etc
  52. ' in a more-derived component to over-ride one of the same name in a baser
  53. ' component. Note that script (DHTML and regular) is not collapsed.
  54. '
  55. ' Returns False to disallow addition, True to allow addition
  56. Function cmiOnAddInstance
  57. TraceEnter "DefProto::cmiOnAddInstance"
  58. TraceState "cmiThis.Comment", cmiThis.Comment
  59. ' Initial instance validity check
  60. cmiOnAddInstance = cmiThis.Script.cmiCollapseFirstCheck
  61. ' Build instance by collapsing component chain data
  62. If cmiOnAddInstance Then cmiOnAddInstance = cmiThis.Script.cmiCollapseProperties
  63. If cmiOnAddInstance Then cmiOnAddInstance = cmiThis.Script.cmiCollapseResources
  64. If cmiOnAddInstance Then cmiOnAddInstance = cmiThis.Script.cmiCollapseDependencies
  65. ' Final instance validity check before acceptance
  66. If cmiOnAddInstance Then cmiOnAddInstance = cmithis.Script.cmiCollapseLastCheck
  67. TraceLeave "DefProto::cmiOnAddInstance"
  68. End Function
  69. '////////////////////////////////////////////////////////////////////////////
  70. ' cmiCollapseFirstCheck and cmiCollapseLastCheck (virtual)
  71. ' Check valid instance first and last checks
  72. '
  73. ' Returns False to disallow addition, True to allow addition
  74. Function cmiCollapseFirstCheck
  75. TraceEnter "DefProto::cmiCollapseFirstCheck"
  76. cmiCollapseFirstCheck = True ' OK to add instance
  77. TraceLeave "DefProto::cmiCollapseFirstCheck"
  78. End Function
  79. Function cmiCollapseLastCheck
  80. TraceEnter "DefProto::cmiCollapseLastCheck"
  81. cmiCollapseLastCheck = True ' OK to add instance
  82. TraceLeave "DefProto::cmiCollapseLastCheck"
  83. End Function
  84. '////////////////////////////////////////////////////////////////////////////
  85. ' cmiCollapseProperties (virtual)
  86. ' Collapse all instance properties (standard and extended)
  87. '
  88. ' Returns False to disallow addition, True to allow addition
  89. Function cmiCollapseProperties
  90. TraceEnter "DefProto::cmiCollapseProperties"
  91. Dim oDict : Set oDict = CreateObject("Scripting.Dictionary")
  92. oDict.CompareMode = vbTextCompare
  93. Dim oTopComp : Set oTopComp = cmiThis.ComponentChain(1)
  94. Dim oComp, oProp
  95. ' Set standard properties
  96. cmiThis.Editable = False ' True if any component true
  97. cmiThis.IsBaseComponent = (LCase(oTopComp.VIGUID) = LCase(cmiThis.Platform.BaseComponentVIGUID))
  98. cmiThis.IsMacro = oTopComp.IsMacro ' Are we a macro instance?
  99. cmiThis.MultiInstance = True ' False if any component false
  100. cmiThis.Visibility = 0 ' Use max of all components
  101. ' Merge component chain properties
  102. For Each oComp In cmiThis.ComponentChain ' For each component..
  103. cmiThis.Editable = cmiThis.Editable Or oComp.Editable
  104. cmiThis.MultiInstance = cmiThis.MultiInstance And oComp.MultiInstance
  105. If oComp.Visibility > cmiThis.Visibility Then
  106. cmiThis.Visibility = oComp.Visibility ' Choose most visible
  107. End If
  108. For Each oProp In oComp.Properties ' For each extended property..
  109. If Not oDict.Exists(oProp.Name) Then ' If not yet added..
  110. If cmiThis.Script.cmiCollapseProperty(oComp, oProp) Then
  111. oDict.Add oProp.Name, "" ' Mark it's added
  112. End If
  113. End If
  114. Next
  115. Next
  116. If cmiThis.Editable Then ' Force visibility if editable
  117. If cmiThis.Visibility < 1000 Then cmiThis.Visibility = 1000 ' Force to default
  118. End If
  119. ' Not ok if single instance component and instance > 0
  120. cmiCollapseProperties = (cmiThis.MultiInstance Or cmiThis.InstanceID = 0)
  121. TraceLeave "DefProto::cmiCollapseProperties"
  122. End Function
  123. '////////////////////////////////////////////////////////////////////////////
  124. ' cmiCollapseProperty (virtual)
  125. ' Collapse an individual property
  126. '
  127. ' oComponent Source component for property
  128. ' oProperty Property to collapse (add) into instance
  129. ' Returns True if property added, else False (not added)
  130. Function cmiCollapseProperty(oComponent, oProperty)
  131. TraceEnter "DefProto::cmiCollapseProperty"
  132. TraceState "oProperty.Name", oProperty.Name
  133. cmiThis.Properties.Add oProperty.Name, oProperty.Format, oProperty.Value
  134. cmiCollapseProperty = True ' Mark that we added it
  135. TraceLeave "DefProto::cmiCollapseProperty"
  136. End Function
  137. '////////////////////////////////////////////////////////////////////////////
  138. ' cmiCollapseResources (virtual)
  139. ' Collapse resources (choose most derived where overlap occurs)
  140. '
  141. ' Returns False to disallow addition, True to allow addition
  142. Function cmiCollapseResources
  143. TraceEnter "DefProto::cmiCollapseResources"
  144. Dim oDict : Set oDict = CreateObject("Scripting.Dictionary")
  145. oDict.CompareMode = vbTextCompare
  146. Dim oComp, oRes
  147. For Each oComp In cmiThis.ComponentChain ' For each component..
  148. For Each oRes In oComp.GetResources ' For each resource..
  149. If Not oDict.Exists(oRes.Name) Then ' If not yet added..
  150. If cmiThis.Script.cmiCollapseResource(oComp, oRes) Then
  151. oDict.Add oRes.Name, "" ' Mark it's added
  152. End If
  153. End If
  154. Next
  155. Next
  156. cmiCollapseResources = True ' OK to add instance
  157. TraceLeave "DefProto::cmiCollapseResources"
  158. End Function
  159. '////////////////////////////////////////////////////////////////////////////
  160. ' cmiCollapseResource (virtual)
  161. ' Collapse an individual resource
  162. '
  163. ' oComponent Source component for resource
  164. ' oResource Resource to collapse (add) into instance
  165. ' Returns True if resource added, else False (not added)
  166. Function cmiCollapseResource(oComponent, oResource)
  167. TraceEnter "DefProto::cmiCollapseResource"
  168. TraceState "oResource.Name", oResource.Name
  169. Dim oNewRes, oProp, oNewProp
  170. Set oNewRes = cmiThis.Resources.Add(oResource.Type, oResource.BuildTypeMask, oResource.Localize, oResource.Disabled, oResource.DisplayName, oResource.Description)
  171. For Each oProp In oResource.Properties ' For each property
  172. Set oNewProp = oNewRes.Properties(oProp.Name)
  173. If oNewProp Is Nothing Then ' Property does not exist
  174. oNewRes.Properties.Add oProp.Name, oProp.Format, oProp.Value
  175. Else
  176. If oNewProp.Format = oProp.Format Then ' If same format..
  177. If oProp.Format = cmiObject Then
  178. Set oNewProp.Value = oProp.Value
  179. Else
  180. oNewProp.Value = oProp.Value ' ..just copy value
  181. End If
  182. Else
  183. oNewRes.Properties.Remove oProp.Name ' Delete default
  184. oNewRes.Properties.Add oProp.Name, oProp.Format, oProp.Value
  185. End If
  186. End If
  187. Next
  188. Set oProp = oNewRes.Properties("ComponentVSGUID")
  189. If Not oProp Is Nothing Then ' If present..
  190. oProp.Value = oComponent.VSGUID ' ..record component VSGUID
  191. End If
  192. cmiCollapseResource = True ' Add the resource
  193. TraceLeave "DefProto::cmiCollapseResource"
  194. End Function
  195. '////////////////////////////////////////////////////////////////////////////
  196. ' cmiCollapseDependencies (virtual)
  197. ' Collapse dependencies
  198. '
  199. ' Returns False to disallow addition, True to allow addition
  200. Function cmiCollapseDependencies
  201. TraceEnter "DefProto::cmiCollapseDependencies"
  202. Dim oComp, oDep
  203. cmiCollapseDependencies = True ' Mark that we added it
  204. For Each oComp In cmiThis.ComponentChain ' For each component..
  205. For Each oDep In oComp.GetDependencies ' For each dependency..
  206. If Not cmiThis.Script.cmiCollapseDependency(oComp, oDep) Then
  207. cmiCollapseDependencies = False
  208. End If
  209. Next
  210. Next
  211. TraceLeave "DefProto::cmiCollapseDependencies"
  212. End Function
  213. '////////////////////////////////////////////////////////////////////////////
  214. ' cmiCollapseDependency (virtual)
  215. ' Collapse an individual dependency
  216. '
  217. ' oComponent Source component for dependency
  218. ' oDependency Dependency to collapse (add) into instance
  219. ' Returns True if dependency added, else False (not added)
  220. Function cmiCollapseDependency(oComponent, oDependency)
  221. TraceEnter "DefProto::cmiCollapseDependency"
  222. cmiThis.Dependencies.Add oDependency.Class, oDependency.Type, oDependency.TargetGUID, oDependency.MinRevision, oDependency.DisplayName, oDependency.Description
  223. cmiCollapseDependency = True ' Mark that we added it
  224. TraceLeave "DefProto::cmiCollapseDependency"
  225. End Function
  226. '////////////////////////////////////////////////////////////////////////////
  227. ' cmiOnLoadInstance
  228. ' Called from Config::cmiOnLoadInstance
  229. '
  230. ' Returns False to disallow load, True to allow load
  231. Function cmiOnLoadInstance
  232. TraceEnter "DefProto::cmiOnLoadInstance"
  233. TraceState "cmiThis.Comment", cmiThis.Comment
  234. cmiOnLoadInstance = True
  235. TraceLeave "DefProto::cmiOnLoadInstance"
  236. End Function
  237. '////////////////////////////////////////////////////////////////////////////
  238. ' cmiOnConfigureInstance
  239. ' Called from Config::cmiOnConfigureInstance
  240. Sub cmiOnConfigureInstance
  241. TraceEnter "DefProto::cmiOnConfigureInstance"
  242. TraceState "cmiThis.Comment", cmiThis.Comment
  243. TraceLeave "DefProto::cmiOnConfigureInstance"
  244. End Sub
  245. '////////////////////////////////////////////////////////////////////////////
  246. ' cmiOnUpgradeInstance
  247. ' Called from Config::cmiOnUpgradeInstance
  248. '
  249. ' oOldInstance Old instance (source of upgrade state)
  250. Sub cmiOnUpgradeInstance(oOldInstance)
  251. TraceEnter "DefProto::cmiOnUpgradeInstance"
  252. TraceState "cmiThis.Comment", cmiThis.Comment
  253. TraceState "oOldInstance.Comment", oOldInstance.Comment
  254. TraceLeave "DefProto::cmiOnUpgradeInstance"
  255. End Sub
  256. '////////////////////////////////////////////////////////////////////////////
  257. ' cmiOnDeleteInstance
  258. ' Called from Config::cmiOnDeleteInstance
  259. '
  260. ' Returns False to disallow deletion, True to allow
  261. Function cmiOnDeleteInstance
  262. TraceEnter "DefProto::cmiOnDeleteInstance"
  263. TraceState "cmiThis.Comment", cmiThis.Comment
  264. cmiOnDeleteInstance = Not cmiThis.IsBaseComponent ' Cannot delete base
  265. TraceLeave "DefProto::cmiOnDeleteInstance"
  266. End Function
  267. '////////////////////////////////////////////////////////////////////////////
  268. ' Resource handlers
  269. '////////////////////////////////////////////////////////////////////////////
  270. '////////////////////////////////////////////////////////////////////////////
  271. ' cmiOnAddResource (virtual)
  272. ' Called from Config::cmiOnAddResource
  273. '
  274. ' oNewResource Resource being added to instance
  275. ' Returns True if resource added, else False (not added)
  276. Function cmiOnAddResource(oNewResource)
  277. TraceEnter "DefProto::cmiOnAddResource"
  278. TraceState "oNewResource.Name", oNewResource.Name
  279. cmiOnAddResource = oNewResource.Type.Script.cmiOnAddResource(cmiThis.Configuration, cmiThis, oNewResource)
  280. TraceLeave "DefProto::cmiOnAddResource"
  281. End Function
  282. '////////////////////////////////////////////////////////////////////////////
  283. ' cmiOnDeleteResource (virtual)
  284. ' Called from Config::cmiOnDeleteResource
  285. '
  286. ' oResource Resource being deleted from instance
  287. ' Returns True if resource deleted, else False
  288. Function cmiOnDeleteResource(oResource)
  289. TraceEnter "DefProto::cmiOnDeleteResource"
  290. TraceState "oResource.Name", oResource.Name
  291. cmiOnDeleteResource = oResource.Type.Script.cmiOnDeleteResource(cmiThis.Configuration, cmiThis, oResource)
  292. TraceLeave "DefProto::cmiOnDeleteResource"
  293. End Function
  294. '////////////////////////////////////////////////////////////////////////////
  295. ' cmiOnLoadResource (virtual)
  296. ' Called from Config::cmiOnLoadResource
  297. '
  298. ' oNewResource Resource being added to instance
  299. ' Returns True if resource added, else False (not added)
  300. Function cmiOnLoadResource(oNewResource)
  301. TraceEnter "DefProto::cmiOnLoadResource"
  302. TraceState "oNewResource.Name", oNewResource.Name
  303. cmiOnLoadResource = oNewResource.Type.Script.cmiOnLoadResource(cmiThis.Configuration, cmiThis, oNewResource)
  304. TraceLeave "DefProto::cmiOnLoadResource"
  305. End Function
  306. '////////////////////////////////////////////////////////////////////////////
  307. ' Build handlers
  308. '////////////////////////////////////////////////////////////////////////////
  309. '////////////////////////////////////////////////////////////////////////////
  310. ' cmiOnPreBuild and cmiOnPostBuild (virtual)
  311. ' Called from Config::cmiOnBuild
  312. '
  313. ' These routines are called before and after the build for each instance
  314. ' to allow special setup/teardown. The base instance is first in and
  315. ' last out but other instances are NOT ORDERED.
  316. Sub cmiOnPreBuild
  317. TraceEnter "DefProto::cmiOnPreBuild"
  318. TraceState "cmiThis.Comment", cmiThis.Comment
  319. TraceLeave "DefProto::cmiOnPreBuild"
  320. End Sub
  321. Sub cmiOnPostBuild
  322. TraceEnter "DefProto::cmiOnPostBuild"
  323. TraceState "cmiThis.Comment", cmiThis.Comment
  324. TraceLeave "DefProto::cmiOnPostBuild"
  325. End Sub
  326. '////////////////////////////////////////////////////////////////////////////
  327. ' cmiOnBuild (virtual)
  328. ' Called from Config::OnBuild
  329. '
  330. ' Each instance should build itself at this time. Individual cmiOnBuild
  331. ' calls are made against each instance in correct build order.
  332. Sub cmiOnBuild
  333. TraceEnter "DefProto::cmiOnBuild"
  334. TraceState "cmiThis.Comment", cmiThis.Comment
  335. Dim oRes, oProp, sOldHKR
  336. Set oProp = cmiThis.Properties("cmiHKRRoot") ' Get HKR root..
  337. If Not oProp Is Nothing Then
  338. sOldHKR = g_oCMIUtil.RelativeKey
  339. g_oCMIUtil.RelativeKey = oProp.Value
  340. End If
  341. cmiThis.Script.cmiOnBeginBuild ' Start instance build
  342. For Each oRes In cmiThis.Resources ' For each resource..
  343. cmiThis.Script.cmiOnBuildResource oRes ' ..build it
  344. Next
  345. cmiThis.Script.cmiOnEndBuild ' End instance build
  346. If Not oProp Is Nothing Then g_oCMIUtil.RelativeKey = sOldHKR
  347. TraceLeave "DefProto::cmiOnBuild"
  348. End Sub
  349. '////////////////////////////////////////////////////////////////////////////
  350. ' cmiOnBeginBuild and cmiOnEndBuild (virtual)
  351. ' Called from DefProto::cmiOnBuild
  352. Sub cmiOnBeginBuild
  353. TraceEnter "DefProto::cmiOnBeginBuild"
  354. TraceLeave "DefProto::cmiOnBeginBuild"
  355. End Sub
  356. Sub cmiOnEndBuild
  357. TraceEnter "DefProto::cmiOnEndBuild"
  358. TraceLeave "DefProto::cmiOnEndBuild"
  359. End Sub
  360. '////////////////////////////////////////////////////////////////////////////
  361. ' cmiOnBuildResource (virtual)
  362. ' Called from DefProto::cmiOnBuild
  363. '
  364. ' oResource Resource to build
  365. Sub cmiOnBuildResource(oResource)
  366. TraceEnter "DefProto::cmiOnBuildResource"
  367. TraceState "oResource.Name", oResource.Name
  368. If Not oResource.Disabled And (cmiThis.Configuration.BuildType And oResource.BuildTypeMask) Then
  369. cmiThis.Script.cmiOnBuildFilteredResource oResource
  370. End If
  371. TraceLeave "DefProto::cmiOnBuildResource"
  372. End Sub
  373. '////////////////////////////////////////////////////////////////////////////
  374. ' cmiOnBuildFilteredResource (virtual)
  375. ' Called from DefProt::cmiOnBuildResource
  376. '
  377. ' oResource Resource to build
  378. Sub cmiOnBuildFilteredResource(oResource)
  379. TraceEnter "DefProto::cmiOnBuildFilteredResource"
  380. TraceState "oResource.Name", oResource.Name
  381. g_oConfigScript.BuildResource cmiThis, oResource
  382. TraceLeave "DefProto::cmiOnBuildFilteredResource"
  383. End Sub
  384. '////////////////////////////////////////////////////////////////////////////
  385. ' Dependency checking handlers
  386. '////////////////////////////////////////////////////////////////////////////
  387. '////////////////////////////////////////////////////////////////////////////
  388. ' cmiAutoResolveDependencies
  389. ' Resolve all non-ambiguous dependencies for instance
  390. '
  391. ' Returns Edit array on commands to add/remove components
  392. Function cmiAutoResolveDependencies
  393. TraceEnter "DefProto::cmiAutoResolveDependencies"
  394. cmiAutoResolveDependencies = Array()
  395. TraceLeave "DefProto::cmiAutoResolveDependencies"
  396. End Function
  397. '////////////////////////////////////////////////////////////////////////////
  398. ' cmiOnCheckDependencies
  399. ' Check all include depencencies against current instances
  400. '
  401. ' oGUIDMember GUID membership dictionary
  402. Sub cmiOnCheckDependencies(oGUIDMember)
  403. TraceEnter "DefProto::cmiOnCheckDependencies"
  404. TraceState "cmiThis.Comment", cmiThis.Comment
  405. Dim oDep, nRet2
  406. ' Process each dependency (include class only)
  407. For Each oDep In cmiThis.Dependencies
  408. If oDep.Class = cmiInclude Then ' Only check include class
  409. nRet2 = ReportInfoStatus(Array(104, cmiThis.Index, oDep.Index), "... Dependency: " & oDep.Index & ", name: " & oDep.DisplayName)
  410. cmiThis.Script.cmiCheckDependency oDep, oGUIDMember
  411. End If
  412. Next
  413. TraceLeave "DefProto::cmiOnCheckDependencies"
  414. End Sub
  415. '////////////////////////////////////////////////////////////////////////////
  416. ' cmiCheckDependency
  417. ' Check individual include dependency for validity
  418. '
  419. ' To check a dependency, we need to discover how many instances are
  420. ' referenced by the target of the dependency. As with build, this involves
  421. ' converting one or more component GUIDs into instance indexes, which is
  422. ' done via the GUID member dictionary already built. This ensures that we
  423. ' correctly "see" the entire prototype chain of GUIDs as belonging to an
  424. ' instance. When resolving groups it's important to OR each vector first
  425. ' before counting instances to stop individual instances being counted twice.
  426. ' Once we have the match count, checking the dependency rule is trivial.
  427. '
  428. ' oDep Dependency to check
  429. ' oGUIDMember GUID membership dictionary
  430. Sub cmiCheckDependency(oDep, oGUIDMember)
  431. TraceEnter "DefProto::cmiCheckDependency"
  432. Dim oTarget, bGroupTarget, aVector, nMembers, oComp, aTemp, ix, iy
  433. Dim nMatchCount, nType, nReport, sTemp, nRet2
  434. ' Get the target object and check if it's a group or component
  435. Set oTarget = oDep.TargetObject ' Get target object
  436. If oTarget Is Nothing Then ' Target not in database
  437. nRet2 = ReportInfoStatus(Array(113, cmiThis.Index, oDep.Index), "Missing dependency target, instance: " & cmiThis.Comment & ", dependency: " & oDep.DisplayName)
  438. Exit Sub ' Nothing to check
  439. End If
  440. bGroupTarget = LCase(TypeName(oTarget)) = "group" ' Check for group
  441. nType = oDep.Type ' Get dependency type
  442. If nType = cmiFromGroup Then nType = oTarget.DefaultDependencyType
  443. ' For groups, we OR together each members vector, else just get the vector
  444. If bGroupTarget Then ' Count matching instances
  445. aVector = oGUIDMember.GetEmptyVector ' Clear vector
  446. nMembers = oTarget.GetMembers.Count ' Get membership count
  447. For Each oComp In oTarget.GetMembers ' For each component..
  448. aTemp = oGUIDMember.GetVector(oComp.VIGUID)
  449. If Not IsEmpty(aTemp) Then
  450. For ix = 1 To UBound(aTemp) ' Accumulate results
  451. aVector(ix) = aVector(ix) Or aTemp(ix)
  452. Next
  453. End If
  454. Next
  455. Else
  456. aVector = oGUIDMember.GetVector(oTarget.VIGUID)
  457. If IsEmpty(aVector) Then aVector = oGUIDMember.GetEmptyVector
  458. nMembers = 1 ' Single component target
  459. End If
  460. ' Now count the number of instances that match this dependency
  461. nMatchCount = 0 ' Clear match counter
  462. For ix = 1 To UBound(aVector)
  463. If aVector(ix) Then nMatchCount = nMatchCount + 1 ' Count matches
  464. Next
  465. ' Now check this result against the dependency requirements
  466. nReport = 0 ' Assume good result
  467. Select Case nType ' Check dependency type
  468. Case cmiExactlyOne ' Exactly one match
  469. If nMatchCount = 0 Then nReport = 112 ' Missing instance
  470. If nMatchCount > 1 Then nReport = 111 ' Too many instances
  471. Case cmiAtLeastOne ' At least one match
  472. If nMatchCount = 0 Then nReport = 112 ' Missing instance
  473. Case cmiZeroOrOne ' Zero or one match
  474. If nMatchCount > 1 Then nReport = 111 ' Too many instances
  475. Case cmiAll ' All match
  476. If nMatchCount < nMembers Then nReport = 112 ' Missing instance
  477. Case cmiNone ' No match (conflict)
  478. If nMatchCount > 0 Then nReport = 110 ' Conflicting instances
  479. End Select
  480. ' Finally, report discrepances
  481. If nReport <> 0 Then ' If discrepancy in dependency..
  482. Select Case nReport ' Process reports
  483. Case 110, 111 ' Conflicting or too many
  484. aTemp = Array() : ReDim aTemp(nMatchCount + 2)
  485. aTemp(0) = nReport ' Status code
  486. aTemp(1) = cmiThis.Index ' Instance index
  487. aTemp(2) = oDep.Index ' Dependency index
  488. iy = 3 ' List of conflicting instances
  489. For ix = 1 To UBound(aVector)
  490. If aVector(ix) Then aTemp(iy) = ix : iy = iy + 1
  491. Next
  492. If nReport = 110 Then
  493. nRet2 = ReportInfoStatus(aTemp, "Conflicting instance(s), instance: " & cmiThis.Comment & ", dependency: " & oDep.DisplayName)
  494. Else
  495. nRet2 = ReportInfoStatus(aTemp, "Too many instance(s), instance: " & cmiThis.Comment & ", dependency: " & oDep.DisplayName)
  496. End If
  497. Case 112 ' Missing instance(s)
  498. nRet2 = ReportInfoStatus(Array(112, cmiThis.Index, oDep.Index), "Required instance(s) missing, instance: " & cmiThis.Comment & ", dependency: " & oDep.DisplayName)
  499. End Select
  500. End If
  501. TraceLeave "DefProto::cmiCheckDependency"
  502. End Sub
  503. '////////////////////////////////////////////////////////////////////////////
  504. ' Platform script reflectors
  505. '////////////////////////////////////////////////////////////////////////////
  506. '////////////////////////////////////////////////////////////////////////////
  507. ' GetPropValue and GetPropValue2 reflectors
  508. Function GetPropValue(oProp, vCurrValue)
  509. GetPropValue = g_oConfigScript.GetPropValue(oProp, vCurrValue)
  510. End Function
  511. Function GetPropValue2(vRawValue, nFormat, vCurrValue)
  512. GetPropValue2 = g_oConfigScript.GetPropValue2(vRawValue, nFormat, vCurrValue)
  513. End Function
  514. '////////////////////////////////////////////////////////////////////////////
  515. ' ReportInfoStatus and ReportErrorStatus reflectors
  516. Function ReportInfoStatus(nCode, sText)
  517. ReportInfoStatus = g_oConfigScript.ReportInfoStatus(nCode, sText)
  518. End Function
  519. Function ReportErrorStatus(nError, sText)
  520. ReportErrorStatus = g_oConfigScript.ReportErrorStatus(nError, sText)
  521. End Function
  522. '////////////////////////////////////////////////////////////////////////////
  523. ' TraceExcept reflector
  524. Sub TraceExcept(nError, sText)
  525. g_oConfigScript.TraceExcept nError, sText
  526. End Sub
  527. '////////////////////////////////////////////////////////////////////////////
  528. ' TraceEnter and TraceLeave reflectors
  529. Sub TraceEnter(sProc)
  530. g_oConfigScript.TraceEnter sProc
  531. End Sub
  532. Sub TraceLeave(sProc)
  533. g_oConfigScript.TraceLeave sProc
  534. End Sub
  535. '////////////////////////////////////////////////////////////////////////////
  536. ' TraceState reflector
  537. Sub TraceState(sName, vValue)
  538. g_oConfigScript.TraceState sName, vValue
  539. End Sub
  540. '////////////////////////////////////////////////////////////////////////////
  541. ' TraceInfo reflector
  542. Sub TraceInfo(sText)
  543. g_oConfigScript.TraceInfo sText
  544. End Sub
  545. '////////////////////////////////////////////////////////////////////////////