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.

133 lines
3.4 KiB

  1. Attribute VB_Name = "Main"
  2. Option Explicit
  3. Private Const HHC_C As String = "hhc"
  4. Private Const HTML_CLOSE_C As String = "</HTML>"
  5. Private Const QUOTED_NAME_C As String = """Name"""
  6. Private Const QUOTE_C As String = """"
  7. Private Const QUOTE_GT_C As String = """>"
  8. Private Const NOLOCENUTITLE_C As String = "<param name=""Comment"" value=""NoLocEnuTitle: "
  9. Public Sub MainFunction( _
  10. ByVal i_strFolder As String, _
  11. ByVal i_blnRecurse As Boolean _
  12. )
  13. On Error GoTo LError
  14. Dim FSO As Scripting.FileSystemObject
  15. Dim Folder As Scripting.Folder
  16. Dim File As Scripting.File
  17. Dim FolderSub As Scripting.Folder
  18. Set FSO = New Scripting.FileSystemObject
  19. If (Not FSO.FolderExists(i_strFolder)) Then
  20. Err.Raise E_FAIL, , "Folder " & i_strFolder & " does not exist"
  21. End If
  22. Set Folder = FSO.GetFolder(i_strFolder)
  23. For Each File In Folder.Files
  24. If (LCase$(FSO.GetExtensionName(File.Path)) = HHC_C) Then
  25. frmMain.Output "Processing " & File.Name, LOGGING_TYPE_NORMAL_E
  26. p_Process File, i_strFolder
  27. End If
  28. Next
  29. If (i_blnRecurse) Then
  30. For Each FolderSub In Folder.SubFolders
  31. MainFunction FolderSub.Path, i_blnRecurse
  32. Next
  33. End If
  34. LEnd:
  35. Exit Sub
  36. LError:
  37. frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E
  38. Err.Raise Err.Number
  39. End Sub
  40. Private Sub p_Process( _
  41. ByVal i_File As Scripting.File, _
  42. ByVal i_strFolder As String _
  43. )
  44. Dim Tokenizer As Tokenizer
  45. Dim arr() As String
  46. Dim str As String
  47. Dim strMatch As String
  48. Dim strNoLocEnuTitle As String
  49. str = FileRead(i_File.Path)
  50. str = p_ClearNoLocEnuTitle(str)
  51. Set Tokenizer = New Tokenizer
  52. Tokenizer.Init str
  53. ReDim arr(1)
  54. arr(0) = HTML_CLOSE_C
  55. arr(1) = QUOTED_NAME_C
  56. Tokenizer.NormalizeTokens arr
  57. str = ""
  58. Do
  59. str = str & Tokenizer.GetUpToClosestMatch(arr, strMatch)
  60. If (Len(strMatch) = 0 Or strMatch = HTML_CLOSE_C) Then
  61. Exit Do
  62. End If
  63. str = str & Tokenizer.GetUpTo(QUOTE_C)
  64. strNoLocEnuTitle = Tokenizer.GetUpTo(QUOTE_C, False)
  65. str = str & strNoLocEnuTitle & Tokenizer.GetUpTo(QUOTE_GT_C) & vbCrLf
  66. str = str & NOLOCENUTITLE_C & strNoLocEnuTitle & QUOTE_GT_C
  67. Loop
  68. If (Not FileWrite(i_strFolder & "\" & i_File.Name, str)) Then
  69. Err.Raise E_FAIL, , "File " & i_File.Name & " could not be saved"
  70. End If
  71. End Sub
  72. Function p_ClearNoLocEnuTitle( _
  73. ByVal i_str As String _
  74. ) As String
  75. Dim Tokenizer As Tokenizer
  76. Dim arr() As String
  77. Dim strChunk As String
  78. Dim strOutHhc As String
  79. Dim strMatch As String
  80. Dim intPosition As Long
  81. strOutHhc = ""
  82. Set Tokenizer = New Tokenizer
  83. Tokenizer.Init i_str
  84. ReDim arr(1)
  85. arr(0) = NOLOCENUTITLE_C
  86. arr(1) = HTML_CLOSE_C
  87. Tokenizer.NormalizeTokens arr
  88. Do
  89. strChunk = Tokenizer.GetUpToClosestMatch(arr, strMatch, False)
  90. strOutHhc = strOutHhc & strChunk
  91. If (Len(strChunk) = 0) Then
  92. strOutHhc = strOutHhc & HTML_CLOSE_C
  93. Exit Do
  94. End If
  95. Tokenizer.GetUpTo ">"
  96. Loop
  97. strOutHhc = Replace$(strOutHhc, vbCrLf & vbCrLf, vbCrLf)
  98. p_ClearNoLocEnuTitle = strOutHhc
  99. End Function