Source code of Windows XP (NT5)
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.

107 lines
5.4 KiB

  1. <!--
  2. VBScript used to generate wival.inc from a Windows Installer schema.msi
  3. wival.inc is used by the candle compiler for the _Validation table
  4. data
  5. 2000/02/17 - created - [email protected]
  6. -->
  7. <job id='wi_compile'>
  8. <!-- main -->
  9. <script Language='VBScript'>
  10. 'Option Explicit
  11. Set fso = WScript.CreateObject("Scripting.FileSystemObject")
  12. Set ts = fso.CreateTextFile("wival.inc", True)
  13. Set Installer = WScript.CreateObject("WindowsInstaller.Installer")
  14. Set db = Installer.OpenDatabase("schema.msi", 0)
  15. Set vw = db.OpenView("SELECT * FROM `_Validation` ORDER BY `Table`")
  16. vw.Execute
  17. ts.WriteLine "'<script language='VBScript'>"
  18. ts.WriteLine "' wival.inc - Windows Installer _Validation table definitions"
  19. ts.WriteLine "'"
  20. ts.WriteLine "' " & Now & " - created - val.wsf (tool by [email protected])"
  21. ts.WriteLine "'"
  22. ts.WriteLine "' requires:"
  23. ts.WriteLine "' none"
  24. ts.WriteLine "'"
  25. ts.WriteLine "' entrypoints:"
  26. ts.WriteLine "' AddValidation"
  27. ts.WriteLine "'" & vbCrLf
  28. ts.WriteLine "Dim val_dicValidation : Set val_dicValidation = CreateObject(""Scripting.Dictionary"")"
  29. i = 0
  30. sTable = Empty
  31. Set rec = vw.Fetch
  32. Do Until rec Is Nothing
  33. If sTable <> rec.StringData(1) Then
  34. If Not IsEmpty(sTable) Then
  35. ts.WriteLine "Dim val_" & sTable & "(" & i - 1 & ")"
  36. ts.Write s
  37. ts.WriteLine "val_dicValidation.Add """ & sTable & """, val_" & sTable & vbCrLf
  38. End If
  39. i = 0
  40. s = ""
  41. sTable = rec.StringData(1)
  42. End If
  43. ' s = s & "val_" & sTable & "(" & i & ") = ""INSERT INTO `_Validation`(`Table`, `Column`, `Nullable`, `MinValue`, `MaxValue`, `KeyTable`, `KeyColumn`, `Category`, `Set`, `Description`) VALUES("
  44. ' s = s & "'" & rec.StringData(1) & "', '" & rec.StringData(2) & "', '" & rec.StringData(3) & "', " & rec.IntegerData(4) & ", " & rec.IntegerData(5) & ", '"
  45. ' s = s & rec.StringData(6) & "', " & rec.IntegerData(7) & ", '" & rec.StringData(8) & "', '" & rec.StringData(9) & "', '" & Replace(Replace(rec.StringData(10), """", """"""), "'", "") & "')""" & vbCrLf
  46. s = s & "val_" & sTable & "(" & i & ") = ""'" & rec.StringData(1) & "'&&'" & rec.StringData(2) & "'&&'" & rec.StringData(3) & "'&&'" & rec.StringData(4) & "'&&'" & rec.StringData(5)
  47. s = s & "'&&'" & rec.StringData(6) & "'&&'" & rec.StringData(7) & "'&&'" & rec.StringData(8) & "'&&'" & rec.StringData(9) & "'&&'" & Replace(rec.StringData(10), """", """""") & "'""" & vbCrLf
  48. ' s = s & "val_" & sTable & "_Table(" & i & ") = """ & rec.StringData(1) & """" & vbCrLf
  49. ' s = s & "val_" & sTable & "_Column(" & i & ") = """ & rec.StringData(2) & """" & vbCrLf
  50. ' s = s & "val_" & sTable & "_Nullable(" & i & ") = """ & rec.StringData(3) & """" & vbCrLf
  51. ' s = s & "val_" & sTable & "_MinValue(" & i & ") = """ & rec.StringData(4) & """" & vbCrLf
  52. ' s = s & "val_" & sTable & "_MaxValue(" & i & ") = """ & rec.StringData(5) & """" & vbCrLf
  53. ' s = s & "val_" & sTable & "_KeyTable(" & i & ") = """ & rec.StringData(6) & """" & vbCrLf
  54. ' s = s & "val_" & sTable & "_KeyColumn(" & i & ") = """ & rec.StringData(7) & """" & vbCrLf
  55. ' s = s & "val_" & sTable & "_Category(" & i & ") = """ & rec.StringData(8) & """" & vbCrLf
  56. ' s = s & "val_" & sTable & "_Set(" & i & ") = """ & rec.StringData(9) & """" & vbCrLf
  57. ' s = s & "val_" & sTable & "_Description(" & i & ") = """ & Replace(rec.StringData(10), """", """""") & """"' & vbCrLf
  58. i = i + 1
  59. Set rec = vw.Fetch
  60. Loop
  61. If Not IsEmpty(sTable) Then
  62. ts.WriteLine "Dim val_" & sTable & "(" & i - 1 & ")"
  63. ts.WriteLine s
  64. ts.WriteLine "val_dicValidation.Add """ & sTable & """, val_" & sTable
  65. End If
  66. ts.WriteLine vbCrLf & "Sub AddValidation(installer, db, sTable, fVerbose)"
  67. ts.WriteLine vbTab & "Dim vw, rec, arrSplit"
  68. ts.WriteLine vbTab & "' create the validation table if necessary"
  69. ts.WriteLine vbTab & "If db.TablePersistent(""_Validation"") = 2 Then"
  70. ts.WriteLine vbTab & vbTab & "Set vw = db.OpenView(""CREATE TABLE _Validation(`Table` CHAR(32) NOT NULL, `Column` CHAR(32) NOT NULL, `Nullable` CHAR(4) NOT NULL, `MinValue` LONG, `MaxValue` LONG, `KeyTable` CHAR(255), `KeyColumn` SHORT, `Category` CHAR(32), `Set` CHAR(255), `Description` CHAR(255) PRIMARY KEY `Table`, `Column`)"")"
  71. ts.WriteLine vbTab & vbTab & "vw.Execute"
  72. ts.WriteLine vbTab & vbTab & "AddValidation installer, db, ""_Validation"", fVerbose"
  73. ts.WriteLine vbTab & "End If"
  74. ts.WriteLine vbTab & "If val_dicValidation.Exists(sTable) Then"
  75. ts.WriteLine vbTab & vbTab & "Dim i, arTable : arTable = val_dicValidation.Item(sTable)"
  76. ts.WriteLine vbTab & vbTab & "Set vw = db.OpenView(""SELECT `Table`, `Column`, `Nullable`, `MinValue`, `MaxValue`, `KeyTable`, `KeyColumn`, `Category`, `Set`, `Description` FROM `_Validation`"")"
  77. ts.WriteLine vbTab & vbTab & "vw.Execute"
  78. ts.WriteLine vbTab & vbTab & "Set rec = installer.CreateRecord(10)"
  79. ts.WriteLine vbTab & vbTab & "For i = 0 To UBound(arTable)"
  80. ts.WriteLine vbTab & vbTab & vbTab & "If fVerbose Then WScript.Echo arTable(i)"
  81. ts.WriteLine vbTab & vbTab & vbTab & "arrSplit = Split(arTable(i), ""&&"")"
  82. ts.WriteLine vbTab & vbTab & vbTab & "For j = 0 To UBound(arrSplit)"
  83. ' ts.WriteLine vbTab & vbTab & vbTab & "db.OpenView(arTable(i)).Execute"
  84. ts.WriteLine vbTab & vbTab & vbTab & vbTab & "rec.StringData(j + 1) = Mid(arrSplit(j), 2, Len(arrSplit(j)) - 2)"
  85. ts.WriteLine vbTab & vbTab & vbTab & "Next"
  86. ts.WriteLine vbTab & vbTab & vbTab & "vw.Modify 1, rec"
  87. ts.WriteLine vbTab & vbTab & "Next"
  88. ts.WriteLine vbTab & "End If"
  89. ts.WriteLine "End Sub"
  90. </script>
  91. </job>